feat: add kubernetes secret provider#2006
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds Kubernetes as a secrets provider: new config types and env bindings, loader updates, a kubernetes secrets resolver with client caching and kubeconfig/context handling, JSON schema additions, and tests updating/covering configuration and resolver behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant Reg as SecretsRegistry
participant KRes as KubernetesResolver
participant Cache as ClientCache
participant K8s as KubernetesAPI
App->>Reg: Request secret(ref)
activate Reg
Reg->>KRes: Lookup & Validate(ref)
activate KRes
KRes->>KRes: Parse ref (namespace/name/key, options)
KRes-->>Reg: Validation result
deactivate KRes
Reg->>KRes: Resolve(ctx, ref)
activate KRes
KRes->>KRes: Derive client settings (config + ref.options)
KRes->>Cache: getClient(settings)
activate Cache
Cache-->>KRes: client (cached or new)
deactivate Cache
KRes->>K8s: Get Secret(namespace, name)
activate K8s
K8s-->>KRes: Secret{data}
deactivate K8s
KRes->>KRes: Extract data key, format errors if missing/forbidden/not-found
KRes-->>Reg: SecretValue / error
deactivate KRes
Reg-->>App: SecretValue / error
deactivate Reg
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
9a196f8 to
9e82c0e
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/cmn/config/loader.go (1)
421-426: Normalize YAMLsecrets.kubernetes.kubeconfigpaths for parity with env loading.
DAGU_SECRETS_KUBERNETES_KUBECONFIGis treated as a path (Line 1657), but YAMLsecrets.kubernetes.kubeconfigis copied as-is. That creates inconsistent behavior for relative paths.Proposed patch
func (l *ConfigLoader) loadSecretsConfig(cfg *Config, def Definition) { if def.Secrets == nil { return } @@ if def.Secrets.Kubernetes != nil { + kubeconfig := def.Secrets.Kubernetes.Kubeconfig + if resolved, err := l.resolvePath("secrets.kubernetes.kubeconfig", kubeconfig); err == nil { + kubeconfig = resolved + } else if kubeconfig != "" { + l.warnings = append(l.warnings, err.Error()) + } + cfg.Secrets.Kubernetes = KubernetesSecretsConfig{ Namespace: def.Secrets.Kubernetes.Namespace, - Kubeconfig: def.Secrets.Kubernetes.Kubeconfig, + Kubeconfig: kubeconfig, Context: def.Secrets.Kubernetes.Context, } } }Also applies to: 1657-1657
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/cmn/config/loader.go` around lines 421 - 426, The YAML loader copies def.Secrets.Kubernetes.Kubeconfig into cfg.Secrets.Kubernetes as-is, causing inconsistent handling vs the env var path logic for DAGU_SECRETS_KUBERNETES_KUBECONFIG; update the mapping that sets cfg.Secrets.Kubernetes.Kubeconfig in loader.go to normalize/resolve the path the same way the env-loading code does (e.g., use the same helper or call path/filepath resolution to convert relative paths to an absolute/clean path) so KubernetesSecretsConfig.Kubeconfig receives a normalized path consistent with the env path handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/cmn/secrets/kubernetes.go`:
- Around line 91-93: The error currently reveals all secret keys by calling
getByteMapKeys(secret.Data) and including them in the error returned; remove
that sensitive enumeration and return a generic missing-key error instead (or
only include the available keys behind an explicit debug flag). Update the error
return in the kubernetes secret lookup (the block that references
parsed.dataKey, parsed.secretName, parsed.namespace and getByteMapKeys) to omit
strings.Join(available, ", ") so the message does not leak key names, or gate
that enumeration behind a debug/logging path rather than returning it in the
error.
---
Nitpick comments:
In `@internal/cmn/config/loader.go`:
- Around line 421-426: The YAML loader copies def.Secrets.Kubernetes.Kubeconfig
into cfg.Secrets.Kubernetes as-is, causing inconsistent handling vs the env var
path logic for DAGU_SECRETS_KUBERNETES_KUBECONFIG; update the mapping that sets
cfg.Secrets.Kubernetes.Kubeconfig in loader.go to normalize/resolve the path the
same way the env-loading code does (e.g., use the same helper or call
path/filepath resolution to convert relative paths to an absolute/clean path) so
KubernetesSecretsConfig.Kubeconfig receives a normalized path consistent with
the env path handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f3f0fa6d-b675-46cb-92ea-ad624c723d70
📒 Files selected for processing (9)
internal/cmn/config/config.gointernal/cmn/config/definition.gointernal/cmn/config/loader.gointernal/cmn/config/loader_test.gointernal/cmn/schema/config.schema.jsoninternal/cmn/secrets/kubernetes.gointernal/cmn/secrets/kubernetes_test.gointernal/cmn/secrets/resolver_test.gointernal/core/dag.go
9e82c0e to
7a1e051
Compare
Merged features from upstream: - feat: add embedded Dagu API (dagucloud#2011) - feat: add edit-and-retry DAG runs (dagucloud#2010) - feat: add bulk DAG-run deletion in web UI (dagucloud#2009) - feat: add kubernetes secret provider (dagucloud#2006) - feat: make workspace selection global (dagucloud#2015) - feat: show cockpit run artifacts (dagucloud#2017) - feat: allow disabling DAG retry policy (dagucloud#2018) - feat: make DAG labels canonical, deprecate tags (dagucloud#2013) - feat: add workflow design workspace (dagucloud#2012) - feat: add step with/config alias (dagucloud#2021) - fix: allow runtime custom step inputs (dagucloud#2005) - fix: align embedded engine run labels (dagucloud#2014) - Various CI/test/docs improvements Conflict resolution: - Kept fork i18n files (ui/src/i18n/, LanguageSwitcher) - Merged i18n hooks with upstream structural changes in App.tsx, Layout.tsx, menu.tsx, DAGStatus.tsx, etc. - Adopted upstream labels-over-tags rename (TagCombobox -> LabelCombobox)
Summary
secrets:entriesTesting
Summary by CodeRabbit