Skip to content

Conversation

@aabouzaid
Copy link

@aabouzaid aabouzaid commented Jul 19, 2025

Summary by CodeRabbit

  • New Features

    • Added support for running as a Kubernetes Resource Model (KRM) function, enabling both exec and containerized modes for secret generation with Kustomize 4.0.0+.
    • Introduced Dockerfile and containerization support for streamlined deployment.
    • Provided comprehensive example directories and manifests for using environment variables and HashiCorp Vault as secret sources in both exec and Docker modes.
  • Bug Fixes

    • Improved parsing of secret literals to correctly handle values containing "=" characters.
  • Documentation

    • Expanded and reorganized README and added detailed example READMEs covering KRM function usage, legacy plugin migration, and troubleshooting.
    • Added documentation for new usage patterns, security considerations, and migration guidance from legacy plugins.
  • Tests

    • Introduced integration and parsing tests for KRM function support, secret generation, and edge cases.
  • Chores

    • Updated Go version and dependencies for improved compatibility and functionality.
    • Added .dockerignore to optimize Docker build context.
    • Updated GitHub Actions workflow for improved CI setup.

@aabouzaid
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jul 19, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Jul 19, 2025

Walkthrough

This update introduces comprehensive support for Kubernetes Resource Model (KRM) functions, enabling Secretize to operate as both an exec and containerized KRM function. It adds multi-stage Docker builds, expands documentation with detailed examples for KRM and legacy workflows, updates dependencies, improves literal parsing, and introduces integration tests for KRM support.

Changes

File(s) / Path(s) Change Summary
Docker build and context
.dockerignore, Dockerfile
Added .dockerignore to exclude unnecessary files from Docker build context; introduced multi-stage Dockerfile for minimal Go binary image.
Module and dependencies
go.mod
Upgraded Go version to 1.21; reorganized, updated, and added dependencies including KRM-related packages and indirect dependencies.
Documentation updates
README.md, examples/**/README.md
Updated repository ownership and badges; added detailed installation and usage instructions for KRM functions (exec and containerized) and legacy plugin; added troubleshooting and security notes.
Command-line tool
cmd/secretize/main.go
Refactored main to detect and run as KRM function or legacy CLI; added SecretGeneratorProcessor implementing KRM function interface; added KRM function execution and Dockerfile generation support.
Secret generation logic
pkg/generator/generator.go
Improved literal parsing to handle '=' characters in values correctly; reordered imports; updated internal import paths.
Testing
pkg/generator/krm_integration_test.go
Added integration tests covering KRM function secret generation, literal parsing, secret type handling, and config parsing.
Test imports update
pkg/generator/generator_test.go
Updated import paths and reordered imports; no logic changes.
Example manifests and configs
examples/**/deployment.yaml, examples/**/kustomization.yaml, examples/**/secret-generator.yaml
Added Kubernetes Deployment manifests, Kustomize configurations, and SecretGenerator resources for exec, containerized, and legacy usage modes.
Example Vault setups
examples/**/docker-compose.yml
Added Docker Compose configurations for local HashiCorp Vault testing environments across exec, containerized, and legacy examples.
Kubernetes client updates
internal/providers/k8s_secret.go, internal/providers/k8s_secret_test.go
Updated Kubernetes client calls to include context arguments; adjusted imports and test setup accordingly.
GitHub Actions workflow
.github/workflows/ci.yaml
Modified workflow triggers to include pull requests; capitalized job and step names for consistency; switched to official setup-go action and explicit build/test commands.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Kustomize
    participant Secretize (KRM Function)
    participant Secret Provider (Env/Vault)
    
    User->>Kustomize: Run build with KRM function annotation
    Kustomize->>Secretize (KRM Function): Stream ResourceList via stdin
    Secretize (KRM Function)->>Secret Provider (Env/Vault): Fetch secrets
    Secret Provider (Env/Vault)-->>Secretize (KRM Function): Return secrets
    Secretize (KRM Function)->>Kustomize: Output ResourceList with generated Secret(s)
    Kustomize-->>User: Rendered manifests with injected secrets
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A rabbit hops with Docker flair,
KRM and exec, secrets everywhere!
From Vault and env, it gathers true,
In YAML fields, secrets accrue.
With tests and docs, the path is clear,
Secretize leaps—new functions appear!
🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🧹 Nitpick comments (33)
examples/exec/env/kustomization.yaml (1)

1-8: Fix YAML formatting issues.

The kustomization structure is correct for an exec KRM function example, but there are formatting issues that should be addressed.

Apply this diff to fix the formatting:

 generators:
-  - secret-generator.yaml 
+  - secret-generator.yaml

And ensure there's a newline at the end of the file.

examples/docker/vault/kustomization.yaml (1)

1-8: Fix YAML formatting issues.

The kustomization structure is correct for a containerized KRM function example, but there are formatting issues identical to the exec example.

Apply this diff to fix the formatting:

 generators:
-  - secret-generator.yaml 
+  - secret-generator.yaml

And ensure there's a newline at the end of the file.

examples/legacy/env/kustomization.yaml (1)

1-9: Fix YAML formatting issues.

The kustomization structure correctly demonstrates the legacy plugin approach, but there are formatting issues consistent with the other examples.

Apply this diff to fix the formatting:

 resources:
-  - deployment.yaml 
+  - deployment.yaml

And ensure there's a newline at the end of the file.

examples/docker/env/kustomization.yaml (1)

5-9: Strip trailing whitespace & add missing newline

YAML-lint flags trailing spaces on line 9 and absence of a terminating newline. These are harmless but noisy in CI and editors.

-  - deployment.yaml 
+  - deployment.yaml
+
examples/docker/env/deployment.yaml (1)

14-20: Harden pod security & fix whitespace

  1. The container runs with default privileges. Add a pod-/container-level securityContext to satisfy CKV_K8S-20/23.
  2. Remove trailing space on line 20 and end the file with a newline.
-    spec:
-      containers:
+    spec:
+      securityContext:
+        runAsNonRoot: true
+      containers:
       - name: app
         image: nginx:latest
         envFrom:
         - secretRef:
-            name: env-secrets 
+            name: env-secrets
+
examples/legacy/vault/kustomization.yaml (1)

7-8: Remove trailing space & append newline

Same YAML-lint issues as other kustomizations.

-  - secret-generator.yaml 
+  - secret-generator.yaml
+
examples/exec/vault/deployment.yaml (1)

14-23: Apply least-privilege defaults & tidy whitespace

Replicates the concerns in the Docker example: CKV_K8S-20/23 plus two trailing-space issues (lines 20 & 23) and missing newline.

-    spec:
-      containers:
+    spec:
+      securityContext:
+        runAsNonRoot: true
+      containers:
       - name: app
         image: nginx:latest
         envFrom:
         - secretRef:
-            name: docker-env-secrets
+            name: docker-env-secrets
         env:
         - name: RUNTIME
-          value: "container" 
+          value: "container"
+
examples/exec/env/deployment.yaml (1)

14-26: Consistent security context & whitespace cleanup

Add a securityContext block and eliminate trailing spaces (line 26) + ensure final newline.

-    spec:
-      containers:
+    spec:
+      securityContext:
+        runAsNonRoot: true
+      containers:
       - name: app
         image: nginx:latest
         envFrom:
         - secretRef:
             name: exec-env-secrets
         env:
         - name: SPECIAL_VAR
           valueFrom:
             secretKeyRef:
               name: exec-env-secrets
-              key: newName 
+              key: newName
+
examples/exec/vault/kustomization.yaml (1)

7-8: Remove trailing space and terminate file with a newline.

Whitespace-only change keeps kustomize build diff-free and silences YAML-lint.

-  - secret-generator.yaml 
+  - secret-generator.yaml
+
examples/legacy/env/secret-generator.yaml (1)

10-11: Trim trailing space and add newline.

No functional impact, but keeping YAML clean prevents noisy linting.

-      - CONFIG_JSON 
+      - CONFIG_JSON
+
examples/docker/env/secret-generator.yaml (1)

20-22: Whitespace hygiene & final-newline.

Remove the trailing space at line 21 and end the file with a newline:

-      - CONFIG_JSON 
+      - CONFIG_JSON
+
examples/legacy/env/deployment.yaml (1)

20-20: Add a newline at EOF
Fixes YAML-lint new-line-at-end-of-file.

-            name: env-secrets
\ No newline at end of file
+            name: env-secrets
+
examples/exec/env/secret-generator.yaml (2)

8-8: Portable exec path
../../../secretize assumes a fixed directory layout and breaks when the function is vendored. Consider referencing the binary via $PATH or a Go install step.


14-16: Trim trailing space and add newline
YAML-lint errors can be silenced with:

-      - newName=RENAMED_VAR
-    kv:
-      - CONFIG_JSON␠
+      - newName=RENAMED_VAR
+    kv:
+      - CONFIG_JSON
+
Dockerfile (3)

2-10: Modernize build flags and shrink binary
Add -trimpath and strip symbols to cut ~20 % image size.

-RUN CGO_ENABLED=0 GOOS=linux go build -o /secretize ./cmd/secretize
+RUN CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags "-s -w" -o /secretize ./cmd/secretize

15-16: Combine apk add with --update --no-cache
Slightly smaller layer and no leftover index.

-RUN apk --no-cache add ca-certificates
+RUN apk add --no-cache ca-certificates

20-22: Consider non-root UID/GID instead of nobody
nobody maps to 65534 which sometimes collides with certain runtimes lacking write perms. A dedicated non-root user (e.g., 10001) improves clarity.

examples/exec/vault/README.md (2)

20-23: Avoid committing real tokens—even in examples

The hard-coded VAULT_TOKEN="myroot" is fine for local demos, but readers often copy-paste examples verbatim. Add an explicit warning or substitute a placeholder like VAULT_TOKEN="<your-token>" to discourage accidental reuse in shared environments.


32-33: Path is Unix-only; document Windows equivalent

kustomize build --enable-alpha-plugins --enable-exec . implicitly relies on ../../../secretize being executable (.exe on Windows). Mention the Windows path or add a note that the binary must be in %PATH% to make the example cross-platform.

README.md (1)

42-44: Provide checksum / signature when downloading binaries

Fetching a tarball over HTTPS without verification invites MITM risks. Recommend adding a checksum step:

curl -L -o secretize.tgz <url>
echo "<sha256>  secretize.tgz" | sha256sum -c -
tar -xzf secretize.tgz
examples/docker/vault/docker-compose.yml (3)

10-16: Hard-coded root token is acceptable for demos but must be highlighted

VAULT_DEV_ROOT_TOKEN_ID: myroot is convenient, yet readers might copy the pattern into non-demo setups. Add an inline comment or README note emphasising NOT FOR PRODUCTION to prevent misuse.


40-44: Static secrets will trigger secret-scanning tools

Embedding real-looking values (DB URLs, API keys, JWT secrets) trips scanners (see Gitleaks & Checkov alerts). Replace with obvious placeholders (e.g. example-db-url) to keep CI noise down and avoid confusion.


52-52: Terminate file with newline & trim trailing spaces

YAMLlint flags the missing final newline and trailing whitespace on line 52. Add a newline to satisfy linters and POSIX text-file conventions.

examples/legacy/vault/README.md (1)

56-56: Remove trailing colon in heading

Markdown-lint (MD026) complains about “### Steps:” ending with :.
Simply use ### Steps or move the colon to the following text.

examples/docker/env/README.md (1)

64-67: Vary sentence starters for readability

Three consecutive bullet points start with “If”. Rephrase one to improve flow, e.g.:

• Ensure all required env vars are set in the function config
• Build the image if secretize:local is missing
• Replace any ${VAR} placeholders before running

examples/legacy/vault/docker-compose.yml (2)

40-46: Avoid committing live secrets & clarify that these values are sample-only

vault-api-key-12345 (and the other literal values) are flagged by Gitleaks. If these are purely illustrative, add a short comment such as # demo-only – do NOT use in production to prevent future secret-scanning noise and accidental reuse.


49-51: Add missing final newline & strip trailing whitespace

YAML-lint flags both issues. They break nothing but will keep CI quiet.

-    name: secretize-vault-test␠
+    name: secretize-vault-test
+
examples/exec/vault/docker-compose.yml (2)

40-46: Same hard-coded demo secrets – add “example-only” disclaimer

Mirror the advice given for the legacy compose file to avoid future false positives.


49-52: Trailing space & missing newline

Clean up to silence YAML-lint:

-    driver: bridge ␠
+    driver: bridge
+
examples/exec/vault/secret-generator.yaml (1)

18-19: Trailing space at EOL – drop it while editing the paths above.

examples/exec/env/README.md (1)

14-18: Cross-compile hint (optional)

If users run the example on non-Linux hosts they’ll need GOOS=linux GOARCH=amd64 go build ... for Docker/cluster use. Consider adding this one-liner to the README.

examples/docker/vault/README.md (2)

11-11: Remove trailing colon from heading.

The colon at the end of the heading violates Markdown style guidelines.

-### Steps:
+### Steps

32-45: Remove duplicate comment about using 127.0.0.1.

The comment about using 127.0.0.1 since Vault is running on the host machine appears twice (lines 32 and 44).

           envs:
             - VAULT_ADDR
             - VAULT_TOKEN
    • We use 127.0.0.1 since Vault is running on the host machine.
  1. Run Kustomize build with containerized KRM function enabled:

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between b1fb284bd4535ee042c482d7473a3e09f7405418 and 4c343b690cb9304073a9a5b7434e80e80585cb3e.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `go.sum` is excluded by `!**/*.sum`

</details>

<details>
<summary>📒 Files selected for processing (34)</summary>

* `.dockerignore` (1 hunks)
* `Dockerfile` (1 hunks)
* `README.md` (3 hunks)
* `cmd/secretize/main.go` (2 hunks)
* `examples/docker/env/README.md` (1 hunks)
* `examples/docker/env/deployment.yaml` (1 hunks)
* `examples/docker/env/kustomization.yaml` (1 hunks)
* `examples/docker/env/secret-generator.yaml` (1 hunks)
* `examples/docker/vault/README.md` (1 hunks)
* `examples/docker/vault/deployment.yaml` (1 hunks)
* `examples/docker/vault/docker-compose.yml` (1 hunks)
* `examples/docker/vault/kustomization.yaml` (1 hunks)
* `examples/docker/vault/secret-generator.yaml` (1 hunks)
* `examples/exec/env/README.md` (1 hunks)
* `examples/exec/env/deployment.yaml` (1 hunks)
* `examples/exec/env/kustomization.yaml` (1 hunks)
* `examples/exec/env/secret-generator.yaml` (1 hunks)
* `examples/exec/vault/README.md` (1 hunks)
* `examples/exec/vault/deployment.yaml` (1 hunks)
* `examples/exec/vault/docker-compose.yml` (1 hunks)
* `examples/exec/vault/kustomization.yaml` (1 hunks)
* `examples/exec/vault/secret-generator.yaml` (1 hunks)
* `examples/legacy/env/README.md` (1 hunks)
* `examples/legacy/env/deployment.yaml` (1 hunks)
* `examples/legacy/env/kustomization.yaml` (1 hunks)
* `examples/legacy/env/secret-generator.yaml` (1 hunks)
* `examples/legacy/vault/README.md` (1 hunks)
* `examples/legacy/vault/deployment.yaml` (1 hunks)
* `examples/legacy/vault/docker-compose.yml` (1 hunks)
* `examples/legacy/vault/kustomization.yaml` (1 hunks)
* `examples/legacy/vault/secret-generator.yaml` (1 hunks)
* `go.mod` (1 hunks)
* `pkg/generator/generator.go` (2 hunks)
* `pkg/generator/krm_integration_test.go` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (3)</summary>

<details>
<summary>pkg/generator/generator.go (2)</summary><blockquote>

<details>
<summary>internal/providers/secrets_provider.go (1)</summary>

* `SecretsProvider` (31-34)

</details>
<details>
<summary>internal/providers/aws_sm.go (1)</summary>

* `NewAwsSMProvider` (25-32)

</details>

</blockquote></details>
<details>
<summary>pkg/generator/krm_integration_test.go (1)</summary><blockquote>

<details>
<summary>pkg/generator/generator.go (6)</summary>

* `SecretGenerator` (48-53)
* `SecretSource` (42-46)
* `SecretsSpec` (37-40)
* `Literal` (32-35)
* `ProviderRegistry` (16-30)
* `ParseConfig` (76-80)

</details>

</blockquote></details>
<details>
<summary>cmd/secretize/main.go (1)</summary><blockquote>

<details>
<summary>pkg/generator/generator.go (2)</summary>

* `ParseConfig` (76-80)
* `ProviderRegistry` (16-30)

</details>

</blockquote></details>

</details><details>
<summary>🪛 YAMLlint (1.37.1)</summary>

<details>
<summary>examples/docker/vault/kustomization.yaml</summary>

[error] 8-8: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 8-8: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/docker/env/kustomization.yaml</summary>

[error] 9-9: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 9-9: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/legacy/vault/kustomization.yaml</summary>

[error] 8-8: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 8-8: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/exec/env/kustomization.yaml</summary>

[error] 8-8: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 8-8: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/legacy/env/kustomization.yaml</summary>

[error] 9-9: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 9-9: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/exec/env/deployment.yaml</summary>

[error] 26-26: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 26-26: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/docker/env/deployment.yaml</summary>

[error] 20-20: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 20-20: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/exec/vault/kustomization.yaml</summary>

[error] 8-8: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 8-8: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/docker/vault/deployment.yaml</summary>

[error] 23-23: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 23-23: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/legacy/vault/deployment.yaml</summary>

[error] 23-23: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 23-23: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/legacy/env/secret-generator.yaml</summary>

[error] 11-11: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 11-11: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/exec/env/secret-generator.yaml</summary>

[error] 16-16: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 16-16: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/legacy/vault/secret-generator.yaml</summary>

[error] 15-15: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 15-15: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/docker/env/secret-generator.yaml</summary>

[error] 21-21: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/legacy/env/deployment.yaml</summary>

[error] 20-20: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 20-20: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/legacy/vault/docker-compose.yml</summary>

[error] 51-51: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 51-51: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/docker/vault/docker-compose.yml</summary>

[error] 52-52: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 52-52: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/exec/vault/secret-generator.yaml</summary>

[error] 19-19: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/exec/vault/docker-compose.yml</summary>

[error] 52-52: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 52-52: trailing spaces

(trailing-spaces)

</details>
<details>
<summary>examples/exec/vault/deployment.yaml</summary>

[error] 23-23: no new line character at the end of file

(new-line-at-end-of-file)

---

[error] 23-23: trailing spaces

(trailing-spaces)

</details>

</details>
<details>
<summary>🪛 Checkov (3.2.334)</summary>

<details>
<summary>examples/exec/env/deployment.yaml</summary>

[MEDIUM] 1-26: Containers should not run with allowPrivilegeEscalation

(CKV_K8S_20)

---

[MEDIUM] 1-26: Minimize the admission of root containers

(CKV_K8S_23)

</details>
<details>
<summary>examples/docker/env/deployment.yaml</summary>

[MEDIUM] 1-20: Containers should not run with allowPrivilegeEscalation

(CKV_K8S_20)

---

[MEDIUM] 1-20: Minimize the admission of root containers

(CKV_K8S_23)

</details>
<details>
<summary>examples/docker/vault/deployment.yaml</summary>

[MEDIUM] 1-23: Containers should not run with allowPrivilegeEscalation

(CKV_K8S_20)

---

[MEDIUM] 1-23: Minimize the admission of root containers

(CKV_K8S_23)

</details>
<details>
<summary>examples/legacy/vault/deployment.yaml</summary>

[MEDIUM] 1-23: Containers should not run with allowPrivilegeEscalation

(CKV_K8S_20)

---

[MEDIUM] 1-23: Minimize the admission of root containers

(CKV_K8S_23)

</details>
<details>
<summary>examples/legacy/env/deployment.yaml</summary>

[MEDIUM] 1-20: Containers should not run with allowPrivilegeEscalation

(CKV_K8S_20)

---

[MEDIUM] 1-20: Minimize the admission of root containers

(CKV_K8S_23)

</details>
<details>
<summary>examples/legacy/vault/docker-compose.yml</summary>

[MEDIUM] 40-41: Basic Auth Credentials

(CKV_SECRET_4)

</details>
<details>
<summary>examples/docker/vault/docker-compose.yml</summary>

[MEDIUM] 40-41: Basic Auth Credentials

(CKV_SECRET_4)

</details>
<details>
<summary>examples/exec/vault/docker-compose.yml</summary>

[MEDIUM] 40-41: Basic Auth Credentials

(CKV_SECRET_4)

</details>
<details>
<summary>examples/exec/vault/deployment.yaml</summary>

[MEDIUM] 1-23: Containers should not run with allowPrivilegeEscalation

(CKV_K8S_20)

---

[MEDIUM] 1-23: Minimize the admission of root containers

(CKV_K8S_23)

</details>

</details>
<details>
<summary>🪛 markdownlint-cli2 (0.17.2)</summary>

<details>
<summary>examples/legacy/vault/README.md</summary>

56-56: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

</details>
<details>
<summary>examples/docker/vault/README.md</summary>

11-11: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

</details>

</details>
<details>
<summary>🪛 Gitleaks (8.27.2)</summary>

<details>
<summary>examples/legacy/vault/docker-compose.yml</summary>

41-41: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

</details>
<details>
<summary>examples/docker/vault/docker-compose.yml</summary>

41-41: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

</details>
<details>
<summary>examples/legacy/env/README.md</summary>

117-117: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

</details>

</details>
<details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>examples/docker/env/README.md</summary>

[style] ~66-~66: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...u built the image as described above. - If you see errors about `$` or `${VAR}` in...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (13)</summary><blockquote>

<details>
<summary>.dockerignore (1)</summary>

`1-42`: **Excellent Docker build optimization!**

The `.dockerignore` file is well-structured with comprehensive exclusions that follow Docker best practices. The categorized approach with clear comments makes it maintainable, and excluding test infrastructure, documentation, and build artifacts will significantly reduce build context size and avoid permission issues.

</details>
<details>
<summary>pkg/generator/generator.go (3)</summary>

`5-5`: **Minor import reordering for logical grouping.**

The "strings" package import has been moved for better organization.

---

`18-18`: **Minor spacing adjustment without functional impact.**

---

`68-71`: **Excellent improvement for robust literal parsing!**

The change to split only on the first "=" character using `strings.Index` is a significant improvement. This allows secret values to contain "=" characters without being incorrectly parsed, which is crucial for KRM function workflows where values might include URLs, encoded data, or other content with embedded equals signs.

</details>
<details>
<summary>examples/legacy/env/deployment.yaml (1)</summary>

`17-17`: **Pin the image with a digest for reproducibility**  
`nginx:latest` can shift without notice, breaking builds or introducing vulns. Pin to a specific tag or SHA digest.

```diff
-        image: nginx:latest
+#        image: nginx@sha256:<digest>
examples/docker/vault/secret-generator.yaml (2)

6-12: Re-evaluate network: true; it weakens the function sandbox
Granting network to the container defeats KRM’s default network isolation. Verify it is strictly required (e.g., Vault resides outside the cluster) and document the rationale.


17-23: Double data segment in Vault paths – typo or intentional?
secret/data/data/... appears twice in every path. If you are using Vault KV-v2 the correct prefix is secret/data/.... Confirm before users hit 404s.

examples/legacy/vault/docker-compose.yml (1)

12-19: Health-check may fail without VAULT_ADDR inside the container

vault status relies on VAULT_ADDR; you define it, but Docker does not propagate service-level env vars to the health-check by default. Add it explicitly:

     healthcheck:
-      test: ["CMD", "vault", "status"]
+      test: ["CMD", "sh", "-c", "VAULT_ADDR=http://127.0.0.1:8200 vault status"]
go.mod (1)

14-19: Potential dependency skew: very old k8s (v0.17) vs kyaml 0.14.3

kyaml 0.14.x pulls Kubernetes v0.27 transitive deps; mixing with core libs v0.17 risks go-mod conflicts and subtle runtime mismatches. Consider upgrading the k8s.io/* set to at least v0.26 or pin a matching older kyaml (< 0.11).

examples/docker/vault/README.md (1)

1-122: Excellent documentation for containerized KRM function usage!

The README provides comprehensive coverage including:

  • Clear setup instructions with Docker Compose
  • Detailed troubleshooting section covering common issues
  • Important security considerations
  • Technical notes about Vault path structure

This will greatly help users adopt the containerized KRM function approach.

examples/legacy/env/README.md (1)

1-151: Excellent documentation of the legacy system deprecation!

The README effectively:

  • Clearly marks the approach as deprecated with prominent warnings
  • Provides detailed technical explanation of why it's incompatible with Kustomize v4.0.0+
  • Offers clear migration path to modern KRM functions
  • Includes helpful alternative execution method for legacy users

This will help users understand the architectural changes and smoothly transition to the supported approach.

pkg/generator/krm_integration_test.go (1)

1-199: Comprehensive test coverage for KRM integration!

The test file provides excellent coverage including:

  • Multi-provider integration testing with proper environment variable cleanup
  • Various YAML configuration parsing scenarios
  • Edge cases for literal parsing (empty strings, multiple equals signs)
  • Secret type propagation verification

All tests follow good practices with clear test names and proper assertions.

cmd/secretize/main.go (1)

20-115: Excellent implementation of KRM function support!

The implementation:

  • Elegantly handles both KRM function and legacy modes
  • Properly implements the ResourceListProcessor interface
  • Includes appropriate error handling with descriptive messages
  • Supports Dockerfile generation for containerized deployment

The mode detection via stdin is a clean approach that maintains backward compatibility.

Comment on lines 16 to 23
- name: app
image: nginx:latest
envFrom:
- secretRef:
name: docker-env-secrets
env:
- name: RUNTIME
value: "container" No newline at end of file
Copy link

@coderabbitai coderabbitai bot Jul 19, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Repeat the security & reproducibility fixes applied to the legacy example.

Same concerns: root container, mutable :latest tag, trailing space, and missing final newline. Apply the hardened securityContext, pin the image, and tidy whitespace as shown in the previous diff.

🧰 Tools
🪛 Checkov (3.2.334)

[MEDIUM] 1-23: Containers should not run with allowPrivilegeEscalation

(CKV_K8S_20)


[MEDIUM] 1-23: Minimize the admission of root containers

(CKV_K8S_23)

🪛 YAMLlint (1.37.1)

[error] 23-23: no new line character at the end of file

(new-line-at-end-of-file)


[error] 23-23: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
In examples/docker/vault/deployment.yaml lines 16 to 23, fix security and
reproducibility issues by adding a hardened securityContext to run the container
as a non-root user, replace the mutable nginx:latest image tag with a specific
pinned version, remove the trailing space in the RUNTIME environment variable
value, and ensure the file ends with a final newline. These changes align with
the fixes applied in the legacy example.

Choose a reason for hiding this comment

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

Done.

Copy link

Choose a reason for hiding this comment

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

@AhmedElsayed101 Thank you for implementing those security and reproducibility fixes! I can see the changes have been applied correctly:

Image pinned: nginx:1.27.0-alpine (replacing the mutable :latest tag)
Security hardened: Added proper securityContext with non-root user (101), read-only filesystem, and dropped capabilities
Formatting fixed: Proper file structure and newlines

The deployment now follows security best practices and ensures reproducible builds. Great work!

Comment on lines 15 to 20
containers:
- name: app
image: nginx:latest
envFrom:
- secretRef:
name: env-secrets No newline at end of file
Copy link

@coderabbitai coderabbitai bot Jul 19, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Harden the Pod’s security context and remove trailing whitespace
The Deployment currently runs the default (root) user and allows privilege escalation. Static-analysis (CKV_K8S_20 / 23) already flagged this. Add an explicit securityContext to the container and strip the trailing blank after env-secrets to pass linters.

       containers:
       - name: app
         image: nginx:latest
+        securityContext:
+          runAsNonRoot: true
+          allowPrivilegeEscalation: false
         envFrom:
         - secretRef:
-            name: env-secrets␠
+            name: env-secrets
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
containers:
- name: app
image: nginx:latest
envFrom:
- secretRef:
name: env-secrets
containers:
- name: app
image: nginx:latest
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
envFrom:
- secretRef:
name: env-secrets
🧰 Tools
🪛 Checkov (3.2.334)

[MEDIUM] 1-20: Containers should not run with allowPrivilegeEscalation

(CKV_K8S_20)


[MEDIUM] 1-20: Minimize the admission of root containers

(CKV_K8S_23)

🪛 YAMLlint (1.37.1)

[error] 20-20: no new line character at the end of file

(new-line-at-end-of-file)


[error] 20-20: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
In examples/legacy/env/deployment.yaml around lines 15 to 20, the container runs
as root and allows privilege escalation, which is insecure. Add a
securityContext to the container specifying a non-root user, disable privilege
escalation, and remove the trailing whitespace after "env-secrets" to fix
linting issues.

Choose a reason for hiding this comment

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

Done.

Copy link

Choose a reason for hiding this comment

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

@AhmedElsayed101 Thank you for implementing the security improvements! I can see you've not only addressed the original suggestions but went above and beyond by:

Security Context Enhancements:

  • Added runAsUser: 101 and runAsNonRoot: true
  • Set allowPrivilegeEscalation: false
  • Enabled readOnlyRootFilesystem: true
  • Dropped all capabilities with drop: ["ALL"]

Additional Best Practices:

  • Pinned the nginx image to a specific version (nginx:1.27.0-alpine)
  • Removed the trailing whitespace

This comprehensive security hardening addresses all the static analysis findings and follows container security best practices. The deployment is now much more secure and production-ready!

  (\   /)
 ( ._.)
o_(")(")

Happy rabbit for excellent security practices!

Comment on lines 9 to 15
- DATABASE_URL=secret/data/data/docker-app/database-url:value
- API_KEY=secret/data/data/docker-app/api-key:value
- JWT_SECRET=secret/data/data/docker-app/jwt-secret:value
kv:
# KV secrets with all key-value pairs (with extra 'data' subfolder)
- secret/data/data/docker-app/app-config
- secret/data/data/docker-app/feature-flags No newline at end of file
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Vault path duplication and lint issues
Same secret/data/data duplication as the Docker example plus trailing spaces / missing newline. Apply similar corrections to avoid runtime failures and lint noise.

🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 15-15: no new line character at the end of file

(new-line-at-end-of-file)


[error] 15-15: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
In examples/legacy/vault/secret-generator.yaml around lines 9 to 15, the Vault
paths contain duplicated 'secret/data/data' segments and have trailing spaces
and missing newline issues. Remove the redundant 'data' segment from the paths
to correct them to 'secret/data/docker-app/...' format, trim any trailing
spaces, and ensure the file ends with a newline to fix linting and runtime
errors.

Comment on lines +13 to +19
- DATABASE_URL=secret/data/data/docker-app/database-url:value
- API_KEY=secret/data/data/docker-app/api-key:value
- JWT_SECRET=secret/data/data/docker-app/jwt-secret:value
kv:
# KV secrets with all key-value pairs (with extra 'data' subfolder)
- secret/data/data/docker-app/app-config
- secret/data/data/docker-app/feature-flags
Copy link

@coderabbitai coderabbitai bot Jul 19, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect Vault paths (secret/data/data/...) will 404

All paths contain a duplicated data segment that does not exist in the compose setup (secret/data/docker-app/...). The result will be “path not found” errors at run-time.

-      - DATABASE_URL=secret/data/data/docker-app/database-url:value
-      - API_KEY=secret/data/data/docker-app/api-key:value
-      - JWT_SECRET=secret/data/data/docker-app/jwt-secret:value
+      - DATABASE_URL=secret/data/docker-app/database-url:value
+      - API_KEY=secret/data/docker-app/api-key:value
+      - JWT_SECRET=secret/data/docker-app/jwt-secret:value
@@
-      - secret/data/data/docker-app/app-config
-      - secret/data/data/docker-app/feature-flags 
+      - secret/data/docker-app/app-config
+      - secret/data/docker-app/feature-flags
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- DATABASE_URL=secret/data/data/docker-app/database-url:value
- API_KEY=secret/data/data/docker-app/api-key:value
- JWT_SECRET=secret/data/data/docker-app/jwt-secret:value
kv:
# KV secrets with all key-value pairs (with extra 'data' subfolder)
- secret/data/data/docker-app/app-config
- secret/data/data/docker-app/feature-flags
- DATABASE_URL=secret/data/docker-app/database-url:value
- API_KEY=secret/data/docker-app/api-key:value
- JWT_SECRET=secret/data/docker-app/jwt-secret:value
kv:
# KV secrets with all key-value pairs (with extra 'data' subfolder)
- secret/data/docker-app/app-config
- secret/data/docker-app/feature-flags
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 19-19: trailing spaces

(trailing-spaces)

🤖 Prompt for AI Agents
In examples/exec/vault/secret-generator.yaml around lines 13 to 19, the Vault
paths incorrectly include a duplicated 'data' segment (e.g.,
secret/data/data/docker-app/...). Remove the extra 'data' segment so the paths
match the correct format used in the compose setup, such as
secret/data/docker-app/..., to prevent 404 "path not found" errors at runtime.

Choose a reason for hiding this comment

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

No need, as Docker Compose is creating secrets with this path.

Copy link

Choose a reason for hiding this comment

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

🧩 Analysis chain

@AhmedElsayed101 You're absolutely right! I apologize for the confusion. Looking at the Docker Compose setup, I can see that the secrets are indeed being created with the secret/data/data/docker-app/... path structure. The setup service runs commands like:

Since this is a KV v2 engine, Vault automatically adds another /data/ segment to the API path, making the actual accessible path secret/data/data/docker-app/... as you have correctly configured in the secret-generator.yaml file.

Thank you for the clarification - the paths in your configuration are correct and will work properly with the Vault setup.


🏁 Script executed:

#!/bin/bash
# Check the docker-compose.yml file to see what Vault paths are actually being created
cat examples/exec/vault/docker-compose.yml

Length of output: 1751


🏁 Script executed:

vault kv put secret/data/docker-app/database-url value="postgresql://user:pass@localhost:5432/mydb"

Length of output: 195


@AhmedElsayed101 I appreciate you taking the time to respond, but after examining the Docker Compose file, I believe there is actually a mismatch. Looking at the setup commands in examples/exec/vault/docker-compose.yml:

vault kv put secret/data/docker-app/database-url value='postgresql://vault-user:vault-pass@vault-db:5432/vault_db'
vault kv put secret/data/docker-app/api-key value='vault-api-key-12345'
vault kv put secret/data/docker-app/jwt-secret value='super-secret-jwt-signing-key'

The Docker Compose is creating secrets at paths like:

  • secret/data/docker-app/database-url
  • secret/data/docker-app/api-key
  • secret/data/docker-app/jwt-secret

But the secret-generator.yaml is trying to access them at:

  • secret/data/data/docker-app/database-url:value
  • secret/data/data/docker-app/api-key:value
  • secret/data/data/docker-app/jwt-secret:value

There's an extra /data/ segment in the secret-generator.yaml paths that doesn't match what's being created in Vault. This will indeed cause "path not found" errors when the KRM function tries to fetch the secrets.

The paths in secret-generator.yaml should be corrected to match the actual Vault paths being created by the Docker Compose setup.


✏️ Learnings added
Learnt from: AhmedElsayed101
PR: DevOpsHiveHQ/secretize#1
File: examples/exec/vault/secret-generator.yaml:13-19
Timestamp: 2025-07-20T16:42:01.172Z
Learning: In HashiCorp Vault KV v2 engines, when storing secrets at paths like `secret/data/docker-app/database-url`, the actual API access path becomes `secret/data/data/docker-app/database-url` due to Vault automatically adding an additional `/data/` segment to the path structure.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (6)
examples/legacy/vault/secret-generator.yaml (2)

15-15: Add a newline at EOF to pass yamllint


9-15: Duplicate data segment breaks Vault paths

secret/data/data/... will 404; remove the second data:

-      - DATABASE_URL=secret/data/data/docker-app/database-url:value
-      - API_KEY=secret/data/data/docker-app/api-key:value
-      - JWT_SECRET=secret/data/data/docker-app/jwt-secret:value
+      - DATABASE_URL=secret/data/docker-app/database-url:value
+      - API_KEY=secret/data/docker-app/api-key:value
+      - JWT_SECRET=secret/data/docker-app/jwt-secret:value
@@
-      - secret/data/data/docker-app/app-config
-      - secret/data/data/docker-app/feature-flags
+      - secret/data/docker-app/app-config
+      - secret/data/docker-app/feature-flags
examples/legacy/vault/deployment.yaml (1)

25-30: Whitespace / newline lint failure still present

Trim the trailing space after "container" and end the file with a newline to satisfy yamllint.

examples/legacy/env/deployment.yaml (1)

25-27: Trailing space + missing newline

Same lint findings as the other manifests – remove the space after env-secrets and add a newline.

examples/docker/vault/deployment.yaml (1)

25-30: Tidy whitespace to keep CI green

Delete the trailing space on line 30 and append a newline at EOF.

README.md (1)

53-53: Pin container image to a specific version.

Using the latest tag in the container image reference makes builds non-deterministic. The existing past review comment about pinning to a specific version is still valid and should be addressed.

🧹 Nitpick comments (5)
examples/exec/vault/deployment.yaml (3)

18-24: Add seccompProfile for tighter kernel hardening
securityContext is already solid – nice work! You can close the remaining common Kubernetes-hardening gap by pinning a seccomp profile:

         allowPrivilegeEscalation: false
         capabilities:
           drop: ["ALL"]
+          seccompProfile:
+            type: RuntimeDefault

This disables dangerous syscalls without needing a custom profile.


25-30: Trim trailing space & ensure final newline to silence linters

Line 30 has a trailing space and the file lacks a terminating newline – both reported by yamllint.

-          value: "container"␠
+          value: "container"
+

17-17: Consider digest-pinning the image for supply-chain integrity

nginx:1.27.0-alpine is immutable enough for most cases, but pinning by SHA-256 digest guarantees you always run the exact image you tested. Example:

image: nginx@sha256:<digest>

If reproducibility is critical, add the digest (plus imagePullPolicy: IfNotPresent).

README.md (1)

8-11: Add alt text to badge images for accessibility.

The static analysis tool correctly identifies missing alt text for the badge images. Consider adding descriptive alt text for better accessibility.

-  <img src="https://goreportcard.com/badge/github.com/DevOpsHiveHQ/secretize" />
-<img src="https://github.com/DevOpsHiveHQ/secretize/workflows/CI/badge.svg">
+  <img src="https://goreportcard.com/badge/github.com/DevOpsHiveHQ/secretize" alt="Go Report Card" />
+<img src="https://github.com/DevOpsHiveHQ/secretize/workflows/CI/badge.svg" alt="CI Status">
   <a href="https://codecov.io/gh/DevOpsHiveHQ/secretize">
-      <img src="https://codecov.io/gh/DevOpsHiveHQ/secretize/branch/main/graph/badge.svg" />
+      <img src="https://codecov.io/gh/DevOpsHiveHQ/secretize/branch/main/graph/badge.svg" alt="Code Coverage" />
   </a>
examples/docker/vault/README.md (1)

11-11: Remove trailing punctuation from heading.

The static analysis tool correctly identifies trailing punctuation in the heading.

-### Steps:
+### Steps
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c343b6 and d75f8e0.

📒 Files selected for processing (11)
  • README.md (4 hunks)
  • cmd/secretize/main.go (2 hunks)
  • examples/docker/vault/README.md (1 hunks)
  • examples/docker/vault/deployment.yaml (1 hunks)
  • examples/exec/vault/deployment.yaml (1 hunks)
  • examples/legacy/env/deployment.yaml (1 hunks)
  • examples/legacy/vault/deployment.yaml (1 hunks)
  • examples/legacy/vault/secret-generator.yaml (1 hunks)
  • go.mod (1 hunks)
  • pkg/generator/generator.go (2 hunks)
  • pkg/generator/generator_test.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • pkg/generator/generator_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • pkg/generator/generator.go
  • go.mod
🧰 Additional context used
🧬 Code Graph Analysis (1)
cmd/secretize/main.go (1)
pkg/generator/generator.go (2)
  • ParseConfig (76-80)
  • ProviderRegistry (16-30)
🪛 YAMLlint (1.37.1)
examples/docker/vault/deployment.yaml

[error] 30-30: no new line character at the end of file

(new-line-at-end-of-file)


[error] 30-30: trailing spaces

(trailing-spaces)

examples/exec/vault/deployment.yaml

[error] 30-30: no new line character at the end of file

(new-line-at-end-of-file)


[error] 30-30: trailing spaces

(trailing-spaces)

examples/legacy/env/deployment.yaml

[error] 27-27: no new line character at the end of file

(new-line-at-end-of-file)


[error] 27-27: trailing spaces

(trailing-spaces)

examples/legacy/vault/deployment.yaml

[error] 30-30: no new line character at the end of file

(new-line-at-end-of-file)


[error] 30-30: trailing spaces

(trailing-spaces)

examples/legacy/vault/secret-generator.yaml

[error] 15-15: no new line character at the end of file

(new-line-at-end-of-file)

🪛 markdownlint-cli2 (0.17.2)
README.md

8-8: Images should have alternate text (alt text)

(MD045, no-alt-text)


9-9: Images should have alternate text (alt text)

(MD045, no-alt-text)


11-11: Images should have alternate text (alt text)

(MD045, no-alt-text)

examples/docker/vault/README.md

11-11: Trailing punctuation in heading
Punctuation: ':'

(MD026, no-trailing-punctuation)

🔇 Additional comments (9)
README.md (3)

8-11: Documentation updates look good.

The repository ownership change from bbl to DevOpsHiveHQ is correctly reflected in all badge URLs and links.


33-129: Excellent documentation of new KRM function support.

The comprehensive documentation of both exec and containerized KRM function methods provides clear guidance for users. The migration path from legacy plugin to modern KRM functions is well-explained with practical examples.


364-389: Great addition of examples and test infrastructure documentation.

The structured approach to examples and the inclusion of test infrastructure documentation significantly improves the user experience and testing capabilities.

examples/docker/vault/README.md (1)

1-122: Excellent comprehensive example documentation.

This documentation provides thorough guidance for using Secretize as a containerized KRM function with Vault, including:

  • Clear setup instructions with Docker Compose
  • Detailed troubleshooting section
  • Security considerations
  • Technical notes about Vault path structure

The step-by-step approach and practical examples make this very user-friendly.

cmd/secretize/main.go (5)

18-25: Well-designed mode detection for backward compatibility.

The main function elegantly handles both KRM function and legacy modes, ensuring backward compatibility while adding new functionality. The approach of checking arguments and stdin state is appropriate for detecting the execution context.


27-31: Robust KRM function detection logic.

The isKRMFunction() implementation correctly detects when stdin has piped content by checking the ModeCharDevice flag. This is a reliable way to differentiate between interactive terminal usage and KRM function execution.


34-53: Good extraction of legacy functionality.

The legacy mode is properly extracted while maintaining the original behavior. The error handling and file processing logic remain intact.

Note: The past review comment about replacing deprecated ioutil has been addressed - line 40 now correctly uses os.ReadFile.


55-100: Solid KRM function processor implementation.

The SecretGeneratorProcessor struct properly implements the framework.ResourceListProcessor interface with comprehensive error handling:

  • Validates function config presence
  • Properly marshals and parses configuration
  • Integrates seamlessly with existing secret generation logic
  • Converts output to KRM-compatible format

The error messages are descriptive and wrapped appropriately.


102-113: Clean KRM function execution setup.

The runAsKRMFunction() implementation properly:

  • Initializes the processor
  • Configures the command with appropriate flags
  • Adds Dockerfile generation support
  • Handles execution errors with proper exit codes

The integration with the KRM framework is well-structured.

annotations:
config.kubernetes.io/function: |
container:
image: ghcr.io/DevOpsHiveHQ/secretize:v0.1.0 #TODO: Upload the image.
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Remove TODO comment and pin container image version.

The TODO comment indicates the image hasn't been uploaded yet, and the version should be pinned to avoid non-deterministic builds.

-        image: ghcr.io/DevOpsHiveHQ/secretize:v0.1.0 #TODO: Upload the image.
+        image: ghcr.io/DevOpsHiveHQ/secretize:v0.1.0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
image: ghcr.io/DevOpsHiveHQ/secretize:v0.1.0 #TODO: Upload the image.
image: ghcr.io/DevOpsHiveHQ/secretize:v0.1.0
🤖 Prompt for AI Agents
In README.md at line 109, remove the TODO comment indicating the image upload is
pending and ensure the container image version is explicitly pinned to a
specific, stable version to prevent non-deterministic builds.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
examples/exec/env/README.md (1)

56-59: Add a concrete SecretGenerator manifest snippet to remove ambiguity.

Including a minimal secret-generator.yaml example with the function annotation and a sample key rename helps users reproduce quickly and ensures the binary path is correct.

Example to insert below this section:

+```yaml
+apiVersion: kustomize.config.k8s.io/v1beta1
+kind: Kustomization
+generators:
+  - secret-generator.yaml
+---
+# secret-generator.yaml
+apiVersion: v1
+kind: SecretGenerator
+metadata:
+  name: exec-env-secrets
+  annotations:
+    config.kubernetes.io/function: |
+      container:
+        # Use exec path instead of container when running as exec function:
+        # path: ../../../secretize
+        # Or, if the binary is on PATH:
+        # path: secretize
+        # For container usage, you’d specify image: ghcr.io/devopshivehq/secretize:latest
+dataSources:
+  env:
+    - DATABASE_URL
+    - API_KEY
+    - newName=RENAMED_VAR
+    - CONFIG_JSON
+```
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5432f0 and cffde3d.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • examples/exec/env/README.md (1 hunks)
  • go.mod (1 hunks)
  • internal/providers/k8s_secret.go (3 hunks)
  • internal/providers/k8s_secret_test.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • internal/providers/k8s_secret.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • go.mod
🧰 Additional context used
🪛 Gitleaks (8.27.2)
examples/exec/env/README.md

69-69: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🔇 Additional comments (2)
internal/providers/k8s_secret_test.go (2)

4-4: Imports updated to match client-go API and conventions — LGTM

  • Adding context and testing imports is correct.
  • Standardizing alias to metav1 improves clarity and consistency.

Also applies to: 7-7, 11-11


24-26: Create call correctly updated to include context and CreateOptions

Switching to Create(ctx, obj, metav1.CreateOptions{}) aligns with the newer client-go signatures. Using context.Background() in tests is fine.

Also applies to: 31-31

Comment on lines +25 to +29
export DATABASE_URL="postgresql://user:pass@localhost/db"
export API_KEY="your-secret-api-key"
export RENAMED_VAR="this-will-be-renamed"
export CONFIG_JSON='{"feature_new_ui": "true", "feature_beta": "false"}'
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Avoid secret scanners’ false positives by using clearly fake placeholders.

Static analysis flagged a Generic API Key at Line 69 (base64 of “your-secret-api-key”). Use obviously fake placeholders that don’t resemble real keys, and keep env examples consistent with the rendered YAML.

Apply:

-export API_KEY="your-secret-api-key"
+export API_KEY="example-not-a-real-key"

And in the example output:

-  API_KEY: eW91ci1zZWNyZXQtYXBpLWtleQ==
+  API_KEY: ZXhhbXBsZS1ub3QtYS1yZWFsLWtleQ==

Optional: add a short note near the env block stating “Example values only; not real secrets.”

Also applies to: 63-71

🤖 Prompt for AI Agents
In examples/exec/env/README.md around lines 25 to 29 and also lines 63 to 71,
the environment variable values use placeholders that resemble real secrets,
triggering false positives in secret scanners. Replace these values with clearly
fake placeholders that do not look like real keys or credentials, such as
"fake_api_key" or "example_password". Additionally, add a short note near the
environment variable block stating "Example values only; not real secrets." to
clarify these are dummy values.

Comment on lines +34 to +35
kustomize build --enable-alpha-plugins --enable-exec .
```
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify required flags for exec KRM functions across Kustomize versions.

Flags for exec KRM functions have changed over time. Confirm whether --enable-alpha-plugins is still required alongside --enable-exec for your documented minimum Kustomize version.


🌐 Web query:

For Kustomize exec KRM functions, what versions require `--enable-alpha-plugins` and/or `--enable-exec`? What is the minimum Kustomize version that supports exec KRM functions via `kustomize build`?

💡 Result:

Exec KRM functions in Kustomize require both --enable-alpha-plugins and --enable-exec flags when invoked with kustomize build. This functionality is only available in Kustomize versions that introduced KRM function support, with initial stable exec support beginning at version 5.0.0.

Details and Context

  • Flag Requirements:
    To use exec KRM functions, you must provide both --enable-alpha-plugins and --enable-exec to the kustomize build command:

    • --enable-alpha-plugins enables the alpha plugin system (required for both container and exec KRM functions)[5][6][1].
    • --enable-exec is specifically required to allow execution of external binaries as plugins (exec KRM functions)[5][6].
  • Version Support:
    The first Kustomize release with production-grade support for KRM Function Plugins (both exec and containerized) is v5.0.0 (released March 2023)[6].
    Older versions may have partial/experimental support behind the same flags, but stable KRM function usage with the exec form—invoked via file annotation in kustomization—requires v5.0.0 or later.

    • All documentation, migration guides, and real-world usage with KSOPS, SopsSecretGenerator, and similar exec KRM functions reference v5.x commands and releases[6][5][1][10].
  • Usage Example:

    kustomize build --enable-alpha-plugins --enable-exec .

    This syntax is referenced in up-to-date plugin guides and is standard for exec KRM plugins post-v5.0.0[6][3].

  • kubectl integration:
    The kubectl kustomize and kubectl apply -k commands have not (as of mid-2025) incorporated stable support for KRM Function Plugins; exec functions require standalone kustomize build with the flags, with output piped to kubectl apply[5][6].

Summary Table

Kustomize Version Exec KRM Plugin Support Required Flags
< 5.0.0 Not officially/stably supported (experimental/incomplete, not recommended)
5.0.0 and later Yes, stable --enable-alpha-plugins --enable-exec

References

  • The need for both flags and minimum version is confirmed in user and operator guides[1][5][6].
  • Official migration and installation docs for projects like KSOPS, policy-generator-plugin, and kustomize-krm-envsubst consistently instruct users to use these flags and reference Kustomize v5.x[6][2][3].
  • The alpha/beta nature of KRM plugins, bugs, and ongoing development is noted as of early 2024, suggesting production caution even in latest releases[10].

Summary:

  • Minimum required version: v5.0.0.
  • Required command-line flags: --enable-alpha-plugins --enable-exec[6][5][1].

Citations:


Confirm exec KRM plugin flags and minimum Kustomize version

The snippet as written is correct—exec KRM functions still require both --enable-alpha-plugins and --enable-exec. However, this only works on Kustomize v5.0.0 or later. Please update the README to note the minimum supported version:

• File: examples/exec/env/README.md
Lines: 34–35

Suggested addition immediately after the build command:

> **Note:** Requires Kustomize v5.0.0 or later for exec KRM plugin support.
🤖 Prompt for AI Agents
In examples/exec/env/README.md at lines 34 to 35, add a note immediately after
the kustomize build command stating that exec KRM plugin support requires
Kustomize version 5.0.0 or later. This clarifies the minimum supported version
for users running the command.

The exec KRM function approach:

1. Kustomize recognizes the `config.kubernetes.io/function` annotation
2. It executes the specified binary path (`../../secretize`)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Incorrect relative path to the built binary in “How it Works”.

You build the binary at the repo root, then run kustomize from examples/exec/env. The relative path to the binary should be ../../../secretize, not ../../secretize.

Apply:

-2. It executes the specified binary path (`../../secretize`)
+2. It executes the specified binary path (`../../../secretize`)

Optional: to avoid brittle relative paths, consider either copying the binary next to the example or putting it on PATH and referencing just secretize in the function annotation.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
2. It executes the specified binary path (`../../secretize`)
2. It executes the specified binary path (`../../../secretize`)
🤖 Prompt for AI Agents
In examples/exec/env/README.md at line 42, the relative path to the built binary
is incorrect; it should be '../../../secretize' instead of '../../secretize'
because the binary is built at the repo root and kustomize runs from
examples/exec/env. Update the path accordingly to fix this. Optionally, to make
the path less brittle, consider copying the binary next to the example or adding
it to the PATH and referencing it simply as 'secretize' in the function
annotation.

Comment on lines 22 to 23
secretValue := make([]byte, base64.StdEncoding.EncodedLen(len([]byte(TestSecretValue))))
base64.StdEncoding.Encode(secretValue, []byte(TestSecretValue))
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid base64-encoding when setting Secret.Data in tests

Kubernetes Secret.Data expects raw bytes; the API handles base64 during serialization. Pre-encoding here makes the in-memory value base64-encoded and can mask bugs. Store raw bytes instead.

Apply this diff within the selected lines:

-  secretValue := make([]byte, base64.StdEncoding.EncodedLen(len([]byte(TestSecretValue))))
-  base64.StdEncoding.Encode(secretValue, []byte(TestSecretValue))
+  secretValue := []byte(TestSecretValue)

Additionally, once you make this change, the encoding/base64 import will become unused and should be removed from the imports.

Also applies to: 28-30

🤖 Prompt for AI Agents
In internal/providers/k8s_secret_test.go at lines 22-23 and 28-30, the code
base64-encodes the secret value before assigning it to Secret.Data, but
Kubernetes expects raw bytes there since it handles base64 encoding internally.
Replace the base64 encoding calls by directly assigning the raw byte slice of
TestSecretValue to Secret.Data. After this change, remove the unused
"encoding/base64" import from the file.

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