Skip to content

fix: detect and convert secrets in initContainers, not just containers - #56

Merged
bpradipt merged 1 commit into
confidential-devhub:mainfrom
esposem:secrets
Jul 14, 2026
Merged

bpradipt merged 1 commit into
confidential-devhub:mainfrom
esposem:secrets

Conversation

@esposem

@esposem esposem commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

DetectSecrets, ConvertEnvSecretToSealed, ConvertEnvFromSecret, and ReplaceSecretName only iterated over podSpec["containers"], so secrets referenced exclusively in initContainers were silently ignored and no sealed secret file was generated.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes secret detection and secret-name replacement for Kubernetes initContainers, ensuring secrets referenced only in initContainers are no longer silently ignored during secret processing/sealing workflows.

Changes:

  • Update secret detection (DetectSecrets) to scan both containers and initContainers.
  • Update manifest transformations (ReplaceSecretName, ConvertEnvSecretToSealed, ConvertEnvFromSecret) to operate on both containers and initContainers.
  • Add an integration manifest and tests covering initContainer env-secret detection and conversion.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/secrets/secrets.go Detect secrets and volume mount paths from both containers and initContainers.
pkg/manifest/manifest.go Apply secret reference transformations across containers and initContainers.
integration_test/testdata/manifests/pod-with-initcontainer-secrets.yaml New fixture manifest with a secret referenced only in an initContainer env var.
integration_test/secrets_test.go Add integration coverage for initContainer env-secret conversion and detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread integration_test/secrets_test.go
DetectSecrets, ConvertEnvSecretToSealed, ConvertEnvFromSecret, and
ReplaceSecretName only iterated over podSpec["containers"], so secrets
referenced exclusively in initContainers were silently ignored and no
sealed secret file was generated.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>

@bpradipt bpradipt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
Thanks @esposem

@bpradipt
bpradipt merged commit a0ae5f9 into confidential-devhub:main Jul 14, 2026
3 checks passed
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.

3 participants