forked from fluxcd/flux2
-
Notifications
You must be signed in to change notification settings - Fork 0
build/diff: strip SOPS metadata from non-Secret resources (HelmRelease etc.) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0289b28
Changes before error encountered
Copilot 56e523b
Extend maskSopsData and add tests for SOPS HelmRelease support
Copilot c9db0cf
Add plan.md documenting SOPS HelmRelease work done and remaining
Copilot 0ce87fe
Add build-kustomization tests for SOPS HelmRelease and ConfigMap
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
cmd/flux/testdata/build-kustomization/sops-configmap-result.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| apiVersion: v1 | ||
| data: | ||
| api-key: ENC[AES256_GCM,data:abc123,iv:xyz,tag:tag,type:str] | ||
| kind: ConfigMap | ||
| metadata: | ||
| labels: | ||
| kustomize.toolkit.fluxcd.io/name: podinfo | ||
| kustomize.toolkit.fluxcd.io/namespace: {{ .fluxns }} | ||
| name: app-config | ||
| namespace: default | ||
| --- |
22 changes: 22 additions & 0 deletions
22
cmd/flux/testdata/build-kustomization/sops-configmap/configmap.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: app-config | ||
| namespace: default | ||
| data: | ||
| api-key: ENC[AES256_GCM,data:abc123,iv:xyz,tag:tag,type:str] | ||
| sops: | ||
| kms: [] | ||
| gcp_kms: [] | ||
| azure_kv: [] | ||
| hc_vault: [] | ||
| age: | ||
| - recipient: age10la2ge0wtvx3qr7datqf7rs4yngxszdal927fs9rukamr8u2pshsvtz7ce | ||
| enc: | | ||
| -----BEGIN AGE ENCRYPTED FILE----- | ||
| abc | ||
| -----END AGE ENCRYPTED FILE----- | ||
| lastmodified: "2023-07-15T00:00:00Z" | ||
| mac: ENC[AES256_GCM,data:mac,iv:iv,tag:tag,type:str] | ||
| encrypted_regex: ^(data)$ | ||
| version: 3.7.3 |
4 changes: 4 additions & 0 deletions
4
cmd/flux/testdata/build-kustomization/sops-configmap/kustomization.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| resources: | ||
| - ./configmap.yaml |
19 changes: 19 additions & 0 deletions
19
cmd/flux/testdata/build-kustomization/sops-helmrelease-result.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| apiVersion: helm.toolkit.fluxcd.io/v2 | ||
| kind: HelmRelease | ||
| metadata: | ||
| labels: | ||
| kustomize.toolkit.fluxcd.io/name: podinfo | ||
| kustomize.toolkit.fluxcd.io/namespace: {{ .fluxns }} | ||
| name: mysql | ||
| namespace: default | ||
| spec: | ||
| chart: | ||
| spec: | ||
| chart: mysql | ||
| sourceRef: | ||
| kind: HelmRepository | ||
| name: bitnami | ||
| values: | ||
| mysql: | ||
| rootPassword: ENC[AES256_GCM,data:abc123,iv:xyz,tag:tag,type:str] | ||
| --- |
30 changes: 30 additions & 0 deletions
30
cmd/flux/testdata/build-kustomization/sops-helmrelease/helmrelease.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| apiVersion: helm.toolkit.fluxcd.io/v2 | ||
| kind: HelmRelease | ||
| metadata: | ||
| name: mysql | ||
| namespace: default | ||
| spec: | ||
| chart: | ||
| spec: | ||
| chart: mysql | ||
| sourceRef: | ||
| kind: HelmRepository | ||
| name: bitnami | ||
| values: | ||
| mysql: | ||
| rootPassword: ENC[AES256_GCM,data:abc123,iv:xyz,tag:tag,type:str] | ||
| sops: | ||
| kms: [] | ||
| gcp_kms: [] | ||
| azure_kv: [] | ||
| hc_vault: [] | ||
| age: | ||
| - recipient: age10la2ge0wtvx3qr7datqf7rs4yngxszdal927fs9rukamr8u2pshsvtz7ce | ||
| enc: | | ||
| -----BEGIN AGE ENCRYPTED FILE----- | ||
| abc | ||
| -----END AGE ENCRYPTED FILE----- | ||
| lastmodified: "2023-07-15T00:00:00Z" | ||
| mac: ENC[AES256_GCM,data:mac,iv:iv,tag:tag,type:str] | ||
| encrypted_regex: ^(values)$ | ||
| version: 3.7.3 |
4 changes: 4 additions & 0 deletions
4
cmd/flux/testdata/build-kustomization/sops-helmrelease/kustomization.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| apiVersion: kustomize.config.k8s.io/v1beta1 | ||
| kind: Kustomization | ||
| resources: | ||
| - ./helmrelease.yaml |
17 changes: 17 additions & 0 deletions
17
cmd/flux/testdata/create_kustomization/with-sops-decryption.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| apiVersion: kustomize.toolkit.fluxcd.io/v1 | ||
| kind: Kustomization | ||
| metadata: | ||
| name: mysql | ||
| namespace: flux-system | ||
| spec: | ||
| decryption: | ||
| provider: sops | ||
| secretRef: | ||
| name: sops-age | ||
| interval: 1m0s | ||
| path: ./apps | ||
| prune: false | ||
| sourceRef: | ||
| kind: GitRepository | ||
| name: apps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The non-Secret branch detects SOPS by serializing the whole resource to YAML and doing substring checks. This adds per-resource overhead during build/diff and is also brittle (it depends on YAML rendering details like
mac: ENC[formatting). Consider doing a structured lookup on the root node instead (e.g., check for a top-levelsopsmapping and optionallysops.mac), then clear thesopsfield based on that, avoidingAsYAML()/bytes.Containsentirely.