Skip to content

add secret decode diff #785

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 4 commits into from
May 24, 2025
Merged

add secret decode diff #785

merged 4 commits into from
May 24, 2025

Conversation

yxxhero
Copy link
Collaborator

@yxxhero yxxhero commented May 21, 2025

This pull request introduces several updates to the helm-diff plugin, including new features, enhanced functionality, and documentation improvements. The most notable changes include the addition of the --show-secrets-decoded flag, improvements to secret handling in diffs, and updates to the README.md for better clarity and accuracy.

New Features and Enhancements:

  • Added the --show-secrets-decoded flag to decode and display secret values in the diff output. This includes updates to diff.Options and the doDiff and contentSearch functions to handle the new flag. (cmd/options.go [1] diff/diff.go [2] [3] [4]
  • Improved error handling and logic in the redactSecrets function to ensure better handling of secrets during diff operations. (diff/diff.go [1] [2] [3] [4] [5]

Documentation Updates:

  • Enhanced the README.md with additional examples and corrected grammar for clarity. For instance, added examples for namespace-specific release comparisons and improved descriptions of flags like --dry-run and --suppress. [1] [2]
  • Added new flags to the documentation, such as --show-secrets-decoded, --set-json, and --set-literal, and clarified existing flag descriptions. [1] [2] [3]

Bug Fixes and Consistency:

  • Fixed duplicate entries and inconsistencies in the README.md for flags like --reset-then-reuse-values and --skip-schema-validation. [1] [2]
  • Corrected a typo in the "Additional help topics" section of the README.md.

These changes improve the functionality and usability of the plugin while ensuring the documentation is clear and up-to-date.

Signed-off-by: yxxhero <[email protected]>
@yxxhero yxxhero linked an issue May 21, 2025 that may be closed by this pull request
Signed-off-by: yxxhero <[email protected]>
@yxxhero yxxhero requested a review from mumoshu May 22, 2025 00:58
@yxxhero
Copy link
Collaborator Author

yxxhero commented May 22, 2025

@lucasfcnunes hi. could you try to use this branch?

@yxxhero yxxhero merged commit ab6f030 into master May 24, 2025
16 checks passed
Copy link
Contributor

@lucasfcnunes lucasfcnunes left a comment

Choose a reason for hiding this comment

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

Little too late @yxxhero but

# helmfile.yaml.gotmpl
repositories:
  - name: bedag
    url: https://bedag.github.io/helm-charts
---
releases:
  - chart: bedag/raw
    name: helmfile-diff
    namespace: lucasfcnunes-test
    values:
      - resources:
          - apiVersion: v1
            kind: Secret
            metadata:
              name: test-secret
            stringData:
              key2: value2
              key3: value3-stringData
            data:
              key1: '{{ "value1" | b64enc }}'
              key3: '{{ "value3-data" | b64enc }}'
              key4: '{{ "value4\na" | b64enc }}'
              key5: '{{ "value5\na\n" | b64enc }}'
              key6: '{{ "value6\na\n\n" | b64enc }}'
              key7: '{{ "value7\na\n\n\n" | b64enc }}'

on initial helm release (v1), the command helmfile diff --diff-args='--show-secrets-decoded' --debug gives the key3 on .data instead of the one on .stringData.

refs:

@yxxhero
Copy link
Collaborator Author

yxxhero commented May 24, 2025

@lucasfcnunes cool. got it. will fix that.

@rerime
Copy link

rerime commented May 27, 2025

@yxxhero Diff adds special characters in some cases:

template/_helpers.tpl

{{- define "json.definitions" -}}
{{ .Values.definitions.key1 | indent 4 }}
{{ .Values.definitions.key2 | indent 4 }}
{{- end -}}

values.yaml

definitions:
  key1: |-
    one
    two
  key2:  |-

Run

helm diff --context 3 --color --three-way-merge --normalize-manifests --show-secrets-decoded upgrade   --install \
test ./\
    -f ./values.yaml \
    -n test

Output broken (adds \n, brokes diff on huge files)
+ json: " one\n two\n "

Temp fix (trim whitespaces in template)

{{- define "json.definitions" -}}
{{ .Values.definitions.key1 | indent 4 -}}
{{ .Values.definitions.key2 | indent 4 -}}
{{- end -}}

@yxxhero
Copy link
Collaborator Author

yxxhero commented May 27, 2025

@rerime could you give me exampe that I can debug?

@rerime
Copy link

rerime commented May 27, 2025

test.zip
Zipped test chart with readme
@yxxhero

@yxxhero
Copy link
Collaborator Author

yxxhero commented May 28, 2025

@rerime got it. it's special case.

@yxxhero yxxhero deleted the add-decode-diff branch May 28, 2025 23:45
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.

Show helm diff secrets base64 decoded
4 participants