diff --git a/.github/workflows/checkLicenses.yml b/.github/workflows/checkLicenses.yml index 11e6a4e5f0..ee8b52f2ed 100644 --- a/.github/workflows/checkLicenses.yml +++ b/.github/workflows/checkLicenses.yml @@ -28,7 +28,7 @@ jobs: - run: | ./scripts/create-licenses.sh # Upload the licenses list so it's available if needed - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: Licenses path: LICENSES.txt diff --git a/.golangci.yml b/.golangci.yml index f43546b428..5f31fd7d1b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -2,8 +2,6 @@ run: deadline: 5m - skip-dirs: - thirdparty/ linters: # please, do not use `enable-all`: it's deprecated and will be removed soon. @@ -11,8 +9,6 @@ linters: disable-all: true enable: - bodyclose - - deadcode - - depguard - dogsled - dupl - errcheck @@ -33,19 +29,19 @@ linters: - misspell - nakedret - staticcheck - - structcheck - stylecheck - revive - typecheck - unconvert - unparam - unused - - varcheck - whitespace issues: exclude: - Using the variable on range scope `tc` in function literal + exclude-dirs: + - thirdparty/ linters-settings: dupl: diff --git a/Makefile b/Makefile index da0b4f54c9..4ed2bc6ad2 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,7 @@ install-kind: .PHONY: install-golangci-lint install-golangci-lint: - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.2 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.1 .PHONY: install-go-licenses install-go-licenses: diff --git a/commands/alpha/alphacmd.go b/commands/alpha/alphacmd.go index 87931dea0a..32d7d8e838 100644 --- a/commands/alpha/alphacmd.go +++ b/commands/alpha/alphacmd.go @@ -32,7 +32,7 @@ func GetCommand(ctx context.Context, _, version string) *cobra.Command { Use: "alpha", Short: alphadocs.AlphaShort, Long: alphadocs.AlphaLong, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { h, err := cmd.Flags().GetBool("help") if err != nil { return err diff --git a/commands/alpha/license/command.go b/commands/alpha/license/command.go index e22c6127ad..eb4b77dfff 100644 --- a/commands/alpha/license/command.go +++ b/commands/alpha/license/command.go @@ -27,7 +27,7 @@ func NewCommand(ctx context.Context, _ string) *cobra.Command { Use: "license", Short: "[Alpha] " + licensedocs.LicenseShort, Long: "[Alpha] " + licensedocs.LicenseShort + "\n" + licensedocs.LicenseLong, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { h, err := cmd.Flags().GetBool("help") if err != nil { return err diff --git a/commands/alpha/rollouts/rolloutscmd.go b/commands/alpha/rollouts/rolloutscmd.go index 2ded2cb0ad..c8df20ebce 100644 --- a/commands/alpha/rollouts/rolloutscmd.go +++ b/commands/alpha/rollouts/rolloutscmd.go @@ -29,7 +29,7 @@ func NewCommand(ctx context.Context, version string) *cobra.Command { Use: "rollouts", Short: "rollouts", Long: "rollouts", - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { h, err := cmd.Flags().GetBool("help") if err != nil { return err diff --git a/commands/fn/doc/cmdfndoc.go b/commands/fn/doc/cmdfndoc.go index cf2790ab8e..4ee5947995 100644 --- a/commands/fn/doc/cmdfndoc.go +++ b/commands/fn/doc/cmdfndoc.go @@ -43,7 +43,7 @@ func NewRunner(ctx context.Context, parent string) *Runner { } r.Command = c c.Flags().StringVarP(&r.Image, "image", "i", "", "kpt function image name") - _ = r.Command.RegisterFlagCompletionFunc("image", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + _ = r.Command.RegisterFlagCompletionFunc("image", func(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { return cmdutil.SuggestFunctions(cmd), cobra.ShellCompDirectiveDefault }) cmdutil.FixDocs("kpt", parent, c) diff --git a/commands/fn/fncmd.go b/commands/fn/fncmd.go index b8919abcc1..d2cbb9827a 100644 --- a/commands/fn/fncmd.go +++ b/commands/fn/fncmd.go @@ -32,7 +32,7 @@ func GetCommand(ctx context.Context, name string) *cobra.Command { Short: fndocs.FnShort, Long: fndocs.FnLong, Aliases: []string{"functions"}, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { h, err := cmd.Flags().GetBool("help") if err != nil { return err diff --git a/commands/fn/render/cmdrender.go b/commands/fn/render/cmdrender.go index 646e631589..4db250b605 100644 --- a/commands/fn/render/cmdrender.go +++ b/commands/fn/render/cmdrender.go @@ -53,7 +53,7 @@ func NewRunner(ctx context.Context, parent string) *Runner { c.Flags().Var(&r.RunnerOptions.ImagePullPolicy, "image-pull-policy", "pull image before running the container "+r.RunnerOptions.ImagePullPolicy.HelpAllowedValues()) - _ = c.RegisterFlagCompletionFunc("image-pull-policy", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + _ = c.RegisterFlagCompletionFunc("image-pull-policy", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { return r.RunnerOptions.ImagePullPolicy.AllStrings(), cobra.ShellCompDirectiveDefault }) diff --git a/commands/fn/render/cmdrender_test.go b/commands/fn/render/cmdrender_test.go index 5f89fa7700..e280343050 100644 --- a/commands/fn/render/cmdrender_test.go +++ b/commands/fn/render/cmdrender_test.go @@ -44,4 +44,4 @@ func TestCmd_flagAndArgParsing_Symlink(t *testing.T) { } // NoOpRunE is a noop function to replace the run function of a command. Useful for testing argument parsing. -var NoOpRunE = func(cmd *cobra.Command, args []string) error { return nil } +var NoOpRunE = func(_ *cobra.Command, _ []string) error { return nil } diff --git a/commands/live/migrate/migratecmd.go b/commands/live/migrate/migratecmd.go index 9c6aeef8c4..a10688ec62 100644 --- a/commands/live/migrate/migratecmd.go +++ b/commands/live/migrate/migratecmd.go @@ -86,7 +86,7 @@ func NewRunner( Short: livedocs.MigrateShort, Long: livedocs.MigrateShort + "\n" + livedocs.MigrateLong, Example: livedocs.MigrateExamples, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { if len(args) == 0 { // default to current working directory args = append(args, ".") diff --git a/commands/live/migrate/migratecmd_test.go b/commands/live/migrate/migratecmd_test.go index 0ac4b20dab..08403cfaac 100644 --- a/commands/live/migrate/migratecmd_test.go +++ b/commands/live/migrate/migratecmd_test.go @@ -168,7 +168,7 @@ func TestKptMigrate_migrateKptfileToRG(t *testing.T) { migrateRunner := NewRunner(ctx, tf, cmLoader, ioStreams) migrateRunner.dryRun = tc.dryRun migrateRunner.rgFile = tc.rgFilename - migrateRunner.cmInvClientFunc = func(factory util.Factory) (inventory.Client, error) { + migrateRunner.cmInvClientFunc = func(_ util.Factory) (inventory.Client, error) { return inventory.NewFakeClient([]object.ObjMetadata{}), nil } err = migrateRunner.migrateKptfileToRG([]string{dir}) @@ -242,7 +242,7 @@ func TestKptMigrate_retrieveConfigMapInv(t *testing.T) { // Create MigrateRunner and call "retrieveConfigMapInv" cmLoader := manifestreader.NewManifestLoader(tf) migrateRunner := NewRunner(ctx, tf, cmLoader, ioStreams) - migrateRunner.cmInvClientFunc = func(factory util.Factory) (inventory.Client, error) { + migrateRunner.cmInvClientFunc = func(_ util.Factory) (inventory.Client, error) { return inventory.NewFakeClient([]object.ObjMetadata{}), nil } actual, err := migrateRunner.retrieveConfigMapInv(strings.NewReader(tc.configMap), []string{"-"}) diff --git a/commands/live/status/cmdstatus_test.go b/commands/live/status/cmdstatus_test.go index fb03df8f1c..80a5d70d56 100644 --- a/commands/live/status/cmdstatus_test.go +++ b/commands/live/status/cmdstatus_test.go @@ -265,7 +265,7 @@ foo/deployment.apps/default/foo is InProgress: inProgress invFactory := inventory.FakeClientFactory(tc.inventory) loader := NewFakeLoader(ctx, tf, tc.inventory) runner := NewRunner(ctx, tf, invFactory, loader) - runner.PollerFactoryFunc = func(c cmdutil.Factory) (poller.Poller, error) { + runner.PollerFactoryFunc = func(_ cmdutil.Factory) (poller.Poller, error) { return &fakePoller{tc.events}, nil } diff --git a/commands/pkg/diff/cmddiff_test.go b/commands/pkg/diff/cmddiff_test.go index 29fbdfa842..2c51d54dc1 100644 --- a/commands/pkg/diff/cmddiff_test.go +++ b/commands/pkg/diff/cmddiff_test.go @@ -91,4 +91,4 @@ func TestCmd_flagAndArgParsing_Symlink(t *testing.T) { assert.Equal(t, filepath.Join(cwd, "path", "to", "pkg", "dir"), r.Path) } -var NoOpRunE = func(cmd *cobra.Command, args []string) error { return nil } +var NoOpRunE = func(_ *cobra.Command, _ []string) error { return nil } diff --git a/commands/pkg/get/cmdget.go b/commands/pkg/get/cmdget.go index 880df94451..b44b4a925c 100644 --- a/commands/pkg/get/cmdget.go +++ b/commands/pkg/get/cmdget.go @@ -55,7 +55,7 @@ func NewRunner(ctx context.Context, parent string) *Runner { strings.Join(kptfilev1.UpdateStrategiesAsStrings(), ",")) c.Flags().BoolVar(&r.isDeploymentInstance, "for-deployment", false, "(Experimental) indicates if this package will be deployed to a cluster.") - _ = c.RegisterFlagCompletionFunc("strategy", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + _ = c.RegisterFlagCompletionFunc("strategy", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { return kptfilev1.UpdateStrategiesAsStrings(), cobra.ShellCompDirectiveDefault }) return r diff --git a/commands/pkg/get/cmdget_test.go b/commands/pkg/get/cmdget_test.go index 0ea48b3935..72753549f2 100644 --- a/commands/pkg/get/cmdget_test.go +++ b/commands/pkg/get/cmdget_test.go @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// revive:disable:unused-parameter + package get_test import ( @@ -169,7 +171,7 @@ func TestCmd_fail(t *testing.T) { } // NoOpRunE is a noop function to replace the run function of a command. Useful for testing argument parsing. -var NoOpRunE = func(cmd *cobra.Command, args []string) error { return nil } +var NoOpRunE = func(_ *cobra.Command, _ []string) error { return nil } // NoOpFailRunE causes the test to fail if run is called. Useful for validating run isn't called for // errors. @@ -205,26 +207,26 @@ func TestCmd_Execute_flagAndArgParsing(t *testing.T) { validations func(repo, dir string, r *get.Runner, err error) }{ "must have at least 1 arg": { - argsFunc: func(repo, _ string) []string { + argsFunc: func(_, _ string) []string { return []string{} }, runE: failRun, - validations: func(_, _ string, r *get.Runner, err error) { + validations: func(_, _ string, _ *get.Runner, err error) { assert.EqualError(t, err, "requires at least 1 arg(s), only received 0") }, }, "must provide unambiguous repo, dir and version": { - argsFunc: func(repo, _ string) []string { + argsFunc: func(_, _ string) []string { return []string{"foo", "bar", "baz"} }, runE: failRun, - validations: func(_, _ string, r *get.Runner, err error) { + validations: func(_, _ string, _ *get.Runner, err error) { assert.Error(t, err) assert.Contains(t, err.Error(), "ambiguous repo/dir@version specify '.git' in argument") }, }, "repo arg is split up correctly into ref and repo": { - argsFunc: func(repo, _ string) []string { + argsFunc: func(_, _ string) []string { return []string{"something://foo.git/@master", "./"} }, runE: NoOpRunE, diff --git a/commands/pkg/pkgcmd.go b/commands/pkg/pkgcmd.go index 8e3f35149d..2af5aa92a6 100644 --- a/commands/pkg/pkgcmd.go +++ b/commands/pkg/pkgcmd.go @@ -32,7 +32,7 @@ func GetCommand(ctx context.Context, name string) *cobra.Command { Short: pkgdocs.PkgShort, Long: pkgdocs.PkgLong, Aliases: []string{"package"}, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { h, err := cmd.Flags().GetBool("help") if err != nil { return err diff --git a/commands/pkg/update/cmdupdate.go b/commands/pkg/update/cmdupdate.go index 855ad72eef..33d33cb415 100644 --- a/commands/pkg/update/cmdupdate.go +++ b/commands/pkg/update/cmdupdate.go @@ -54,7 +54,7 @@ func NewRunner(ctx context.Context, parent string) *Runner { "the update strategy that will be used when updating the package. This will change "+ "the default strategy for the package -- must be one of: "+ strings.Join(kptfilev1.UpdateStrategiesAsStrings(), ",")) - _ = c.RegisterFlagCompletionFunc("strategy", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + _ = c.RegisterFlagCompletionFunc("strategy", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { return kptfilev1.UpdateStrategiesAsStrings(), cobra.ShellCompDirectiveDefault }) cmdutil.FixDocs("kpt", parent, c) diff --git a/commands/pkg/update/cmdupdate_test.go b/commands/pkg/update/cmdupdate_test.go index a788e4ca8e..cd049c97a8 100644 --- a/commands/pkg/update/cmdupdate_test.go +++ b/commands/pkg/update/cmdupdate_test.go @@ -278,7 +278,7 @@ func TestCmd_onlyVersionAsInput(t *testing.T) { } // NoOpRunE is a noop function to replace the run function of a command. Useful for testing argument parsing. -var NoOpRunE = func(cmd *cobra.Command, args []string) error { return nil } +var NoOpRunE = func(_ *cobra.Command, _ []string) error { return nil } // NoOpFailRunE causes the test to fail if run is called. Useful for validating run isn't called for // errors. @@ -429,7 +429,7 @@ func TestCmd_path(t *testing.T) { defer testutil.Chdir(t, test.currentWD)() r := update.NewRunner(fake.CtxWithDefaultPrinter(), "kpt") - r.Command.RunE = func(cmd *cobra.Command, args []string) error { + r.Command.RunE = func(_ *cobra.Command, _ []string) error { if !assert.Equal(t, test.expectedFullPackagePath, r.Update.Pkg.UniquePath.String()) { t.FailNow() } diff --git a/go.mod b/go.mod index d4f66f0430..841989e8e2 100644 --- a/go.mod +++ b/go.mod @@ -20,8 +20,8 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 github.com/xlab/treeprint v1.2.0 - golang.org/x/mod v0.10.0 - golang.org/x/text v0.14.0 + golang.org/x/mod v0.17.0 + golang.org/x/text v0.21.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools v2.2.0+incompatible k8s.io/api v0.28.4 @@ -107,11 +107,11 @@ require ( github.com/spyzhov/ajson v0.9.0 // indirect github.com/vbatts/tar-split v0.11.2 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect - golang.org/x/net v0.17.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/term v0.27.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/go.sum b/go.sum index 242455f88a..6d2000b9cf 100644 --- a/go.sum +++ b/go.sum @@ -270,8 +270,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= -golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -281,8 +281,8 @@ golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8= golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE= @@ -292,8 +292,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -302,16 +302,16 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -322,8 +322,8 @@ golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.9.3 h1:Gn1I8+64MsuTb/HpH+LmQtNas23LhUVr3rYZ0eKuaMM= -golang.org/x/tools v0.9.3/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/alpha/printers/table/printer.go b/internal/alpha/printers/table/printer.go index 8dbf2bee70..248b103d2e 100644 --- a/internal/alpha/printers/table/printer.go +++ b/internal/alpha/printers/table/printer.go @@ -212,7 +212,7 @@ func getProgress(resInfo *resourceInfo) (string, string, error) { color, setColor := printcommon.ColorForStatus(rs.Status) if setColor { - s = printcommon.SprintfWithColor(color, s) + s = printcommon.SprintfWithColor(color, "%s", s) } text = s @@ -295,7 +295,7 @@ func getConditions(rs *pollingevent.ResourceStatus) []string { } } - s := printcommon.SprintfWithColor(color, text) + s := printcommon.SprintfWithColor(color, "%s", text) conditionStrings = append(conditionStrings, s) } return conditionStrings diff --git a/internal/errors/errors.go b/internal/errors/errors.go index 73e7d87a24..f776b948ad 100644 --- a/internal/errors/errors.go +++ b/internal/errors/errors.go @@ -192,7 +192,7 @@ func E(args ...interface{}) error { case error: e.Err = a case string: - e.Err = fmt.Errorf(a) + e.Err = fmt.Errorf("%s", a) default: panic(fmt.Errorf("unknown type %T for value %v in call to error.E", a, a)) } diff --git a/internal/fnruntime/imagepullpolicy.go b/internal/fnruntime/imagepullpolicy.go index 96c42ddd92..bb54dd2967 100644 --- a/internal/fnruntime/imagepullpolicy.go +++ b/internal/fnruntime/imagepullpolicy.go @@ -53,7 +53,7 @@ func (e *ImagePullPolicy) Set(v string) error { return nil } } - return fmt.Errorf("must must be one of " + strings.Join(e.AllStrings(), ", ")) + return fmt.Errorf("must be one of: %s", strings.Join(e.AllStrings(), ", ")) } func (e *ImagePullPolicy) AllStrings() []string { diff --git a/internal/fnruntime/utils.go b/internal/fnruntime/utils.go index bff5cc4da7..3d1e54f162 100644 --- a/internal/fnruntime/utils.go +++ b/internal/fnruntime/utils.go @@ -110,8 +110,8 @@ func presentIn(targetNode *yaml.RNode, input []*yaml.RNode) bool { return false } -// SetResourceIds adds kpt-resource-id annotation to each input resource -func SetResourceIds(input []*yaml.RNode) error { +// SetResourceIDs adds kpt-resource-id annotation to each input resource +func SetResourceIDs(input []*yaml.RNode) error { id := 0 for i := range input { idStr := fmt.Sprintf("%v", id) @@ -124,8 +124,8 @@ func SetResourceIds(input []*yaml.RNode) error { return nil } -// DeleteResourceIds removes the kpt-resource-id annotation from all resources -func DeleteResourceIds(input []*yaml.RNode) error { +// DeleteResourceIDs removes the kpt-resource-id annotation from all resources +func DeleteResourceIDs(input []*yaml.RNode) error { for i := range input { err := input[i].PipeE(yaml.ClearAnnotation(ResourceIDAnnotation)) if err != nil { diff --git a/internal/gitutil/gitutil_test.go b/internal/gitutil/gitutil_test.go index 3c6a7fa584..bac04c2617 100644 --- a/internal/gitutil/gitutil_test.go +++ b/internal/gitutil/gitutil_test.go @@ -22,7 +22,7 @@ import ( "testing" "github.com/GoogleContainerTools/kpt/internal/errors" - . "github.com/GoogleContainerTools/kpt/internal/gitutil" + "github.com/GoogleContainerTools/kpt/internal/gitutil" "github.com/GoogleContainerTools/kpt/internal/testutil" "github.com/GoogleContainerTools/kpt/internal/testutil/pkgbuilder" "github.com/GoogleContainerTools/kpt/pkg/printer/fake" @@ -38,7 +38,7 @@ func TestLocalGitRunner(t *testing.T) { command string args []string expectedStdout string - expectedErr *GitExecError + expectedErr *gitutil.GitExecError }{ "successful command with output to stdout": { command: "branch", @@ -48,7 +48,7 @@ func TestLocalGitRunner(t *testing.T) { "failed command with output to stderr": { command: "checkout", args: []string{"does-not-exist"}, - expectedErr: &GitExecError{ + expectedErr: &gitutil.GitExecError{ StdOut: "", StdErr: "error: pathspec 'does-not-exist' did not match any file(s) known to git", }, @@ -59,7 +59,7 @@ func TestLocalGitRunner(t *testing.T) { t.Run(tn, func(t *testing.T) { dir := t.TempDir() - runner, err := NewLocalGitRunner(dir) + runner, err := gitutil.NewLocalGitRunner(dir) if !assert.NoError(t, err) { t.FailNow() } @@ -70,7 +70,7 @@ func TestLocalGitRunner(t *testing.T) { rr, err := runner.Run(fake.CtxWithDefaultPrinter(), tc.command, tc.args...) if tc.expectedErr != nil { - var gitExecError *GitExecError + var gitExecError *gitutil.GitExecError if !errors.As(err, &gitExecError) { t.Error("expected error of type *GitExecError") t.FailNow() @@ -92,7 +92,7 @@ func TestLocalGitRunner(t *testing.T) { func TestNewGitUpstreamRepo_noRepo(t *testing.T) { dir := t.TempDir() - _, err := NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), dir) + _, err := gitutil.NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), dir) if !assert.Error(t, err) { t.FailNow() } @@ -102,7 +102,7 @@ func TestNewGitUpstreamRepo_noRepo(t *testing.T) { func TestNewGitUpstreamRepo_noRefs(t *testing.T) { dir := t.TempDir() - runner, err := NewLocalGitRunner(dir) + runner, err := gitutil.NewLocalGitRunner(dir) if !assert.NoError(t, err) { t.FailNow() } @@ -111,7 +111,7 @@ func TestNewGitUpstreamRepo_noRefs(t *testing.T) { t.FailNow() } - gur, err := NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), dir) + gur, err := gitutil.NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), dir) if !assert.NoError(t, err) { t.FailNow() } @@ -168,7 +168,7 @@ func TestNewGitUpstreamRepo(t *testing.T) { t.FailNow() } - gur, err := NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), g[testutil.Upstream].RepoDirectory) + gur, err := gitutil.NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), g[testutil.Upstream].RepoDirectory) if !assert.NoError(t, err) { t.FailNow() } @@ -181,7 +181,7 @@ func TestNewGitUpstreamRepo(t *testing.T) { func TestGitUpstreamRepo_GetDefaultBranch_noRefs(t *testing.T) { dir := t.TempDir() - runner, err := NewLocalGitRunner(dir) + runner, err := gitutil.NewLocalGitRunner(dir) if !assert.NoError(t, err) { t.FailNow() } @@ -190,7 +190,7 @@ func TestGitUpstreamRepo_GetDefaultBranch_noRefs(t *testing.T) { t.FailNow() } - gur, err := NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), dir) + gur, err := gitutil.NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), dir) if !assert.NoError(t, err) { t.FailNow() } @@ -241,7 +241,7 @@ func TestGitUpstreamRepo_GetDefaultBranch(t *testing.T) { }) defer clean() - gur, err := NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), g[testutil.Upstream].RepoDirectory) + gur, err := gitutil.NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), g[testutil.Upstream].RepoDirectory) if !assert.NoError(t, err) { t.FailNow() } @@ -298,7 +298,7 @@ func TestGitUpstreamRepo_GetRepo(t *testing.T) { }, }, refsFunc: func(t *testing.T, upstreamPath string) []string { - runner, err := NewLocalGitRunner(upstreamPath) + runner, err := gitutil.NewLocalGitRunner(upstreamPath) if !assert.NoError(t, err) { t.FailNow() } @@ -319,7 +319,7 @@ func TestGitUpstreamRepo_GetRepo(t *testing.T) { }, }, refsFunc: func(t *testing.T, upstreamPath string) []string { - runner, err := NewLocalGitRunner(upstreamPath) + runner, err := gitutil.NewLocalGitRunner(upstreamPath) if !assert.NoError(t, err) { t.FailNow() } @@ -344,7 +344,7 @@ func TestGitUpstreamRepo_GetRepo(t *testing.T) { }) defer clean() - gur, err := NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), g[testutil.Upstream].RepoDirectory) + gur, err := gitutil.NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), g[testutil.Upstream].RepoDirectory) if !assert.NoError(t, err) { t.FailNow() } @@ -354,7 +354,7 @@ func TestGitUpstreamRepo_GetRepo(t *testing.T) { t.FailNow() } - runner, err := NewLocalGitRunner(dir) + runner, err := gitutil.NewLocalGitRunner(dir) if !assert.NoError(t, err) { t.FailNow() } @@ -412,7 +412,7 @@ func TestGitUpstreamRepo_GetRepo_multipleUpdates(t *testing.T) { } func getRepoAndVerify(t *testing.T, repo, branchName string) string { - gur, err := NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), repo) + gur, err := gitutil.NewGitUpstreamRepo(fake.CtxWithDefaultPrinter(), repo) if !assert.NoError(t, err) { t.FailNow() } @@ -421,7 +421,7 @@ func getRepoAndVerify(t *testing.T, repo, branchName string) string { t.FailNow() } - runner, err := NewLocalGitRunner(dir) + runner, err := gitutil.NewLocalGitRunner(dir) if !assert.NoError(t, err) { t.FailNow() } diff --git a/internal/testutil/testutil.go b/internal/testutil/testutil.go index 30806d28f4..cef878e2c5 100644 --- a/internal/testutil/testutil.go +++ b/internal/testutil/testutil.go @@ -180,7 +180,7 @@ func Diff(sourceDir, destDir string, addMergeCommentsToSource bool) (sets.String sourceDir = newSourceDir } upstreamFiles := sets.String{} - err := filepath.Walk(sourceDir, func(path string, info os.FileInfo, err error) error { + err := filepath.Walk(sourceDir, func(path string, _ os.FileInfo, err error) error { if err != nil { return err } @@ -199,7 +199,7 @@ func Diff(sourceDir, destDir string, addMergeCommentsToSource bool) (sets.String // get set of filenames in the cloned package localFiles := sets.String{} - err = filepath.Walk(destDir, func(path string, info os.FileInfo, err error) error { + err = filepath.Walk(destDir, func(path string, _ os.FileInfo, err error) error { if err != nil { return err } @@ -821,7 +821,7 @@ func (w *TestWorkspace) Tag(tagName string) error { func PrintPackage(paths ...string) error { path := filepath.Join(paths...) - return filepath.Walk(path, func(path string, info os.FileInfo, err error) error { + return filepath.Walk(path, func(path string, _ os.FileInfo, err error) error { if err != nil { return err } diff --git a/internal/util/argutil/argutil_test.go b/internal/util/argutil/argutil_test.go index 3f6388f06f..f8ff27f58a 100644 --- a/internal/util/argutil/argutil_test.go +++ b/internal/util/argutil/argutil_test.go @@ -20,7 +20,7 @@ import ( "testing" "github.com/GoogleContainerTools/kpt/internal/testutil" - . "github.com/GoogleContainerTools/kpt/internal/util/argutil" + "github.com/GoogleContainerTools/kpt/internal/util/argutil" "github.com/GoogleContainerTools/kpt/pkg/printer/fake" "github.com/stretchr/testify/assert" ) @@ -54,7 +54,7 @@ func TestParseDirVersion(t *testing.T) { in: "/some@dir2@ver1", expDir: "", expVer: "", - expErr: ErrMultiVersion, + expErr: argutil.ErrMultiVersion, }, { // empty in: "", @@ -65,7 +65,7 @@ func TestParseDirVersion(t *testing.T) { } for _, test := range tests { - gotDir, gotVer, gotErr := ParseDirVersion(test.in) + gotDir, gotVer, gotErr := argutil.ParseDirVersion(test.in) assert.Equal(t, gotErr, test.expErr) assert.Equal(t, gotDir, test.expDir) @@ -102,7 +102,7 @@ func TestParseDirVersionWithDefaults(t *testing.T) { in: "/some@dir2@ver1", expDir: "", expVer: "", - expErr: ErrMultiVersion, + expErr: argutil.ErrMultiVersion, }, { // empty in: "", @@ -113,7 +113,7 @@ func TestParseDirVersionWithDefaults(t *testing.T) { } for _, test := range tests { - gotDir, gotVer, gotErr := ParseDirVersionWithDefaults(test.in) + gotDir, gotVer, gotErr := argutil.ParseDirVersionWithDefaults(test.in) assert.Equal(t, gotErr, test.expErr) assert.Equal(t, gotDir, test.expDir) @@ -131,19 +131,19 @@ func TestResolveSymlink(t *testing.T) { err = os.Symlink("foo-link", "link-to-foo-link") assert.NoError(t, err) - actual1, err := ResolveSymlink(fake.CtxWithDefaultPrinter(), "foo-link") + actual1, err := argutil.ResolveSymlink(fake.CtxWithDefaultPrinter(), "foo-link") assert.NoError(t, err) assert.Equal(t, "foo", actual1) - actual2, err := ResolveSymlink(fake.CtxWithDefaultPrinter(), "link-to-foo-link") + actual2, err := argutil.ResolveSymlink(fake.CtxWithDefaultPrinter(), "link-to-foo-link") assert.NoError(t, err) assert.Equal(t, "foo", actual2) - actual3, err := ResolveSymlink(fake.CtxWithDefaultPrinter(), ".") + actual3, err := argutil.ResolveSymlink(fake.CtxWithDefaultPrinter(), ".") assert.NoError(t, err) assert.Equal(t, ".", actual3) - _, err = ResolveSymlink(fake.CtxWithDefaultPrinter(), "baz") + _, err = argutil.ResolveSymlink(fake.CtxWithDefaultPrinter(), "baz") assert.Error(t, err) assert.Equal(t, "lstat baz: no such file or directory", err.Error()) } diff --git a/internal/util/diff/diff_test.go b/internal/util/diff/diff_test.go index 27f1f74fab..030f4b2db3 100644 --- a/internal/util/diff/diff_test.go +++ b/internal/util/diff/diff_test.go @@ -28,7 +28,7 @@ import ( "github.com/GoogleContainerTools/kpt/internal/testutil" "github.com/GoogleContainerTools/kpt/internal/testutil/pkgbuilder" - . "github.com/GoogleContainerTools/kpt/internal/util/diff" + "github.com/GoogleContainerTools/kpt/internal/util/diff" "github.com/GoogleContainerTools/kpt/pkg/printer/fake" "github.com/stretchr/testify/assert" ) @@ -39,7 +39,7 @@ func TestCommand_Diff(t *testing.T) { updatedLocal testutil.Content fetchRef string diffRef string - diffType Type + diffType diff.Type diffTool string diffOpts string expDiff string @@ -67,7 +67,7 @@ func TestCommand_Diff(t *testing.T) { }, fetchRef: "v2", diffRef: "master", - diffType: TypeRemote, + diffType: diff.TypeRemote, diffTool: "diff", diffOpts: "-r -i -w", expDiff: ` @@ -107,7 +107,7 @@ func TestCommand_Diff(t *testing.T) { }, fetchRef: "v2", diffRef: "master", - diffType: TypeCombined, + diffType: diff.TypeCombined, diffTool: "diff", diffOpts: "-r -i -w", expDiff: ` @@ -148,7 +148,7 @@ func TestCommand_Diff(t *testing.T) { }, fetchRef: "v2", diffRef: "master", - diffType: TypeCombined, + diffType: diff.TypeCombined, diffTool: "diff", diffOpts: "-r -i -w", expDiff: ` @@ -194,7 +194,7 @@ func TestCommand_Diff(t *testing.T) { }, fetchRef: "main", diffRef: "main", - diffType: TypeCombined, + diffType: diff.TypeCombined, diffTool: "diff", diffOpts: "-r -i -w", expDiff: ` @@ -245,7 +245,7 @@ locally changed: foo }, fetchRef: "main", diffRef: "main", - diffType: TypeCombined, + diffType: diff.TypeCombined, diffTool: "diff", diffOpts: "-r -i -w", expDiff: ` @@ -300,7 +300,7 @@ locally changed: foo }, fetchRef: "main", diffRef: "main", - diffType: TypeCombined, + diffType: diff.TypeCombined, diffTool: "diff", diffOpts: "-r -i -w", expDiff: ` @@ -331,7 +331,7 @@ locally changed: foo } diffOutput := &bytes.Buffer{} - err := (&Command{ + err := (&diff.Command{ Path: g.LocalWorkspace.FullPackagePath(), Ref: tc.diffRef, DiffType: tc.diffType, @@ -378,10 +378,10 @@ func TestCommand_InvalidRef(t *testing.T) { } diffOutput := &bytes.Buffer{} - err := (&Command{ + err := (&diff.Command{ Path: g.LocalWorkspace.FullPackagePath(), Ref: "hurdygurdy", // ref should not exist in upstream - DiffType: TypeCombined, + DiffType: diff.TypeCombined, DiffTool: "diff", DiffToolOpts: "-r -i -w", Output: diffOutput, @@ -418,10 +418,10 @@ func TestCommand_Diff3Parameters(t *testing.T) { } diffOutput := &bytes.Buffer{} - err := (&Command{ + err := (&diff.Command{ Path: g.LocalWorkspace.FullPackagePath(), Ref: "master", - DiffType: Type3Way, + DiffType: diff.Type3Way, DiffTool: "echo", // this is a proxy for 3 way diffing to validate we pass proper values DiffToolOpts: "", Output: diffOutput, @@ -432,9 +432,9 @@ func TestCommand_Diff3Parameters(t *testing.T) { results := strings.Split(diffOutput.String(), " ") assert.Equal(t, 3, len(results)) // Validate diff argument ordering - assert.Contains(t, results[0], LocalPackageSource) - assert.Contains(t, results[1], RemotePackageSource) - assert.Contains(t, results[2], TargetRemotePackageSource) + assert.Contains(t, results[0], diff.LocalPackageSource) + assert.Contains(t, results[1], diff.RemotePackageSource) + assert.Contains(t, results[2], diff.TargetRemotePackageSource) } // Tests against directories in different states @@ -452,10 +452,10 @@ func TestCommand_NotAKptDirectory(t *testing.T) { for tn, tc := range testCases { t.Run(tn, func(t *testing.T) { diffOutput := &bytes.Buffer{} - cmdErr := (&Command{ + cmdErr := (&diff.Command{ Path: tc.directory, Ref: "master", - DiffType: TypeCombined, + DiffType: diff.TypeCombined, DiffTool: "diff", DiffToolOpts: "-r -i -w", Output: diffOutput, @@ -498,7 +498,7 @@ func TestStagingDirectoryNames(t *testing.T) { for i := range tests { tt := tests[i] t.Run(tt.expected, func(t *testing.T) { - result := NameStagingDirectory(tt.source, tt.branch) + result := diff.NameStagingDirectory(tt.source, tt.branch) assert.Equal(t, tt.expected, result) }) } diff --git a/internal/util/diff/pkgdiff.go b/internal/util/diff/pkgdiff.go index a2794b8ed2..5c326ebcef 100644 --- a/internal/util/diff/pkgdiff.go +++ b/internal/util/diff/pkgdiff.go @@ -107,7 +107,7 @@ func kptfilesEqual(pkg1, pkg2, filePath string) (bool, error) { func pkgSet(pkgPath string) (sets.String, error) { pkgFiles := sets.String{} - if err := pkgutil.WalkPackage(pkgPath, func(path string, info os.FileInfo, err error) error { + if err := pkgutil.WalkPackage(pkgPath, func(path string, _ os.FileInfo, err error) error { if err != nil { return err } diff --git a/internal/util/fetch/fetch_test.go b/internal/util/fetch/fetch_test.go index 2a85823512..08dc775eeb 100644 --- a/internal/util/fetch/fetch_test.go +++ b/internal/util/fetch/fetch_test.go @@ -23,7 +23,7 @@ import ( pkgtesting "github.com/GoogleContainerTools/kpt/internal/pkg/testing" "github.com/GoogleContainerTools/kpt/internal/testutil" "github.com/GoogleContainerTools/kpt/internal/testutil/pkgbuilder" - . "github.com/GoogleContainerTools/kpt/internal/util/fetch" + "github.com/GoogleContainerTools/kpt/internal/util/fetch" kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1" "github.com/GoogleContainerTools/kpt/pkg/kptfile/kptfileutil" "github.com/GoogleContainerTools/kpt/pkg/printer/fake" @@ -85,7 +85,7 @@ func TestCommand_Run_failNoKptfile(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, pkgPath), }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -104,7 +104,7 @@ func TestCommand_Run_failNoGit(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -127,7 +127,7 @@ func TestCommand_Run_failEmptyRepo(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -150,7 +150,7 @@ func TestCommand_Run_failNoRevision(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -177,7 +177,7 @@ func TestCommand_Run(t *testing.T) { } absPath := filepath.Join(w.WorkspaceDirectory, g.RepoName) - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) assert.NoError(t, err) @@ -240,7 +240,7 @@ func TestCommand_Run_subdir(t *testing.T) { } absPath := filepath.Join(w.WorkspaceDirectory, g.RepoName) - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) assert.NoError(t, err) @@ -318,7 +318,7 @@ func TestCommand_Run_branch(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) assert.NoError(t, err) @@ -400,7 +400,7 @@ func TestCommand_Run_tag(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) assert.NoError(t, err) @@ -510,7 +510,7 @@ func TestCommand_Run_subdir_at_tag(t *testing.T) { } actualPkg := pkgtesting.CreatePkgOrFail(t, rw.FullPackagePath()) - err = Command{ + err = fetch.Command{ Pkg: actualPkg, }.Run(fake.CtxWithDefaultPrinter()) if !assert.NoError(t, err) { @@ -568,7 +568,7 @@ func TestCommand_Run_no_subdir_at_valid_tag(t *testing.T) { } actualPkg := pkgtesting.CreatePkgOrFail(t, rw.FullPackagePath()) - err = Command{ + err = fetch.Command{ Pkg: actualPkg, }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -615,7 +615,7 @@ func TestCommand_Run_no_subdir_at_invalid_tag(t *testing.T) { } actualPkg := pkgtesting.CreatePkgOrFail(t, rw.FullPackagePath()) - err = Command{ + err = fetch.Command{ Pkg: actualPkg, }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -637,7 +637,7 @@ func TestCommand_Run_failInvalidRepo(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -661,7 +661,7 @@ func TestCommand_Run_failInvalidBranch(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -688,7 +688,7 @@ func TestCommand_Run_failInvalidTag(t *testing.T) { t.FailNow() } - err = Command{ + err = fetch.Command{ Pkg: pkgtesting.CreatePkgOrFail(t, w.FullPackagePath()), }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { diff --git a/internal/util/get/get_test.go b/internal/util/get/get_test.go index 6280e56a76..efb2228946 100644 --- a/internal/util/get/get_test.go +++ b/internal/util/get/get_test.go @@ -22,7 +22,7 @@ import ( "github.com/GoogleContainerTools/kpt/internal/testutil" "github.com/GoogleContainerTools/kpt/internal/testutil/pkgbuilder" - . "github.com/GoogleContainerTools/kpt/internal/util/get" + "github.com/GoogleContainerTools/kpt/internal/util/get" kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1" "github.com/GoogleContainerTools/kpt/pkg/printer/fake" "github.com/stretchr/testify/assert" @@ -42,7 +42,7 @@ func TestCommand_Run_failEmptyRepo(t *testing.T) { _, w, clean := testutil.SetupRepoAndWorkspace(t, testutil.Content{}) defer clean() - err := Command{ + err := get.Command{ Destination: w.WorkspaceDirectory, }.Run(fake.CtxWithDefaultPrinter()) if !assert.Error(t, err) { @@ -56,7 +56,7 @@ func TestCommand_Run_failNoRevision(t *testing.T) { _, w, clean := testutil.SetupRepoAndWorkspace(t, testutil.Content{}) defer clean() - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: "foo", }, @@ -82,7 +82,7 @@ func TestCommand_Run(t *testing.T) { defer testutil.Chdir(t, w.WorkspaceDirectory)() absPath := filepath.Join(w.WorkspaceDirectory, g.RepoName) - err := Command{Git: &kptfilev1.Git{ + err := get.Command{Git: &kptfilev1.Git{ Repo: "file://" + g.RepoDirectory, Ref: "master", Directory: "/", @@ -143,7 +143,7 @@ func TestCommand_Run_subdir(t *testing.T) { defer testutil.Chdir(t, w.WorkspaceDirectory)() absPath := filepath.Join(w.WorkspaceDirectory, subdir) - err := Command{Git: &kptfilev1.Git{ + err := get.Command{Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "refs/heads/master", Directory: subdir}, Destination: absPath, }.Run(fake.CtxWithDefaultPrinter()) @@ -207,7 +207,7 @@ func TestCommand_Run_subdir_symlinks(t *testing.T) { cliOutput := &bytes.Buffer{} absPath := filepath.Join(w.WorkspaceDirectory, subdir) - err := Command{Git: &kptfilev1.Git{ + err := get.Command{Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "refs/heads/master", Directory: subdir}, Destination: absPath, }.Run(fake.CtxWithPrinter(cliOutput, cliOutput)) @@ -271,7 +271,7 @@ func TestCommand_Run_destination(t *testing.T) { defer testutil.Chdir(t, w.WorkspaceDirectory)() absPath := filepath.Join(w.WorkspaceDirectory, dest) - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "master", @@ -335,7 +335,7 @@ func TestCommand_Run_subdirAndDestination(t *testing.T) { defer testutil.Chdir(t, w.WorkspaceDirectory)() absPath := filepath.Join(w.WorkspaceDirectory, dest) - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "master", @@ -415,7 +415,7 @@ func TestCommand_Run_branch(t *testing.T) { assert.NotEqual(t, commit, commit2) absPath := filepath.Join(w.WorkspaceDirectory, g.RepoName) - err = Command{ + err = get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "refs/heads/exp", @@ -498,7 +498,7 @@ func TestCommand_Run_tag(t *testing.T) { assert.NotEqual(t, commit, commit2) absPath := filepath.Join(w.WorkspaceDirectory, g.RepoName) - err = Command{ + err = get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "refs/tags/v2", @@ -639,7 +639,7 @@ func TestCommand_Run_ref(t *testing.T) { ref := tc.ref(repos) absPath := filepath.Join(w.WorkspaceDirectory, repos[testutil.Upstream].RepoName) - err = Command{ + err = get.Command{ Git: &kptfilev1.Git{ Repo: repos[testutil.Upstream].RepoDirectory, Ref: ref, @@ -668,7 +668,7 @@ func TestCommand_Run_failExistingDir(t *testing.T) { defer testutil.Chdir(t, w.WorkspaceDirectory)() absPath := filepath.Join(w.WorkspaceDirectory, g.RepoName) - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "master", @@ -722,7 +722,7 @@ func TestCommand_Run_failExistingDir(t *testing.T) { assert.NoError(t, err) // try to clone and expect a failure - err = Command{ + err = get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "master", @@ -779,7 +779,7 @@ func TestCommand_Run_nonexistingParentDir(t *testing.T) { defer testutil.Chdir(t, w.WorkspaceDirectory)() absPath := filepath.Join(w.WorkspaceDirectory, "more", "dirs", g.RepoName) - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Ref: "master", @@ -799,7 +799,7 @@ func TestCommand_Run_failInvalidRepo(t *testing.T) { defer clean() absPath := filepath.Join(w.WorkspaceDirectory, "foo") - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: "foo", Directory: "/", @@ -829,7 +829,7 @@ func TestCommand_Run_failInvalidBranch(t *testing.T) { defer clean() absPath := filepath.Join(w.WorkspaceDirectory, g.RepoDirectory) - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Directory: "/", @@ -862,7 +862,7 @@ func TestCommand_Run_failInvalidTag(t *testing.T) { defer clean() absPath := filepath.Join(w.WorkspaceDirectory, g.RepoDirectory) - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: g.RepoDirectory, Directory: "/", @@ -1387,7 +1387,7 @@ func TestCommand_Run_subpackages(t *testing.T) { w.PackageDir = targetDir destinationDir := filepath.Join(w.WorkspaceDirectory, targetDir) - err = Command{ + err = get.Command{ Git: &kptfilev1.Git{ Repo: upstreamRepo.RepoDirectory, Directory: tc.directory, @@ -1458,7 +1458,7 @@ func TestCommand_Run_symlinks(t *testing.T) { upstreamRepo := repos[testutil.Upstream] destinationDir := filepath.Join(w.WorkspaceDirectory, upstreamRepo.RepoName) - err := Command{ + err := get.Command{ Git: &kptfilev1.Git{ Repo: upstreamRepo.RepoDirectory, Directory: "/", diff --git a/internal/util/man/man.go b/internal/util/man/man.go index 88f575f7ed..b7f9fd5e11 100644 --- a/internal/util/man/man.go +++ b/internal/util/man/man.go @@ -53,7 +53,7 @@ const ManFilename = "README.md" func (m Command) Run() error { _, err := exec.LookPath(m.GetExecCmd()) if err != nil { - return errors.Errorf(m.GetExecCmd() + " not installed") + return errors.Errorf("%s not installed", m.GetExecCmd()) } // lookup the path to the man page diff --git a/internal/util/man/man_test.go b/internal/util/man/man_test.go index c2cf6215dc..4b6cd854c2 100644 --- a/internal/util/man/man_test.go +++ b/internal/util/man/man_test.go @@ -21,7 +21,7 @@ import ( "path/filepath" "testing" - . "github.com/GoogleContainerTools/kpt/internal/util/man" + man "github.com/GoogleContainerTools/kpt/internal/util/man" kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1" "github.com/stretchr/testify/assert" ) @@ -45,7 +45,7 @@ info: // write the man md file err = os.Mkdir(filepath.Join(d, "man"), 0700) assert.NoError(t, err) - err = os.WriteFile(filepath.Join(d, "man", ManFilename), []byte(` + err = os.WriteFile(filepath.Join(d, "man", man.ManFilename), []byte(` java 1 "June 2019" "Application" ================================================== @@ -86,7 +86,7 @@ Java server ConfigMap assert.NoError(t, err) b := &bytes.Buffer{} - instance := Command{ + instance := man.Command{ ManExecCommand: "cat", Path: d, StdOut: b, @@ -164,11 +164,11 @@ metadata: // but can be overridden func TestMan_GetExecCmd(t *testing.T) { // default to "man" - instance := Command{} + instance := man.Command{} assert.Equal(t, "man", instance.GetExecCmd()) // allow overrides for testing - instance = Command{ManExecCommand: "cat"} + instance = man.Command{ManExecCommand: "cat"} assert.Equal(t, "cat", instance.GetExecCmd()) } @@ -176,12 +176,12 @@ func TestMan_GetExecCmd(t *testing.T) { // but can be overridden. func TestMan_GetStdOut(t *testing.T) { // default to stdout - instance := Command{} + instance := man.Command{} assert.Equal(t, os.Stdout, instance.GetStdOut()) // allow overrides for testing b := &bytes.Buffer{} - instance = Command{StdOut: b} + instance = man.Command{StdOut: b} assert.Equal(t, b, instance.GetStdOut()) } @@ -203,7 +203,7 @@ info: } b := &bytes.Buffer{} - instance := Command{ + instance := man.Command{ ManExecCommand: "cat", Path: d, StdOut: b, @@ -234,7 +234,7 @@ info: assert.NoError(t, err) b := &bytes.Buffer{} - instance := Command{ + instance := man.Command{ ManExecCommand: "cat", Path: d, StdOut: b, @@ -262,7 +262,7 @@ info: assert.NoError(t, err) b := &bytes.Buffer{} - instance := Command{ + instance := man.Command{ ManExecCommand: "cat", Path: d, StdOut: b, @@ -276,7 +276,7 @@ info: // path is not under the package directory. func TestMan_Execute_failManNotInstalled(t *testing.T) { b := &bytes.Buffer{} - instance := Command{ + instance := man.Command{ ManExecCommand: "notrealprogram", Path: "path", StdOut: b, diff --git a/internal/util/parse/parse_test.go b/internal/util/parse/parse_test.go index b9d48bc932..b37347c443 100644 --- a/internal/util/parse/parse_test.go +++ b/internal/util/parse/parse_test.go @@ -170,7 +170,7 @@ func Test_pkgURLFromGHURL(t *testing.T) { r := require.New(t) ctx := printer.WithContext(context.Background(), printer.New(nil, nil)) // getBranches returns test branches slice - getBranches := func(ctx context.Context, repo string) ([]string, error) { + getBranches := func(_ context.Context, _ string) ([]string, error) { return tt.branches, nil } got, err := pkgURLFromGHURL(ctx, tt.ghURL, getBranches) diff --git a/internal/util/pkgutil/pkgutil.go b/internal/util/pkgutil/pkgutil.go index bf906c426d..c671d1b7f4 100644 --- a/internal/util/pkgutil/pkgutil.go +++ b/internal/util/pkgutil/pkgutil.go @@ -209,7 +209,7 @@ func RemovePackageContent(path string, removeRootKptfile bool) error { if err != nil { return err } - defer f.Close() + defer f.Close() // List up to one file or folder in the directory. _, err = f.Readdirnames(1) if err != nil && err != io.EOF { diff --git a/internal/util/pkgutil/pkgutil_test.go b/internal/util/pkgutil/pkgutil_test.go index 5914f85a3a..b183346c78 100644 --- a/internal/util/pkgutil/pkgutil_test.go +++ b/internal/util/pkgutil/pkgutil_test.go @@ -83,7 +83,7 @@ func TestWalkPackage(t *testing.T) { pkgPath := tc.pkg.ExpandPkg(t, testutil.EmptyReposInfo) var visited []string - if err := pkgutil.WalkPackage(pkgPath, func(s string, info os.FileInfo, err error) error { + if err := pkgutil.WalkPackage(pkgPath, func(s string, _ os.FileInfo, err error) error { if err != nil { return err } @@ -371,7 +371,7 @@ func TestCopyPackage(t *testing.T) { } var visited []string - if err = filepath.Walk(dest, func(s string, info os.FileInfo, err error) error { + if err = filepath.Walk(dest, func(s string, _ os.FileInfo, err error) error { if err != nil { return err } diff --git a/internal/util/render/executor.go b/internal/util/render/executor.go index 6db4b8dd5c..df7b500c1d 100644 --- a/internal/util/render/executor.go +++ b/internal/util/render/executor.go @@ -415,7 +415,7 @@ func (pn *pkgNode) runMutators(ctx context.Context, hctx *hydrationContext, inpu if len(selectors) > 0 || len(exclusions) > 0 { // set kpt-resource-id annotation on each resource before mutation - err = fnruntime.SetResourceIds(input) + err = fnruntime.SetResourceIDs(input) if err != nil { return nil, err } @@ -444,7 +444,7 @@ func (pn *pkgNode) runMutators(ctx context.Context, hctx *hydrationContext, inpu // merge the output resources with input resources input = fnruntime.MergeWithInput(output.Nodes, selectedInput, input) // delete the kpt-resource-id annotation on each resource - err = fnruntime.DeleteResourceIds(input) + err = fnruntime.DeleteResourceIDs(input) if err != nil { return nil, err } diff --git a/internal/util/update/fastforward_test.go b/internal/util/update/fastforward_test.go index 61274e2e25..83851c122c 100644 --- a/internal/util/update/fastforward_test.go +++ b/internal/util/update/fastforward_test.go @@ -21,7 +21,7 @@ import ( "github.com/GoogleContainerTools/kpt/internal/testutil" "github.com/GoogleContainerTools/kpt/internal/testutil/pkgbuilder" - . "github.com/GoogleContainerTools/kpt/internal/util/update" + "github.com/GoogleContainerTools/kpt/internal/util/update" "github.com/stretchr/testify/assert" ) @@ -170,9 +170,9 @@ func TestUpdate_FastForward(t *testing.T) { updated := tc.updated.ExpandPkg(t, repos) expected := tc.expected.ExpandPkg(t, repos) - updater := &FastForwardUpdater{} + updater := &update.FastForwardUpdater{} - err := updater.Update(Options{ + err := updater.Update(update.Options{ RelPackagePath: tc.relPackagePath, OriginPath: filepath.Join(origin, tc.relPackagePath), LocalPath: filepath.Join(local, tc.relPackagePath), diff --git a/internal/util/update/replace_test.go b/internal/util/update/replace_test.go index cee27af3b3..e54586756c 100644 --- a/internal/util/update/replace_test.go +++ b/internal/util/update/replace_test.go @@ -21,7 +21,7 @@ import ( "github.com/GoogleContainerTools/kpt/internal/testutil" "github.com/GoogleContainerTools/kpt/internal/testutil/pkgbuilder" - . "github.com/GoogleContainerTools/kpt/internal/util/update" + "github.com/GoogleContainerTools/kpt/internal/util/update" "github.com/stretchr/testify/assert" ) @@ -170,9 +170,9 @@ func TestUpdate_Replace(t *testing.T) { updated := tc.updated.ExpandPkg(t, repos) expected := tc.expected.ExpandPkg(t, repos) - updater := &ReplaceUpdater{} + updater := &update.ReplaceUpdater{} - err := updater.Update(Options{ + err := updater.Update(update.Options{ RelPackagePath: tc.relPackagePath, OriginPath: filepath.Join(origin, tc.relPackagePath), LocalPath: filepath.Join(local, tc.relPackagePath), diff --git a/internal/util/update/resource-merge_test.go b/internal/util/update/resource-merge_test.go index d93acd95e5..aab486dda3 100644 --- a/internal/util/update/resource-merge_test.go +++ b/internal/util/update/resource-merge_test.go @@ -21,7 +21,7 @@ import ( "github.com/GoogleContainerTools/kpt/internal/testutil" "github.com/GoogleContainerTools/kpt/internal/testutil/pkgbuilder" - . "github.com/GoogleContainerTools/kpt/internal/util/update" + "github.com/GoogleContainerTools/kpt/internal/util/update" "github.com/stretchr/testify/assert" ) @@ -283,9 +283,9 @@ func TestUpdate_ResourceMerge(t *testing.T) { updated := tc.updated.ExpandPkg(t, repos) expected := tc.expected.ExpandPkg(t, repos) - updater := &ResourceMergeUpdater{} + updater := &update.ResourceMergeUpdater{} - err := updater.Update(Options{ + err := updater.Update(update.Options{ RelPackagePath: tc.relPackagePath, OriginPath: filepath.Join(origin, tc.relPackagePath), LocalPath: filepath.Join(local, tc.relPackagePath), diff --git a/internal/util/update/update_test.go b/internal/util/update/update_test.go index df8ee6ea9f..05b7be7c6d 100644 --- a/internal/util/update/update_test.go +++ b/internal/util/update/update_test.go @@ -26,7 +26,7 @@ import ( pkgtest "github.com/GoogleContainerTools/kpt/internal/pkg/testing" "github.com/GoogleContainerTools/kpt/internal/testutil" "github.com/GoogleContainerTools/kpt/internal/testutil/pkgbuilder" - . "github.com/GoogleContainerTools/kpt/internal/util/update" + "github.com/GoogleContainerTools/kpt/internal/util/update" kptfilev1 "github.com/GoogleContainerTools/kpt/pkg/api/kptfile/v1" "github.com/GoogleContainerTools/kpt/pkg/kptfile/kptfileutil" "github.com/GoogleContainerTools/kpt/pkg/printer/fake" @@ -75,7 +75,7 @@ func TestCommand_Run_noRefChanges(t *testing.T) { return } upstreamRepo := g.Repos[testutil.Upstream] - cmd := &Command{ + cmd := &update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Strategy: strategy, } @@ -138,7 +138,7 @@ func TestCommand_Run_subDir(t *testing.T) { upstreamRepo := g.Repos[testutil.Upstream] // Update the local package - if !assert.NoError(t, (&Command{ + if !assert.NoError(t, (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Ref: "v1.2", Strategy: strategy, @@ -194,7 +194,7 @@ func TestCommand_Run_noChanges(t *testing.T) { upstreamRepo := g.Repos[testutil.Upstream] // Update the local package - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Strategy: u.updater, }).Run(fake.CtxWithDefaultPrinter()) @@ -376,7 +376,7 @@ func TestCommand_Run_localPackageChanges(t *testing.T) { } // run the command - err = (&Command{ + err = (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Ref: masterBranch, Strategy: tc.strategy, @@ -446,7 +446,7 @@ func TestCommand_Run_toBranchRef(t *testing.T) { upstreamRepo := g.Repos[testutil.Upstream] // Update the local package - if !assert.NoError(t, (&Command{ + if !assert.NoError(t, (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Strategy: strategy, Ref: "exp", @@ -810,7 +810,7 @@ func TestCommand_Run_toBranchRefWithSubpkgs(t *testing.T) { } // Update the local package - if !assert.NoError(t, (&Command{ + if !assert.NoError(t, (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, path.Join(g.LocalWorkspace.FullPackagePath(), tc.updateSubPkg)), Strategy: tc.strategy, Ref: tc.updateRef, @@ -856,7 +856,7 @@ func TestCommand_Run_toTagRef(t *testing.T) { upstreamRepo := g.Repos[testutil.Upstream] // Update the local package - if !assert.NoError(t, (&Command{ + if !assert.NoError(t, (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Strategy: strategy, Ref: "v1.0", @@ -913,7 +913,7 @@ func TestCommand_ResourceMerge_NonKRMUpdates(t *testing.T) { upstreamRepo := g.Repos[testutil.Upstream] // Update the local package - if !assert.NoError(t, (&Command{ + if !assert.NoError(t, (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Strategy: strategy, Ref: "v1.0", @@ -956,7 +956,7 @@ func TestCommand_Run_noUpstreamReference(t *testing.T) { testutil.AddKptfileToWorkspace(t, w, kf) // Update the local package - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, w.FullPackagePath()), }).Run(fake.CtxWithDefaultPrinter()) @@ -969,7 +969,7 @@ func TestCommand_Run_failInvalidPath(t *testing.T) { strategy := kptfilev1.UpdateStrategies[i] t.Run(string(strategy), func(t *testing.T) { path := filepath.Join("fake", "path") - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, path), Strategy: strategy, }).Run(fake.CtxWithDefaultPrinter()) @@ -1034,7 +1034,7 @@ func TestCommand_Run_badUpstreamLock(t *testing.T) { } // Update the local package. - err = (&Command{ + err = (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), }).Run(fake.CtxWithDefaultPrinter()) @@ -1069,7 +1069,7 @@ func TestCommand_Run_failInvalidRef(t *testing.T) { return } - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Ref: "exp", Strategy: strategy, @@ -1127,7 +1127,7 @@ func TestCommand_Run_manualChange(t *testing.T) { return } - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), }).Run(fake.CtxWithDefaultPrinter()) if !assert.NoError(t, err) { @@ -1181,7 +1181,7 @@ func TestCommand_Run_symlinks(t *testing.T) { } upstreamRepo := g.Repos[testutil.Upstream] - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), }).Run(fake.CtxWithDefaultPrinter()) if !assert.NoError(t, err) { @@ -1229,7 +1229,7 @@ func TestCommand_Run_badStrategy(t *testing.T) { } // Update the local package - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Strategy: strategy, }).Run(fake.CtxWithDefaultPrinter()) @@ -2008,7 +2008,7 @@ func TestCommand_Run_local_subpackages(t *testing.T) { return } - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), Strategy: strategy, }).Run(fake.CtxWithDefaultPrinter()) @@ -3548,7 +3548,7 @@ func TestRun_remote_subpackages(t *testing.T) { return } - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, g.LocalWorkspace.FullPackagePath()), }).Run(fake.CtxWithDefaultPrinter()) @@ -3693,7 +3693,7 @@ func TestRootPackageIsUnfetched(t *testing.T) { } testutil.AddKptfileToWorkspace(t, w, kf) - err := (&Command{ + err := (&update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, w.FullPackagePath()), }).Run(fake.CtxWithDefaultPrinter()) if !assert.NoError(t, err) { @@ -3764,7 +3764,7 @@ func TestMultiUpdateCache(t *testing.T) { UpdateStrategy: kptfilev1.ResourceMerge, } testutil.AddKptfileToWorkspace(t, w, kf) - cmd := Command{ + cmd := update.Command{ Pkg: pkgtest.CreatePkgOrFail(t, w.FullPackagePath()), } err := cmd.Run(fake.CtxWithDefaultPrinter()) @@ -3869,7 +3869,7 @@ func TestReplaceNonKRMFiles(t *testing.T) { // expectedLocal. err = os.WriteFile(filepath.Join(updated, "new.yaml"), []byte("a: b"), 0600) assert.NoError(t, err) - err = ReplaceNonKRMFiles(updated, original, local) + err = update.ReplaceNonKRMFiles(updated, original, local) assert.NoError(t, err) tg := testutil.TestGitRepo{} tg.AssertEqual(t, local, expectedLocal, false) diff --git a/run/run.go b/run/run.go index 8b2598cc61..a750ca3a87 100644 --- a/run/run.go +++ b/run/run.go @@ -44,7 +44,7 @@ func GetMain(ctx context.Context) *cobra.Command { // We handle all errors in main after return from cobra so we can // adjust the error message coming from libraries SilenceErrors: true, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { h, err := cmd.Flags().GetBool("help") if err != nil { return err @@ -158,7 +158,7 @@ var version = "unknown" var versionCmd = &cobra.Command{ Use: "version", Short: "Print the version number of kpt", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { fmt.Printf("%s\n", version) }, } diff --git a/thirdparty/kyaml/runfn/runfn.go b/thirdparty/kyaml/runfn/runfn.go index d632540c04..b446c6c8b8 100644 --- a/thirdparty/kyaml/runfn/runfn.go +++ b/thirdparty/kyaml/runfn/runfn.go @@ -193,7 +193,7 @@ func (r RunFns) runFunctions(input kio.Reader, output kio.Writer, fltrs []kio.Fi selectedInput := inputResources if !r.Selector.IsEmpty() || !r.Exclusion.IsEmpty() { - err = fnruntime.SetResourceIds(inputResources) + err = fnruntime.SetResourceIDs(inputResources) if err != nil { return err } @@ -221,7 +221,7 @@ func (r RunFns) runFunctions(input kio.Reader, output kio.Writer, fltrs []kio.Fi if !r.Selector.IsEmpty() || !r.Exclusion.IsEmpty() { outputResources = fnruntime.MergeWithInput(pb.Nodes, selectedInput, inputResources) - deleteAnnoErr := fnruntime.DeleteResourceIds(outputResources) + deleteAnnoErr := fnruntime.DeleteResourceIDs(outputResources) if deleteAnnoErr != nil { return deleteAnnoErr }