From 8690d63401d2912f8fd7966b6837078bce0ce6b2 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Fri, 12 Aug 2022 22:05:41 +0800 Subject: [PATCH] fix lint error Signed-off-by: yxxhero --- cmd/apply.go | 3 ++- cmd/build.go | 3 ++- cmd/cache.go | 3 ++- cmd/charts.go | 3 ++- cmd/delete.go | 3 ++- cmd/deps.go | 3 ++- cmd/destroy.go | 3 ++- cmd/diff.go | 3 ++- cmd/fetch.go | 3 ++- cmd/lint.go | 3 ++- cmd/list.go | 3 ++- cmd/repos.go | 3 ++- cmd/root.go | 9 +++++---- cmd/status.go | 3 ++- cmd/sync.go | 3 ++- cmd/template.go | 3 ++- cmd/test.go | 3 ++- cmd/version.go | 3 ++- cmd/write-values.go | 3 ++- main.go | 3 ++- pkg/app/app.go | 6 ++++-- pkg/app/app_apply_nokubectx_test.go | 3 ++- pkg/app/app_apply_test.go | 3 ++- pkg/app/app_diff_test.go | 5 +++-- pkg/app/app_lint_test.go | 5 +++-- pkg/app/app_sync_test.go | 3 ++- pkg/app/app_template_test.go | 5 +++-- pkg/app/app_test.go | 15 +++++---------- pkg/app/constants_test.go | 3 ++- pkg/app/desired_state_file_loader.go | 7 ++++--- pkg/app/destroy_nokubectx_test.go | 3 ++- pkg/app/destroy_test.go | 5 +++-- pkg/app/diff_nokubectx_test.go | 3 ++- pkg/app/diff_test.go | 5 +++-- pkg/app/load_opts.go | 3 ++- pkg/app/two_pass_renderer.go | 1 + pkg/app/two_pass_renderer_test.go | 6 +++--- pkg/argparser/args_test.go | 3 ++- pkg/config/config.go | 5 +++-- pkg/config/global.go | 3 ++- pkg/config/test.go | 3 ++- pkg/environment/environment.go | 3 ++- pkg/event/bus.go | 3 ++- pkg/event/bus_test.go | 3 ++- pkg/exectest/helm.go | 1 + pkg/helmexec/exec.go | 3 ++- pkg/helmexec/exec_test.go | 6 +++--- pkg/remote/remote.go | 3 ++- pkg/remote/remote_test.go | 1 + pkg/state/chart_dependency.go | 6 ++++-- pkg/state/create.go | 11 ++++++----- pkg/state/create_test.go | 9 ++++----- pkg/state/envvals_loader.go | 7 ++++--- pkg/state/envvals_loader_test.go | 3 ++- pkg/state/helmx.go | 4 +++- pkg/state/release.go | 3 ++- pkg/state/state.go | 10 +++++----- pkg/state/state_exec_tmpl.go | 3 ++- pkg/state/state_exec_tmpl_test.go | 1 + pkg/state/state_gogetter_test.go | 1 + pkg/state/state_run.go | 4 +++- pkg/state/state_test.go | 4 +++- pkg/state/temp.go | 9 +++++---- pkg/state/util.go | 2 +- pkg/tmpl/context_funcs.go | 3 ++- pkg/tmpl/expand_secret_ref.go | 3 ++- pkg/tmpl/expand_secret_ref_test.go | 3 +-- pkg/tmpl/expand_secrets_mock.go | 3 ++- pkg/tmpl/file_renderer.go | 3 +-- test/diff-yamls/diff-yamls.go | 1 + test/e2e/template/helmfile/tmpl_test.go | 3 ++- test/yamldiff/yamldiff.go | 1 - 72 files changed, 170 insertions(+), 111 deletions(-) diff --git a/cmd/apply.go b/cmd/apply.go index 01dc8f67..0a2f6cf5 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewApplyCmd returns apply subcmd diff --git a/cmd/build.go b/cmd/build.go index 44e9cd2e..35ec0d12 100644 --- a/cmd/build.go +++ b/cmd/build.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewBuildCmd returns build subcmd diff --git a/cmd/cache.go b/cmd/cache.go index ab7e3bd6..e85ded6e 100644 --- a/cmd/cache.go +++ b/cmd/cache.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) func NewCacheInfoSubcommand(cacheImpl *config.CacheImpl) *cobra.Command { diff --git a/cmd/charts.go b/cmd/charts.go index 9ad0e08b..2f3c8f0a 100644 --- a/cmd/charts.go +++ b/cmd/charts.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewChartsCmd returns charts subcmd diff --git a/cmd/delete.go b/cmd/delete.go index 26cbad75..08ec2d4b 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewDeleteCmd returns delete subcmd diff --git a/cmd/deps.go b/cmd/deps.go index 6018f1fe..01a89fc6 100644 --- a/cmd/deps.go +++ b/cmd/deps.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewDepsCmd returns deps subcmd diff --git a/cmd/destroy.go b/cmd/destroy.go index 50a5a314..008fab50 100644 --- a/cmd/destroy.go +++ b/cmd/destroy.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewDestroyCmd returns destroy subcmd diff --git a/cmd/diff.go b/cmd/diff.go index 9a168e53..32200367 100644 --- a/cmd/diff.go +++ b/cmd/diff.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewDiffCmd returns diff subcmd diff --git a/cmd/fetch.go b/cmd/fetch.go index fb21703d..653c1924 100644 --- a/cmd/fetch.go +++ b/cmd/fetch.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewFetchCmd returns diff subcmd diff --git a/cmd/lint.go b/cmd/lint.go index 40100a73..71e6e07c 100644 --- a/cmd/lint.go +++ b/cmd/lint.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewLintCmd returns lint subcmd diff --git a/cmd/list.go b/cmd/list.go index 8ed6248c..d439e830 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewListCmd returns list subcmd diff --git a/cmd/repos.go b/cmd/repos.go index 0940f005..e4b90285 100644 --- a/cmd/repos.go +++ b/cmd/repos.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewReposCmd returns repos subcmd diff --git a/cmd/root.go b/cmd/root.go index ae6c34dd..49503874 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -4,14 +4,15 @@ import ( "fmt" "os" - "github.com/helmfile/helmfile/pkg/app" - "github.com/helmfile/helmfile/pkg/app/version" - "github.com/helmfile/helmfile/pkg/config" - "github.com/helmfile/helmfile/pkg/helmexec" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/urfave/cli" "go.uber.org/zap" + + "github.com/helmfile/helmfile/pkg/app" + "github.com/helmfile/helmfile/pkg/app/version" + "github.com/helmfile/helmfile/pkg/config" + "github.com/helmfile/helmfile/pkg/helmexec" ) var logger *zap.SugaredLogger diff --git a/cmd/status.go b/cmd/status.go index d9f5f2c3..2f860df9 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewStatusCmd returns status subcmd diff --git a/cmd/sync.go b/cmd/sync.go index 2fe481b8..75b1c144 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewSyncCmd returns sync subcmd diff --git a/cmd/template.go b/cmd/template.go index 9b821d3b..709a8f73 100644 --- a/cmd/template.go +++ b/cmd/template.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewTemplateCmd returm template subcmd diff --git a/cmd/test.go b/cmd/test.go index 0af5cf10..fa6e6d78 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewTestCmd returns test subcmd diff --git a/cmd/version.go b/cmd/version.go index b2961430..c1a29c0a 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -3,8 +3,9 @@ package cmd import ( "fmt" - "github.com/helmfile/helmfile/pkg/app/version" "github.com/spf13/cobra" + + "github.com/helmfile/helmfile/pkg/app/version" ) // NewVersionCmd returns version subcmd diff --git a/cmd/write-values.go b/cmd/write-values.go index 8c918fa9..762e4fbc 100644 --- a/cmd/write-values.go +++ b/cmd/write-values.go @@ -1,9 +1,10 @@ package cmd import ( + "github.com/spf13/cobra" + "github.com/helmfile/helmfile/pkg/app" "github.com/helmfile/helmfile/pkg/config" - "github.com/spf13/cobra" ) // NewWriteValuesCmd returns write subcmd diff --git a/main.go b/main.go index 1fa6dac1..e9b86d51 100644 --- a/main.go +++ b/main.go @@ -4,9 +4,10 @@ import ( "fmt" "os" + "github.com/urfave/cli" + "github.com/helmfile/helmfile/cmd" "github.com/helmfile/helmfile/pkg/config" - "github.com/urfave/cli" ) func warning(format string, v ...interface{}) { diff --git a/pkg/app/app.go b/pkg/app/app.go index 06a7e4cf..4dd83873 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -13,13 +13,14 @@ import ( "syscall" "text/tabwriter" + "github.com/variantdev/vals" + "go.uber.org/zap" + "github.com/helmfile/helmfile/pkg/argparser" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/plugins" "github.com/helmfile/helmfile/pkg/remote" "github.com/helmfile/helmfile/pkg/state" - "github.com/variantdev/vals" - "go.uber.org/zap" ) // App is the main application object. @@ -920,6 +921,7 @@ func printBatches(batches [][]state.Release) string { return buf.String() } +// nolint: unparam func withDAG(templated *state.HelmState, helm helmexec.Interface, logger *zap.SugaredLogger, opts state.PlanOptions, converge func(*state.HelmState, helmexec.Interface) (bool, []error)) (bool, []error) { batches, err := templated.PlanReleases(opts) if err != nil { diff --git a/pkg/app/app_apply_nokubectx_test.go b/pkg/app/app_apply_nokubectx_test.go index 1584c710..56a6b781 100644 --- a/pkg/app/app_apply_nokubectx_test.go +++ b/pkg/app/app_apply_nokubectx_test.go @@ -9,10 +9,11 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/variantdev/vals" ) func TestApply_3(t *testing.T) { diff --git a/pkg/app/app_apply_test.go b/pkg/app/app_apply_test.go index 0fe30c54..d7d81da9 100644 --- a/pkg/app/app_apply_test.go +++ b/pkg/app/app_apply_test.go @@ -9,10 +9,11 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/variantdev/vals" ) func TestApply_2(t *testing.T) { diff --git a/pkg/app/app_diff_test.go b/pkg/app/app_diff_test.go index 9628da93..e4a0c833 100644 --- a/pkg/app/app_diff_test.go +++ b/pkg/app/app_diff_test.go @@ -9,11 +9,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/stretchr/testify/require" - "github.com/variantdev/vals" ) func TestDiffWithNeeds(t *testing.T) { diff --git a/pkg/app/app_lint_test.go b/pkg/app/app_lint_test.go index fb4ca33f..085057c7 100644 --- a/pkg/app/app_lint_test.go +++ b/pkg/app/app_lint_test.go @@ -11,11 +11,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/stretchr/testify/require" - "github.com/variantdev/vals" ) func TestLint(t *testing.T) { diff --git a/pkg/app/app_sync_test.go b/pkg/app/app_sync_test.go index c32cf2bc..034002ba 100644 --- a/pkg/app/app_sync_test.go +++ b/pkg/app/app_sync_test.go @@ -9,10 +9,11 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/variantdev/vals" ) func TestSync(t *testing.T) { diff --git a/pkg/app/app_template_test.go b/pkg/app/app_template_test.go index 979eb626..e76c04c7 100644 --- a/pkg/app/app_template_test.go +++ b/pkg/app/app_template_test.go @@ -11,11 +11,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/stretchr/testify/require" - "github.com/variantdev/vals" ) func TestTemplate(t *testing.T) { diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index f837d5ee..0e0f1850 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -15,22 +15,17 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/helmfile/helmfile/pkg/envvar" - - "github.com/helmfile/helmfile/pkg/remote" - "github.com/helmfile/helmfile/pkg/testutil" - "github.com/stretchr/testify/assert" - - "github.com/helmfile/helmfile/pkg/exectest" - "github.com/variantdev/vals" + "go.uber.org/zap" + "github.com/helmfile/helmfile/pkg/envvar" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" + "github.com/helmfile/helmfile/pkg/remote" "github.com/helmfile/helmfile/pkg/state" "github.com/helmfile/helmfile/pkg/testhelper" - - "go.uber.org/zap" + "github.com/helmfile/helmfile/pkg/testutil" ) func appWithFs(app *App, files map[string]string) *App { diff --git a/pkg/app/constants_test.go b/pkg/app/constants_test.go index 9d117046..215c99c3 100644 --- a/pkg/app/constants_test.go +++ b/pkg/app/constants_test.go @@ -5,8 +5,9 @@ import ( "os" "testing" - "github.com/helmfile/helmfile/pkg/envvar" "github.com/stretchr/testify/require" + + "github.com/helmfile/helmfile/pkg/envvar" ) // TestIsExplicitSelectorInheritanceEnabled tests the isExplicitSelectorInheritanceEnabled function diff --git a/pkg/app/desired_state_file_loader.go b/pkg/app/desired_state_file_loader.go index 2184b90a..e29ec660 100644 --- a/pkg/app/desired_state_file_loader.go +++ b/pkg/app/desired_state_file_loader.go @@ -6,13 +6,14 @@ import ( "fmt" "path/filepath" + "github.com/imdario/mergo" + "github.com/variantdev/vals" + "go.uber.org/zap" + "github.com/helmfile/helmfile/pkg/environment" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/remote" "github.com/helmfile/helmfile/pkg/state" - "github.com/imdario/mergo" - "github.com/variantdev/vals" - "go.uber.org/zap" ) const ( diff --git a/pkg/app/destroy_nokubectx_test.go b/pkg/app/destroy_nokubectx_test.go index 006b3462..97991f4c 100644 --- a/pkg/app/destroy_nokubectx_test.go +++ b/pkg/app/destroy_nokubectx_test.go @@ -8,10 +8,11 @@ import ( "sync" "testing" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/variantdev/vals" ) func TestDestroy_2(t *testing.T) { diff --git a/pkg/app/destroy_test.go b/pkg/app/destroy_test.go index 390bb945..786aa429 100644 --- a/pkg/app/destroy_test.go +++ b/pkg/app/destroy_test.go @@ -8,11 +8,12 @@ import ( "sync" "testing" + "github.com/variantdev/vals" + "go.uber.org/zap" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/variantdev/vals" - "go.uber.org/zap" ) const ( diff --git a/pkg/app/diff_nokubectx_test.go b/pkg/app/diff_nokubectx_test.go index 8095adfe..c624fffe 100644 --- a/pkg/app/diff_nokubectx_test.go +++ b/pkg/app/diff_nokubectx_test.go @@ -9,10 +9,11 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/variantdev/vals" ) func TestDiff_2(t *testing.T) { diff --git a/pkg/app/diff_test.go b/pkg/app/diff_test.go index 5302bae7..b798079c 100644 --- a/pkg/app/diff_test.go +++ b/pkg/app/diff_test.go @@ -9,11 +9,12 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/variantdev/vals" + "go.uber.org/zap" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/variantdev/vals" - "go.uber.org/zap" ) type diffConfig struct { diff --git a/pkg/app/load_opts.go b/pkg/app/load_opts.go index 56b3c8ee..73b2324f 100644 --- a/pkg/app/load_opts.go +++ b/pkg/app/load_opts.go @@ -1,8 +1,9 @@ package app import ( - "github.com/helmfile/helmfile/pkg/state" "gopkg.in/yaml.v2" + + "github.com/helmfile/helmfile/pkg/state" ) type LoadOpts struct { diff --git a/pkg/app/two_pass_renderer.go b/pkg/app/two_pass_renderer.go index 05e12d1f..af441cda 100644 --- a/pkg/app/two_pass_renderer.go +++ b/pkg/app/two_pass_renderer.go @@ -6,6 +6,7 @@ import ( "strings" "github.com/google/go-cmp/cmp" + "github.com/helmfile/helmfile/pkg/environment" "github.com/helmfile/helmfile/pkg/state" "github.com/helmfile/helmfile/pkg/tmpl" diff --git a/pkg/app/two_pass_renderer_test.go b/pkg/app/two_pass_renderer_test.go index d24c4d87..5c6732a9 100644 --- a/pkg/app/two_pass_renderer_test.go +++ b/pkg/app/two_pass_renderer_test.go @@ -5,15 +5,15 @@ import ( "strings" "testing" - "github.com/helmfile/helmfile/pkg/remote" + "gopkg.in/yaml.v2" "github.com/helmfile/helmfile/pkg/helmexec" + "github.com/helmfile/helmfile/pkg/remote" "github.com/helmfile/helmfile/pkg/state" "github.com/helmfile/helmfile/pkg/testhelper" - - "gopkg.in/yaml.v2" ) +// nolint: unparam func makeLoader(files map[string]string, env string) (*desiredStateLoader, *testhelper.TestFs) { testfs := testhelper.NewTestFs(files) logger := helmexec.NewLogger(os.Stdout, "debug") diff --git a/pkg/argparser/args_test.go b/pkg/argparser/args_test.go index d1b8afa7..c5a9a21f 100644 --- a/pkg/argparser/args_test.go +++ b/pkg/argparser/args_test.go @@ -4,8 +4,9 @@ import ( "strings" "testing" - "github.com/helmfile/helmfile/pkg/state" "github.com/stretchr/testify/require" + + "github.com/helmfile/helmfile/pkg/state" ) // TestGetArgs tests the GetArgs function diff --git a/pkg/config/config.go b/pkg/config/config.go index 242f3341..58031f36 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -5,11 +5,12 @@ import ( "os" "strings" - "github.com/helmfile/helmfile/pkg/maputil" - "github.com/helmfile/helmfile/pkg/state" "github.com/urfave/cli" "go.uber.org/zap" "golang.org/x/term" + + "github.com/helmfile/helmfile/pkg/maputil" + "github.com/helmfile/helmfile/pkg/state" ) // nolint: golint diff --git a/pkg/config/global.go b/pkg/config/global.go index 68a66138..671a7aaf 100644 --- a/pkg/config/global.go +++ b/pkg/config/global.go @@ -4,9 +4,10 @@ import ( "errors" "os" - "github.com/helmfile/helmfile/pkg/state" "go.uber.org/zap" "golang.org/x/term" + + "github.com/helmfile/helmfile/pkg/state" ) // GlobalOptions is the global configuration for the Helmfile CLI. diff --git a/pkg/config/test.go b/pkg/config/test.go index a992632a..f856bbaf 100644 --- a/pkg/config/test.go +++ b/pkg/config/test.go @@ -1,8 +1,9 @@ package config import ( - "github.com/helmfile/helmfile/pkg/state" "github.com/spf13/cobra" + + "github.com/helmfile/helmfile/pkg/state" ) // TestOptions is the options for the build command diff --git a/pkg/environment/environment.go b/pkg/environment/environment.go index ef674c19..0ef3c943 100644 --- a/pkg/environment/environment.go +++ b/pkg/environment/environment.go @@ -1,9 +1,10 @@ package environment import ( - "github.com/helmfile/helmfile/pkg/maputil" "github.com/imdario/mergo" "gopkg.in/yaml.v2" + + "github.com/helmfile/helmfile/pkg/maputil" ) type Environment struct { diff --git a/pkg/event/bus.go b/pkg/event/bus.go index 1a062f0d..284615cf 100644 --- a/pkg/event/bus.go +++ b/pkg/event/bus.go @@ -4,10 +4,11 @@ import ( "fmt" "strings" + "go.uber.org/zap" + "github.com/helmfile/helmfile/pkg/environment" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/tmpl" - "go.uber.org/zap" ) type Hook struct { diff --git a/pkg/event/bus_test.go b/pkg/event/bus_test.go index 601f947f..9cef6d89 100644 --- a/pkg/event/bus_test.go +++ b/pkg/event/bus_test.go @@ -5,9 +5,10 @@ import ( "io" "testing" - "github.com/helmfile/helmfile/pkg/environment" "go.uber.org/zap" "go.uber.org/zap/zaptest/observer" + + "github.com/helmfile/helmfile/pkg/environment" ) type runner struct { diff --git a/pkg/exectest/helm.go b/pkg/exectest/helm.go index 300b5f9c..8f01947b 100644 --- a/pkg/exectest/helm.go +++ b/pkg/exectest/helm.go @@ -7,6 +7,7 @@ import ( "sync" "github.com/Masterminds/semver/v3" + "github.com/helmfile/helmfile/pkg/helmexec" ) diff --git a/pkg/helmexec/exec.go b/pkg/helmexec/exec.go index 49340b3e..a134f1fd 100644 --- a/pkg/helmexec/exec.go +++ b/pkg/helmexec/exec.go @@ -12,9 +12,10 @@ import ( "sync" "github.com/Masterminds/semver/v3" - "github.com/helmfile/helmfile/pkg/envvar" "go.uber.org/zap" "go.uber.org/zap/zapcore" + + "github.com/helmfile/helmfile/pkg/envvar" ) type decryptedSecret struct { diff --git a/pkg/helmexec/exec_test.go b/pkg/helmexec/exec_test.go index d44242c0..3aafa4c5 100644 --- a/pkg/helmexec/exec_test.go +++ b/pkg/helmexec/exec_test.go @@ -11,11 +11,11 @@ import ( "regexp" "testing" - "github.com/google/go-cmp/cmp" - "github.com/helmfile/helmfile/pkg/envvar" - "github.com/Masterminds/semver/v3" + "github.com/google/go-cmp/cmp" "go.uber.org/zap" + + "github.com/helmfile/helmfile/pkg/envvar" ) // Mocking the command-line runner diff --git a/pkg/remote/remote.go b/pkg/remote/remote.go index 24caaf96..e903daff 100644 --- a/pkg/remote/remote.go +++ b/pkg/remote/remote.go @@ -12,10 +12,11 @@ import ( "github.com/hashicorp/go-getter" "github.com/hashicorp/go-getter/helper/url" - "github.com/helmfile/helmfile/pkg/envvar" "go.uber.org/multierr" "go.uber.org/zap" "gopkg.in/yaml.v2" + + "github.com/helmfile/helmfile/pkg/envvar" ) var disableInsecureFeatures bool diff --git a/pkg/remote/remote_test.go b/pkg/remote/remote_test.go index 70e81596..13eecfdf 100644 --- a/pkg/remote/remote_test.go +++ b/pkg/remote/remote_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" ) diff --git a/pkg/state/chart_dependency.go b/pkg/state/chart_dependency.go index cb0df9f1..f38a2ccd 100644 --- a/pkg/state/chart_dependency.go +++ b/pkg/state/chart_dependency.go @@ -9,11 +9,12 @@ import ( "github.com/Masterminds/semver/v3" goversion "github.com/hashicorp/go-version" - "github.com/helmfile/helmfile/pkg/app/version" - "github.com/helmfile/helmfile/pkg/helmexec" "github.com/r3labs/diff" "go.uber.org/zap" "gopkg.in/yaml.v2" + + "github.com/helmfile/helmfile/pkg/app/version" + "github.com/helmfile/helmfile/pkg/helmexec" ) type ChartMeta struct { @@ -97,6 +98,7 @@ type ResolvedDependencies struct { deps map[string][]ResolvedChartDependency } +// nolint: unparam func (d *ResolvedDependencies) add(dep ResolvedChartDependency) error { deps := d.deps[dep.ChartName] if deps == nil { diff --git a/pkg/state/create.go b/pkg/state/create.go index 98173837..50e35b4a 100644 --- a/pkg/state/create.go +++ b/pkg/state/create.go @@ -7,15 +7,15 @@ import ( "io" "os" - "github.com/helmfile/helmfile/pkg/helmexec" - "github.com/helmfile/helmfile/pkg/remote" - - "github.com/helmfile/helmfile/pkg/environment" - "github.com/helmfile/helmfile/pkg/maputil" "github.com/imdario/mergo" "github.com/variantdev/vals" "go.uber.org/zap" "gopkg.in/yaml.v2" + + "github.com/helmfile/helmfile/pkg/environment" + "github.com/helmfile/helmfile/pkg/helmexec" + "github.com/helmfile/helmfile/pkg/maputil" + "github.com/helmfile/helmfile/pkg/remote" ) const ( @@ -221,6 +221,7 @@ func (c *StateCreator) loadBases(envValues *environment.Environment, st *HelmSta return layers[0], nil } +// nolint: unparam func (c *StateCreator) loadEnvValues(st *HelmState, name string, failOnMissingEnv bool, ctxEnv *environment.Environment, readFile func(string) ([]byte, error), glob func(string) ([]string, error)) (*environment.Environment, error) { envVals := map[string]interface{}{} envSpec, ok := st.Environments[name] diff --git a/pkg/state/create_test.go b/pkg/state/create_test.go index 90ecaa23..21c277e9 100644 --- a/pkg/state/create_test.go +++ b/pkg/state/create_test.go @@ -6,13 +6,12 @@ import ( "reflect" "testing" - "github.com/helmfile/helmfile/pkg/environment" - "github.com/helmfile/helmfile/pkg/remote" - - "github.com/helmfile/helmfile/pkg/testhelper" + "github.com/stretchr/testify/require" "go.uber.org/zap" - "github.com/stretchr/testify/require" + "github.com/helmfile/helmfile/pkg/environment" + "github.com/helmfile/helmfile/pkg/remote" + "github.com/helmfile/helmfile/pkg/testhelper" ) func createFromYaml(content []byte, file string, env string, logger *zap.SugaredLogger) (*HelmState, error) { diff --git a/pkg/state/envvals_loader.go b/pkg/state/envvals_loader.go index 6b08efa3..c11bd334 100644 --- a/pkg/state/envvals_loader.go +++ b/pkg/state/envvals_loader.go @@ -4,13 +4,14 @@ import ( "fmt" "path/filepath" + "github.com/imdario/mergo" + "go.uber.org/zap" + "gopkg.in/yaml.v2" + "github.com/helmfile/helmfile/pkg/environment" "github.com/helmfile/helmfile/pkg/maputil" "github.com/helmfile/helmfile/pkg/remote" "github.com/helmfile/helmfile/pkg/tmpl" - "github.com/imdario/mergo" - "go.uber.org/zap" - "gopkg.in/yaml.v2" ) type EnvironmentValuesLoader struct { diff --git a/pkg/state/envvals_loader_test.go b/pkg/state/envvals_loader_test.go index 627ff211..c162b818 100644 --- a/pkg/state/envvals_loader_test.go +++ b/pkg/state/envvals_loader_test.go @@ -6,8 +6,9 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/helmfile/helmfile/pkg/remote" "go.uber.org/zap" + + "github.com/helmfile/helmfile/pkg/remote" ) func newLoader() *EnvironmentValuesLoader { diff --git a/pkg/state/helmx.go b/pkg/state/helmx.go index f12aeebf..7fcfa52f 100644 --- a/pkg/state/helmx.go +++ b/pkg/state/helmx.go @@ -5,9 +5,10 @@ import ( "os" "path/filepath" + "github.com/variantdev/chartify" + "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/remote" - "github.com/variantdev/chartify" ) type Dependency struct { @@ -16,6 +17,7 @@ type Dependency struct { Alias string `yaml:"alias"` } +// nolint: unparam func (st *HelmState) appendHelmXFlags(flags []string, release *ReleaseSpec) ([]string, error) { for _, adopt := range release.Adopt { flags = append(flags, "--adopt", adopt) diff --git a/pkg/state/release.go b/pkg/state/release.go index 6000bb66..9ad890e0 100644 --- a/pkg/state/release.go +++ b/pkg/state/release.go @@ -3,8 +3,9 @@ package state import ( "fmt" - "github.com/helmfile/helmfile/pkg/tmpl" "gopkg.in/yaml.v2" + + "github.com/helmfile/helmfile/pkg/tmpl" ) func (r ReleaseSpec) ExecuteTemplateExpressions(renderer *tmpl.FileRenderer) (*ReleaseSpec, error) { diff --git a/pkg/state/state.go b/pkg/state/state.go index b50993ef..8a7efe1c 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -18,18 +18,17 @@ import ( "text/template" "github.com/imdario/mergo" + "github.com/tatsushid/go-prettytable" "github.com/variantdev/chartify" + "github.com/variantdev/vals" + "go.uber.org/zap" + "gopkg.in/yaml.v2" "github.com/helmfile/helmfile/pkg/environment" "github.com/helmfile/helmfile/pkg/event" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/remote" "github.com/helmfile/helmfile/pkg/tmpl" - - "github.com/tatsushid/go-prettytable" - "github.com/variantdev/vals" - "go.uber.org/zap" - "gopkg.in/yaml.v2" ) const ( @@ -1301,6 +1300,7 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre return temp, nil } +// nolint: unparam func (st *HelmState) runHelmDepBuilds(helm helmexec.Interface, concurrency int, builds []*chartPrepareResult) error { // NOTES: // 1. `helm dep build` fails when it was run concurrency on the same chart. diff --git a/pkg/state/state_exec_tmpl.go b/pkg/state/state_exec_tmpl.go index 44df1dc1..3ad14c79 100644 --- a/pkg/state/state_exec_tmpl.go +++ b/pkg/state/state_exec_tmpl.go @@ -4,8 +4,9 @@ import ( "fmt" "reflect" - "github.com/helmfile/helmfile/pkg/tmpl" "gopkg.in/yaml.v2" + + "github.com/helmfile/helmfile/pkg/tmpl" ) func (st *HelmState) Values() map[string]interface{} { diff --git a/pkg/state/state_exec_tmpl_test.go b/pkg/state/state_exec_tmpl_test.go index 19cbad08..5ce5c0cd 100644 --- a/pkg/state/state_exec_tmpl_test.go +++ b/pkg/state/state_exec_tmpl_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/go-test/deep" + "github.com/helmfile/helmfile/pkg/environment" ) diff --git a/pkg/state/state_gogetter_test.go b/pkg/state/state_gogetter_test.go index 4de43463..c7bda8b8 100644 --- a/pkg/state/state_gogetter_test.go +++ b/pkg/state/state_gogetter_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/google/go-cmp/cmp" + "github.com/helmfile/helmfile/pkg/helmexec" ) diff --git a/pkg/state/state_run.go b/pkg/state/state_run.go index 5e6a14ef..0500a1e7 100644 --- a/pkg/state/state_run.go +++ b/pkg/state/state_run.go @@ -7,8 +7,9 @@ import ( "strings" "sync" - "github.com/helmfile/helmfile/pkg/helmexec" "github.com/variantdev/dag/pkg/dag" + + "github.com/helmfile/helmfile/pkg/helmexec" ) type result struct { @@ -55,6 +56,7 @@ func (st *HelmState) scatterGatherReleases(helm helmexec.Interface, concurrency return st.iterateOnReleases(helm, concurrency, st.Releases, do) } +// nolint: unparam func (st *HelmState) iterateOnReleases(helm helmexec.Interface, concurrency int, inputs []ReleaseSpec, do func(ReleaseSpec, int) error) []error { var errs []error diff --git a/pkg/state/state_test.go b/pkg/state/state_test.go index 23cce442..93aed06c 100644 --- a/pkg/state/state_test.go +++ b/pkg/state/state_test.go @@ -8,10 +8,11 @@ import ( "testing" "github.com/Masterminds/semver/v3" + "github.com/variantdev/vals" + "github.com/helmfile/helmfile/pkg/exectest" "github.com/helmfile/helmfile/pkg/helmexec" "github.com/helmfile/helmfile/pkg/testhelper" - "github.com/variantdev/vals" ) var logger = helmexec.NewLogger(os.Stdout, "warn") @@ -1841,6 +1842,7 @@ func TestHelmState_UpdateDeps(t *testing.T) { if err != nil { return "", err } + // nolint: unparam helm.UpdateDepsCallbacks[generatedDir] = func(chart string) error { content := []byte(`dependencies: - name: envoy diff --git a/pkg/state/temp.go b/pkg/state/temp.go index 72ab31da..730b8e17 100644 --- a/pkg/state/temp.go +++ b/pkg/state/temp.go @@ -9,8 +9,9 @@ import ( "strings" "github.com/davecgh/go-spew/spew" - "github.com/helmfile/helmfile/pkg/envvar" "k8s.io/apimachinery/pkg/util/rand" + + "github.com/helmfile/helmfile/pkg/envvar" ) func createTempValuesFile(release *ReleaseSpec, data interface{}) (*os.File, error) { @@ -30,7 +31,7 @@ func createTempValuesFile(release *ReleaseSpec, data interface{}) (*os.File, err func tempValuesFilePath(release *ReleaseSpec, data interface{}) (*string, error) { id, err := generateValuesID(release, data) if err != nil { - panic(err) + return nil, err } workDir := os.Getenv(envvar.TempDir) @@ -40,14 +41,14 @@ func tempValuesFilePath(release *ReleaseSpec, data interface{}) (*string, error) err = os.MkdirAll(workDir, os.FileMode(0700)) } if err != nil { - panic(err) + return nil, err } d := filepath.Join(workDir, id) _, err = os.Stat(d) if err != nil && !errors.Is(err, os.ErrNotExist) { - panic(err) + return nil, err } return &d, nil diff --git a/pkg/state/util.go b/pkg/state/util.go index e894adda..4f9605ba 100644 --- a/pkg/state/util.go +++ b/pkg/state/util.go @@ -48,7 +48,7 @@ func resolveRemoteChart(repoAndChart string) (string, string, bool) { // normalizeChart allows for the distinction between a file path reference and repository references. // - Any single (or double character) followed by a `/` will be considered a local file reference and -// be constructed relative to the `base path`. +// be constructed relative to the `base path`. // - Everything else is assumed to be an absolute path or an actual / reference. func normalizeChart(basePath, chart string) string { if !isLocalChart(chart) || chart[0] == '/' { diff --git a/pkg/tmpl/context_funcs.go b/pkg/tmpl/context_funcs.go index 1867a579..aa4ffa9d 100644 --- a/pkg/tmpl/context_funcs.go +++ b/pkg/tmpl/context_funcs.go @@ -14,9 +14,10 @@ import ( "text/template" "github.com/ghodss/yaml" + "golang.org/x/sync/errgroup" + "github.com/helmfile/helmfile/pkg/envvar" "github.com/helmfile/helmfile/pkg/helmexec" - "golang.org/x/sync/errgroup" ) type Values = map[string]interface{} diff --git a/pkg/tmpl/expand_secret_ref.go b/pkg/tmpl/expand_secret_ref.go index d4c3e92d..b179ef7e 100644 --- a/pkg/tmpl/expand_secret_ref.go +++ b/pkg/tmpl/expand_secret_ref.go @@ -4,8 +4,9 @@ import ( "fmt" "sync" - "github.com/helmfile/helmfile/pkg/plugins" "github.com/variantdev/vals" + + "github.com/helmfile/helmfile/pkg/plugins" ) // to generate mock run mockgen -source=expand_secret_ref.go -destination=expand_secrets_mock.go -package=tmpl diff --git a/pkg/tmpl/expand_secret_ref_test.go b/pkg/tmpl/expand_secret_ref_test.go index 7d70f396..287adab7 100644 --- a/pkg/tmpl/expand_secret_ref_test.go +++ b/pkg/tmpl/expand_secret_ref_test.go @@ -2,11 +2,10 @@ package tmpl import ( "errors" + "testing" "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" - - "testing" ) func Test_fetchSecretValue(t *testing.T) { diff --git a/pkg/tmpl/expand_secrets_mock.go b/pkg/tmpl/expand_secrets_mock.go index aa5ab725..56dc70b6 100644 --- a/pkg/tmpl/expand_secrets_mock.go +++ b/pkg/tmpl/expand_secrets_mock.go @@ -4,8 +4,9 @@ package tmpl import ( - gomock "github.com/golang/mock/gomock" reflect "reflect" + + gomock "github.com/golang/mock/gomock" ) // MockvalClient is a mock of valClient interface diff --git a/pkg/tmpl/file_renderer.go b/pkg/tmpl/file_renderer.go index 16c41cf4..6004061e 100644 --- a/pkg/tmpl/file_renderer.go +++ b/pkg/tmpl/file_renderer.go @@ -2,9 +2,8 @@ package tmpl import ( "bytes" - "os" - "fmt" + "os" "strings" ) diff --git a/test/diff-yamls/diff-yamls.go b/test/diff-yamls/diff-yamls.go index c0404950..b182ab15 100644 --- a/test/diff-yamls/diff-yamls.go +++ b/test/diff-yamls/diff-yamls.go @@ -137,6 +137,7 @@ type meta struct { namespace string } +// nolint: unparam func (res resource) getMeta() (meta, error) { if len(res) == 0 { return meta{}, nil diff --git a/test/e2e/template/helmfile/tmpl_test.go b/test/e2e/template/helmfile/tmpl_test.go index 6944817e..7fc49b43 100644 --- a/test/e2e/template/helmfile/tmpl_test.go +++ b/test/e2e/template/helmfile/tmpl_test.go @@ -6,8 +6,9 @@ import ( "testing" "text/template" - "github.com/helmfile/helmfile/pkg/tmpl" "github.com/stretchr/testify/require" + + "github.com/helmfile/helmfile/pkg/tmpl" ) type tmplTestCase struct { diff --git a/test/yamldiff/yamldiff.go b/test/yamldiff/yamldiff.go index 163e33a3..78ada2b3 100644 --- a/test/yamldiff/yamldiff.go +++ b/test/yamldiff/yamldiff.go @@ -4,7 +4,6 @@ import ( "fmt" "io" "os" - "strings" "github.com/jessevdk/go-flags"