Skip to content

feat: add --store-sops-age-key flag to allow secret creation - #76

Merged
user-cube merged 5 commits into
mainfrom
feature/support-age-key
Aug 29, 2026
Merged

user-cube merged 5 commits into
mainfrom
feature/support-age-key

Conversation

@user-cube

Copy link
Copy Markdown
Owner

Add --store-sops-age-key to store the configured age private key as argocd/sops-age-key during bootstrap, allowing ArgoCD repo-server to decrypt SOPS-encrypted Helm values in-cluster. Update tests and bootstrap documentation.

@user-cube user-cube added documentation Improvements or additions to documentation enhancement New feature or request feature Auto-generated label for feature branches labels Aug 29, 2026
@user-cube
user-cube requested a lite review from Copilot August 29, 2026 22:22

Copilot AI 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.

🟢 Approval recommended

The feature is implemented end-to-end with CLI wiring, k8s client support, tests, and docs; remaining feedback is limited to minor error-message/diagnostic improvements.

Pull request overview

Adds an opt-in bootstrap flag to persist the configured SOPS age private key into the cluster as an argocd/sops-age-key Secret so ArgoCD repo-server (e.g., via helm-secrets) can decrypt SOPS-encrypted Helm values in-cluster.

Changes:

  • Add --store-sops-age-key flag and bootstrap flow to read the age key file and create/update argocd/sops-age-key.
  • Add Kubernetes client support + mock + unit test for creating/updating the sops-age-key Secret.
  • Update README and CLI bootstrap docs with usage and updated bootstrap step list.
File summaries
File Description
README.md Documents the new bootstrap option and updates the “This will” step list.
docs/cli/bootstrap.md Adds the new flag to CLI docs and provides an example invocation.
cluster-bootstrap-cli/internal/k8s/secrets.go Implements CreateSopsAgeKeySecret to create/update argocd/sops-age-key.
cluster-bootstrap-cli/internal/k8s/secrets_test.go Adds idempotency tests for the new Secret creation/update behavior.
cluster-bootstrap-cli/internal/k8s/client_mock.go Extends the mock client + interface to support CreateSopsAgeKeySecret.
cluster-bootstrap-cli/cmd/bootstrap.go Wires --store-sops-age-key into the bootstrap execution path.
cluster-bootstrap-cli/cmd/bootstrap_test.go Verifies the new flag defaults to opt-in (false).
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cluster-bootstrap-cli/internal/k8s/secrets.go
Comment thread cluster-bootstrap-cli/cmd/bootstrap.go Outdated

Copilot AI 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.

🟡 Changes recommended

There is an error-handling bug in runBootstrap where the wrapped bootstrapErr is not returned/reported, causing loss of context and inconsistent stage reporting.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread cluster-bootstrap-cli/cmd/bootstrap.go

Copilot AI 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.

🔵 Needs a closer look

The implementation looks sound, but the updated CLI docs are ambiguous/misleading about when secrets are created, and the #nosec suppression format may be inconsistent with the repo’s existing lint conventions.

Review details

Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

docs/cli/bootstrap.md:60

  • --age-key-file is documented as “(SOPS only)”, but it’s also required to supply the key data for --store-sops-age-key even when --encryption git-crypt is used. Update the flag descriptions to avoid misleading users.
| `--age-key-file` | `SOPS_AGE_KEY_FILE` env | Path to age private key (SOPS only) |
| `--store-sops-age-key` | `false` | Store the age private key from `--age-key-file` (or `SOPS_AGE_KEY_FILE`) as `sops-age-key` in `argocd`. Use when ArgoCD decrypts SOPS values in-cluster. |

cluster-bootstrap-cli/cmd/bootstrap.go:575

  • The #nosec directive here uses a comma-separated list (G304,G703), while other suppressions in this repo use a single rule ID. To reduce the chance of the directive not being recognized by your security/lint tooling, keep it consistent and only suppress the rule that applies to this call site.
	// The path is deliberately provided by the operator through a CLI flag or
	// SOPS_AGE_KEY_FILE; bootstrap must support age keys stored outside the repo.
	keyData, err := os.ReadFile(ageKeyFile) // #nosec G304,G703 -- explicit operator-controlled key path
	if err != nil {
		return false, fmt.Errorf("read SOPS age key file %s: %w", ageKeyFile, err)

docs/cli/bootstrap.md:19

  • The step list is a bit ambiguous about when each Secret is created; as written it can read like sops-age-key is always created during SOPS bootstrap. Clarify the exact flags/conditions so the docs match the implementation.
1. Loads secrets — decrypts via SOPS (default) or reads plaintext git-crypt files
2. Creates the `argocd` namespace
3. Creates the `repo-ssh-key` Secret with Git SSH credentials
4. Optionally creates `git-crypt-key` or `sops-age-key` Secrets for in-cluster decryption
5. When `--enable-cilium` is set, installs or upgrades Cilium and waits for Helm's workload readiness checks to pass
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@filipegalo filipegalo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM eheh

@user-cube
user-cube merged commit a914a52 into main Aug 29, 2026
8 checks passed
@user-cube
user-cube deleted the feature/support-age-key branch August 29, 2026 23:04
devopsbuddyapp Bot pushed a commit that referenced this pull request Aug 29, 2026
# [1.9.0](v1.8.0...v1.9.0) (2026-08-29)

### Features

* add --store-sops-age-key flag to allow secret creation ([#76](#76)) ([a914a52](a914a52))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request feature Auto-generated label for feature branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants