Skip to content

Conversation

@glours
Copy link
Contributor

@glours glours commented Oct 29, 2025

What I did
introduces a new LoadProject method to the Compose API, enabling programmatic loading of Compose projects with full control over the loading process.

Related issue
#13230

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@glours glours requested a review from a team as a code owner October 29, 2025 18:06
@glours glours requested a review from ndeloof October 29, 2025 18:06
@glours glours self-assigned this Oct 29, 2025
@glours glours force-pushed the add-LoadProject-to-sdk branch 2 times, most recently from 915e976 to ee7bd60 Compare October 29, 2025 18:09
@glours glours force-pushed the add-LoadProject-to-sdk branch 2 times, most recently from bc45e72 to bf0a5ac Compare October 29, 2025 19:09
@glours glours changed the title Add load project to sdk Add load project to api definition Oct 29, 2025
@ndeloof ndeloof enabled auto-merge (rebase) November 3, 2025 07:06
@ndeloof ndeloof force-pushed the add-LoadProject-to-sdk branch from 2b5161c to 9af6576 Compare November 3, 2025 07:43
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 <[email protected]>
Simplifying the codebase and eliminating duplicate backend creation.

Signed-off-by: Guillaume Lours <[email protected]>
@ndeloof ndeloof force-pushed the add-LoadProject-to-sdk branch 2 times, most recently from 794f87c to 198b357 Compare November 3, 2025 07:45
@ndeloof ndeloof merged commit b80bb05 into docker:main Nov 3, 2025
23 checks passed
@ndeloof ndeloof deleted the add-LoadProject-to-sdk branch November 3, 2025 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants