Skip to content

Commit eb238a1

Browse files
authored
HELM_DIFF_THREE_WAY_MERGE=true to imply --three-way-merge (#336)
This adds a dedicated envvar to enable the three-way-merge diff added in #304. It should be useful when you are using helm-diff from another command or script and you dont have ability to specify the --three-way-merge flag without modifying the command/script but you cant due to various reasons.
1 parent 7486472 commit eb238a1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ Examples:
128128
# See https://github.com/databus23/helm-diff/issues/253 for more information.
129129
HELM_DIFF_USE_UPGRADE_DRY_RUN=true helm diff upgarde my-release datadog/datadog
130130
131+
# Set HELM_DIFF_THREE_WAY_MERGE=true to
132+
# enable the three-way-merge on diff.
133+
# This is equivalent to specifying the --three-way-merge flag.
134+
# Read the flag usage below for more information on --three-way-merge.
135+
HELM_DIFF_THREE_WAY_MERGE=true helm diff upgarde my-release datadog/datadog
136+
131137
Flags:
132138
--allow-unreleased enables diffing of releases that are not yet deployed via Helm
133139
-a, --api-versions stringArray Kubernetes api versions used for Capabilities.APIVersions

cmd/upgrade.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,16 @@ func newChartCommand() *cobra.Command {
9999
" # See https://github.com/databus23/helm-diff/issues/278 for more information.",
100100
" HELM_DIFF_IGNORE_UNKNOWN_FLAGS=true helm diff upgrade my-release stable/postgres --wait",
101101
"",
102-
" # Set HELM_DIFF_USE_UPGRADE_DRY_RUN=true to ",
102+
" # Set HELM_DIFF_USE_UPGRADE_DRY_RUN=true to",
103103
" # use `helm upgrade --dry-run` instead of `helm template` to render manifests from the chart.",
104104
" # See https://github.com/databus23/helm-diff/issues/253 for more information.",
105105
" HELM_DIFF_USE_UPGRADE_DRY_RUN=true helm diff upgarde my-release datadog/datadog",
106+
"",
107+
" # Set HELM_DIFF_THREE_WAY_MERGE=true to",
108+
" # enable the three-way-merge on diff.",
109+
" # This is equivalent to specifying the --three-way-merge flag.",
110+
" # Read the flag usage below for more information on --three-way-merge.",
111+
" HELM_DIFF_THREE_WAY_MERGE=true helm diff upgarde my-release datadog/datadog",
106112
}, "\n"),
107113
Args: func(cmd *cobra.Command, args []string) error {
108114
return checkArgsLength(len(args), "release name", "chart path")
@@ -117,6 +123,11 @@ func newChartCommand() *cobra.Command {
117123
// See https://github.com/databus23/helm-diff/issues/253
118124
diff.useUpgradeDryRun = os.Getenv("HELM_DIFF_USE_UPGRADE_DRY_RUN") == "true"
119125

126+
if !diff.threeWayMerge && !cmd.Flags().Changed("three-way-merge") {
127+
println("reading three way merge from env")
128+
diff.threeWayMerge = os.Getenv("HELM_DIFF_THREE_WAY_MERGE") == "true"
129+
}
130+
120131
if q, _ := cmd.Flags().GetBool("suppress-secrets"); q {
121132
diff.suppressedKinds = append(diff.suppressedKinds, "Secret")
122133
}
@@ -550,6 +561,8 @@ func deleteStatusAndTidyMetadata(obj []byte) (map[string]interface{}, error) {
550561

551562
delete(metadata, "managedFields")
552563

564+
// See the below for the goal of this metadata tidy logic.
565+
// https://github.com/databus23/helm-diff/issues/326#issuecomment-1008253274
553566
if a := metadata["annotations"]; a != nil {
554567
annotations := a.(map[string]interface{})
555568
delete(annotations, "meta.helm.sh/release-name")

0 commit comments

Comments
 (0)