Skip to content

Commit 59f7768

Browse files
authored
Merge pull request #389 from Anthon129/master
add env var HELM_DIFF_NORMALIZE_MANIFESTS=true for flag --normalize-m…
2 parents 4b9da5c + 8eec5e1 commit 59f7768

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ Examples:
157157
# Read the flag usage below for more information on --three-way-merge.
158158
HELM_DIFF_THREE_WAY_MERGE=true helm diff upgrade my-release datadog/datadog
159159
160+
# Set HELM_DIFF_NORMALIZE_MANIFESTS=true to",
161+
# normalize the yaml file content when using helm diff.",
162+
# This is equivalent to specifying the --normalize-manifests flag.",
163+
# Read the flag usage below for more information on --normalize-manifests.",
164+
HELM_DIFF_NORMALIZE_MANIFESTS=true helm diff upgrade my-release datadog/datadog",
165+
160166
Flags:
161167
--allow-unreleased enables diffing of releases that are not yet deployed via Helm
162168
-a, --api-versions stringArray Kubernetes api versions used for Capabilities.APIVersions
@@ -172,7 +178,7 @@ Flags:
172178
--kube-version string Kubernetes version used for Capabilities.KubeVersion
173179
--kubeconfig string This flag is ignored, to allow passing of this top level flag to helm
174180
--no-hooks disable diffing of hooks
175-
--normalize-manifests normalize manifests before running diff to exclude style differences from the output
181+
--normalize-manifests normalize manifests before running diff to exclude style differences from the output, or use HELM_DIFF_NORMALIZE_MANIFESTS=true.
176182
--output string Possible values: diff, simple, json, template. When set to "template", use the env var HELM_DIFF_TPL to specify the template. (default "diff")
177183
--post-renderer string the path to an executable to be used for post rendering. If it exists in $PATH, the binary will be used, otherwise it will try to look for the executable at the given path
178184
--repo string specify the chart repository url to locate the requested chart
@@ -185,7 +191,7 @@ Flags:
185191
--strip-trailing-cr strip trailing carriage return on input
186192
--suppress stringArray allows suppression of the values listed in the diff output
187193
-q, --suppress-secrets suppress secrets in the output
188-
--three-way-merge use three-way-merge to compute patch and generate diff output
194+
--three-way-merge use three-way-merge to compute patch and generate diff output, or use HELM_DIFF_THREE_WAY_MERGE=true.
189195
-f, --values valueFiles specify values in a YAML file (can specify multiple) (default [])
190196
--version string specify the exact chart version to use. If this is not specified, the latest version is used
191197

cmd/upgrade.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ func newChartCommand() *cobra.Command {
106106
" # This is equivalent to specifying the --three-way-merge flag.",
107107
" # Read the flag usage below for more information on --three-way-merge.",
108108
" HELM_DIFF_THREE_WAY_MERGE=true helm diff upgarde my-release datadog/datadog",
109+
"",
110+
" # Set HELM_DIFF_NORMALIZE_MANIFESTS=true to",
111+
" # normalize the yaml file content when using helm diff.",
112+
" # This is equivalent to specifying the --normalize-manifests flag.",
113+
" # Read the flag usage below for more information on --normalize-manifests.",
114+
" HELM_DIFF_NORMALIZE_MANIFESTS=true helm diff upgrade my-release datadog/datadog",
109115
}, "\n"),
110116
Args: func(cmd *cobra.Command, args []string) error {
111117
return checkArgsLength(len(args), "release name", "chart path")
@@ -129,6 +135,15 @@ func newChartCommand() *cobra.Command {
129135
}
130136
}
131137

138+
if !diff.normalizeManifests && !cmd.Flags().Changed("normalize-manifests") {
139+
enabled := os.Getenv("HELM_DIFF_NORMALIZE_MANIFESTS") == "true"
140+
diff.normalizeManifests = enabled
141+
142+
if enabled {
143+
fmt.Println("Enabled normalize manifests via the envvar")
144+
}
145+
}
146+
132147
ProcessDiffOptions(cmd.Flags(), &diff.Options)
133148

134149
diff.release = args[0]

0 commit comments

Comments
 (0)