From 5bfdd11c409982b68c60c79559bd2a47599c4e94 Mon Sep 17 00:00:00 2001 From: Sajiyah Salat <109643863+Sajiyah-Salat@users.noreply.github.com> Date: Wed, 18 Jan 2023 07:39:17 +0530 Subject: [PATCH 01/23] Update cronjob_types.go --- .../cronjob-tutorial/testdata/project/api/v1/cronjob_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_types.go b/docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_types.go index 1e53e12f78c..46d5bd69b04 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_types.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_types.go @@ -1,5 +1,5 @@ /* -Copyright 2022 The Kubernetes authors. +Copyright 2023 The Kubernetes authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 2e0a0fb4d0586b9f1794655d2d801e21d455c276 Mon Sep 17 00:00:00 2001 From: El Mehdi Rami Date: Wed, 22 Feb 2023 21:43:49 +0100 Subject: [PATCH 02/23] fix: XDG_CONFIG_HOME external plugin discovery --- pkg/cli/options.go | 45 +++++++++++++++++++++++------------------ pkg/cli/options_test.go | 14 +++++++++++-- pkg/cli/root.go | 4 ++++ 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/pkg/cli/options.go b/pkg/cli/options.go index 33867c7dc4e..9ae3ac3c7fb 100644 --- a/pkg/cli/options.go +++ b/pkg/cli/options.go @@ -171,26 +171,44 @@ func parseExternalPluginArgs() (args []string) { return args } +// isHostSupported checks whether the host system is supported or not. +func isHostSupported(host string) bool { + for _, platform := range supportedPlatforms { + if host == platform { + return true + } + } + return false +} + // getPluginsRoot detects the host system and gets the plugins root based on the host. func getPluginsRoot(host string) (pluginsRoot string, err error) { + if !isHostSupported(host) { + // freebsd, openbsd, windows... + return "", fmt.Errorf("host not supported: %v", host) + } + + pluginsRelativePath := filepath.Join("kubebuilder", "plugins") + if xdgHome := os.Getenv("XDG_CONFIG_HOME"); xdgHome != "" { + return filepath.Join(xdgHome, pluginsRelativePath), nil + } + switch host { case "darwin": logrus.Debugf("Detected host is macOS.") - pluginsRoot = filepath.Join("Library", "Application Support", "kubebuilder", "plugins") + pluginsRoot = filepath.Join("Library", "Application Support", pluginsRelativePath) case "linux": logrus.Debugf("Detected host is Linux.") - pluginsRoot = filepath.Join(".config", "kubebuilder", "plugins") - default: - // freebsd, openbsd, windows... - return "", fmt.Errorf("Host not supported: %v", host) + pluginsRoot = filepath.Join(".config", pluginsRelativePath) } - userHomeDir, err := getHomeDir() + + userHomeDir, err := os.UserHomeDir() if err != nil { return "", fmt.Errorf("error retrieving home dir: %v", err) } pluginsRoot = filepath.Join(userHomeDir, pluginsRoot) - return pluginsRoot, nil + return } // DiscoverExternalPlugins discovers the external plugins in the plugins root directory @@ -286,16 +304,3 @@ func DiscoverExternalPlugins(fs afero.Fs) (ps []plugin.Plugin, err error) { func isPluginExectuable(mode fs.FileMode) bool { return mode&0111 != 0 } - -// getHomeDir returns $XDG_CONFIG_HOME if set, otherwise $HOME. -func getHomeDir() (string, error) { - var err error - xdgHome := os.Getenv("XDG_CONFIG_HOME") - if xdgHome == "" { - xdgHome, err = os.UserHomeDir() - if err != nil { - return "", err - } - } - return xdgHome, nil -} diff --git a/pkg/cli/options_test.go b/pkg/cli/options_test.go index eec052ede5f..578e3f64bcb 100644 --- a/pkg/cli/options_test.go +++ b/pkg/cli/options_test.go @@ -228,7 +228,7 @@ var _ = Describe("Discover external plugins", func() { _, err = getPluginsRoot("random") Expect(err).ToNot(BeNil()) - Expect(err.Error()).To(ContainSubstring("Host not supported")) + Expect(err.Error()).To(ContainSubstring("host not supported")) }) It("should skip parsing of directories if plugins root is not a directory", func() { @@ -249,7 +249,17 @@ var _ = Describe("Discover external plugins", func() { _, err = getPluginsRoot("random") Expect(err).ToNot(BeNil()) - Expect(err.Error()).To(ContainSubstring("Host not supported")) + Expect(err.Error()).To(ContainSubstring("host not supported")) + }) + + It("should return full path to the external plugins", func() { + err = os.Setenv("XDG_CONFIG_HOME", "/some/random/path") + Expect(err).To(BeNil()) + + pluginsRoot, err := getPluginsRoot(runtime.GOOS) + Expect(err).To(BeNil()) + Expect(pluginsRoot).To(Equal("/some/random/path/kubebuilder/plugins")) + }) It("should return error when home directory is set to empty", func() { diff --git a/pkg/cli/root.go b/pkg/cli/root.go index f4479a199da..056353e9f14 100644 --- a/pkg/cli/root.go +++ b/pkg/cli/root.go @@ -29,6 +29,10 @@ const ( projectVersionsHeader = "Supported project versions" ) +var ( + supportedPlatforms = []string{"linux", "darwin"} +) + func (c CLI) newRootCmd() *cobra.Command { cmd := &cobra.Command{ Use: c.commandName, From 0232bbb1c70668dab7536e4f8afa11ea733036ee Mon Sep 17 00:00:00 2001 From: Tony Jin Date: Thu, 23 Feb 2023 00:18:51 -0500 Subject: [PATCH 03/23] =?UTF-8?q?=F0=9F=91=BB=20:=20add=20tony=20as=20revi?= =?UTF-8?q?ewer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OWNERS_ALIASES | 1 + 1 file changed, 1 insertion(+) diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES index 9ae98625774..90f558c5e00 100644 --- a/OWNERS_ALIASES +++ b/OWNERS_ALIASES @@ -18,6 +18,7 @@ aliases: - joelanford - rashmigottipati - everettraven + - Kavinjsir # folks who may have context on ancient history, # but are no longer directly involved From 6ccbc0fd658c13d3963f09dec159daf58065b8a6 Mon Sep 17 00:00:00 2001 From: El Mehdi Rami Date: Sat, 25 Feb 2023 02:44:51 +0100 Subject: [PATCH 04/23] test: increase coverage --- pkg/cli/options_test.go | 22 ++++++++++++++++++++-- pkg/cli/root.go | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/pkg/cli/options_test.go b/pkg/cli/options_test.go index 578e3f64bcb..71974831005 100644 --- a/pkg/cli/options_test.go +++ b/pkg/cli/options_test.go @@ -252,14 +252,32 @@ var _ = Describe("Discover external plugins", func() { Expect(err.Error()).To(ContainSubstring("host not supported")) }) - It("should return full path to the external plugins", func() { + 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()) + } + + home := os.Getenv("HOME") + + pluginsRoot, err := getPluginsRoot("darwin") + Expect(err).To(BeNil()) + expected := filepath.Join(home, "Library", "Application Support", "kubebuilder", "plugins") + Expect(pluginsRoot).To(Equal(expected)) + + pluginsRoot, err = getPluginsRoot("linux") + Expect(err).To(BeNil()) + 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()) pluginsRoot, err := getPluginsRoot(runtime.GOOS) Expect(err).To(BeNil()) Expect(pluginsRoot).To(Equal("/some/random/path/kubebuilder/plugins")) - }) It("should return error when home directory is set to empty", func() { diff --git a/pkg/cli/root.go b/pkg/cli/root.go index 056353e9f14..7ee54e17682 100644 --- a/pkg/cli/root.go +++ b/pkg/cli/root.go @@ -30,7 +30,7 @@ const ( ) var ( - supportedPlatforms = []string{"linux", "darwin"} + supportedPlatforms = []string{"darwin", "linux"} ) func (c CLI) newRootCmd() *cobra.Command { From 4732cf566006a8211f670295bebddb8f57567ae9 Mon Sep 17 00:00:00 2001 From: Sajiyah Salat <109643863+Sajiyah-Salat@users.noreply.github.com> Date: Wed, 1 Mar 2023 20:52:28 +0530 Subject: [PATCH 05/23] Update helper_to_upgrade_projects_by_rescaffolding.md --- designs/helper_to_upgrade_projects_by_rescaffolding.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designs/helper_to_upgrade_projects_by_rescaffolding.md b/designs/helper_to_upgrade_projects_by_rescaffolding.md index 8da49bd1238..3ec6c329e5b 100644 --- a/designs/helper_to_upgrade_projects_by_rescaffolding.md +++ b/designs/helper_to_upgrade_projects_by_rescaffolding.md @@ -207,6 +207,6 @@ to be addressed and maintained. We could use it to do cool future features such as creating a GitHub action which would push-pull requests against the project repositories to help users be updated with, for example, minor changes. By using this command, we might able to git clone the project and to do a new scaffold and then use some [git strategy merge](https://www.geeksforgeeks.org/merge-strategies-in-git/) to result in a PR to purpose the required changes. -We probably need to store the CLI tool tag release used to do the scaffold to persuade this idea. So that we can know if the project requires or not updates. +We probably need to store the CLI tool tag release used to do the scaffold to persuade this idea. So that we can know if the project requires updates or not. -[project-config]: https://book.kubebuilder.io/reference/project-config.html \ No newline at end of file +[project-config]: https://book.kubebuilder.io/reference/project-config.html From 5ed3440d9a6506639394d5f78cfe642a12b6fd7f Mon Sep 17 00:00:00 2001 From: Shubham Rajvanshi Date: Sun, 5 Mar 2023 19:52:22 -0800 Subject: [PATCH 06/23] Update api-changes.md Fix a typo in the docs --- docs/book/src/component-config-tutorial/api-changes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/src/component-config-tutorial/api-changes.md b/docs/book/src/component-config-tutorial/api-changes.md index a762e43dcae..e65d6100b3e 100644 --- a/docs/book/src/component-config-tutorial/api-changes.md +++ b/docs/book/src/component-config-tutorial/api-changes.md @@ -14,7 +14,7 @@ steps](/quick-start.md#installation) before continuing. kubebuilder init --domain tutorial.kubebuilder.io --component-config ``` -## Setting up an exising project +## Setting up an existing project If you've previously generated a project we can add support for parsing the config file by making the following changes to `main.go`. From 142ee0255b592133c0be4a891a102965bf3d53bf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Mar 2023 09:52:12 +0000 Subject: [PATCH 07/23] =?UTF-8?q?=F0=9F=8C=B1=20Bump=20github.com/spf13/af?= =?UTF-8?q?ero=20from=201.9.3=20to=201.9.4=20(#3254)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bump github.com/spf13/afero from 1.9.3 to 1.9.4 Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.9.3 to 1.9.4. - [Release notes](https://github.com/spf13/afero/releases) - [Commits](https://github.com/spf13/afero/compare/v1.9.3...v1.9.4) --- updated-dependencies: - dependency-name: github.com/spf13/afero dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 982d3be1eaa..29ffb706535 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/onsi/ginkgo/v2 v2.8.3 github.com/onsi/gomega v1.27.1 github.com/sirupsen/logrus v1.9.0 - github.com/spf13/afero v1.9.3 + github.com/spf13/afero v1.9.4 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 golang.org/x/text v0.7.0 diff --git a/go.sum b/go.sum index 37d2e93fd3d..2ea0fcc9630 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= -github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= +github.com/spf13/afero v1.9.4 h1:Sd43wM1IWz/s1aVXdOBkjJvuP8UdyqioeE4AmM0QsBs= +github.com/spf13/afero v1.9.4/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= From 4757be79dbee62bb392de7ea0266a3430efa4ead Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Mar 2023 09:52:38 +0000 Subject: [PATCH 08/23] =?UTF-8?q?=F0=9F=8C=B1=20Bump=20github.com/onsi/gin?= =?UTF-8?q?kgo/v2=20from=202.8.3=20to=202.8.4=20(#3253)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bump github.com/onsi/ginkgo/v2 from 2.8.3 to 2.8.4 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.8.3 to 2.8.4. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.8.3...v2.8.4) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 29ffb706535..955d379f60e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/gobuffalo/flect v1.0.0 - github.com/onsi/ginkgo/v2 v2.8.3 + github.com/onsi/ginkgo/v2 v2.8.4 github.com/onsi/gomega v1.27.1 github.com/sirupsen/logrus v1.9.0 github.com/spf13/afero v1.9.4 diff --git a/go.sum b/go.sum index 2ea0fcc9630..220de1e4bdd 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/onsi/ginkgo/v2 v2.8.3 h1:RpbK1G8nWPNaCVFBWsOGnEQQGgASi6b8fxcWBvDYjxQ= -github.com/onsi/ginkgo/v2 v2.8.3/go.mod h1:6OaUA8BCi0aZfmzYT/q9AacwTzDpNbxILUT+TlBq6MY= +github.com/onsi/ginkgo/v2 v2.8.4 h1:gf5mIQ8cLFieruNLAdgijHF1PYfLphKm2dxxcUtcqK0= +github.com/onsi/ginkgo/v2 v2.8.4/go.mod h1:427dEDQZkDKsBvCjc2A/ZPefhKxsTTrsQegMlayL730= github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754= github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 91396e0d72a1e185cfd11e13da2140bf7910eee5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Mar 2023 09:53:10 +0000 Subject: [PATCH 09/23] Bump github.com/onsi/ginkgo/v2 from 2.8.4 to 2.9.0 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.8.4 to 2.9.0. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/ginkgo/compare/v2.8.4...v2.9.0) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 955d379f60e..ca1e886cc3e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( github.com/gobuffalo/flect v1.0.0 - github.com/onsi/ginkgo/v2 v2.8.4 + github.com/onsi/ginkgo/v2 v2.9.0 github.com/onsi/gomega v1.27.1 github.com/sirupsen/logrus v1.9.0 github.com/spf13/afero v1.9.4 diff --git a/go.sum b/go.sum index 220de1e4bdd..e6c93d02e5c 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/onsi/ginkgo/v2 v2.8.4 h1:gf5mIQ8cLFieruNLAdgijHF1PYfLphKm2dxxcUtcqK0= -github.com/onsi/ginkgo/v2 v2.8.4/go.mod h1:427dEDQZkDKsBvCjc2A/ZPefhKxsTTrsQegMlayL730= +github.com/onsi/ginkgo/v2 v2.9.0 h1:Tugw2BKlNHTMfG+CheOITkYvk4LAh6MFOvikhGVnhE8= +github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxmrTcxyk= github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754= github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= From 244a9e9602be4494e7dcccb4b149e5484886fb2e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Mar 2023 15:03:11 +0000 Subject: [PATCH 10/23] =?UTF-8?q?=F0=9F=8C=B1=20Bump=20github.com/gobuffal?= =?UTF-8?q?o/flect=20from=201.0.0=20to=201.0.2=20(#3252)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bump github.com/gobuffalo/flect from 1.0.0 to 1.0.2 Bumps [github.com/gobuffalo/flect](https://github.com/gobuffalo/flect) from 1.0.0 to 1.0.2. - [Release notes](https://github.com/gobuffalo/flect/releases) - [Commits](https://github.com/gobuffalo/flect/compare/v1.0.0...v1.0.2) --- updated-dependencies: - dependency-name: github.com/gobuffalo/flect dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index ca1e886cc3e..731d57b6c98 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module sigs.k8s.io/kubebuilder/v3 go 1.19 require ( - github.com/gobuffalo/flect v1.0.0 + github.com/gobuffalo/flect v1.0.2 github.com/onsi/ginkgo/v2 v2.9.0 github.com/onsi/gomega v1.27.1 github.com/sirupsen/logrus v1.9.0 diff --git a/go.sum b/go.sum index e6c93d02e5c..29cd3b2981a 100644 --- a/go.sum +++ b/go.sum @@ -64,8 +64,8 @@ github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gobuffalo/flect v1.0.0 h1:eBFmskjXZgAOagiTXJH25Nt5sdFwNRcb8DKZsIsAUQI= -github.com/gobuffalo/flect v1.0.0/go.mod h1:l9V6xSb4BlXwsxEMj3FVEub2nkdQjWhPvD8XTTlHPQc= +github.com/gobuffalo/flect v1.0.2 h1:eqjPGSo2WmjgY2XlpGwo2NXgL3RucAKo4k4qQMNA5sA= +github.com/gobuffalo/flect v1.0.2/go.mod h1:A5msMlrHtLqh9umBSnvabjsMrCcCpAyzglnDvkbYKHs= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= From 90d09e11f94a7c2e23ef5fae7239238b3df5ea0c Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Mon, 6 Mar 2023 15:52:30 +0000 Subject: [PATCH 11/23] :warning: (go/v3) deprecate go/v3 in favor of go/v4 (#3238) * :warning: deprecate go/v3 * Apply suggestions from code review * Update pkg/plugins/golang/v4/plugin.go Co-authored-by: Bryce Palmer --------- Co-authored-by: Bryce Palmer --- docs/book/src/plugins/go-v3-plugin.md | 17 +++++++++++++++-- pkg/plugins/golang/v4/plugin.go | 8 ++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/book/src/plugins/go-v3-plugin.md b/docs/book/src/plugins/go-v3-plugin.md index 54e9da430f5..21613773f7f 100644 --- a/docs/book/src/plugins/go-v3-plugin.md +++ b/docs/book/src/plugins/go-v3-plugin.md @@ -1,4 +1,16 @@ -# go/v3 (go.kubebuilder.io/v3) +# [Deprecated] go/v3 (go.kubebuilder.io/v3) + + + Kubebuilder tool will scaffold the go/v3 plugin by default. This plugin is a composition of the plugins ` kustomize.common.kubebuilder.io/v1` and `base.go.kubebuilder.io/v3`. By using you can scaffold the default project which is a helper to construct sets of [controllers][controller-runtime]. @@ -23,8 +35,9 @@ As `go/v3` is the default plugin there is no need to explicitly mention to Kubeb To create a new project with the `go/v3` plugin the following command can be used: ```sh -kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project +kubebuilder init --plugins=`go/v3` --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project ``` + All the other subcommands supported by the go/v3 plugin can be executed similarly. diff --git a/docs/book/src/plugins/kustomize-v2-alpha.md b/docs/book/src/plugins/kustomize-v2.md similarity index 82% rename from docs/book/src/plugins/kustomize-v2-alpha.md rename to docs/book/src/plugins/kustomize-v2.md index c599f513f02..36b7ecaeb6f 100644 --- a/docs/book/src/plugins/kustomize-v2-alpha.md +++ b/docs/book/src/plugins/kustomize-v2.md @@ -1,4 +1,4 @@ -# Kustomize v2-alpha +# Kustomize v2 The kustomize plugin allows you to scaffold all kustomize manifests used to work with the language base plugin `base.go.kubebuilder.io/v3`. @@ -12,7 +12,7 @@ able to create "helper" plugins which can work with many projects and languages. @@ -26,15 +26,6 @@ directory of the Kubebuilder project. - If you are NOT looking to rely on special URLs in resource fields - If you want to use [replacements][kustomize-replacements] since [vars][kustomize-vars] are deprecated and might be removed soon - - - ## How to use it If you are looking to define that your language plugin should use kustomize use the [Bundle Plugin][bundle] @@ -44,7 +35,7 @@ all that is language specific and kustomize for its configuration, see: ```go import ( ... - kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha" + kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2" golangv3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3" ... ) @@ -53,15 +44,15 @@ import ( // The follow code is creating a new plugin with its name and version via composition // You can define that one plugin is composite by 1 or Many others plugins gov3Bundle, _ := plugin.NewBundle(golang.DefaultNameQualifier, plugin.Version{Number: 3}, - kustomizecommonv2alpha.Plugin{}, // scaffold the config/ directory and all kustomize files + kustomizecommonv2.Plugin{}, // scaffold the config/ directory and all kustomize files golangv3.Plugin{}, // Scaffold the Golang files and all that specific for the language e.g. go.mod, apis, controllers ) ``` -Also, with Kubebuilder, you can use kustomize/v2-alpha alone via: +Also, with Kubebuilder, you can use kustomize/v2 alone via: ```sh -kubebuilder init --plugins=kustomize/v2-alpha +kubebuilder init --plugins=kustomize/v2 $ ls -la total 24 drwxr-xr-x 6 camilamacedo86 staff 192 31 Mar 09:56 . @@ -75,8 +66,8 @@ drwx------ 6 camilamacedo86 staff 192 31 Mar 09:56 config Or combined with the base language plugins: ```sh -# Provides the same scaffold of go/v3 plugin which is composition but with kustomize/v2-alpha -kubebuilder init --plugins=kustomize/v2-alpha,base.go.kubebuilder.io/v3 --domain example.org --repo example.org/guestbook-operator +# Provides the same scaffold of go/v3 plugin which is composition but with kustomize/v2 +kubebuilder init --plugins=kustomize/v2,base.go.kubebuilder.io/v4 --domain example.org --repo example.org/guestbook-operator ``` ## Subcommands @@ -108,12 +99,12 @@ The following scaffolds will be created or updated by this plugin: * Check the [kustomize documentation][kustomize-docs] * Check the [kustomize repository][kustomize-github] * To know more about the changes between kustomize v4 and v5 see its [release notes][release-notes] -* Also, you can compare the `config/` directory between the samples `project-v3` and `project-v3-with-kustomize-v2` to check the difference in the syntax of the manifests provided by default +* Also, you can compare the `config/` directory between the samples `project-v3` and `project-v4` to check the difference in the syntax of the manifests provided by default [sdk]:https://github.com/operator-framework/operator-sdk [testdata]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata/ [bundle]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugin/bundle.go -[kustomize-create-api]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/common/kustomize/v2-alpha/scaffolds/api.go#L72-L84 +[kustomize-create-api]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugins/common/kustomize/v2/scaffolds/api.go#L72-L84 [kustomize-docs]: https://kustomize.io/ [kustomize-github]: https://github.com/kubernetes-sigs/kustomize [kustomize-replacements]: https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/replacements/ diff --git a/docs/book/src/plugins/to-be-extended.md b/docs/book/src/plugins/to-be-extended.md index 99e69f7deb1..15b60c4e508 100644 --- a/docs/book/src/plugins/to-be-extended.md +++ b/docs/book/src/plugins/to-be-extended.md @@ -16,7 +16,7 @@ helpers on top, such as [Operator-SDK][sdk] does to add their features to integr | Plugin | Key | Description | | ---------------------------------------------------------------------------------- |-----------------------------| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [kustomize.common.kubebuilder.io/v1](https://github.com/kubernetes-sigs/kubebuilder/pull/3235/kustomize-v1.md) | kustomize/v1 (Deprecated) | Responsible for scaffolding all manifests to configure projects with [kustomize(v3)][kustomize]. (create and update the `config/` directory). This plugin is used in the composition to create the plugin (`go/v3`). | -| [kustomize.common.kubebuilder.io/v2-alpha](kustomize-v2-alpha.md) | `kustomize/v2-alpha` | It has the same purpose as of `kustomize/v1`. However, it works with [kustomize][kustomize] version `v4` and addresses the required changes for future kustomize configurations. It will probably be used with the future `go/v4-alpha` plugin. | +| [kustomize.common.kubebuilder.io/v2](kustomize-v2.md) | `kustomize/v2` | It has the same purpose of `kustomize/v1`. However, it works with [kustomize][kustomize] version `v4` and addresses the required changes for future kustomize configurations. It will probably be used with the future `go/v4-alpha` plugin. | | `base.go.kubebuilder.io/v3` | `base/v3` | Responsible for scaffolding all files that specifically require Golang. This plugin is used in composition to create the plugin (`go/v3`) | | `base.go.kubebuilder.io/v4-alpha` | `base/v3-alpha` | Responsible for scaffolding all files which specifically requires Golang. This plugin is used in the composition to create the plugin (`go/v4-alpha`) | diff --git a/docs/book/src/plugins/to-scaffold-project.md b/docs/book/src/plugins/to-scaffold-project.md index f8de71fee6f..cb29f9cb534 100644 --- a/docs/book/src/plugins/to-scaffold-project.md +++ b/docs/book/src/plugins/to-scaffold-project.md @@ -6,4 +6,4 @@ The following plugins are useful to scaffold the whole project with the tool. | ---------------------------------------------------------------------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [go.kubebuilder.io/v2 - (Deprecated)](go-v2-plugin.md) | `go/v2` | Golang plugin responsible for scaffolding the legacy layout provided with Kubebuilder CLI >= `2.0.0` and < `3.0.0`. | | [go.kubebuilder.io/v3 - (Default scaffold with Kubebuilder init)](go-v3-plugin.md) | `go/v3` | Default scaffold used for creating a project when no plugin(s) are provided. Responsible for scaffolding Golang projects and its configurations. | -| [go.kubebuilder.io/v4-alpha - (Add Apple Sillicom Support)](go-v4-plugin.md) | `go/v4` | Scaffold composite by `base.go.kubebuilder.io/v3` and [kustomize.common.kubebuilder.io/v2-alpha](kustomize-v2-alpha.md). Responsible for scaffolding Golang projects and its configurations. | +| [go.kubebuilder.io/v4-alpha - (Add Apple Sillicom Support)](go-v4-plugin.md) | `go/v4` | Scaffold composite by `base.go.kubebuilder.io/v3` and [kustomize.common.kubebuilder.io/v2](kustomize-v2.md). Responsible for scaffolding Golang projects and its configurations. | diff --git a/pkg/plugins/common/kustomize/v2-alpha/api.go b/pkg/plugins/common/kustomize/v2/api.go similarity index 91% rename from pkg/plugins/common/kustomize/v2-alpha/api.go rename to pkg/plugins/common/kustomize/v2/api.go index 23a36fc855c..98059f0ae32 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/api.go +++ b/pkg/plugins/common/kustomize/v2/api.go @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2_alpha +package v2 import ( "sigs.k8s.io/kubebuilder/v3/pkg/machinery" "sigs.k8s.io/kubebuilder/v3/pkg/plugin" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds" ) var _ plugin.CreateAPISubcommand = &createAPISubcommand{} diff --git a/pkg/plugins/common/kustomize/v2-alpha/create.go b/pkg/plugins/common/kustomize/v2/create.go similarity index 98% rename from pkg/plugins/common/kustomize/v2-alpha/create.go rename to pkg/plugins/common/kustomize/v2/create.go index 933f112c2f2..a0aac27649a 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/create.go +++ b/pkg/plugins/common/kustomize/v2/create.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2_alpha +package v2 import ( "strconv" diff --git a/pkg/plugins/common/kustomize/v2-alpha/init.go b/pkg/plugins/common/kustomize/v2/init.go similarity index 96% rename from pkg/plugins/common/kustomize/v2-alpha/init.go rename to pkg/plugins/common/kustomize/v2/init.go index 2c37d19aec0..2d40b4dcd50 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/init.go +++ b/pkg/plugins/common/kustomize/v2/init.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2_alpha +package v2 import ( "fmt" @@ -28,7 +28,7 @@ import ( "sigs.k8s.io/kubebuilder/v3/pkg/internal/validation" "sigs.k8s.io/kubebuilder/v3/pkg/machinery" "sigs.k8s.io/kubebuilder/v3/pkg/plugin" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds" ) var _ plugin.InitSubcommand = &initSubcommand{} diff --git a/pkg/plugins/common/kustomize/v2-alpha/plugin.go b/pkg/plugins/common/kustomize/v2/plugin.go similarity index 98% rename from pkg/plugins/common/kustomize/v2-alpha/plugin.go rename to pkg/plugins/common/kustomize/v2/plugin.go index 30e05d33c99..5e8eb4ad5c5 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/plugin.go +++ b/pkg/plugins/common/kustomize/v2/plugin.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2_alpha +package v2 import ( "sigs.k8s.io/kubebuilder/v3/pkg/config" @@ -30,7 +30,7 @@ const KustomizeVersion = "v5.0.0" const pluginName = "kustomize.common." + plugins.DefaultNameQualifier var ( - pluginVersion = plugin.Version{Number: 2, Stage: stage.Alpha} + pluginVersion = plugin.Version{Number: 2, Stage: stage.Stable} supportedProjectVersions = []config.Version{cfgv3.Version} ) diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/api.go b/pkg/plugins/common/kustomize/v2/scaffolds/api.go similarity index 85% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/api.go rename to pkg/plugins/common/kustomize/v2/scaffolds/api.go index 4713f6f0150..402d9d4b65d 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/api.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/api.go @@ -23,10 +23,10 @@ import ( "sigs.k8s.io/kubebuilder/v3/pkg/machinery" "sigs.k8s.io/kubebuilder/v3/pkg/model/resource" "sigs.k8s.io/kubebuilder/v3/pkg/plugins" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/patches" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/samples" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples" ) var _ plugins.Scaffolder = &apiScaffolder{} diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/init.go b/pkg/plugins/common/kustomize/v2/scaffolds/init.go similarity index 83% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/init.go rename to pkg/plugins/common/kustomize/v2/scaffolds/init.go index f19334e2199..d669963c9df 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/init.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/init.go @@ -22,10 +22,10 @@ import ( "sigs.k8s.io/kubebuilder/v3/pkg/config" "sigs.k8s.io/kubebuilder/v3/pkg/machinery" "sigs.k8s.io/kubebuilder/v3/pkg/plugins" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/prometheus" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/manager" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/prometheus" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac" ) const ( diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/certmanager/certificate.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/certmanager/certificate.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/certmanager/certificate.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/certmanager/certificate.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/certmanager/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/certmanager/kustomization.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/certmanager/kustomization.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/certmanager/kustomization.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/certmanager/kustomizeconfig.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/certmanager/kustomizeconfig.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/certmanager/kustomizeconfig.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/certmanager/kustomizeconfig.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/kustomization.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/kustomizeconfig.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomizeconfig.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/kustomizeconfig.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomizeconfig.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/enablecainection_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/enablecainection_patch.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/enablecainection_patch.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/enablecainection_patch.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/kustomization.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_config_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/manager_config_patch.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/manager_config_patch.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/manager_config_patch.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/webhook_manager_patch.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/webhook_manager_patch.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault/webhook_manager_patch.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/webhook_manager_patch.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/config.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/manager/config.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/config.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/manager/config.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/controller_manager_config.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/manager/controller_manager_config.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/controller_manager_config.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/manager/controller_manager_config.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/manager/kustomization.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/manager/kustomization.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/manager/kustomization.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/prometheus/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/prometheus/kustomization.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/prometheus/kustomization.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/prometheus/kustomization.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/prometheus/monitor.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/prometheus/monitor.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/prometheus/monitor.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/prometheus/monitor.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/auth_proxy_client_role.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/auth_proxy_client_role.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/auth_proxy_client_role.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/auth_proxy_client_role.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/auth_proxy_role.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/auth_proxy_role.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/auth_proxy_service.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/auth_proxy_service.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/auth_proxy_service.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/auth_proxy_service.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/crd_editor_role.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/crd_editor_role.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/crd_viewer_role.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/crd_viewer_role.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/kustomization.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/kustomization.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/kustomization.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/leader_election_role.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/leader_election_role.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/leader_election_role.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/leader_election_role.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/role_binding.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/role_binding.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/role_binding.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/role_binding.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/service_account.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/service_account.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/rbac/service_account.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/rbac/service_account.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/samples/crd_sample.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/crd_sample.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/samples/crd_sample.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/crd_sample.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/samples/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/kustomization.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/samples/kustomization.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/samples/kustomization.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/webhook/kustomization.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/webhook/kustomization.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/webhook/kustomization.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/webhook/kustomization.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/webhook/kustomizeconfig.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/webhook/kustomizeconfig.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/webhook/kustomizeconfig.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/webhook/kustomizeconfig.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/webhook/service.go b/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/webhook/service.go similarity index 100% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/webhook/service.go rename to pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/webhook/service.go diff --git a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/webhook.go b/pkg/plugins/common/kustomize/v2/scaffolds/webhook.go similarity index 87% rename from pkg/plugins/common/kustomize/v2-alpha/scaffolds/webhook.go rename to pkg/plugins/common/kustomize/v2/scaffolds/webhook.go index a859d03f071..422e198fc8d 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/scaffolds/webhook.go +++ b/pkg/plugins/common/kustomize/v2/scaffolds/webhook.go @@ -23,9 +23,9 @@ import ( "sigs.k8s.io/kubebuilder/v3/pkg/machinery" "sigs.k8s.io/kubebuilder/v3/pkg/model/resource" "sigs.k8s.io/kubebuilder/v3/pkg/plugins" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/certmanager" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/kdefault" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds/internal/templates/config/webhook" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/certmanager" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/webhook" ) var _ plugins.Scaffolder = &webhookScaffolder{} diff --git a/pkg/plugins/common/kustomize/v2-alpha/webhook.go b/pkg/plugins/common/kustomize/v2/webhook.go similarity index 91% rename from pkg/plugins/common/kustomize/v2-alpha/webhook.go rename to pkg/plugins/common/kustomize/v2/webhook.go index 9b5a3107f74..d7964b2c086 100644 --- a/pkg/plugins/common/kustomize/v2-alpha/webhook.go +++ b/pkg/plugins/common/kustomize/v2/webhook.go @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v2_alpha +package v2 import ( "sigs.k8s.io/kubebuilder/v3/pkg/machinery" "sigs.k8s.io/kubebuilder/v3/pkg/plugin" - "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds" + "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds" ) var _ plugin.CreateWebhookSubcommand = &createWebhookSubcommand{} diff --git a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go index 274d87a4eef..313929ffc7f 100644 --- a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go +++ b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go @@ -31,7 +31,7 @@ import ( "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util" "sigs.k8s.io/kubebuilder/v3/pkg/plugins" kustomizev1scaffolds "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v1/scaffolds" - kustomizev2scaffolds "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha/scaffolds" + kustomizev2scaffolds "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2/scaffolds" "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/api" "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/config/samples" "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers" @@ -297,7 +297,7 @@ func (s *apiScaffolder) updateControllerCode(controller controllers.Controller) func (s *apiScaffolder) scaffoldCreateAPIFromKustomize(isLegacyLayout bool) error { // Now we need call the kustomize/v1 plugin to do its scaffolds when we create a new API // todo: when we have the go/v4-alpha plugin we will also need to check what is the plugin used - // in the Project layout to know if we should use kustomize/v1 OR kustomize/v2-alpha + // in the Project layout to know if we should use kustomize/v1 OR kustomize/v2 var kustomizeScaffolder plugins.Scaffolder if isLegacyLayout { @@ -326,7 +326,7 @@ func (s *apiScaffolder) scaffoldCreateAPIFromKustomize(isLegacyLayout bool) erro func (s *apiScaffolder) scaffoldCreateAPIFromGolang(isLegacyLayout bool) error { // Now we need call the kustomize/v1 plugin to do its scaffolds when we create a new API // todo: when we have the go/v4-alpha plugin we will also need to check what is the plugin used - // in the Project layout to know if we should use kustomize/v1 OR kustomize/v2-alpha + // in the Project layout to know if we should use kustomize/v1 OR kustomize/v2 if isLegacyLayout { golangV3Scaffolder := golangv3scaffolds.NewAPIScaffolder(s.config, s.resource, true) diff --git a/pkg/plugins/golang/v3/scaffolds/init.go b/pkg/plugins/golang/v3/scaffolds/init.go index ae89c705c3e..5e798149752 100644 --- a/pkg/plugins/golang/v3/scaffolds/init.go +++ b/pkg/plugins/golang/v3/scaffolds/init.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/kubebuilder/v3/pkg/machinery" "sigs.k8s.io/kubebuilder/v3/pkg/plugins" kustomizecommonv1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v1" - kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha" + kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2" "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds/internal/templates" "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds/internal/templates/hack" ) diff --git a/pkg/plugins/golang/v4/scaffolds/init.go b/pkg/plugins/golang/v4/scaffolds/init.go index c9cd93a9747..0a39c087d84 100644 --- a/pkg/plugins/golang/v4/scaffolds/init.go +++ b/pkg/plugins/golang/v4/scaffolds/init.go @@ -27,7 +27,7 @@ import ( "sigs.k8s.io/kubebuilder/v3/pkg/machinery" "sigs.k8s.io/kubebuilder/v3/pkg/plugins" kustomizecommonv1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v1" - kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2-alpha" + kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2" "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v4/scaffolds/internal/templates" "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v4/scaffolds/internal/templates/hack" ) From 2c61a353b23bc374b3745c4445a79941de0b788e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Mar 2023 00:06:49 +0000 Subject: [PATCH 13/23] Bump golang.org/x/text from 0.7.0 to 0.8.0 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.7.0 to 0.8.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](https://github.com/golang/text/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 731d57b6c98..9a2c499fc96 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/spf13/afero v1.9.4 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 - golang.org/x/text v0.7.0 + golang.org/x/text v0.8.0 golang.org/x/tools v0.6.0 sigs.k8s.io/yaml v1.3.0 ) diff --git a/go.sum b/go.sum index 29cd3b2981a..90fe6ad94db 100644 --- a/go.sum +++ b/go.sum @@ -320,8 +320,8 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 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.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From 99caf56b87d4221f2260481d4ab5d2605791abda Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Mar 2023 09:25:04 +0000 Subject: [PATCH 14/23] Bump github.com/spf13/afero from 1.9.4 to 1.9.5 Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.9.4 to 1.9.5. - [Release notes](https://github.com/spf13/afero/releases) - [Commits](https://github.com/spf13/afero/compare/v1.9.4...v1.9.5) --- updated-dependencies: - dependency-name: github.com/spf13/afero dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 9a2c499fc96..de5e52726ef 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/onsi/ginkgo/v2 v2.9.0 github.com/onsi/gomega v1.27.1 github.com/sirupsen/logrus v1.9.0 - github.com/spf13/afero v1.9.4 + github.com/spf13/afero v1.9.5 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 golang.org/x/text v0.8.0 diff --git a/go.sum b/go.sum index 90fe6ad94db..b56255912bd 100644 --- a/go.sum +++ b/go.sum @@ -155,8 +155,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/afero v1.9.4 h1:Sd43wM1IWz/s1aVXdOBkjJvuP8UdyqioeE4AmM0QsBs= -github.com/spf13/afero v1.9.4/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= +github.com/spf13/afero v1.9.5 h1:stMpOSZFs//0Lv29HduCmli3GUfpFoF3Y1Q/aXj/wVM= +github.com/spf13/afero v1.9.5/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -187,7 +187,7 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -254,6 +254,7 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -308,6 +309,7 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -320,6 +322,8 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 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.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From 8ce171cb9f5f9914c4b4b6b6797251239755bc16 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Mar 2023 09:46:50 +0000 Subject: [PATCH 15/23] Bump github.com/onsi/gomega from 1.27.1 to 1.27.2 Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.27.1 to 1.27.2. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.27.1...v1.27.2) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index de5e52726ef..8192a6972e2 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.19 require ( github.com/gobuffalo/flect v1.0.2 github.com/onsi/ginkgo/v2 v2.9.0 - github.com/onsi/gomega v1.27.1 + github.com/onsi/gomega v1.27.2 github.com/sirupsen/logrus v1.9.0 github.com/spf13/afero v1.9.5 github.com/spf13/cobra v1.6.1 diff --git a/go.sum b/go.sum index b56255912bd..51b701d2343 100644 --- a/go.sum +++ b/go.sum @@ -144,8 +144,8 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/onsi/ginkgo/v2 v2.9.0 h1:Tugw2BKlNHTMfG+CheOITkYvk4LAh6MFOvikhGVnhE8= github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxmrTcxyk= -github.com/onsi/gomega v1.27.1 h1:rfztXRbg6nv/5f+Raen9RcGoSecHIFgBBLQK3Wdj754= -github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw= +github.com/onsi/gomega v1.27.2 h1:SKU0CXeKE/WVgIV1T61kSa3+IRE8Ekrv9rdXDwwTqnY= +github.com/onsi/gomega v1.27.2/go.mod h1:5mR3phAHpkAVIDkHEUBY6HGVsU+cpcEscrGPB4oPlZI= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= From ab4591691710922d5aa72ff59d9192dba491be9c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Mar 2023 11:41:07 +0000 Subject: [PATCH 16/23] :seedling: Bump joelanford/go-apidiff from 0.5.0 to 0.6.0 (#3265) Bumps [joelanford/go-apidiff](https://github.com/joelanford/go-apidiff) from 0.5.0 to 0.6.0. - [Release notes](https://github.com/joelanford/go-apidiff/releases) - [Commits](https://github.com/joelanford/go-apidiff/compare/v0.5.0...v0.6.0) --- updated-dependencies: - dependency-name: joelanford/go-apidiff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/apidiff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/apidiff.yml b/.github/workflows/apidiff.yml index 41863ac6aaa..ae83a9a1446 100644 --- a/.github/workflows/apidiff.yml +++ b/.github/workflows/apidiff.yml @@ -39,7 +39,7 @@ jobs: with: go-version: "1.19" - name: Execute go-apidiff - uses: joelanford/go-apidiff@v0.5.0 + uses: joelanford/go-apidiff@v0.6.0 with: compare-imports: true print-compatible: true From 56bbc8814c20e3de22af1a52e28de725660e7760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=93=E6=9D=B0?= <87080562+xiao-jay@users.noreply.github.com> Date: Tue, 7 Mar 2023 22:36:34 +0800 Subject: [PATCH 17/23] =?UTF-8?q?=F0=9F=93=96=20:=20delete=20cronjob=20tut?= =?UTF-8?q?orial=20Incorrect=20kustomization.yaml=20(#3256)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../testdata/project/config/manager/kustomization.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/manager/kustomization.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/manager/kustomization.yaml index 2bcd3eeaa94..372a75ae43f 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/manager/kustomization.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/manager/kustomization.yaml @@ -1,10 +1,3 @@ resources: - manager.yaml -generatorOptions: - disableNameSuffixHash: true - -configMapGenerator: -- name: manager-config - files: - - controller_manager_config.yaml From 014e08c2979da511f8589b8136d0d7c4aa85138a Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Tue, 7 Mar 2023 14:40:09 +0000 Subject: [PATCH 18/23] :warning: (go/v4-alpha) stabilize go/v4 plugin. Plugin go/v4-alpha replaced with go/v4 (#3237) --- README.md | 11 +--------- cmd/main.go | 3 +-- docs/book/src/SUMMARY.md | 4 ++-- docs/book/src/faq.md | 2 +- docs/book/src/migration/legacy/v2vsv3.md | 6 ++--- .../manually_migration_guide_gov3_to_gov4.md | 20 ++++++++--------- .../migration/migration_guide_gov3_to_gov4.md | 18 +++++++-------- docs/book/src/migration/multi-group.md | 4 ++-- docs/book/src/migration/v3vsv4.md | 22 +++++++++---------- docs/book/src/plugins/creating-plugins.md | 4 ++-- docs/book/src/plugins/go-v4-plugin.md | 14 ++++++------ docs/book/src/plugins/to-be-extended.md | 2 +- docs/book/src/quick-start.md | 5 ++--- .../deploy-image/v1alpha1/scaffolds/api.go | 8 +++---- pkg/plugins/golang/v2/scaffolds/init.go | 2 +- pkg/plugins/golang/v3/commons.go | 2 +- pkg/plugins/golang/v4/init.go | 4 ++-- pkg/plugins/golang/v4/plugin.go | 2 +- pkg/plugins/golang/v4/scaffolds/init.go | 4 ++-- test/e2e/v4/generate_test.go | 4 ++-- test/e2e/v4/plugin_cluster_test.go | 2 +- test/testdata/generate.sh | 10 ++++----- testdata/project-v4-config/PROJECT | 2 +- testdata/project-v4-declarative-v1/PROJECT | 2 +- testdata/project-v4-multigroup/PROJECT | 2 +- testdata/project-v4-with-deploy-image/PROJECT | 2 +- testdata/project-v4/PROJECT | 2 +- 27 files changed, 75 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index 04ca52a4b88..e4321e5e62f 100644 --- a/README.md +++ b/README.md @@ -127,16 +127,7 @@ supporting Windows are welcome. ### Apple Silicon -Apple Silicon (`darwin/arm64`) is supported using the `go/v4-alpha` plugin which provides support for this platform. - -```bash -kubebuilder init --domain my.domain --repo my.domain/guestbook --plugins=go/v4-alpha -``` - -**Note**: The `go/v4-alpha` plugin is an unstable version and can have breaking changes in future releases. The previous kustomize -version (`v3.Y.Z`) used in the `go/v3` has no available binaries for this -platform [kubernetes-sigs/kustomize/issues/4612](https://github.com/kubernetes-sigs/kustomize/issues/4612) -Because of this, we cannot support this `darwin/arm64` on the stable scaffold done by default with the Kubebuilder with the `go/v3` plugin. +Apple Silicon (`darwin/arm64`) support begins with the `go/v4` plugin. ## Community Meetings diff --git a/cmd/main.go b/cmd/main.go index 93ea3ff0a3c..b320ef6d4bc 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -25,7 +25,6 @@ import ( cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2" cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3" "sigs.k8s.io/kubebuilder/v3/pkg/machinery" - "sigs.k8s.io/kubebuilder/v3/pkg/model/stage" "sigs.k8s.io/kubebuilder/v3/pkg/plugin" kustomizecommonv1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v1" kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2" @@ -46,7 +45,7 @@ func main() { golangv3.Plugin{}, ) // Bundle plugin which built the golang projects scaffold by Kubebuilder go/v4 with kustomize alpha-v2 - gov4Bundle, _ := plugin.NewBundle(golang.DefaultNameQualifier, plugin.Version{Number: 4, Stage: stage.Alpha}, + gov4Bundle, _ := plugin.NewBundle(golang.DefaultNameQualifier, plugin.Version{Number: 4}, kustomizecommonv2alpha.Plugin{}, golangv4.Plugin{}, ) diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md index 8e7af480011..4c8a951bada 100644 --- a/docs/book/src/SUMMARY.md +++ b/docs/book/src/SUMMARY.md @@ -68,7 +68,7 @@ - [Migration Guide](migration/legacy/migration_guide_v2tov3.md) - [Migration by updating the files](migration/legacy/manually_migration_guide_v2_v3.md) - [From v3.0.0 with plugins](./migration/v3-plugins.md) - - [go/v3 vs go/v4-alpha](migration/v3vsv4.md) + - [go/v3 vs go/v4](migration/v3vsv4.md) - [Migration Guide](migration/migration_guide_gov3_to_gov4.md) - [Migration by updating the files](migration/manually_migration_guide_gov3_to_gov4.md) @@ -117,7 +117,7 @@ - [To scaffold a project](./plugins/to-scaffold-project.md) - [go/v2 (Deprecated)](./plugins/go-v2-plugin.md) - [go/v3 (Default init scaffold)](./plugins/go-v3-plugin.md) - - [go/v4-alpha](./plugins/go-v4-plugin.md) + - [go/v4](./plugins/go-v4-plugin.md) - [To add optional features](./plugins/to-add-optional-features.md) - [declarative/v1](./plugins/declarative-v1.md) - [grafana/v1-alpha](./plugins/grafana-v1-alpha.md) diff --git a/docs/book/src/faq.md b/docs/book/src/faq.md index a1d7022a06c..0e8aa54c296 100644 --- a/docs/book/src/faq.md +++ b/docs/book/src/faq.md @@ -8,7 +8,7 @@ After creating a project, usually you will want to extend the Kubernetes APIs an The domain is for the group suffix, to explicitly show the resource group category. For example, if set `--domain=example.com`: ``` -kubebuilder init --domain example.com --repo xxx --plugins=go/v4-alpha +kubebuilder init --domain example.com --repo xxx --plugins=go/v4 kubebuilder create api --group mygroup --version v1beta1 --kind Mykind ``` Then the result resource group will be `mygroup.example.com`. diff --git a/docs/book/src/migration/legacy/v2vsv3.md b/docs/book/src/migration/legacy/v2vsv3.md index 0073dcceeb7..75ec754932f 100644 --- a/docs/book/src/migration/legacy/v2vsv3.md +++ b/docs/book/src/migration/legacy/v2vsv3.md @@ -66,15 +66,13 @@ So you want to upgrade your scaffolding to use the latest and greatest features

Apple Silicon (M1)

The current scaffold done by the CLI (`go/v3`) uses [kubernetes-sigs/kustomize][kustomize] v3 which does not provide -a valid binary for Apple Silicon (`darwin/arm64`). Therefore, you can use the `go/v4-alpha` plugin +a valid binary for Apple Silicon (`darwin/arm64`). Therefore, you can use the `go/v4` plugin instead which provides support for this platform: ```bash -kubebuilder init --domain my.domain --repo my.domain/guestbook --plugins=go/v4-alpha +kubebuilder init --domain my.domain --repo my.domain/guestbook --plugins=go/v4 ``` -**Note**: The `go/v4-alpha` plugin is an unstable version and can have breaking changes in future releases. -The steps to migrate your project from v2 to v3 using the `alpha` scaffold are the same. - [Migration Guide v2 to V3][migration-guide-v2-to-v3] **(Recommended)** diff --git a/docs/book/src/migration/manually_migration_guide_gov3_to_gov4.md b/docs/book/src/migration/manually_migration_guide_gov3_to_gov4.md index 14215fd9089..8ead1c1a293 100644 --- a/docs/book/src/migration/manually_migration_guide_gov3_to_gov4.md +++ b/docs/book/src/migration/manually_migration_guide_gov3_to_gov4.md @@ -1,18 +1,18 @@ -# Migration from go/v3 to go/v4-alpha by updating the files manually +# Migration from go/v3 to go/v4 by updating the files manually -Make sure you understand the [differences between Kubebuilder go/v3 and go/v4-alpha][v3vsv4] +Make sure you understand the [differences between Kubebuilder go/v3 and go/v4][v3vsv4] before continuing. Please ensure you have followed the [installation guide][quick-start] to install the required components. -The following guide describes the manual steps required to upgrade your PROJECT config file to begin using `go/v4-alpha`. +The following guide describes the manual steps required to upgrade your PROJECT config file to begin using `go/v4`. This way is more complex, susceptible to errors, and success cannot be assured. Also, by following these steps you will not get the improvements and bug fixes in the default generated project files. Usually it is suggested to do it manually if you have customized your project and deviated too much from the proposed scaffold. Before continuing, ensure that you understand the note about [project customizations][project-customizations]. Note that you might need to spend more effort to do this process manually than to organize your project customizations. The proposed layout will keep your project maintainable and upgradable with less effort in the future. -The recommended upgrade approach is to follow the [Migration Guide go/v3 to go/v4-alpha][migration-guide-gov3-to-gov4] instead. +The recommended upgrade approach is to follow the [Migration Guide go/v3 to go/v4][migration-guide-gov3-to-gov4] instead. ## Migration from project config version "go/v3" to "go/v4" @@ -37,7 +37,7 @@ With: ```yaml layout: -- go.kubebuilder.io/v4-alpha +- go.kubebuilder.io/v4 ``` @@ -152,7 +152,7 @@ The PROJECT tracks the paths of all APIs used in your project. Ensure that they ### Update kustomize manifests with the changes made so far -- Update the manifest under `config/` directory with all changes performed in the default scaffold done with `go/v4-alpha` plugin. (see for example `testdata/project-v4/config/`) to get all changes in the +- Update the manifest under `config/` directory with all changes performed in the default scaffold done with `go/v4` plugin. (see for example `testdata/project-v4/config/`) to get all changes in the default scaffolds to be applied on your project - Create `config/samples/kustomization.yaml` with all Custom Resources samples specified into `config/samples`. _(see for example `testdata/project-v4/config/samples/kustomization.yaml`)_ @@ -160,7 +160,7 @@ The PROJECT tracks the paths of all APIs used in your project. Ensure that they

`config/` directory with changes into the scaffold files

Note that under the `config/` directory you will find scaffolding changes since using -`go/v4-alpha` you will ensure that you are no longer using Kustomize v3x. +`go/v4` you will ensure that you are no longer using Kustomize v3x. You can mainly compare the `config/` directory from the samples scaffolded under the `testdata`directory by checking the differences between the `testdata/project-v3/config/` with `testdata/project-v4/config/` which @@ -189,11 +189,11 @@ Update the `go.mod` with the changes which can be found in the samples under `te ### Verification In the steps above, you updated your project manually with the goal of ensuring that it follows -the changes in the layout introduced with the `go/v4-alpha` plugin that update the scaffolds. +the changes in the layout introduced with the `go/v4` plugin that update the scaffolds. There is no option to verify that you properly updated the `PROJECT` file of your project. -The best way to ensure that everything is updated correctly, would be to initialize a project using the `go/v4-alpha` plugin, -(ie) using `kubebuilder init --domain tutorial.kubebuilder.io plugins=go/v4-alpha` and generating the same API(s), +The best way to ensure that everything is updated correctly, would be to initialize a project using the `go/v4` plugin, +(ie) using `kubebuilder init --domain tutorial.kubebuilder.io plugins=go/v4` and generating the same API(s), controller(s), and webhook(s) in order to compare the generated configuration with the manually changed configuration. Also, after all updates you would run the following commands: diff --git a/docs/book/src/migration/migration_guide_gov3_to_gov4.md b/docs/book/src/migration/migration_guide_gov3_to_gov4.md index 543662376fc..b6c5fce7add 100644 --- a/docs/book/src/migration/migration_guide_gov3_to_gov4.md +++ b/docs/book/src/migration/migration_guide_gov3_to_gov4.md @@ -1,19 +1,19 @@ -# Migration from go/v3 to go/v4-alpha +# Migration from go/v3 to go/v4 -Make sure you understand the [differences between Kubebuilder go/v3 and go/v4-alpha][v3vsv4] +Make sure you understand the [differences between Kubebuilder go/v3 and go/v4][v3vsv4] before continuing. Please ensure you have followed the [installation guide][quick-start] to install the required components. -The recommended way to migrate a go/v3 project is to create a new go/v4-alpha project and +The recommended way to migrate a `go/v3` project is to create a new `go/v4` project and copy over the API and the reconciliation code. The conversion will end up with a -project that looks like a native go/v4-alpha project layout (latest version). +project that looks like a native go/v4 project layout (latest version). However, in some cases, it's possible to do an in-place upgrade (i.e. reuse the go/v3 project layout, upgrading -the PROJECT file, and scaffolds manually). For further information see [Migration from go/v3 to go/v4-alpha by updating the files manually][manually-upgrade] +the PROJECT file, and scaffolds manually). For further information see [Migration from go/v3 to go/v4 by updating the files manually][manually-upgrade] -## Initialize a go/v4-alpha Project +## Initialize a go/v4 Project ## How to use it ? -To create a new project with the `go/v4-alpha` plugin the following command can be used: +To create a new project with the `go/v4` plugin the following command can be used: ```sh -kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --plugins=go/v4-alpha +kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --plugins=go/v4 ``` ## Subcommands supported by the plugin diff --git a/docs/book/src/plugins/to-be-extended.md b/docs/book/src/plugins/to-be-extended.md index 15b60c4e508..e6137bdad28 100644 --- a/docs/book/src/plugins/to-be-extended.md +++ b/docs/book/src/plugins/to-be-extended.md @@ -18,7 +18,7 @@ helpers on top, such as [Operator-SDK][sdk] does to add their features to integr | [kustomize.common.kubebuilder.io/v1](https://github.com/kubernetes-sigs/kubebuilder/pull/3235/kustomize-v1.md) | kustomize/v1 (Deprecated) | Responsible for scaffolding all manifests to configure projects with [kustomize(v3)][kustomize]. (create and update the `config/` directory). This plugin is used in the composition to create the plugin (`go/v3`). | | [kustomize.common.kubebuilder.io/v2](kustomize-v2.md) | `kustomize/v2` | It has the same purpose of `kustomize/v1`. However, it works with [kustomize][kustomize] version `v4` and addresses the required changes for future kustomize configurations. It will probably be used with the future `go/v4-alpha` plugin. | | `base.go.kubebuilder.io/v3` | `base/v3` | Responsible for scaffolding all files that specifically require Golang. This plugin is used in composition to create the plugin (`go/v3`) | -| `base.go.kubebuilder.io/v4-alpha` | `base/v3-alpha` | Responsible for scaffolding all files which specifically requires Golang. This plugin is used in the composition to create the plugin (`go/v4-alpha`) | +| `base.go.kubebuilder.io/v4` | `base/v4` | Responsible for scaffolding all files which specifically requires Golang. This plugin is used in the composition to create the plugin (`go/v4`) | [create-plugins]: creating-plugins.md [kubebuilder-declarative-pattern]: https://github.com/kubernetes-sigs/kubebuilder-declarative-pattern diff --git a/docs/book/src/quick-start.md b/docs/book/src/quick-start.md index d22fffcd0ec..0d49942ad97 100644 --- a/docs/book/src/quick-start.md +++ b/docs/book/src/quick-start.md @@ -57,14 +57,13 @@ Create a directory, and then run the init command inside of it to initialize a n

Apple Silicon (M1)

The current scaffold done by the CLI (`go/v3`) uses [kubernetes-sigs/kustomize][kustomize] v3 which does not provide -a valid binary for Apple Silicon (`darwin/arm64`). Therefore, you can use the `go/v4-alpha` plugin +a valid binary for Apple Silicon (`darwin/arm64`). Therefore, you can use the `go/v4` plugin instead which provides support for this platform: ```bash -kubebuilder init --domain my.domain --repo my.domain/guestbook --plugins=go/v4-alpha +kubebuilder init --domain my.domain --repo my.domain/guestbook --plugins=go/v4 ``` -**Note**: The `go/v4-alpha` plugin is an unstable version and can have breaking changes in future releases. ```bash diff --git a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go index 313929ffc7f..4da0284c7b5 100644 --- a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go +++ b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go @@ -296,8 +296,8 @@ func (s *apiScaffolder) updateControllerCode(controller controllers.Controller) func (s *apiScaffolder) scaffoldCreateAPIFromKustomize(isLegacyLayout bool) error { // Now we need call the kustomize/v1 plugin to do its scaffolds when we create a new API - // todo: when we have the go/v4-alpha plugin we will also need to check what is the plugin used - // in the Project layout to know if we should use kustomize/v1 OR kustomize/v2 + // todo: when we have the go/v4 plugin we will also need to check what is the plugin used + // in the Project layout to know if we should use kustomize/v1 OR kustomize/v2-alpha var kustomizeScaffolder plugins.Scaffolder if isLegacyLayout { @@ -325,8 +325,8 @@ func (s *apiScaffolder) scaffoldCreateAPIFromKustomize(isLegacyLayout bool) erro func (s *apiScaffolder) scaffoldCreateAPIFromGolang(isLegacyLayout bool) error { // Now we need call the kustomize/v1 plugin to do its scaffolds when we create a new API - // todo: when we have the go/v4-alpha plugin we will also need to check what is the plugin used - // in the Project layout to know if we should use kustomize/v1 OR kustomize/v2 + // todo: when we have the go/v4 plugin we will also need to check what is the plugin used + // in the Project layout to know if we should use kustomize/v1 OR kustomize/v2-alpha if isLegacyLayout { golangV3Scaffolder := golangv3scaffolds.NewAPIScaffolder(s.config, s.resource, true) diff --git a/pkg/plugins/golang/v2/scaffolds/init.go b/pkg/plugins/golang/v2/scaffolds/init.go index fd40cb0bc14..e730f9e51a4 100644 --- a/pkg/plugins/golang/v2/scaffolds/init.go +++ b/pkg/plugins/golang/v2/scaffolds/init.go @@ -44,7 +44,7 @@ const ( // Go/v2 plugin exist only to ensure the backwards compatibility with the old scaffold // produced with kubebuilder >= 2.0.0 < 3.0.0. It does not take advantage of the plugin system // (see that the PROJECT file does not have the layout of the plugin and uses the old/legacy - // version/schema.) This plugin will be deprecated with go/v4-alpha and can be removed + // version/schema.) This plugin will be deprecated with go/v4 and can be removed // when go/v4 stable is published. KustomizeVersion = "v3.5.4" diff --git a/pkg/plugins/golang/v3/commons.go b/pkg/plugins/golang/v3/commons.go index 15760a88e86..0ea6c33f899 100644 --- a/pkg/plugins/golang/v3/commons.go +++ b/pkg/plugins/golang/v3/commons.go @@ -89,7 +89,7 @@ manifests: controller-gen` // create api [options] crd-version=v1beta1. The flag/feature is deprecated. however, to ensure that backwards // compatible we must introduce this logic. Also, note that when we bump the k8s dependencies we need to // ensure that the following replacements will be done accordingly to downgrade the versions. - // The next version of the Golang base plugin (go/v4-alpha) no longer provide this feature. + // The next version of the Golang base plugin (go/v4) no longer provide this feature. const controllerRuntimeVersionForVBeta1 = "v0.9.2" if err := util.ReplaceInFile("go.mod", diff --git a/pkg/plugins/golang/v4/init.go b/pkg/plugins/golang/v4/init.go index 681a20d7ba1..fb94b18e07b 100644 --- a/pkg/plugins/golang/v4/init.go +++ b/pkg/plugins/golang/v4/init.go @@ -69,10 +69,10 @@ func (p *initSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta * - a "cmd/main.go" file that creates the manager that will run the project controllers ` subcmdMeta.Examples = fmt.Sprintf(` # Initialize a new project with your domain and name in copyright - %[1]s init --plugins go/v4-alpha --domain example.org --owner "Your name" + %[1]s init --plugins go/v4 --domain example.org --owner "Your name" # Initialize a new project defining a specific project version - %[1]s init --plugins go/v4-alpha --project-version 3 + %[1]s init --plugins go/v4 --project-version 3 `, cliMeta.CommandName) } diff --git a/pkg/plugins/golang/v4/plugin.go b/pkg/plugins/golang/v4/plugin.go index 89596a2a11c..e973f7aae5c 100644 --- a/pkg/plugins/golang/v4/plugin.go +++ b/pkg/plugins/golang/v4/plugin.go @@ -27,7 +27,7 @@ import ( const pluginName = "base." + golang.DefaultNameQualifier var ( - pluginVersion = plugin.Version{Number: 4, Stage: stage.Alpha} + pluginVersion = plugin.Version{Number: 4, Stage: stage.Stable} supportedProjectVersions = []config.Version{cfgv3.Version} ) diff --git a/pkg/plugins/golang/v4/scaffolds/init.go b/pkg/plugins/golang/v4/scaffolds/init.go index 0a39c087d84..6a1b64e7948 100644 --- a/pkg/plugins/golang/v4/scaffolds/init.go +++ b/pkg/plugins/golang/v4/scaffolds/init.go @@ -106,11 +106,11 @@ func (s *initScaffolder) Scaffold() error { // in order to support it kustomizeVersion = kustomizecommonv1.KustomizeVersion kustomizev2 := kustomizecommonv2alpha.Plugin{} - gov4alpha := "go.kubebuilder.io/v4-alpha" + gov4 := "go.kubebuilder.io/v4" pluginKeyForKustomizeV2 := plugin.KeyFor(kustomizev2) for _, pluginKey := range s.config.GetPluginChain() { - if pluginKey == pluginKeyForKustomizeV2 || pluginKey == gov4alpha { + if pluginKey == pluginKeyForKustomizeV2 || pluginKey == gov4 { kustomizeVersion = kustomizecommonv2alpha.KustomizeVersion break } diff --git a/test/e2e/v4/generate_test.go b/test/e2e/v4/generate_test.go index eb8591d0414..c439751420e 100644 --- a/test/e2e/v4/generate_test.go +++ b/test/e2e/v4/generate_test.go @@ -39,7 +39,7 @@ func GenerateV4(kbc *utils.TestContext) { By("initializing a project") err = kbc.Init( - "--plugins", "go/v4-alpha", + "--plugins", "go/v4", "--project-version", "3", "--domain", kbc.Domain, ) @@ -209,7 +209,7 @@ func GenerateV4ComponentConfig(kbc *utils.TestContext) { By("initializing a project") err = kbc.Init( - "--plugins", "go/v4-alpha", + "--plugins", "go/v4", "--project-version", "3", "--domain", kbc.Domain, "--component-config=true", diff --git a/test/e2e/v4/plugin_cluster_test.go b/test/e2e/v4/plugin_cluster_test.go index 6f65d812c58..8366e7e104e 100644 --- a/test/e2e/v4/plugin_cluster_test.go +++ b/test/e2e/v4/plugin_cluster_test.go @@ -52,7 +52,7 @@ type tokenRequest struct { } var _ = Describe("kubebuilder", func() { - Context("plugin go/v4-alpha", func() { + Context("plugin go/v4", func() { var kbc *utils.TestContext BeforeEach(func() { diff --git a/test/testdata/generate.sh b/test/testdata/generate.sh index 11dce087c1d..814c5723931 100755 --- a/test/testdata/generate.sh +++ b/test/testdata/generate.sh @@ -138,9 +138,9 @@ scaffold_test_project project-v3-with-deploy-image scaffold_test_project project-v3-with-grafana # [Next version, alpha] Project version v4-alpha -scaffold_test_project project-v4 --plugins="go/v4-alpha" -scaffold_test_project project-v4-multigroup --plugins="go/v4-alpha" -scaffold_test_project project-v4-declarative-v1 --plugins="go/v4-alpha,declarative" -scaffold_test_project project-v4-config --component-config --plugins="go/v4-alpha" -scaffold_test_project project-v4-with-deploy-image --plugins="go/v4-alpha" +scaffold_test_project project-v4 --plugins="go/v4" +scaffold_test_project project-v4-multigroup --plugins="go/v4" +scaffold_test_project project-v4-declarative-v1 --plugins="go/v4,declarative" +scaffold_test_project project-v4-config --component-config --plugins="go/v4" +scaffold_test_project project-v4-with-deploy-image --plugins="go/v4" scaffold_test_project project-v4-with-grafana diff --git a/testdata/project-v4-config/PROJECT b/testdata/project-v4-config/PROJECT index dddcf4b57f7..fcd404dbfa7 100644 --- a/testdata/project-v4-config/PROJECT +++ b/testdata/project-v4-config/PROJECT @@ -5,7 +5,7 @@ componentConfig: true domain: testproject.org layout: -- go.kubebuilder.io/v4-alpha +- go.kubebuilder.io/v4 projectName: project-v4-config repo: sigs.k8s.io/kubebuilder/testdata/project-v4-config resources: diff --git a/testdata/project-v4-declarative-v1/PROJECT b/testdata/project-v4-declarative-v1/PROJECT index 28ef24efc50..9753638b394 100644 --- a/testdata/project-v4-declarative-v1/PROJECT +++ b/testdata/project-v4-declarative-v1/PROJECT @@ -4,7 +4,7 @@ # More info: https://book.kubebuilder.io/reference/project-config.html domain: testproject.org layout: -- go.kubebuilder.io/v4-alpha +- go.kubebuilder.io/v4 - declarative.go.kubebuilder.io/v1 plugins: declarative.go.kubebuilder.io/v1: diff --git a/testdata/project-v4-multigroup/PROJECT b/testdata/project-v4-multigroup/PROJECT index 60096e6e453..92f8bcfd7a5 100644 --- a/testdata/project-v4-multigroup/PROJECT +++ b/testdata/project-v4-multigroup/PROJECT @@ -4,7 +4,7 @@ # More info: https://book.kubebuilder.io/reference/project-config.html domain: testproject.org layout: -- go.kubebuilder.io/v4-alpha +- go.kubebuilder.io/v4 multigroup: true projectName: project-v4-multigroup repo: sigs.k8s.io/kubebuilder/testdata/project-v4-multigroup diff --git a/testdata/project-v4-with-deploy-image/PROJECT b/testdata/project-v4-with-deploy-image/PROJECT index 3d0131505b5..f3f6a9a56dc 100644 --- a/testdata/project-v4-with-deploy-image/PROJECT +++ b/testdata/project-v4-with-deploy-image/PROJECT @@ -4,7 +4,7 @@ # More info: https://book.kubebuilder.io/reference/project-config.html domain: testproject.org layout: -- go.kubebuilder.io/v4-alpha +- go.kubebuilder.io/v4 plugins: deploy-image.go.kubebuilder.io/v1-alpha: resources: diff --git a/testdata/project-v4/PROJECT b/testdata/project-v4/PROJECT index c2e591df335..34bad47aa95 100644 --- a/testdata/project-v4/PROJECT +++ b/testdata/project-v4/PROJECT @@ -4,7 +4,7 @@ # More info: https://book.kubebuilder.io/reference/project-config.html domain: testproject.org layout: -- go.kubebuilder.io/v4-alpha +- go.kubebuilder.io/v4 projectName: project-v4 repo: sigs.k8s.io/kubebuilder/testdata/project-v4 resources: From 82843113fbf91d1b994de033dfa90a1f0533f49b Mon Sep 17 00:00:00 2001 From: Varsha Prasad Narsing Date: Wed, 8 Mar 2023 11:43:30 -0500 Subject: [PATCH 19/23] [fix: go/v3, go/v4] Remove stale imports This PR removes the stale import: "pkg/envtest/printer" that is not needed after migrating to ginko/v2. Controller-runtime v0.14.0+ has migrated to use ginko/v2 and thereby removed "printer" package. The imports were still being scaffolded though not used in the codebase. Signed-off-by: Varsha Prasad Narsing --- .../v3/scaffolds/internal/templates/api/webhook_suitetest.go | 1 - .../internal/templates/controllers/controller_suitetest.go | 1 - .../v4/scaffolds/internal/templates/api/webhook_suitetest.go | 1 - .../internal/templates/controllers/controller_suitetest.go | 1 - 4 files changed, 4 deletions(-) diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go index 9ab368fd661..c246cddffb4 100644 --- a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go +++ b/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook_suitetest.go @@ -149,7 +149,6 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" - "sigs.k8s.io/controller-runtime/pkg/envtest/printer" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" ) diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller_suitetest.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller_suitetest.go index 2577add2f1f..5daa897ee6e 100644 --- a/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller_suitetest.go +++ b/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller_suitetest.go @@ -138,7 +138,6 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" - "sigs.k8s.io/controller-runtime/pkg/envtest/printer" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" %s diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook_suitetest.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook_suitetest.go index 3b13084e907..22fd41479ad 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook_suitetest.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/api/webhook_suitetest.go @@ -146,7 +146,6 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" - "sigs.k8s.io/controller-runtime/pkg/envtest/printer" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" ) diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/controllers/controller_suitetest.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/controllers/controller_suitetest.go index 60bd156124f..5f2f8174772 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/controllers/controller_suitetest.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/controllers/controller_suitetest.go @@ -140,7 +140,6 @@ import ( "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" - "sigs.k8s.io/controller-runtime/pkg/envtest/printer" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" %s From 2e445098693c5efcfa8024806aaa6b663cac2bcf Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Sat, 11 Mar 2023 10:19:57 +0000 Subject: [PATCH 20/23] fix nit lint issue --- pkg/config/store/yaml/store_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/config/store/yaml/store_test.go b/pkg/config/store/yaml/store_test.go index be831a489eb..d4afb6dad8d 100644 --- a/pkg/config/store/yaml/store_test.go +++ b/pkg/config/store/yaml/store_test.go @@ -54,10 +54,10 @@ var _ = Describe("yamlStore", func() { unversionedFile = `version: ` nonexistentVersionFile = `version: 1-alpha -` // v1-alpha never existed +` // v1-alpha never existed wrongFile = `version: "2" layout: "" -` // layout field does not exist in v2 +` // layout field does not exist in v2 ) var ( From 5f89a59f606d7de58570c8594cfd41bd67417859 Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Sat, 11 Mar 2023 11:46:15 +0000 Subject: [PATCH 21/23] =?UTF-8?q?=F0=9F=90=9B=20=20fix:=20deprecate=20mess?= =?UTF-8?q?age=20should=20be=20in=20go/v3=20(#3277)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: deprecate message should be in go/v3 --- pkg/plugins/golang/v3/plugin.go | 8 ++++++++ pkg/plugins/golang/v4/plugin.go | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/plugins/golang/v3/plugin.go b/pkg/plugins/golang/v3/plugin.go index 3ad89267e4b..07f5e812931 100644 --- a/pkg/plugins/golang/v3/plugin.go +++ b/pkg/plugins/golang/v3/plugin.go @@ -62,3 +62,11 @@ func (p Plugin) GetCreateWebhookSubcommand() plugin.CreateWebhookSubcommand { // GetEditSubcommand will return the subcommand which is responsible for editing the scaffold of the project func (p Plugin) GetEditSubcommand() plugin.EditSubcommand { return &p.editSubcommand } + +func (p Plugin) DeprecationWarning() string { + return "This version is deprecated." + + "The `go/v3` cannot scaffold projects using kustomize versions v4x+" + + " and cannot fully support Kubernetes 1.25+." + + "It is recommended to upgrade your project to the latest versions available (go/v4)." + + "Please, check the migration guide to learn how to upgrade your project" +} diff --git a/pkg/plugins/golang/v4/plugin.go b/pkg/plugins/golang/v4/plugin.go index e973f7aae5c..385e79f7cfa 100644 --- a/pkg/plugins/golang/v4/plugin.go +++ b/pkg/plugins/golang/v4/plugin.go @@ -63,11 +63,3 @@ func (p Plugin) GetCreateWebhookSubcommand() plugin.CreateWebhookSubcommand { // GetEditSubcommand will return the subcommand which is responsible for editing the scaffold of the project func (p Plugin) GetEditSubcommand() plugin.EditSubcommand { return &p.editSubcommand } - -func (p Plugin) DeprecationWarning() string { - return "This version is deprecated." + - "The `go/v3` cannot scaffold projects using kustomize versions v4x+" + - " and cannot fully support Kubernetes 1.25+." + - "It is recommended to upgrade your project to the latest versions available (go/v4)." + - "Please, check the migration guide to learn how to upgrade your project" -} From 958cda208be4db41b5adf20742fdc780b7000bbd Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Sat, 11 Mar 2023 12:07:43 +0000 Subject: [PATCH 22/23] =?UTF-8?q?=F0=9F=8C=B1=20:=20fix=20sample=20project?= =?UTF-8?q?-v4-grafana=20(#3279)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit :bug: fix sample project-v4-grafana --- test/testdata/generate.sh | 12 +- testdata/project-v4-with-grafana/Dockerfile | 6 +- testdata/project-v4-with-grafana/Makefile | 6 +- testdata/project-v4-with-grafana/PROJECT | 2 +- .../project-v4-with-grafana/{ => cmd}/main.go | 0 .../config/default/kustomization.yaml | 134 ++++++++++++++---- .../config/rbac/service_account.yaml | 2 +- 7 files changed, 117 insertions(+), 45 deletions(-) rename testdata/project-v4-with-grafana/{ => cmd}/main.go (100%) diff --git a/test/testdata/generate.sh b/test/testdata/generate.sh index 814c5723931..b87539e827d 100755 --- a/test/testdata/generate.sh +++ b/test/testdata/generate.sh @@ -130,12 +130,12 @@ build_kb scaffold_test_project project-v2 --project-version=2 # [Currently, default CLI plugin] - Project version 3 (default) uses plugin go/v3 (default). -scaffold_test_project project-v3 -scaffold_test_project project-v3-multigroup +scaffold_test_project project-v3 --plugins="go/v3" +scaffold_test_project project-v3-multigroup --plugins="go/v3" scaffold_test_project project-v3-declarative-v1 --plugins="go/v3,declarative" -scaffold_test_project project-v3-config --component-config -scaffold_test_project project-v3-with-deploy-image -scaffold_test_project project-v3-with-grafana +scaffold_test_project project-v3-config --component-config --plugins="go/v3" +scaffold_test_project project-v3-with-deploy-image --plugins="go/v3" +scaffold_test_project project-v3-with-grafana --plugins="go/v3" # [Next version, alpha] Project version v4-alpha scaffold_test_project project-v4 --plugins="go/v4" @@ -143,4 +143,4 @@ scaffold_test_project project-v4-multigroup --plugins="go/v4" scaffold_test_project project-v4-declarative-v1 --plugins="go/v4,declarative" scaffold_test_project project-v4-config --component-config --plugins="go/v4" scaffold_test_project project-v4-with-deploy-image --plugins="go/v4" -scaffold_test_project project-v4-with-grafana +scaffold_test_project project-v4-with-grafana --plugins="go/v4" diff --git a/testdata/project-v4-with-grafana/Dockerfile b/testdata/project-v4-with-grafana/Dockerfile index 8f9cca18eb6..ef4cfaf90bd 100644 --- a/testdata/project-v4-with-grafana/Dockerfile +++ b/testdata/project-v4-with-grafana/Dockerfile @@ -12,16 +12,16 @@ COPY go.sum go.sum RUN go mod download # Copy the go source -COPY main.go main.go +COPY cmd/main.go cmd/main.go COPY api/ api/ -COPY controllers/ controllers/ +COPY internal/controller/ internal/controller/ # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/testdata/project-v4-with-grafana/Makefile b/testdata/project-v4-with-grafana/Makefile index 73a01c158dd..87dd37d4e2f 100644 --- a/testdata/project-v4-with-grafana/Makefile +++ b/testdata/project-v4-with-grafana/Makefile @@ -62,11 +62,11 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: manifests generate fmt vet ## Build manager binary. - go build -o bin/manager main.go + go build -o bin/manager cmd/main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. - go run ./main.go + go run ./cmd/main.go # If you wish built the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. @@ -132,7 +132,7 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions -KUSTOMIZE_VERSION ?= v3.8.7 +KUSTOMIZE_VERSION ?= v5.0.0 CONTROLLER_TOOLS_VERSION ?= v0.11.3 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" diff --git a/testdata/project-v4-with-grafana/PROJECT b/testdata/project-v4-with-grafana/PROJECT index 241a6cdefb9..35d0977d50f 100644 --- a/testdata/project-v4-with-grafana/PROJECT +++ b/testdata/project-v4-with-grafana/PROJECT @@ -4,7 +4,7 @@ # More info: https://book.kubebuilder.io/reference/project-config.html domain: testproject.org layout: -- go.kubebuilder.io/v3 +- go.kubebuilder.io/v4 plugins: grafana.kubebuilder.io/v1-alpha: {} projectName: project-v4-with-grafana diff --git a/testdata/project-v4-with-grafana/main.go b/testdata/project-v4-with-grafana/cmd/main.go similarity index 100% rename from testdata/project-v4-with-grafana/main.go rename to testdata/project-v4-with-grafana/cmd/main.go diff --git a/testdata/project-v4-with-grafana/config/default/kustomization.yaml b/testdata/project-v4-with-grafana/config/default/kustomization.yaml index ca19fadabb7..d392dadc0fd 100644 --- a/testdata/project-v4-with-grafana/config/default/kustomization.yaml +++ b/testdata/project-v4-with-grafana/config/default/kustomization.yaml @@ -9,10 +9,12 @@ namespace: project-v4-with-grafana-system namePrefix: project-v4-with-grafana- # Labels to add to all resources and selectors. -#commonLabels: -# someName: someValue +#labels: +#- includeSelectors: true +# pairs: +# someName: someValue -bases: +resources: - ../crd - ../rbac - ../manager @@ -41,32 +43,102 @@ patchesStrategicMerge: # 'CERTMANAGER' needs to be enabled to use ca injection #- webhookcainjection_patch.yaml -# the following config is for teaching kustomize how to do var substitution -vars: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. -#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -# fieldref: -# fieldpath: metadata.namespace -#- name: CERTIFICATE_NAME -# objref: -# kind: Certificate -# group: cert-manager.io -# version: v1 -# name: serving-cert # this name should match the one in certificate.yaml -#- name: SERVICE_NAMESPACE # namespace of the service -# objref: -# kind: Service -# version: v1 -# name: webhook-service -# fieldref: -# fieldpath: metadata.namespace -#- name: SERVICE_NAME -# objref: -# kind: Service -# version: v1 -# name: webhook-service +# Uncomment the following replacements to add the cert-manager CA injection annotations +#replacements: +# - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs +# kind: Certificate +# group: cert-manager.io +# version: v1 +# name: serving-cert # this name should match the one in certificate.yaml +# fieldPath: .metadata.namespace # namespace of the certificate CR +# targets: +# - select: +# kind: ValidatingWebhookConfiguration +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 0 +# create: true +# - select: +# kind: MutatingWebhookConfiguration +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 0 +# create: true +# - select: +# kind: CustomResourceDefinition +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 0 +# create: true +# - source: +# kind: Certificate +# group: cert-manager.io +# version: v1 +# name: serving-cert # this name should match the one in certificate.yaml +# fieldPath: .metadata.name +# targets: +# - select: +# kind: ValidatingWebhookConfiguration +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 1 +# create: true +# - select: +# kind: MutatingWebhookConfiguration +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 1 +# create: true +# - select: +# kind: CustomResourceDefinition +# fieldPaths: +# - .metadata.annotations.[cert-manager.io/inject-ca-from] +# options: +# delimiter: '/' +# index: 1 +# create: true +# - source: # Add cert-manager annotation to the webhook Service +# kind: Service +# version: v1 +# name: webhook-service +# fieldPath: .metadata.name # namespace of the service +# targets: +# - select: +# kind: Certificate +# group: cert-manager.io +# version: v1 +# fieldPaths: +# - .spec.dnsNames.0 +# - .spec.dnsNames.1 +# options: +# delimiter: '.' +# index: 0 +# create: true +# - source: +# kind: Service +# version: v1 +# name: webhook-service +# fieldPath: .metadata.namespace # namespace of the service +# targets: +# - select: +# kind: Certificate +# group: cert-manager.io +# version: v1 +# fieldPaths: +# - .spec.dnsNames.0 +# - .spec.dnsNames.1 +# options: +# delimiter: '.' +# index: 1 +# create: true diff --git a/testdata/project-v4-with-grafana/config/rbac/service_account.yaml b/testdata/project-v4-with-grafana/config/rbac/service_account.yaml index 1fb853ae687..04f10b75d76 100644 --- a/testdata/project-v4-with-grafana/config/rbac/service_account.yaml +++ b/testdata/project-v4-with-grafana/config/rbac/service_account.yaml @@ -3,7 +3,7 @@ kind: ServiceAccount metadata: labels: app.kubernetes.io/name: serviceaccount - app.kubernetes.io/instance: controller-manager + app.kubernetes.io/instance: controller-manager-sa app.kubernetes.io/component: rbac app.kubernetes.io/created-by: project-v4-with-grafana app.kubernetes.io/part-of: project-v4-with-grafana From 66aa98b1a3ef172ce895abdc4590454a34d3aece Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Sat, 11 Mar 2023 12:49:23 +0000 Subject: [PATCH 23/23] :book: update cronjob tutorial sample to use go/v4 --- docs/book/install-and-build.sh | 2 +- .../controller-implementation.md | 2 +- .../src/cronjob-tutorial/main-revisited.md | 2 +- .../testdata/generate_cronjob.sh | 2 +- .../testdata/project/Dockerfile | 6 +- .../testdata/project/Makefile | 8 +- .../cronjob-tutorial/testdata/project/PROJECT | 2 +- .../project/api/v1/webhook_suite_test.go | 4 +- .../testdata/project/{ => cmd}/main.go | 4 +- .../config/certmanager/certificate.yaml | 10 +- .../config/certmanager/kustomizeconfig.yaml | 10 +- ...atch.tutorial.kubebuilder.io_cronjobs.yaml | 2 +- .../crd/patches/cainjection_in_cronjobs.yaml | 2 +- .../project/config/default/kustomization.yaml | 138 +++++++++++++----- .../default/webhookcainjection_patch.yaml | 6 +- .../project/config/manager/kustomization.yaml | 1 - .../project/config/rbac/service_account.yaml | 2 +- .../project/config/samples/kustomization.yaml | 4 + .../config/webhook/kustomizeconfig.yaml | 5 +- .../cronjob-tutorial/testdata/project/go.mod | 2 +- .../cronjob-tutorial/testdata/project/go.sum | 4 +- .../controller}/cronjob_controller.go | 4 +- .../controller}/cronjob_controller_test.go | 2 +- .../controller}/suite_test.go | 6 +- .../src/cronjob-tutorial/writing-tests.md | 4 +- 25 files changed, 149 insertions(+), 85 deletions(-) rename docs/book/src/cronjob-tutorial/testdata/project/{ => cmd}/main.go (98%) create mode 100644 docs/book/src/cronjob-tutorial/testdata/project/config/samples/kustomization.yaml rename docs/book/src/cronjob-tutorial/testdata/project/{controllers => internal/controller}/cronjob_controller.go (99%) rename docs/book/src/cronjob-tutorial/testdata/project/{controllers => internal/controller}/cronjob_controller_test.go (99%) rename docs/book/src/cronjob-tutorial/testdata/project/{controllers => internal/controller}/suite_test.go (96%) diff --git a/docs/book/install-and-build.sh b/docs/book/install-and-build.sh index 8a4ef89b451..fc9c6a51199 100755 --- a/docs/book/install-and-build.sh +++ b/docs/book/install-and-build.sh @@ -67,7 +67,7 @@ ${cmd} /tmp/mdbook.${ext} chmod +x /tmp/mdbook echo "grabbing the latest released controller-gen" -go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.1 +go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.3 # make sure we add the go bin directory to our path gobin=$(go env GOBIN) diff --git a/docs/book/src/cronjob-tutorial/controller-implementation.md b/docs/book/src/cronjob-tutorial/controller-implementation.md index 95dc605f152..be548e069a1 100644 --- a/docs/book/src/cronjob-tutorial/controller-implementation.md +++ b/docs/book/src/cronjob-tutorial/controller-implementation.md @@ -18,7 +18,7 @@ The basic logic of our CronJob controller is this: 7. Requeue when we either see a running job (done automatically) or it's time for the next scheduled run. -{{#literatego ./testdata/project/controllers/cronjob_controller.go}} +{{#literatego ./testdata/project/internal/controller/cronjob_controller.go}} That was a doozy, but now we've got a working controller. Let's test against the cluster, then, if we don't have any issues, deploy it! diff --git a/docs/book/src/cronjob-tutorial/main-revisited.md b/docs/book/src/cronjob-tutorial/main-revisited.md index 395b67e5bd3..4a8c0fd33dc 100644 --- a/docs/book/src/cronjob-tutorial/main-revisited.md +++ b/docs/book/src/cronjob-tutorial/main-revisited.md @@ -4,6 +4,6 @@ But first, remember how we said we'd [come back to `main.go` again](/cronjob-tutorial/empty-main.md)? Let's take a look and see what's changed, and what we need to add. -{{#literatego ./testdata/project/main.go}} +{{#literatego ./testdata/project/cmd/main.go}} *Now* we can implement our controller. diff --git a/docs/book/src/cronjob-tutorial/testdata/generate_cronjob.sh b/docs/book/src/cronjob-tutorial/testdata/generate_cronjob.sh index 073de3ec5fc..2adc6603cef 100755 --- a/docs/book/src/cronjob-tutorial/testdata/generate_cronjob.sh +++ b/docs/book/src/cronjob-tutorial/testdata/generate_cronjob.sh @@ -52,7 +52,7 @@ function gen_cronjob_tutorial { mkdir project cd project header_text "creating tutorial.kubebuilder.io base ..." - kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors" + kubebuilder init --plugins=go/v4 --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --license apache2 --owner "The Kubernetes authors" kubebuilder create api --group batch --version v1 --kind CronJob --resource --controller kubebuilder create webhook --group batch --version v1 --kind CronJob --defaulting --programmatic-validation go mod tidy diff --git a/docs/book/src/cronjob-tutorial/testdata/project/Dockerfile b/docs/book/src/cronjob-tutorial/testdata/project/Dockerfile index 8f9cca18eb6..ef4cfaf90bd 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/Dockerfile +++ b/docs/book/src/cronjob-tutorial/testdata/project/Dockerfile @@ -12,16 +12,16 @@ COPY go.sum go.sum RUN go mod download # Copy the go source -COPY main.go main.go +COPY cmd/main.go cmd/main.go COPY api/ api/ -COPY controllers/ controllers/ +COPY internal/controller/ internal/controller/ # Build # the GOARCH has not a default value to allow the binary be built according to the host where the command # was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO # the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, # by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. -RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details diff --git a/docs/book/src/cronjob-tutorial/testdata/project/Makefile b/docs/book/src/cronjob-tutorial/testdata/project/Makefile index e3e61f60c84..87dd37d4e2f 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/Makefile +++ b/docs/book/src/cronjob-tutorial/testdata/project/Makefile @@ -62,11 +62,11 @@ test: manifests generate fmt vet envtest ## Run tests. .PHONY: build build: manifests generate fmt vet ## Build manager binary. - go build -o bin/manager main.go + go build -o bin/manager cmd/main.go .PHONY: run run: manifests generate fmt vet ## Run a controller from your host. - go run ./main.go + go run ./cmd/main.go # If you wish built the manager image targeting other platforms you can use the --platform flag. # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. @@ -132,8 +132,8 @@ CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions -KUSTOMIZE_VERSION ?= v3.8.7 -CONTROLLER_TOOLS_VERSION ?= v0.11.1 +KUSTOMIZE_VERSION ?= v5.0.0 +CONTROLLER_TOOLS_VERSION ?= v0.11.3 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize diff --git a/docs/book/src/cronjob-tutorial/testdata/project/PROJECT b/docs/book/src/cronjob-tutorial/testdata/project/PROJECT index 8c1ce305ea2..573e2e5ff1f 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/PROJECT +++ b/docs/book/src/cronjob-tutorial/testdata/project/PROJECT @@ -4,7 +4,7 @@ # More info: https://book.kubebuilder.io/reference/project-config.html domain: tutorial.kubebuilder.io layout: -- go.kubebuilder.io/v3 +- go.kubebuilder.io/v4 projectName: project repo: tutorial.kubebuilder.io/project resources: diff --git a/docs/book/src/cronjob-tutorial/testdata/project/api/v1/webhook_suite_test.go b/docs/book/src/cronjob-tutorial/testdata/project/api/v1/webhook_suite_test.go index 620effb6197..9abf343fbdb 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/api/v1/webhook_suite_test.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/api/v1/webhook_suite_test.go @@ -28,7 +28,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - admissionv1beta1 "k8s.io/api/admission/v1beta1" + admissionv1 "k8s.io/api/admission/v1" //+kubebuilder:scaffold:imports "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/rest" @@ -78,7 +78,7 @@ var _ = BeforeSuite(func() { err = AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) - err = admissionv1beta1.AddToScheme(scheme) + err = admissionv1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) //+kubebuilder:scaffold:scheme diff --git a/docs/book/src/cronjob-tutorial/testdata/project/main.go b/docs/book/src/cronjob-tutorial/testdata/project/cmd/main.go similarity index 98% rename from docs/book/src/cronjob-tutorial/testdata/project/main.go rename to docs/book/src/cronjob-tutorial/testdata/project/cmd/main.go index 4577185fb12..65054cbc361 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/main.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/cmd/main.go @@ -20,6 +20,7 @@ package main import ( "flag" "os" + "tutorial.kubebuilder.io/project/internal/controller" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. @@ -33,7 +34,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" batchv1 "tutorial.kubebuilder.io/project/api/v1" - "tutorial.kubebuilder.io/project/controllers" //+kubebuilder:scaffold:imports ) @@ -109,7 +109,7 @@ func main() { // +kubebuilder:docs-gen:collapse=old stuff - if err = (&controllers.CronJobReconciler{ + if err = (&controller.CronJobReconciler{ Client: mgr.GetClient(), Scheme: mgr.GetScheme(), }).SetupWithManager(mgr); err != nil { diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/certificate.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/certificate.yaml index 886202b4ed7..36b9d42e69d 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/certificate.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/certificate.yaml @@ -5,8 +5,8 @@ apiVersion: cert-manager.io/v1 kind: Issuer metadata: labels: - app.kubernetes.io/name: issuer - app.kubernetes.io/instance: selfsigned-issuer + app.kubernetes.io/name: certificate + app.kubernetes.io/instance: serving-cert app.kubernetes.io/component: certificate app.kubernetes.io/created-by: project app.kubernetes.io/part-of: project @@ -29,10 +29,10 @@ metadata: name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml namespace: system spec: - # $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize + # SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize dnsNames: - - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc - - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local + - SERVICE_NAME.SERVICE_NAMESPACE.svc + - SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local issuerRef: kind: Issuer name: selfsigned-issuer diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/kustomizeconfig.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/kustomizeconfig.yaml index e631f777366..cf6f89e8892 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/kustomizeconfig.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/certmanager/kustomizeconfig.yaml @@ -1,4 +1,4 @@ -# This configuration is for teaching kustomize how to update name ref and var substitution +# This configuration is for teaching kustomize how to update name ref substitution nameReference: - kind: Issuer group: cert-manager.io @@ -6,11 +6,3 @@ nameReference: - kind: Certificate group: cert-manager.io path: spec/issuerRef/name - -varReference: -- kind: Certificate - group: cert-manager.io - path: spec/commonName -- kind: Certificate - group: cert-manager.io - path: spec/dnsNames diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/bases/batch.tutorial.kubebuilder.io_cronjobs.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/crd/bases/batch.tutorial.kubebuilder.io_cronjobs.yaml index 670fd84e429..8279fb83eb7 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/bases/batch.tutorial.kubebuilder.io_cronjobs.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/crd/bases/batch.tutorial.kubebuilder.io_cronjobs.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - controller-gen.kubebuilder.io/version: v0.11.1 + controller-gen.kubebuilder.io/version: v0.11.3 creationTimestamp: null name: cronjobs.batch.tutorial.kubebuilder.io spec: diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/cainjection_in_cronjobs.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/cainjection_in_cronjobs.yaml index 7b037c0e41f..752fa9ac6a0 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/cainjection_in_cronjobs.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/crd/patches/cainjection_in_cronjobs.yaml @@ -3,5 +3,5 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME name: cronjobs.batch.tutorial.kubebuilder.io diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/default/kustomization.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/default/kustomization.yaml index 178e48bdb97..d9dc63e0d2a 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/default/kustomization.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/default/kustomization.yaml @@ -9,10 +9,12 @@ namespace: project-system namePrefix: project- # Labels to add to all resources and selectors. -#commonLabels: -# someName: someValue +#labels: +#- includeSelectors: true +# pairs: +# someName: someValue -bases: +resources: - ../crd - ../rbac - ../manager @@ -22,7 +24,7 @@ bases: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required. - ../certmanager # [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'. -#- ../prometheus +- ../prometheus patchesStrategicMerge: # Protect the /metrics endpoint by putting it behind auth. @@ -34,39 +36,109 @@ patchesStrategicMerge: # [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in # crd/kustomization.yaml -- manager_webhook_patch.yaml +#- manager_webhook_patch.yaml # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. # Uncomment 'CERTMANAGER' sections in crd/kustomization.yaml to enable the CA injection in the admission webhooks. # 'CERTMANAGER' needs to be enabled to use ca injection - webhookcainjection_patch.yaml -# the following config is for teaching kustomize how to do var substitution -vars: # [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix. -- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR - objref: - kind: Certificate - group: cert-manager.io - version: v1 - name: serving-cert # this name should match the one in certificate.yaml - fieldref: - fieldpath: metadata.namespace -- name: CERTIFICATE_NAME - objref: - kind: Certificate - group: cert-manager.io - version: v1 - name: serving-cert # this name should match the one in certificate.yaml -- name: SERVICE_NAMESPACE # namespace of the service - objref: - kind: Service - version: v1 - name: webhook-service - fieldref: - fieldpath: metadata.namespace -- name: SERVICE_NAME - objref: - kind: Service - version: v1 - name: webhook-service +# Uncomment the following replacements to add the cert-manager CA injection annotations +replacements: + - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs + kind: Certificate + group: cert-manager.io + version: v1 + name: serving-cert # this name should match the one in certificate.yaml + fieldPath: .metadata.namespace # namespace of the certificate CR + targets: + - select: + kind: ValidatingWebhookConfiguration + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 0 + create: true + - select: + kind: MutatingWebhookConfiguration + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 0 + create: true + - select: + kind: CustomResourceDefinition + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 0 + create: true + - source: + kind: Certificate + group: cert-manager.io + version: v1 + name: serving-cert # this name should match the one in certificate.yaml + fieldPath: .metadata.name + targets: + - select: + kind: ValidatingWebhookConfiguration + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 1 + create: true + - select: + kind: MutatingWebhookConfiguration + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 1 + create: true + - select: + kind: CustomResourceDefinition + fieldPaths: + - .metadata.annotations.[cert-manager.io/inject-ca-from] + options: + delimiter: '/' + index: 1 + create: true + - source: # Add cert-manager annotation to the webhook Service + kind: Service + version: v1 + name: webhook-service + fieldPath: .metadata.name # namespace of the service + targets: + - select: + kind: Certificate + group: cert-manager.io + version: v1 + fieldPaths: + - .spec.dnsNames.0 + - .spec.dnsNames.1 + options: + delimiter: '.' + index: 0 + create: true + - source: + kind: Service + version: v1 + name: webhook-service + fieldPath: .metadata.namespace # namespace of the service + targets: + - select: + kind: Certificate + group: cert-manager.io + version: v1 + fieldPaths: + - .spec.dnsNames.0 + - .spec.dnsNames.1 + options: + delimiter: '.' + index: 1 + create: true diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/default/webhookcainjection_patch.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/default/webhookcainjection_patch.yaml index 88cd5d22870..202f1d83d52 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/default/webhookcainjection_patch.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/default/webhookcainjection_patch.yaml @@ -1,5 +1,5 @@ # This patch add annotation to admission webhook config and -# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize. +# CERTIFICATE_NAMESPACE and CERTIFICATE_NAME will be substituted by kustomize apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: @@ -12,7 +12,7 @@ metadata: app.kubernetes.io/managed-by: kustomize name: mutating-webhook-configuration annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME --- apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration @@ -26,4 +26,4 @@ metadata: app.kubernetes.io/managed-by: kustomize name: validating-webhook-configuration annotations: - cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME) + cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/manager/kustomization.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/manager/kustomization.yaml index 372a75ae43f..5c5f0b84cba 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/manager/kustomization.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/manager/kustomization.yaml @@ -1,3 +1,2 @@ resources: - manager.yaml - diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/rbac/service_account.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/rbac/service_account.yaml index 018f2dd1b59..c38941e4f9e 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/rbac/service_account.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/rbac/service_account.yaml @@ -3,7 +3,7 @@ kind: ServiceAccount metadata: labels: app.kubernetes.io/name: serviceaccount - app.kubernetes.io/instance: controller-manager + app.kubernetes.io/instance: controller-manager-sa app.kubernetes.io/component: rbac app.kubernetes.io/created-by: project app.kubernetes.io/part-of: project diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/samples/kustomization.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/samples/kustomization.yaml new file mode 100644 index 00000000000..9324acc15c9 --- /dev/null +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/samples/kustomization.yaml @@ -0,0 +1,4 @@ +## Append samples of your project ## +resources: +- batch_v1_cronjob.yaml +#+kubebuilder:scaffold:manifestskustomizesamples diff --git a/docs/book/src/cronjob-tutorial/testdata/project/config/webhook/kustomizeconfig.yaml b/docs/book/src/cronjob-tutorial/testdata/project/config/webhook/kustomizeconfig.yaml index 25e21e3c963..206316e54ff 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/config/webhook/kustomizeconfig.yaml +++ b/docs/book/src/cronjob-tutorial/testdata/project/config/webhook/kustomizeconfig.yaml @@ -1,4 +1,4 @@ -# the following config is for teaching kustomize where to look at when substituting vars. +# the following config is for teaching kustomize where to look at when substituting nameReference. # It requires kustomize v2.1.0 or newer to work properly. nameReference: - kind: Service @@ -20,6 +20,3 @@ namespace: group: admissionregistration.k8s.io path: webhooks/clientConfig/service/namespace create: true - -varReference: -- path: metadata/annotations diff --git a/docs/book/src/cronjob-tutorial/testdata/project/go.mod b/docs/book/src/cronjob-tutorial/testdata/project/go.mod index 586d85969da..80df4571d5f 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/go.mod +++ b/docs/book/src/cronjob-tutorial/testdata/project/go.mod @@ -8,7 +8,7 @@ require ( k8s.io/api v0.26.1 k8s.io/apimachinery v0.26.1 k8s.io/client-go v0.26.1 - sigs.k8s.io/controller-runtime v0.14.2 + sigs.k8s.io/controller-runtime v0.14.4 ) require ( diff --git a/docs/book/src/cronjob-tutorial/testdata/project/go.sum b/docs/book/src/cronjob-tutorial/testdata/project/go.sum index 4709c2a2d1e..4c702bb0401 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/go.sum +++ b/docs/book/src/cronjob-tutorial/testdata/project/go.sum @@ -607,8 +607,8 @@ k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/controller-runtime v0.14.2 h1:P6IwDhbsRWsBClt/8/h8Zy36bCuGuW5Op7MHpFrN/60= -sigs.k8s.io/controller-runtime v0.14.2/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= +sigs.k8s.io/controller-runtime v0.14.4 h1:Kd/Qgx5pd2XUL08eOV2vwIq3L9GhIbJ5Nxengbd4/0M= +sigs.k8s.io/controller-runtime v0.14.4/go.mod h1:WqIdsAY6JBsjfc/CqO0CORmNtoCtE4S6qbPc9s68h+0= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= diff --git a/docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller.go b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go similarity index 99% rename from docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller.go rename to docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go index c6e599eaf86..64f0eef969c 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go @@ -19,7 +19,7 @@ limitations under the License. We'll start out with some imports. You'll see below that we'll need a few more imports than those scaffolded for us. We'll talk about each one when we use it. */ -package controllers +package controller import ( "context" @@ -94,7 +94,7 @@ var ( // the user. // // For more details, check Reconcile and its Result here: -// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.0/pkg/reconcile +// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile func (r *CronJobReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { log := log.FromContext(ctx) diff --git a/docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go similarity index 99% rename from docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go rename to docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go index aab07668d49..d28c25d53aa 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go @@ -22,7 +22,7 @@ So, let's write our example test for the CronJob controller (`cronjob_controller /* As usual, we start with the necessary imports. We also define some utility variables. */ -package controllers +package controller import ( "context" diff --git a/docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/suite_test.go similarity index 96% rename from docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go rename to docs/book/src/cronjob-tutorial/testdata/project/internal/controller/suite_test.go index 9336f69319f..4fade8b1492 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/controllers/suite_test.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/internal/controller/suite_test.go @@ -17,12 +17,12 @@ limitations under the License. /* When we created the CronJob API with `kubebuilder create api` in a [previous chapter](/cronjob-tutorial/new-api.md), Kubebuilder already did some test work for you. -Kubebuilder scaffolded a `controllers/suite_test.go` file that does the bare bones of setting up a test environment. +Kubebuilder scaffolded a `internal/controller/suite_test.go` file that does the bare bones of setting up a test environment. First, it will contain the necessary imports. */ -package controllers +package controller import ( "context" @@ -77,7 +77,7 @@ var _ = BeforeSuite(func() { */ By("bootstrapping test environment") testEnv = &envtest.Environment{ - CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")}, + CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")}, ErrorIfCRDPathMissing: true, } diff --git a/docs/book/src/cronjob-tutorial/writing-tests.md b/docs/book/src/cronjob-tutorial/writing-tests.md index e62d8a31441..f31d87fc1c6 100644 --- a/docs/book/src/cronjob-tutorial/writing-tests.md +++ b/docs/book/src/cronjob-tutorial/writing-tests.md @@ -11,11 +11,11 @@ If you want to tinker with how your envtest cluster is configured, see section [ ## Test Environment Setup -{{#literatego ../cronjob-tutorial/testdata/project/controllers/suite_test.go}} +{{#literatego ../cronjob-tutorial/testdata/project/internal/controller/suite_test.go}} ## Testing your Controller's Behavior -{{#literatego ../cronjob-tutorial/testdata/project/controllers/cronjob_controller_test.go}} +{{#literatego ../cronjob-tutorial/testdata/project/internal/controller/cronjob_controller_test.go}} This Status update example above demonstrates a general testing strategy for a custom Kind with downstream objects. By this point, you hopefully have learned the following methods for testing your controller behavior: