diff --git a/.golangci.yml b/.golangci.yml index db63cd4588..e78943727d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -68,6 +68,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt diff --git a/docs/book/src/cronjob-tutorial/testdata/project/.golangci.yml b/docs/book/src/cronjob-tutorial/testdata/project/.golangci.yml index ca69a11f6f..709ef192a1 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/.golangci.yml +++ b/docs/book/src/cronjob-tutorial/testdata/project/.golangci.yml @@ -22,6 +22,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt diff --git a/docs/book/src/getting-started/testdata/project/.golangci.yml b/docs/book/src/getting-started/testdata/project/.golangci.yml index ca69a11f6f..709ef192a1 100644 --- a/docs/book/src/getting-started/testdata/project/.golangci.yml +++ b/docs/book/src/getting-started/testdata/project/.golangci.yml @@ -22,6 +22,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt diff --git a/pkg/cli/cli_test.go b/pkg/cli/cli_test.go index 3fe5cfab34..ce01d2a4d9 100644 --- a/pkg/cli/cli_test.go +++ b/pkg/cli/cli_test.go @@ -372,7 +372,7 @@ plugins: c.projectVersion = projectVersion Expect(c.resolvePlugins()).To(Succeed()) - Expect(len(c.resolvedPlugins)).To(Equal(1)) + Expect(c.resolvedPlugins).To(HaveLen(1)) Expect(plugin.KeyFor(c.resolvedPlugins[0])).To(Equal(qualified)) }, Entry("fully qualified plugin", "foo.example.com/v1", "foo.example.com/v1"), diff --git a/pkg/cli/options_test.go b/pkg/cli/options_test.go index 994b759345..c5847cc474 100644 --- a/pkg/cli/options_test.go +++ b/pkg/cli/options_test.go @@ -51,33 +51,33 @@ var _ = Describe("Discover external plugins", func() { BeforeEach(func() { originalXdghome = os.Getenv("XDG_CONFIG_HOME") err := os.Unsetenv("XDG_CONFIG_HOME") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { if originalXdghome != "" { // restore the original value err := os.Setenv("XDG_CONFIG_HOME", originalXdghome) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } }) It("should return the correct path for the darwin OS", func() { plgPath, err := getPluginsRoot("darwin") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(plgPath).To(Equal(fmt.Sprintf("%s/Library/Application Support/kubebuilder/plugins", homePath))) }) It("should return the correct path for the linux OS", func() { plgPath, err := getPluginsRoot("linux") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(plgPath).To(Equal(fmt.Sprintf("%s/.config/kubebuilder/plugins", homePath))) }) It("should return error when the host is not darwin / linux", func() { plgPath, err := getPluginsRoot("random") Expect(plgPath).To(Equal("")) - Expect(err).ToNot(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("host not supported")) }) }) @@ -87,7 +87,7 @@ var _ = Describe("Discover external plugins", func() { // store and set the XDG_CONFIG_HOME originalXdghome = os.Getenv("XDG_CONFIG_HOME") err := os.Setenv("XDG_CONFIG_HOME", fmt.Sprintf("%s/.config", homePath)) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) xdghome = os.Getenv("XDG_CONFIG_HOME") }) @@ -96,30 +96,30 @@ var _ = Describe("Discover external plugins", func() { if originalXdghome != "" { // restore the original value err := os.Setenv("XDG_CONFIG_HOME", originalXdghome) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } else { // unset if it was originally unset err := os.Unsetenv("XDG_CONFIG_HOME") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } }) It("should return the correct path for the darwin OS", func() { plgPath, err := getPluginsRoot("darwin") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(plgPath).To(Equal(fmt.Sprintf("%s/kubebuilder/plugins", xdghome))) }) It("should return the correct path for the linux OS", func() { plgPath, err := getPluginsRoot("linux") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(plgPath).To(Equal(fmt.Sprintf("%s/kubebuilder/plugins", xdghome))) }) It("should return error when the host is not darwin / linux", func() { plgPath, err := getPluginsRoot("random") Expect(plgPath).To(Equal("")) - Expect(err).ToNot(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("host not supported")) }) }) @@ -127,42 +127,42 @@ var _ = Describe("Discover external plugins", func() { When("using the custom path", func() { BeforeEach(func() { err := os.MkdirAll(customPath, 0750) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) // store and set the EXTERNAL_PLUGINS_PATH originalPluginPath = os.Getenv("EXTERNAL_PLUGINS_PATH") err = os.Setenv("EXTERNAL_PLUGINS_PATH", customPath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { if originalPluginPath != "" { // restore the original value err := os.Setenv("EXTERNAL_PLUGINS_PATH", originalPluginPath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } else { // unset if it was originally unset err := os.Unsetenv("EXTERNAL_PLUGINS_PATH") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } }) It("should return the user given path for darwin OS", func() { plgPath, err := getPluginsRoot("darwin") Expect(plgPath).To(Equal(customPath)) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should return the user given path for linux OS", func() { plgPath, err := getPluginsRoot("linux") Expect(plgPath).To(Equal(customPath)) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should report error when the host is not darwin / linux", func() { plgPath, err := getPluginsRoot("random") Expect(plgPath).To(Equal("")) - Expect(err).ToNot(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("host not supported")) }) }) @@ -174,36 +174,36 @@ var _ = Describe("Discover external plugins", func() { BeforeEach(func() { originalPluginPath = os.Getenv("EXTERNAL_PLUGINS_PATH") err := os.Setenv("EXTERNAL_PLUGINS_PATH", "/non/existent/path") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { if originalPluginPath != "" { // restore the original value err := os.Setenv("EXTERNAL_PLUGINS_PATH", originalPluginPath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } else { // unset if it was originally unset err := os.Unsetenv("EXTERNAL_PLUGINS_PATH") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } }) It("should return an error for the darwin OS", func() { plgPath, err := getPluginsRoot("darwin") - Expect(err).ToNot(BeNil()) + Expect(err).To(HaveOccurred()) Expect(plgPath).To(Equal("")) }) It("should return an error for the linux OS", func() { plgPath, err := getPluginsRoot("linux") - Expect(err).ToNot(BeNil()) + Expect(err).To(HaveOccurred()) Expect(plgPath).To(Equal("")) }) It("should return an error when the host is not darwin / linux", func() { plgPath, err := getPluginsRoot("random") - Expect(err).ToNot(BeNil()) + Expect(err).To(HaveOccurred()) Expect(plgPath).To(Equal("")) }) }) @@ -231,20 +231,20 @@ var _ = Describe("Discover external plugins", func() { } pluginPath, err = getPluginsRoot(runtime.GOOS) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) pluginFileName = "externalPlugin.sh" pluginFilePath = filepath.Join(pluginPath, "externalPlugin", "v1", pluginFileName) err = fs.FS.MkdirAll(filepath.Dir(pluginFilePath), 0o700) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) f, err = fs.FS.Create(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(f).ToNot(BeNil()) _, err = fs.FS.Stat(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should discover the external plugin executable without any errors", func() { @@ -257,12 +257,12 @@ var _ = Describe("Discover external plugins", func() { Expect(err).To(Not(HaveOccurred())) _, err = fs.FS.Stat(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) ps, err := DiscoverExternalPlugins(fs.FS) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(ps).NotTo(BeNil()) - Expect(len(ps)).To(Equal(1)) + Expect(ps).To(HaveLen(1)) Expect(ps[0].Name()).To(Equal("externalPlugin")) Expect(ps[0].Version().Number).To(Equal(1)) }) @@ -275,11 +275,11 @@ var _ = Describe("Discover external plugins", func() { pluginFilePath = filepath.Join(pluginPath, "myotherexternalPlugin", "v1", pluginFileName) f, err = fs.FS.Create(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(f).ToNot(BeNil()) _, err = fs.FS.Stat(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) _, err = f.WriteString(testPluginScript) Expect(err).To(Not(HaveOccurred())) @@ -289,12 +289,12 @@ var _ = Describe("Discover external plugins", func() { Expect(err).To(Not(HaveOccurred())) _, err = fs.FS.Stat(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) ps, err := DiscoverExternalPlugins(fs.FS) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(ps).NotTo(BeNil()) - Expect(len(ps)).To(Equal(2)) + Expect(ps).To(HaveLen(2)) Expect(ps[0].Name()).To(Equal("externalPlugin")) Expect(ps[1].Name()).To(Equal("myotherexternalPlugin")) @@ -307,7 +307,7 @@ var _ = Describe("Discover external plugins", func() { } pluginPath, err = getPluginsRoot(runtime.GOOS) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should error if the plugin found is not an executable", func() { @@ -315,23 +315,23 @@ var _ = Describe("Discover external plugins", func() { pluginFilePath = filepath.Join(pluginPath, "externalPlugin", "v1", pluginFileName) err = fs.FS.MkdirAll(filepath.Dir(pluginFilePath), 0o700) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) f, err := fs.FS.Create(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(f).ToNot(BeNil()) _, err = fs.FS.Stat(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) // set the plugin file permissions to read-only err = fs.FS.Chmod(pluginFilePath, 0o444) Expect(err).To(Not(HaveOccurred())) ps, err := DiscoverExternalPlugins(fs.FS) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("not an executable")) - Expect(len(ps)).To(Equal(0)) + Expect(ps).To(BeEmpty()) }) It("should error if the plugin found has an invalid plugin name", func() { @@ -339,16 +339,16 @@ var _ = Describe("Discover external plugins", func() { pluginFilePath = filepath.Join(pluginPath, "externalPlugin", "v1", pluginFileName) err = fs.FS.MkdirAll(filepath.Dir(pluginFilePath), 0o700) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) f, err = fs.FS.Create(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(f).ToNot(BeNil()) ps, err := DiscoverExternalPlugins(fs.FS) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("Invalid plugin name found")) - Expect(len(ps)).To(Equal(0)) + Expect(ps).To(BeEmpty()) }) }) @@ -359,7 +359,7 @@ var _ = Describe("Discover external plugins", func() { } pluginPath, err = getPluginsRoot(runtime.GOOS) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should skip adding the external plugin and not return any errors", func() { @@ -367,18 +367,18 @@ var _ = Describe("Discover external plugins", func() { pluginFilePath = filepath.Join(pluginPath, "externalPlugin", "v1", pluginFileName) err = fs.FS.MkdirAll(filepath.Dir(pluginFilePath), 0o700) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) f, err = fs.FS.Create(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(f).ToNot(BeNil()) err = fs.FS.Chmod(pluginFilePath, filePermissions) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) ps, err := DiscoverExternalPlugins(fs.FS) - Expect(err).To(BeNil()) - Expect(len(ps)).To(Equal(0)) + Expect(err).ToNot(HaveOccurred()) + Expect(ps).To(BeEmpty()) }) It("should fail if pluginsroot is empty", func() { @@ -388,7 +388,7 @@ var _ = Describe("Discover external plugins", func() { } _, err := DiscoverExternalPlugins(fs.FS) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err).To(Equal(errPluginsRoot)) }) @@ -399,34 +399,34 @@ var _ = Describe("Discover external plugins", func() { } _, err := DiscoverExternalPlugins(fs.FS) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should return full path to the external plugins without XDG_CONFIG_HOME", func() { if _, ok := os.LookupEnv("XDG_CONFIG_HOME"); ok { err = os.Setenv("XDG_CONFIG_HOME", "") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } home := os.Getenv("HOME") pluginsRoot, err := getPluginsRoot("darwin") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) expected := filepath.Join(home, "Library", "Application Support", "kubebuilder", "plugins") Expect(pluginsRoot).To(Equal(expected)) pluginsRoot, err = getPluginsRoot("linux") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) expected = filepath.Join(home, ".config", "kubebuilder", "plugins") Expect(pluginsRoot).To(Equal(expected)) }) It("should return full path to the external plugins with XDG_CONFIG_HOME", func() { err = os.Setenv("XDG_CONFIG_HOME", "/some/random/path") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) pluginsRoot, err := getPluginsRoot(runtime.GOOS) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(pluginsRoot).To(Equal("/some/random/path/kubebuilder/plugins")) }) @@ -435,18 +435,18 @@ var _ = Describe("Discover external plugins", func() { if !ok { } else { err = os.Setenv("XDG_CONFIG_HOME", "") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } _, ok = os.LookupEnv("HOME") if !ok { } else { err = os.Setenv("HOME", "") - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) } pluginsroot, err := getPluginsRoot(runtime.GOOS) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(pluginsroot).To(Equal("")) Expect(err.Error()).To(ContainSubstring("error retrieving home dir")) }) @@ -681,7 +681,7 @@ var _ = Describe("CLI options", func() { Expect(err).NotTo(HaveOccurred()) Expect(c).NotTo(BeNil()) Expect(c.extraCommands).NotTo(BeNil()) - Expect(len(c.extraCommands)).To(Equal(1)) + Expect(c.extraCommands).To(HaveLen(1)) Expect(c.extraCommands[0]).NotTo(BeNil()) Expect(c.extraCommands[0].Use).To(Equal(commandTest.Use)) }) @@ -696,7 +696,7 @@ var _ = Describe("CLI options", func() { Expect(err).NotTo(HaveOccurred()) Expect(c).NotTo(BeNil()) Expect(c.extraAlphaCommands).NotTo(BeNil()) - Expect(len(c.extraAlphaCommands)).To(Equal(1)) + Expect(c.extraAlphaCommands).To(HaveLen(1)) Expect(c.extraAlphaCommands[0]).NotTo(BeNil()) Expect(c.extraAlphaCommands[0].Use).To(Equal(commandTest.Use)) }) diff --git a/pkg/config/v3/config_test.go b/pkg/config/v3/config_test.go index e8fac688fd..94a61c0105 100644 --- a/pkg/config/v3/config_test.go +++ b/pkg/config/v3/config_test.go @@ -231,7 +231,7 @@ var _ = Describe("Cfg", func() { It("AddResource should add the provided resource if non-existent", func() { l := len(c.Resources) Expect(c.AddResource(res)).To(Succeed()) - Expect(len(c.Resources)).To(Equal(l + 1)) + Expect(c.Resources).To(HaveLen(l + 1)) checkResource(c.Resources[0], resWithoutPlural) }) @@ -240,13 +240,13 @@ var _ = Describe("Cfg", func() { c.Resources = append(c.Resources, res) l := len(c.Resources) Expect(c.AddResource(res)).To(Succeed()) - Expect(len(c.Resources)).To(Equal(l)) + Expect(c.Resources).To(HaveLen(l)) }) It("UpdateResource should add the provided resource if non-existent", func() { l := len(c.Resources) Expect(c.UpdateResource(res)).To(Succeed()) - Expect(len(c.Resources)).To(Equal(l + 1)) + Expect(c.Resources).To(HaveLen(l + 1)) checkResource(c.Resources[0], resWithoutPlural) }) @@ -265,7 +265,7 @@ var _ = Describe("Cfg", func() { checkResource(c.Resources[0], r) Expect(c.UpdateResource(res)).To(Succeed()) - Expect(len(c.Resources)).To(Equal(l)) + Expect(c.Resources).To(HaveLen(l)) checkResource(c.Resources[0], resWithoutPlural) }) diff --git a/pkg/internal/validation/dns_test.go b/pkg/internal/validation/dns_test.go index b3ec7925bc..87b565ede6 100644 --- a/pkg/internal/validation/dns_test.go +++ b/pkg/internal/validation/dns_test.go @@ -38,7 +38,7 @@ var _ = Describe("IsDNS1123Label", func() { strings.Repeat("a", 56), } { By(fmt.Sprintf("for %s", value)) - Expect(len(IsDNS1123Label(value))).To(Equal(0)) + Expect(IsDNS1123Label(value)).To(BeEmpty()) } }) @@ -52,7 +52,7 @@ var _ = Describe("IsDNS1123Label", func() { strings.Repeat("a", 57), } { By(fmt.Sprintf("for %s", value)) - Expect(len(IsDNS1123Label(value))).NotTo(Equal(0)) + Expect(IsDNS1123Label(value)).NotTo(BeEmpty()) } }) }) @@ -70,7 +70,7 @@ var _ = Describe("IsDNS1123Subdomain", func() { strings.Repeat("a", 253), } { By(fmt.Sprintf("for %s", value)) - Expect(len(IsDNS1123Subdomain(value))).To(Equal(0)) + Expect(IsDNS1123Subdomain(value)).To(BeEmpty()) } }) @@ -90,7 +90,7 @@ var _ = Describe("IsDNS1123Subdomain", func() { strings.Repeat("a", 254), } { By(fmt.Sprintf("for %s", value)) - Expect(len(IsDNS1123Subdomain(value))).NotTo(Equal(0)) + Expect(IsDNS1123Subdomain(value)).NotTo(BeEmpty()) } }) }) @@ -102,7 +102,7 @@ var _ = Describe("IsDNS1035Label", func() { strings.Repeat("a", 63), } { By(fmt.Sprintf("for %s", value)) - Expect(len(IsDNS1035Label(value))).To(Equal(0)) + Expect(IsDNS1035Label(value)).To(BeEmpty()) } }) @@ -117,7 +117,7 @@ var _ = Describe("IsDNS1035Label", func() { strings.Repeat("a", 64), } { By(fmt.Sprintf("for %s", value)) - Expect(len(IsDNS1035Label(value))).NotTo(Equal(0)) + Expect(IsDNS1035Label(value)).NotTo(BeEmpty()) } }) }) diff --git a/pkg/plugins/external/external_test.go b/pkg/plugins/external/external_test.go index 327e338900..53169b4ff7 100644 --- a/pkg/plugins/external/external_test.go +++ b/pkg/plugins/external/external_test.go @@ -128,14 +128,14 @@ var _ = Describe("Run external plugin using Scaffold", func() { pluginFilePath := filepath.Join("tmp", "externalPlugin", pluginFileName) err = fs.FS.MkdirAll(filepath.Dir(pluginFilePath), filePerm) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) f, err = fs.FS.Create(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(f).ToNot(BeNil()) _, err = fs.FS.Stat(pluginFilePath) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) args = []string{"--domain", "example.com"} }) @@ -143,7 +143,7 @@ var _ = Describe("Run external plugin using Scaffold", func() { AfterEach(func() { filename := filepath.Join("tmp", "externalPlugin", "LICENSE") fileInfo, err := fs.FS.Stat(filename) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) Expect(fileInfo).NotTo(BeNil()) }) @@ -154,7 +154,7 @@ var _ = Describe("Run external plugin using Scaffold", func() { } err = i.Scaffold(fs) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should successfully run edit subcommand on the external plugin", func() { @@ -164,7 +164,7 @@ var _ = Describe("Run external plugin using Scaffold", func() { } err = e.Scaffold(fs) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should successfully run create api subcommand on the external plugin", func() { @@ -174,7 +174,7 @@ var _ = Describe("Run external plugin using Scaffold", func() { } err = c.Scaffold(fs) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) It("should successfully run create webhook subcommand on the external plugin", func() { @@ -184,7 +184,7 @@ var _ = Describe("Run external plugin using Scaffold", func() { } err = c.Scaffold(fs) - Expect(err).To(BeNil()) + Expect(err).ToNot(HaveOccurred()) }) }) @@ -213,14 +213,14 @@ var _ = Describe("Run external plugin using Scaffold", func() { } err = i.Scaffold(fs) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("error getting exec command output")) outputGetter = &mockValidOutputGetter{} currentDirGetter = &mockInValidOsWdGetter{} err = i.Scaffold(fs) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("error getting current directory")) }) @@ -231,14 +231,14 @@ var _ = Describe("Run external plugin using Scaffold", func() { } err = e.Scaffold(fs) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("error getting exec command output")) outputGetter = &mockValidOutputGetter{} currentDirGetter = &mockInValidOsWdGetter{} err = e.Scaffold(fs) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("error getting current directory")) }) @@ -249,14 +249,14 @@ var _ = Describe("Run external plugin using Scaffold", func() { } err = c.Scaffold(fs) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("error getting exec command output")) outputGetter = &mockValidOutputGetter{} currentDirGetter = &mockInValidOsWdGetter{} err = c.Scaffold(fs) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("error getting current directory")) }) @@ -267,14 +267,14 @@ var _ = Describe("Run external plugin using Scaffold", func() { } err = c.Scaffold(fs) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("error getting exec command output")) outputGetter = &mockValidOutputGetter{} currentDirGetter = &mockInValidOsWdGetter{} err = c.Scaffold(fs) - Expect(err).NotTo(BeNil()) + Expect(err).To(HaveOccurred()) Expect(err.Error()).To(ContainSubstring("error getting current directory")) }) }) @@ -726,7 +726,7 @@ var _ = Describe("Run external plugin using Scaffold", func() { universe, err := getUniverseMap(fs) Expect(err).ToNot(HaveOccurred()) - Expect(len(universe)).To(Equal(len(files))) + Expect(universe).To(HaveLen(len(files))) for _, file := range files { content := universe[filepath.Join(file.path, file.name)] diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/golangci.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/golangci.go index a7a01a45f5..88adb2cc16 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/golangci.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/golangci.go @@ -66,6 +66,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt diff --git a/testdata/project-v4-multigroup-with-deploy-image/.golangci.yml b/testdata/project-v4-multigroup-with-deploy-image/.golangci.yml index ca69a11f6f..709ef192a1 100644 --- a/testdata/project-v4-multigroup-with-deploy-image/.golangci.yml +++ b/testdata/project-v4-multigroup-with-deploy-image/.golangci.yml @@ -22,6 +22,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt diff --git a/testdata/project-v4-multigroup/.golangci.yml b/testdata/project-v4-multigroup/.golangci.yml index ca69a11f6f..709ef192a1 100644 --- a/testdata/project-v4-multigroup/.golangci.yml +++ b/testdata/project-v4-multigroup/.golangci.yml @@ -22,6 +22,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt diff --git a/testdata/project-v4-with-deploy-image/.golangci.yml b/testdata/project-v4-with-deploy-image/.golangci.yml index ca69a11f6f..709ef192a1 100644 --- a/testdata/project-v4-with-deploy-image/.golangci.yml +++ b/testdata/project-v4-with-deploy-image/.golangci.yml @@ -22,6 +22,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt diff --git a/testdata/project-v4-with-grafana/.golangci.yml b/testdata/project-v4-with-grafana/.golangci.yml index ca69a11f6f..709ef192a1 100644 --- a/testdata/project-v4-with-grafana/.golangci.yml +++ b/testdata/project-v4-with-grafana/.golangci.yml @@ -22,6 +22,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt diff --git a/testdata/project-v4/.golangci.yml b/testdata/project-v4/.golangci.yml index ca69a11f6f..709ef192a1 100644 --- a/testdata/project-v4/.golangci.yml +++ b/testdata/project-v4/.golangci.yml @@ -22,6 +22,7 @@ linters: - dupl - errcheck - exportloopref + - ginkgolinter - goconst - gocyclo - gofmt