diff --git a/cmd/main.go b/cmd/main.go
index 617f06b08b4..9955408588d 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -20,19 +20,15 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/afero"
"sigs.k8s.io/kubebuilder/v3/pkg/cli"
- 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/plugin"
- kustomizecommonv1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v1"
- kustomizecommonv2alpha "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2"
+ kustomizecommonv2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/common/kustomize/v2"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
//nolint:staticcheck
declarativev1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/declarative/v1"
deployimagev1alpha1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/deploy-image/v1alpha1"
- golangv2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2"
- golangv3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
golangv4 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v4"
grafanav1alpha1 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/optional/grafana/v1alpha"
)
@@ -43,24 +39,10 @@ func init() {
}
func main() {
-
- const deprecateMessageGoV3Bundle = "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"
-
- // Bundle plugin which built the golang projects scaffold by Kubebuilder go/v3
- gov3Bundle, _ := plugin.NewBundleWithOptions(plugin.WithName(golang.DefaultNameQualifier),
- plugin.WithVersion(plugin.Version{Number: 3}),
- plugin.WithDeprecationMessage(deprecateMessageGoV3Bundle),
- plugin.WithPlugins(kustomizecommonv1.Plugin{}, golangv3.Plugin{}),
- )
-
- // Bundle plugin which built the golang projects scaffold by Kubebuilder go/v4 with kustomize alpha-v2
+ // Bundle plugin which built the golang projects scaffold by Kubebuilder go/v4 with kustomize v2
gov4Bundle, _ := plugin.NewBundleWithOptions(plugin.WithName(golang.DefaultNameQualifier),
plugin.WithVersion(plugin.Version{Number: 4}),
- plugin.WithPlugins(kustomizecommonv2alpha.Plugin{}, golangv4.Plugin{}),
+ plugin.WithPlugins(kustomizecommonv2.Plugin{}, golangv4.Plugin{}),
)
fs := machinery.Filesystem{
@@ -75,19 +57,14 @@ func main() {
cli.WithCommandName("kubebuilder"),
cli.WithVersion(versionString()),
cli.WithPlugins(
- golangv2.Plugin{},
- golangv3.Plugin{},
golangv4.Plugin{},
- gov3Bundle,
gov4Bundle,
- &kustomizecommonv1.Plugin{},
- &kustomizecommonv2alpha.Plugin{},
+ &kustomizecommonv2.Plugin{},
&declarativev1.Plugin{},
&deployimagev1alpha1.Plugin{},
&grafanav1alpha1.Plugin{},
),
cli.WithPlugins(externalPlugins...),
- cli.WithDefaultPlugins(cfgv2.Version, golangv2.Plugin{}),
cli.WithDefaultPlugins(cfgv3.Version, gov4Bundle),
cli.WithDefaultProjectVersion(cfgv3.Version),
cli.WithCompletion(),
diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md
index d4495ce7700..5bace7b4065 100644
--- a/docs/book/src/SUMMARY.md
+++ b/docs/book/src/SUMMARY.md
@@ -114,16 +114,13 @@
- [Available Plugins](./plugins/available-plugins.md)
- [To scaffold a project](./plugins/to-scaffold-project.md)
- - [go/v2 (Deprecated)](./plugins/go-v2-plugin.md)
- - [go/v3 (Deprecated)](./plugins/go-v3-plugin.md)
- [go/v4 (Default init scaffold)](./plugins/go-v4-plugin.md)
- [To add optional features](./plugins/to-add-optional-features.md)
- [declarative/v1 (Deprecated)](./plugins/declarative-v1.md)
- [grafana/v1-alpha](./plugins/grafana-v1-alpha.md)
- [deploy-image/v1-alpha](./plugins/deploy-image-plugin-v1-alpha.md)
- [To be extended for others tools](./plugins/to-be-extended.md)
- - [kustomize/v1 (Deprecated)](./plugins/kustomize-v1.md)
- - [kustomize/v2](./plugins/kustomize-v2.md)
+ - [kustomize/v2 (Default init scaffold with go/v4)](./plugins/kustomize-v2.md)
- [Extending the CLI](./plugins/extending-cli.md)
- [Creating your own plugins](./plugins/creating-plugins.md)
- [Testing your own plugins](./plugins/testing-plugins.md)
diff --git a/docs/book/src/plugins/go-v2-plugin.md b/docs/book/src/plugins/go-v2-plugin.md
deleted file mode 100644
index 3c2d3f18a23..00000000000
--- a/docs/book/src/plugins/go-v2-plugin.md
+++ /dev/null
@@ -1,75 +0,0 @@
-# [Deprecated] go/v2 (go.kubebuilder.io/v2 - "Kubebuilder 2.x" layout)
-
-
-
-The `go/v2` plugin has the purpose to scaffold Golang projects to help users
-to build projects with [controllers][controller-runtime] and keep the backwards compatibility
-with the default scaffold made using Kubebuilder CLI `2.x.z` releases.
-
-
-
-## When should I use this plugin ?
-
-Only if you are looking to scaffold a project with the legacy layout. Otherwise, it is recommended you to use the default Golang version plugin.
-
-
-
-## How to use it ?
-
-To initialize a Golang project using the legacy layout and with this plugin run, e.g.:
-
-```sh
-kubebuilder init --domain tutorial.kubebuilder.io --repo tutorial.kubebuilder.io/project --plugins=go/v2
-```
-
-
-## Subcommands supported by the plugin ?
-
-- Init - `kubebuilder init [OPTIONS]`
-- Edit - `kubebuilder edit [OPTIONS]`
-- Create API - `kubebuilder create api [OPTIONS]`
-- Create Webhook - `kubebuilder create webhook [OPTIONS]`
-
-## Further resources
-
-- Check the code implementation of the [go/v2 plugin][v2-plugin].
-
-[controller-runtime]: https://github.com/kubernetes-sigs/controller-runtime
-[testdata]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata
-[v2-plugin]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/pkg/plugins/golang/v2
\ No newline at end of file
diff --git a/docs/book/src/plugins/go-v3-plugin.md b/docs/book/src/plugins/go-v3-plugin.md
deleted file mode 100644
index af41662389f..00000000000
--- a/docs/book/src/plugins/go-v3-plugin.md
+++ /dev/null
@@ -1,70 +0,0 @@
-# [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].
-
-It basically scaffolds all the boilerplate code required to create and design controllers. Note that by following the [quickstart][quickstart] you will be using this plugin.
-
-
-
-## When to use it ?
-
-If you are looking to scaffold Golang projects to develop projects using [controllers][controller-runtime]
-
-## How to use it ?
-
-As `go/v3` is the default plugin there is no need to explicitly mention to Kubebuilder to use this plugin.
-
-To create a new project with the `go/v3` plugin the following command can be used:
-
-```sh
-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.
-
-
-
-## Subcommands supported by the plugin
-
-- Init - `kubebuilder init [OPTIONS]`
-- Edit - `kubebuilder edit [OPTIONS]`
-- Create API - `kubebuilder create api [OPTIONS]`
-- Create Webhook - `kubebuilder create webhook [OPTIONS]`
-
-## Further resources
-
-- To check how plugins are composited by looking at this definition in the [main.go][plugins-main].
-- Check the code implementation of the [base Golang plugin `base.go.kubebuilder.io/v3`][v3-plugin].
-- Check the code implementation of the [Kustomize/v1 plugin][kustomize-plugin].
-- Check [controller-runtime][controller-runtime] to know more about controllers.
-
-[controller-runtime]: https://github.com/kubernetes-sigs/controller-runtime
-[quickstart]: ../quick-start.md
-[testdata]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/testdata
-[plugins-main]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/cmd/main.go
-[v3-plugin]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/pkg/plugins/golang/v3
-[kustomize-plugin]: https://github.com/kubernetes-sigs/kubebuilder/tree/master/pkg/plugins/common/kustomize/v1
\ No newline at end of file
diff --git a/docs/book/src/plugins/kustomize-v1.md b/docs/book/src/plugins/kustomize-v1.md
deleted file mode 100644
index 6a1ab54bc8e..00000000000
--- a/docs/book/src/plugins/kustomize-v1.md
+++ /dev/null
@@ -1,124 +0,0 @@
-# [Deprecated] Kustomize (kustomize/v1)
-
-
-
-The kustomize plugin allows you to scaffold all kustomize manifests used to work with the language plugins such as `go/v2` and `go/v3`.
-By using the kustomize plugin, you can create your own language plugins and ensure that you will have the same configurations
-and features provided by it.
-
-
-
-Note that projects such as [Operator-sdk][sdk] consume the Kubebuilder project as a lib and provide options to work with other languages
-like Ansible and Helm. The kustomize plugin allows them to easily keep a maintained configuration and ensure that all languages have
-the same configuration. It is also helpful if you are looking to provide nice plugins which will perform changes on top of
-what is scaffolded by default. With this approach we do not need to keep manually updating this configuration in all possible language plugins
-which uses the same and we are also
-able to create "helper" plugins which can work with many projects and languages.
-
-
-
-
-## When to use it ?
-
-If you are looking to scaffold the kustomize configuration manifests for your own language plugin
-
-## How to use it ?
-
-If you are looking to define that your language plugin should use kustomize use the [Bundle Plugin][bundle]
-to specify that your language plugin is a composition with your plugin responsible for scaffold
-all that is language specific and kustomize for its configuration, see:
-
-```go
- // Bundle plugin which built the golang projects scaffold by Kubebuilder go/v3
- // 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(plugin.WithName(golang.DefaultNameQualifier),
- plugin.WithVersion(plugin.Version{Number: 3}),
- plugin.WithPlugins(kustomizecommonv1.Plugin{}, golangv3.Plugin{}), // scaffold the config/ directory and all kustomize files
- // Scaffold the Golang files and all that specific for the language e.g. go.mod, apis, controllers
- )
-```
-
-Also, with Kubebuilder, you can use kustomize alone via:
-
-```sh
-kubebuilder init --plugins=kustomize/v1
-$ ls -la
-total 24
-drwxr-xr-x 6 camilamacedo86 staff 192 31 Mar 09:56 .
-drwxr-xr-x 11 camilamacedo86 staff 352 29 Mar 21:23 ..
--rw------- 1 camilamacedo86 staff 129 26 Mar 12:01 .dockerignore
--rw------- 1 camilamacedo86 staff 367 26 Mar 12:01 .gitignore
--rw------- 1 camilamacedo86 staff 94 31 Mar 09:56 PROJECT
-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 a composition (kubebuilder init --plugins=go/v3)
-kubebuilder init --plugins=kustomize/v1,base.go.kubebuilder.io/v3 --domain example.org --repo example.org/guestbook-operator
-```
-
-## Subcommands
-
-The kustomize plugin implements the following subcommands:
-
-* init (`$ kubebuilder init [OPTIONS]`)
-* create api (`$ kubebuilder create api [OPTIONS]`)
-* create webhook (`$ kubebuilder create api [OPTIONS]`)
-
-
-
-## Affected files
-
-The following scaffolds will be created or updated by this plugin:
-
-* `config/*`
-
-## Further resources
-
-* Check the kustomize [plugin implementation](https://github.com/kubernetes-sigs/kubebuilder/tree/master/pkg/plugins/common/kustomize)
-* Check the [kustomize documentation][kustomize-docs]
-* Check the [kustomize repository][kustomize-github]
-
-[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/v1/scaffolds/api.go#L72-L84
-[kustomize-docs]: https://kustomize.io/
-[kustomize-github]: https://github.com/kubernetes-sigs/kustomize
\ No newline at end of file
diff --git a/docs/book/src/plugins/to-scaffold-project.md b/docs/book/src/plugins/to-scaffold-project.md
index c2c9235e2b5..c91217191d6 100644
--- a/docs/book/src/plugins/to-scaffold-project.md
+++ b/docs/book/src/plugins/to-scaffold-project.md
@@ -2,8 +2,6 @@
The following plugins are useful to scaffold the whole project with the tool.
-| Plugin | Key | Description |
-| ---------------------------------------------------------------------------------- | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| [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 Silicon 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. |
+| Plugin | Key | Description |
+|------------------------------------------------------------------------------------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| [go.kubebuilder.io/v4 - (Default scaffold with Kubebuilder init)](go-v4-plugin.md) | `go/v4` | Scaffold composite by `base.go.kubebuilder.io/v4` and [kustomize.common.kubebuilder.io/v2](kustomize-v2.md). Responsible for scaffolding Golang projects and its configurations. |
diff --git a/pkg/cli/cli_test.go b/pkg/cli/cli_test.go
index ae5f8c7023f..f92db2043d2 100644
--- a/pkg/cli/cli_test.go
+++ b/pkg/cli/cli_test.go
@@ -28,12 +28,11 @@ import (
"github.com/spf13/cobra"
"sigs.k8s.io/kubebuilder/v3/pkg/config"
- 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"
- goPluginV3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
+ goPluginV4 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v4"
)
func makeMockPluginsFor(projectVersion config.Version, pluginKeys ...string) []plugin.Plugin {
@@ -142,22 +141,9 @@ plugins:
// TODO: test CLI.getInfoFromConfigFile using a mock filesystem
Context("getInfoFromConfig", func() {
- When("not having layout field", func() {
- It("should succeed", func() {
- pluginChain := []string{"go.kubebuilder.io/v2"}
-
- projectConfig := cfgv2.New()
-
- Expect(c.getInfoFromConfig(projectConfig)).To(Succeed())
- Expect(c.pluginKeys).To(Equal(pluginChain))
- Expect(c.projectVersion.Compare(projectConfig.GetVersion())).To(Equal(0))
- })
- })
-
When("having a single plugin in the layout field", func() {
It("should succeed", func() {
- pluginChain := []string{"go.kubebuilder.io/v2"}
-
+ pluginChain := []string{"go.kubebuilder.io/v4"}
projectConfig := cfgv3.New()
Expect(projectConfig.SetPluginChain(pluginChain)).To(Succeed())
@@ -458,8 +444,8 @@ plugins:
It("should create a valid CLI", func() {
const version = "version string"
c, err = New(
- WithPlugins(&goPluginV3.Plugin{}),
- WithDefaultPlugins(projectVersion, &goPluginV3.Plugin{}),
+ WithPlugins(&goPluginV4.Plugin{}),
+ WithDefaultPlugins(projectVersion, &goPluginV4.Plugin{}),
WithVersion(version),
)
Expect(err).NotTo(HaveOccurred())
@@ -489,8 +475,8 @@ plugins:
When("enabling completion", func() {
It("should create a valid CLI", func() {
c, err = New(
- WithPlugins(&goPluginV3.Plugin{}),
- WithDefaultPlugins(projectVersion, &goPluginV3.Plugin{}),
+ WithPlugins(&goPluginV4.Plugin{}),
+ WithDefaultPlugins(projectVersion, &goPluginV4.Plugin{}),
WithCompletion(),
)
Expect(err).NotTo(HaveOccurred())
@@ -535,8 +521,8 @@ plugins:
It("should create a valid CLI for non-conflicting ones", func() {
extraCommand := &cobra.Command{Use: "extra"}
c, err = New(
- WithPlugins(&goPluginV3.Plugin{}),
- WithDefaultPlugins(projectVersion, &goPluginV3.Plugin{}),
+ WithPlugins(&goPluginV4.Plugin{}),
+ WithDefaultPlugins(projectVersion, &goPluginV4.Plugin{}),
WithExtraCommands(extraCommand),
)
Expect(err).NotTo(HaveOccurred())
@@ -546,8 +532,8 @@ plugins:
It("should return an error for conflicting ones", func() {
extraCommand := &cobra.Command{Use: "init"}
c, err = New(
- WithPlugins(&goPluginV3.Plugin{}),
- WithDefaultPlugins(projectVersion, &goPluginV3.Plugin{}),
+ WithPlugins(&goPluginV4.Plugin{}),
+ WithDefaultPlugins(projectVersion, &goPluginV4.Plugin{}),
WithExtraCommands(extraCommand),
)
Expect(err).To(HaveOccurred())
@@ -558,8 +544,8 @@ plugins:
It("should create a valid CLI for non-conflicting ones", func() {
extraAlphaCommand := &cobra.Command{Use: "extra"}
c, err = New(
- WithPlugins(&goPluginV3.Plugin{}),
- WithDefaultPlugins(projectVersion, &goPluginV3.Plugin{}),
+ WithPlugins(&goPluginV4.Plugin{}),
+ WithDefaultPlugins(projectVersion, &goPluginV4.Plugin{}),
WithExtraAlphaCommands(extraAlphaCommand),
)
Expect(err).NotTo(HaveOccurred())
@@ -577,8 +563,8 @@ plugins:
It("should return an error for conflicting ones", func() {
extraAlphaCommand := &cobra.Command{Use: "extra"}
_, err = New(
- WithPlugins(&goPluginV3.Plugin{}),
- WithDefaultPlugins(projectVersion, &goPluginV3.Plugin{}),
+ WithPlugins(&goPluginV4.Plugin{}),
+ WithDefaultPlugins(projectVersion, &goPluginV4.Plugin{}),
WithExtraAlphaCommands(extraAlphaCommand, extraAlphaCommand),
)
Expect(err).To(HaveOccurred())
diff --git a/pkg/cli/options.go b/pkg/cli/options.go
index a720239eda3..54222ea7b22 100644
--- a/pkg/cli/options.go
+++ b/pkg/cli/options.go
@@ -30,7 +30,6 @@ import (
"github.com/spf13/cobra"
"sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/external"
@@ -294,7 +293,7 @@ func DiscoverExternalPlugins(fs afero.Fs) (ps []plugin.Plugin, err error) {
ep := external.Plugin{
PName: pluginInfo.Name(),
Path: filepath.Join(pluginsRoot, pluginInfo.Name(), version.Name(), pluginFile.Name()),
- PSupportedProjectVersions: []config.Version{cfgv2.Version, cfgv3.Version},
+ PSupportedProjectVersions: []config.Version{cfgv3.Version},
Args: parseExternalPluginArgs(),
}
diff --git a/pkg/config/store/yaml/store_test.go b/pkg/config/store/yaml/store_test.go
index d4afb6dad8d..2f3cb6abaaf 100644
--- a/pkg/config/store/yaml/store_test.go
+++ b/pkg/config/store/yaml/store_test.go
@@ -21,13 +21,14 @@ import (
"os"
"testing"
+ cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
+
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/spf13/afero"
"sigs.k8s.io/kubebuilder/v3/pkg/config"
"sigs.k8s.io/kubebuilder/v3/pkg/config/store"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
)
@@ -49,7 +50,7 @@ var _ = Describe("New", func() {
var _ = Describe("yamlStore", func() {
const (
- v2File = `version: "2"
+ v3File = `version: "3"
`
unversionedFile = `version:
`
@@ -71,14 +72,6 @@ layout: ""
})
Context("New", func() {
- It("should initialize a new Config backend for the provided version", func() {
- Expect(s.New(cfgv2.Version)).To(Succeed())
- Expect(s.fs).NotTo(BeNil())
- Expect(s.mustNotExist).To(BeTrue())
- Expect(s.Config()).NotTo(BeNil())
- Expect(s.Config().GetVersion().Compare(cfgv2.Version)).To(Equal(0))
- })
-
It("should fail for an unregistered config version", func() {
Expect(s.New(config.Version{})).NotTo(Succeed())
})
@@ -86,13 +79,13 @@ layout: ""
Context("Load", func() {
It("should load the Config from an existing file at the default path", func() {
- Expect(afero.WriteFile(s.fs, DefaultPath, []byte(commentStr+v2File), os.ModePerm)).To(Succeed())
+ Expect(afero.WriteFile(s.fs, DefaultPath, []byte(commentStr+v3File), os.ModePerm)).To(Succeed())
Expect(s.Load()).To(Succeed())
Expect(s.fs).NotTo(BeNil())
Expect(s.mustNotExist).To(BeFalse())
Expect(s.Config()).NotTo(BeNil())
- Expect(s.Config().GetVersion().Compare(cfgv2.Version)).To(Equal(0))
+ Expect(s.Config().GetVersion().Compare(cfgv3.Version)).To(Equal(0))
})
It("should fail if no file exists at the default path", func() {
@@ -128,13 +121,13 @@ layout: ""
Context("LoadFrom", func() {
It("should load the Config from an existing file from the specified path", func() {
- Expect(afero.WriteFile(s.fs, path, []byte(commentStr+v2File), os.ModePerm)).To(Succeed())
+ Expect(afero.WriteFile(s.fs, path, []byte(commentStr+v3File), os.ModePerm)).To(Succeed())
Expect(s.LoadFrom(path)).To(Succeed())
Expect(s.fs).NotTo(BeNil())
Expect(s.mustNotExist).To(BeFalse())
Expect(s.Config()).NotTo(BeNil())
- Expect(s.Config().GetVersion().Compare(cfgv2.Version)).To(Equal(0))
+ Expect(s.Config().GetVersion().Compare(cfgv3.Version)).To(Equal(0))
})
It("should fail if no file exists at the specified path", func() {
@@ -170,22 +163,22 @@ layout: ""
Context("Save", func() {
It("should succeed for a valid config", func() {
- s.cfg = cfgv2.New()
+ s.cfg = cfgv3.New()
Expect(s.Save()).To(Succeed())
cfgBytes, err := afero.ReadFile(s.fs, DefaultPath)
Expect(err).NotTo(HaveOccurred())
- Expect(string(cfgBytes)).To(Equal(commentStr + v2File))
+ Expect(string(cfgBytes)).To(Equal(commentStr + v3File))
})
It("should succeed for a valid config that must not exist", func() {
- s.cfg = cfgv2.New()
+ s.cfg = cfgv3.New()
s.mustNotExist = true
Expect(s.Save()).To(Succeed())
cfgBytes, err := afero.ReadFile(s.fs, DefaultPath)
Expect(err).NotTo(HaveOccurred())
- Expect(string(cfgBytes)).To(Equal(commentStr + v2File))
+ Expect(string(cfgBytes)).To(Equal(commentStr + v3File))
})
It("should fail for an empty config", func() {
@@ -195,9 +188,9 @@ layout: ""
})
It("should fail for a pre-existent file that must not exist", func() {
- s.cfg = cfgv2.New()
+ s.cfg = cfgv3.New()
s.mustNotExist = true
- Expect(afero.WriteFile(s.fs, DefaultPath, []byte(v2File), os.ModePerm)).To(Succeed())
+ Expect(afero.WriteFile(s.fs, DefaultPath, []byte(v3File), os.ModePerm)).To(Succeed())
err := s.Save()
Expect(err).To(HaveOccurred())
@@ -207,22 +200,22 @@ layout: ""
Context("SaveTo", func() {
It("should success for valid configs", func() {
- s.cfg = cfgv2.New()
+ s.cfg = cfgv3.New()
Expect(s.SaveTo(path)).To(Succeed())
cfgBytes, err := afero.ReadFile(s.fs, path)
Expect(err).NotTo(HaveOccurred())
- Expect(string(cfgBytes)).To(Equal(commentStr + v2File))
+ Expect(string(cfgBytes)).To(Equal(commentStr + v3File))
})
It("should succeed for a valid config that must not exist", func() {
- s.cfg = cfgv2.New()
+ s.cfg = cfgv3.New()
s.mustNotExist = true
Expect(s.SaveTo(path)).To(Succeed())
cfgBytes, err := afero.ReadFile(s.fs, path)
Expect(err).NotTo(HaveOccurred())
- Expect(string(cfgBytes)).To(Equal(commentStr + v2File))
+ Expect(string(cfgBytes)).To(Equal(commentStr + v3File))
})
It("should fail for an empty config", func() {
@@ -232,9 +225,9 @@ layout: ""
})
It("should fail for a pre-existent file that must not exist", func() {
- s.cfg = cfgv2.New()
+ s.cfg = cfgv3.New()
s.mustNotExist = true
- Expect(afero.WriteFile(s.fs, path, []byte(v2File), os.ModePerm)).To(Succeed())
+ Expect(afero.WriteFile(s.fs, path, []byte(v3File), os.ModePerm)).To(Succeed())
err := s.SaveTo(path)
Expect(err).To(HaveOccurred())
diff --git a/pkg/plugins/golang/declarative/v1/api.go b/pkg/plugins/golang/declarative/v1/api.go
index c3c99eade4d..f74c0ac3064 100644
--- a/pkg/plugins/golang/declarative/v1/api.go
+++ b/pkg/plugins/golang/declarative/v1/api.go
@@ -28,14 +28,10 @@ import (
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/declarative/v1/scaffolds"
- goPluginV2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2"
- goPluginV3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
)
const (
// kbDeclarativePattern is the sigs.k8s.io/kubebuilder-declarative-pattern version
- kbDeclarativePatternForV2 = "v0.0.0-20200522144838-848d48e5b073"
- kbDeclarativePatternForV3 = "18dbaf5fcd851e6adc3f2f8a8facb669a1420797"
kbDeclarativePatternForV4 = "9a410556b95de526e12acfe0d6f56fd35c0b0135"
)
@@ -130,16 +126,6 @@ func (p *createAPISubcommand) Scaffold(fs machinery.Filesystem) error {
// Just pin an old value for go/v2. It shows fine for now. However, we should improve/change it
// if we see that more rules based on the plugins version are required.
kbDeclarativePattern := kbDeclarativePatternForV4
- for _, pluginKey := range p.config.GetPluginChain() {
- if pluginKey == plugin.KeyFor(goPluginV2.Plugin{}) {
- kbDeclarativePattern = kbDeclarativePatternForV2
- break
- }
- if pluginKey == plugin.KeyFor(goPluginV3.Plugin{}) {
- kbDeclarativePattern = kbDeclarativePatternForV3
- break
- }
- }
err = util.RunCmd("Get declarative pattern", "go", "get",
"sigs.k8s.io/kubebuilder-declarative-pattern@"+kbDeclarativePattern)
if err != nil {
diff --git a/pkg/plugins/golang/declarative/v1/plugin.go b/pkg/plugins/golang/declarative/v1/plugin.go
index bb553a3aaaa..323ffae0cb7 100644
--- a/pkg/plugins/golang/declarative/v1/plugin.go
+++ b/pkg/plugins/golang/declarative/v1/plugin.go
@@ -27,7 +27,6 @@ package v1
import (
"sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
@@ -38,7 +37,7 @@ const pluginName = "declarative." + golang.DefaultNameQualifier
var (
pluginVersion = plugin.Version{Number: 1}
- supportedProjectVersions = []config.Version{cfgv2.Version, cfgv3.Version}
+ supportedProjectVersions = []config.Version{cfgv3.Version}
pluginKey = plugin.KeyFor(Plugin{})
)
diff --git a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go
index 16dbe43f366..ca4fc870f91 100644
--- a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go
+++ b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/api.go
@@ -27,15 +27,12 @@ import (
"sigs.k8s.io/kubebuilder/v3/pkg/config"
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
"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/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"
- golangv3scaffolds "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds"
golangv4scaffolds "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v4/scaffolds"
)
@@ -79,10 +76,7 @@ func (s *apiScaffolder) InjectFS(fs machinery.Filesystem) {
func (s *apiScaffolder) Scaffold() error {
log.Println("Writing scaffold for you to edit...")
- //nolint: staticcheck
- isGoV3 := plugin.IsLegacyLayout(s.config)
-
- if err := s.scaffoldCreateAPIFromPlugins(isGoV3); err != nil {
+ if err := s.scaffoldCreateAPI(); err != nil {
return err
}
@@ -100,7 +94,7 @@ func (s *apiScaffolder) Scaffold() error {
)
if err := scaffold.Execute(
- &api.Types{Port: s.port, IsLegacyLayout: isGoV3},
+ &api.Types{Port: s.port},
); err != nil {
return fmt.Errorf("error updating APIs: %v", err)
}
@@ -112,12 +106,7 @@ func (s *apiScaffolder) Scaffold() error {
}
controller := &controllers.Controller{
- ControllerRuntimeVersion: golangv3scaffolds.ControllerRuntimeVersion,
- IsLegacyLayout: isGoV3,
- }
-
- if !isGoV3 {
- controller.ControllerRuntimeVersion = golangv4scaffolds.ControllerRuntimeVersion
+ ControllerRuntimeVersion: golangv4scaffolds.ControllerRuntimeVersion,
}
if err := scaffold.Execute(
@@ -131,15 +120,12 @@ func (s *apiScaffolder) Scaffold() error {
}
defaultMainPath := "cmd/main.go"
- if isGoV3 {
- defaultMainPath = "main.go"
- }
if err := s.updateMainByAddingEventRecorder(defaultMainPath); err != nil {
return fmt.Errorf("error updating main.go: %v", err)
}
if err := scaffold.Execute(
- &controllers.ControllerTest{Port: s.port, IsLegacyLayout: isGoV3},
+ &controllers.ControllerTest{Port: s.port},
); err != nil {
return fmt.Errorf("error creating controller/**_controller_test.go: %v", err)
}
@@ -172,14 +158,14 @@ func (s *apiScaffolder) addEnvVarIntoManager() error {
return nil
}
-// scaffoldCreateAPIFromPlugins will reuse the code from the kustomize and base golang
+// scaffoldCreateAPI will reuse the code from the kustomize and base golang
// plugins to do the default scaffolds which an API is created
-func (s *apiScaffolder) scaffoldCreateAPIFromPlugins(isLegacyLayout bool) error {
- if err := s.scaffoldCreateAPIFromGolang(isLegacyLayout); err != nil {
+func (s *apiScaffolder) scaffoldCreateAPI() error {
+ if err := s.scaffoldCreateAPIFromGolang(); err != nil {
return fmt.Errorf("error scaffolding golang files for the new API: %v", err)
}
- if err := s.scaffoldCreateAPIFromKustomize(isLegacyLayout); err != nil {
+ if err := s.scaffoldCreateAPIFromKustomize(); err != nil {
return fmt.Errorf("error scaffolding kustomize manifests for the new API: %v", err)
}
return nil
@@ -281,25 +267,12 @@ func (s *apiScaffolder) updateControllerCode(controller controllers.Controller)
return nil
}
-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 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 {
- kustomizeScaffolder = kustomizev1scaffolds.NewAPIScaffolder(
- s.config,
- s.resource,
- true,
- )
- } else {
- kustomizeScaffolder = kustomizev2scaffolds.NewAPIScaffolder(
- s.config,
- s.resource,
- true,
- )
- }
+func (s *apiScaffolder) scaffoldCreateAPIFromKustomize() error {
+ kustomizeScaffolder := kustomizev2scaffolds.NewAPIScaffolder(
+ s.config,
+ s.resource,
+ true,
+ )
kustomizeScaffolder.InjectFS(s.fs)
@@ -310,16 +283,7 @@ func (s *apiScaffolder) scaffoldCreateAPIFromKustomize(isLegacyLayout bool) erro
return nil
}
-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 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)
- golangV3Scaffolder.InjectFS(s.fs)
- return golangV3Scaffolder.Scaffold()
- }
+func (s *apiScaffolder) scaffoldCreateAPIFromGolang() error {
golangV4Scaffolder := golangv4scaffolds.NewAPIScaffolder(s.config,
s.resource, true)
golangV4Scaffolder.InjectFS(s.fs)
diff --git a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller.go b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller.go
index 83137e45af9..7f927384fdd 100644
--- a/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller.go
+++ b/pkg/plugins/golang/deploy-image/v1alpha1/scaffolds/internal/templates/controllers/controller.go
@@ -37,36 +37,22 @@ type Controller struct {
ControllerRuntimeVersion string
- // IsLegacyLayout is added to ensure backwards compatibility and should
- // be removed when we remove the go/v3 plugin
- IsLegacyLayout bool
- PackageName string
+ PackageName string
}
// SetTemplateDefaults implements file.Template
func (f *Controller) SetTemplateDefaults() error {
if f.Path == "" {
if f.MultiGroup && f.Resource.Group != "" {
- if f.IsLegacyLayout {
- f.Path = filepath.Join("controllers", "%[group]", "%[kind]_controller.go")
- } else {
- f.Path = filepath.Join("internal", "controller", "%[group]", "%[kind]_controller.go")
- }
+ f.Path = filepath.Join("internal", "controller", "%[group]", "%[kind]_controller.go")
} else {
- if f.IsLegacyLayout {
- f.Path = filepath.Join("controllers", "%[kind]_controller.go")
- } else {
- f.Path = filepath.Join("internal", "controller", "%[kind]_controller.go")
- }
+ f.Path = filepath.Join("internal", "controller", "%[kind]_controller.go")
}
}
f.Path = f.Resource.Replacer().Replace(f.Path)
log.Println(f.Path)
f.PackageName = "controller"
- if f.IsLegacyLayout {
- f.PackageName = "controllers"
- }
log.Println("creating import for %", f.Resource.Path)
f.TemplateBody = controllerTemplate
diff --git a/pkg/plugins/golang/options.go b/pkg/plugins/golang/options.go
index 33665f747e6..2227f4de3ee 100644
--- a/pkg/plugins/golang/options.go
+++ b/pkg/plugins/golang/options.go
@@ -20,7 +20,6 @@ import (
"path"
"sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
)
@@ -128,12 +127,8 @@ func (opts Options) UpdateResource(res *resource.Resource, c config.Config) {
// TODO: need to support '--resource-pkg-path' flag for specifying resourcePath
if !opts.DoAPI {
var alreadyHasAPI bool
- if c.GetVersion().Compare(cfgv2.Version) == 0 {
- alreadyHasAPI = c.HasResource(res.GVK)
- } else {
- loadedRes, err := c.GetResource(res.GVK)
- alreadyHasAPI = err == nil && loadedRes.HasAPI()
- }
+ loadedRes, err := c.GetResource(res.GVK)
+ alreadyHasAPI = err == nil && loadedRes.HasAPI()
if !alreadyHasAPI {
if domain, found := coreGroups[res.Group]; found {
res.Domain = domain
diff --git a/pkg/plugins/golang/options_test.go b/pkg/plugins/golang/options_test.go
index 19301100937..b1fb6701f8b 100644
--- a/pkg/plugins/golang/options_test.go
+++ b/pkg/plugins/golang/options_test.go
@@ -23,7 +23,6 @@ import (
. "github.com/onsi/gomega"
"sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
)
@@ -156,7 +155,7 @@ var _ = Describe("Options", func() {
// the `HasAPI` method of the resource obtained with `GetResource` will always return false.
// Instead, the existence of a resource in the list means the API was scaffolded.
func(group, qualified string) {
- cfg = cfgv2.New()
+ cfg = cfgv3.New()
_ = cfg.SetRepository("test")
options := Options{}
diff --git a/pkg/plugins/golang/v2/api.go b/pkg/plugins/golang/v2/api.go
deleted file mode 100644
index 88ccd3d188b..00000000000
--- a/pkg/plugins/golang/v2/api.go
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated
-package v2
-
-import (
- "bufio"
- "errors"
- "fmt"
- "os"
-
- "github.com/spf13/pflag"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
- goPlugin "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds"
-)
-
-var _ plugin.CreateAPISubcommand = &createAPISubcommand{}
-
-type createAPISubcommand struct {
- config config.Config
-
- options *goPlugin.Options
-
- resource *resource.Resource
-
- // Check if we have to scaffold resource and/or controller
- resourceFlag *pflag.Flag
- controllerFlag *pflag.Flag
-
- // force indicates that the resource should be created even if it already exists
- force bool
-
- // runMake indicates whether to run make or not after scaffolding APIs
- runMake bool
-}
-
-func (p *createAPISubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
- subcmdMeta.Description = `Scaffold a Kubernetes API by writing a Resource definition and/or a Controller.
-
-If information about whether the resource and controller should be scaffolded
-was not explicitly provided, it will prompt the user if they should be.
-
-After the scaffold is written, the dependencies will be updated and
-make generate will be run.
-`
- subcmdMeta.Examples = fmt.Sprintf(` # Create a frigates API with Group: ship, Version: v1beta1 and Kind: Frigate
- %[1]s create api --group ship --version v1beta1 --kind Frigate
-
- # Edit the API Scheme
- nano api/v1beta1/frigate_types.go
-
- # Edit the Controller
- nano controllers/frigate/frigate_controller.go
-
- # Edit the Controller Test
- nano controllers/frigate/frigate_controller_test.go
-
- # Generate the manifests
- make manifests
-
- # Install CRDs into the Kubernetes cluster using kubectl apply
- make install
-
- # Regenerate code and run against the Kubernetes cluster configured by ~/.kube/config
- make run
-`, cliMeta.CommandName)
-}
-
-func (p *createAPISubcommand) BindFlags(fs *pflag.FlagSet) {
- fs.BoolVar(&p.runMake, "make", true, "if true, run `make generate` after generating files")
-
- fs.BoolVar(&p.force, "force", false,
- "attempt to create resource even if it already exists")
-
- p.options = &goPlugin.Options{CRDVersion: "v1beta1"}
- // p.options.Plural can be set to specify an irregular plural form
-
- fs.BoolVar(&p.options.DoAPI, "resource", true,
- "if set, generate the resource without prompting the user")
- p.resourceFlag = fs.Lookup("resource")
- fs.BoolVar(&p.options.Namespaced, "namespaced", true, "resource is namespaced")
-
- fs.BoolVar(&p.options.DoController, "controller", true,
- "if set, generate the controller without prompting the user")
- p.controllerFlag = fs.Lookup("controller")
-}
-
-func (p *createAPISubcommand) InjectConfig(c config.Config) error {
- p.config = c
-
- return nil
-}
-
-func (p *createAPISubcommand) InjectResource(res *resource.Resource) error {
- p.resource = res
-
- if p.resource.Group == "" {
- return fmt.Errorf("group cannot be empty")
- }
-
- // Ask for API and Controller if not specified
- reader := bufio.NewReader(os.Stdin)
- if !p.resourceFlag.Changed {
- fmt.Println("Create Resource [y/n]")
- p.options.DoAPI = util.YesNo(reader)
- }
- if !p.controllerFlag.Changed {
- fmt.Println("Create Controller [y/n]")
- p.options.DoController = util.YesNo(reader)
- }
-
- p.options.UpdateResource(p.resource, p.config)
-
- if err := p.resource.Validate(); err != nil {
- return err
- }
-
- // In case we want to scaffold a resource API we need to do some checks
- if p.options.DoAPI {
- // Check that resource doesn't have the API scaffolded or flag force was set
- if res, err := p.config.GetResource(p.resource.GVK); err == nil && res.HasAPI() && !p.force {
- return errors.New("API resource already exists")
- }
-
- // Check that the provided group can be added to the project
- if !p.config.IsMultiGroup() && p.config.ResourcesLength() != 0 && !p.config.HasGroup(p.resource.Group) {
- return fmt.Errorf("multiple groups are not allowed by default, to enable multi-group visit %s",
- "https://kubebuilder.io/migration/multi-group.html")
- }
- }
-
- return nil
-}
-
-func (p *createAPISubcommand) Scaffold(fs machinery.Filesystem) error {
- scaffolder := scaffolds.NewAPIScaffolder(p.config, *p.resource, p.force)
- scaffolder.InjectFS(fs)
- return scaffolder.Scaffold()
-}
-
-func (p *createAPISubcommand) PostScaffold() error {
- err := util.RunCmd("Update dependencies", "go", "mod", "tidy")
- if err != nil {
- return err
- }
-
- if p.runMake && p.resource.HasAPI() {
- err = util.RunCmd("Running make", "make", "generate")
- if err != nil {
- return err
- }
- fmt.Print("Next: implement your new API and generate the manifests (e.g. CRDs,CRs) with:\n$ make manifests \n")
- }
-
- return nil
-}
diff --git a/pkg/plugins/golang/v2/edit.go b/pkg/plugins/golang/v2/edit.go
deleted file mode 100644
index d8e04f39443..00000000000
--- a/pkg/plugins/golang/v2/edit.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated
-package v2
-
-import (
- "fmt"
-
- "github.com/spf13/pflag"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds"
-)
-
-var _ plugin.EditSubcommand = &editSubcommand{}
-
-type editSubcommand struct {
- config config.Config
-
- multigroup bool
-}
-
-func (p *editSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
- subcmdMeta.Description = `This command will edit the project configuration.
-Features supported:
- - Toggle between single or multi group projects.
-`
- subcmdMeta.Examples = fmt.Sprintf(` # Enable the multigroup layout
- %[1]s edit --multigroup
-
- # Disable the multigroup layout
- %[1]s edit --multigroup=false
-`, cliMeta.CommandName)
-}
-
-func (p *editSubcommand) BindFlags(fs *pflag.FlagSet) {
- fs.BoolVar(&p.multigroup, "multigroup", false, "enable or disable multigroup layout")
-}
-
-func (p *editSubcommand) InjectConfig(c config.Config) error {
- p.config = c
-
- return nil
-}
-
-func (p *editSubcommand) Scaffold(fs machinery.Filesystem) error {
- scaffolder := scaffolds.NewEditScaffolder(p.config, p.multigroup)
- scaffolder.InjectFS(fs)
- return scaffolder.Scaffold()
-}
diff --git a/pkg/plugins/golang/v2/init.go b/pkg/plugins/golang/v2/init.go
deleted file mode 100644
index 7d5f0077113..00000000000
--- a/pkg/plugins/golang/v2/init.go
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated
-package v2
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
-
- log "github.com/sirupsen/logrus"
- "github.com/spf13/pflag"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
- "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/plugin/util"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds"
-)
-
-// Variables and function to check Go version requirements.
-var (
- goVerMin = golang.MustParse("go1.13")
- goVerMax = golang.MustParse("go2.0alpha1")
-)
-
-var _ plugin.InitSubcommand = &initSubcommand{}
-
-type initSubcommand struct {
- config config.Config
-
- // For help text.
- commandName string
-
- // boilerplate options
- license string
- owner string
-
- // config options
- domain string
- repo string
- name string
-
- // flags
- fetchDeps bool
- skipGoVersionCheck bool
-}
-
-func (p *initSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
- p.commandName = cliMeta.CommandName
-
- subcmdMeta.Description = `Initialize a new project including the following files:
- - a "go.mod" with project dependencies
- - a "PROJECT" file that stores project configuration
- - a "Makefile" with several useful make targets for the project
- - several YAML files for project deployment under the "config" directory
- - a "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/v2 --domain example.org --owner "Your name"
-
- # Initialize a new project defining a specific project version
- %[1]s init --plugins go/v2 --project-version 2
-`, cliMeta.CommandName)
-}
-
-func (p *initSubcommand) BindFlags(fs *pflag.FlagSet) {
- fs.BoolVar(&p.skipGoVersionCheck, "skip-go-version-check",
- false, "if specified, skip checking the Go version")
-
- // dependency args
- fs.BoolVar(&p.fetchDeps, "fetch-deps", true, "ensure dependencies are downloaded")
-
- // boilerplate args
- fs.StringVar(&p.license, "license", "apache2",
- "license to use to boilerplate, may be one of 'apache2', 'none'")
- fs.StringVar(&p.owner, "owner", "", "owner to add to the copyright")
-
- // project args
- fs.StringVar(&p.domain, "domain", "my.domain", "domain for groups")
- fs.StringVar(&p.repo, "repo", "", "name to use for go module (e.g., github.com/user/repo), "+
- "defaults to the go package of the current working directory.")
- fs.StringVar(&p.name, "project-name", "", "name of this project")
-}
-
-func (p *initSubcommand) InjectConfig(c config.Config) error {
- p.config = c
-
- if err := p.config.SetDomain(p.domain); err != nil {
- return err
- }
-
- // Try to guess repository if flag is not set.
- if p.repo == "" {
- repoPath, err := golang.FindCurrentRepo()
- if err != nil {
- return fmt.Errorf("error finding current repository: %v", err)
- }
- p.repo = repoPath
- }
- if err := p.config.SetRepository(p.repo); err != nil {
- return err
- }
-
- if p.config.GetVersion().Compare(cfgv2.Version) > 0 {
- // Assign a default project name
- if p.name == "" {
- dir, err := os.Getwd()
- if err != nil {
- return fmt.Errorf("error getting current directory: %v", err)
- }
- p.name = strings.ToLower(filepath.Base(dir))
- }
- // Check if the project name is a valid k8s namespace (DNS 1123 label).
- if err := validation.IsDNS1123Label(p.name); err != nil {
- return fmt.Errorf("project name (%s) is invalid: %v", p.name, err)
- }
- if err := p.config.SetProjectName(p.name); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (p *initSubcommand) PreScaffold(machinery.Filesystem) error {
- // Ensure Go version is in the allowed range if check not turned off.
- if !p.skipGoVersionCheck {
- if err := golang.ValidateGoVersion(goVerMin, goVerMax); err != nil {
- return err
- }
- }
-
- return nil
-}
-
-func (p *initSubcommand) Scaffold(fs machinery.Filesystem) error {
- scaffolder := scaffolds.NewInitScaffolder(p.config, p.license, p.owner)
- scaffolder.InjectFS(fs)
- err := scaffolder.Scaffold()
- if err != nil {
- return err
- }
-
- if !p.fetchDeps {
- log.Println("Skipping fetching dependencies.")
- return nil
- }
-
- // Ensure that we are pinning controller-runtime version
- // xref: https://github.com/kubernetes-sigs/kubebuilder/issues/997
- err = util.RunCmd("Get controller runtime", "go", "get",
- "sigs.k8s.io/controller-runtime@"+scaffolds.ControllerRuntimeVersion)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func (p *initSubcommand) PostScaffold() error {
- err := util.RunCmd("Update dependencies", "go", "mod", "tidy")
- if err != nil {
- return err
- }
-
- fmt.Printf("Next: define a resource with:\n$ %s create api\n", p.commandName)
- return nil
-}
diff --git a/pkg/plugins/golang/v2/plugin.go b/pkg/plugins/golang/v2/plugin.go
deleted file mode 100644
index 894a660dd1f..00000000000
--- a/pkg/plugins/golang/v2/plugin.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated
-package v2
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
- cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins"
-)
-
-const pluginName = "go." + plugins.DefaultNameQualifier
-
-var (
- pluginVersion = plugin.Version{Number: 2}
- supportedProjectVersions = []config.Version{cfgv2.Version, cfgv3.Version}
-)
-
-var _ plugin.Full = Plugin{}
-
-// Plugin implements the plugin.Full interface
-type Plugin struct {
- initSubcommand
- createAPISubcommand
- createWebhookSubcommand
- editSubcommand
-}
-
-// Name returns the name of the plugin
-func (Plugin) Name() string { return pluginName }
-
-// Version returns the version of the plugin
-func (Plugin) Version() plugin.Version { return pluginVersion }
-
-// SupportedProjectVersions returns an array with all project versions supported by the plugin
-func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
-
-// GetInitSubcommand will return the subcommand which is responsible for initializing and common scaffolding
-func (p Plugin) GetInitSubcommand() plugin.InitSubcommand { return &p.initSubcommand }
-
-// GetCreateAPISubcommand will return the subcommand which is responsible for scaffolding apis
-func (p Plugin) GetCreateAPISubcommand() plugin.CreateAPISubcommand { return &p.createAPISubcommand }
-
-// GetCreateWebhookSubcommand will return the subcommand which is responsible for scaffolding webhooks
-func (p Plugin) GetCreateWebhookSubcommand() plugin.CreateWebhookSubcommand {
- return &p.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 and is no longer scaffolded by default since `28 Apr 2021`." +
- "The `go/v2` plugin cannot scaffold projects in which CRDs and/or Webhooks have a `v1` API version." +
- "Be aware that v1beta1 API for CRDs and Webhooks was deprecated on Kubernetes 1.16 and are" +
- "removed as of the Kubernetes 1.22 release. Therefore, since this plugin cannot produce projects that" +
- "work on Kubernetes versions >= 1.22, it is recommended to upgrade your project " +
- "to the latest versions available."
-}
diff --git a/pkg/plugins/golang/v2/scaffolds/api.go b/pkg/plugins/golang/v2/scaffolds/api.go
deleted file mode 100644
index 0b190c62791..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/api.go
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package scaffolds
-
-import (
- "fmt"
-
- log "github.com/sirupsen/logrus"
- "github.com/spf13/afero"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
- "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/golang/v2/scaffolds/internal/templates"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/api"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/patches"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/samples"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/controllers"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/hack"
-)
-
-var _ plugins.Scaffolder = &apiScaffolder{}
-
-// apiScaffolder contains configuration for generating scaffolding for Go type
-// representing the API and controller that implements the behavior for the API.
-type apiScaffolder struct {
- config config.Config
- resource resource.Resource
-
- // fs is the filesystem that will be used by the scaffolder
- fs machinery.Filesystem
-
- // force indicates whether to scaffold controller files even if it exists or not
- force bool
-}
-
-// NewAPIScaffolder returns a new Scaffolder for API/controller creation operations
-func NewAPIScaffolder(config config.Config, res resource.Resource, force bool) plugins.Scaffolder {
- return &apiScaffolder{
- config: config,
- resource: res,
- force: force,
- }
-}
-
-// InjectFS implements cmdutil.Scaffolder
-func (s *apiScaffolder) InjectFS(fs machinery.Filesystem) {
- s.fs = fs
-}
-
-// Scaffold implements cmdutil.Scaffolder
-func (s *apiScaffolder) Scaffold() error {
- log.Println("Writing scaffold for you to edit...")
-
- // Load the boilerplate
- boilerplate, err := afero.ReadFile(s.fs.FS, hack.DefaultBoilerplatePath)
- if err != nil {
- return fmt.Errorf("error scaffolding API/controller: unable to load boilerplate: %w", err)
- }
-
- // Initialize the machinery.Scaffold that will write the files to disk
- scaffold := machinery.NewScaffold(s.fs,
- machinery.WithConfig(s.config),
- machinery.WithBoilerplate(string(boilerplate)),
- machinery.WithResource(&s.resource),
- )
-
- // Keep track of these values before the update
- doAPI := s.resource.HasAPI()
- doController := s.resource.HasController()
-
- // Project version v2 only tracked GVK triplets of each resource.
- // As they were only tracked when the API was scaffolded, the presence of a
- // resource in the config file was used in webhook creation to verify that
- // the API had been scaffolded previously. From project version v3 onwards
- // this information is stored in the API field of the resource, so we can
- // update the resources except for project version 2 when no API was scaffolded.
- if doAPI || s.config.GetVersion().Compare(cfgv2.Version) == 1 {
- if err := s.config.UpdateResource(s.resource); err != nil {
- return fmt.Errorf("error updating resource: %w", err)
- }
- }
-
- if doAPI {
- if err := scaffold.Execute(
- &api.Types{Force: s.force},
- &api.Group{},
- &samples.CRDSample{Force: s.force},
- &rbac.CRDEditorRole{},
- &rbac.CRDViewerRole{},
- &patches.EnableWebhookPatch{},
- &patches.EnableCAInjectionPatch{},
- ); err != nil {
- return fmt.Errorf("error scaffolding APIs: %w", err)
- }
-
- if err := scaffold.Execute(
- &crd.Kustomization{},
- &crd.KustomizeConfig{},
- ); err != nil {
- return fmt.Errorf("error scaffolding kustomization: %v", err)
- }
- }
-
- if doController {
- if err := scaffold.Execute(
- &controllers.SuiteTest{Force: s.force},
- &controllers.Controller{ControllerRuntimeVersion: ControllerRuntimeVersion, Force: s.force},
- ); err != nil {
- return fmt.Errorf("error scaffolding controller: %v", err)
- }
- }
-
- if err := scaffold.Execute(
- &templates.MainUpdater{WireResource: doAPI, WireController: doController},
- ); err != nil {
- return fmt.Errorf("error updating main.go: %v", err)
- }
-
- return nil
-}
diff --git a/pkg/plugins/golang/v2/scaffolds/doc.go b/pkg/plugins/golang/v2/scaffolds/doc.go
deleted file mode 100644
index d969260e58b..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/doc.go
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Package scaffolds contains libraries for scaffolding code to use with controller-runtime
-package scaffolds
diff --git a/pkg/plugins/golang/v2/scaffolds/edit.go b/pkg/plugins/golang/v2/scaffolds/edit.go
deleted file mode 100644
index 0e4f39751c2..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/edit.go
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package scaffolds
-
-import (
- "fmt"
- "strings"
-
- "github.com/spf13/afero"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins"
-)
-
-var _ plugins.Scaffolder = &editScaffolder{}
-
-type editScaffolder struct {
- config config.Config
- multigroup bool
-
- // fs is the filesystem that will be used by the scaffolder
- fs machinery.Filesystem
-}
-
-// NewEditScaffolder returns a new Scaffolder for configuration edit operations
-func NewEditScaffolder(config config.Config, multigroup bool) plugins.Scaffolder {
- return &editScaffolder{
- config: config,
- multigroup: multigroup,
- }
-}
-
-// InjectFS implements cmdutil.Scaffolder
-func (s *editScaffolder) InjectFS(fs machinery.Filesystem) {
- s.fs = fs
-}
-
-// Scaffold implements cmdutil.Scaffolder
-func (s *editScaffolder) Scaffold() error {
- filename := "Dockerfile"
- bs, err := afero.ReadFile(s.fs.FS, filename)
- if err != nil {
- return err
- }
- str := string(bs)
-
- // update dockerfile
- if s.multigroup {
- str, err = ensureExistAndReplace(
- str,
- "COPY api/ api/",
- `COPY apis/ apis/`)
- } else {
- str, err = ensureExistAndReplace(
- str,
- "COPY apis/ apis/",
- `COPY api/ api/`)
- }
-
- // Ignore the error encountered, if the file is already in desired format.
- if err != nil && s.multigroup != s.config.IsMultiGroup() {
- return err
- }
-
- if s.multigroup {
- _ = s.config.SetMultiGroup()
- } else {
- _ = s.config.ClearMultiGroup()
- }
-
- // Check if the str is not empty, because when the file is already in desired format it will return empty string
- // because there is nothing to replace.
- if str != "" {
- // TODO: instead of writing it directly, we should use the scaffolding machinery for consistency
- return afero.WriteFile(s.fs.FS, filename, []byte(str), 0644)
- }
-
- return nil
-}
-
-func ensureExistAndReplace(input, match, replace string) (string, error) {
- if !strings.Contains(input, match) {
- return "", fmt.Errorf("can't find %q", match)
- }
- return strings.Replace(input, match, replace, -1), nil
-}
diff --git a/pkg/plugins/golang/v2/scaffolds/init.go b/pkg/plugins/golang/v2/scaffolds/init.go
deleted file mode 100644
index eb883d9c79f..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/init.go
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package scaffolds
-
-import (
- log "github.com/sirupsen/logrus"
- "github.com/spf13/afero"
-
- "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/golang/v2/scaffolds/internal/templates"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/manager"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/prometheus"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/hack"
-)
-
-const (
- // ControllerRuntimeVersion is the kubernetes-sigs/controller-runtime version to be used in the project
- ControllerRuntimeVersion = "v0.6.4"
- // ControllerToolsVersion is the kubernetes-sigs/controller-tools version to be used in the project
- ControllerToolsVersion = "v0.3.0"
- // KustomizeVersion is the kubernetes-sigs/kustomize version to be used in the project
- // @Deprecate: KustomizeVersion came from the Kustomize plugin since go/v3
- // 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 and can be removed
- // when go/v4 stable is published.
- KustomizeVersion = "v3.5.4"
-
- imageName = "controller:latest"
-)
-
-var _ plugins.Scaffolder = &initScaffolder{}
-
-type initScaffolder struct {
- config config.Config
- boilerplatePath string
- license string
- owner string
-
- // fs is the filesystem that will be used by the scaffolder
- fs machinery.Filesystem
-}
-
-// NewInitScaffolder returns a new Scaffolder for project initialization operations
-func NewInitScaffolder(config config.Config, license, owner string) plugins.Scaffolder {
- return &initScaffolder{
- config: config,
- boilerplatePath: hack.DefaultBoilerplatePath,
- license: license,
- owner: owner,
- }
-}
-
-// InjectFS implements cmdutil.Scaffolder
-func (s *initScaffolder) InjectFS(fs machinery.Filesystem) {
- s.fs = fs
-}
-
-// Scaffold implements cmdutil.Scaffolder
-func (s *initScaffolder) Scaffold() error {
- log.Println("Writing scaffold for you to edit...")
-
- // Initialize the machinery.Scaffold that will write the boilerplate file to disk
- // The boilerplate file needs to be scaffolded as a separate step as it is going to
- // be used by the rest of the files, even those scaffolded in this command call.
- scaffold := machinery.NewScaffold(s.fs,
- machinery.WithConfig(s.config),
- )
-
- bpFile := &hack.Boilerplate{
- License: s.license,
- Owner: s.owner,
- }
- bpFile.Path = s.boilerplatePath
- if err := scaffold.Execute(bpFile); err != nil {
- return err
- }
-
- boilerplate, err := afero.ReadFile(s.fs.FS, s.boilerplatePath)
- if err != nil {
- return err
- }
-
- // Initialize the machinery.Scaffold that will write the files to disk
- scaffold = machinery.NewScaffold(s.fs,
- machinery.WithConfig(s.config),
- machinery.WithBoilerplate(string(boilerplate)),
- )
-
- return scaffold.Execute(
- &rbac.Kustomization{},
- &rbac.AuthProxyRole{},
- &rbac.AuthProxyRoleBinding{},
- &rbac.AuthProxyService{},
- &rbac.AuthProxyClientRole{},
- &rbac.RoleBinding{},
- &rbac.LeaderElectionRole{},
- &rbac.LeaderElectionRoleBinding{},
- &manager.Kustomization{},
- &manager.Config{Image: imageName},
- &templates.Main{},
- &templates.GoMod{ControllerRuntimeVersion: ControllerRuntimeVersion},
- &templates.GitIgnore{},
- &templates.Makefile{
- Image: imageName,
- BoilerplatePath: s.boilerplatePath,
- ControllerToolsVersion: ControllerToolsVersion,
- KustomizeVersion: KustomizeVersion,
- },
- &templates.Dockerfile{},
- &kdefault.Kustomization{},
- &kdefault.ManagerAuthProxyPatch{},
- &kdefault.ManagerWebhookPatch{},
- &kdefault.WebhookCAInjectionPatch{},
- &webhook.Kustomization{},
- &webhook.KustomizeConfig{},
- &webhook.Service{},
- &prometheus.Kustomization{},
- &prometheus.Monitor{},
- &certmanager.Certificate{},
- &certmanager.Kustomization{},
- &certmanager.KustomizeConfig{},
- )
-}
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/api/group.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/api/group.go
deleted file mode 100644
index ba9f21f6acc..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/api/group.go
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package api
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Group{}
-
-// Group scaffolds the file that defines the registration methods for a certain group and version
-type Group struct {
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.BoilerplateMixin
- machinery.ResourceMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Group) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup {
- f.Path = filepath.Join("apis", "%[group]", "%[version]", "groupversion_info.go")
- } else {
- f.Path = filepath.Join("api", "%[version]", "groupversion_info.go")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
-
- f.TemplateBody = groupTemplate
-
- return nil
-}
-
-//nolint:lll
-const groupTemplate = `{{ .Boilerplate }}
-
-// Package {{ .Resource.Version }} contains API Schema definitions for the {{ .Resource.Group }} {{ .Resource.Version }} API group
-//+kubebuilder:object:generate=true
-//+groupName={{ .Resource.QualifiedGroup }}
-package {{ .Resource.Version }}
-
-import (
- "k8s.io/apimachinery/pkg/runtime/schema"
- "sigs.k8s.io/controller-runtime/pkg/scheme"
-)
-
-var (
- // GroupVersion is group version used to register these objects
- GroupVersion = schema.GroupVersion{Group: "{{ .Resource.QualifiedGroup }}", Version: "{{ .Resource.Version }}"}
-
- // SchemeBuilder is used to add go types to the GroupVersionKind scheme
- SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
-
- // AddToScheme adds the types in this group-version to the given scheme.
- AddToScheme = SchemeBuilder.AddToScheme
-)
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/api/types.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/api/types.go
deleted file mode 100644
index 688751e1f8f..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/api/types.go
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package api
-
-import (
- "path/filepath"
-
- log "github.com/sirupsen/logrus"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Types{}
-
-// Types scaffolds the file that defines the schema for a CRD
-// nolint:maligned
-type Types struct {
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.BoilerplateMixin
- machinery.ResourceMixin
-
- Force bool
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Types) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup {
- f.Path = filepath.Join("apis", "%[group]", "%[version]", "%[kind]_types.go")
- } else {
- f.Path = filepath.Join("api", "%[version]", "%[kind]_types.go")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
- log.Println(f.Path)
-
- f.TemplateBody = typesTemplate
-
- if f.Force {
- f.IfExistsAction = machinery.OverwriteFile
- } else {
- f.IfExistsAction = machinery.Error
- }
-
- return nil
-}
-
-const typesTemplate = `{{ .Boilerplate }}
-
-package {{ .Resource.Version }}
-
-import (
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// {{ .Resource.Kind }}Spec defines the desired state of {{ .Resource.Kind }}
-type {{ .Resource.Kind }}Spec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-
- // Foo is an example field of {{ .Resource.Kind }}. Edit {{ lower .Resource.Kind }}_types.go to remove/update
- Foo string ` + "`" + `json:"foo,omitempty"` + "`" + `
-}
-
-// {{ .Resource.Kind }}Status defines the observed state of {{ .Resource.Kind }}
-type {{ .Resource.Kind }}Status struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-}
-
-//+kubebuilder:object:root=true
-//+kubebuilder:subresource:status
-{{- if not .Resource.API.Namespaced }}
-//+kubebuilder:resource:scope=Cluster
-{{- end }}
-
-// {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API
-type {{ .Resource.Kind }} struct {
- metav1.TypeMeta ` + "`" + `json:",inline"` + "`" + `
- metav1.ObjectMeta ` + "`" + `json:"metadata,omitempty"` + "`" + `
-
- Spec {{ .Resource.Kind }}Spec ` + "`" + `json:"spec,omitempty"` + "`" + `
- Status {{ .Resource.Kind }}Status ` + "`" + `json:"status,omitempty"` + "`" + `
-}
-
-//+kubebuilder:object:root=true
-
-// {{ .Resource.Kind }}List contains a list of {{ .Resource.Kind }}
-type {{ .Resource.Kind }}List struct {
- metav1.TypeMeta ` + "`" + `json:",inline"` + "`" + `
- metav1.ListMeta ` + "`" + `json:"metadata,omitempty"` + "`" + `
- Items []{{ .Resource.Kind }} ` + "`" + `json:"items"` + "`" + `
-}
-
-func init() {
- SchemeBuilder.Register(&{{ .Resource.Kind }}{}, &{{ .Resource.Kind }}List{})
-}
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/api/webhook.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/api/webhook.go
deleted file mode 100644
index 1d653617227..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/api/webhook.go
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package api
-
-import (
- "path/filepath"
- "strings"
-
- log "github.com/sirupsen/logrus"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Webhook{}
-
-// Webhook scaffolds the file that defines a webhook for a CRD or a builtin resource
-type Webhook struct { // nolint:maligned
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.BoilerplateMixin
- machinery.ResourceMixin
-
- // Is the Group domain for the Resource replacing '.' with '-'
- QualifiedGroupWithDash string
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Webhook) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup {
- f.Path = filepath.Join("apis", "%[group]", "%[version]", "%[kind]_webhook.go")
- } else {
- f.Path = filepath.Join("api", "%[version]", "%[kind]_webhook.go")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
- log.Println(f.Path)
-
- webhookTemplate := webhookTemplate
- if f.Resource.HasDefaultingWebhook() {
- webhookTemplate = webhookTemplate + defaultingWebhookTemplate
- }
- if f.Resource.HasValidationWebhook() {
- webhookTemplate = webhookTemplate + validatingWebhookTemplate
- }
- f.TemplateBody = webhookTemplate
-
- f.IfExistsAction = machinery.Error
-
- f.QualifiedGroupWithDash = strings.Replace(f.Resource.QualifiedGroup(), ".", "-", -1)
-
- return nil
-}
-
-const (
- webhookTemplate = `{{ .Boilerplate }}
-
-package {{ .Resource.Version }}
-
-import (
- ctrl "sigs.k8s.io/controller-runtime"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
- {{- if .Resource.HasValidationWebhook }}
- "k8s.io/apimachinery/pkg/runtime"
- {{- end }}
- {{- if or .Resource.HasValidationWebhook .Resource.HasDefaultingWebhook }}
- "sigs.k8s.io/controller-runtime/pkg/webhook"
- {{- end }}
-)
-
-// log is for logging in this package.
-var {{ lower .Resource.Kind }}log = logf.Log.WithName("{{ lower .Resource.Kind }}-resource")
-
-func (r *{{ .Resource.Kind }}) SetupWebhookWithManager(mgr ctrl.Manager) error {
- return ctrl.NewWebhookManagedBy(mgr).
- For(r).
- Complete()
-}
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-`
-
- //nolint:lll
- defaultingWebhookTemplate = `
-//+kubebuilder:webhook:path=/mutate-{{ .QualifiedGroupWithDash }}-{{ .Resource.Version }}-{{ lower .Resource.Kind }},mutating=true,failurePolicy=fail,groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }},verbs=create;update,versions={{ .Resource.Version }},name=m{{ lower .Resource.Kind }}.kb.io
-
-var _ webhook.Defaulter = &{{ .Resource.Kind }}{}
-
-// Default implements webhook.Defaulter so a webhook will be registered for the type
-func (r *{{ .Resource.Kind }}) Default() {
- {{ lower .Resource.Kind }}log.Info("default", "name", r.Name)
-
- // TODO(user): fill in your defaulting logic.
-}
-`
- //nolint:lll
- validatingWebhookTemplate = `
-// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
-//+kubebuilder:webhook:verbs=create;update,path=/validate-{{ .QualifiedGroupWithDash }}-{{ .Resource.Version }}-{{ lower .Resource.Kind }},mutating=false,failurePolicy=fail,groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }},versions={{ .Resource.Version }},name=v{{ lower .Resource.Kind }}.kb.io
-
-var _ webhook.Validator = &{{ .Resource.Kind }}{}
-
-// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
-func (r *{{ .Resource.Kind }}) ValidateCreate() error {
- {{ lower .Resource.Kind }}log.Info("validate create", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object creation.
- return nil
-}
-
-// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
-func (r *{{ .Resource.Kind }}) ValidateUpdate(old runtime.Object) error {
- {{ lower .Resource.Kind }}log.Info("validate update", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object update.
- return nil
-}
-
-// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
-func (r *{{ .Resource.Kind }}) ValidateDelete() error {
- {{ lower .Resource.Kind }}log.Info("validate delete", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object deletion.
- return nil
-}
-`
-)
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/certificate.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/certificate.go
deleted file mode 100644
index 0fd4bffa433..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/certificate.go
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package certmanager
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Certificate{}
-
-// Certificate scaffolds a file that defines the issuer CR and the certificate CR
-type Certificate struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Certificate) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "certmanager", "certificate.yaml")
- }
-
- f.TemplateBody = certManagerTemplate
-
- return nil
-}
-
-const certManagerTemplate = `# The following manifests contain a self-signed issuer CR and a certificate CR.
-# More document can be found at https://docs.cert-manager.io
-# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
-# breaking changes
-apiVersion: cert-manager.io/v1alpha2
-kind: Issuer
-metadata:
- name: selfsigned-issuer
- namespace: system
-spec:
- selfSigned: {}
----
-apiVersion: cert-manager.io/v1alpha2
-kind: Certificate
-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
- dnsNames:
- - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
- issuerRef:
- kind: Issuer
- name: selfsigned-issuer
- secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/kustomization.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/kustomization.go
deleted file mode 100644
index 78b2c5e9484..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/kustomization.go
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package certmanager
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Kustomization{}
-
-// Kustomization scaffolds a file that defines the kustomization scheme for the certmanager folder
-type Kustomization struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Kustomization) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "certmanager", "kustomization.yaml")
- }
-
- f.TemplateBody = kustomizationTemplate
-
- return nil
-}
-
-const kustomizationTemplate = `resources:
-- certificate.yaml
-
-configurations:
-- kustomizeconfig.yaml
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/kustomizeconfig.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/kustomizeconfig.go
deleted file mode 100644
index a67b834e9c4..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/certmanager/kustomizeconfig.go
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package certmanager
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &KustomizeConfig{}
-
-// KustomizeConfig scaffolds a file that configures the kustomization for the certmanager folder
-type KustomizeConfig struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *KustomizeConfig) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "certmanager", "kustomizeconfig.yaml")
- }
-
- f.TemplateBody = kustomizeConfigTemplate
-
- return nil
-}
-
-//nolint:lll
-const kustomizeConfigTemplate = `# This configuration is for teaching kustomize how to update name ref and var substitution
-nameReference:
-- kind: Issuer
- group: cert-manager.io
- fieldSpecs:
- - 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/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/kustomization.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/kustomization.go
deleted file mode 100644
index 7f23dbb5d5b..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/kustomization.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package crd
-
-import (
- "fmt"
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var (
- _ machinery.Template = &Kustomization{}
- _ machinery.Inserter = &Kustomization{}
-)
-
-// Kustomization scaffolds a file that defines the kustomization scheme for the crd folder
-type Kustomization struct {
- machinery.TemplateMixin
- machinery.ResourceMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Kustomization) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "crd", "kustomization.yaml")
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
-
- f.TemplateBody = fmt.Sprintf(kustomizationTemplate,
- machinery.NewMarkerFor(f.Path, resourceMarker),
- machinery.NewMarkerFor(f.Path, webhookPatchMarker),
- machinery.NewMarkerFor(f.Path, caInjectionPatchMarker),
- )
-
- return nil
-}
-
-//nolint:gosec to ignore false complain G101: Potential hardcoded credentials (gosec)
-const (
- resourceMarker = "crdkustomizeresource"
- webhookPatchMarker = "crdkustomizewebhookpatch"
- caInjectionPatchMarker = "crdkustomizecainjectionpatch"
-)
-
-// GetMarkers implements file.Inserter
-func (f *Kustomization) GetMarkers() []machinery.Marker {
- return []machinery.Marker{
- machinery.NewMarkerFor(f.Path, resourceMarker),
- machinery.NewMarkerFor(f.Path, webhookPatchMarker),
- machinery.NewMarkerFor(f.Path, caInjectionPatchMarker),
- }
-}
-
-const (
- resourceCodeFragment = `- bases/%s_%s.yaml
-`
- webhookPatchCodeFragment = `#- patches/webhook_in_%s.yaml
-`
- caInjectionPatchCodeFragment = `#- patches/cainjection_in_%s.yaml
-`
-)
-
-// GetCodeFragments implements file.Inserter
-func (f *Kustomization) GetCodeFragments() machinery.CodeFragmentsMap {
- fragments := make(machinery.CodeFragmentsMap, 3)
-
- // Generate resource code fragments
- res := make([]string, 0)
- res = append(res, fmt.Sprintf(resourceCodeFragment, f.Resource.QualifiedGroup(), f.Resource.Plural))
-
- // Generate resource code fragments
- webhookPatch := make([]string, 0)
- webhookPatch = append(webhookPatch, fmt.Sprintf(webhookPatchCodeFragment, f.Resource.Plural))
-
- // Generate resource code fragments
- caInjectionPatch := make([]string, 0)
- caInjectionPatch = append(caInjectionPatch, fmt.Sprintf(caInjectionPatchCodeFragment, f.Resource.Plural))
-
- // Only store code fragments in the map if the slices are non-empty
- if len(res) != 0 {
- fragments[machinery.NewMarkerFor(f.Path, resourceMarker)] = res
- }
- if len(webhookPatch) != 0 {
- fragments[machinery.NewMarkerFor(f.Path, webhookPatchMarker)] = webhookPatch
- }
- if len(caInjectionPatch) != 0 {
- fragments[machinery.NewMarkerFor(f.Path, caInjectionPatchMarker)] = caInjectionPatch
- }
-
- return fragments
-}
-
-var kustomizationTemplate = `# This kustomization.yaml is not intended to be run by itself,
-# since it depends on service name and namespace that are out of this kustomize package.
-# It should be run by config/default
-resources:
-%s
-
-patchesStrategicMerge:
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
-# patches here are for enabling the conversion webhook for each CRD
-%s
-
-# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
-# patches here are for enabling the CA injection for each CRD
-%s
-
-# the following config is for teaching kustomize how to do kustomization for CRDs.
-configurations:
-- kustomizeconfig.yaml
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/kustomizeconfig.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/kustomizeconfig.go
deleted file mode 100644
index 0013026f81c..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/kustomizeconfig.go
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package crd
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &KustomizeConfig{}
-
-// KustomizeConfig scaffolds a file that configures the kustomization for the crd folder
-type KustomizeConfig struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *KustomizeConfig) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "crd", "kustomizeconfig.yaml")
- }
-
- f.TemplateBody = kustomizeConfigTemplate
-
- return nil
-}
-
-//nolint:lll
-const kustomizeConfigTemplate = `# This file is for teaching kustomize how to substitute name and namespace reference in CRD
-nameReference:
-- kind: Service
- version: v1
- fieldSpecs:
- - kind: CustomResourceDefinition
- group: apiextensions.k8s.io
- path: spec/conversion/webhookClientConfig/service/name
-
-namespace:
-- kind: CustomResourceDefinition
- group: apiextensions.k8s.io
- path: spec/conversion/webhookClientConfig/service/namespace
- create: false
-
-varReference:
-- path: metadata/annotations
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go
deleted file mode 100644
index 60debd5dc92..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/patches/enablecainjection_patch.go
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package patches
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &EnableCAInjectionPatch{}
-
-// EnableCAInjectionPatch scaffolds a file that defines the patch that injects CA into the CRD
-type EnableCAInjectionPatch struct {
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.ResourceMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *EnableCAInjectionPatch) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup {
- f.Path = filepath.Join("config", "crd", "patches", "cainjection_in_%[group]_%[plural].yaml")
- } else {
- f.Path = filepath.Join("config", "crd", "patches", "cainjection_in_%[plural].yaml")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
-
- f.TemplateBody = enableCAInjectionPatchTemplate
-
- return nil
-}
-
-const enableCAInjectionPatchTemplate = `# The following patch adds a directive for certmanager to inject CA into the CRD
-# CRD conversion requires k8s 1.13 or later.
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
- name: {{ .Resource.Plural }}.{{ .Resource.QualifiedGroup }}
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go
deleted file mode 100644
index 1472028b627..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/crd/patches/enablewebhook_patch.go
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package patches
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &EnableWebhookPatch{}
-
-// EnableWebhookPatch scaffolds a file that defines the patch that enables conversion webhook for the CRD
-type EnableWebhookPatch struct {
- machinery.TemplateMixin
- machinery.ResourceMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *EnableWebhookPatch) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "crd", "patches", "webhook_in_%[plural].yaml")
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
-
- f.TemplateBody = enableWebhookPatchTemplate
-
- return nil
-}
-
-const enableWebhookPatchTemplate = `# The following patch enables conversion webhook for CRD
-# CRD conversion requires k8s 1.13 or later.
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- name: {{ .Resource.Plural }}.{{ .Resource.QualifiedGroup }}
-spec:
- conversion:
- strategy: Webhook
- webhookClientConfig:
- # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
- # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
- caBundle: Cg==
- service:
- namespace: system
- name: webhook-service
- path: /convert
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/enablecainection_patch.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/enablecainection_patch.go
deleted file mode 100644
index 3cee6b8595d..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/enablecainection_patch.go
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package kdefault
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &WebhookCAInjectionPatch{}
-
-// WebhookCAInjectionPatch scaffolds a file that defines the patch that adds annotation to webhooks
-type WebhookCAInjectionPatch struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *WebhookCAInjectionPatch) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "default", "webhookcainjection_patch.yaml")
- }
-
- f.TemplateBody = injectCAPatchTemplate
-
- f.IfExistsAction = machinery.Error
-
- return nil
-}
-
-const injectCAPatchTemplate = `# This patch add annotation to admission webhook config and
-# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize.
-apiVersion: admissionregistration.k8s.io/v1beta1
-kind: MutatingWebhookConfiguration
-metadata:
- name: mutating-webhook-configuration
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
----
-apiVersion: admissionregistration.k8s.io/v1beta1
-kind: ValidatingWebhookConfiguration
-metadata:
- name: validating-webhook-configuration
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/kustomization.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
deleted file mode 100644
index 68ecc351cd7..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/kustomization.go
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package kdefault
-
-import (
- "os"
- "path/filepath"
- "strings"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Kustomization{}
-
-// Kustomization scaffolds a file that defines the kustomization scheme for the default overlay folder
-type Kustomization struct {
- machinery.TemplateMixin
- machinery.ProjectNameMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Kustomization) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "default", "kustomization.yaml")
- }
-
- f.TemplateBody = kustomizeTemplate
-
- f.IfExistsAction = machinery.Error
-
- if f.ProjectName == "" {
- // Use directory name as project name, which will be empty if the project version is < v3.
- dir, err := os.Getwd()
- if err != nil {
- return err
- }
- f.ProjectName = strings.ToLower(filepath.Base(dir))
- }
-
- return nil
-}
-
-const kustomizeTemplate = `# Adds namespace to all resources.
-namespace: {{ .ProjectName }}-system
-
-# Value of this field is prepended to the
-# names of all resources, e.g. a deployment named
-# "wordpress" becomes "alices-wordpress".
-# Note that it should also match with the prefix (text before '-') of the namespace
-# field above.
-namePrefix: {{ .ProjectName }}-
-
-# Labels to add to all resources and selectors.
-#commonLabels:
-# someName: someValue
-
-bases:
-- ../crd
-- ../rbac
-- ../manager
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
-# crd/kustomization.yaml
-#- ../webhook
-# [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
-
-patchesStrategicMerge:
- # Protect the /metrics endpoint by putting it behind auth.
- # If you want your controller-manager to expose the /metrics
- # endpoint w/o any authn/z, please comment the following line.
-- manager_auth_proxy_patch.yaml
-
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
-# crd/kustomization.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: v1alpha2
-# 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: v1alpha2
-# 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
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go
deleted file mode 100644
index c764cde5b21..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/manager_auth_proxy_patch.go
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package kdefault
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &ManagerAuthProxyPatch{}
-
-// ManagerAuthProxyPatch scaffolds a file that defines the patch that enables prometheus metrics for the manager
-type ManagerAuthProxyPatch struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *ManagerAuthProxyPatch) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "default", "manager_auth_proxy_patch.yaml")
- }
-
- f.TemplateBody = kustomizeAuthProxyPatchTemplate
-
- f.IfExistsAction = machinery.Error
-
- return nil
-}
-
-const kustomizeAuthProxyPatchTemplate = `# This patch inject a sidecar container which is a HTTP proxy for the
-# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
-spec:
- template:
- spec:
- containers:
- - name: kube-rbac-proxy
- image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
- args:
- - "--secure-listen-address=0.0.0.0:8443"
- - "--upstream=http://127.0.0.1:8080/"
- - "--logtostderr=true"
- - "--v=10"
- ports:
- - containerPort: 8443
- name: https
- - name: manager
- args:
- - "--metrics-addr=127.0.0.1:8080"
- - "--enable-leader-election"
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/webhook_manager_patch.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/webhook_manager_patch.go
deleted file mode 100644
index a9e0844bf18..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/kdefault/webhook_manager_patch.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package kdefault
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &ManagerWebhookPatch{}
-
-// ManagerWebhookPatch scaffolds a file that defines the patch that enables webhooks on the manager
-type ManagerWebhookPatch struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *ManagerWebhookPatch) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "default", "manager_webhook_patch.yaml")
- }
-
- f.TemplateBody = managerWebhookPatchTemplate
-
- return nil
-}
-
-const managerWebhookPatchTemplate = `apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
-spec:
- template:
- spec:
- containers:
- - name: manager
- ports:
- - containerPort: 9443
- name: webhook-server
- protocol: TCP
- volumeMounts:
- - mountPath: /tmp/k8s-webhook-server/serving-certs
- name: cert
- readOnly: true
- volumes:
- - name: cert
- secret:
- defaultMode: 420
- secretName: webhook-server-cert
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/manager/config.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/manager/config.go
deleted file mode 100644
index 1e08e134923..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/manager/config.go
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package manager
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Config{}
-
-// Config scaffolds a file that defines the namespace and the manager deployment
-type Config struct {
- machinery.TemplateMixin
-
- // Image is controller manager image name
- Image string
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Config) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "manager", "manager.yaml")
- }
-
- f.TemplateBody = configTemplate
-
- return nil
-}
-
-const configTemplate = `apiVersion: v1
-kind: Namespace
-metadata:
- labels:
- control-plane: controller-manager
- name: system
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
- labels:
- control-plane: controller-manager
-spec:
- selector:
- matchLabels:
- control-plane: controller-manager
- replicas: 1
- template:
- metadata:
- labels:
- control-plane: controller-manager
- spec:
- containers:
- - command:
- - /manager
- args:
- - --enable-leader-election
- image: {{ .Image }}
- name: manager
- resources:
- limits:
- cpu: 100m
- memory: 30Mi
- requests:
- cpu: 100m
- memory: 20Mi
- terminationGracePeriodSeconds: 10
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/manager/kustomization.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/manager/kustomization.go
deleted file mode 100644
index f8d5ecd7ec9..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/manager/kustomization.go
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package manager
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Kustomization{}
-
-// Kustomization scaffolds a file that defines the kustomization scheme for the manager folder
-type Kustomization struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Kustomization) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "manager", "kustomization.yaml")
- }
-
- f.TemplateBody = kustomizeManagerTemplate
-
- f.IfExistsAction = machinery.Error
-
- return nil
-}
-
-const kustomizeManagerTemplate = `resources:
-- manager.yaml
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/prometheus/kustomization.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/prometheus/kustomization.go
deleted file mode 100644
index c271a6a3dbb..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/prometheus/kustomization.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package prometheus
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Kustomization{}
-
-// Kustomization scaffolds a file that defines the kustomization scheme for the prometheus folder
-type Kustomization struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Kustomization) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "prometheus", "kustomization.yaml")
- }
-
- f.TemplateBody = kustomizationTemplate
-
- return nil
-}
-
-const kustomizationTemplate = `resources:
-- monitor.yaml
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/prometheus/monitor.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/prometheus/monitor.go
deleted file mode 100644
index 261282075ec..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/prometheus/monitor.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package prometheus
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Monitor{}
-
-// Monitor scaffolds a file that defines the prometheus service monitor
-type Monitor struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Monitor) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "prometheus", "monitor.yaml")
- }
-
- f.TemplateBody = serviceMonitorTemplate
-
- return nil
-}
-
-const serviceMonitorTemplate = `
-# Prometheus Monitor Service (Metrics)
-apiVersion: monitoring.coreos.com/v1
-kind: ServiceMonitor
-metadata:
- labels:
- control-plane: controller-manager
- name: controller-manager-metrics-monitor
- namespace: system
-spec:
- endpoints:
- - path: /metrics
- port: https
- scheme: https
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
- tlsConfig:
- insecureSkipVerify: true
- selector:
- matchLabels:
- control-plane: controller-manager
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_client_role.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_client_role.go
deleted file mode 100644
index 1eee0af2031..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_client_role.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &AuthProxyClientRole{}
-
-// AuthProxyClientRole scaffolds a file that defines the role for the metrics reader
-type AuthProxyClientRole struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *AuthProxyClientRole) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "auth_proxy_client_clusterrole.yaml")
- }
-
- f.TemplateBody = clientClusterRoleTemplate
-
- return nil
-}
-
-const clientClusterRoleTemplate = `apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: metrics-reader
-rules:
-- nonResourceURLs: ["/metrics"]
- verbs: ["get"]
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role.go
deleted file mode 100644
index df22ef8dc39..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role.go
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &AuthProxyRole{}
-
-// AuthProxyRole scaffolds a file that defines the role for the auth proxy
-type AuthProxyRole struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *AuthProxyRole) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "auth_proxy_role.yaml")
- }
-
- f.TemplateBody = proxyRoleTemplate
-
- return nil
-}
-
-const proxyRoleTemplate = `apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: proxy-role
-rules:
-- apiGroups: ["authentication.k8s.io"]
- resources:
- - tokenreviews
- verbs: ["create"]
-- apiGroups: ["authorization.k8s.io"]
- resources:
- - subjectaccessreviews
- verbs: ["create"]
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go
deleted file mode 100644
index eafc45f6ee9..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_role_binding.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &AuthProxyRoleBinding{}
-
-// AuthProxyRoleBinding scaffolds a file that defines the role binding for the auth proxy
-type AuthProxyRoleBinding struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *AuthProxyRoleBinding) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "auth_proxy_role_binding.yaml")
- }
-
- f.TemplateBody = proxyRoleBindinggTemplate
-
- return nil
-}
-
-const proxyRoleBindinggTemplate = `apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
- name: proxy-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: proxy-role
-subjects:
-- kind: ServiceAccount
- name: default
- namespace: system
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_service.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_service.go
deleted file mode 100644
index 6287d360ebb..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/auth_proxy_service.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &AuthProxyService{}
-
-// AuthProxyService scaffolds a file that defines the service for the auth proxy
-type AuthProxyService struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *AuthProxyService) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "auth_proxy_service.yaml")
- }
-
- f.TemplateBody = authProxyServiceTemplate
-
- return nil
-}
-
-const authProxyServiceTemplate = `apiVersion: v1
-kind: Service
-metadata:
- labels:
- control-plane: controller-manager
- name: controller-manager-metrics-service
- namespace: system
-spec:
- ports:
- - name: https
- port: 8443
- targetPort: https
- selector:
- control-plane: controller-manager
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go
deleted file mode 100644
index 7024549629d..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/crd_editor_role.go
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &CRDEditorRole{}
-
-// CRDEditorRole scaffolds a file that defines the role that allows to edit plurals
-type CRDEditorRole struct {
- machinery.TemplateMixin
- machinery.ResourceMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *CRDEditorRole) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "%[kind]_editor_role.yaml")
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
-
- f.TemplateBody = crdRoleEditorTemplate
-
- return nil
-}
-
-const crdRoleEditorTemplate = `# permissions for end users to edit {{ .Resource.Plural }}.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: {{ lower .Resource.Kind }}-editor-role
-rules:
-- apiGroups:
- - {{ .Resource.QualifiedGroup }}
- resources:
- - {{ .Resource.Plural }}
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - {{ .Resource.QualifiedGroup }}
- resources:
- - {{ .Resource.Plural }}/status
- verbs:
- - get
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go
deleted file mode 100644
index 74177476661..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/crd_viewer_role.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &CRDViewerRole{}
-
-// CRDViewerRole scaffolds a file that defines the role that allows to view plurals
-type CRDViewerRole struct {
- machinery.TemplateMixin
- machinery.ResourceMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *CRDViewerRole) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "%[kind]_viewer_role.yaml")
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
-
- f.TemplateBody = crdRoleViewerTemplate
-
- return nil
-}
-
-const crdRoleViewerTemplate = `# permissions for end users to view {{ .Resource.Plural }}.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: {{ lower .Resource.Kind }}-viewer-role
-rules:
-- apiGroups:
- - {{ .Resource.QualifiedGroup }}
- resources:
- - {{ .Resource.Plural }}
- verbs:
- - get
- - list
- - watch
-- apiGroups:
- - {{ .Resource.QualifiedGroup }}
- resources:
- - {{ .Resource.Plural }}/status
- verbs:
- - get
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/kustomization.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/kustomization.go
deleted file mode 100644
index f5b164e5b79..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/kustomization.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Kustomization{}
-
-// Kustomization scaffolds a file that defines the kustomization scheme for the rbac folder
-type Kustomization struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Kustomization) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "kustomization.yaml")
- }
-
- f.TemplateBody = kustomizeRBACTemplate
-
- f.IfExistsAction = machinery.Error
-
- return nil
-}
-
-const kustomizeRBACTemplate = `resources:
-- role.yaml
-- role_binding.yaml
-- leader_election_role.yaml
-- leader_election_role_binding.yaml
-# Comment the following 4 lines if you want to disable
-# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
-# which protects your /metrics endpoint.
-- auth_proxy_service.yaml
-- auth_proxy_role.yaml
-- auth_proxy_role_binding.yaml
-- auth_proxy_client_clusterrole.yaml
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/leader_election_role.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/leader_election_role.go
deleted file mode 100644
index 6de4d48b784..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/leader_election_role.go
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &LeaderElectionRole{}
-
-// LeaderElectionRole scaffolds a file that defines the role that allows leader election
-type LeaderElectionRole struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *LeaderElectionRole) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "leader_election_role.yaml")
- }
-
- f.TemplateBody = leaderElectionRoleTemplate
-
- return nil
-}
-
-const leaderElectionRoleTemplate = `# permissions to do leader election.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: Role
-metadata:
- name: leader-election-role
-rules:
-- apiGroups:
- - ""
- resources:
- - configmaps
- verbs:
- - get
- - list
- - watch
- - create
- - update
- - patch
- - delete
-- apiGroups:
- - ""
- resources:
- - configmaps/status
- verbs:
- - get
- - update
- - patch
-- apiGroups:
- - ""
- resources:
- - events
- verbs:
- - create
- - patch
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go
deleted file mode 100644
index 9dd75b7ff6b..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/leader_election_role_binding.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &LeaderElectionRoleBinding{}
-
-// LeaderElectionRoleBinding scaffolds a file that defines the role binding that allows leader election
-type LeaderElectionRoleBinding struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *LeaderElectionRoleBinding) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "leader_election_role_binding.yaml")
- }
-
- f.TemplateBody = leaderElectionRoleBindingTemplate
-
- return nil
-}
-
-const leaderElectionRoleBindingTemplate = `apiVersion: rbac.authorization.k8s.io/v1
-kind: RoleBinding
-metadata:
- name: leader-election-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: Role
- name: leader-election-role
-subjects:
-- kind: ServiceAccount
- name: default
- namespace: system
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/role_binding.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/role_binding.go
deleted file mode 100644
index 0cc6687e8c3..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/rbac/role_binding.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package rbac
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &RoleBinding{}
-
-// RoleBinding scaffolds a file that defines the role binding for the manager
-type RoleBinding struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *RoleBinding) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "rbac", "role_binding.yaml")
- }
-
- f.TemplateBody = managerBindingTemplate
-
- return nil
-}
-
-const managerBindingTemplate = `apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
- name: manager-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: manager-role
-subjects:
-- kind: ServiceAccount
- name: default
- namespace: system
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/samples/crd_sample.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/samples/crd_sample.go
deleted file mode 100644
index 4a8eee252f8..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/samples/crd_sample.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package samples
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &CRDSample{}
-
-// CRDSample scaffolds a file that defines a sample manifest for the CRD
-type CRDSample struct {
- machinery.TemplateMixin
- machinery.ResourceMixin
-
- Force bool
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *CRDSample) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "samples", "%[group]_%[version]_%[kind].yaml")
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
-
- if f.Force {
- f.IfExistsAction = machinery.OverwriteFile
- } else {
- f.IfExistsAction = machinery.Error
- }
-
- f.TemplateBody = crdSampleTemplate
-
- return nil
-}
-
-const crdSampleTemplate = `apiVersion: {{ .Resource.QualifiedGroup }}/{{ .Resource.Version }}
-kind: {{ .Resource.Kind }}
-metadata:
- name: {{ lower .Resource.Kind }}-sample
-spec:
- # TODO(user): Add fields here
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/kustomization.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/kustomization.go
deleted file mode 100644
index 7157dd8380c..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/kustomization.go
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package webhook
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Kustomization{}
-
-// Kustomization scaffolds a file that defines the kustomization scheme for the webhook folder
-type Kustomization struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Kustomization) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "webhook", "kustomization.yaml")
- }
-
- f.TemplateBody = kustomizeWebhookTemplate
-
- f.IfExistsAction = machinery.Error
-
- return nil
-}
-
-const kustomizeWebhookTemplate = `resources:
-- manifests.yaml
-- service.yaml
-
-configurations:
-- kustomizeconfig.yaml
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/kustomizeconfig.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/kustomizeconfig.go
deleted file mode 100644
index ac2c92cc89e..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/kustomizeconfig.go
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package webhook
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &KustomizeConfig{}
-
-// KustomizeConfig scaffolds a file that configures the kustomization for the webhook folder
-type KustomizeConfig struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *KustomizeConfig) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "webhook", "kustomizeconfig.yaml")
- }
-
- f.TemplateBody = kustomizeConfigWebhookTemplate
-
- f.IfExistsAction = machinery.Error
-
- return nil
-}
-
-//nolint:lll
-const kustomizeConfigWebhookTemplate = `# the following config is for teaching kustomize where to look at when substituting vars.
-# It requires kustomize v2.1.0 or newer to work properly.
-nameReference:
-- kind: Service
- version: v1
- fieldSpecs:
- - kind: MutatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/name
- - kind: ValidatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/name
-
-namespace:
-- kind: MutatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/namespace
- create: true
-- kind: ValidatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/namespace
- create: true
-
-varReference:
-- path: metadata/annotations
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/service.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/service.go
deleted file mode 100644
index 7783aa136c4..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/config/webhook/service.go
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package webhook
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Service{}
-
-// Service scaffolds a file that defines the webhook service
-type Service struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Service) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join("config", "webhook", "service.yaml")
- }
-
- f.TemplateBody = serviceTemplate
-
- f.IfExistsAction = machinery.Error
-
- return nil
-}
-
-const serviceTemplate = `
-apiVersion: v1
-kind: Service
-metadata:
- name: webhook-service
- namespace: system
-spec:
- ports:
- - port: 443
- targetPort: 9443
- selector:
- control-plane: controller-manager
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/controllers/controller.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/controllers/controller.go
deleted file mode 100644
index 7c800b50e54..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/controllers/controller.go
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "path/filepath"
-
- log "github.com/sirupsen/logrus"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Controller{}
-
-// Controller scaffolds the file that defines the controller for a CRD or a builtin resource
-// nolint:maligned
-type Controller struct {
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.BoilerplateMixin
- machinery.ResourceMixin
-
- ControllerRuntimeVersion string
-
- Force bool
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Controller) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup {
- f.Path = filepath.Join("controllers", "%[group]", "%[kind]_controller.go")
- } else {
- f.Path = filepath.Join("controllers", "%[kind]_controller.go")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
- log.Println(f.Path)
-
- f.TemplateBody = controllerTemplate
-
- if f.Force {
- f.IfExistsAction = machinery.OverwriteFile
- } else {
- f.IfExistsAction = machinery.Error
- }
-
- return nil
-}
-
-//nolint:lll
-const controllerTemplate = `{{ .Boilerplate }}
-
-package controllers
-
-import (
- "context"
- "github.com/go-logr/logr"
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
- {{ if not (isEmptyStr .Resource.Path) -}}
- {{ .Resource.ImportAlias }} "{{ .Resource.Path }}"
- {{- end }}
-)
-
-// {{ .Resource.Kind }}Reconciler reconciles a {{ .Resource.Kind }} object
-type {{ .Resource.Kind }}Reconciler struct {
- client.Client
- Log logr.Logger
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }},verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }}/status,verbs=get;update;patch
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the {{ .Resource.Kind }} object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@{{ .ControllerRuntimeVersion }}/pkg/reconcile
-func (r *{{ .Resource.Kind }}Reconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
- _ = context.Background()
- _ = r.Log.WithValues("{{ .Resource.Kind | lower }}", req.NamespacedName)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *{{ .Resource.Kind }}Reconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- {{ if not (isEmptyStr .Resource.Path) -}}
- For(&{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}{}).
- {{- else -}}
- // Uncomment the following line adding a pointer to an instance of the controlled resource as an argument
- // For().
- {{- end }}
- Complete(r)
-}
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/dockerfile.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/dockerfile.go
deleted file mode 100644
index 38e4c47167c..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/dockerfile.go
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Dockerfile{}
-
-// Dockerfile scaffolds a file that defines the containerized build process
-type Dockerfile struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Dockerfile) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = "Dockerfile"
- }
-
- f.TemplateBody = dockerfileTemplate
-
- return nil
-}
-
-const dockerfileTemplate = `# Build the manager binary
-FROM golang:1.13 as builder
-
-WORKDIR /workspace
-# Copy the Go Modules manifests
-COPY go.mod go.mod
-COPY go.sum go.sum
-# cache deps before building and copying source so that we don't need to re-download as much
-# and so that source changes don't invalidate our downloaded layer
-RUN go mod download
-
-# Copy the go source
-COPY main.go main.go
-COPY api/ api/
-COPY controllers/ controllers/
-
-# Build
-RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
-
-# Use distroless as minimal base image to package the manager binary
-# Refer to https://github.com/GoogleContainerTools/distroless for more details
-FROM gcr.io/distroless/static:nonroot
-WORKDIR /
-COPY --from=builder /workspace/manager .
-USER nonroot:nonroot
-
-ENTRYPOINT ["/manager"]
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/gitignore.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/gitignore.go
deleted file mode 100644
index b4a5c691167..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/gitignore.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &GitIgnore{}
-
-// GitIgnore scaffolds a file that defines which files should be ignored by git
-type GitIgnore struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *GitIgnore) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = ".gitignore"
- }
-
- f.TemplateBody = gitignoreTemplate
-
- return nil
-}
-
-const gitignoreTemplate = `
-# Binaries for programs and plugins
-*.exe
-*.exe~
-*.dll
-*.so
-*.dylib
-bin
-
-# Test binary, build with ` + "`go test -c`" + `
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# Kubernetes Generated files - skip generated files, except for vendored files
-
-!vendor/**/zz_generated.*
-
-# editor and IDE paraphernalia
-.idea
-.vscode
-*.swp
-*.swo
-*~
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/gomod.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/gomod.go
deleted file mode 100644
index e369bc98567..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/gomod.go
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &GoMod{}
-
-// GoMod scaffolds a file that defines the project dependencies
-type GoMod struct {
- machinery.TemplateMixin
- machinery.RepositoryMixin
-
- ControllerRuntimeVersion string
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *GoMod) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = "go.mod"
- }
-
- f.TemplateBody = goModTemplate
-
- f.IfExistsAction = machinery.OverwriteFile
-
- return nil
-}
-
-const goModTemplate = `
-module {{ .Repo }}
-
-go 1.13
-
-require (
- sigs.k8s.io/controller-runtime {{ .ControllerRuntimeVersion }}
-)
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/hack/boilerplate.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/hack/boilerplate.go
deleted file mode 100644
index 1d07c79b45a..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/hack/boilerplate.go
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-Copyright 2018 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package hack
-
-import (
- "fmt"
- "path/filepath"
- "time"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-// DefaultBoilerplatePath is the default path to the boilerplate file
-var DefaultBoilerplatePath = filepath.Join("hack", "boilerplate.go.txt")
-
-var _ machinery.Template = &Boilerplate{}
-
-// Boilerplate scaffolds a file that defines the common header for the rest of the files
-type Boilerplate struct {
- machinery.TemplateMixin
- machinery.BoilerplateMixin
-
- // License is the License type to write
- License string
-
- // Licenses maps License types to their actual string
- Licenses map[string]string
-
- // Owner is the copyright owner - e.g. "The Kubernetes Authors"
- Owner string
-
- // Year is the copyright year
- Year string
-}
-
-// Validate implements file.RequiresValidation
-func (f Boilerplate) Validate() error {
- if f.License == "" {
- // A default license will be set later
- } else if _, found := knownLicenses[f.License]; found {
- // One of the know licenses
- } else if _, found := f.Licenses[f.License]; found {
- // A map containing the requested license was also provided
- } else {
- return fmt.Errorf("unknown specified license %s", f.License)
- }
-
- return nil
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Boilerplate) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = DefaultBoilerplatePath
- }
-
- if f.License == "" {
- f.License = "apache2"
- }
-
- if f.Licenses == nil {
- f.Licenses = make(map[string]string, len(knownLicenses))
- }
-
- for key, value := range knownLicenses {
- if _, hasLicense := f.Licenses[key]; !hasLicense {
- f.Licenses[key] = value
- }
- }
-
- if f.Year == "" {
- f.Year = fmt.Sprintf("%v", time.Now().Year())
- }
-
- // Boilerplate given
- if len(f.Boilerplate) > 0 {
- f.TemplateBody = f.Boilerplate
- return nil
- }
-
- f.TemplateBody = boilerplateTemplate
-
- return nil
-}
-
-const boilerplateTemplate = `/*
-{{ if .Owner -}}
-Copyright {{ .Year }} {{ .Owner }}.
-{{- else -}}
-Copyright {{ .Year }}.
-{{- end }}
-{{ index .Licenses .License }}*/`
-
-var knownLicenses = map[string]string{
- "apache2": apache2,
- "none": "",
-}
-
-const apache2 = `
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/main.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/main.go
deleted file mode 100644
index c2bd6928d85..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/main.go
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "fmt"
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-const defaultMainPath = "main.go"
-
-var _ machinery.Template = &Main{}
-
-// Main scaffolds a file that defines the controller manager entry point
-type Main struct {
- machinery.TemplateMixin
- machinery.BoilerplateMixin
- machinery.DomainMixin
- machinery.RepositoryMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Main) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = filepath.Join(defaultMainPath)
- }
-
- f.TemplateBody = fmt.Sprintf(mainTemplate,
- machinery.NewMarkerFor(f.Path, importMarker),
- machinery.NewMarkerFor(f.Path, addSchemeMarker),
- machinery.NewMarkerFor(f.Path, setupMarker),
- )
-
- return nil
-}
-
-var _ machinery.Inserter = &MainUpdater{}
-
-// MainUpdater updates main.go to run Controllers
-type MainUpdater struct { //nolint:maligned
- machinery.RepositoryMixin
- machinery.MultiGroupMixin
- machinery.ResourceMixin
-
- // Flags to indicate which parts need to be included when updating the file
- WireResource, WireController, WireWebhook bool
-}
-
-// GetPath implements file.Builder
-func (*MainUpdater) GetPath() string {
- return defaultMainPath
-}
-
-// GetIfExistsAction implements file.Builder
-func (*MainUpdater) GetIfExistsAction() machinery.IfExistsAction {
- return machinery.OverwriteFile
-}
-
-const (
- importMarker = "imports"
- addSchemeMarker = "scheme"
- setupMarker = "builder"
-)
-
-// GetMarkers implements file.Inserter
-func (f *MainUpdater) GetMarkers() []machinery.Marker {
- return []machinery.Marker{
- machinery.NewMarkerFor(defaultMainPath, importMarker),
- machinery.NewMarkerFor(defaultMainPath, addSchemeMarker),
- machinery.NewMarkerFor(defaultMainPath, setupMarker),
- }
-}
-
-const (
- apiImportCodeFragment = `%s "%s"
-`
- controllerImportCodeFragment = `"%s/controllers"
-`
- multiGroupControllerImportCodeFragment = `%scontroller "%s/controllers/%s"
-`
- addschemeCodeFragment = `utilruntime.Must(%s.AddToScheme(scheme))
-`
- reconcilerSetupCodeFragment = `if err = (&controllers.%sReconciler{
- Client: mgr.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("%s"),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "%s")
- os.Exit(1)
- }
-`
- multiGroupReconcilerSetupCodeFragment = `if err = (&%scontroller.%sReconciler{
- Client: mgr.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("%s"),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "%s")
- os.Exit(1)
- }
-`
- webhookSetupCodeFragment = `if err = (&%s.%s{}).SetupWebhookWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create webhook", "webhook", "%s")
- os.Exit(1)
- }
-`
-)
-
-// GetCodeFragments implements file.Inserter
-func (f *MainUpdater) GetCodeFragments() machinery.CodeFragmentsMap {
- fragments := make(machinery.CodeFragmentsMap, 3)
-
- // If resource is not being provided we are creating the file, not updating it
- if f.Resource == nil {
- return fragments
- }
-
- // Generate import code fragments
- imports := make([]string, 0)
- if f.WireResource {
- imports = append(imports, fmt.Sprintf(apiImportCodeFragment, f.Resource.ImportAlias(), f.Resource.Path))
- }
-
- if f.WireController {
- if !f.MultiGroup {
- imports = append(imports, fmt.Sprintf(controllerImportCodeFragment, f.Repo))
- } else {
- imports = append(imports, fmt.Sprintf(multiGroupControllerImportCodeFragment,
- f.Resource.PackageName(), f.Repo, f.Resource.Group))
- }
- }
-
- // Generate add scheme code fragments
- addScheme := make([]string, 0)
- if f.WireResource {
- addScheme = append(addScheme, fmt.Sprintf(addschemeCodeFragment, f.Resource.ImportAlias()))
- }
-
- // Generate setup code fragments
- setup := make([]string, 0)
- if f.WireController {
- if !f.MultiGroup {
- setup = append(setup, fmt.Sprintf(reconcilerSetupCodeFragment,
- f.Resource.Kind, f.Resource.Kind, f.Resource.Kind))
- } else {
- setup = append(setup, fmt.Sprintf(multiGroupReconcilerSetupCodeFragment,
- f.Resource.PackageName(), f.Resource.Kind, f.Resource.Kind, f.Resource.Kind))
- }
- }
- if f.WireWebhook {
- setup = append(setup, fmt.Sprintf(webhookSetupCodeFragment,
- f.Resource.ImportAlias(), f.Resource.Kind, f.Resource.Kind))
- }
-
- // Only store code fragments in the map if the slices are non-empty
- if len(imports) != 0 {
- fragments[machinery.NewMarkerFor(defaultMainPath, importMarker)] = imports
- }
- if len(addScheme) != 0 {
- fragments[machinery.NewMarkerFor(defaultMainPath, addSchemeMarker)] = addScheme
- }
- if len(setup) != 0 {
- fragments[machinery.NewMarkerFor(defaultMainPath, setupMarker)] = setup
- }
-
- return fragments
-}
-
-var mainTemplate = `{{ .Boilerplate }}
-
-package main
-
-import (
- "flag"
- "os"
- "k8s.io/apimachinery/pkg/runtime"
- utilruntime "k8s.io/apimachinery/pkg/util/runtime"
- clientgoscheme "k8s.io/client-go/kubernetes/scheme"
- _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/log/zap"
- %s
-)
-
-var (
- scheme = runtime.NewScheme()
- setupLog = ctrl.Log.WithName("setup")
-)
-
-func init() {
- utilruntime.Must(clientgoscheme.AddToScheme(scheme))
-
- %s
-}
-
-func main() {
- var metricsAddr string
- var enableLeaderElection bool
- flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
- flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
- "Enable leader election for controller manager. " +
- "Enabling this will ensure there is only one active controller manager.")
- flag.Parse()
-
- ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
-
- mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
- Scheme: scheme,
- MetricsBindAddress: metricsAddr,
- Port: 9443,
- LeaderElection: enableLeaderElection,
- LeaderElectionID: "{{ hashFNV .Repo }}.{{ .Domain }}",
- })
- if err != nil {
- setupLog.Error(err, "unable to start manager")
- os.Exit(1)
- }
-
- %s
-
- setupLog.Info("starting manager")
- if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
- setupLog.Error(err, "problem running manager")
- os.Exit(1)
- }
-}
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/makefile.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/makefile.go
deleted file mode 100644
index 94ecf72fad2..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/internal/templates/makefile.go
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
-Copyright 2019 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Makefile{}
-
-// Makefile scaffolds a file that defines project management CLI commands
-type Makefile struct {
- machinery.TemplateMixin
-
- // Image is controller manager image name
- Image string
- // BoilerplatePath is the path to the boilerplate file
- BoilerplatePath string
- // Controller tools version to use in the project
- ControllerToolsVersion string
- // Kustomize version to use in the project
- KustomizeVersion string
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Makefile) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = "Makefile"
- }
-
- f.TemplateBody = makefileTemplate
-
- f.IfExistsAction = machinery.Error
-
- if f.Image == "" {
- f.Image = "controller:latest"
- }
-
- return nil
-}
-
-//nolint:lll
-const makefileTemplate = `
-# Image URL to use all building/pushing image targets
-IMG ?= {{ .Image }}
-# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
-CRD_OPTIONS ?= "crd:trivialVersions=true"
-
-# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
-ifeq (,$(shell go env GOBIN))
-GOBIN=$(shell go env GOPATH)/bin
-else
-GOBIN=$(shell go env GOBIN)
-endif
-
-.PHONY: all
-all: build
-
-##@ General
-
-# The help target prints out all targets with their descriptions organized
-# beneath their categories. The categories are represented by '##@' and the
-# target descriptions by '##'. The awk command is responsible for reading the
-# entire set of makefiles included in this invocation, looking for lines of the
-# file as xyz: ## something, and then pretty-format the target and help. Then,
-# if there's a line with ##@ something, that gets pretty-printed as a category.
-# More info on the usage of ANSI control characters for terminal formatting:
-# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
-# More info on the awk command:
-# http://linuxcommand.org/lc3_adv_awk.php
-
-.PHONY: help
-help: ## Display this help.
- @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
-
-##@ Development
-
-.PHONY: manifests
-manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
- $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
-
-.PHONY: generate
-generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
- $(CONTROLLER_GEN) object:headerFile={{printf "%q" .BoilerplatePath}} paths="./..."
-
-.PHONY: fmt
-fmt: ## Run go fmt against code.
- go fmt ./...
-
-.PHONY: vet
-vet: ## Run go vet against code.
- go vet ./...
-
-.PHONY: test
-test: manifests generate fmt vet ## Run tests.
- go test ./... -coverprofile cover.out
-
-##@ Build
-
-.PHONY: build
-build: generate fmt vet ## Build manager binary.
- go build -o bin/manager main.go
-
-# Backwards compatibility
-.PHONY: manager
-manager: build ## Build manager binary (alias for build target).
-
-.PHONY: run
-run: manifests generate fmt vet ## Run a controller from your host.
- go run ./main.go
-
-.PHONY: docker-build
-docker-build: test ## Build docker image with the manager.
- docker build -t ${IMG} .
-
-.PHONY: docker-push
-docker-push: ## Push docker image with the manager.
- docker push ${IMG}
-
-##@ Deployment
-
-ifndef ignore-not-found
- ignore-not-found = false
-endif
-
-.PHONY: install
-install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
- $(KUSTOMIZE) build config/crd | kubectl apply -f -
-
-.PHONY: uninstall
-uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
- $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
-
-.PHONY: deploy
-deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
- cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
- $(KUSTOMIZE) build config/default | kubectl apply -f -
-
-.PHONY: undeploy
-undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
- $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
-
-##@ Build Dependencies
-
-## Location to install dependencies to
-LOCALBIN ?= $(shell pwd)/bin
-$(LOCALBIN): ## Ensure that the directory exists
- mkdir -p $(LOCALBIN)
-
-## Tool Binaries
-KUSTOMIZE ?= $(LOCALBIN)/kustomize
-CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
-
-## Tool Versions
-KUSTOMIZE_VERSION ?= {{ .KustomizeVersion }}
-CONTROLLER_TOOLS_VERSION ?= {{ .ControllerToolsVersion }}
-
-KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
-.PHONY: kustomize
-kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
-$(KUSTOMIZE): $(LOCALBIN)
- test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
-
-.PHONY: controller-gen
-controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
-$(CONTROLLER_GEN): $(LOCALBIN)
- test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
-`
diff --git a/pkg/plugins/golang/v2/scaffolds/webhook.go b/pkg/plugins/golang/v2/scaffolds/webhook.go
deleted file mode 100644
index 3e34cbf0ac0..00000000000
--- a/pkg/plugins/golang/v2/scaffolds/webhook.go
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package scaffolds
-
-import (
- "fmt"
-
- log "github.com/sirupsen/logrus"
- "github.com/spf13/afero"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "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/golang/v2/scaffolds/internal/templates"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/api"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds/internal/templates/hack"
-)
-
-var _ plugins.Scaffolder = &webhookScaffolder{}
-
-type webhookScaffolder struct {
- config config.Config
- resource resource.Resource
-
- // fs is the filesystem that will be used by the scaffolder
- fs machinery.Filesystem
-}
-
-// NewWebhookScaffolder returns a new Scaffolder for v2 webhook creation operations
-func NewWebhookScaffolder(config config.Config, resource resource.Resource) plugins.Scaffolder {
- return &webhookScaffolder{
- config: config,
- resource: resource,
- }
-}
-
-// InjectFS implements cmdutil.Scaffolder
-func (s *webhookScaffolder) InjectFS(fs machinery.Filesystem) {
- s.fs = fs
-}
-
-// Scaffold implements cmdutil.Scaffolder
-func (s *webhookScaffolder) Scaffold() error {
- log.Println("Writing scaffold for you to edit...")
-
- // Load the boilerplate
- boilerplate, err := afero.ReadFile(s.fs.FS, hack.DefaultBoilerplatePath)
- if err != nil {
- return fmt.Errorf("error scaffolding webhook: unable to load boilerplate: %w", err)
- }
-
- // Initialize the machinery.Scaffold that will write the files to disk
- scaffold := machinery.NewScaffold(s.fs,
- machinery.WithConfig(s.config),
- machinery.WithBoilerplate(string(boilerplate)),
- machinery.WithResource(&s.resource),
- )
-
- if err := s.config.UpdateResource(s.resource); err != nil {
- return fmt.Errorf("error updating resource: %w", err)
- }
-
- if err := scaffold.Execute(
- &api.Webhook{},
- &templates.MainUpdater{WireWebhook: true},
- ); err != nil {
- return err
- }
-
- if s.resource.HasConversionWebhook() {
- fmt.Println(`Webhook server has been set up for you.
-You need to implement the conversion.Hub and conversion.Convertible interfaces for your CRD types.`)
- }
-
- return nil
-}
diff --git a/pkg/plugins/golang/v2/webhook.go b/pkg/plugins/golang/v2/webhook.go
deleted file mode 100644
index 02a7ae91eab..00000000000
--- a/pkg/plugins/golang/v2/webhook.go
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated
-package v2
-
-import (
- "fmt"
-
- "github.com/spf13/pflag"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv2 "sigs.k8s.io/kubebuilder/v3/pkg/config/v2"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- goPlugin "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2/scaffolds"
-)
-
-var _ plugin.CreateWebhookSubcommand = &createWebhookSubcommand{}
-
-type createWebhookSubcommand struct {
- config config.Config
- // For help text.
- commandName string
-
- options *goPlugin.Options
-
- resource *resource.Resource
-}
-
-func (p *createWebhookSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
- p.commandName = cliMeta.CommandName
-
- subcmdMeta.Description = `Scaffold a webhook for an API resource. You can choose to scaffold defaulting,
-validating and/or conversion webhooks.
-`
- subcmdMeta.Examples = fmt.Sprintf(` # Create defaulting and validating webhooks for Group: ship, Version: v1beta1
- # and Kind: Frigate
- %[1]s create webhook --group ship --version v1beta1 --kind Frigate --defaulting --programmatic-validation
-
- # Create conversion webhook for Group: ship, Version: v1beta1
- # and Kind: Frigate
- %[1]s create webhook --group ship --version v1beta1 --kind Frigate --conversion
-`, cliMeta.CommandName)
-}
-
-func (p *createWebhookSubcommand) BindFlags(fs *pflag.FlagSet) {
- p.options = &goPlugin.Options{WebhookVersion: "v1beta1"}
-
- fs.StringVar(&p.options.Plural, "resource", "", "resource irregular plural form")
-
- fs.BoolVar(&p.options.DoDefaulting, "defaulting", false,
- "if set, scaffold the defaulting webhook")
- fs.BoolVar(&p.options.DoValidation, "programmatic-validation", false,
- "if set, scaffold the validating webhook")
- fs.BoolVar(&p.options.DoConversion, "conversion", false,
- "if set, scaffold the conversion webhook")
-}
-
-func (p *createWebhookSubcommand) InjectConfig(c config.Config) error {
- p.config = c
-
- return nil
-}
-
-func (p *createWebhookSubcommand) InjectResource(res *resource.Resource) error {
- p.resource = res
-
- if p.resource.Group == "" {
- return fmt.Errorf("group cannot be empty")
- }
-
- p.options.UpdateResource(p.resource, p.config)
-
- if err := p.resource.Validate(); err != nil {
- return err
- }
-
- if !p.resource.HasDefaultingWebhook() && !p.resource.HasValidationWebhook() && !p.resource.HasConversionWebhook() {
- return fmt.Errorf("%s create webhook requires at least one of --defaulting,"+
- " --programmatic-validation and --conversion to be true", p.commandName)
- }
-
- // check if resource exist to create webhook
- if p.config.GetVersion().Compare(cfgv2.Version) == 0 {
- if !p.config.HasResource(p.resource.GVK) {
- return fmt.Errorf("%s create webhook requires a previously created API ", p.commandName)
- }
- } else {
- if r, err := p.config.GetResource(p.resource.GVK); err != nil {
- return fmt.Errorf("%s create webhook requires a previously created API ", p.commandName)
- } else if r.Webhooks != nil && !r.Webhooks.IsEmpty() {
- return fmt.Errorf("webhook resource already exists")
- }
- }
-
- return nil
-}
-
-func (p *createWebhookSubcommand) Scaffold(fs machinery.Filesystem) error {
- scaffolder := scaffolds.NewWebhookScaffolder(p.config, *p.resource)
- scaffolder.InjectFS(fs)
- return scaffolder.Scaffold()
-}
diff --git a/pkg/plugins/golang/v3/api.go b/pkg/plugins/golang/v3/api.go
deleted file mode 100644
index bf981aaf86b..00000000000
--- a/pkg/plugins/golang/v3/api.go
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated in favor of v4
-package v3
-
-import (
- "bufio"
- "errors"
- "fmt"
- "os"
-
- "github.com/spf13/pflag"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
- goPlugin "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds"
-)
-
-const (
- // defaultCRDVersion is the default CRD API version to scaffold.
- defaultCRDVersion = "v1"
-)
-
-// DefaultMainPath is default file path of main.go
-const DefaultMainPath = "main.go"
-
-var _ plugin.CreateAPISubcommand = &createAPISubcommand{}
-
-type createAPISubcommand struct {
- config config.Config
-
- options *goPlugin.Options
-
- resource *resource.Resource
-
- // Check if we have to scaffold resource and/or controller
- resourceFlag *pflag.Flag
- controllerFlag *pflag.Flag
-
- // force indicates that the resource should be created even if it already exists
- force bool
-
- // runMake indicates whether to run make or not after scaffolding APIs
- runMake bool
-}
-
-func (p *createAPISubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
- subcmdMeta.Description = `Scaffold a Kubernetes API by writing a Resource definition and/or a Controller.
-
-If information about whether the resource and controller should be scaffolded
-was not explicitly provided, it will prompt the user if they should be.
-
-After the scaffold is written, the dependencies will be updated and
-make generate will be run.
-`
- subcmdMeta.Examples = fmt.Sprintf(` # Create a frigates API with Group: ship, Version: v1beta1 and Kind: Frigate
- %[1]s create api --group ship --version v1beta1 --kind Frigate
-
- # Edit the API Scheme
- nano api/v1beta1/frigate_types.go
-
- # Edit the Controller
- nano controllers/frigate/frigate_controller.go
-
- # Edit the Controller Test
- nano controllers/frigate/frigate_controller_test.go
-
- # Generate the manifests
- make manifests
-
- # Install CRDs into the Kubernetes cluster using kubectl apply
- make install
-
- # Regenerate code and run against the Kubernetes cluster configured by ~/.kube/config
- make run
-`, cliMeta.CommandName)
-}
-
-func (p *createAPISubcommand) BindFlags(fs *pflag.FlagSet) {
- fs.BoolVar(&p.runMake, "make", true, "if true, run `make generate` after generating files")
-
- fs.BoolVar(&p.force, "force", false,
- "attempt to create resource even if it already exists")
-
- p.options = &goPlugin.Options{}
-
- fs.StringVar(&p.options.Plural, "plural", "", "resource irregular plural form")
-
- fs.BoolVar(&p.options.DoAPI, "resource", true,
- "if set, generate the resource without prompting the user")
- p.resourceFlag = fs.Lookup("resource")
- fs.StringVar(&p.options.CRDVersion, "crd-version", defaultCRDVersion,
- "version of CustomResourceDefinition to scaffold. Options: [v1, v1beta1]")
- fs.BoolVar(&p.options.Namespaced, "namespaced", true, "resource is namespaced")
-
- fs.BoolVar(&p.options.DoController, "controller", true,
- "if set, generate the controller without prompting the user")
- p.controllerFlag = fs.Lookup("controller")
-
- // (not required raise an error in this case)
- // nolint:errcheck,gosec
- fs.MarkDeprecated("crd-version", deprecateMsg)
-}
-
-func (p *createAPISubcommand) InjectConfig(c config.Config) error {
- p.config = c
-
- return nil
-}
-
-func (p *createAPISubcommand) InjectResource(res *resource.Resource) error {
- p.resource = res
-
- // TODO: re-evaluate whether y/n input still makes sense. We should probably always
- // scaffold the resource and controller.
- // Ask for API and Controller if not specified
- reader := bufio.NewReader(os.Stdin)
- if !p.resourceFlag.Changed {
- fmt.Println("Create Resource [y/n]")
- p.options.DoAPI = util.YesNo(reader)
- }
- if !p.controllerFlag.Changed {
- fmt.Println("Create Controller [y/n]")
- p.options.DoController = util.YesNo(reader)
- }
-
- p.options.UpdateResource(p.resource, p.config)
-
- if err := p.resource.Validate(); err != nil {
- return err
- }
-
- // In case we want to scaffold a resource API we need to do some checks
- if p.options.DoAPI {
- // Check that resource doesn't have the API scaffolded or flag force was set
- if r, err := p.config.GetResource(p.resource.GVK); err == nil && r.HasAPI() && !p.force {
- return errors.New("API resource already exists")
- }
-
- // Check that the provided group can be added to the project
- if !p.config.IsMultiGroup() && p.config.ResourcesLength() != 0 && !p.config.HasGroup(p.resource.Group) {
- return fmt.Errorf("multiple groups are not allowed by default, " +
- "to enable multi-group visit https://kubebuilder.io/migration/multi-group.html")
- }
-
- // Check CRDVersion against all other CRDVersions in p.config for compatibility.
- // nolint:staticcheck
- if util.HasDifferentCRDVersion(p.config, p.resource.API.CRDVersion) {
- return fmt.Errorf("only one CRD version can be used for all resources, cannot add %q",
- p.resource.API.CRDVersion)
- }
- }
-
- return nil
-}
-
-func (p *createAPISubcommand) PreScaffold(machinery.Filesystem) error {
- // check if main.go is present in the root directory
- if _, err := os.Stat(DefaultMainPath); os.IsNotExist(err) {
- return fmt.Errorf("%s file should present in the root directory", DefaultMainPath)
- }
-
- return nil
-}
-
-func (p *createAPISubcommand) Scaffold(fs machinery.Filesystem) error {
- scaffolder := scaffolds.NewAPIScaffolder(p.config, *p.resource, p.force)
- scaffolder.InjectFS(fs)
- return scaffolder.Scaffold()
-}
-
-func (p *createAPISubcommand) PostScaffold() error {
-
- // Update the makefile to allow generate Webhooks to ensure backwards compatibility
- // todo: it should be removed for go/v4
- // nolint:lll,gosec
- if p.resource.API.CRDVersion == "v1beta1" {
- if err := applyScaffoldCustomizationsForVbeta1(); err != nil {
- return err
- }
- }
-
- err := util.RunCmd("Update dependencies", "go", "mod", "tidy")
- if err != nil {
- return err
- }
- if p.runMake && p.resource.HasAPI() {
- err = util.RunCmd("Running make", "make", "generate")
- if err != nil {
- return err
- }
- fmt.Print("Next: implement your new API and generate the manifests (e.g. CRDs,CRs) with:\n$ make manifests\n")
- }
-
- return nil
-}
diff --git a/pkg/plugins/golang/v3/commons.go b/pkg/plugins/golang/v3/commons.go
deleted file mode 100644
index cd8c1eb8675..00000000000
--- a/pkg/plugins/golang/v3/commons.go
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
-Copyright 2022 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated in favor of v4
-package v3
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
-
- log "github.com/sirupsen/logrus"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds"
-)
-
-const deprecateMsg = "The v1beta1 API version for CRDs and Webhooks are deprecated and are no longer supported since " +
- "the Kubernetes release 1.22. This flag no longer required to exist in future releases. Also, we would like to " +
- "recommend you no longer use these API versions." +
- "More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22"
-
-// Update the makefile to allow generate CRDs/Webhooks with v1beta1 to ensure backwards compatibility
-// nolint:lll,gosec
-func applyScaffoldCustomizationsForVbeta1() error {
- makefilePath := filepath.Join("Makefile")
- bs, err := os.ReadFile(makefilePath)
- if err != nil {
- return err
- }
- if !strings.Contains(string(bs), "CRD_OPTIONS") {
-
- log.Warn("The v1beta1 API version for CRDs and Webhooks are deprecated and are no longer supported " +
- "since the Kubernetes release 1.22. In order to help you out use these versions" +
- "we will need to try to update the Makefile and go.mod files of this project. Please," +
- "ensure that these changes were done accordingly with your customizations.\n" +
- "Also, we would like to recommend you no longer use these API versions." +
- "More info: https://kubernetes.io/docs/reference/using-api/deprecation-guide/#v1-22")
-
- const makefileTarget = `$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases`
- const makefileTargetForV1beta1 = `$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases`
-
- if err := util.ReplaceInFile("Makefile", makefileTarget, makefileTargetForV1beta1); err != nil {
- fmt.Printf("unable to update the makefile to allow the usage of v1beta1: %s", err)
- }
-
- const makegentarget = `manifests: controller-gen`
- const makegenV1beta1Options = `# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
-CRD_OPTIONS ?= "crd:crdVersions={v1beta1},trivialVersions=true,preserveUnknownFields=false"
-manifests: controller-gen`
-
- if err := util.ReplaceInFile("Makefile", makegentarget, makegenV1beta1Options); err != nil {
- log.Warnf("unable to update the Makefile with %s: %s", makegenV1beta1Options, err)
- }
-
- // latest version of controller-tools where v1beta1 is supported
- const controllerToolsVersionForVBeta1 = "v0.6.2"
- if err := util.ReplaceInFile("Makefile",
- fmt.Sprintf("CONTROLLER_TOOLS_VERSION ?= %s",
- scaffolds.ControllerToolsVersion),
- fmt.Sprintf("CONTROLLER_TOOLS_VERSION ?= %s",
- controllerToolsVersionForVBeta1)); err != nil {
- log.Warnf("unable to update the Makefile with %s: %s", fmt.Sprintf("controller-gen@%s",
- controllerToolsVersionForVBeta1), err)
- }
-
- if err := util.ReplaceInFile("Makefile",
- "ENVTEST_K8S_VERSION = 1.26.1",
- "ENVTEST_K8S_VERSION = 1.21"); err != nil {
- log.Warnf("unable to update the Makefile with %s: %s", "ENVTEST_K8S_VERSION = 1.21", err)
- }
-
- // DO NOT UPDATE THIS VERSION
- // Note that this implementation will update the go.mod to downgrade the versions for those that are
- // compatible v1beta1 CRD/Webhooks k8s core APIs if/when a user tries to create an API with
- // 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) no longer provide this feature.
- const controllerRuntimeVersionForVBeta1 = "v0.9.2"
-
- if err := util.ReplaceInFile("go.mod",
- fmt.Sprintf("sigs.k8s.io/controller-runtime %s", scaffolds.ControllerRuntimeVersion),
- fmt.Sprintf("sigs.k8s.io/controller-runtime %s", controllerRuntimeVersionForVBeta1)); err != nil {
- log.Warnf("unable to update the go.mod with sigs.k8s.io/controller-runtime %s: %s",
- controllerRuntimeVersionForVBeta1, err)
- }
-
- if err := util.ReplaceInFile("go.mod",
- "k8s.io/api v0.24.2",
- "k8s.io/api v0.21.2"); err != nil {
- log.Warnf("unable to update the go.mod with k8s.io/api v0.21.2: %s", err)
- }
-
- if err := util.ReplaceInFile("go.mod",
- "k8s.io/apimachinery v0.24.2",
- "k8s.io/apimachinery v0.21.2"); err != nil {
- log.Warnf("unable to update the go.mod with k8s.io/apimachinery v0.21.2: %s", err)
- }
-
- if err := util.ReplaceInFile("go.mod",
- "k8s.io/client-go v0.24.2",
- "k8s.io/client-go v0.21.2"); err != nil {
- log.Warnf("unable to update the go.mod with k8s.io/client-go v0.21.2: %s", err)
- }
-
- // During the scaffolding phase, this gets added to go.mod file, running go mod tidy bumps back
- // the version from 21.2 to the latest
- if err := util.ReplaceInFile("go.mod",
- "k8s.io/api v0.24.2",
- "k8s.io/api v0.21.2"); err != nil {
- log.Warnf("unable to update the go.mod with k8s.io/api v0.21.2: %s", err)
- }
-
- if err := util.ReplaceInFile("go.mod",
- "k8s.io/apiextensions-apiserver v0.24.2",
- "k8s.io/apiextensions-apiserver v0.21.2"); err != nil {
- log.Warnf("unable to update the go.mod with k8s.io/apiextensions-apiserver v0.21.2: %s", err)
- }
-
- if err := util.ReplaceInFile("go.mod",
- "k8s.io/component-base v0.24.2",
- "k8s.io/component-base v0.21.2"); err != nil {
- log.Warnf("unable to update the go.mod with k8s.io/component-base v0.21.2: %s", err)
- }
-
- // Cannot use v1+ unless controller runtime is v0.11
- if err := util.ReplaceInFile("go.mod",
- "github.com/go-logr/logr v1.2.0",
- "github.com/go-logr/logr v0.4.0"); err != nil {
- log.Warnf("unable to update the go.mod with github.com/go-logr/logr v0.4.0: %s", err)
- }
-
- if err := util.ReplaceInFile("go.mod",
- "github.com/go-logr/zapr v1.2.0",
- "github.com/go-logr/zapr v0.4.0"); err != nil {
- log.Warnf("unable to update the go.mod with github.com/go-logr/zapr v0.4.0: %s", err)
- }
-
- if err := util.ReplaceInFile("go.mod",
- "k8s.io/klog/v2 v2.60.1",
- "k8s.io/klog/v2 v2.9.0"); err != nil {
- log.Warnf("unable to update the go.mod with k8s.io/klog/v2 v2.9.0: %s", err)
- }
-
- // Due to some indirect dependency changes with a bump in k8s packages from 0.23.x --> 0.24.x we need to
- // clear out all indirect dependencies before we run `go mod tidy` so that the above changes get resolved correctly
- if err := util.ReplaceRegexInFile("go.mod", `(require \(\n(\t.* \/\/ indirect\n)+\))`, ""); err != nil {
- log.Warnf("unable to update the go.mod indirect dependencies: %s", err)
- }
-
- err = util.RunCmd("Update dependencies", "go", "mod", "tidy")
- if err != nil {
- return err
- }
- }
- return nil
-}
diff --git a/pkg/plugins/golang/v3/edit.go b/pkg/plugins/golang/v3/edit.go
deleted file mode 100644
index 679902ab073..00000000000
--- a/pkg/plugins/golang/v3/edit.go
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated in favor of v4
-package v3
-
-import (
- "fmt"
-
- "github.com/spf13/pflag"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds"
-)
-
-var _ plugin.EditSubcommand = &editSubcommand{}
-
-type editSubcommand struct {
- config config.Config
-
- multigroup bool
-}
-
-func (p *editSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
- subcmdMeta.Description = `This command will edit the project configuration.
-Features supported:
- - Toggle between single or multi group projects.
-`
- subcmdMeta.Examples = fmt.Sprintf(` # Enable the multigroup layout
- %[1]s edit --multigroup
-
- # Disable the multigroup layout
- %[1]s edit --multigroup=false
-`, cliMeta.CommandName)
-}
-
-func (p *editSubcommand) BindFlags(fs *pflag.FlagSet) {
- fs.BoolVar(&p.multigroup, "multigroup", false, "enable or disable multigroup layout")
-}
-
-func (p *editSubcommand) InjectConfig(c config.Config) error {
- p.config = c
-
- return nil
-}
-
-func (p *editSubcommand) Scaffold(fs machinery.Filesystem) error {
- scaffolder := scaffolds.NewEditScaffolder(p.config, p.multigroup)
- scaffolder.InjectFS(fs)
- return scaffolder.Scaffold()
-}
diff --git a/pkg/plugins/golang/v3/init.go b/pkg/plugins/golang/v3/init.go
deleted file mode 100644
index 6264118f744..00000000000
--- a/pkg/plugins/golang/v3/init.go
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated in favor of v4
-package v3
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
- "unicode"
-
- log "github.com/sirupsen/logrus"
- "github.com/spf13/pflag"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds"
-)
-
-// Variables and function to check Go version requirements.
-var (
- goVerMin = golang.MustParse("go1.19.0")
- goVerMax = golang.MustParse("go2.0alpha1")
-)
-
-var _ plugin.InitSubcommand = &initSubcommand{}
-
-type initSubcommand struct {
- config config.Config
- // For help text.
- commandName string
-
- // boilerplate options
- license string
- owner string
-
- // go config options
- repo string
-
- // flags
- fetchDeps bool
- skipGoVersionCheck bool
-}
-
-func (p *initSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
- p.commandName = cliMeta.CommandName
-
- subcmdMeta.Description = `Initialize a new project including the following files:
- - a "go.mod" with project dependencies
- - a "PROJECT" file that stores project configuration
- - a "Makefile" with several useful make targets for the project
- - several YAML files for project deployment under the "config" directory
- - a "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/v3 --domain example.org --owner "Your name"
-
- # Initialize a new project defining a specific project version
- %[1]s init --plugins go/v3 --project-version 3
-`, cliMeta.CommandName)
-}
-
-func (p *initSubcommand) BindFlags(fs *pflag.FlagSet) {
- fs.BoolVar(&p.skipGoVersionCheck, "skip-go-version-check",
- false, "if specified, skip checking the Go version")
-
- // dependency args
- fs.BoolVar(&p.fetchDeps, "fetch-deps", true, "ensure dependencies are downloaded")
-
- // boilerplate args
- fs.StringVar(&p.license, "license", "apache2",
- "license to use to boilerplate, may be one of 'apache2', 'none'")
- fs.StringVar(&p.owner, "owner", "", "owner to add to the copyright")
-
- // project args
- fs.StringVar(&p.repo, "repo", "", "name to use for go module (e.g., github.com/user/repo), "+
- "defaults to the go package of the current working directory.")
-}
-
-func (p *initSubcommand) InjectConfig(c config.Config) error {
- p.config = c
-
- // Try to guess repository if flag is not set.
- if p.repo == "" {
- repoPath, err := golang.FindCurrentRepo()
- if err != nil {
- return fmt.Errorf("error finding current repository: %v", err)
- }
- p.repo = repoPath
- }
-
- return p.config.SetRepository(p.repo)
-}
-
-func (p *initSubcommand) PreScaffold(machinery.Filesystem) error {
- // Ensure Go version is in the allowed range if check not turned off.
- if !p.skipGoVersionCheck {
- if err := golang.ValidateGoVersion(goVerMin, goVerMax); err != nil {
- return err
- }
- }
-
- // Check if the current directory has not files or directories which does not allow to init the project
- return checkDir()
-}
-
-func (p *initSubcommand) Scaffold(fs machinery.Filesystem) error {
- scaffolder := scaffolds.NewInitScaffolder(p.config, p.license, p.owner)
- scaffolder.InjectFS(fs)
- err := scaffolder.Scaffold()
- if err != nil {
- return err
- }
-
- if !p.fetchDeps {
- log.Println("Skipping fetching dependencies.")
- return nil
- }
-
- // Ensure that we are pinning controller-runtime version
- // xref: https://github.com/kubernetes-sigs/kubebuilder/issues/997
- err = util.RunCmd("Get controller runtime", "go", "get",
- "sigs.k8s.io/controller-runtime@"+scaffolds.ControllerRuntimeVersion)
- if err != nil {
- return err
- }
-
- return nil
-}
-
-func (p *initSubcommand) PostScaffold() error {
- err := util.RunCmd("Update dependencies", "go", "mod", "tidy")
- if err != nil {
- return err
- }
-
- fmt.Printf("Next: define a resource with:\n$ %s create api\n", p.commandName)
- return nil
-}
-
-// checkDir will return error if the current directory has files which are not allowed.
-// Note that, it is expected that the directory to scaffold the project is cleaned.
-// Otherwise, it might face issues to do the scaffold.
-func checkDir() error {
- err := filepath.Walk(".",
- func(path string, info os.FileInfo, err error) error {
- if err != nil {
- return err
- }
- // Allow directory trees starting with '.'
- if info.IsDir() && strings.HasPrefix(info.Name(), ".") && info.Name() != "." {
- return filepath.SkipDir
- }
- // Allow files starting with '.'
- if strings.HasPrefix(info.Name(), ".") {
- return nil
- }
- // Allow files ending with '.md' extension
- if strings.HasSuffix(info.Name(), ".md") && !info.IsDir() {
- return nil
- }
- // Allow capitalized files except PROJECT
- isCapitalized := true
- for _, l := range info.Name() {
- if !unicode.IsUpper(l) {
- isCapitalized = false
- break
- }
- }
- if isCapitalized && info.Name() != "PROJECT" {
- return nil
- }
- // Allow files in the following list
- allowedFiles := []string{
- "go.mod", // user might run `go mod init` instead of providing the `--flag` at init
- "go.sum", // auto-generated file related to go.mod
- }
- for _, allowedFile := range allowedFiles {
- if info.Name() == allowedFile {
- return nil
- }
- }
- // Do not allow any other file
- return fmt.Errorf(
- "target directory is not empty (only %s, files and directories with the prefix \".\", "+
- "files with the suffix \".md\" or capitalized files name are allowed); "+
- "found existing file %q", strings.Join(allowedFiles, ", "), path)
- })
- if err != nil {
- return err
- }
- return nil
-}
diff --git a/pkg/plugins/golang/v3/plugin.go b/pkg/plugins/golang/v3/plugin.go
deleted file mode 100644
index 6fb800b63b3..00000000000
--- a/pkg/plugins/golang/v3/plugin.go
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated in favor of v4
-package v3
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- cfgv3 "sigs.k8s.io/kubebuilder/v3/pkg/config/v3"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
-)
-
-const pluginName = "base." + golang.DefaultNameQualifier
-
-var (
- pluginVersion = plugin.Version{Number: 3}
- supportedProjectVersions = []config.Version{cfgv3.Version}
-)
-
-var _ plugin.Full = Plugin{}
-
-// Plugin implements the plugin.Full interface
-type Plugin struct {
- initSubcommand
- createAPISubcommand
- createWebhookSubcommand
- editSubcommand
-}
-
-// Name returns the name of the plugin
-func (Plugin) Name() string { return pluginName }
-
-// Version returns the version of the plugin
-func (Plugin) Version() plugin.Version { return pluginVersion }
-
-// SupportedProjectVersions returns an array with all project versions supported by the plugin
-func (Plugin) SupportedProjectVersions() []config.Version { return supportedProjectVersions }
-
-// GetInitSubcommand will return the subcommand which is responsible for initializing and common scaffolding
-func (p Plugin) GetInitSubcommand() plugin.InitSubcommand { return &p.initSubcommand }
-
-// GetCreateAPISubcommand will return the subcommand which is responsible for scaffolding apis
-func (p Plugin) GetCreateAPISubcommand() plugin.CreateAPISubcommand { return &p.createAPISubcommand }
-
-// GetCreateWebhookSubcommand will return the subcommand which is responsible for scaffolding webhooks
-func (p Plugin) GetCreateWebhookSubcommand() plugin.CreateWebhookSubcommand {
- return &p.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/v3/scaffolds/api.go b/pkg/plugins/golang/v3/scaffolds/api.go
deleted file mode 100644
index bccb6e84350..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/api.go
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package scaffolds
-
-import (
- "fmt"
-
- log "github.com/sirupsen/logrus"
- "github.com/spf13/afero"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "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/golang/v3/scaffolds/internal/templates"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds/internal/templates/api"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds/internal/templates/hack"
-)
-
-var _ plugins.Scaffolder = &apiScaffolder{}
-
-// apiScaffolder contains configuration for generating scaffolding for Go type
-// representing the API and controller that implements the behavior for the API.
-type apiScaffolder struct {
- config config.Config
- resource resource.Resource
-
- // fs is the filesystem that will be used by the scaffolder
- fs machinery.Filesystem
-
- // force indicates whether to scaffold controller files even if it exists or not
- force bool
-}
-
-// NewAPIScaffolder returns a new Scaffolder for API/controller creation operations
-func NewAPIScaffolder(config config.Config, res resource.Resource, force bool) plugins.Scaffolder {
- return &apiScaffolder{
- config: config,
- resource: res,
- force: force,
- }
-}
-
-// InjectFS implements cmdutil.Scaffolder
-func (s *apiScaffolder) InjectFS(fs machinery.Filesystem) {
- s.fs = fs
-}
-
-// Scaffold implements cmdutil.Scaffolder
-func (s *apiScaffolder) Scaffold() error {
- log.Println("Writing scaffold for you to edit...")
-
- // Load the boilerplate
- boilerplate, err := afero.ReadFile(s.fs.FS, hack.DefaultBoilerplatePath)
- if err != nil {
- return fmt.Errorf("error scaffolding API/controller: unable to load boilerplate: %w", err)
- }
-
- // Initialize the machinery.Scaffold that will write the files to disk
- scaffold := machinery.NewScaffold(s.fs,
- machinery.WithConfig(s.config),
- machinery.WithBoilerplate(string(boilerplate)),
- machinery.WithResource(&s.resource),
- )
-
- // Keep track of these values before the update
- doAPI := s.resource.HasAPI()
- doController := s.resource.HasController()
-
- if err := s.config.UpdateResource(s.resource); err != nil {
- return fmt.Errorf("error updating resource: %w", err)
- }
-
- if doAPI {
- if err := scaffold.Execute(
- &api.Types{Force: s.force},
- &api.Group{},
- ); err != nil {
- return fmt.Errorf("error scaffolding APIs: %v", err)
- }
- }
-
- if doController {
- if err := scaffold.Execute(
- &controllers.SuiteTest{Force: s.force},
- &controllers.Controller{ControllerRuntimeVersion: ControllerRuntimeVersion, Force: s.force},
- ); err != nil {
- return fmt.Errorf("error scaffolding controller: %v", err)
- }
- }
-
- if err := scaffold.Execute(
- &templates.MainUpdater{WireResource: doAPI, WireController: doController},
- ); err != nil {
- return fmt.Errorf("error updating main.go: %v", err)
- }
-
- return nil
-}
diff --git a/pkg/plugins/golang/v3/scaffolds/doc.go b/pkg/plugins/golang/v3/scaffolds/doc.go
deleted file mode 100644
index 71ae0484cf4..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/doc.go
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Package scaffolds contains libraries for scaffolding code to use with controller-runtime
-package scaffolds
diff --git a/pkg/plugins/golang/v3/scaffolds/edit.go b/pkg/plugins/golang/v3/scaffolds/edit.go
deleted file mode 100644
index e099a8a7b16..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/edit.go
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package scaffolds
-
-import (
- "fmt"
- "strings"
-
- "github.com/spf13/afero"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins"
-)
-
-var _ plugins.Scaffolder = &editScaffolder{}
-
-type editScaffolder struct {
- config config.Config
- multigroup bool
-
- // fs is the filesystem that will be used by the scaffolder
- fs machinery.Filesystem
-}
-
-// NewEditScaffolder returns a new Scaffolder for configuration edit operations
-func NewEditScaffolder(config config.Config, multigroup bool) plugins.Scaffolder {
- return &editScaffolder{
- config: config,
- multigroup: multigroup,
- }
-}
-
-// InjectFS implements cmdutil.Scaffolder
-func (s *editScaffolder) InjectFS(fs machinery.Filesystem) {
- s.fs = fs
-}
-
-// Scaffold implements cmdutil.Scaffolder
-func (s *editScaffolder) Scaffold() error {
- filename := "Dockerfile"
- bs, err := afero.ReadFile(s.fs.FS, filename)
- if err != nil {
- return err
- }
- str := string(bs)
-
- // update dockerfile
- if s.multigroup {
- str, err = ensureExistAndReplace(
- str,
- "COPY api/ api/",
- `COPY apis/ apis/`)
-
- } else {
- str, err = ensureExistAndReplace(
- str,
- "COPY apis/ apis/",
- `COPY api/ api/`)
- }
-
- // Ignore the error encountered, if the file is already in desired format.
- if err != nil && s.multigroup != s.config.IsMultiGroup() {
- return err
- }
-
- if s.multigroup {
- _ = s.config.SetMultiGroup()
- } else {
- _ = s.config.ClearMultiGroup()
- }
-
- // Check if the str is not empty, because when the file is already in desired format it will return empty string
- // because there is nothing to replace.
- if str != "" {
- // TODO: instead of writing it directly, we should use the scaffolding machinery for consistency
- return afero.WriteFile(s.fs.FS, filename, []byte(str), 0644)
- }
-
- return nil
-}
-
-func ensureExistAndReplace(input, match, replace string) (string, error) {
- if !strings.Contains(input, match) {
- return "", fmt.Errorf("can't find %q", match)
- }
- return strings.Replace(input, match, replace, -1), nil
-}
diff --git a/pkg/plugins/golang/v3/scaffolds/init.go b/pkg/plugins/golang/v3/scaffolds/init.go
deleted file mode 100644
index ffba15e9216..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/init.go
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package scaffolds
-
-import (
- log "github.com/sirupsen/logrus"
- "github.com/spf13/afero"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- "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"
- "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"
-)
-
-const (
- // ControllerRuntimeVersion is the kubernetes-sigs/controller-runtime version to be used in the project
- ControllerRuntimeVersion = "v0.14.4"
- // ControllerToolsVersion is the kubernetes-sigs/controller-tools version to be used in the project
- ControllerToolsVersion = "v0.11.3"
-
- imageName = "controller:latest"
-)
-
-var _ plugins.Scaffolder = &initScaffolder{}
-
-var kustomizeVersion string
-
-type initScaffolder struct {
- config config.Config
- boilerplatePath string
- license string
- owner string
-
- // fs is the filesystem that will be used by the scaffolder
- fs machinery.Filesystem
-}
-
-// NewInitScaffolder returns a new Scaffolder for project initialization operations
-func NewInitScaffolder(config config.Config, license, owner string) plugins.Scaffolder {
- return &initScaffolder{
- config: config,
- boilerplatePath: hack.DefaultBoilerplatePath,
- license: license,
- owner: owner,
- }
-}
-
-// InjectFS implements cmdutil.Scaffolder
-func (s *initScaffolder) InjectFS(fs machinery.Filesystem) {
- s.fs = fs
-}
-
-// Scaffold implements cmdutil.Scaffolder
-func (s *initScaffolder) Scaffold() error {
- log.Println("Writing scaffold for you to edit...")
-
- // Initialize the machinery.Scaffold that will write the boilerplate file to disk
- // The boilerplate file needs to be scaffolded as a separate step as it is going to
- // be used by the rest of the files, even those scaffolded in this command call.
- scaffold := machinery.NewScaffold(s.fs,
- machinery.WithConfig(s.config),
- )
-
- bpFile := &hack.Boilerplate{
- License: s.license,
- Owner: s.owner,
- }
- bpFile.Path = s.boilerplatePath
- if err := scaffold.Execute(bpFile); err != nil {
- return err
- }
-
- boilerplate, err := afero.ReadFile(s.fs.FS, s.boilerplatePath)
- if err != nil {
- return err
- }
-
- // Initialize the machinery.Scaffold that will write the files to disk
- scaffold = machinery.NewScaffold(s.fs,
- machinery.WithConfig(s.config),
- machinery.WithBoilerplate(string(boilerplate)),
- )
-
- // If the KustomizeV2 was used to do the scaffold then
- // we need to ensure that we use its supported Kustomize Version
- // in order to support it
- kustomizeVersion = kustomizecommonv1.KustomizeVersion
- kustomizev2 := kustomizecommonv2alpha.Plugin{}
- gov4alpha := "go.kubebuilder.io/v4-alpha"
- pluginKeyForKustomizeV2 := plugin.KeyFor(kustomizev2)
-
- for _, pluginKey := range s.config.GetPluginChain() {
- if pluginKey == pluginKeyForKustomizeV2 || pluginKey == gov4alpha {
- kustomizeVersion = kustomizecommonv2alpha.KustomizeVersion
- break
- }
- }
-
- return scaffold.Execute(
- &templates.Main{},
- &templates.GoMod{
- ControllerRuntimeVersion: ControllerRuntimeVersion,
- },
- &templates.GitIgnore{},
- &templates.Makefile{
- Image: imageName,
- BoilerplatePath: s.boilerplatePath,
- ControllerToolsVersion: ControllerToolsVersion,
- KustomizeVersion: kustomizeVersion,
- ControllerRuntimeVersion: ControllerRuntimeVersion,
- },
- &templates.Dockerfile{},
- &templates.DockerIgnore{},
- &templates.Readme{},
- )
-}
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/group.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/api/group.go
deleted file mode 100644
index 8c93af689a0..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/group.go
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package api
-
-import (
- "path/filepath"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Group{}
-
-// Group scaffolds the file that defines the registration methods for a certain group and version
-type Group struct {
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.BoilerplateMixin
- machinery.ResourceMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Group) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup {
- if f.Resource.Group != "" {
- f.Path = filepath.Join("apis", "%[group]", "%[version]", "groupversion_info.go")
- } else {
- f.Path = filepath.Join("apis", "%[version]", "groupversion_info.go")
- }
- } else {
- f.Path = filepath.Join("api", "%[version]", "groupversion_info.go")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
-
- f.TemplateBody = groupTemplate
-
- return nil
-}
-
-//nolint:lll
-const groupTemplate = `{{ .Boilerplate }}
-
-// Package {{ .Resource.Version }} contains API Schema definitions for the {{ .Resource.Group }} {{ .Resource.Version }} API group
-//+kubebuilder:object:generate=true
-//+groupName={{ .Resource.QualifiedGroup }}
-package {{ .Resource.Version }}
-
-import (
- "k8s.io/apimachinery/pkg/runtime/schema"
- "sigs.k8s.io/controller-runtime/pkg/scheme"
-)
-
-var (
- // GroupVersion is group version used to register these objects
- GroupVersion = schema.GroupVersion{Group: "{{ .Resource.QualifiedGroup }}", Version: "{{ .Resource.Version }}"}
-
- // SchemeBuilder is used to add go types to the GroupVersionKind scheme
- SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
-
- // AddToScheme adds the types in this group-version to the given scheme.
- AddToScheme = SchemeBuilder.AddToScheme
-)
-`
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/types.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/api/types.go
deleted file mode 100644
index 03241a6610e..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/types.go
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package api
-
-import (
- "path/filepath"
-
- log "github.com/sirupsen/logrus"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Types{}
-
-// Types scaffolds the file that defines the schema for a CRD
-// nolint:maligned
-type Types struct {
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.BoilerplateMixin
- machinery.ResourceMixin
-
- Force bool
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Types) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup {
- if f.Resource.Group != "" {
- f.Path = filepath.Join("apis", "%[group]", "%[version]", "%[kind]_types.go")
- } else {
- f.Path = filepath.Join("apis", "%[version]", "%[kind]_types.go")
- }
- } else {
- f.Path = filepath.Join("api", "%[version]", "%[kind]_types.go")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
- log.Println(f.Path)
-
- f.TemplateBody = typesTemplate
-
- if f.Force {
- f.IfExistsAction = machinery.OverwriteFile
- } else {
- f.IfExistsAction = machinery.Error
- }
-
- return nil
-}
-
-const typesTemplate = `{{ .Boilerplate }}
-
-package {{ .Resource.Version }}
-
-import (
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// {{ .Resource.Kind }}Spec defines the desired state of {{ .Resource.Kind }}
-type {{ .Resource.Kind }}Spec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-
- // Foo is an example field of {{ .Resource.Kind }}. Edit {{ lower .Resource.Kind }}_types.go to remove/update
- Foo string ` + "`" + `json:"foo,omitempty"` + "`" + `
-}
-
-// {{ .Resource.Kind }}Status defines the observed state of {{ .Resource.Kind }}
-type {{ .Resource.Kind }}Status struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-}
-
-//+kubebuilder:object:root=true
-//+kubebuilder:subresource:status
-{{- if and (not .Resource.API.Namespaced) (not .Resource.IsRegularPlural) }}
-//+kubebuilder:resource:path={{ .Resource.Plural }},scope=Cluster
-{{- else if not .Resource.API.Namespaced }}
-//+kubebuilder:resource:scope=Cluster
-{{- else if not .Resource.IsRegularPlural }}
-//+kubebuilder:resource:path={{ .Resource.Plural }}
-{{- end }}
-
-// {{ .Resource.Kind }} is the Schema for the {{ .Resource.Plural }} API
-type {{ .Resource.Kind }} struct {
- metav1.TypeMeta ` + "`" + `json:",inline"` + "`" + `
- metav1.ObjectMeta ` + "`" + `json:"metadata,omitempty"` + "`" + `
-
- Spec {{ .Resource.Kind }}Spec ` + "`" + `json:"spec,omitempty"` + "`" + `
- Status {{ .Resource.Kind }}Status ` + "`" + `json:"status,omitempty"` + "`" + `
-}
-
-//+kubebuilder:object:root=true
-
-// {{ .Resource.Kind }}List contains a list of {{ .Resource.Kind }}
-type {{ .Resource.Kind }}List struct {
- metav1.TypeMeta ` + "`" + `json:",inline"` + "`" + `
- metav1.ListMeta ` + "`" + `json:"metadata,omitempty"` + "`" + `
- Items []{{ .Resource.Kind }} ` + "`" + `json:"items"` + "`" + `
-}
-
-func init() {
- SchemeBuilder.Register(&{{ .Resource.Kind }}{}, &{{ .Resource.Kind }}List{})
-}
-`
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook.go
deleted file mode 100644
index a019844c25c..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/api/webhook.go
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package api
-
-import (
- "path/filepath"
- "strings"
-
- log "github.com/sirupsen/logrus"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Webhook{}
-
-// Webhook scaffolds the file that defines a webhook for a CRD or a builtin resource
-type Webhook struct { // nolint:maligned
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.BoilerplateMixin
- machinery.ResourceMixin
-
- // Is the Group domain for the Resource replacing '.' with '-'
- QualifiedGroupWithDash string
-
- // Define value for AdmissionReviewVersions marker
- AdmissionReviewVersions string
-
- Force bool
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Webhook) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup {
- if f.Resource.Group != "" {
- f.Path = filepath.Join("apis", "%[group]", "%[version]", "%[kind]_webhook.go")
- } else {
- f.Path = filepath.Join("apis", "%[version]", "%[kind]_webhook.go")
- }
- } else {
- f.Path = filepath.Join("api", "%[version]", "%[kind]_webhook.go")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
- log.Println(f.Path)
-
- webhookTemplate := webhookTemplate
- if f.Resource.HasDefaultingWebhook() {
- webhookTemplate = webhookTemplate + defaultingWebhookTemplate
- }
- if f.Resource.HasValidationWebhook() {
- webhookTemplate = webhookTemplate + validatingWebhookTemplate
- }
- f.TemplateBody = webhookTemplate
-
- if f.Force {
- f.IfExistsAction = machinery.OverwriteFile
- } else {
- f.IfExistsAction = machinery.Error
- }
-
- f.AdmissionReviewVersions = "v1"
- if f.Resource.Webhooks.WebhookVersion == "v1beta1" {
- f.AdmissionReviewVersions = "{v1,v1beta1}"
- }
-
- f.QualifiedGroupWithDash = strings.Replace(f.Resource.QualifiedGroup(), ".", "-", -1)
-
- return nil
-}
-
-const (
- webhookTemplate = `{{ .Boilerplate }}
-
-package {{ .Resource.Version }}
-
-import (
- ctrl "sigs.k8s.io/controller-runtime"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
- {{- if .Resource.HasValidationWebhook }}
- "k8s.io/apimachinery/pkg/runtime"
- {{- end }}
- {{- if or .Resource.HasValidationWebhook .Resource.HasDefaultingWebhook }}
- "sigs.k8s.io/controller-runtime/pkg/webhook"
- {{- end }}
-)
-
-// log is for logging in this package.
-var {{ lower .Resource.Kind }}log = logf.Log.WithName("{{ lower .Resource.Kind }}-resource")
-
-func (r *{{ .Resource.Kind }}) SetupWebhookWithManager(mgr ctrl.Manager) error {
- return ctrl.NewWebhookManagedBy(mgr).
- For(r).
- Complete()
-}
-
-// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-`
-
- //nolint:lll
- defaultingWebhookTemplate = `
-//+kubebuilder:webhook:{{ if ne .Resource.Webhooks.WebhookVersion "v1" }}webhookVersions={{"{"}}{{ .Resource.Webhooks.WebhookVersion }}{{"}"}},{{ end }}path=/mutate-{{ .QualifiedGroupWithDash }}-{{ .Resource.Version }}-{{ lower .Resource.Kind }},mutating=true,failurePolicy=fail,sideEffects=None,groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }},verbs=create;update,versions={{ .Resource.Version }},name=m{{ lower .Resource.Kind }}.kb.io,admissionReviewVersions={{ .AdmissionReviewVersions }}
-
-var _ webhook.Defaulter = &{{ .Resource.Kind }}{}
-
-// Default implements webhook.Defaulter so a webhook will be registered for the type
-func (r *{{ .Resource.Kind }}) Default() {
- {{ lower .Resource.Kind }}log.Info("default", "name", r.Name)
-
- // TODO(user): fill in your defaulting logic.
-}
-`
-
- //nolint:lll
- validatingWebhookTemplate = `
-// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
-//+kubebuilder:webhook:{{ if ne .Resource.Webhooks.WebhookVersion "v1" }}webhookVersions={{"{"}}{{ .Resource.Webhooks.WebhookVersion }}{{"}"}},{{ end }}path=/validate-{{ .QualifiedGroupWithDash }}-{{ .Resource.Version }}-{{ lower .Resource.Kind }},mutating=false,failurePolicy=fail,sideEffects=None,groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }},verbs=create;update,versions={{ .Resource.Version }},name=v{{ lower .Resource.Kind }}.kb.io,admissionReviewVersions={{ .AdmissionReviewVersions }}
-
-var _ webhook.Validator = &{{ .Resource.Kind }}{}
-
-// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
-func (r *{{ .Resource.Kind }}) ValidateCreate() error {
- {{ lower .Resource.Kind }}log.Info("validate create", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object creation.
- return nil
-}
-
-// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
-func (r *{{ .Resource.Kind }}) ValidateUpdate(old runtime.Object) error {
- {{ lower .Resource.Kind }}log.Info("validate update", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object update.
- return nil
-}
-
-// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
-func (r *{{ .Resource.Kind }}) ValidateDelete() error {
- {{ lower .Resource.Kind }}log.Info("validate delete", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object deletion.
- return nil
-}
-`
-)
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller.go
deleted file mode 100644
index e2dd50ddc34..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/controllers/controller.go
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "path/filepath"
-
- log "github.com/sirupsen/logrus"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Controller{}
-
-// Controller scaffolds the file that defines the controller for a CRD or a builtin resource
-// nolint:maligned
-type Controller struct {
- machinery.TemplateMixin
- machinery.MultiGroupMixin
- machinery.BoilerplateMixin
- machinery.ResourceMixin
-
- ControllerRuntimeVersion string
-
- Force bool
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Controller) SetTemplateDefaults() error {
- if f.Path == "" {
- if f.MultiGroup && f.Resource.Group != "" {
- f.Path = filepath.Join("controllers", "%[group]", "%[kind]_controller.go")
- } else {
- f.Path = filepath.Join("controllers", "%[kind]_controller.go")
- }
- }
- f.Path = f.Resource.Replacer().Replace(f.Path)
- log.Println(f.Path)
-
- f.TemplateBody = controllerTemplate
-
- if f.Force {
- f.IfExistsAction = machinery.OverwriteFile
- } else {
- f.IfExistsAction = machinery.Error
- }
-
- return nil
-}
-
-//nolint:lll
-const controllerTemplate = `{{ .Boilerplate }}
-
-package {{ if and .MultiGroup .Resource.Group }}{{ .Resource.PackageName }}{{ else }}controllers{{ end }}
-
-import (
- "context"
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/log"
- {{ if not (isEmptyStr .Resource.Path) -}}
- {{ .Resource.ImportAlias }} "{{ .Resource.Path }}"
- {{- end }}
-)
-
-// {{ .Resource.Kind }}Reconciler reconciles a {{ .Resource.Kind }} object
-type {{ .Resource.Kind }}Reconciler struct {
- client.Client
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }},verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }}/status,verbs=get;update;patch
-//+kubebuilder:rbac:groups={{ .Resource.QualifiedGroup }},resources={{ .Resource.Plural }}/finalizers,verbs=update
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the {{ .Resource.Kind }} object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@{{ .ControllerRuntimeVersion }}/pkg/reconcile
-func (r *{{ .Resource.Kind }}Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
- _ = log.FromContext(ctx)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *{{ .Resource.Kind }}Reconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- {{ if not (isEmptyStr .Resource.Path) -}}
- For(&{{ .Resource.ImportAlias }}.{{ .Resource.Kind }}{}).
- {{- else -}}
- // Uncomment the following line adding a pointer to an instance of the controlled resource as an argument
- // For().
- {{- end }}
- Complete(r)
-}
-`
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/dockerfile.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/dockerfile.go
deleted file mode 100644
index 1d1c1b53630..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/dockerfile.go
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Dockerfile{}
-
-// Dockerfile scaffolds a file that defines the containerized build process
-type Dockerfile struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Dockerfile) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = "Dockerfile"
- }
-
- f.TemplateBody = dockerfileTemplate
-
- return nil
-}
-
-const dockerfileTemplate = `# Build the manager binary
-FROM golang:1.19 as builder
-ARG TARGETOS
-ARG TARGETARCH
-
-WORKDIR /workspace
-# Copy the Go Modules manifests
-COPY go.mod go.mod
-COPY go.sum go.sum
-# cache deps before building and copying source so that we don't need to re-download as much
-# and so that source changes don't invalidate our downloaded layer
-RUN go mod download
-
-# Copy the go source
-COPY main.go main.go
-COPY api/ api/
-COPY controllers/ controllers/
-
-# 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
-
-# Use distroless as minimal base image to package the manager binary
-# Refer to https://github.com/GoogleContainerTools/distroless for more details
-FROM gcr.io/distroless/static:nonroot
-WORKDIR /
-COPY --from=builder /workspace/manager .
-USER 65532:65532
-
-ENTRYPOINT ["/manager"]
-`
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/dockerignore.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/dockerignore.go
deleted file mode 100644
index 3826dc2b8a0..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/dockerignore.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &DockerIgnore{}
-
-// DockerIgnore scaffolds a file that defines which files should be ignored by the containerized build process
-type DockerIgnore struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *DockerIgnore) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = ".dockerignore"
- }
-
- f.TemplateBody = dockerignorefileTemplate
-
- return nil
-}
-
-const dockerignorefileTemplate = `# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
-# Ignore build and test binaries.
-bin/
-testbin/
-`
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/gitignore.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/gitignore.go
deleted file mode 100644
index f79f6a32d65..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/gitignore.go
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &GitIgnore{}
-
-// GitIgnore scaffolds a file that defines which files should be ignored by git
-type GitIgnore struct {
- machinery.TemplateMixin
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *GitIgnore) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = ".gitignore"
- }
-
- f.TemplateBody = gitignoreTemplate
-
- return nil
-}
-
-const gitignoreTemplate = `
-# Binaries for programs and plugins
-*.exe
-*.exe~
-*.dll
-*.so
-*.dylib
-bin
-testbin/*
-Dockerfile.cross
-
-# Test binary, build with ` + "`go test -c`" + `
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# Kubernetes Generated files - skip generated files, except for vendored files
-
-!vendor/**/zz_generated.*
-
-# editor and IDE paraphernalia
-.idea
-.vscode
-*.swp
-*.swo
-*~
-`
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/gomod.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/gomod.go
deleted file mode 100644
index 0191ede9702..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/gomod.go
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &GoMod{}
-
-// GoMod scaffolds a file that defines the project dependencies
-type GoMod struct {
- machinery.TemplateMixin
- machinery.RepositoryMixin
-
- ControllerRuntimeVersion string
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *GoMod) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = "go.mod"
- }
-
- f.TemplateBody = goModTemplate
-
- f.IfExistsAction = machinery.OverwriteFile
-
- return nil
-}
-
-const goModTemplate = `
-module {{ .Repo }}
-
-go 1.19
-
-require (
- sigs.k8s.io/controller-runtime {{ .ControllerRuntimeVersion }}
-)
-`
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/hack/boilerplate.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/hack/boilerplate.go
deleted file mode 100644
index 3efbe592a54..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/hack/boilerplate.go
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package hack
-
-import (
- "fmt"
- "path/filepath"
- "time"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-// DefaultBoilerplatePath is the default path to the boilerplate file
-var DefaultBoilerplatePath = filepath.Join("hack", "boilerplate.go.txt")
-
-var _ machinery.Template = &Boilerplate{}
-
-// Boilerplate scaffolds a file that defines the common header for the rest of the files
-type Boilerplate struct {
- machinery.TemplateMixin
- machinery.BoilerplateMixin
-
- // License is the License type to write
- License string
-
- // Licenses maps License types to their actual string
- Licenses map[string]string
-
- // Owner is the copyright owner - e.g. "The Kubernetes Authors"
- Owner string
-
- // Year is the copyright year
- Year string
-}
-
-// Validate implements file.RequiresValidation
-func (f Boilerplate) Validate() error {
- if f.License == "" {
- // A default license will be set later
- } else if _, found := knownLicenses[f.License]; found {
- // One of the know licenses
- } else if _, found := f.Licenses[f.License]; found {
- // A map containing the requested license was also provided
- } else {
- return fmt.Errorf("unknown specified license %s", f.License)
- }
-
- return nil
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Boilerplate) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = DefaultBoilerplatePath
- }
-
- if f.License == "" {
- f.License = "apache2"
- }
-
- if f.Licenses == nil {
- f.Licenses = make(map[string]string, len(knownLicenses))
- }
-
- for key, value := range knownLicenses {
- if _, hasLicense := f.Licenses[key]; !hasLicense {
- f.Licenses[key] = value
- }
- }
-
- if f.Year == "" {
- f.Year = fmt.Sprintf("%v", time.Now().Year())
- }
-
- // Boilerplate given
- if len(f.Boilerplate) > 0 {
- f.TemplateBody = f.Boilerplate
- return nil
- }
-
- f.TemplateBody = boilerplateTemplate
-
- return nil
-}
-
-const boilerplateTemplate = `/*
-{{ if .Owner -}}
-Copyright {{ .Year }} {{ .Owner }}.
-{{- else -}}
-Copyright {{ .Year }}.
-{{- end }}
-{{ index .Licenses .License }}*/`
-
-var knownLicenses = map[string]string{
- "apache2": apache2,
- "none": "",
-}
-
-const apache2 = `
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-`
diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/readme.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/readme.go
deleted file mode 100644
index 577f5a62a49..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/internal/templates/readme.go
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-Copyright 2022 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package templates
-
-import (
- "fmt"
- "strings"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
-)
-
-var _ machinery.Template = &Readme{}
-
-// Readme scaffolds a README.md file
-type Readme struct {
- machinery.TemplateMixin
- machinery.BoilerplateMixin
- machinery.ProjectNameMixin
-
- License string
-}
-
-// SetTemplateDefaults implements file.Template
-func (f *Readme) SetTemplateDefaults() error {
- if f.Path == "" {
- f.Path = "README.md"
- }
-
- f.License = strings.Replace(
- strings.Replace(f.Boilerplate, "/*", "", 1),
- "*/", "", 1)
-
- f.TemplateBody = fmt.Sprintf(readmeFileTemplate,
- codeFence("kubectl apply -k config/samples/"),
- codeFence("make docker-build docker-push IMG=/{{ .ProjectName }}:tag"),
- codeFence("make deploy IMG=/{{ .ProjectName }}:tag"),
- codeFence("make uninstall"),
- codeFence("make undeploy"),
- codeFence("make install"),
- codeFence("make run"),
- codeFence("make manifests"))
-
- return nil
-}
-
-//nolint:lll
-const readmeFileTemplate = `# {{ .ProjectName }}
-// TODO(user): Add simple overview of use/purpose
-
-## Description
-// TODO(user): An in-depth paragraph about your project and overview of use
-
-## Getting Started
-You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster.
-**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster ` + "`kubectl cluster-info`" + ` shows).
-
-### Running on the cluster
-1. Install Instances of Custom Resources:
-
-%s
-
-2. Build and push your image to the location specified by ` + "`IMG`" + `:
-
-%s
-
-3. Deploy the controller to the cluster with the image specified by ` + "`IMG`" + `:
-
-%s
-
-### Uninstall CRDs
-To delete the CRDs from the cluster:
-
-%s
-
-### Undeploy controller
-UnDeploy the controller from the cluster:
-
-%s
-
-## Contributing
-// TODO(user): Add detailed information on how you would like others to contribute to this project
-
-### How it works
-This project aims to follow the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/).
-
-It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/),
-which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster.
-
-### Test It Out
-1. Install the CRDs into the cluster:
-
-%s
-
-2. Run your controller (this will run in the foreground, so switch to a new terminal if you want to leave it running):
-
-%s
-
-**NOTE:** You can also run this in one step by running: ` + "`make install run`" + `
-
-### Modifying the API definitions
-If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
-
-%s
-
-**NOTE:** Run ` + "`make --help`" + ` for more information on all potential ` + "`make`" + ` targets
-
-More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)
-
-## License
-{{ .License }}
-`
-
-func codeFence(code string) string {
- return "```sh" + "\n" + code + "\n" + "```"
-}
diff --git a/pkg/plugins/golang/v3/scaffolds/webhook.go b/pkg/plugins/golang/v3/scaffolds/webhook.go
deleted file mode 100644
index b77aefadbcc..00000000000
--- a/pkg/plugins/golang/v3/scaffolds/webhook.go
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package scaffolds
-
-import (
- "fmt"
-
- log "github.com/sirupsen/logrus"
- "github.com/spf13/afero"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "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/golang/v3/scaffolds/internal/templates"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds/internal/templates/api"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds/internal/templates/hack"
-)
-
-var _ plugins.Scaffolder = &webhookScaffolder{}
-
-type webhookScaffolder struct {
- config config.Config
- resource resource.Resource
-
- // fs is the filesystem that will be used by the scaffolder
- fs machinery.Filesystem
-
- // force indicates whether to scaffold controller files even if it exists or not
- force bool
-}
-
-// NewWebhookScaffolder returns a new Scaffolder for v2 webhook creation operations
-func NewWebhookScaffolder(config config.Config, resource resource.Resource, force bool) plugins.Scaffolder {
- return &webhookScaffolder{
- config: config,
- resource: resource,
- force: force,
- }
-}
-
-// InjectFS implements cmdutil.Scaffolder
-func (s *webhookScaffolder) InjectFS(fs machinery.Filesystem) {
- s.fs = fs
-}
-
-// Scaffold implements cmdutil.Scaffolder
-func (s *webhookScaffolder) Scaffold() error {
- log.Println("Writing scaffold for you to edit...")
-
- // Load the boilerplate
- boilerplate, err := afero.ReadFile(s.fs.FS, hack.DefaultBoilerplatePath)
- if err != nil {
- return fmt.Errorf("error scaffolding webhook: unable to load boilerplate: %w", err)
- }
-
- // Initialize the machinery.Scaffold that will write the files to disk
- scaffold := machinery.NewScaffold(s.fs,
- machinery.WithConfig(s.config),
- machinery.WithBoilerplate(string(boilerplate)),
- machinery.WithResource(&s.resource),
- )
-
- // Keep track of these values before the update
- doDefaulting := s.resource.HasDefaultingWebhook()
- doValidation := s.resource.HasValidationWebhook()
- doConversion := s.resource.HasConversionWebhook()
-
- if err := s.config.UpdateResource(s.resource); err != nil {
- return fmt.Errorf("error updating resource: %w", err)
- }
-
- if err := scaffold.Execute(
- &api.Webhook{Force: s.force},
- &templates.MainUpdater{WireWebhook: true},
- ); err != nil {
- return err
- }
-
- if doConversion {
- fmt.Println(`Webhook server has been set up for you.
-You need to implement the conversion.Hub and conversion.Convertible interfaces for your CRD types.`)
- }
-
- // TODO: Add test suite for conversion webhook after #1664 has been merged & conversion tests supported in envtest.
- if doDefaulting || doValidation {
- if err := scaffold.Execute(
- &api.WebhookSuite{},
- ); err != nil {
- return err
- }
- }
-
- return nil
-}
diff --git a/pkg/plugins/golang/v3/webhook.go b/pkg/plugins/golang/v3/webhook.go
deleted file mode 100644
index ef38fe1f5b8..00000000000
--- a/pkg/plugins/golang/v3/webhook.go
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
-Copyright 2020 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-//go:deprecated This package has been deprecated in favor of v4
-package v3
-
-import (
- "fmt"
-
- "github.com/spf13/pflag"
-
- "sigs.k8s.io/kubebuilder/v3/pkg/config"
- "sigs.k8s.io/kubebuilder/v3/pkg/machinery"
- "sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugin"
- pluginutil "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
- goPlugin "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang"
- "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3/scaffolds"
-)
-
-// defaultWebhookVersion is the default mutating/validating webhook config API version to scaffold.
-const defaultWebhookVersion = "v1"
-
-var _ plugin.CreateWebhookSubcommand = &createWebhookSubcommand{}
-
-type createWebhookSubcommand struct {
- config config.Config
- // For help text.
- commandName string
-
- options *goPlugin.Options
-
- resource *resource.Resource
-
- // force indicates that the resource should be created even if it already exists
- force bool
-}
-
-func (p *createWebhookSubcommand) UpdateMetadata(cliMeta plugin.CLIMetadata, subcmdMeta *plugin.SubcommandMetadata) {
- p.commandName = cliMeta.CommandName
-
- subcmdMeta.Description = `Scaffold a webhook for an API resource. You can choose to scaffold defaulting,
-validating and/or conversion webhooks.
-`
- subcmdMeta.Examples = fmt.Sprintf(` # Create defaulting and validating webhooks for Group: ship, Version: v1beta1
- # and Kind: Frigate
- %[1]s create webhook --group ship --version v1beta1 --kind Frigate --defaulting --programmatic-validation
-
- # Create conversion webhook for Group: ship, Version: v1beta1
- # and Kind: Frigate
- %[1]s create webhook --group ship --version v1beta1 --kind Frigate --conversion
-`, cliMeta.CommandName)
-}
-
-func (p *createWebhookSubcommand) BindFlags(fs *pflag.FlagSet) {
- p.options = &goPlugin.Options{}
-
- fs.StringVar(&p.options.Plural, "plural", "", "resource irregular plural form")
-
- fs.StringVar(&p.options.WebhookVersion, "webhook-version", defaultWebhookVersion,
- "version of {Mutating,Validating}WebhookConfigurations to scaffold. Options: [v1, v1beta1]")
- fs.BoolVar(&p.options.DoDefaulting, "defaulting", false,
- "if set, scaffold the defaulting webhook")
- fs.BoolVar(&p.options.DoValidation, "programmatic-validation", false,
- "if set, scaffold the validating webhook")
- fs.BoolVar(&p.options.DoConversion, "conversion", false,
- "if set, scaffold the conversion webhook")
-
- fs.BoolVar(&p.force, "force", false,
- "attempt to create resource even if it already exists")
-
- // (not required raise an error in this case)
- // nolint:errcheck,gosec
- fs.MarkDeprecated("webhook-version", deprecateMsg)
-}
-
-func (p *createWebhookSubcommand) InjectConfig(c config.Config) error {
- p.config = c
-
- return nil
-}
-
-func (p *createWebhookSubcommand) InjectResource(res *resource.Resource) error {
- p.resource = res
-
- p.options.UpdateResource(p.resource, p.config)
-
- if err := p.resource.Validate(); err != nil {
- return err
- }
-
- if !p.resource.HasDefaultingWebhook() && !p.resource.HasValidationWebhook() && !p.resource.HasConversionWebhook() {
- return fmt.Errorf("%s create webhook requires at least one of --defaulting,"+
- " --programmatic-validation and --conversion to be true", p.commandName)
- }
-
- // check if resource exist to create webhook
- if r, err := p.config.GetResource(p.resource.GVK); err != nil {
- return fmt.Errorf("%s create webhook requires a previously created API ", p.commandName)
- } else if r.Webhooks != nil && !r.Webhooks.IsEmpty() && !p.force {
- return fmt.Errorf("webhook resource already exists")
- }
-
- // nolint:staticcheck
- if pluginutil.HasDifferentWebhookVersion(p.config, p.resource.Webhooks.WebhookVersion) {
- return fmt.Errorf("only one webhook version can be used for all resources, cannot add %q",
- p.resource.Webhooks.WebhookVersion)
- }
-
- return nil
-}
-
-func (p *createWebhookSubcommand) Scaffold(fs machinery.Filesystem) error {
- scaffolder := scaffolds.NewWebhookScaffolder(p.config, *p.resource, p.force)
- scaffolder.InjectFS(fs)
- return scaffolder.Scaffold()
-}
-
-func (p *createWebhookSubcommand) PostScaffold() error {
- if p.resource.Webhooks.WebhookVersion == "v1beta1" {
- if err := applyScaffoldCustomizationsForVbeta1(); err != nil {
- return err
- }
- }
-
- err := pluginutil.RunCmd("Update dependencies", "go", "mod", "tidy")
- if err != nil {
- return err
- }
-
- err = pluginutil.RunCmd("Running make", "make", "generate")
- if err != nil {
- return err
- }
- fmt.Print("Next: implement your new Webhook and generate the manifests with:\n$ make manifests\n")
-
- return nil
-}
diff --git a/test/testdata/generate.sh b/test/testdata/generate.sh
index 64cfae3d60d..4e72116f234 100755
--- a/test/testdata/generate.sh
+++ b/test/testdata/generate.sh
@@ -127,12 +127,6 @@ function scaffold_test_project {
build_kb
-# [Deprecated] - Project version 2 uses plugin go/v2 (default).
-scaffold_test_project project-v2 --project-version=2
-
-# [Deprecated] - Project version 3 (default) uses plugin go/v3 (default).
-scaffold_test_project project-v3 --plugins="go/v3"
-
# [Currently, default CLI plugin] - [Next version, alpha] Project version v4-alpha
scaffold_test_project project-v4 --plugins="go/v4"
scaffold_test_project project-v4-multigroup --plugins="go/v4"
diff --git a/testdata/project-v2/.gitignore b/testdata/project-v2/.gitignore
deleted file mode 100644
index 4f592d7553b..00000000000
--- a/testdata/project-v2/.gitignore
+++ /dev/null
@@ -1,25 +0,0 @@
-
-# Binaries for programs and plugins
-*.exe
-*.exe~
-*.dll
-*.so
-*.dylib
-bin
-
-# Test binary, build with `go test -c`
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# Kubernetes Generated files - skip generated files, except for vendored files
-
-!vendor/**/zz_generated.*
-
-# editor and IDE paraphernalia
-.idea
-.vscode
-*.swp
-*.swo
-*~
diff --git a/testdata/project-v2/Dockerfile b/testdata/project-v2/Dockerfile
deleted file mode 100644
index 74eb9d7412f..00000000000
--- a/testdata/project-v2/Dockerfile
+++ /dev/null
@@ -1,27 +0,0 @@
-# Build the manager binary
-FROM golang:1.13 as builder
-
-WORKDIR /workspace
-# Copy the Go Modules manifests
-COPY go.mod go.mod
-COPY go.sum go.sum
-# cache deps before building and copying source so that we don't need to re-download as much
-# and so that source changes don't invalidate our downloaded layer
-RUN go mod download
-
-# Copy the go source
-COPY main.go main.go
-COPY api/ api/
-COPY controllers/ controllers/
-
-# Build
-RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go
-
-# Use distroless as minimal base image to package the manager binary
-# Refer to https://github.com/GoogleContainerTools/distroless for more details
-FROM gcr.io/distroless/static:nonroot
-WORKDIR /
-COPY --from=builder /workspace/manager .
-USER nonroot:nonroot
-
-ENTRYPOINT ["/manager"]
diff --git a/testdata/project-v2/Makefile b/testdata/project-v2/Makefile
deleted file mode 100644
index 09b2518aa71..00000000000
--- a/testdata/project-v2/Makefile
+++ /dev/null
@@ -1,125 +0,0 @@
-
-# Image URL to use all building/pushing image targets
-IMG ?= controller:latest
-# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
-CRD_OPTIONS ?= "crd:trivialVersions=true"
-
-# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
-ifeq (,$(shell go env GOBIN))
-GOBIN=$(shell go env GOPATH)/bin
-else
-GOBIN=$(shell go env GOBIN)
-endif
-
-.PHONY: all
-all: build
-
-##@ General
-
-# The help target prints out all targets with their descriptions organized
-# beneath their categories. The categories are represented by '##@' and the
-# target descriptions by '##'. The awk command is responsible for reading the
-# entire set of makefiles included in this invocation, looking for lines of the
-# file as xyz: ## something, and then pretty-format the target and help. Then,
-# if there's a line with ##@ something, that gets pretty-printed as a category.
-# More info on the usage of ANSI control characters for terminal formatting:
-# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
-# More info on the awk command:
-# http://linuxcommand.org/lc3_adv_awk.php
-
-.PHONY: help
-help: ## Display this help.
- @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
-
-##@ Development
-
-.PHONY: manifests
-manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
- $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
-
-.PHONY: generate
-generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
- $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
-
-.PHONY: fmt
-fmt: ## Run go fmt against code.
- go fmt ./...
-
-.PHONY: vet
-vet: ## Run go vet against code.
- go vet ./...
-
-.PHONY: test
-test: manifests generate fmt vet ## Run tests.
- go test ./... -coverprofile cover.out
-
-##@ Build
-
-.PHONY: build
-build: generate fmt vet ## Build manager binary.
- go build -o bin/manager main.go
-
-# Backwards compatibility
-.PHONY: manager
-manager: build ## Build manager binary (alias for build target).
-
-.PHONY: run
-run: manifests generate fmt vet ## Run a controller from your host.
- go run ./main.go
-
-.PHONY: docker-build
-docker-build: test ## Build docker image with the manager.
- docker build -t ${IMG} .
-
-.PHONY: docker-push
-docker-push: ## Push docker image with the manager.
- docker push ${IMG}
-
-##@ Deployment
-
-ifndef ignore-not-found
- ignore-not-found = false
-endif
-
-.PHONY: install
-install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
- $(KUSTOMIZE) build config/crd | kubectl apply -f -
-
-.PHONY: uninstall
-uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
- $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
-
-.PHONY: deploy
-deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
- cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
- $(KUSTOMIZE) build config/default | kubectl apply -f -
-
-.PHONY: undeploy
-undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
- $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
-
-##@ Build Dependencies
-
-## Location to install dependencies to
-LOCALBIN ?= $(shell pwd)/bin
-$(LOCALBIN): ## Ensure that the directory exists
- mkdir -p $(LOCALBIN)
-
-## Tool Binaries
-KUSTOMIZE ?= $(LOCALBIN)/kustomize
-CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
-
-## Tool Versions
-KUSTOMIZE_VERSION ?= v3.5.4
-CONTROLLER_TOOLS_VERSION ?= v0.3.0
-
-KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
-.PHONY: kustomize
-kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
-$(KUSTOMIZE): $(LOCALBIN)
- test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
-
-.PHONY: controller-gen
-controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
-$(CONTROLLER_GEN): $(LOCALBIN)
- test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
diff --git a/testdata/project-v2/PROJECT b/testdata/project-v2/PROJECT
deleted file mode 100644
index 53085282124..00000000000
--- a/testdata/project-v2/PROJECT
+++ /dev/null
@@ -1,17 +0,0 @@
-# Code generated by tool. DO NOT EDIT.
-# This file is used to track the info used to scaffold your project
-# and allow the plugins properly work.
-# More info: https://book.kubebuilder.io/reference/project-config.html
-domain: testproject.org
-repo: sigs.k8s.io/kubebuilder/testdata/project-v2
-resources:
-- group: crew
- kind: Captain
- version: v1
-- group: crew
- kind: FirstMate
- version: v1
-- group: crew
- kind: Admiral
- version: v1
-version: "2"
diff --git a/testdata/project-v2/api/v1/admiral_types.go b/testdata/project-v2/api/v1/admiral_types.go
deleted file mode 100644
index e27821bfc90..00000000000
--- a/testdata/project-v2/api/v1/admiral_types.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// AdmiralSpec defines the desired state of Admiral
-type AdmiralSpec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-
- // Foo is an example field of Admiral. Edit admiral_types.go to remove/update
- Foo string `json:"foo,omitempty"`
-}
-
-// AdmiralStatus defines the observed state of Admiral
-type AdmiralStatus struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-}
-
-//+kubebuilder:object:root=true
-//+kubebuilder:subresource:status
-//+kubebuilder:resource:scope=Cluster
-
-// Admiral is the Schema for the admirals API
-type Admiral struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ObjectMeta `json:"metadata,omitempty"`
-
- Spec AdmiralSpec `json:"spec,omitempty"`
- Status AdmiralStatus `json:"status,omitempty"`
-}
-
-//+kubebuilder:object:root=true
-
-// AdmiralList contains a list of Admiral
-type AdmiralList struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ListMeta `json:"metadata,omitempty"`
- Items []Admiral `json:"items"`
-}
-
-func init() {
- SchemeBuilder.Register(&Admiral{}, &AdmiralList{})
-}
diff --git a/testdata/project-v2/api/v1/admiral_webhook.go b/testdata/project-v2/api/v1/admiral_webhook.go
deleted file mode 100644
index f3988891d8f..00000000000
--- a/testdata/project-v2/api/v1/admiral_webhook.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- ctrl "sigs.k8s.io/controller-runtime"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
- "sigs.k8s.io/controller-runtime/pkg/webhook"
-)
-
-// log is for logging in this package.
-var admirallog = logf.Log.WithName("admiral-resource")
-
-func (r *Admiral) SetupWebhookWithManager(mgr ctrl.Manager) error {
- return ctrl.NewWebhookManagedBy(mgr).
- For(r).
- Complete()
-}
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-
-//+kubebuilder:webhook:path=/mutate-crew-testproject-org-v1-admiral,mutating=true,failurePolicy=fail,groups=crew.testproject.org,resources=admirals,verbs=create;update,versions=v1,name=madmiral.kb.io
-
-var _ webhook.Defaulter = &Admiral{}
-
-// Default implements webhook.Defaulter so a webhook will be registered for the type
-func (r *Admiral) Default() {
- admirallog.Info("default", "name", r.Name)
-
- // TODO(user): fill in your defaulting logic.
-}
diff --git a/testdata/project-v2/api/v1/captain_types.go b/testdata/project-v2/api/v1/captain_types.go
deleted file mode 100644
index f7b87f2a264..00000000000
--- a/testdata/project-v2/api/v1/captain_types.go
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// CaptainSpec defines the desired state of Captain
-type CaptainSpec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-
- // Foo is an example field of Captain. Edit captain_types.go to remove/update
- Foo string `json:"foo,omitempty"`
-}
-
-// CaptainStatus defines the observed state of Captain
-type CaptainStatus struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-}
-
-//+kubebuilder:object:root=true
-//+kubebuilder:subresource:status
-
-// Captain is the Schema for the captains API
-type Captain struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ObjectMeta `json:"metadata,omitempty"`
-
- Spec CaptainSpec `json:"spec,omitempty"`
- Status CaptainStatus `json:"status,omitempty"`
-}
-
-//+kubebuilder:object:root=true
-
-// CaptainList contains a list of Captain
-type CaptainList struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ListMeta `json:"metadata,omitempty"`
- Items []Captain `json:"items"`
-}
-
-func init() {
- SchemeBuilder.Register(&Captain{}, &CaptainList{})
-}
diff --git a/testdata/project-v2/api/v1/captain_webhook.go b/testdata/project-v2/api/v1/captain_webhook.go
deleted file mode 100644
index d291d5b0ba1..00000000000
--- a/testdata/project-v2/api/v1/captain_webhook.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
- "sigs.k8s.io/controller-runtime/pkg/webhook"
-)
-
-// log is for logging in this package.
-var captainlog = logf.Log.WithName("captain-resource")
-
-func (r *Captain) SetupWebhookWithManager(mgr ctrl.Manager) error {
- return ctrl.NewWebhookManagedBy(mgr).
- For(r).
- Complete()
-}
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-
-//+kubebuilder:webhook:path=/mutate-crew-testproject-org-v1-captain,mutating=true,failurePolicy=fail,groups=crew.testproject.org,resources=captains,verbs=create;update,versions=v1,name=mcaptain.kb.io
-
-var _ webhook.Defaulter = &Captain{}
-
-// Default implements webhook.Defaulter so a webhook will be registered for the type
-func (r *Captain) Default() {
- captainlog.Info("default", "name", r.Name)
-
- // TODO(user): fill in your defaulting logic.
-}
-
-// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
-//+kubebuilder:webhook:verbs=create;update,path=/validate-crew-testproject-org-v1-captain,mutating=false,failurePolicy=fail,groups=crew.testproject.org,resources=captains,versions=v1,name=vcaptain.kb.io
-
-var _ webhook.Validator = &Captain{}
-
-// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
-func (r *Captain) ValidateCreate() error {
- captainlog.Info("validate create", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object creation.
- return nil
-}
-
-// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
-func (r *Captain) ValidateUpdate(old runtime.Object) error {
- captainlog.Info("validate update", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object update.
- return nil
-}
-
-// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
-func (r *Captain) ValidateDelete() error {
- captainlog.Info("validate delete", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object deletion.
- return nil
-}
diff --git a/testdata/project-v2/api/v1/firstmate_types.go b/testdata/project-v2/api/v1/firstmate_types.go
deleted file mode 100644
index 1e38fa31adf..00000000000
--- a/testdata/project-v2/api/v1/firstmate_types.go
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// FirstMateSpec defines the desired state of FirstMate
-type FirstMateSpec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-
- // Foo is an example field of FirstMate. Edit firstmate_types.go to remove/update
- Foo string `json:"foo,omitempty"`
-}
-
-// FirstMateStatus defines the observed state of FirstMate
-type FirstMateStatus struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-}
-
-//+kubebuilder:object:root=true
-//+kubebuilder:subresource:status
-
-// FirstMate is the Schema for the firstmates API
-type FirstMate struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ObjectMeta `json:"metadata,omitempty"`
-
- Spec FirstMateSpec `json:"spec,omitempty"`
- Status FirstMateStatus `json:"status,omitempty"`
-}
-
-//+kubebuilder:object:root=true
-
-// FirstMateList contains a list of FirstMate
-type FirstMateList struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ListMeta `json:"metadata,omitempty"`
- Items []FirstMate `json:"items"`
-}
-
-func init() {
- SchemeBuilder.Register(&FirstMate{}, &FirstMateList{})
-}
diff --git a/testdata/project-v2/api/v1/firstmate_webhook.go b/testdata/project-v2/api/v1/firstmate_webhook.go
deleted file mode 100644
index 788e74e7a5b..00000000000
--- a/testdata/project-v2/api/v1/firstmate_webhook.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- ctrl "sigs.k8s.io/controller-runtime"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
-)
-
-// log is for logging in this package.
-var firstmatelog = logf.Log.WithName("firstmate-resource")
-
-func (r *FirstMate) SetupWebhookWithManager(mgr ctrl.Manager) error {
- return ctrl.NewWebhookManagedBy(mgr).
- For(r).
- Complete()
-}
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
diff --git a/testdata/project-v2/api/v1/groupversion_info.go b/testdata/project-v2/api/v1/groupversion_info.go
deleted file mode 100644
index b2b4c7e7335..00000000000
--- a/testdata/project-v2/api/v1/groupversion_info.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Package v1 contains API Schema definitions for the crew v1 API group
-// +kubebuilder:object:generate=true
-// +groupName=crew.testproject.org
-package v1
-
-import (
- "k8s.io/apimachinery/pkg/runtime/schema"
- "sigs.k8s.io/controller-runtime/pkg/scheme"
-)
-
-var (
- // GroupVersion is group version used to register these objects
- GroupVersion = schema.GroupVersion{Group: "crew.testproject.org", Version: "v1"}
-
- // SchemeBuilder is used to add go types to the GroupVersionKind scheme
- SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
-
- // AddToScheme adds the types in this group-version to the given scheme.
- AddToScheme = SchemeBuilder.AddToScheme
-)
diff --git a/testdata/project-v2/api/v1/zz_generated.deepcopy.go b/testdata/project-v2/api/v1/zz_generated.deepcopy.go
deleted file mode 100644
index e6d9ca566eb..00000000000
--- a/testdata/project-v2/api/v1/zz_generated.deepcopy.go
+++ /dev/null
@@ -1,293 +0,0 @@
-//go:build !ignore_autogenerated
-// +build !ignore_autogenerated
-
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by controller-gen. DO NOT EDIT.
-
-package v1
-
-import (
- "k8s.io/apimachinery/pkg/runtime"
-)
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *Admiral) DeepCopyInto(out *Admiral) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
- out.Spec = in.Spec
- out.Status = in.Status
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Admiral.
-func (in *Admiral) DeepCopy() *Admiral {
- if in == nil {
- return nil
- }
- out := new(Admiral)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *Admiral) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *AdmiralList) DeepCopyInto(out *AdmiralList) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ListMeta.DeepCopyInto(&out.ListMeta)
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]Admiral, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralList.
-func (in *AdmiralList) DeepCopy() *AdmiralList {
- if in == nil {
- return nil
- }
- out := new(AdmiralList)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *AdmiralList) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *AdmiralSpec) DeepCopyInto(out *AdmiralSpec) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralSpec.
-func (in *AdmiralSpec) DeepCopy() *AdmiralSpec {
- if in == nil {
- return nil
- }
- out := new(AdmiralSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *AdmiralStatus) DeepCopyInto(out *AdmiralStatus) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralStatus.
-func (in *AdmiralStatus) DeepCopy() *AdmiralStatus {
- if in == nil {
- return nil
- }
- out := new(AdmiralStatus)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *Captain) DeepCopyInto(out *Captain) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
- out.Spec = in.Spec
- out.Status = in.Status
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Captain.
-func (in *Captain) DeepCopy() *Captain {
- if in == nil {
- return nil
- }
- out := new(Captain)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *Captain) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CaptainList) DeepCopyInto(out *CaptainList) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ListMeta.DeepCopyInto(&out.ListMeta)
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]Captain, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainList.
-func (in *CaptainList) DeepCopy() *CaptainList {
- if in == nil {
- return nil
- }
- out := new(CaptainList)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *CaptainList) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CaptainSpec) DeepCopyInto(out *CaptainSpec) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainSpec.
-func (in *CaptainSpec) DeepCopy() *CaptainSpec {
- if in == nil {
- return nil
- }
- out := new(CaptainSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CaptainStatus) DeepCopyInto(out *CaptainStatus) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainStatus.
-func (in *CaptainStatus) DeepCopy() *CaptainStatus {
- if in == nil {
- return nil
- }
- out := new(CaptainStatus)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FirstMate) DeepCopyInto(out *FirstMate) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
- out.Spec = in.Spec
- out.Status = in.Status
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMate.
-func (in *FirstMate) DeepCopy() *FirstMate {
- if in == nil {
- return nil
- }
- out := new(FirstMate)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *FirstMate) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FirstMateList) DeepCopyInto(out *FirstMateList) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ListMeta.DeepCopyInto(&out.ListMeta)
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]FirstMate, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateList.
-func (in *FirstMateList) DeepCopy() *FirstMateList {
- if in == nil {
- return nil
- }
- out := new(FirstMateList)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *FirstMateList) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FirstMateSpec) DeepCopyInto(out *FirstMateSpec) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateSpec.
-func (in *FirstMateSpec) DeepCopy() *FirstMateSpec {
- if in == nil {
- return nil
- }
- out := new(FirstMateSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FirstMateStatus) DeepCopyInto(out *FirstMateStatus) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateStatus.
-func (in *FirstMateStatus) DeepCopy() *FirstMateStatus {
- if in == nil {
- return nil
- }
- out := new(FirstMateStatus)
- in.DeepCopyInto(out)
- return out
-}
diff --git a/testdata/project-v2/config/certmanager/certificate.yaml b/testdata/project-v2/config/certmanager/certificate.yaml
deleted file mode 100644
index 3d46cff8847..00000000000
--- a/testdata/project-v2/config/certmanager/certificate.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-# The following manifests contain a self-signed issuer CR and a certificate CR.
-# More document can be found at https://docs.cert-manager.io
-# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for
-# breaking changes
-apiVersion: cert-manager.io/v1alpha2
-kind: Issuer
-metadata:
- name: selfsigned-issuer
- namespace: system
-spec:
- selfSigned: {}
----
-apiVersion: cert-manager.io/v1alpha2
-kind: Certificate
-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
- dnsNames:
- - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
- issuerRef:
- kind: Issuer
- name: selfsigned-issuer
- secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
diff --git a/testdata/project-v2/config/certmanager/kustomization.yaml b/testdata/project-v2/config/certmanager/kustomization.yaml
deleted file mode 100644
index bebea5a595e..00000000000
--- a/testdata/project-v2/config/certmanager/kustomization.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-resources:
-- certificate.yaml
-
-configurations:
-- kustomizeconfig.yaml
diff --git a/testdata/project-v2/config/certmanager/kustomizeconfig.yaml b/testdata/project-v2/config/certmanager/kustomizeconfig.yaml
deleted file mode 100644
index e631f777366..00000000000
--- a/testdata/project-v2/config/certmanager/kustomizeconfig.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# This configuration is for teaching kustomize how to update name ref and var substitution
-nameReference:
-- kind: Issuer
- group: cert-manager.io
- fieldSpecs:
- - 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/testdata/project-v2/config/crd/bases/crew.testproject.org_admirals.yaml b/testdata/project-v2/config/crd/bases/crew.testproject.org_admirals.yaml
deleted file mode 100644
index ceba98ca231..00000000000
--- a/testdata/project-v2/config/crd/bases/crew.testproject.org_admirals.yaml
+++ /dev/null
@@ -1,58 +0,0 @@
-
----
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- controller-gen.kubebuilder.io/version: v0.3.0
- creationTimestamp: null
- name: admirals.crew.testproject.org
-spec:
- group: crew.testproject.org
- names:
- kind: Admiral
- listKind: AdmiralList
- plural: admirals
- singular: admiral
- scope: Cluster
- subresources:
- status: {}
- validation:
- openAPIV3Schema:
- description: Admiral is the Schema for the admirals API
- properties:
- apiVersion:
- description: 'APIVersion defines the versioned schema of this representation
- of an object. Servers should convert recognized schemas to the latest
- internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
- type: string
- kind:
- description: 'Kind is a string value representing the REST resource this
- object represents. Servers may infer this from the endpoint the client
- submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
- type: string
- metadata:
- type: object
- spec:
- description: AdmiralSpec defines the desired state of Admiral
- properties:
- foo:
- description: Foo is an example field of Admiral. Edit admiral_types.go
- to remove/update
- type: string
- type: object
- status:
- description: AdmiralStatus defines the observed state of Admiral
- type: object
- type: object
- version: v1
- versions:
- - name: v1
- served: true
- storage: true
-status:
- acceptedNames:
- kind: ""
- plural: ""
- conditions: []
- storedVersions: []
diff --git a/testdata/project-v2/config/crd/bases/crew.testproject.org_captains.yaml b/testdata/project-v2/config/crd/bases/crew.testproject.org_captains.yaml
deleted file mode 100644
index 5b0580f100e..00000000000
--- a/testdata/project-v2/config/crd/bases/crew.testproject.org_captains.yaml
+++ /dev/null
@@ -1,58 +0,0 @@
-
----
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- controller-gen.kubebuilder.io/version: v0.3.0
- creationTimestamp: null
- name: captains.crew.testproject.org
-spec:
- group: crew.testproject.org
- names:
- kind: Captain
- listKind: CaptainList
- plural: captains
- singular: captain
- scope: Namespaced
- subresources:
- status: {}
- validation:
- openAPIV3Schema:
- description: Captain is the Schema for the captains API
- properties:
- apiVersion:
- description: 'APIVersion defines the versioned schema of this representation
- of an object. Servers should convert recognized schemas to the latest
- internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
- type: string
- kind:
- description: 'Kind is a string value representing the REST resource this
- object represents. Servers may infer this from the endpoint the client
- submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
- type: string
- metadata:
- type: object
- spec:
- description: CaptainSpec defines the desired state of Captain
- properties:
- foo:
- description: Foo is an example field of Captain. Edit captain_types.go
- to remove/update
- type: string
- type: object
- status:
- description: CaptainStatus defines the observed state of Captain
- type: object
- type: object
- version: v1
- versions:
- - name: v1
- served: true
- storage: true
-status:
- acceptedNames:
- kind: ""
- plural: ""
- conditions: []
- storedVersions: []
diff --git a/testdata/project-v2/config/crd/bases/crew.testproject.org_firstmates.yaml b/testdata/project-v2/config/crd/bases/crew.testproject.org_firstmates.yaml
deleted file mode 100644
index 499d4131a73..00000000000
--- a/testdata/project-v2/config/crd/bases/crew.testproject.org_firstmates.yaml
+++ /dev/null
@@ -1,58 +0,0 @@
-
----
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- controller-gen.kubebuilder.io/version: v0.3.0
- creationTimestamp: null
- name: firstmates.crew.testproject.org
-spec:
- group: crew.testproject.org
- names:
- kind: FirstMate
- listKind: FirstMateList
- plural: firstmates
- singular: firstmate
- scope: Namespaced
- subresources:
- status: {}
- validation:
- openAPIV3Schema:
- description: FirstMate is the Schema for the firstmates API
- properties:
- apiVersion:
- description: 'APIVersion defines the versioned schema of this representation
- of an object. Servers should convert recognized schemas to the latest
- internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
- type: string
- kind:
- description: 'Kind is a string value representing the REST resource this
- object represents. Servers may infer this from the endpoint the client
- submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
- type: string
- metadata:
- type: object
- spec:
- description: FirstMateSpec defines the desired state of FirstMate
- properties:
- foo:
- description: Foo is an example field of FirstMate. Edit firstmate_types.go
- to remove/update
- type: string
- type: object
- status:
- description: FirstMateStatus defines the observed state of FirstMate
- type: object
- type: object
- version: v1
- versions:
- - name: v1
- served: true
- storage: true
-status:
- acceptedNames:
- kind: ""
- plural: ""
- conditions: []
- storedVersions: []
diff --git a/testdata/project-v2/config/crd/kustomization.yaml b/testdata/project-v2/config/crd/kustomization.yaml
deleted file mode 100644
index 37c36ffdebd..00000000000
--- a/testdata/project-v2/config/crd/kustomization.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-# This kustomization.yaml is not intended to be run by itself,
-# since it depends on service name and namespace that are out of this kustomize package.
-# It should be run by config/default
-resources:
-- bases/crew.testproject.org_captains.yaml
-- bases/crew.testproject.org_firstmates.yaml
-- bases/crew.testproject.org_admirals.yaml
-#+kubebuilder:scaffold:crdkustomizeresource
-
-patchesStrategicMerge:
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
-# patches here are for enabling the conversion webhook for each CRD
-#- patches/webhook_in_captains.yaml
-#- patches/webhook_in_firstmates.yaml
-#- patches/webhook_in_admirals.yaml
-#+kubebuilder:scaffold:crdkustomizewebhookpatch
-
-# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
-# patches here are for enabling the CA injection for each CRD
-#- patches/cainjection_in_captains.yaml
-#- patches/cainjection_in_firstmates.yaml
-#- patches/cainjection_in_admirals.yaml
-#+kubebuilder:scaffold:crdkustomizecainjectionpatch
-
-# the following config is for teaching kustomize how to do kustomization for CRDs.
-configurations:
-- kustomizeconfig.yaml
diff --git a/testdata/project-v2/config/crd/kustomizeconfig.yaml b/testdata/project-v2/config/crd/kustomizeconfig.yaml
deleted file mode 100644
index 6f83d9a94bc..00000000000
--- a/testdata/project-v2/config/crd/kustomizeconfig.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is for teaching kustomize how to substitute name and namespace reference in CRD
-nameReference:
-- kind: Service
- version: v1
- fieldSpecs:
- - kind: CustomResourceDefinition
- group: apiextensions.k8s.io
- path: spec/conversion/webhookClientConfig/service/name
-
-namespace:
-- kind: CustomResourceDefinition
- group: apiextensions.k8s.io
- path: spec/conversion/webhookClientConfig/service/namespace
- create: false
-
-varReference:
-- path: metadata/annotations
diff --git a/testdata/project-v2/config/crd/patches/cainjection_in_admirals.yaml b/testdata/project-v2/config/crd/patches/cainjection_in_admirals.yaml
deleted file mode 100644
index 8573317f652..00000000000
--- a/testdata/project-v2/config/crd/patches/cainjection_in_admirals.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-# The following patch adds a directive for certmanager to inject CA into the CRD
-# CRD conversion requires k8s 1.13 or later.
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
- name: admirals.crew.testproject.org
diff --git a/testdata/project-v2/config/crd/patches/cainjection_in_captains.yaml b/testdata/project-v2/config/crd/patches/cainjection_in_captains.yaml
deleted file mode 100644
index 72918ce20f4..00000000000
--- a/testdata/project-v2/config/crd/patches/cainjection_in_captains.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-# The following patch adds a directive for certmanager to inject CA into the CRD
-# CRD conversion requires k8s 1.13 or later.
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
- name: captains.crew.testproject.org
diff --git a/testdata/project-v2/config/crd/patches/cainjection_in_firstmates.yaml b/testdata/project-v2/config/crd/patches/cainjection_in_firstmates.yaml
deleted file mode 100644
index 271b973cb56..00000000000
--- a/testdata/project-v2/config/crd/patches/cainjection_in_firstmates.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-# The following patch adds a directive for certmanager to inject CA into the CRD
-# CRD conversion requires k8s 1.13 or later.
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
- name: firstmates.crew.testproject.org
diff --git a/testdata/project-v2/config/crd/patches/webhook_in_admirals.yaml b/testdata/project-v2/config/crd/patches/webhook_in_admirals.yaml
deleted file mode 100644
index 2b9bf612404..00000000000
--- a/testdata/project-v2/config/crd/patches/webhook_in_admirals.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-# The following patch enables conversion webhook for CRD
-# CRD conversion requires k8s 1.13 or later.
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- name: admirals.crew.testproject.org
-spec:
- conversion:
- strategy: Webhook
- webhookClientConfig:
- # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
- # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
- caBundle: Cg==
- service:
- namespace: system
- name: webhook-service
- path: /convert
diff --git a/testdata/project-v2/config/crd/patches/webhook_in_captains.yaml b/testdata/project-v2/config/crd/patches/webhook_in_captains.yaml
deleted file mode 100644
index c515517131e..00000000000
--- a/testdata/project-v2/config/crd/patches/webhook_in_captains.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-# The following patch enables conversion webhook for CRD
-# CRD conversion requires k8s 1.13 or later.
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- name: captains.crew.testproject.org
-spec:
- conversion:
- strategy: Webhook
- webhookClientConfig:
- # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
- # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
- caBundle: Cg==
- service:
- namespace: system
- name: webhook-service
- path: /convert
diff --git a/testdata/project-v2/config/crd/patches/webhook_in_firstmates.yaml b/testdata/project-v2/config/crd/patches/webhook_in_firstmates.yaml
deleted file mode 100644
index 05c23fd1e8b..00000000000
--- a/testdata/project-v2/config/crd/patches/webhook_in_firstmates.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-# The following patch enables conversion webhook for CRD
-# CRD conversion requires k8s 1.13 or later.
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- name: firstmates.crew.testproject.org
-spec:
- conversion:
- strategy: Webhook
- webhookClientConfig:
- # this is "\n" used as a placeholder, otherwise it will be rejected by the apiserver for being blank,
- # but we're going to set it later using the cert-manager (or potentially a patch if not using cert-manager)
- caBundle: Cg==
- service:
- namespace: system
- name: webhook-service
- path: /convert
diff --git a/testdata/project-v2/config/default/kustomization.yaml b/testdata/project-v2/config/default/kustomization.yaml
deleted file mode 100644
index 9efc436ae78..00000000000
--- a/testdata/project-v2/config/default/kustomization.yaml
+++ /dev/null
@@ -1,70 +0,0 @@
-# Adds namespace to all resources.
-namespace: project-v2-system
-
-# Value of this field is prepended to the
-# names of all resources, e.g. a deployment named
-# "wordpress" becomes "alices-wordpress".
-# Note that it should also match with the prefix (text before '-') of the namespace
-# field above.
-namePrefix: project-v2-
-
-# Labels to add to all resources and selectors.
-#commonLabels:
-# someName: someValue
-
-bases:
-- ../crd
-- ../rbac
-- ../manager
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
-# crd/kustomization.yaml
-#- ../webhook
-# [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
-
-patchesStrategicMerge:
- # Protect the /metrics endpoint by putting it behind auth.
- # If you want your controller-manager to expose the /metrics
- # endpoint w/o any authn/z, please comment the following line.
-- manager_auth_proxy_patch.yaml
-
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
-# crd/kustomization.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: v1alpha2
-# 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: v1alpha2
-# 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
diff --git a/testdata/project-v2/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v2/config/default/manager_auth_proxy_patch.yaml
deleted file mode 100644
index 1d471f711eb..00000000000
--- a/testdata/project-v2/config/default/manager_auth_proxy_patch.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-# This patch inject a sidecar container which is a HTTP proxy for the
-# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
-spec:
- template:
- spec:
- containers:
- - name: kube-rbac-proxy
- image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
- args:
- - "--secure-listen-address=0.0.0.0:8443"
- - "--upstream=http://127.0.0.1:8080/"
- - "--logtostderr=true"
- - "--v=10"
- ports:
- - containerPort: 8443
- name: https
- - name: manager
- args:
- - "--metrics-addr=127.0.0.1:8080"
- - "--enable-leader-election"
diff --git a/testdata/project-v2/config/default/manager_webhook_patch.yaml b/testdata/project-v2/config/default/manager_webhook_patch.yaml
deleted file mode 100644
index 738de350b71..00000000000
--- a/testdata/project-v2/config/default/manager_webhook_patch.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
-spec:
- template:
- spec:
- containers:
- - name: manager
- ports:
- - containerPort: 9443
- name: webhook-server
- protocol: TCP
- volumeMounts:
- - mountPath: /tmp/k8s-webhook-server/serving-certs
- name: cert
- readOnly: true
- volumes:
- - name: cert
- secret:
- defaultMode: 420
- secretName: webhook-server-cert
diff --git a/testdata/project-v2/config/default/webhookcainjection_patch.yaml b/testdata/project-v2/config/default/webhookcainjection_patch.yaml
deleted file mode 100644
index 7e79bf9955a..00000000000
--- a/testdata/project-v2/config/default/webhookcainjection_patch.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-# This patch add annotation to admission webhook config and
-# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize.
-apiVersion: admissionregistration.k8s.io/v1beta1
-kind: MutatingWebhookConfiguration
-metadata:
- name: mutating-webhook-configuration
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
----
-apiVersion: admissionregistration.k8s.io/v1beta1
-kind: ValidatingWebhookConfiguration
-metadata:
- name: validating-webhook-configuration
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
diff --git a/testdata/project-v2/config/manager/kustomization.yaml b/testdata/project-v2/config/manager/kustomization.yaml
deleted file mode 100644
index 5c5f0b84cba..00000000000
--- a/testdata/project-v2/config/manager/kustomization.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-resources:
-- manager.yaml
diff --git a/testdata/project-v2/config/manager/manager.yaml b/testdata/project-v2/config/manager/manager.yaml
deleted file mode 100644
index b6c85a52d5f..00000000000
--- a/testdata/project-v2/config/manager/manager.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-apiVersion: v1
-kind: Namespace
-metadata:
- labels:
- control-plane: controller-manager
- name: system
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
- labels:
- control-plane: controller-manager
-spec:
- selector:
- matchLabels:
- control-plane: controller-manager
- replicas: 1
- template:
- metadata:
- labels:
- control-plane: controller-manager
- spec:
- containers:
- - command:
- - /manager
- args:
- - --enable-leader-election
- image: controller:latest
- name: manager
- resources:
- limits:
- cpu: 100m
- memory: 30Mi
- requests:
- cpu: 100m
- memory: 20Mi
- terminationGracePeriodSeconds: 10
diff --git a/testdata/project-v2/config/prometheus/kustomization.yaml b/testdata/project-v2/config/prometheus/kustomization.yaml
deleted file mode 100644
index ed137168a1d..00000000000
--- a/testdata/project-v2/config/prometheus/kustomization.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-resources:
-- monitor.yaml
diff --git a/testdata/project-v2/config/prometheus/monitor.yaml b/testdata/project-v2/config/prometheus/monitor.yaml
deleted file mode 100644
index d19136ae710..00000000000
--- a/testdata/project-v2/config/prometheus/monitor.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-# Prometheus Monitor Service (Metrics)
-apiVersion: monitoring.coreos.com/v1
-kind: ServiceMonitor
-metadata:
- labels:
- control-plane: controller-manager
- name: controller-manager-metrics-monitor
- namespace: system
-spec:
- endpoints:
- - path: /metrics
- port: https
- scheme: https
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
- tlsConfig:
- insecureSkipVerify: true
- selector:
- matchLabels:
- control-plane: controller-manager
diff --git a/testdata/project-v2/config/rbac/admiral_editor_role.yaml b/testdata/project-v2/config/rbac/admiral_editor_role.yaml
deleted file mode 100644
index 7f2cc5cd99f..00000000000
--- a/testdata/project-v2/config/rbac/admiral_editor_role.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-# permissions for end users to edit admirals.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: admiral-editor-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirals
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirals/status
- verbs:
- - get
diff --git a/testdata/project-v2/config/rbac/admiral_viewer_role.yaml b/testdata/project-v2/config/rbac/admiral_viewer_role.yaml
deleted file mode 100644
index ddbb0c2a85b..00000000000
--- a/testdata/project-v2/config/rbac/admiral_viewer_role.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-# permissions for end users to view admirals.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: admiral-viewer-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirals
- verbs:
- - get
- - list
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirals/status
- verbs:
- - get
diff --git a/testdata/project-v2/config/rbac/auth_proxy_client_clusterrole.yaml b/testdata/project-v2/config/rbac/auth_proxy_client_clusterrole.yaml
deleted file mode 100644
index bd4af137a9f..00000000000
--- a/testdata/project-v2/config/rbac/auth_proxy_client_clusterrole.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: metrics-reader
-rules:
-- nonResourceURLs: ["/metrics"]
- verbs: ["get"]
diff --git a/testdata/project-v2/config/rbac/auth_proxy_role.yaml b/testdata/project-v2/config/rbac/auth_proxy_role.yaml
deleted file mode 100644
index 618f5e4177c..00000000000
--- a/testdata/project-v2/config/rbac/auth_proxy_role.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: proxy-role
-rules:
-- apiGroups: ["authentication.k8s.io"]
- resources:
- - tokenreviews
- verbs: ["create"]
-- apiGroups: ["authorization.k8s.io"]
- resources:
- - subjectaccessreviews
- verbs: ["create"]
diff --git a/testdata/project-v2/config/rbac/auth_proxy_role_binding.yaml b/testdata/project-v2/config/rbac/auth_proxy_role_binding.yaml
deleted file mode 100644
index 48ed1e4b85c..00000000000
--- a/testdata/project-v2/config/rbac/auth_proxy_role_binding.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
- name: proxy-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: proxy-role
-subjects:
-- kind: ServiceAccount
- name: default
- namespace: system
diff --git a/testdata/project-v2/config/rbac/auth_proxy_service.yaml b/testdata/project-v2/config/rbac/auth_proxy_service.yaml
deleted file mode 100644
index 6cf656be149..00000000000
--- a/testdata/project-v2/config/rbac/auth_proxy_service.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
- labels:
- control-plane: controller-manager
- name: controller-manager-metrics-service
- namespace: system
-spec:
- ports:
- - name: https
- port: 8443
- targetPort: https
- selector:
- control-plane: controller-manager
diff --git a/testdata/project-v2/config/rbac/captain_editor_role.yaml b/testdata/project-v2/config/rbac/captain_editor_role.yaml
deleted file mode 100644
index 4b53ae38ffa..00000000000
--- a/testdata/project-v2/config/rbac/captain_editor_role.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-# permissions for end users to edit captains.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: captain-editor-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains/status
- verbs:
- - get
diff --git a/testdata/project-v2/config/rbac/captain_viewer_role.yaml b/testdata/project-v2/config/rbac/captain_viewer_role.yaml
deleted file mode 100644
index f19e10439d2..00000000000
--- a/testdata/project-v2/config/rbac/captain_viewer_role.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-# permissions for end users to view captains.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: captain-viewer-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains
- verbs:
- - get
- - list
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains/status
- verbs:
- - get
diff --git a/testdata/project-v2/config/rbac/firstmate_editor_role.yaml b/testdata/project-v2/config/rbac/firstmate_editor_role.yaml
deleted file mode 100644
index 22a08be29dd..00000000000
--- a/testdata/project-v2/config/rbac/firstmate_editor_role.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-# permissions for end users to edit firstmates.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: firstmate-editor-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates/status
- verbs:
- - get
diff --git a/testdata/project-v2/config/rbac/firstmate_viewer_role.yaml b/testdata/project-v2/config/rbac/firstmate_viewer_role.yaml
deleted file mode 100644
index 9fd6ba933c7..00000000000
--- a/testdata/project-v2/config/rbac/firstmate_viewer_role.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-# permissions for end users to view firstmates.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- name: firstmate-viewer-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates
- verbs:
- - get
- - list
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates/status
- verbs:
- - get
diff --git a/testdata/project-v2/config/rbac/kustomization.yaml b/testdata/project-v2/config/rbac/kustomization.yaml
deleted file mode 100644
index 66c28338fe0..00000000000
--- a/testdata/project-v2/config/rbac/kustomization.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-resources:
-- role.yaml
-- role_binding.yaml
-- leader_election_role.yaml
-- leader_election_role_binding.yaml
-# Comment the following 4 lines if you want to disable
-# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
-# which protects your /metrics endpoint.
-- auth_proxy_service.yaml
-- auth_proxy_role.yaml
-- auth_proxy_role_binding.yaml
-- auth_proxy_client_clusterrole.yaml
diff --git a/testdata/project-v2/config/rbac/leader_election_role.yaml b/testdata/project-v2/config/rbac/leader_election_role.yaml
deleted file mode 100644
index 7dc16c420ec..00000000000
--- a/testdata/project-v2/config/rbac/leader_election_role.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
-# permissions to do leader election.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: Role
-metadata:
- name: leader-election-role
-rules:
-- apiGroups:
- - ""
- resources:
- - configmaps
- verbs:
- - get
- - list
- - watch
- - create
- - update
- - patch
- - delete
-- apiGroups:
- - ""
- resources:
- - configmaps/status
- verbs:
- - get
- - update
- - patch
-- apiGroups:
- - ""
- resources:
- - events
- verbs:
- - create
- - patch
diff --git a/testdata/project-v2/config/rbac/leader_election_role_binding.yaml b/testdata/project-v2/config/rbac/leader_election_role_binding.yaml
deleted file mode 100644
index eed16906f4d..00000000000
--- a/testdata/project-v2/config/rbac/leader_election_role_binding.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: RoleBinding
-metadata:
- name: leader-election-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: Role
- name: leader-election-role
-subjects:
-- kind: ServiceAccount
- name: default
- namespace: system
diff --git a/testdata/project-v2/config/rbac/role.yaml b/testdata/project-v2/config/rbac/role.yaml
deleted file mode 100644
index 5048ab84fee..00000000000
--- a/testdata/project-v2/config/rbac/role.yaml
+++ /dev/null
@@ -1,88 +0,0 @@
-
----
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- creationTimestamp: null
- name: manager-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirals
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirals/status
- verbs:
- - get
- - patch
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains/status
- verbs:
- - get
- - patch
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates/status
- verbs:
- - get
- - patch
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - lakers
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - lakers/status
- verbs:
- - get
- - patch
- - update
diff --git a/testdata/project-v2/config/rbac/role_binding.yaml b/testdata/project-v2/config/rbac/role_binding.yaml
deleted file mode 100644
index 8f2658702c8..00000000000
--- a/testdata/project-v2/config/rbac/role_binding.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
- name: manager-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: manager-role
-subjects:
-- kind: ServiceAccount
- name: default
- namespace: system
diff --git a/testdata/project-v2/config/samples/crew_v1_admiral.yaml b/testdata/project-v2/config/samples/crew_v1_admiral.yaml
deleted file mode 100644
index 588448f7801..00000000000
--- a/testdata/project-v2/config/samples/crew_v1_admiral.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-apiVersion: crew.testproject.org/v1
-kind: Admiral
-metadata:
- name: admiral-sample
-spec:
- # TODO(user): Add fields here
diff --git a/testdata/project-v2/config/samples/crew_v1_captain.yaml b/testdata/project-v2/config/samples/crew_v1_captain.yaml
deleted file mode 100644
index d0dcfc6cb4d..00000000000
--- a/testdata/project-v2/config/samples/crew_v1_captain.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-apiVersion: crew.testproject.org/v1
-kind: Captain
-metadata:
- name: captain-sample
-spec:
- # TODO(user): Add fields here
diff --git a/testdata/project-v2/config/samples/crew_v1_firstmate.yaml b/testdata/project-v2/config/samples/crew_v1_firstmate.yaml
deleted file mode 100644
index 61749572695..00000000000
--- a/testdata/project-v2/config/samples/crew_v1_firstmate.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-apiVersion: crew.testproject.org/v1
-kind: FirstMate
-metadata:
- name: firstmate-sample
-spec:
- # TODO(user): Add fields here
diff --git a/testdata/project-v2/config/webhook/kustomization.yaml b/testdata/project-v2/config/webhook/kustomization.yaml
deleted file mode 100644
index 9cf26134e4d..00000000000
--- a/testdata/project-v2/config/webhook/kustomization.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-resources:
-- manifests.yaml
-- service.yaml
-
-configurations:
-- kustomizeconfig.yaml
diff --git a/testdata/project-v2/config/webhook/kustomizeconfig.yaml b/testdata/project-v2/config/webhook/kustomizeconfig.yaml
deleted file mode 100644
index 25e21e3c963..00000000000
--- a/testdata/project-v2/config/webhook/kustomizeconfig.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-# the following config is for teaching kustomize where to look at when substituting vars.
-# It requires kustomize v2.1.0 or newer to work properly.
-nameReference:
-- kind: Service
- version: v1
- fieldSpecs:
- - kind: MutatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/name
- - kind: ValidatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/name
-
-namespace:
-- kind: MutatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/namespace
- create: true
-- kind: ValidatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/namespace
- create: true
-
-varReference:
-- path: metadata/annotations
diff --git a/testdata/project-v2/config/webhook/manifests.yaml b/testdata/project-v2/config/webhook/manifests.yaml
deleted file mode 100644
index 387f0c3ea71..00000000000
--- a/testdata/project-v2/config/webhook/manifests.yaml
+++ /dev/null
@@ -1,70 +0,0 @@
-
----
-apiVersion: admissionregistration.k8s.io/v1beta1
-kind: MutatingWebhookConfiguration
-metadata:
- creationTimestamp: null
- name: mutating-webhook-configuration
-webhooks:
-- clientConfig:
- caBundle: Cg==
- service:
- name: webhook-service
- namespace: system
- path: /mutate-crew-testproject-org-v1-admiral
- failurePolicy: Fail
- name: madmiral.kb.io
- rules:
- - apiGroups:
- - crew.testproject.org
- apiVersions:
- - v1
- operations:
- - CREATE
- - UPDATE
- resources:
- - admirals
-- clientConfig:
- caBundle: Cg==
- service:
- name: webhook-service
- namespace: system
- path: /mutate-crew-testproject-org-v1-captain
- failurePolicy: Fail
- name: mcaptain.kb.io
- rules:
- - apiGroups:
- - crew.testproject.org
- apiVersions:
- - v1
- operations:
- - CREATE
- - UPDATE
- resources:
- - captains
-
----
-apiVersion: admissionregistration.k8s.io/v1beta1
-kind: ValidatingWebhookConfiguration
-metadata:
- creationTimestamp: null
- name: validating-webhook-configuration
-webhooks:
-- clientConfig:
- caBundle: Cg==
- service:
- name: webhook-service
- namespace: system
- path: /validate-crew-testproject-org-v1-captain
- failurePolicy: Fail
- name: vcaptain.kb.io
- rules:
- - apiGroups:
- - crew.testproject.org
- apiVersions:
- - v1
- operations:
- - CREATE
- - UPDATE
- resources:
- - captains
diff --git a/testdata/project-v2/config/webhook/service.yaml b/testdata/project-v2/config/webhook/service.yaml
deleted file mode 100644
index 31e0f829591..00000000000
--- a/testdata/project-v2/config/webhook/service.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-apiVersion: v1
-kind: Service
-metadata:
- name: webhook-service
- namespace: system
-spec:
- ports:
- - port: 443
- targetPort: 9443
- selector:
- control-plane: controller-manager
diff --git a/testdata/project-v2/controllers/admiral_controller.go b/testdata/project-v2/controllers/admiral_controller.go
deleted file mode 100644
index 8aae5510f79..00000000000
--- a/testdata/project-v2/controllers/admiral_controller.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "context"
-
- "github.com/go-logr/logr"
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2/api/v1"
-)
-
-// AdmiralReconciler reconciles a Admiral object
-type AdmiralReconciler struct {
- client.Client
- Log logr.Logger
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirals,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirals/status,verbs=get;update;patch
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the Admiral object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.6.4/pkg/reconcile
-func (r *AdmiralReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
- _ = context.Background()
- _ = r.Log.WithValues("admiral", req.NamespacedName)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *AdmiralReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- For(&crewv1.Admiral{}).
- Complete(r)
-}
diff --git a/testdata/project-v2/controllers/captain_controller.go b/testdata/project-v2/controllers/captain_controller.go
deleted file mode 100644
index 97151947b57..00000000000
--- a/testdata/project-v2/controllers/captain_controller.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "context"
-
- "github.com/go-logr/logr"
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2/api/v1"
-)
-
-// CaptainReconciler reconciles a Captain object
-type CaptainReconciler struct {
- client.Client
- Log logr.Logger
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=captains,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=captains/status,verbs=get;update;patch
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the Captain object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.6.4/pkg/reconcile
-func (r *CaptainReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
- _ = context.Background()
- _ = r.Log.WithValues("captain", req.NamespacedName)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- For(&crewv1.Captain{}).
- Complete(r)
-}
diff --git a/testdata/project-v2/controllers/firstmate_controller.go b/testdata/project-v2/controllers/firstmate_controller.go
deleted file mode 100644
index 729d3062099..00000000000
--- a/testdata/project-v2/controllers/firstmate_controller.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "context"
-
- "github.com/go-logr/logr"
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2/api/v1"
-)
-
-// FirstMateReconciler reconciles a FirstMate object
-type FirstMateReconciler struct {
- client.Client
- Log logr.Logger
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates/status,verbs=get;update;patch
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the FirstMate object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.6.4/pkg/reconcile
-func (r *FirstMateReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
- _ = context.Background()
- _ = r.Log.WithValues("firstmate", req.NamespacedName)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *FirstMateReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- For(&crewv1.FirstMate{}).
- Complete(r)
-}
diff --git a/testdata/project-v2/controllers/laker_controller.go b/testdata/project-v2/controllers/laker_controller.go
deleted file mode 100644
index 4e3464ebfc9..00000000000
--- a/testdata/project-v2/controllers/laker_controller.go
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "context"
-
- "github.com/go-logr/logr"
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
-)
-
-// LakerReconciler reconciles a Laker object
-type LakerReconciler struct {
- client.Client
- Log logr.Logger
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=lakers,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=lakers/status,verbs=get;update;patch
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the Laker object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.6.4/pkg/reconcile
-func (r *LakerReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
- _ = context.Background()
- _ = r.Log.WithValues("laker", req.NamespacedName)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *LakerReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- // Uncomment the following line adding a pointer to an instance of the controlled resource as an argument
- // For().
- Complete(r)
-}
diff --git a/testdata/project-v2/controllers/suite_test.go b/testdata/project-v2/controllers/suite_test.go
deleted file mode 100644
index 6cfacce548b..00000000000
--- a/testdata/project-v2/controllers/suite_test.go
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "path/filepath"
- "testing"
-
- . "github.com/onsi/ginkgo"
- . "github.com/onsi/gomega"
- "k8s.io/client-go/kubernetes/scheme"
- "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"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2/api/v1"
- //+kubebuilder:scaffold:imports
-)
-
-// These tests use Ginkgo (BDD-style Go testing framework). Refer to
-// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
-
-var cfg *rest.Config
-var k8sClient client.Client
-var testEnv *envtest.Environment
-
-func TestAPIs(t *testing.T) {
- RegisterFailHandler(Fail)
-
- RunSpecsWithDefaultAndCustomReporters(t,
- "Controller Suite",
- []Reporter{printer.NewlineReporter{}})
-}
-
-var _ = BeforeSuite(func(done Done) {
- logf.SetLogger(zap.LoggerTo(GinkgoWriter, true))
-
- By("bootstrapping test environment")
- testEnv = &envtest.Environment{
- CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
- }
-
- var err error
- // cfg is defined in this file globally.
- cfg, err = testEnv.Start()
- Expect(err).ToNot(HaveOccurred())
- Expect(cfg).ToNot(BeNil())
-
- err = crewv1.AddToScheme(scheme.Scheme)
- Expect(err).NotTo(HaveOccurred())
-
- //+kubebuilder:scaffold:scheme
-
- k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
- Expect(err).ToNot(HaveOccurred())
- Expect(k8sClient).ToNot(BeNil())
-
- close(done)
-}, 60)
-
-var _ = AfterSuite(func() {
- By("tearing down the test environment")
- err := testEnv.Stop()
- Expect(err).ToNot(HaveOccurred())
-})
diff --git a/testdata/project-v2/go.mod b/testdata/project-v2/go.mod
deleted file mode 100644
index d12efdcca14..00000000000
--- a/testdata/project-v2/go.mod
+++ /dev/null
@@ -1,12 +0,0 @@
-module sigs.k8s.io/kubebuilder/testdata/project-v2
-
-go 1.13
-
-require (
- github.com/go-logr/logr v0.1.0
- github.com/onsi/ginkgo v1.12.1
- github.com/onsi/gomega v1.10.1
- k8s.io/apimachinery v0.18.6
- k8s.io/client-go v0.18.6
- sigs.k8s.io/controller-runtime v0.6.4
-)
diff --git a/testdata/project-v2/hack/boilerplate.go.txt b/testdata/project-v2/hack/boilerplate.go.txt
deleted file mode 100644
index 0d32012672a..00000000000
--- a/testdata/project-v2/hack/boilerplate.go.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
\ No newline at end of file
diff --git a/testdata/project-v2/main.go b/testdata/project-v2/main.go
deleted file mode 100644
index 326493b97f4..00000000000
--- a/testdata/project-v2/main.go
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package main
-
-import (
- "flag"
- "os"
-
- "k8s.io/apimachinery/pkg/runtime"
- utilruntime "k8s.io/apimachinery/pkg/util/runtime"
- clientgoscheme "k8s.io/client-go/kubernetes/scheme"
- _ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/log/zap"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2/api/v1"
- "sigs.k8s.io/kubebuilder/testdata/project-v2/controllers"
- //+kubebuilder:scaffold:imports
-)
-
-var (
- scheme = runtime.NewScheme()
- setupLog = ctrl.Log.WithName("setup")
-)
-
-func init() {
- utilruntime.Must(clientgoscheme.AddToScheme(scheme))
-
- utilruntime.Must(crewv1.AddToScheme(scheme))
- //+kubebuilder:scaffold:scheme
-}
-
-func main() {
- var metricsAddr string
- var enableLeaderElection bool
- flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.")
- flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
- "Enable leader election for controller manager. "+
- "Enabling this will ensure there is only one active controller manager.")
- flag.Parse()
-
- ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
-
- mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
- Scheme: scheme,
- MetricsBindAddress: metricsAddr,
- Port: 9443,
- LeaderElection: enableLeaderElection,
- LeaderElectionID: "dc1d9fac.testproject.org",
- })
- if err != nil {
- setupLog.Error(err, "unable to start manager")
- os.Exit(1)
- }
-
- if err = (&controllers.CaptainReconciler{
- Client: mgr.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("Captain"),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "Captain")
- os.Exit(1)
- }
- if err = (&controllers.CaptainReconciler{
- Client: mgr.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("Captain"),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "Captain")
- os.Exit(1)
- }
- if err = (&crewv1.Captain{}).SetupWebhookWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create webhook", "webhook", "Captain")
- os.Exit(1)
- }
- if err = (&controllers.FirstMateReconciler{
- Client: mgr.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("FirstMate"),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "FirstMate")
- os.Exit(1)
- }
- if err = (&crewv1.FirstMate{}).SetupWebhookWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create webhook", "webhook", "FirstMate")
- os.Exit(1)
- }
- if err = (&controllers.AdmiralReconciler{
- Client: mgr.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("Admiral"),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "Admiral")
- os.Exit(1)
- }
- if err = (&crewv1.Admiral{}).SetupWebhookWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create webhook", "webhook", "Admiral")
- os.Exit(1)
- }
- if err = (&controllers.LakerReconciler{
- Client: mgr.GetClient(),
- Log: ctrl.Log.WithName("controllers").WithName("Laker"),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "Laker")
- os.Exit(1)
- }
- //+kubebuilder:scaffold:builder
-
- setupLog.Info("starting manager")
- if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
- setupLog.Error(err, "problem running manager")
- os.Exit(1)
- }
-}
diff --git a/testdata/project-v3/.dockerignore b/testdata/project-v3/.dockerignore
deleted file mode 100644
index 0f046820f18..00000000000
--- a/testdata/project-v3/.dockerignore
+++ /dev/null
@@ -1,4 +0,0 @@
-# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
-# Ignore build and test binaries.
-bin/
-testbin/
diff --git a/testdata/project-v3/.gitignore b/testdata/project-v3/.gitignore
deleted file mode 100644
index c1c593e67e1..00000000000
--- a/testdata/project-v3/.gitignore
+++ /dev/null
@@ -1,27 +0,0 @@
-
-# Binaries for programs and plugins
-*.exe
-*.exe~
-*.dll
-*.so
-*.dylib
-bin
-testbin/*
-Dockerfile.cross
-
-# Test binary, build with `go test -c`
-*.test
-
-# Output of the go coverage tool, specifically when used with LiteIDE
-*.out
-
-# Kubernetes Generated files - skip generated files, except for vendored files
-
-!vendor/**/zz_generated.*
-
-# editor and IDE paraphernalia
-.idea
-.vscode
-*.swp
-*.swo
-*~
diff --git a/testdata/project-v3/Dockerfile b/testdata/project-v3/Dockerfile
deleted file mode 100644
index 8f9cca18eb6..00000000000
--- a/testdata/project-v3/Dockerfile
+++ /dev/null
@@ -1,33 +0,0 @@
-# Build the manager binary
-FROM golang:1.19 as builder
-ARG TARGETOS
-ARG TARGETARCH
-
-WORKDIR /workspace
-# Copy the Go Modules manifests
-COPY go.mod go.mod
-COPY go.sum go.sum
-# cache deps before building and copying source so that we don't need to re-download as much
-# and so that source changes don't invalidate our downloaded layer
-RUN go mod download
-
-# Copy the go source
-COPY main.go main.go
-COPY api/ api/
-COPY controllers/ controllers/
-
-# 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
-
-# Use distroless as minimal base image to package the manager binary
-# Refer to https://github.com/GoogleContainerTools/distroless for more details
-FROM gcr.io/distroless/static:nonroot
-WORKDIR /
-COPY --from=builder /workspace/manager .
-USER 65532:65532
-
-ENTRYPOINT ["/manager"]
diff --git a/testdata/project-v3/Makefile b/testdata/project-v3/Makefile
deleted file mode 100644
index d3476d64fd9..00000000000
--- a/testdata/project-v3/Makefile
+++ /dev/null
@@ -1,157 +0,0 @@
-
-# Image URL to use all building/pushing image targets
-IMG ?= controller:latest
-# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
-ENVTEST_K8S_VERSION = 1.26.1
-
-# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
-ifeq (,$(shell go env GOBIN))
-GOBIN=$(shell go env GOPATH)/bin
-else
-GOBIN=$(shell go env GOBIN)
-endif
-
-# Setting SHELL to bash allows bash commands to be executed by recipes.
-# Options are set to exit when a recipe line exits non-zero or a piped command fails.
-SHELL = /usr/bin/env bash -o pipefail
-.SHELLFLAGS = -ec
-
-.PHONY: all
-all: build
-
-##@ General
-
-# The help target prints out all targets with their descriptions organized
-# beneath their categories. The categories are represented by '##@' and the
-# target descriptions by '##'. The awk command is responsible for reading the
-# entire set of makefiles included in this invocation, looking for lines of the
-# file as xyz: ## something, and then pretty-format the target and help. Then,
-# if there's a line with ##@ something, that gets pretty-printed as a category.
-# More info on the usage of ANSI control characters for terminal formatting:
-# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters
-# More info on the awk command:
-# http://linuxcommand.org/lc3_adv_awk.php
-
-.PHONY: help
-help: ## Display this help.
- @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
-
-##@ Development
-
-.PHONY: manifests
-manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
- $(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
-
-.PHONY: generate
-generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
- $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
-
-.PHONY: fmt
-fmt: ## Run go fmt against code.
- go fmt ./...
-
-.PHONY: vet
-vet: ## Run go vet against code.
- go vet ./...
-
-.PHONY: test
-test: manifests generate fmt vet envtest ## Run tests.
- KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
-
-##@ Build
-
-.PHONY: build
-build: manifests generate fmt vet ## Build manager binary.
- go build -o bin/manager main.go
-
-.PHONY: run
-run: manifests generate fmt vet ## Run a controller from your host.
- go run ./main.go
-
-# If you wish to build 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.
-# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
-.PHONY: docker-build
-docker-build: test ## Build docker image with the manager.
- docker build -t ${IMG} .
-
-.PHONY: docker-push
-docker-push: ## Push docker image with the manager.
- docker push ${IMG}
-
-# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
-# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
-# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
-# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
-# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=> then the export will fail)
-# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
-PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
-.PHONY: docker-buildx
-docker-buildx: test ## Build and push docker image for the manager for cross-platform support
- # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
- sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- - docker buildx create --name project-v3-builder
- docker buildx use project-v3-builder
- - docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
- - docker buildx rm project-v3-builder
- rm Dockerfile.cross
-
-##@ Deployment
-
-ifndef ignore-not-found
- ignore-not-found = false
-endif
-
-.PHONY: install
-install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
- $(KUSTOMIZE) build config/crd | kubectl apply -f -
-
-.PHONY: uninstall
-uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
- $(KUSTOMIZE) build config/crd | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
-
-.PHONY: deploy
-deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
- cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
- $(KUSTOMIZE) build config/default | kubectl apply -f -
-
-.PHONY: undeploy
-undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
- $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
-
-##@ Build Dependencies
-
-## Location to install dependencies to
-LOCALBIN ?= $(shell pwd)/bin
-$(LOCALBIN):
- mkdir -p $(LOCALBIN)
-
-## Tool Binaries
-KUSTOMIZE ?= $(LOCALBIN)/kustomize
-CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
-ENVTEST ?= $(LOCALBIN)/setup-envtest
-
-## Tool Versions
-KUSTOMIZE_VERSION ?= v3.8.7
-CONTROLLER_TOOLS_VERSION ?= v0.11.3
-
-KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
-.PHONY: kustomize
-kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
-$(KUSTOMIZE): $(LOCALBIN)
- @if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \
- echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \
- rm -rf $(LOCALBIN)/kustomize; \
- fi
- test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) --output install_kustomize.sh && bash install_kustomize.sh $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); rm install_kustomize.sh; }
-
-.PHONY: controller-gen
-controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
-$(CONTROLLER_GEN): $(LOCALBIN)
- test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
- GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
-
-.PHONY: envtest
-envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
-$(ENVTEST): $(LOCALBIN)
- test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
diff --git a/testdata/project-v3/PROJECT b/testdata/project-v3/PROJECT
deleted file mode 100644
index 8376173de79..00000000000
--- a/testdata/project-v3/PROJECT
+++ /dev/null
@@ -1,53 +0,0 @@
-# Code generated by tool. DO NOT EDIT.
-# This file is used to track the info used to scaffold your project
-# and allow the plugins properly work.
-# More info: https://book.kubebuilder.io/reference/project-config.html
-domain: testproject.org
-layout:
-- go.kubebuilder.io/v3
-projectName: project-v3
-repo: sigs.k8s.io/kubebuilder/testdata/project-v3
-resources:
-- api:
- crdVersion: v1
- namespaced: true
- controller: true
- domain: testproject.org
- group: crew
- kind: Captain
- path: sigs.k8s.io/kubebuilder/testdata/project-v3/api/v1
- version: v1
- webhooks:
- defaulting: true
- validation: true
- webhookVersion: v1
-- api:
- crdVersion: v1
- namespaced: true
- controller: true
- domain: testproject.org
- group: crew
- kind: FirstMate
- path: sigs.k8s.io/kubebuilder/testdata/project-v3/api/v1
- version: v1
- webhooks:
- conversion: true
- webhookVersion: v1
-- api:
- crdVersion: v1
- controller: true
- domain: testproject.org
- group: crew
- kind: Admiral
- path: sigs.k8s.io/kubebuilder/testdata/project-v3/api/v1
- plural: admirales
- version: v1
- webhooks:
- defaulting: true
- webhookVersion: v1
-- controller: true
- domain: testproject.org
- group: crew
- kind: Laker
- version: v1
-version: "3"
diff --git a/testdata/project-v3/README.md b/testdata/project-v3/README.md
deleted file mode 100644
index a968e958d3d..00000000000
--- a/testdata/project-v3/README.md
+++ /dev/null
@@ -1,94 +0,0 @@
-# project-v3
-// TODO(user): Add simple overview of use/purpose
-
-## Description
-// TODO(user): An in-depth paragraph about your project and overview of use
-
-## Getting Started
-You’ll need a Kubernetes cluster to run against. You can use [KIND](https://sigs.k8s.io/kind) to get a local cluster for testing, or run against a remote cluster.
-**Note:** Your controller will automatically use the current context in your kubeconfig file (i.e. whatever cluster `kubectl cluster-info` shows).
-
-### Running on the cluster
-1. Install Instances of Custom Resources:
-
-```sh
-kubectl apply -k config/samples/
-```
-
-2. Build and push your image to the location specified by `IMG`:
-
-```sh
-make docker-build docker-push IMG=/project-v3:tag
-```
-
-3. Deploy the controller to the cluster with the image specified by `IMG`:
-
-```sh
-make deploy IMG=/project-v3:tag
-```
-
-### Uninstall CRDs
-To delete the CRDs from the cluster:
-
-```sh
-make uninstall
-```
-
-### Undeploy controller
-UnDeploy the controller from the cluster:
-
-```sh
-make undeploy
-```
-
-## Contributing
-// TODO(user): Add detailed information on how you would like others to contribute to this project
-
-### How it works
-This project aims to follow the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/).
-
-It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/),
-which provide a reconcile function responsible for synchronizing resources until the desired state is reached on the cluster.
-
-### Test It Out
-1. Install the CRDs into the cluster:
-
-```sh
-make install
-```
-
-2. Run your controller (this will run in the foreground, so switch to a new terminal if you want to leave it running):
-
-```sh
-make run
-```
-
-**NOTE:** You can also run this in one step by running: `make install run`
-
-### Modifying the API definitions
-If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
-
-```sh
-make manifests
-```
-
-**NOTE:** Run `make --help` for more information on all potential `make` targets
-
-More information can be found via the [Kubebuilder Documentation](https://book.kubebuilder.io/introduction.html)
-
-## License
-
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
diff --git a/testdata/project-v3/api/v1/admiral_types.go b/testdata/project-v3/api/v1/admiral_types.go
deleted file mode 100644
index 0e42bc0c31d..00000000000
--- a/testdata/project-v3/api/v1/admiral_types.go
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// AdmiralSpec defines the desired state of Admiral
-type AdmiralSpec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-
- // Foo is an example field of Admiral. Edit admiral_types.go to remove/update
- Foo string `json:"foo,omitempty"`
-}
-
-// AdmiralStatus defines the observed state of Admiral
-type AdmiralStatus struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-}
-
-//+kubebuilder:object:root=true
-//+kubebuilder:subresource:status
-//+kubebuilder:resource:path=admirales,scope=Cluster
-
-// Admiral is the Schema for the admirales API
-type Admiral struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ObjectMeta `json:"metadata,omitempty"`
-
- Spec AdmiralSpec `json:"spec,omitempty"`
- Status AdmiralStatus `json:"status,omitempty"`
-}
-
-//+kubebuilder:object:root=true
-
-// AdmiralList contains a list of Admiral
-type AdmiralList struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ListMeta `json:"metadata,omitempty"`
- Items []Admiral `json:"items"`
-}
-
-func init() {
- SchemeBuilder.Register(&Admiral{}, &AdmiralList{})
-}
diff --git a/testdata/project-v3/api/v1/admiral_webhook.go b/testdata/project-v3/api/v1/admiral_webhook.go
deleted file mode 100644
index 32f7972be24..00000000000
--- a/testdata/project-v3/api/v1/admiral_webhook.go
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- ctrl "sigs.k8s.io/controller-runtime"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
- "sigs.k8s.io/controller-runtime/pkg/webhook"
-)
-
-// log is for logging in this package.
-var admirallog = logf.Log.WithName("admiral-resource")
-
-func (r *Admiral) SetupWebhookWithManager(mgr ctrl.Manager) error {
- return ctrl.NewWebhookManagedBy(mgr).
- For(r).
- Complete()
-}
-
-// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-
-//+kubebuilder:webhook:path=/mutate-crew-testproject-org-v1-admiral,mutating=true,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=admirales,verbs=create;update,versions=v1,name=madmiral.kb.io,admissionReviewVersions=v1
-
-var _ webhook.Defaulter = &Admiral{}
-
-// Default implements webhook.Defaulter so a webhook will be registered for the type
-func (r *Admiral) Default() {
- admirallog.Info("default", "name", r.Name)
-
- // TODO(user): fill in your defaulting logic.
-}
diff --git a/testdata/project-v3/api/v1/captain_types.go b/testdata/project-v3/api/v1/captain_types.go
deleted file mode 100644
index f7b87f2a264..00000000000
--- a/testdata/project-v3/api/v1/captain_types.go
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// CaptainSpec defines the desired state of Captain
-type CaptainSpec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-
- // Foo is an example field of Captain. Edit captain_types.go to remove/update
- Foo string `json:"foo,omitempty"`
-}
-
-// CaptainStatus defines the observed state of Captain
-type CaptainStatus struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-}
-
-//+kubebuilder:object:root=true
-//+kubebuilder:subresource:status
-
-// Captain is the Schema for the captains API
-type Captain struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ObjectMeta `json:"metadata,omitempty"`
-
- Spec CaptainSpec `json:"spec,omitempty"`
- Status CaptainStatus `json:"status,omitempty"`
-}
-
-//+kubebuilder:object:root=true
-
-// CaptainList contains a list of Captain
-type CaptainList struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ListMeta `json:"metadata,omitempty"`
- Items []Captain `json:"items"`
-}
-
-func init() {
- SchemeBuilder.Register(&Captain{}, &CaptainList{})
-}
diff --git a/testdata/project-v3/api/v1/captain_webhook.go b/testdata/project-v3/api/v1/captain_webhook.go
deleted file mode 100644
index 4a977895956..00000000000
--- a/testdata/project-v3/api/v1/captain_webhook.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
- "sigs.k8s.io/controller-runtime/pkg/webhook"
-)
-
-// log is for logging in this package.
-var captainlog = logf.Log.WithName("captain-resource")
-
-func (r *Captain) SetupWebhookWithManager(mgr ctrl.Manager) error {
- return ctrl.NewWebhookManagedBy(mgr).
- For(r).
- Complete()
-}
-
-// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-
-//+kubebuilder:webhook:path=/mutate-crew-testproject-org-v1-captain,mutating=true,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=captains,verbs=create;update,versions=v1,name=mcaptain.kb.io,admissionReviewVersions=v1
-
-var _ webhook.Defaulter = &Captain{}
-
-// Default implements webhook.Defaulter so a webhook will be registered for the type
-func (r *Captain) Default() {
- captainlog.Info("default", "name", r.Name)
-
- // TODO(user): fill in your defaulting logic.
-}
-
-// TODO(user): change verbs to "verbs=create;update;delete" if you want to enable deletion validation.
-//+kubebuilder:webhook:path=/validate-crew-testproject-org-v1-captain,mutating=false,failurePolicy=fail,sideEffects=None,groups=crew.testproject.org,resources=captains,verbs=create;update,versions=v1,name=vcaptain.kb.io,admissionReviewVersions=v1
-
-var _ webhook.Validator = &Captain{}
-
-// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
-func (r *Captain) ValidateCreate() error {
- captainlog.Info("validate create", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object creation.
- return nil
-}
-
-// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
-func (r *Captain) ValidateUpdate(old runtime.Object) error {
- captainlog.Info("validate update", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object update.
- return nil
-}
-
-// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
-func (r *Captain) ValidateDelete() error {
- captainlog.Info("validate delete", "name", r.Name)
-
- // TODO(user): fill in your validation logic upon object deletion.
- return nil
-}
diff --git a/testdata/project-v3/api/v1/firstmate_types.go b/testdata/project-v3/api/v1/firstmate_types.go
deleted file mode 100644
index 1e38fa31adf..00000000000
--- a/testdata/project-v3/api/v1/firstmate_types.go
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-)
-
-// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
-// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
-
-// FirstMateSpec defines the desired state of FirstMate
-type FirstMateSpec struct {
- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-
- // Foo is an example field of FirstMate. Edit firstmate_types.go to remove/update
- Foo string `json:"foo,omitempty"`
-}
-
-// FirstMateStatus defines the observed state of FirstMate
-type FirstMateStatus struct {
- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
- // Important: Run "make" to regenerate code after modifying this file
-}
-
-//+kubebuilder:object:root=true
-//+kubebuilder:subresource:status
-
-// FirstMate is the Schema for the firstmates API
-type FirstMate struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ObjectMeta `json:"metadata,omitempty"`
-
- Spec FirstMateSpec `json:"spec,omitempty"`
- Status FirstMateStatus `json:"status,omitempty"`
-}
-
-//+kubebuilder:object:root=true
-
-// FirstMateList contains a list of FirstMate
-type FirstMateList struct {
- metav1.TypeMeta `json:",inline"`
- metav1.ListMeta `json:"metadata,omitempty"`
- Items []FirstMate `json:"items"`
-}
-
-func init() {
- SchemeBuilder.Register(&FirstMate{}, &FirstMateList{})
-}
diff --git a/testdata/project-v3/api/v1/firstmate_webhook.go b/testdata/project-v3/api/v1/firstmate_webhook.go
deleted file mode 100644
index be9fd16e882..00000000000
--- a/testdata/project-v3/api/v1/firstmate_webhook.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- ctrl "sigs.k8s.io/controller-runtime"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
-)
-
-// log is for logging in this package.
-var firstmatelog = logf.Log.WithName("firstmate-resource")
-
-func (r *FirstMate) SetupWebhookWithManager(mgr ctrl.Manager) error {
- return ctrl.NewWebhookManagedBy(mgr).
- For(r).
- Complete()
-}
-
-// TODO(user): EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
diff --git a/testdata/project-v3/api/v1/groupversion_info.go b/testdata/project-v3/api/v1/groupversion_info.go
deleted file mode 100644
index b2b4c7e7335..00000000000
--- a/testdata/project-v3/api/v1/groupversion_info.go
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Package v1 contains API Schema definitions for the crew v1 API group
-// +kubebuilder:object:generate=true
-// +groupName=crew.testproject.org
-package v1
-
-import (
- "k8s.io/apimachinery/pkg/runtime/schema"
- "sigs.k8s.io/controller-runtime/pkg/scheme"
-)
-
-var (
- // GroupVersion is group version used to register these objects
- GroupVersion = schema.GroupVersion{Group: "crew.testproject.org", Version: "v1"}
-
- // SchemeBuilder is used to add go types to the GroupVersionKind scheme
- SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
-
- // AddToScheme adds the types in this group-version to the given scheme.
- AddToScheme = SchemeBuilder.AddToScheme
-)
diff --git a/testdata/project-v3/api/v1/webhook_suite_test.go b/testdata/project-v3/api/v1/webhook_suite_test.go
deleted file mode 100644
index 456fa6a823a..00000000000
--- a/testdata/project-v3/api/v1/webhook_suite_test.go
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package v1
-
-import (
- "context"
- "crypto/tls"
- "fmt"
- "net"
- "path/filepath"
- "testing"
- "time"
-
- . "github.com/onsi/ginkgo/v2"
- . "github.com/onsi/gomega"
-
- admissionv1beta1 "k8s.io/api/admission/v1beta1"
- //+kubebuilder:scaffold:imports
- "k8s.io/apimachinery/pkg/runtime"
- "k8s.io/client-go/rest"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/envtest"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
- "sigs.k8s.io/controller-runtime/pkg/log/zap"
-)
-
-// These tests use Ginkgo (BDD-style Go testing framework). Refer to
-// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
-
-var cfg *rest.Config
-var k8sClient client.Client
-var testEnv *envtest.Environment
-var ctx context.Context
-var cancel context.CancelFunc
-
-func TestAPIs(t *testing.T) {
- RegisterFailHandler(Fail)
-
- RunSpecs(t, "Webhook Suite")
-}
-
-var _ = BeforeSuite(func() {
- logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
-
- ctx, cancel = context.WithCancel(context.TODO())
-
- By("bootstrapping test environment")
- testEnv = &envtest.Environment{
- CRDDirectoryPaths: []string{filepath.Join("..", "..", "config", "crd", "bases")},
- ErrorIfCRDPathMissing: false,
- WebhookInstallOptions: envtest.WebhookInstallOptions{
- Paths: []string{filepath.Join("..", "..", "config", "webhook")},
- },
- }
-
- var err error
- // cfg is defined in this file globally.
- cfg, err = testEnv.Start()
- Expect(err).NotTo(HaveOccurred())
- Expect(cfg).NotTo(BeNil())
-
- scheme := runtime.NewScheme()
- err = AddToScheme(scheme)
- Expect(err).NotTo(HaveOccurred())
-
- err = admissionv1beta1.AddToScheme(scheme)
- Expect(err).NotTo(HaveOccurred())
-
- //+kubebuilder:scaffold:scheme
-
- k8sClient, err = client.New(cfg, client.Options{Scheme: scheme})
- Expect(err).NotTo(HaveOccurred())
- Expect(k8sClient).NotTo(BeNil())
-
- // start webhook server using Manager
- webhookInstallOptions := &testEnv.WebhookInstallOptions
- mgr, err := ctrl.NewManager(cfg, ctrl.Options{
- Scheme: scheme,
- Host: webhookInstallOptions.LocalServingHost,
- Port: webhookInstallOptions.LocalServingPort,
- CertDir: webhookInstallOptions.LocalServingCertDir,
- LeaderElection: false,
- MetricsBindAddress: "0",
- })
- Expect(err).NotTo(HaveOccurred())
-
- err = (&Captain{}).SetupWebhookWithManager(mgr)
- Expect(err).NotTo(HaveOccurred())
-
- err = (&Admiral{}).SetupWebhookWithManager(mgr)
- Expect(err).NotTo(HaveOccurred())
-
- //+kubebuilder:scaffold:webhook
-
- go func() {
- defer GinkgoRecover()
- err = mgr.Start(ctx)
- Expect(err).NotTo(HaveOccurred())
- }()
-
- // wait for the webhook server to get ready
- dialer := &net.Dialer{Timeout: time.Second}
- addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort)
- Eventually(func() error {
- conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true})
- if err != nil {
- return err
- }
- conn.Close()
- return nil
- }).Should(Succeed())
-
-})
-
-var _ = AfterSuite(func() {
- cancel()
- By("tearing down the test environment")
- err := testEnv.Stop()
- Expect(err).NotTo(HaveOccurred())
-})
diff --git a/testdata/project-v3/api/v1/zz_generated.deepcopy.go b/testdata/project-v3/api/v1/zz_generated.deepcopy.go
deleted file mode 100644
index e6d9ca566eb..00000000000
--- a/testdata/project-v3/api/v1/zz_generated.deepcopy.go
+++ /dev/null
@@ -1,293 +0,0 @@
-//go:build !ignore_autogenerated
-// +build !ignore_autogenerated
-
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-// Code generated by controller-gen. DO NOT EDIT.
-
-package v1
-
-import (
- "k8s.io/apimachinery/pkg/runtime"
-)
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *Admiral) DeepCopyInto(out *Admiral) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
- out.Spec = in.Spec
- out.Status = in.Status
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Admiral.
-func (in *Admiral) DeepCopy() *Admiral {
- if in == nil {
- return nil
- }
- out := new(Admiral)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *Admiral) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *AdmiralList) DeepCopyInto(out *AdmiralList) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ListMeta.DeepCopyInto(&out.ListMeta)
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]Admiral, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralList.
-func (in *AdmiralList) DeepCopy() *AdmiralList {
- if in == nil {
- return nil
- }
- out := new(AdmiralList)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *AdmiralList) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *AdmiralSpec) DeepCopyInto(out *AdmiralSpec) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralSpec.
-func (in *AdmiralSpec) DeepCopy() *AdmiralSpec {
- if in == nil {
- return nil
- }
- out := new(AdmiralSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *AdmiralStatus) DeepCopyInto(out *AdmiralStatus) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AdmiralStatus.
-func (in *AdmiralStatus) DeepCopy() *AdmiralStatus {
- if in == nil {
- return nil
- }
- out := new(AdmiralStatus)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *Captain) DeepCopyInto(out *Captain) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
- out.Spec = in.Spec
- out.Status = in.Status
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Captain.
-func (in *Captain) DeepCopy() *Captain {
- if in == nil {
- return nil
- }
- out := new(Captain)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *Captain) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CaptainList) DeepCopyInto(out *CaptainList) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ListMeta.DeepCopyInto(&out.ListMeta)
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]Captain, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainList.
-func (in *CaptainList) DeepCopy() *CaptainList {
- if in == nil {
- return nil
- }
- out := new(CaptainList)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *CaptainList) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CaptainSpec) DeepCopyInto(out *CaptainSpec) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainSpec.
-func (in *CaptainSpec) DeepCopy() *CaptainSpec {
- if in == nil {
- return nil
- }
- out := new(CaptainSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *CaptainStatus) DeepCopyInto(out *CaptainStatus) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CaptainStatus.
-func (in *CaptainStatus) DeepCopy() *CaptainStatus {
- if in == nil {
- return nil
- }
- out := new(CaptainStatus)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FirstMate) DeepCopyInto(out *FirstMate) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
- out.Spec = in.Spec
- out.Status = in.Status
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMate.
-func (in *FirstMate) DeepCopy() *FirstMate {
- if in == nil {
- return nil
- }
- out := new(FirstMate)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *FirstMate) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FirstMateList) DeepCopyInto(out *FirstMateList) {
- *out = *in
- out.TypeMeta = in.TypeMeta
- in.ListMeta.DeepCopyInto(&out.ListMeta)
- if in.Items != nil {
- in, out := &in.Items, &out.Items
- *out = make([]FirstMate, len(*in))
- for i := range *in {
- (*in)[i].DeepCopyInto(&(*out)[i])
- }
- }
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateList.
-func (in *FirstMateList) DeepCopy() *FirstMateList {
- if in == nil {
- return nil
- }
- out := new(FirstMateList)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
-func (in *FirstMateList) DeepCopyObject() runtime.Object {
- if c := in.DeepCopy(); c != nil {
- return c
- }
- return nil
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FirstMateSpec) DeepCopyInto(out *FirstMateSpec) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateSpec.
-func (in *FirstMateSpec) DeepCopy() *FirstMateSpec {
- if in == nil {
- return nil
- }
- out := new(FirstMateSpec)
- in.DeepCopyInto(out)
- return out
-}
-
-// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
-func (in *FirstMateStatus) DeepCopyInto(out *FirstMateStatus) {
- *out = *in
-}
-
-// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FirstMateStatus.
-func (in *FirstMateStatus) DeepCopy() *FirstMateStatus {
- if in == nil {
- return nil
- }
- out := new(FirstMateStatus)
- in.DeepCopyInto(out)
- return out
-}
diff --git a/testdata/project-v3/config/certmanager/certificate.yaml b/testdata/project-v3/config/certmanager/certificate.yaml
deleted file mode 100644
index 809b9724b62..00000000000
--- a/testdata/project-v3/config/certmanager/certificate.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-# The following manifests contain a self-signed issuer CR and a certificate CR.
-# More document can be found at https://docs.cert-manager.io
-# WARNING: Targets CertManager v1.0. Check https://cert-manager.io/docs/installation/upgrading/ for breaking changes.
-apiVersion: cert-manager.io/v1
-kind: Issuer
-metadata:
- labels:
- app.kubernetes.io/name: issuer
- app.kubernetes.io/instance: selfsigned-issuer
- app.kubernetes.io/component: certificate
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: selfsigned-issuer
- namespace: system
-spec:
- selfSigned: {}
----
-apiVersion: cert-manager.io/v1
-kind: Certificate
-metadata:
- labels:
- app.kubernetes.io/name: certificate
- app.kubernetes.io/instance: serving-cert
- app.kubernetes.io/component: certificate
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- 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
- dnsNames:
- - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- - $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
- issuerRef:
- kind: Issuer
- name: selfsigned-issuer
- secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
diff --git a/testdata/project-v3/config/certmanager/kustomization.yaml b/testdata/project-v3/config/certmanager/kustomization.yaml
deleted file mode 100644
index bebea5a595e..00000000000
--- a/testdata/project-v3/config/certmanager/kustomization.yaml
+++ /dev/null
@@ -1,5 +0,0 @@
-resources:
-- certificate.yaml
-
-configurations:
-- kustomizeconfig.yaml
diff --git a/testdata/project-v3/config/certmanager/kustomizeconfig.yaml b/testdata/project-v3/config/certmanager/kustomizeconfig.yaml
deleted file mode 100644
index e631f777366..00000000000
--- a/testdata/project-v3/config/certmanager/kustomizeconfig.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# This configuration is for teaching kustomize how to update name ref and var substitution
-nameReference:
-- kind: Issuer
- group: cert-manager.io
- fieldSpecs:
- - 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/testdata/project-v3/config/crd/bases/crew.testproject.org_admirales.yaml b/testdata/project-v3/config/crd/bases/crew.testproject.org_admirales.yaml
deleted file mode 100644
index 90af8738b36..00000000000
--- a/testdata/project-v3/config/crd/bases/crew.testproject.org_admirales.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
----
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- controller-gen.kubebuilder.io/version: v0.11.3
- creationTimestamp: null
- name: admirales.crew.testproject.org
-spec:
- group: crew.testproject.org
- names:
- kind: Admiral
- listKind: AdmiralList
- plural: admirales
- singular: admiral
- scope: Cluster
- versions:
- - name: v1
- schema:
- openAPIV3Schema:
- description: Admiral is the Schema for the admirales API
- properties:
- apiVersion:
- description: 'APIVersion defines the versioned schema of this representation
- of an object. Servers should convert recognized schemas to the latest
- internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
- type: string
- kind:
- description: 'Kind is a string value representing the REST resource this
- object represents. Servers may infer this from the endpoint the client
- submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
- type: string
- metadata:
- type: object
- spec:
- description: AdmiralSpec defines the desired state of Admiral
- properties:
- foo:
- description: Foo is an example field of Admiral. Edit admiral_types.go
- to remove/update
- type: string
- type: object
- status:
- description: AdmiralStatus defines the observed state of Admiral
- type: object
- type: object
- served: true
- storage: true
- subresources:
- status: {}
diff --git a/testdata/project-v3/config/crd/bases/crew.testproject.org_captains.yaml b/testdata/project-v3/config/crd/bases/crew.testproject.org_captains.yaml
deleted file mode 100644
index 6c098109938..00000000000
--- a/testdata/project-v3/config/crd/bases/crew.testproject.org_captains.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
----
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- controller-gen.kubebuilder.io/version: v0.11.3
- creationTimestamp: null
- name: captains.crew.testproject.org
-spec:
- group: crew.testproject.org
- names:
- kind: Captain
- listKind: CaptainList
- plural: captains
- singular: captain
- scope: Namespaced
- versions:
- - name: v1
- schema:
- openAPIV3Schema:
- description: Captain is the Schema for the captains API
- properties:
- apiVersion:
- description: 'APIVersion defines the versioned schema of this representation
- of an object. Servers should convert recognized schemas to the latest
- internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
- type: string
- kind:
- description: 'Kind is a string value representing the REST resource this
- object represents. Servers may infer this from the endpoint the client
- submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
- type: string
- metadata:
- type: object
- spec:
- description: CaptainSpec defines the desired state of Captain
- properties:
- foo:
- description: Foo is an example field of Captain. Edit captain_types.go
- to remove/update
- type: string
- type: object
- status:
- description: CaptainStatus defines the observed state of Captain
- type: object
- type: object
- served: true
- storage: true
- subresources:
- status: {}
diff --git a/testdata/project-v3/config/crd/bases/crew.testproject.org_firstmates.yaml b/testdata/project-v3/config/crd/bases/crew.testproject.org_firstmates.yaml
deleted file mode 100644
index b49f937c0d0..00000000000
--- a/testdata/project-v3/config/crd/bases/crew.testproject.org_firstmates.yaml
+++ /dev/null
@@ -1,50 +0,0 @@
----
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- controller-gen.kubebuilder.io/version: v0.11.3
- creationTimestamp: null
- name: firstmates.crew.testproject.org
-spec:
- group: crew.testproject.org
- names:
- kind: FirstMate
- listKind: FirstMateList
- plural: firstmates
- singular: firstmate
- scope: Namespaced
- versions:
- - name: v1
- schema:
- openAPIV3Schema:
- description: FirstMate is the Schema for the firstmates API
- properties:
- apiVersion:
- description: 'APIVersion defines the versioned schema of this representation
- of an object. Servers should convert recognized schemas to the latest
- internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
- type: string
- kind:
- description: 'Kind is a string value representing the REST resource this
- object represents. Servers may infer this from the endpoint the client
- submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
- type: string
- metadata:
- type: object
- spec:
- description: FirstMateSpec defines the desired state of FirstMate
- properties:
- foo:
- description: Foo is an example field of FirstMate. Edit firstmate_types.go
- to remove/update
- type: string
- type: object
- status:
- description: FirstMateStatus defines the observed state of FirstMate
- type: object
- type: object
- served: true
- storage: true
- subresources:
- status: {}
diff --git a/testdata/project-v3/config/crd/kustomization.yaml b/testdata/project-v3/config/crd/kustomization.yaml
deleted file mode 100644
index 0d38144170a..00000000000
--- a/testdata/project-v3/config/crd/kustomization.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-# This kustomization.yaml is not intended to be run by itself,
-# since it depends on service name and namespace that are out of this kustomize package.
-# It should be run by config/default
-resources:
-- bases/crew.testproject.org_captains.yaml
-- bases/crew.testproject.org_firstmates.yaml
-- bases/crew.testproject.org_admirales.yaml
-#+kubebuilder:scaffold:crdkustomizeresource
-
-patchesStrategicMerge:
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
-# patches here are for enabling the conversion webhook for each CRD
-#- patches/webhook_in_captains.yaml
-#- patches/webhook_in_firstmates.yaml
-#- patches/webhook_in_admirales.yaml
-#+kubebuilder:scaffold:crdkustomizewebhookpatch
-
-# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
-# patches here are for enabling the CA injection for each CRD
-#- patches/cainjection_in_captains.yaml
-#- patches/cainjection_in_firstmates.yaml
-#- patches/cainjection_in_admirales.yaml
-#+kubebuilder:scaffold:crdkustomizecainjectionpatch
-
-# the following config is for teaching kustomize how to do kustomization for CRDs.
-configurations:
-- kustomizeconfig.yaml
diff --git a/testdata/project-v3/config/crd/kustomizeconfig.yaml b/testdata/project-v3/config/crd/kustomizeconfig.yaml
deleted file mode 100644
index ec5c150a9df..00000000000
--- a/testdata/project-v3/config/crd/kustomizeconfig.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-# This file is for teaching kustomize how to substitute name and namespace reference in CRD
-nameReference:
-- kind: Service
- version: v1
- fieldSpecs:
- - kind: CustomResourceDefinition
- version: v1
- group: apiextensions.k8s.io
- path: spec/conversion/webhook/clientConfig/service/name
-
-namespace:
-- kind: CustomResourceDefinition
- version: v1
- group: apiextensions.k8s.io
- path: spec/conversion/webhook/clientConfig/service/namespace
- create: false
-
-varReference:
-- path: metadata/annotations
diff --git a/testdata/project-v3/config/crd/patches/cainjection_in_admirales.yaml b/testdata/project-v3/config/crd/patches/cainjection_in_admirales.yaml
deleted file mode 100644
index 04882738e44..00000000000
--- a/testdata/project-v3/config/crd/patches/cainjection_in_admirales.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-# The following patch adds a directive for certmanager to inject CA into the CRD
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
- name: admirales.crew.testproject.org
diff --git a/testdata/project-v3/config/crd/patches/cainjection_in_captains.yaml b/testdata/project-v3/config/crd/patches/cainjection_in_captains.yaml
deleted file mode 100644
index 9c9d61b0c97..00000000000
--- a/testdata/project-v3/config/crd/patches/cainjection_in_captains.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-# The following patch adds a directive for certmanager to inject CA into the CRD
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
- name: captains.crew.testproject.org
diff --git a/testdata/project-v3/config/crd/patches/cainjection_in_firstmates.yaml b/testdata/project-v3/config/crd/patches/cainjection_in_firstmates.yaml
deleted file mode 100644
index 6849f00fb85..00000000000
--- a/testdata/project-v3/config/crd/patches/cainjection_in_firstmates.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-# The following patch adds a directive for certmanager to inject CA into the CRD
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
- name: firstmates.crew.testproject.org
diff --git a/testdata/project-v3/config/crd/patches/webhook_in_admirales.yaml b/testdata/project-v3/config/crd/patches/webhook_in_admirales.yaml
deleted file mode 100644
index cf986a6a411..00000000000
--- a/testdata/project-v3/config/crd/patches/webhook_in_admirales.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# The following patch enables a conversion webhook for the CRD
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- name: admirales.crew.testproject.org
-spec:
- conversion:
- strategy: Webhook
- webhook:
- clientConfig:
- service:
- namespace: system
- name: webhook-service
- path: /convert
- conversionReviewVersions:
- - v1
diff --git a/testdata/project-v3/config/crd/patches/webhook_in_captains.yaml b/testdata/project-v3/config/crd/patches/webhook_in_captains.yaml
deleted file mode 100644
index f73ae2e8abc..00000000000
--- a/testdata/project-v3/config/crd/patches/webhook_in_captains.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# The following patch enables a conversion webhook for the CRD
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- name: captains.crew.testproject.org
-spec:
- conversion:
- strategy: Webhook
- webhook:
- clientConfig:
- service:
- namespace: system
- name: webhook-service
- path: /convert
- conversionReviewVersions:
- - v1
diff --git a/testdata/project-v3/config/crd/patches/webhook_in_firstmates.yaml b/testdata/project-v3/config/crd/patches/webhook_in_firstmates.yaml
deleted file mode 100644
index 76ee5acedbd..00000000000
--- a/testdata/project-v3/config/crd/patches/webhook_in_firstmates.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# The following patch enables a conversion webhook for the CRD
-apiVersion: apiextensions.k8s.io/v1
-kind: CustomResourceDefinition
-metadata:
- name: firstmates.crew.testproject.org
-spec:
- conversion:
- strategy: Webhook
- webhook:
- clientConfig:
- service:
- namespace: system
- name: webhook-service
- path: /convert
- conversionReviewVersions:
- - v1
diff --git a/testdata/project-v3/config/default/kustomization.yaml b/testdata/project-v3/config/default/kustomization.yaml
deleted file mode 100644
index f8b3884950b..00000000000
--- a/testdata/project-v3/config/default/kustomization.yaml
+++ /dev/null
@@ -1,70 +0,0 @@
-# Adds namespace to all resources.
-namespace: project-v3-system
-
-# Value of this field is prepended to the
-# names of all resources, e.g. a deployment named
-# "wordpress" becomes "alices-wordpress".
-# Note that it should also match with the prefix (text before '-') of the namespace
-# field above.
-namePrefix: project-v3-
-
-# Labels to add to all resources and selectors.
-#commonLabels:
-# someName: someValue
-
-bases:
-- ../crd
-- ../rbac
-- ../manager
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
-# crd/kustomization.yaml
-#- ../webhook
-# [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
-
-patchesStrategicMerge:
-# Protect the /metrics endpoint by putting it behind auth.
-# If you want your controller-manager to expose the /metrics
-# endpoint w/o any authn/z, please comment the following line.
-- manager_auth_proxy_patch.yaml
-
-# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
-# crd/kustomization.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
diff --git a/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml b/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml
deleted file mode 100644
index 352b2e3164f..00000000000
--- a/testdata/project-v3/config/default/manager_auth_proxy_patch.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-# This patch inject a sidecar container which is a HTTP proxy for the
-# controller manager, it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
-spec:
- template:
- spec:
- containers:
- - name: kube-rbac-proxy
- securityContext:
- allowPrivilegeEscalation: false
- capabilities:
- drop:
- - "ALL"
- image: gcr.io/kubebuilder/kube-rbac-proxy:v0.13.1
- args:
- - "--secure-listen-address=0.0.0.0:8443"
- - "--upstream=http://127.0.0.1:8080/"
- - "--logtostderr=true"
- - "--v=0"
- ports:
- - containerPort: 8443
- protocol: TCP
- name: https
- resources:
- limits:
- cpu: 500m
- memory: 128Mi
- requests:
- cpu: 5m
- memory: 64Mi
- - name: manager
- args:
- - "--health-probe-bind-address=:8081"
- - "--metrics-bind-address=127.0.0.1:8080"
- - "--leader-elect"
diff --git a/testdata/project-v3/config/default/manager_config_patch.yaml b/testdata/project-v3/config/default/manager_config_patch.yaml
deleted file mode 100644
index f6f58916922..00000000000
--- a/testdata/project-v3/config/default/manager_config_patch.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
-spec:
- template:
- spec:
- containers:
- - name: manager
diff --git a/testdata/project-v3/config/default/manager_webhook_patch.yaml b/testdata/project-v3/config/default/manager_webhook_patch.yaml
deleted file mode 100644
index 738de350b71..00000000000
--- a/testdata/project-v3/config/default/manager_webhook_patch.yaml
+++ /dev/null
@@ -1,23 +0,0 @@
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
-spec:
- template:
- spec:
- containers:
- - name: manager
- ports:
- - containerPort: 9443
- name: webhook-server
- protocol: TCP
- volumeMounts:
- - mountPath: /tmp/k8s-webhook-server/serving-certs
- name: cert
- readOnly: true
- volumes:
- - name: cert
- secret:
- defaultMode: 420
- secretName: webhook-server-cert
diff --git a/testdata/project-v3/config/default/webhookcainjection_patch.yaml b/testdata/project-v3/config/default/webhookcainjection_patch.yaml
deleted file mode 100644
index 9f48225f1e4..00000000000
--- a/testdata/project-v3/config/default/webhookcainjection_patch.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-# This patch add annotation to admission webhook config and
-# the variables $(CERTIFICATE_NAMESPACE) and $(CERTIFICATE_NAME) will be substituted by kustomize.
-apiVersion: admissionregistration.k8s.io/v1
-kind: MutatingWebhookConfiguration
-metadata:
- labels:
- app.kubernetes.io/name: mutatingwebhookconfiguration
- app.kubernetes.io/instance: mutating-webhook-configuration
- app.kubernetes.io/component: webhook
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: mutating-webhook-configuration
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
----
-apiVersion: admissionregistration.k8s.io/v1
-kind: ValidatingWebhookConfiguration
-metadata:
- labels:
- app.kubernetes.io/name: validatingwebhookconfiguration
- app.kubernetes.io/instance: validating-webhook-configuration
- app.kubernetes.io/component: webhook
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: validating-webhook-configuration
- annotations:
- cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
diff --git a/testdata/project-v3/config/manager/kustomization.yaml b/testdata/project-v3/config/manager/kustomization.yaml
deleted file mode 100644
index 5c5f0b84cba..00000000000
--- a/testdata/project-v3/config/manager/kustomization.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-resources:
-- manager.yaml
diff --git a/testdata/project-v3/config/manager/manager.yaml b/testdata/project-v3/config/manager/manager.yaml
deleted file mode 100644
index 575431e4f20..00000000000
--- a/testdata/project-v3/config/manager/manager.yaml
+++ /dev/null
@@ -1,102 +0,0 @@
-apiVersion: v1
-kind: Namespace
-metadata:
- labels:
- control-plane: controller-manager
- app.kubernetes.io/name: namespace
- app.kubernetes.io/instance: system
- app.kubernetes.io/component: manager
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: system
----
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: controller-manager
- namespace: system
- labels:
- control-plane: controller-manager
- app.kubernetes.io/name: deployment
- app.kubernetes.io/instance: controller-manager
- app.kubernetes.io/component: manager
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
-spec:
- selector:
- matchLabels:
- control-plane: controller-manager
- replicas: 1
- template:
- metadata:
- annotations:
- kubectl.kubernetes.io/default-container: manager
- labels:
- control-plane: controller-manager
- spec:
- # TODO(user): Uncomment the following code to configure the nodeAffinity expression
- # according to the platforms which are supported by your solution.
- # It is considered best practice to support multiple architectures. You can
- # build your manager image using the makefile target docker-buildx.
- # affinity:
- # nodeAffinity:
- # requiredDuringSchedulingIgnoredDuringExecution:
- # nodeSelectorTerms:
- # - matchExpressions:
- # - key: kubernetes.io/arch
- # operator: In
- # values:
- # - amd64
- # - arm64
- # - ppc64le
- # - s390x
- # - key: kubernetes.io/os
- # operator: In
- # values:
- # - linux
- securityContext:
- runAsNonRoot: true
- # TODO(user): For common cases that do not require escalating privileges
- # it is recommended to ensure that all your Pods/Containers are restrictive.
- # More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted
- # Please uncomment the following code if your project does NOT have to work on old Kubernetes
- # versions < 1.19 or on vendors versions which do NOT support this field by default (i.e. Openshift < 4.11 ).
- # seccompProfile:
- # type: RuntimeDefault
- containers:
- - command:
- - /manager
- args:
- - --leader-elect
- image: controller:latest
- name: manager
- securityContext:
- allowPrivilegeEscalation: false
- capabilities:
- drop:
- - "ALL"
- livenessProbe:
- httpGet:
- path: /healthz
- port: 8081
- initialDelaySeconds: 15
- periodSeconds: 20
- readinessProbe:
- httpGet:
- path: /readyz
- port: 8081
- initialDelaySeconds: 5
- periodSeconds: 10
- # TODO(user): Configure the resources accordingly based on the project requirements.
- # More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
- resources:
- limits:
- cpu: 500m
- memory: 128Mi
- requests:
- cpu: 10m
- memory: 64Mi
- serviceAccountName: controller-manager
- terminationGracePeriodSeconds: 10
diff --git a/testdata/project-v3/config/prometheus/kustomization.yaml b/testdata/project-v3/config/prometheus/kustomization.yaml
deleted file mode 100644
index ed137168a1d..00000000000
--- a/testdata/project-v3/config/prometheus/kustomization.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-resources:
-- monitor.yaml
diff --git a/testdata/project-v3/config/prometheus/monitor.yaml b/testdata/project-v3/config/prometheus/monitor.yaml
deleted file mode 100644
index 8af78711b6e..00000000000
--- a/testdata/project-v3/config/prometheus/monitor.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-# Prometheus Monitor Service (Metrics)
-apiVersion: monitoring.coreos.com/v1
-kind: ServiceMonitor
-metadata:
- labels:
- control-plane: controller-manager
- app.kubernetes.io/name: servicemonitor
- app.kubernetes.io/instance: controller-manager-metrics-monitor
- app.kubernetes.io/component: metrics
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: controller-manager-metrics-monitor
- namespace: system
-spec:
- endpoints:
- - path: /metrics
- port: https
- scheme: https
- bearerTokenFile: /var/run/secrets/kubernetes.io/serviceaccount/token
- tlsConfig:
- insecureSkipVerify: true
- selector:
- matchLabels:
- control-plane: controller-manager
diff --git a/testdata/project-v3/config/rbac/admiral_editor_role.yaml b/testdata/project-v3/config/rbac/admiral_editor_role.yaml
deleted file mode 100644
index 0355b00c00c..00000000000
--- a/testdata/project-v3/config/rbac/admiral_editor_role.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-# permissions for end users to edit admirales.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app.kubernetes.io/name: clusterrole
- app.kubernetes.io/instance: admiral-editor-role
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: admiral-editor-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirales
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirales/status
- verbs:
- - get
diff --git a/testdata/project-v3/config/rbac/admiral_viewer_role.yaml b/testdata/project-v3/config/rbac/admiral_viewer_role.yaml
deleted file mode 100644
index 1b5764f58d4..00000000000
--- a/testdata/project-v3/config/rbac/admiral_viewer_role.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-# permissions for end users to view admirales.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app.kubernetes.io/name: clusterrole
- app.kubernetes.io/instance: admiral-viewer-role
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: admiral-viewer-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirales
- verbs:
- - get
- - list
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirales/status
- verbs:
- - get
diff --git a/testdata/project-v3/config/rbac/auth_proxy_client_clusterrole.yaml b/testdata/project-v3/config/rbac/auth_proxy_client_clusterrole.yaml
deleted file mode 100644
index 8986f32ea34..00000000000
--- a/testdata/project-v3/config/rbac/auth_proxy_client_clusterrole.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app.kubernetes.io/name: clusterrole
- app.kubernetes.io/instance: metrics-reader
- app.kubernetes.io/component: kube-rbac-proxy
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: metrics-reader
-rules:
-- nonResourceURLs:
- - "/metrics"
- verbs:
- - get
diff --git a/testdata/project-v3/config/rbac/auth_proxy_role.yaml b/testdata/project-v3/config/rbac/auth_proxy_role.yaml
deleted file mode 100644
index dc58428ef6c..00000000000
--- a/testdata/project-v3/config/rbac/auth_proxy_role.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app.kubernetes.io/name: clusterrole
- app.kubernetes.io/instance: proxy-role
- app.kubernetes.io/component: kube-rbac-proxy
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: proxy-role
-rules:
-- apiGroups:
- - authentication.k8s.io
- resources:
- - tokenreviews
- verbs:
- - create
-- apiGroups:
- - authorization.k8s.io
- resources:
- - subjectaccessreviews
- verbs:
- - create
diff --git a/testdata/project-v3/config/rbac/auth_proxy_role_binding.yaml b/testdata/project-v3/config/rbac/auth_proxy_role_binding.yaml
deleted file mode 100644
index 321c945c590..00000000000
--- a/testdata/project-v3/config/rbac/auth_proxy_role_binding.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
- labels:
- app.kubernetes.io/name: clusterrolebinding
- app.kubernetes.io/instance: proxy-rolebinding
- app.kubernetes.io/component: kube-rbac-proxy
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: proxy-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: proxy-role
-subjects:
-- kind: ServiceAccount
- name: controller-manager
- namespace: system
diff --git a/testdata/project-v3/config/rbac/auth_proxy_service.yaml b/testdata/project-v3/config/rbac/auth_proxy_service.yaml
deleted file mode 100644
index 16d323847d8..00000000000
--- a/testdata/project-v3/config/rbac/auth_proxy_service.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-apiVersion: v1
-kind: Service
-metadata:
- labels:
- control-plane: controller-manager
- app.kubernetes.io/name: service
- app.kubernetes.io/instance: controller-manager-metrics-service
- app.kubernetes.io/component: kube-rbac-proxy
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: controller-manager-metrics-service
- namespace: system
-spec:
- ports:
- - name: https
- port: 8443
- protocol: TCP
- targetPort: https
- selector:
- control-plane: controller-manager
diff --git a/testdata/project-v3/config/rbac/captain_editor_role.yaml b/testdata/project-v3/config/rbac/captain_editor_role.yaml
deleted file mode 100644
index 228d1cba109..00000000000
--- a/testdata/project-v3/config/rbac/captain_editor_role.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-# permissions for end users to edit captains.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app.kubernetes.io/name: clusterrole
- app.kubernetes.io/instance: captain-editor-role
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: captain-editor-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains/status
- verbs:
- - get
diff --git a/testdata/project-v3/config/rbac/captain_viewer_role.yaml b/testdata/project-v3/config/rbac/captain_viewer_role.yaml
deleted file mode 100644
index 96863bab25f..00000000000
--- a/testdata/project-v3/config/rbac/captain_viewer_role.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-# permissions for end users to view captains.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app.kubernetes.io/name: clusterrole
- app.kubernetes.io/instance: captain-viewer-role
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: captain-viewer-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains
- verbs:
- - get
- - list
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains/status
- verbs:
- - get
diff --git a/testdata/project-v3/config/rbac/firstmate_editor_role.yaml b/testdata/project-v3/config/rbac/firstmate_editor_role.yaml
deleted file mode 100644
index 12cd7d95abb..00000000000
--- a/testdata/project-v3/config/rbac/firstmate_editor_role.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-# permissions for end users to edit firstmates.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app.kubernetes.io/name: clusterrole
- app.kubernetes.io/instance: firstmate-editor-role
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: firstmate-editor-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates/status
- verbs:
- - get
diff --git a/testdata/project-v3/config/rbac/firstmate_viewer_role.yaml b/testdata/project-v3/config/rbac/firstmate_viewer_role.yaml
deleted file mode 100644
index 6aaf8ff300c..00000000000
--- a/testdata/project-v3/config/rbac/firstmate_viewer_role.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-# permissions for end users to view firstmates.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- labels:
- app.kubernetes.io/name: clusterrole
- app.kubernetes.io/instance: firstmate-viewer-role
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: firstmate-viewer-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates
- verbs:
- - get
- - list
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates/status
- verbs:
- - get
diff --git a/testdata/project-v3/config/rbac/kustomization.yaml b/testdata/project-v3/config/rbac/kustomization.yaml
deleted file mode 100644
index 731832a6ac3..00000000000
--- a/testdata/project-v3/config/rbac/kustomization.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-resources:
-# All RBAC will be applied under this service account in
-# the deployment namespace. You may comment out this resource
-# if your manager will use a service account that exists at
-# runtime. Be sure to update RoleBinding and ClusterRoleBinding
-# subjects if changing service account names.
-- service_account.yaml
-- role.yaml
-- role_binding.yaml
-- leader_election_role.yaml
-- leader_election_role_binding.yaml
-# Comment the following 4 lines if you want to disable
-# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
-# which protects your /metrics endpoint.
-- auth_proxy_service.yaml
-- auth_proxy_role.yaml
-- auth_proxy_role_binding.yaml
-- auth_proxy_client_clusterrole.yaml
diff --git a/testdata/project-v3/config/rbac/leader_election_role.yaml b/testdata/project-v3/config/rbac/leader_election_role.yaml
deleted file mode 100644
index 9cb87b74c83..00000000000
--- a/testdata/project-v3/config/rbac/leader_election_role.yaml
+++ /dev/null
@@ -1,44 +0,0 @@
-# permissions to do leader election.
-apiVersion: rbac.authorization.k8s.io/v1
-kind: Role
-metadata:
- labels:
- app.kubernetes.io/name: role
- app.kubernetes.io/instance: leader-election-role
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: leader-election-role
-rules:
-- apiGroups:
- - ""
- resources:
- - configmaps
- verbs:
- - get
- - list
- - watch
- - create
- - update
- - patch
- - delete
-- apiGroups:
- - coordination.k8s.io
- resources:
- - leases
- verbs:
- - get
- - list
- - watch
- - create
- - update
- - patch
- - delete
-- apiGroups:
- - ""
- resources:
- - events
- verbs:
- - create
- - patch
diff --git a/testdata/project-v3/config/rbac/leader_election_role_binding.yaml b/testdata/project-v3/config/rbac/leader_election_role_binding.yaml
deleted file mode 100644
index 795be7386cd..00000000000
--- a/testdata/project-v3/config/rbac/leader_election_role_binding.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: RoleBinding
-metadata:
- labels:
- app.kubernetes.io/name: rolebinding
- app.kubernetes.io/instance: leader-election-rolebinding
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: leader-election-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: Role
- name: leader-election-role
-subjects:
-- kind: ServiceAccount
- name: controller-manager
- namespace: system
diff --git a/testdata/project-v3/config/rbac/role.yaml b/testdata/project-v3/config/rbac/role.yaml
deleted file mode 100644
index 8c4e2fa042c..00000000000
--- a/testdata/project-v3/config/rbac/role.yaml
+++ /dev/null
@@ -1,111 +0,0 @@
----
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRole
-metadata:
- creationTimestamp: null
- name: manager-role
-rules:
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirales
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirales/finalizers
- verbs:
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - admirales/status
- verbs:
- - get
- - patch
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains/finalizers
- verbs:
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - captains/status
- verbs:
- - get
- - patch
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates/finalizers
- verbs:
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - firstmates/status
- verbs:
- - get
- - patch
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - lakers
- verbs:
- - create
- - delete
- - get
- - list
- - patch
- - update
- - watch
-- apiGroups:
- - crew.testproject.org
- resources:
- - lakers/finalizers
- verbs:
- - update
-- apiGroups:
- - crew.testproject.org
- resources:
- - lakers/status
- verbs:
- - get
- - patch
- - update
diff --git a/testdata/project-v3/config/rbac/role_binding.yaml b/testdata/project-v3/config/rbac/role_binding.yaml
deleted file mode 100644
index 76f9a9355ca..00000000000
--- a/testdata/project-v3/config/rbac/role_binding.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
- labels:
- app.kubernetes.io/name: clusterrolebinding
- app.kubernetes.io/instance: manager-rolebinding
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: manager-rolebinding
-roleRef:
- apiGroup: rbac.authorization.k8s.io
- kind: ClusterRole
- name: manager-role
-subjects:
-- kind: ServiceAccount
- name: controller-manager
- namespace: system
diff --git a/testdata/project-v3/config/rbac/service_account.yaml b/testdata/project-v3/config/rbac/service_account.yaml
deleted file mode 100644
index 54b460ce357..00000000000
--- a/testdata/project-v3/config/rbac/service_account.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-apiVersion: v1
-kind: ServiceAccount
-metadata:
- labels:
- app.kubernetes.io/name: serviceaccount
- app.kubernetes.io/instance: controller-manager
- app.kubernetes.io/component: rbac
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: controller-manager
- namespace: system
diff --git a/testdata/project-v3/config/samples/crew_v1_admiral.yaml b/testdata/project-v3/config/samples/crew_v1_admiral.yaml
deleted file mode 100644
index d71e9561bf1..00000000000
--- a/testdata/project-v3/config/samples/crew_v1_admiral.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-apiVersion: crew.testproject.org/v1
-kind: Admiral
-metadata:
- labels:
- app.kubernetes.io/name: admiral
- app.kubernetes.io/instance: admiral-sample
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- app.kubernetes.io/created-by: project-v3
- name: admiral-sample
-spec:
- # TODO(user): Add fields here
diff --git a/testdata/project-v3/config/samples/crew_v1_captain.yaml b/testdata/project-v3/config/samples/crew_v1_captain.yaml
deleted file mode 100644
index c9ce22986b9..00000000000
--- a/testdata/project-v3/config/samples/crew_v1_captain.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-apiVersion: crew.testproject.org/v1
-kind: Captain
-metadata:
- labels:
- app.kubernetes.io/name: captain
- app.kubernetes.io/instance: captain-sample
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- app.kubernetes.io/created-by: project-v3
- name: captain-sample
-spec:
- # TODO(user): Add fields here
diff --git a/testdata/project-v3/config/samples/crew_v1_firstmate.yaml b/testdata/project-v3/config/samples/crew_v1_firstmate.yaml
deleted file mode 100644
index bdce9213dcc..00000000000
--- a/testdata/project-v3/config/samples/crew_v1_firstmate.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-apiVersion: crew.testproject.org/v1
-kind: FirstMate
-metadata:
- labels:
- app.kubernetes.io/name: firstmate
- app.kubernetes.io/instance: firstmate-sample
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- app.kubernetes.io/created-by: project-v3
- name: firstmate-sample
-spec:
- # TODO(user): Add fields here
diff --git a/testdata/project-v3/config/webhook/kustomization.yaml b/testdata/project-v3/config/webhook/kustomization.yaml
deleted file mode 100644
index 9cf26134e4d..00000000000
--- a/testdata/project-v3/config/webhook/kustomization.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-resources:
-- manifests.yaml
-- service.yaml
-
-configurations:
-- kustomizeconfig.yaml
diff --git a/testdata/project-v3/config/webhook/kustomizeconfig.yaml b/testdata/project-v3/config/webhook/kustomizeconfig.yaml
deleted file mode 100644
index 25e21e3c963..00000000000
--- a/testdata/project-v3/config/webhook/kustomizeconfig.yaml
+++ /dev/null
@@ -1,25 +0,0 @@
-# the following config is for teaching kustomize where to look at when substituting vars.
-# It requires kustomize v2.1.0 or newer to work properly.
-nameReference:
-- kind: Service
- version: v1
- fieldSpecs:
- - kind: MutatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/name
- - kind: ValidatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/name
-
-namespace:
-- kind: MutatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/namespace
- create: true
-- kind: ValidatingWebhookConfiguration
- group: admissionregistration.k8s.io
- path: webhooks/clientConfig/service/namespace
- create: true
-
-varReference:
-- path: metadata/annotations
diff --git a/testdata/project-v3/config/webhook/manifests.yaml b/testdata/project-v3/config/webhook/manifests.yaml
deleted file mode 100644
index 89f3689513d..00000000000
--- a/testdata/project-v3/config/webhook/manifests.yaml
+++ /dev/null
@@ -1,74 +0,0 @@
----
-apiVersion: admissionregistration.k8s.io/v1
-kind: MutatingWebhookConfiguration
-metadata:
- creationTimestamp: null
- name: mutating-webhook-configuration
-webhooks:
-- admissionReviewVersions:
- - v1
- clientConfig:
- service:
- name: webhook-service
- namespace: system
- path: /mutate-crew-testproject-org-v1-admiral
- failurePolicy: Fail
- name: madmiral.kb.io
- rules:
- - apiGroups:
- - crew.testproject.org
- apiVersions:
- - v1
- operations:
- - CREATE
- - UPDATE
- resources:
- - admirales
- sideEffects: None
-- admissionReviewVersions:
- - v1
- clientConfig:
- service:
- name: webhook-service
- namespace: system
- path: /mutate-crew-testproject-org-v1-captain
- failurePolicy: Fail
- name: mcaptain.kb.io
- rules:
- - apiGroups:
- - crew.testproject.org
- apiVersions:
- - v1
- operations:
- - CREATE
- - UPDATE
- resources:
- - captains
- sideEffects: None
----
-apiVersion: admissionregistration.k8s.io/v1
-kind: ValidatingWebhookConfiguration
-metadata:
- creationTimestamp: null
- name: validating-webhook-configuration
-webhooks:
-- admissionReviewVersions:
- - v1
- clientConfig:
- service:
- name: webhook-service
- namespace: system
- path: /validate-crew-testproject-org-v1-captain
- failurePolicy: Fail
- name: vcaptain.kb.io
- rules:
- - apiGroups:
- - crew.testproject.org
- apiVersions:
- - v1
- operations:
- - CREATE
- - UPDATE
- resources:
- - captains
- sideEffects: None
diff --git a/testdata/project-v3/config/webhook/service.yaml b/testdata/project-v3/config/webhook/service.yaml
deleted file mode 100644
index 13742f8fb1f..00000000000
--- a/testdata/project-v3/config/webhook/service.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-apiVersion: v1
-kind: Service
-metadata:
- labels:
- app.kubernetes.io/name: service
- app.kubernetes.io/instance: webhook-service
- app.kubernetes.io/component: webhook
- app.kubernetes.io/created-by: project-v3
- app.kubernetes.io/part-of: project-v3
- app.kubernetes.io/managed-by: kustomize
- name: webhook-service
- namespace: system
-spec:
- ports:
- - port: 443
- protocol: TCP
- targetPort: 9443
- selector:
- control-plane: controller-manager
diff --git a/testdata/project-v3/controllers/admiral_controller.go b/testdata/project-v3/controllers/admiral_controller.go
deleted file mode 100644
index 3db3b3d8012..00000000000
--- a/testdata/project-v3/controllers/admiral_controller.go
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "context"
-
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/log"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v3/api/v1"
-)
-
-// AdmiralReconciler reconciles a Admiral object
-type AdmiralReconciler struct {
- client.Client
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirales,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirales/status,verbs=get;update;patch
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=admirales/finalizers,verbs=update
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the Admiral object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile
-func (r *AdmiralReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
- _ = log.FromContext(ctx)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *AdmiralReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- For(&crewv1.Admiral{}).
- Complete(r)
-}
diff --git a/testdata/project-v3/controllers/captain_controller.go b/testdata/project-v3/controllers/captain_controller.go
deleted file mode 100644
index db195c1e4dc..00000000000
--- a/testdata/project-v3/controllers/captain_controller.go
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "context"
-
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/log"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v3/api/v1"
-)
-
-// CaptainReconciler reconciles a Captain object
-type CaptainReconciler struct {
- client.Client
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=captains,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=captains/status,verbs=get;update;patch
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=captains/finalizers,verbs=update
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the Captain object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile
-func (r *CaptainReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
- _ = log.FromContext(ctx)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *CaptainReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- For(&crewv1.Captain{}).
- Complete(r)
-}
diff --git a/testdata/project-v3/controllers/firstmate_controller.go b/testdata/project-v3/controllers/firstmate_controller.go
deleted file mode 100644
index 94940534372..00000000000
--- a/testdata/project-v3/controllers/firstmate_controller.go
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "context"
-
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/log"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v3/api/v1"
-)
-
-// FirstMateReconciler reconciles a FirstMate object
-type FirstMateReconciler struct {
- client.Client
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates/status,verbs=get;update;patch
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=firstmates/finalizers,verbs=update
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the FirstMate object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile
-func (r *FirstMateReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
- _ = log.FromContext(ctx)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *FirstMateReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- For(&crewv1.FirstMate{}).
- Complete(r)
-}
diff --git a/testdata/project-v3/controllers/laker_controller.go b/testdata/project-v3/controllers/laker_controller.go
deleted file mode 100644
index 39f037b02bc..00000000000
--- a/testdata/project-v3/controllers/laker_controller.go
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "context"
-
- "k8s.io/apimachinery/pkg/runtime"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/log"
-)
-
-// LakerReconciler reconciles a Laker object
-type LakerReconciler struct {
- client.Client
- Scheme *runtime.Scheme
-}
-
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=lakers,verbs=get;list;watch;create;update;patch;delete
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=lakers/status,verbs=get;update;patch
-//+kubebuilder:rbac:groups=crew.testproject.org,resources=lakers/finalizers,verbs=update
-
-// Reconcile is part of the main kubernetes reconciliation loop which aims to
-// move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the Laker object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.14.4/pkg/reconcile
-func (r *LakerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
- _ = log.FromContext(ctx)
-
- // TODO(user): your logic here
-
- return ctrl.Result{}, nil
-}
-
-// SetupWithManager sets up the controller with the Manager.
-func (r *LakerReconciler) SetupWithManager(mgr ctrl.Manager) error {
- return ctrl.NewControllerManagedBy(mgr).
- // Uncomment the following line adding a pointer to an instance of the controlled resource as an argument
- // For().
- Complete(r)
-}
diff --git a/testdata/project-v3/controllers/suite_test.go b/testdata/project-v3/controllers/suite_test.go
deleted file mode 100644
index f9c01d744da..00000000000
--- a/testdata/project-v3/controllers/suite_test.go
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package controllers
-
-import (
- "path/filepath"
- "testing"
-
- . "github.com/onsi/ginkgo/v2"
- . "github.com/onsi/gomega"
-
- "k8s.io/client-go/kubernetes/scheme"
- "k8s.io/client-go/rest"
- "sigs.k8s.io/controller-runtime/pkg/client"
- "sigs.k8s.io/controller-runtime/pkg/envtest"
- logf "sigs.k8s.io/controller-runtime/pkg/log"
- "sigs.k8s.io/controller-runtime/pkg/log/zap"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v3/api/v1"
- //+kubebuilder:scaffold:imports
-)
-
-// These tests use Ginkgo (BDD-style Go testing framework). Refer to
-// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
-
-var cfg *rest.Config
-var k8sClient client.Client
-var testEnv *envtest.Environment
-
-func TestAPIs(t *testing.T) {
- RegisterFailHandler(Fail)
-
- RunSpecs(t, "Controller Suite")
-}
-
-var _ = BeforeSuite(func() {
- logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true)))
-
- By("bootstrapping test environment")
- testEnv = &envtest.Environment{
- CRDDirectoryPaths: []string{filepath.Join("..", "config", "crd", "bases")},
- ErrorIfCRDPathMissing: true,
- }
-
- var err error
- // cfg is defined in this file globally.
- cfg, err = testEnv.Start()
- Expect(err).NotTo(HaveOccurred())
- Expect(cfg).NotTo(BeNil())
-
- err = crewv1.AddToScheme(scheme.Scheme)
- Expect(err).NotTo(HaveOccurred())
-
- //+kubebuilder:scaffold:scheme
-
- k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
- Expect(err).NotTo(HaveOccurred())
- Expect(k8sClient).NotTo(BeNil())
-
-})
-
-var _ = AfterSuite(func() {
- By("tearing down the test environment")
- err := testEnv.Stop()
- Expect(err).NotTo(HaveOccurred())
-})
diff --git a/testdata/project-v3/go.mod b/testdata/project-v3/go.mod
deleted file mode 100644
index 300032446aa..00000000000
--- a/testdata/project-v3/go.mod
+++ /dev/null
@@ -1,70 +0,0 @@
-module sigs.k8s.io/kubebuilder/testdata/project-v3
-
-go 1.19
-
-require (
- github.com/onsi/ginkgo/v2 v2.6.0
- github.com/onsi/gomega v1.24.1
- 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.4
-)
-
-require (
- github.com/beorn7/perks v1.0.1 // indirect
- github.com/cespare/xxhash/v2 v2.1.2 // indirect
- github.com/davecgh/go-spew v1.1.1 // indirect
- github.com/emicklei/go-restful/v3 v3.9.0 // indirect
- github.com/evanphx/json-patch/v5 v5.6.0 // indirect
- github.com/fsnotify/fsnotify v1.6.0 // indirect
- github.com/go-logr/logr v1.2.3 // indirect
- github.com/go-logr/zapr v1.2.3 // indirect
- github.com/go-openapi/jsonpointer v0.19.5 // indirect
- github.com/go-openapi/jsonreference v0.20.0 // indirect
- github.com/go-openapi/swag v0.19.14 // indirect
- github.com/gogo/protobuf v1.3.2 // indirect
- github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
- github.com/golang/protobuf v1.5.2 // indirect
- github.com/google/gnostic v0.5.7-v3refs // indirect
- github.com/google/go-cmp v0.5.9 // indirect
- github.com/google/gofuzz v1.1.0 // indirect
- github.com/google/uuid v1.1.2 // indirect
- github.com/imdario/mergo v0.3.6 // indirect
- github.com/josharian/intern v1.0.0 // indirect
- github.com/json-iterator/go v1.1.12 // indirect
- github.com/mailru/easyjson v0.7.6 // indirect
- github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
- github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
- github.com/modern-go/reflect2 v1.0.2 // indirect
- github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
- github.com/pkg/errors v0.9.1 // indirect
- github.com/prometheus/client_golang v1.14.0 // indirect
- github.com/prometheus/client_model v0.3.0 // indirect
- github.com/prometheus/common v0.37.0 // indirect
- github.com/prometheus/procfs v0.8.0 // indirect
- github.com/spf13/pflag v1.0.5 // indirect
- go.uber.org/atomic v1.7.0 // indirect
- go.uber.org/multierr v1.6.0 // indirect
- go.uber.org/zap v1.24.0 // indirect
- golang.org/x/net v0.3.1-0.20221206200815-1e63c2f08a10 // indirect
- golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
- golang.org/x/sys v0.3.0 // indirect
- golang.org/x/term v0.3.0 // indirect
- golang.org/x/text v0.5.0 // indirect
- golang.org/x/time v0.3.0 // indirect
- gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
- google.golang.org/appengine v1.6.7 // indirect
- google.golang.org/protobuf v1.28.1 // indirect
- gopkg.in/inf.v0 v0.9.1 // indirect
- gopkg.in/yaml.v2 v2.4.0 // indirect
- gopkg.in/yaml.v3 v3.0.1 // indirect
- k8s.io/apiextensions-apiserver v0.26.1 // indirect
- k8s.io/component-base v0.26.1 // indirect
- k8s.io/klog/v2 v2.80.1 // indirect
- k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
- k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 // indirect
- sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
- sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
- sigs.k8s.io/yaml v1.3.0 // indirect
-)
diff --git a/testdata/project-v3/hack/boilerplate.go.txt b/testdata/project-v3/hack/boilerplate.go.txt
deleted file mode 100644
index 0d32012672a..00000000000
--- a/testdata/project-v3/hack/boilerplate.go.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
\ No newline at end of file
diff --git a/testdata/project-v3/main.go b/testdata/project-v3/main.go
deleted file mode 100644
index 60fe6faaad5..00000000000
--- a/testdata/project-v3/main.go
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
-Copyright 2024 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.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-*/
-
-package main
-
-import (
- "crypto/tls"
- "flag"
- "os"
-
- // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
- // to ensure that exec-entrypoint and run can make use of them.
- _ "k8s.io/client-go/plugin/pkg/client/auth"
-
- "k8s.io/apimachinery/pkg/runtime"
- utilruntime "k8s.io/apimachinery/pkg/util/runtime"
- clientgoscheme "k8s.io/client-go/kubernetes/scheme"
- ctrl "sigs.k8s.io/controller-runtime"
- "sigs.k8s.io/controller-runtime/pkg/healthz"
- "sigs.k8s.io/controller-runtime/pkg/log/zap"
- "sigs.k8s.io/controller-runtime/pkg/webhook"
-
- crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v3/api/v1"
- "sigs.k8s.io/kubebuilder/testdata/project-v3/controllers"
- //+kubebuilder:scaffold:imports
-)
-
-var (
- scheme = runtime.NewScheme()
- setupLog = ctrl.Log.WithName("setup")
-)
-
-func init() {
- utilruntime.Must(clientgoscheme.AddToScheme(scheme))
-
- utilruntime.Must(crewv1.AddToScheme(scheme))
- //+kubebuilder:scaffold:scheme
-}
-
-func main() {
- var metricsAddr string
- var enableLeaderElection bool
- var probeAddr string
- var enableHTTP2 bool
- flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
- flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
- flag.BoolVar(&enableLeaderElection, "leader-elect", false,
- "Enable leader election for controller manager. "+
- "Enabling this will ensure there is only one active controller manager.")
- flag.BoolVar(&enableHTTP2, "enable-http2", false,
- "If set, HTTP/2 will be enabled for the metrics and webhook servers")
- opts := zap.Options{
- Development: true,
- }
- opts.BindFlags(flag.CommandLine)
- flag.Parse()
-
- ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
-
- // if the enable-http2 flag is false (the default), http/2 should be disabled
- // due to its vulnerabilities. More specifically, disabling http/2 will
- // prevent from being vulnerable to the HTTP/2 Stream Cancellation and
- // Rapid Reset CVEs. For more information see:
- // - https://github.com/advisories/GHSA-qppj-fm5r-hxr3
- // - https://github.com/advisories/GHSA-4374-p667-p6c8
- disableHTTP2 := func(c *tls.Config) {
- setupLog.Info("disabling http/2")
- c.NextProtos = []string{"http/1.1"}
- }
-
- tlsOpts := []func(*tls.Config){}
- if !enableHTTP2 {
- tlsOpts = append(tlsOpts, disableHTTP2)
- }
-
- mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
- Scheme: scheme,
- MetricsBindAddress: metricsAddr,
- WebhookServer: &webhook.Server{
- TLSOpts: tlsOpts,
- },
- Port: 9443,
- HealthProbeBindAddress: probeAddr,
- LeaderElection: enableLeaderElection,
- LeaderElectionID: "dd1da13f.testproject.org",
- // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
- // when the Manager ends. This requires the binary to immediately end when the
- // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
- // speeds up voluntary leader transitions as the new leader don't have to wait
- // LeaseDuration time first.
- //
- // In the default scaffold provided, the program ends immediately after
- // the manager stops, so would be fine to enable this option. However,
- // if you are doing or is intended to do any operation such as perform cleanups
- // after the manager stops then its usage might be unsafe.
- // LeaderElectionReleaseOnCancel: true,
- })
- if err != nil {
- setupLog.Error(err, "unable to start manager")
- os.Exit(1)
- }
-
- if err = (&controllers.CaptainReconciler{
- Client: mgr.GetClient(),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "Captain")
- os.Exit(1)
- }
- if err = (&crewv1.Captain{}).SetupWebhookWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create webhook", "webhook", "Captain")
- os.Exit(1)
- }
- if err = (&controllers.FirstMateReconciler{
- Client: mgr.GetClient(),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "FirstMate")
- os.Exit(1)
- }
- if err = (&crewv1.FirstMate{}).SetupWebhookWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create webhook", "webhook", "FirstMate")
- os.Exit(1)
- }
- if err = (&controllers.AdmiralReconciler{
- Client: mgr.GetClient(),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "Admiral")
- os.Exit(1)
- }
- if err = (&crewv1.Admiral{}).SetupWebhookWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create webhook", "webhook", "Admiral")
- os.Exit(1)
- }
- if err = (&controllers.LakerReconciler{
- Client: mgr.GetClient(),
- Scheme: mgr.GetScheme(),
- }).SetupWithManager(mgr); err != nil {
- setupLog.Error(err, "unable to create controller", "controller", "Laker")
- os.Exit(1)
- }
- //+kubebuilder:scaffold:builder
-
- if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
- setupLog.Error(err, "unable to set up health check")
- os.Exit(1)
- }
- if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
- setupLog.Error(err, "unable to set up ready check")
- os.Exit(1)
- }
-
- setupLog.Info("starting manager")
- if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
- setupLog.Error(err, "problem running manager")
- os.Exit(1)
- }
-}