From 92ba347d6f899bd4b29a4279efef3199d0fa36b0 Mon Sep 17 00:00:00 2001 From: dudicoco <51051860+dudicoco@users.noreply.github.com> Date: Sun, 16 May 2021 08:02:53 +0300 Subject: [PATCH] Add --skip-diff-on-install to helmfile diff (#1841) * Add --skip-diff-on-install to helmfile diff --- main.go | 4 ++++ pkg/app/app.go | 9 +++++---- pkg/app/config.go | 1 + pkg/app/diff_test.go | 34 ++++++++++++++++++++-------------- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/main.go b/main.go index 9d642f78..d837500c 100644 --- a/main.go +++ b/main.go @@ -207,6 +207,10 @@ func main() { Name: "include-needs", Usage: `automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided`, }, + cli.BoolFlag{ + Name: "skip-diff-on-install", + Usage: "Skips running helm-diff on releases being newly installed on this apply. Useful when the release manifests are too huge to be reviewed, or it's too time-consuming to diff at all", + }, cli.BoolFlag{ Name: "suppress-secrets", Usage: "suppress secrets in the output. highly recommended to specify on CI/CD use-cases", diff --git a/pkg/app/app.go b/pkg/app/app.go index 14af0e3a..e108e0ce 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -1436,10 +1436,11 @@ func (a *App) diff(r *Run, c DiffConfigProvider) (*string, bool, bool, []error) r.helm.SetExtraArgs(argparser.GetArgs(c.Args(), r.state)...) opts := &state.DiffOpts{ - Context: c.Context(), - Output: c.DiffOutput(), - NoColor: c.NoColor(), - Set: c.Set(), + Context: c.Context(), + Output: c.DiffOutput(), + NoColor: c.NoColor(), + Set: c.Set(), + SkipDiffOnInstall: c.SkipDiffOnInstall(), } st.Releases = selectedAndNeededReleases diff --git a/pkg/app/config.go b/pkg/app/config.go index a72ed616..c6445fc2 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -98,6 +98,7 @@ type DiffConfigProvider interface { SuppressSecrets() bool ShowSecrets() bool SuppressDiff() bool + SkipDiffOnInstall() bool SkipNeeds() bool IncludeNeeds() bool diff --git a/pkg/app/diff_test.go b/pkg/app/diff_test.go index 5c015755..6209d9dd 100644 --- a/pkg/app/diff_test.go +++ b/pkg/app/diff_test.go @@ -36,6 +36,7 @@ type diffConfig struct { concurrency int detailedExitcode bool interactive bool + skipDiffOnInstall bool logger *zap.SugaredLogger } @@ -111,6 +112,10 @@ func (a diffConfig) Interactive() bool { return a.interactive } +func (a diffConfig) SkipDiffOnInstall() bool { + return a.skipDiffOnInstall +} + func (a diffConfig) Logger() *zap.SugaredLogger { return a.logger } @@ -125,20 +130,21 @@ func TestDiff(t *testing.T) { } testcases := []struct { - name string - loc string - ns string - concurrency int - detailedExitcode bool - error string - flags flags - files map[string]string - selectors []string - lists map[exectest.ListKey]string - diffs map[exectest.DiffKey]error - upgraded []exectest.Release - deleted []exectest.Release - log string + name string + loc string + ns string + concurrency int + skipDiffOnInstall bool + detailedExitcode bool + error string + flags flags + files map[string]string + selectors []string + lists map[exectest.ListKey]string + diffs map[exectest.DiffKey]error + upgraded []exectest.Release + deleted []exectest.Release + log string }{ // // complex test cases for smoke testing