Skip to content

Commit f4351b3

Browse files
authored
Merge branch 'databus23:master' into plugin-install-mktemp
2 parents 2397668 + b8cb806 commit f4351b3

File tree

15 files changed

+238
-121
lines changed

15 files changed

+238
-121
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ install: build
2222
cp plugin.yaml $(HELM_HOME)/plugins/helm-diff/
2323

2424
.PHONY: install/helm3
25-
install/helm3:
25+
install/helm3: build
2626
mkdir -p $(HELM_3_PLUGINS)/helm-diff/bin
2727
cp bin/diff $(HELM_3_PLUGINS)/helm-diff/bin
2828
cp plugin.yaml $(HELM_3_PLUGINS)/helm-diff/

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,27 @@ E.g.
2828
curl -L $TARBALL_URL | tar -C $(helm home)/plugins -xzv
2929
```
3030

31+
### From Source
32+
#### Prerequisites
33+
- GoLang `>= 1.14`
34+
35+
Make sure you do not have a verison of `helm-diff` installed. You can remove it by running `helm plugin uninstall diff`
36+
37+
#### Installation Steps
38+
The first step is to download the repository and enter the directory. You can do this via `git clone` or downloaing and extracting the release. If you clone via git, remember to checkout the latest tag for the latest release.
39+
40+
Next, depending on which helm version you have, install the plugin into helm.
41+
42+
##### Helm 2
43+
```bash
44+
make install
45+
```
46+
47+
##### Helm 3
48+
```bash
49+
make install/helm3
50+
```
51+
3152

3253
## Usage
3354

@@ -103,6 +124,7 @@ Flags:
103124
--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
104125
--reset-values reset the values to the ones built into the chart and merge in any new values
105126
--reuse-values reuse the last release's values and merge in any new values
127+
--strip-trailing-cr strip trailing carriage return on input
106128
--set stringArray set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
107129
--suppress stringArray allows suppression of the values listed in the diff output
108130
-q, --suppress-secrets suppress secrets in the output
@@ -135,6 +157,7 @@ Flags:
135157
-h, --help help for release
136158
--home string location of your Helm config. Overrides $HELM_HOME (default "/home/aananth/.helm")
137159
--include-tests enable the diffing of the helm test hooks
160+
--strip-trailing-cr strip trailing carriage return on input
138161
--suppress stringArray allows suppression of the values listed in the diff output
139162
-q, --suppress-secrets suppress secrets in the output
140163
--tls enable TLS for request
@@ -157,7 +180,7 @@ This command compares the manifests details of a named release.
157180
158181
It can be used to compare the manifests of
159182
160-
- lastest REVISION with specified REVISION
183+
- latest REVISION with specified REVISION
161184
$ helm diff revision [flags] RELEASE REVISION1
162185
Example:
163186
$ helm diff revision my-release 2
@@ -172,6 +195,7 @@ Usage:
172195
173196
Flags:
174197
-h, --help help for revision
198+
--strip-trailing-cr strip trailing carriage return on input
175199
--suppress stringArray allows suppression of the values listed in the diff output
176200
-q, --suppress-secrets suppress secrets in the output
177201
@@ -197,6 +221,7 @@ Examples:
197221
198222
Flags:
199223
-h, --help help for rollback
224+
--strip-trailing-cr strip trailing carriage return on input
200225
--suppress stringArray allows suppression of the values listed in the diff output
201226
-q, --suppress-secrets suppress secrets in the output
202227

cmd/helm3.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func (d *diffCmd) template(isUpgrade bool) ([]byte, error) {
9292
if d.chartVersion != "" {
9393
flags = append(flags, "--version", d.chartVersion)
9494
}
95+
if d.chartRepo != "" {
96+
flags = append(flags, "--repo", d.chartRepo)
97+
}
9598
if d.namespace != "" {
9699
flags = append(flags, "--namespace", d.namespace)
97100
}

cmd/release.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ import (
1313
)
1414

1515
type release struct {
16-
client helm.Interface
17-
detailedExitCode bool
18-
suppressedKinds []string
19-
releases []string
20-
outputContext int
21-
includeTests bool
22-
showSecrets bool
23-
output string
16+
client helm.Interface
17+
detailedExitCode bool
18+
suppressedKinds []string
19+
releases []string
20+
outputContext int
21+
includeTests bool
22+
showSecrets bool
23+
output string
24+
stripTrailingCR bool
25+
normalizeManifests bool
2426
}
2527

2628
const releaseCmdLongUsage = `
@@ -79,6 +81,8 @@ func releaseCmd() *cobra.Command {
7981
releaseCmd.Flags().IntVarP(&diff.outputContext, "context", "C", -1, "output NUM lines of context around changes")
8082
releaseCmd.Flags().BoolVar(&diff.includeTests, "include-tests", false, "enable the diffing of the helm test hooks")
8183
releaseCmd.Flags().StringVar(&diff.output, "output", "diff", "Possible values: diff, simple, template. When set to \"template\", use the env var HELM_DIFF_TPL to specify the template.")
84+
releaseCmd.Flags().BoolVar(&diff.stripTrailingCR, "strip-trailing-cr", false, "strip trailing carriage return on input")
85+
releaseCmd.Flags().BoolVar(&diff.normalizeManifests, "normalize-manifests", false, "normalize manifests before running diff to exclude style differences from the output")
8286

8387
releaseCmd.SuggestionsMinimumDistance = 1
8488

@@ -115,12 +119,13 @@ func (d *release) differentiateHelm3() error {
115119

116120
if releaseChart1 == releaseChart2 {
117121
seenAnyChanges := diff.Releases(
118-
manifest.Parse(string(releaseResponse1), namespace, excludes...),
119-
manifest.Parse(string(releaseResponse2), namespace, excludes...),
122+
manifest.Parse(string(releaseResponse1), namespace, d.normalizeManifests, excludes...),
123+
manifest.Parse(string(releaseResponse2), namespace, d.normalizeManifests, excludes...),
120124
d.suppressedKinds,
121125
d.showSecrets,
122126
d.outputContext,
123127
d.output,
128+
d.stripTrailingCR,
124129
os.Stdout)
125130

126131
if d.detailedExitCode && seenAnyChanges {
@@ -149,12 +154,13 @@ func (d *release) differentiate() error {
149154

150155
if releaseResponse1.Release.Chart.Metadata.Name == releaseResponse2.Release.Chart.Metadata.Name {
151156
seenAnyChanges := diff.Releases(
152-
manifest.ParseRelease(releaseResponse1.Release, d.includeTests),
153-
manifest.ParseRelease(releaseResponse2.Release, d.includeTests),
157+
manifest.ParseRelease(releaseResponse1.Release, d.includeTests, d.normalizeManifests),
158+
manifest.ParseRelease(releaseResponse2.Release, d.includeTests, d.normalizeManifests),
154159
d.suppressedKinds,
155160
d.showSecrets,
156161
d.outputContext,
157162
d.output,
163+
d.stripTrailingCR,
158164
os.Stdout)
159165

160166
if d.detailedExitCode && seenAnyChanges {

cmd/revision.go

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ import (
1414
)
1515

1616
type revision struct {
17-
release string
18-
client helm.Interface
19-
detailedExitCode bool
20-
suppressedKinds []string
21-
revisions []string
22-
outputContext int
23-
includeTests bool
24-
showSecrets bool
25-
output string
17+
release string
18+
client helm.Interface
19+
detailedExitCode bool
20+
suppressedKinds []string
21+
revisions []string
22+
outputContext int
23+
includeTests bool
24+
showSecrets bool
25+
output string
26+
stripTrailingCR bool
27+
normalizeManifests bool
2628
}
2729

2830
const revisionCmdLongUsage = `
@@ -89,6 +91,8 @@ func revisionCmd() *cobra.Command {
8991
revisionCmd.Flags().IntVarP(&diff.outputContext, "context", "C", -1, "output NUM lines of context around changes")
9092
revisionCmd.Flags().BoolVar(&diff.includeTests, "include-tests", false, "enable the diffing of the helm test hooks")
9193
revisionCmd.Flags().StringVar(&diff.output, "output", "diff", "Possible values: diff, simple, template. When set to \"template\", use the env var HELM_DIFF_TPL to specify the template.")
94+
revisionCmd.Flags().BoolVar(&diff.stripTrailingCR, "strip-trailing-cr", false, "strip trailing carriage return on input")
95+
revisionCmd.Flags().BoolVar(&diff.normalizeManifests, "normalize-manifests", false, "normalize manifests before running diff to exclude style differences from the output")
9296

9397
revisionCmd.SuggestionsMinimumDistance = 1
9498

@@ -120,12 +124,13 @@ func (d *revision) differentiateHelm3() error {
120124
}
121125

122126
diff.Manifests(
123-
manifest.Parse(string(revisionResponse), namespace, excludes...),
124-
manifest.Parse(string(releaseResponse), namespace, excludes...),
127+
manifest.Parse(string(revisionResponse), namespace, d.normalizeManifests, excludes...),
128+
manifest.Parse(string(releaseResponse), namespace, d.normalizeManifests, excludes...),
125129
d.suppressedKinds,
126130
d.showSecrets,
127131
d.outputContext,
128132
d.output,
133+
d.stripTrailingCR,
129134
os.Stdout)
130135

131136
case 2:
@@ -146,12 +151,13 @@ func (d *revision) differentiateHelm3() error {
146151
}
147152

148153
seenAnyChanges := diff.Manifests(
149-
manifest.Parse(string(revisionResponse1), namespace, excludes...),
150-
manifest.Parse(string(revisionResponse2), namespace, excludes...),
154+
manifest.Parse(string(revisionResponse1), namespace, d.normalizeManifests, excludes...),
155+
manifest.Parse(string(revisionResponse2), namespace, d.normalizeManifests, excludes...),
151156
d.suppressedKinds,
152157
d.showSecrets,
153158
d.outputContext,
154159
d.output,
160+
d.stripTrailingCR,
155161
os.Stdout)
156162

157163
if d.detailedExitCode && seenAnyChanges {
@@ -185,12 +191,13 @@ func (d *revision) differentiate() error {
185191
}
186192

187193
diff.Manifests(
188-
manifest.ParseRelease(revisionResponse.Release, d.includeTests),
189-
manifest.ParseRelease(releaseResponse.Release, d.includeTests),
194+
manifest.ParseRelease(revisionResponse.Release, d.includeTests, d.normalizeManifests),
195+
manifest.ParseRelease(releaseResponse.Release, d.includeTests, d.normalizeManifests),
190196
d.suppressedKinds,
191197
d.showSecrets,
192198
d.outputContext,
193199
d.output,
200+
d.stripTrailingCR,
194201
os.Stdout)
195202

196203
case 2:
@@ -211,12 +218,13 @@ func (d *revision) differentiate() error {
211218
}
212219

213220
seenAnyChanges := diff.Manifests(
214-
manifest.ParseRelease(revisionResponse1.Release, d.includeTests),
215-
manifest.ParseRelease(revisionResponse2.Release, d.includeTests),
221+
manifest.ParseRelease(revisionResponse1.Release, d.includeTests, d.normalizeManifests),
222+
manifest.ParseRelease(revisionResponse2.Release, d.includeTests, d.normalizeManifests),
216223
d.suppressedKinds,
217224
d.showSecrets,
218225
d.outputContext,
219226
d.output,
227+
d.stripTrailingCR,
220228
os.Stdout)
221229

222230
if d.detailedExitCode && seenAnyChanges {

cmd/rollback.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ import (
1414
)
1515

1616
type rollback struct {
17-
release string
18-
client helm.Interface
19-
detailedExitCode bool
20-
suppressedKinds []string
21-
revisions []string
22-
outputContext int
23-
includeTests bool
24-
showSecrets bool
25-
output string
17+
release string
18+
client helm.Interface
19+
detailedExitCode bool
20+
suppressedKinds []string
21+
revisions []string
22+
outputContext int
23+
includeTests bool
24+
showSecrets bool
25+
output string
26+
stripTrailingCR bool
27+
normalizeManifests bool
2628
}
2729

2830
const rollbackCmdLongUsage = `
@@ -81,6 +83,8 @@ func rollbackCmd() *cobra.Command {
8183
rollbackCmd.Flags().IntVarP(&diff.outputContext, "context", "C", -1, "output NUM lines of context around changes")
8284
rollbackCmd.Flags().BoolVar(&diff.includeTests, "include-tests", false, "enable the diffing of the helm test hooks")
8385
rollbackCmd.Flags().StringVar(&diff.output, "output", "diff", "Possible values: diff, simple, template. When set to \"template\", use the env var HELM_DIFF_TPL to specify the template.")
86+
rollbackCmd.Flags().BoolVar(&diff.stripTrailingCR, "strip-trailing-cr", false, "strip trailing carriage return on input")
87+
rollbackCmd.Flags().BoolVar(&diff.normalizeManifests, "normalize-manifests", false, "normalize manifests before running diff to exclude style differences from the output")
8488

8589
rollbackCmd.SuggestionsMinimumDistance = 1
8690

@@ -113,12 +117,13 @@ func (d *rollback) backcastHelm3() error {
113117

114118
// create a diff between the current manifest and the version of the manifest that a user is intended to rollback
115119
seenAnyChanges := diff.Manifests(
116-
manifest.Parse(string(releaseResponse), namespace, excludes...),
117-
manifest.Parse(string(revisionResponse), namespace, excludes...),
120+
manifest.Parse(string(releaseResponse), namespace, d.normalizeManifests, excludes...),
121+
manifest.Parse(string(revisionResponse), namespace, d.normalizeManifests, excludes...),
118122
d.suppressedKinds,
119123
d.showSecrets,
120124
d.outputContext,
121125
d.output,
126+
d.stripTrailingCR,
122127
os.Stdout)
123128

124129
if d.detailedExitCode && seenAnyChanges {
@@ -149,12 +154,13 @@ func (d *rollback) backcast() error {
149154

150155
// create a diff between the current manifest and the version of the manifest that a user is intended to rollback
151156
seenAnyChanges := diff.Manifests(
152-
manifest.ParseRelease(releaseResponse.Release, d.includeTests),
153-
manifest.ParseRelease(revisionResponse.Release, d.includeTests),
157+
manifest.ParseRelease(releaseResponse.Release, d.includeTests, d.normalizeManifests),
158+
manifest.ParseRelease(revisionResponse.Release, d.includeTests, d.normalizeManifests),
154159
d.suppressedKinds,
155160
d.showSecrets,
156161
d.outputContext,
157162
d.output,
163+
d.stripTrailingCR,
158164
os.Stdout)
159165

160166
if d.detailedExitCode && seenAnyChanges {

cmd/root.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
package cmd
22

33
import (
4+
"os"
5+
46
"github.com/mgutz/ansi"
57
"github.com/spf13/cobra"
8+
"golang.org/x/crypto/ssh/terminal"
69
)
710

811
const rootCmdLongUsage = `
@@ -40,6 +43,8 @@ func New() *cobra.Command {
4043
PersistentPreRun: func(cmd *cobra.Command, args []string) {
4144
if nc, _ := cmd.Flags().GetBool("no-color"); nc {
4245
ansi.DisableColors(true)
46+
} else if !cmd.Flags().Changed("no-color") {
47+
ansi.DisableColors(!terminal.IsTerminal(int(os.Stdout.Fd())))
4348
}
4449
},
4550
RunE: func(cmd *cobra.Command, args []string) error {

0 commit comments

Comments
 (0)