compose/pkg/compose
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
..
testdata publish env_file references as opaque hash to prevent paths conflicts 2025-10-22 19:32:16 +02:00
transform Test to check writeComposeFile detects invalid OCI artifact 2025-10-22 20:09:32 +02:00
apiSocket.go Introduce abstractions to support SDK usage without requiring Docker CLI 2025-10-27 16:17:50 +01:00
attach.go (refactoring) introduce monitor to manage containers events and application termination 2025-07-16 17:24:11 +02:00
attach_service.go go ahead and wire up sig-proxy and no-stdin for consistency with underlying docker container attach 2024-01-08 17:15:11 -06:00
build.go stop progress UI during build to prevent interference with buildkit Display 2025-10-29 10:11:30 +01:00
build_bake.go fix typo in error message 2025-11-03 08:38:49 +01:00
build_buildkit.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
build_classic.go stop progress UI during build to prevent interference with buildkit Display 2025-10-29 10:11:30 +01:00
build_test.go select services implicitly declared by a service:xx build dependency 2025-05-05 10:20:19 +02:00
commit.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
compose.go add AlwaysOkPrompt to replace 'AlwaysYes' current implementation' 2025-11-03 08:01:59 +01:00
container.go pkg/compose: remove aliases for container-state consts 2025-09-08 11:52:28 +02:00
containers.go pkg/compose: use state consts from moby API 2025-09-08 11:52:28 +02:00
convergence.go fix various linting issues 2025-10-31 17:44:38 +01:00
convergence_test.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
convert.go e2e test for start_interval 2025-04-30 11:08:09 +02:00
cp.go fix various linting issues 2025-10-31 17:44:38 +01:00
create.go add AlwaysOkPrompt to replace 'AlwaysYes' current implementation' 2025-11-03 08:01:59 +01:00
create_test.go introduce networks.interface_name 2025-04-24 12:06:17 +02:00
dependencies.go remove utils.Contains to prefer slice.ContainsFunc 2025-05-27 15:16:50 +02:00
dependencies_test.go Set Required false to depends_on containers for compose -p stop/down 2024-04-11 10:48:09 +02:00
desktop.go remove unused code to only rely on api.Service 2025-10-20 14:53:04 +02:00
docker_cli_providers.go Introduce abstractions to support SDK usage without requiring Docker CLI 2025-10-27 16:17:50 +01:00
down.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
down_test.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
envresolver.go format code with gofumpt 2024-12-17 16:50:14 +01:00
envresolver_test.go ci: remove uses of deprecated gotest.tools v2 (#9935) 2022-11-07 14:07:41 -05:00
events.go feat: add since & until flags to events command 2025-07-09 10:08:33 +02:00
exec.go add a default statut messsage to exec error to avoid empty line display 2025-06-27 20:44:49 +02:00
export.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
filters.go detect network conflict as name is not guaranteed to be unique (#10612) 2023-05-31 14:46:23 -04:00
generate.go replace uses of golang.org/x/exp/(maps|slices) for stdlib 2025-06-02 10:43:17 +02:00
hash.go Recreate container on volume configuration change 2024-12-12 19:11:00 +01:00
hash_test.go adopt compose-go/v2 2023-12-05 18:54:31 +01:00
hook.go (refactoring) introduce monitor to manage containers events and application termination 2025-07-16 17:24:11 +02:00
image_pruner.go remove import aliases for containerd/errdefs 2025-07-21 15:51:39 +02:00
images.go Fix: use image created time when last tag time is not present 2025-08-27 09:03:58 +02:00
images_test.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
kill.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
kill_test.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
loader.go Add LoadProject method to Compose SDK API 2025-11-03 08:58:30 +01:00
loader_test.go Add LoadProject method to Compose SDK API 2025-11-03 08:58:30 +01:00
logs.go fix sigint/sigterm support in logs --follow 2025-09-07 14:19:56 +02:00
logs_test.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
ls.go refactor: use slices.Contains to simplify code 2025-05-27 11:45:26 +02:00
ls_test.go bump golangci-lint to version v2.0.2 2025-03-31 18:50:15 +02:00
model.go stop progress UI during build to prevent interference with buildkit Display 2025-10-29 10:11:30 +01:00
monitor.go fix various linting issues 2025-10-31 17:44:38 +01:00
pause.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
plugins.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
plugins_windows.go append .exe to provider name doing executable lookup on windows 2025-05-14 17:19:35 +02:00
port.go go.mod: docker/docker, docker/cli v28.0.0, buildx v0.21.1 2025-02-21 15:23:25 +01:00
printer.go detect container is restarted 2025-09-08 15:03:18 +02:00
ps.go use enum-consts for State and Health 2025-08-29 08:18:16 +02:00
ps_test.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
publish.go add AlwaysOkPrompt to replace 'AlwaysYes' current implementation' 2025-11-03 08:01:59 +01:00
publish_test.go Test to check writeComposeFile detects invalid OCI artifact 2025-10-22 20:09:32 +02:00
pull.go stop progress UI during build to prevent interference with buildkit Display 2025-10-29 10:11:30 +01:00
push.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
remove.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
restart.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
run.go lint fix 2025-10-29 10:47:18 +01:00
scale.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
secrets.go Compose can't create a tar with adequate uid:gid ownership 2025-10-20 09:51:58 +02:00
shellout.go Introduce abstractions to support SDK usage without requiring Docker CLI 2025-10-27 16:17:50 +01:00
start.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
stop.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
stop_test.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
suffix_unix.go append .exe to provider name doing executable lookup on windows 2025-05-14 17:19:35 +02:00
top.go review: move Summary/Replica collection from cmd/ to pkg/ 2025-03-13 14:23:51 +01:00
up.go skip Start[ed|ing] events to avpd mix with container logs 2025-10-29 10:11:30 +01:00
viz.go golangci-lint: enable copyloopvar linter 2025-02-10 13:46:41 +01:00
viz_test.go register TTYWritter as an Event Processor 2025-10-29 10:11:30 +01:00
volumes.go volume ls command can run without a project 2025-09-10 09:41:47 +02:00
volumes_test.go volume ls command can run without a project 2025-09-10 09:41:47 +02:00
wait.go Introduce abstractions to support SDK usage without requiring Docker CLI 2025-10-27 16:17:50 +01:00
watch.go Write error to watcher error channel if Start() fails 2025-10-06 14:50:19 +02:00
watch_test.go (refactoring) introduce monitor to manage containers events and application termination 2025-07-16 17:24:11 +02:00