Skip to content

Support file-based secrets in provider extensions - #14186

Open
NAVEENKUMARKR777 wants to merge 1 commit into
docker:mainfrom
NAVEENKUMARKR777:14163-provider-secrets-mounts
Open

Support file-based secrets in provider extensions#14186
NAVEENKUMARKR777 wants to merge 1 commit into
docker:mainfrom
NAVEENKUMARKR777:14163-provider-secrets-mounts

Conversation

@NAVEENKUMARKR777

Copy link
Copy Markdown

Summary

  • Provider extensions can currently only inject environment variables into dependent services (setenv/rawsetenv). Credentials are often better delivered as mounted files than env vars, which can leak through process inspection, debugging output, logs and crash reports.
  • Adds two new provider protocol messages, setsecret and rawsetsecret, mirroring setenv/rawsetenv: a provider can hand a dependent service a secret whose content is mounted at /run/secrets/<name>, without the compose file declaring it up front.
  • Fixes a latent bug in buildContainerSecretMounts: a secret with Content set (no File) wasn't skipped before building a bind mount, so it would bind-mount the process's working directory into the container. Provider-contributed secrets are content-based, so this fix is required for the new feature to behave correctly.
  • Documents the new message types in docs/extension.md and extends the example provider (docs/examples/provider.go) to emit them.

Test plan

  • go test ./pkg/compose/... — new unit tests for message parsing (TestExecutePlugin_ParsesSecretMessages) and the merge/dedup logic (TestUpsertProviderSecret)
  • golangci-lint run --build-tags e2e ./... — 0 issues
  • New e2e scenarios (TestProviderSetSecret, TestProviderRawSetSecretOverridesUserSecret) added but not run in this environment — no Docker daemon available. Please run go test -tags e2e ./pkg/e2e/ -run TestProviderSetSecret / TestProviderRawSetSecretOverridesUserSecret before merging.

Closes #14163

🤖 Generated with Claude Code

Provider extensions can currently only inject environment variables into
dependent services (setenv/rawsetenv), but credentials are often better
delivered as mounted files than env vars, which can leak through process
inspection, debugging output, logs and crash reports.

Add two new provider protocol messages, setsecret and rawsetsecret,
mirroring setenv/rawsetenv: a provider can now hand a dependent service a
secret whose content is mounted at /run/secrets/<name>, without the
compose file declaring it.

Also fixes a latent bug in buildContainerSecretMounts: a secret with
Content set (no File) was not skipped before building a bind mount, so it
would bind-mount the process's current working directory into the
container. Provider-contributed secrets are content-based, so this fix is
required for the new feature to behave correctly.

Closes docker#14163

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Naveenkumar <naveenkumarkr555@gmail.com>
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.

Support Mounts and Secrets in Compose Provider Extensions

1 participant