Skip to content

add env var HELM_DIFF_NORMALIZE_MANIFESTS=true for flag --normalize-m… #389

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 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,20 @@ Examples:
# Set HELM_DIFF_USE_UPGRADE_DRY_RUN=true to
# use `helm upgrade --dry-run` instead of `helm template` to render manifests from the chart.
# See https://github.com/databus23/helm-diff/issues/253 for more information.
HELM_DIFF_USE_UPGRADE_DRY_RUN=true helm diff upgarde my-release datadog/datadog
HELM_DIFF_USE_UPGRADE_DRY_RUN=true helm diff upgrade my-release datadog/datadog

# Set HELM_DIFF_THREE_WAY_MERGE=true to
# enable the three-way-merge on diff.
# This is equivalent to specifying the --three-way-merge flag.
# Read the flag usage below for more information on --three-way-merge.
HELM_DIFF_THREE_WAY_MERGE=true helm diff upgarde my-release datadog/datadog

# Set HELM_DIFF_NORMALIZE_MANIFESTS=true to",
# normalize the yaml file content when using helm diff.",
# This is equivalent to specifying the --normalize-manifests flag.",
# Read the flag usage below for more information on --normalize-manifests.",
HELM_DIFF_NORMALIZE_MANIFESTS=true helm diff upgrade my-release datadog/datadog",

Flags:
--allow-unreleased enables diffing of releases that are not yet deployed via Helm
-a, --api-versions stringArray Kubernetes api versions used for Capabilities.APIVersions
Expand All @@ -172,7 +178,7 @@ Flags:
--kube-version string Kubernetes version used for Capabilities.KubeVersion
--kubeconfig string This flag is ignored, to allow passing of this top level flag to helm
--no-hooks disable diffing of hooks
--normalize-manifests normalize manifests before running diff to exclude style differences from the output
--normalize-manifests normalize manifests before running diff to exclude style differences from the output, or use HELM_DIFF_NORMALIZE_MANIFESTS=true.
--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")
--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
--repo string specify the chart repository url to locate the requested chart
Expand All @@ -185,7 +191,7 @@ Flags:
--strip-trailing-cr strip trailing carriage return on input
--suppress stringArray allows suppression of the values listed in the diff output
-q, --suppress-secrets suppress secrets in the output
--three-way-merge use three-way-merge to compute patch and generate diff output
--three-way-merge use three-way-merge to compute patch and generate diff output, or use HELM_DIFF_THREE_WAY_MERGE=true.
-f, --values valueFiles specify values in a YAML file (can specify multiple) (default [])
--version string specify the exact chart version to use. If this is not specified, the latest version is used

Expand Down
15 changes: 15 additions & 0 deletions cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ func newChartCommand() *cobra.Command {
" # This is equivalent to specifying the --three-way-merge flag.",
" # Read the flag usage below for more information on --three-way-merge.",
" HELM_DIFF_THREE_WAY_MERGE=true helm diff upgarde my-release datadog/datadog",
"",
" # Set HELM_DIFF_NORMALIZE_MANIFESTS=true to",
" # normalize the yaml file content when using helm diff.",
" # This is equivalent to specifying the --normalize-manifests flag.",
" # Read the flag usage below for more information on --normalize-manifests.",
" HELM_DIFF_NORMALIZE_MANIFESTS=true helm diff upgrade my-release datadog/datadog",
}, "\n"),
Args: func(cmd *cobra.Command, args []string) error {
return checkArgsLength(len(args), "release name", "chart path")
Expand All @@ -129,6 +135,15 @@ func newChartCommand() *cobra.Command {
}
}

if !diff.normalizeManifests && !cmd.Flags().Changed("normalize-manifests") {
enabled := os.Getenv("HELM_DIFF_NORMALIZE_MANIFESTS") == "true"
diff.normalizeManifests = enabled

if enabled {
fmt.Println("Enabled normalize manifests via the envvar")
}
}

ProcessDiffOptions(cmd.Flags(), &diff.Options)

diff.release = args[0]
Expand Down