mirror of
https://github.com/docker/compose.git
synced 2025-11-17 12:20:30 +01:00
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>