compose/pkg/api
Guillaume Lours d74274bc04 Add LoadProject method to Compose SDK API
This commit adds a new LoadProject method to the Compose service API,
allowing SDK users to programmatically load Compose projects with full
control over the loading process.

Changes:

1. New API method (pkg/api/api.go):
   - LoadProject(ctx, ProjectLoadOptions) (*types.Project, error)
   - ProjectLoadOptions struct with all loader configuration
   - LoadListener callback for event notifications (metrics, etc.)
   - ProjectOptionsFns field for compose-go loader options

2. Implementation (pkg/compose/loader.go):
   - createRemoteLoaders: Git and OCI remote loader setup
   - buildProjectOptions: Translates ProjectLoadOptions to compose-go options
   - postProcessProject: Service filtering, labels, resource pruning

3. Unit test (pkg/compose/loader_test.go):
   - Tests basic project loading functionality
   - Verifies ProjectOptionsFns with cli.WithoutEnvironmentResolution

4. Mock update (pkg/mocks/mock_docker_compose_api.go):
   - Added LoadProject to mock interface

Key design decisions:
- LoadListener pattern keeps metrics collection in CLI, not SDK
- ProjectOptionsFns exposes compose-go options directly (e.g., cli.WithInterpolation(false))
- Post-processing in SDK: labels, service filtering, resource pruning
- Environment resolution NOT in SDK (command responsibility)
- Compatibility mode handling (api.Separator)

Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2025-11-03 08:58:30 +01:00
..
api.go Add LoadProject method to Compose SDK API 2025-11-03 08:58:30 +01:00
api_test.go adopt compose-go/v2 2023-12-05 18:54:31 +01:00
context.go Introduce abstractions to support SDK usage without requiring Docker CLI 2025-10-27 16:17:50 +01:00
dryrunclient.go Setup Compose service using functional parameters 2025-10-24 18:24:21 +02:00
errors.go deps: remove deprecated github.com/pkg/errors 2023-09-29 06:28:58 +02:00
errors_test.go deps: remove deprecated github.com/pkg/errors 2023-09-29 06:28:58 +02:00
labels.go deleted useless comment 2025-07-27 19:36:40 +02:00
labels_test.go fixed lint error 2025-07-27 19:36:40 +02:00