From 0f3db0067df41222e415eab91a1417fa412ba621 Mon Sep 17 00:00:00 2001 From: Joel Pepper Date: Wed, 21 Jun 2023 12:44:42 +0200 Subject: [PATCH 01/11] fix(completion): Fix completion in deprecated projects Currently, when initializing in a project with deprecated plugins the kubebuilder cli will immediately output a deprecation notice to stdout before even parsing the command. While this is acceptable and even desirable for interactive usage of the cli, it will "randomly" (i.e. dependent on $PWD and not on the command) break automated usage of the kubebuilder output. This, again is fine if kubebuilder makes no guarantees of stable machine readable output, but this does not hold for the completion sub commands which are only ever parsed by machines: The output of "kubebuilder completion " must always only output the exact script generated by cobra and the cobra internal commands __complete and __completeNoDesc must only only return an exact list of completion options. In deprecated projects this will break shell completion if the shell is started in the directory and if the completion script is correctly initialized, all completion options will be polluted by the massive deprecation notice. This commit instead changes the deprecation notice to output to stderr (while maintaining the return code of the actual command). This fixes the completion usecase which only reads in stdout, and should not break existing integrations, unless there exist scripts which use the length of stderr to check for errors rather than the return code of the call. Signed-off-by: Joel Pepper --- pkg/cli/cli.go | 2 +- pkg/cli/cli_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/cli/cli.go b/pkg/cli/cli.go index 7b74436db7d..af50425603b 100644 --- a/pkg/cli/cli.go +++ b/pkg/cli/cli.go @@ -444,7 +444,7 @@ func (c *CLI) addExtraCommands() error { func (c CLI) printDeprecationWarnings() { for _, p := range c.resolvedPlugins { if p != nil && p.(plugin.Deprecated) != nil && len(p.(plugin.Deprecated).DeprecationWarning()) > 0 { - fmt.Printf(noticeColor, fmt.Sprintf(deprecationFmt, p.(plugin.Deprecated).DeprecationWarning())) + fmt.Fprintf(os.Stderr, noticeColor, fmt.Sprintf(deprecationFmt, p.(plugin.Deprecated).DeprecationWarning())) } } } diff --git a/pkg/cli/cli_test.go b/pkg/cli/cli_test.go index 7503e2cf18b..ae5f8c7023f 100644 --- a/pkg/cli/cli_test.go +++ b/pkg/cli/cli_test.go @@ -592,13 +592,13 @@ plugins: ) deprecatedPlugin := newMockDeprecatedPlugin("deprecated", "v1", deprecationWarning, projectVersion) - // Overwrite stdout to read the output and reset it afterwards + // Overwrite stderr to read the deprecation output and reset it afterwards r, w, _ := os.Pipe() - temp := os.Stdout + temp := os.Stderr defer func() { - os.Stdout = temp + os.Stderr = temp }() - os.Stdout = w + os.Stderr = w c, err = New( WithPlugins(deprecatedPlugin), From d5ccc155589f8de5a7fccec0c31e64a0daadd8cd Mon Sep 17 00:00:00 2001 From: Eileen Date: Thu, 6 Jul 2023 19:14:44 -0400 Subject: [PATCH 02/11] docs: add tutorial for external plugin Co-authored-by: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Co-authored-by: Rashmi Gottipati Co-authored-by: Bryce Palmer Co-authored-by: Tony Jin --- docs/book/src/SUMMARY.md | 1 + docs/book/src/plugins/external-plugins.md | 156 ++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 docs/book/src/plugins/external-plugins.md diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md index 40773b5e525..bf6aa49abf5 100644 --- a/docs/book/src/SUMMARY.md +++ b/docs/book/src/SUMMARY.md @@ -130,6 +130,7 @@ - [Creating your own plugins](./plugins/creating-plugins.md) - [Testing your own plugins](./plugins/testing-plugins.md) - [Plugins Versioning](./plugins/plugins-versioning.md) + - [Extending Kubebuilder with external plugins](./plugins/external-plugins.md) --- diff --git a/docs/book/src/plugins/external-plugins.md b/docs/book/src/plugins/external-plugins.md new file mode 100644 index 00000000000..a6548a4f297 --- /dev/null +++ b/docs/book/src/plugins/external-plugins.md @@ -0,0 +1,156 @@ +# Extending Kubebuilder with external plugins + +## Overview + +Kubebuilder's functionality can be extended through the use of external plugins. + +An external plugin is an executable (can be written in any language) that implements an execution pattern that Kubebuilder knows how to interact with. + +The Kubebuilder CLI loads the external plugin in the specified path and interacts with it through `stdin` & `stdout`. + +## When is it useful? + +- If you want to create helpers or addons on top of the scaffolds done by Kubebuilder's default scaffolding. + +- If you design customized layouts and want to take advantage of functions from Kubebuilder library. + +- If you are looking for implementing plugins in a language other than `Go`. + +## How to write it? + +The inter-process communication between your external plugin and Kubebuilder is through the standard I/O. + +Your external plugin can be written in any language, given it adheres to the [PluginRequest][PluginRequest] and [PluginResponse][PluginResponse] type structures. + +`PluginRequest` encompasses all the data Kubebuilder collects from the CLI and previously executed plugins in the plugin chain. +Kubebuilder conveys the marshaled PluginRequest (a `JSON` object) to the external plugin over `stdin`. + +Below is a sample JSON object of the `PluginRequest` type, triggered by `kubebuilder init --plugins sampleexternalplugin/v1 --domain my.domain`: +```json +{ + "apiVersion": "v1alpha1", + "args": ["--domain", "my.domain"], + "command": "init", + "universe": {} +} +``` + +`PluginResponse` represents the updated state of the project, as modified by the plugin. This data structure is serialized into `JSON` and sent back to Kubebuilder via `stdout`. + +Here is a sample JSON representation of the `PluginResponse` type: +```json +{ + "apiVersion": "v1alpha1", + "command": "init", + "metadata": { + "description": "The `init` subcommand is meant to initialize a project via Kubebuilder. It scaffolds a single file: `initFile`", + "examples": "kubebuilder init --plugins sampleexternalplugin/v1 --domain my.domain" + }, + "universe": { + "initFile": "A simple file created with the `init` subcommand" + }, + "error": false, + "errorMsgs": [] +} +``` + +In this example, the `init` command of the plugin has created a new file called `initFile`. + +The content of this file is: `A simple file created with the init subcommand`, which is recorded in the `universe` field of the response. + +This output is then sent back to Kubebuilder, allowing it to incorporate the changes made by the plugin into the project. + + + +## How to use it? + +### Prerequisites +- kubebuilder CLI > 3.11.0 +- An executable for the external plugin. + + This could be a plugin that you've created yourself, or one from an external source. +- Configuration of the external plugin's path. + + This can be done by setting the `${EXTERNAL_PLUGINS_PATH}` environment variable, or by placing the plugin in a path that follows a `group-like name and version` scheme: +```sh +# for Linux +$HOME/.config/kubebuilder/plugins/${name}/${version} + +# for OSX +~/Library/Application Support/kubebuilder/plugins/${name}/${version} +``` + +### Subcommands: + +The external plugin supports the same subcommands as kubebuilder already provides: +- `init`: project initialization. +- `create api`: scaffold Kubernetes API definitions. +- `create webhook`: scaffold Kubernetes webhooks. +- `edit`: update the project configuration. + +Also, there are **Optional** subcommands for a better user experience: +- `metadata`: add customized plugin description and examples when a `--help` flag is specified. +- `flags`: specify valid flags for Kubebuilder to pass to the external plugin. + + + +### Configuration + +You can configure your plugin path with a ENV VAR `$EXTERNAL_PLUGINS_PATH` to tell Kubebuilder where to search for the plugin binary, such as: +```sh +export EXTERNAL_PLUGINS_PATH = +``` + +Otherwise, Kubebuilder would search for the plugins in a default path based on your OS. + +Now, you can using it by calling the CLI commands: +```sh +# Initialize a new project with the external plugin named `sampleplugin` +kubebuilder init --plugins sampleplugin/v1 + +# Display help information of the `init` subcommand of the external plugin +kubebuilder init --plugins sampleplugin/v1 --help + +# Create a new API with the above external plugin with a customized flag `number` +kubebuilder create api --plugins sampleplugin/v1 --number 2 + +# Create a webhook with the above external plugin with a customized flag `hooked` +kubebuilder create webhook --plugins sampleplugin/v1 --hooked + +# Update the project configuration with the above external plugin +kubebuilder edit --plugins sampleplugin/v1 + +# Create new APIs with external plugins v1 and v2 by respecting the plugin chaining order +kubebuilder create api --plugins sampleplugin/v1,sampleplugin/v2 + +# Create new APIs with the go/v4 plugin and then pass those files to the external plugin by respecting the plugin chaining order +kubebuilder create api --plugins go/v4,sampleplugin/v1 +``` + + +## Further resources + +- Check the [design proposal of the external plugin](https://github.com/kubernetes-sigs/kubebuilder/blob/master/designs/extensible-cli-and-scaffolding-plugins-phase-2.md) +- Check the [plugin implementation](https://github.com/kubernetes-sigs/kubebuilder/pull/2338) +- A [sample external plugin written in Go](https://github.com/kubernetes-sigs/kubebuilder/tree/master/docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1) +- A [sample external plugin written in Python](https://github.com/rashmigottipati/POC-Phase2-Plugins) +- A [sample external plugin written in JavaScript](https://github.com/Eileen-Yu/kb-js-plugin) + +[PluginRequest]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugin/external/types.go#L23 +[PluginResponse]: https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugin/external/types.go#L42 From 01681bb7fea0848d138636a8b76736531c550852 Mon Sep 17 00:00:00 2001 From: Benjamin <25504895+Benjaminvdv@users.noreply.github.com> Date: Wed, 2 Aug 2023 13:59:07 +0200 Subject: [PATCH 03/11] chore(docs): change folder pkg to internal/controller in the migration guide --- .../book/src/migration/manually_migration_guide_gov3_to_gov4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/src/migration/manually_migration_guide_gov3_to_gov4.md b/docs/book/src/migration/manually_migration_guide_gov3_to_gov4.md index 8ead1c1a293..1fccbb456d0 100644 --- a/docs/book/src/migration/manually_migration_guide_gov3_to_gov4.md +++ b/docs/book/src/migration/manually_migration_guide_gov3_to_gov4.md @@ -66,7 +66,7 @@ Therefore, you can check the changes in the layout results into: - If your project support multi-group the APIs are scaffold under a directory called `apis`. Rename this directory to `api` - Move the `controllers` directory under the `internal` and rename it for `controller` - Now ensure that the imports will be updated accordingly by: - - Update the `main.go` imports to look for the new path of your controllers under the `pkg` directory + - Update the `main.go` imports to look for the new path of your controllers under the `internal/controller` directory **Then, let's update the scaffolds paths** From 7cdcfa34ae499c0735d60c7180c61b5a027f45d2 Mon Sep 17 00:00:00 2001 From: Eileen Date: Thu, 3 Aug 2023 15:36:03 -0400 Subject: [PATCH 04/11] fix: ensure external plugin can scaffold files in new dirs --- pkg/plugins/external/helpers.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/plugins/external/helpers.go b/pkg/plugins/external/helpers.go index 702cb1dc84c..a1bc759317e 100644 --- a/pkg/plugins/external/helpers.go +++ b/pkg/plugins/external/helpers.go @@ -168,7 +168,15 @@ func handlePluginResponse(fs machinery.Filesystem, req external.PluginRequest, p } for filename, data := range res.Universe { - f, err := fs.FS.Create(filepath.Join(currentDir, filename)) + path := filepath.Join(currentDir, filename) + dir := filepath.Dir(path) + + // create the directory if it does not exist + if err := os.MkdirAll(dir, 0o750); err != nil { + return fmt.Errorf("error creating the directory: %v", err) + } + + f, err := fs.FS.Create(path) if err != nil { return err } From b1bf8bb9d7c1fd3fbe1751d3e946a544e435ab99 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 00:01:00 +0000 Subject: [PATCH 05/11] build(deps): bump golang.org/x/tools from 0.11.0 to 0.12.0 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.11.0 to 0.12.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.11.0...v0.12.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index aeb519b1c49..91c755c5f93 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ require ( github.com/spf13/afero v1.9.5 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - golang.org/x/text v0.11.0 - golang.org/x/tools v0.11.0 + golang.org/x/text v0.12.0 + golang.org/x/tools v0.12.0 sigs.k8s.io/yaml v1.3.0 ) @@ -24,8 +24,8 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.12.0 // indirect - golang.org/x/sys v0.10.0 // indirect + golang.org/x/net v0.14.0 // indirect + golang.org/x/sys v0.11.0 // indirect gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 45aa4224a8c..6b1f71c7eb8 100644 --- a/go.sum +++ b/go.sum @@ -256,8 +256,8 @@ golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -314,8 +314,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -325,8 +325,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -377,8 +377,8 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= -golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 136aac668f3fa4b59dbe381893776a634134abc3 Mon Sep 17 00:00:00 2001 From: Sajiyah Salat <109643863+Sajiyah-Salat@users.noreply.github.com> Date: Tue, 15 Aug 2023 18:34:45 +0530 Subject: [PATCH 06/11] :seedling: Image name edge cases covered (#3514) imagename edge case cover --- test/e2e/utils/test_context.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/e2e/utils/test_context.go b/test/e2e/utils/test_context.go index c10b8e138b9..6ee508eb74c 100644 --- a/test/e2e/utils/test_context.go +++ b/test/e2e/utils/test_context.go @@ -243,10 +243,16 @@ func (t *TestContext) Destroy() { //nolint:gosec // if image name is not present or not provided skip execution of docker command if t.ImageName != "" { - cmd := exec.Command("docker", "rmi", "-f", t.ImageName) - if _, err := t.Run(cmd); err != nil { - warnError(err) + // Check white space from image name + if len(strings.TrimSpace(t.ImageName)) == 0 { + fmt.Println("Image not set, skip cleaning up of docker image") + } else { + cmd := exec.Command("docker", "rmi", "-f", t.ImageName) + if _, err := t.Run(cmd); err != nil { + warnError(err) + } } + } if err := os.RemoveAll(t.Dir); err != nil { warnError(err) From 266a038a591fbfe1419074a95ab639adab3eb1dd Mon Sep 17 00:00:00 2001 From: Sajiyah Salat <109643863+Sajiyah-Salat@users.noreply.github.com> Date: Tue, 15 Aug 2023 18:35:13 +0530 Subject: [PATCH 07/11] :seedling: logs info updated (#3512) logs info updated --- .../generate_component_config.go | 6 ++--- .../cronjob-tutorial/generate_cronjob.go | 24 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hack/docs/internal/component-config-tutorial/generate_component_config.go b/hack/docs/internal/component-config-tutorial/generate_component_config.go index 897f80a306e..ffd872aa813 100644 --- a/hack/docs/internal/component-config-tutorial/generate_component_config.go +++ b/hack/docs/internal/component-config-tutorial/generate_component_config.go @@ -56,7 +56,7 @@ func newSampleContext(binaryPath string, samplePath string, env ...string) utils // Prepare the Context for the sample project func (sp *Sample) Prepare() { - log.Infof("destroying directory for sample project") + log.Infof("destroying directory for component_config sample project") sp.ctx.Destroy() log.Infof("refreshing tools and creating directory...") @@ -66,7 +66,7 @@ func (sp *Sample) Prepare() { } func (sp *Sample) GenerateSampleProject() { - log.Infof("Initializing the project") + log.Infof("Initializing the component config project") err := sp.ctx.Init( "--domain", "tutorial.kubebuilder.io", "--repo", "tutorial.kubebuilder.io/project", @@ -75,7 +75,7 @@ func (sp *Sample) GenerateSampleProject() { "--plugins=go/v4", "--component-config", ) - CheckError("Initializing the project", err) + CheckError("Initializing the component config project", err) log.Infof("Adding a new config type") err = sp.ctx.CreateAPI( diff --git a/hack/docs/internal/cronjob-tutorial/generate_cronjob.go b/hack/docs/internal/cronjob-tutorial/generate_cronjob.go index 70f10e7e324..e983e2e5d31 100644 --- a/hack/docs/internal/cronjob-tutorial/generate_cronjob.go +++ b/hack/docs/internal/cronjob-tutorial/generate_cronjob.go @@ -56,7 +56,7 @@ func newSampleContext(binaryPath string, samplePath string, env ...string) utils // Prepare the Context for the sample project func (sp *Sample) Prepare() { - log.Infof("destroying directory for sample project") + log.Infof("destroying directory for cronjob sample project") sp.ctx.Destroy() log.Infof("refreshing tools and creating directory...") @@ -66,7 +66,7 @@ func (sp *Sample) Prepare() { } func (sp *Sample) GenerateSampleProject() { - log.Infof("Initializing the project") + log.Infof("Initializing the cronjob project") err := sp.ctx.Init( "--plugins", "go/v4", @@ -75,7 +75,7 @@ func (sp *Sample) GenerateSampleProject() { "--license", "apache2", "--owner", "The Kubernetes authors", ) - CheckError("Initializing the project", err) + CheckError("Initializing the cronjob project", err) log.Infof("Adding a new config type") err = sp.ctx.CreateAPI( @@ -466,13 +466,13 @@ func updateSuiteTest(sp *Sample) { filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), `limitations under the License. */`, SuiteTestIntro) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go to add license intro", err) err = pluginutil.InsertCode( filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), `import (`, ` "context"`) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go to add context", err) err = pluginutil.InsertCode( filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), @@ -481,7 +481,7 @@ func updateSuiteTest(sp *Sample) { `, ` ctrl "sigs.k8s.io/controller-runtime" `) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go to add ctrl import", err) err = pluginutil.ReplaceInFile( filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), @@ -490,14 +490,14 @@ var cfg *rest.Config var k8sClient client.Client var testEnv *envtest.Environment `, SuiteTestEnv) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go to add more variables", err) err = pluginutil.InsertCode( filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), ` logf.SetLogger(zap.New(zap.WriteTo(GinkgoWriter), zap.UseDevMode(true))) `, SuiteTestReadCRD) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go to add text about CRD", err) err = pluginutil.InsertCode( filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), @@ -507,7 +507,7 @@ var testEnv *envtest.Environment /* Then, we start the envtest cluster. */`) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go to add text to show where envtest cluster start", err) err = pluginutil.ReplaceInFile( filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), @@ -517,7 +517,7 @@ var testEnv *envtest.Environment //+kubebuilder:scaffold:scheme `, SuiteTestAddSchema) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go to add schema", err) err = pluginutil.InsertCode( filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), @@ -526,7 +526,7 @@ var testEnv *envtest.Environment Expect(err).NotTo(HaveOccurred()) Expect(k8sClient).NotTo(BeNil()) `, SuiteTestDescription) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go for test description", err) err = pluginutil.ReplaceInFile( filepath.Join(sp.ctx.Dir, "internal/controller/suite_test.go"), @@ -537,7 +537,7 @@ var _ = AfterSuite(func() { Expect(err).NotTo(HaveOccurred()) }) `, SuiteTestCleanup) - CheckError("fixing suite_test.go", err) + CheckError("updating suite_test.go to cleanup tests", err) } func updateKustomization(sp *Sample) { From c9f35442d3790f58354807dd688829215b9f46ad Mon Sep 17 00:00:00 2001 From: Camila Macedo Date: Mon, 14 Aug 2023 15:19:47 +0100 Subject: [PATCH 08/11] :bug: fix doc preview --- docs/book/book.toml | 8 +++++++- docs/book/install-and-build.sh | 12 ++++++++---- netlify.toml | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/book/book.toml b/docs/book/book.toml index c6244a05df3..557e903a20c 100644 --- a/docs/book/book.toml +++ b/docs/book/book.toml @@ -5,7 +5,6 @@ src = "src" title = "The Kubebuilder Book" [output.html] -google-analytics = "UA-119864590-1" curly-quotes = true additional-css = ["theme/css/markers.css", "theme/css/custom.css", "theme/css/version-dropdown.css"] git-repository-url = "https://github.com/kubernetes-sigs/kubebuilder" @@ -16,3 +15,10 @@ command = "./litgo.sh" [preprocessor.markerdocs] command = "./markerdocs.sh" + +[context.environment] + environment = { GO_VERSION = "1.20" } + +[context.deploy-preview.environment] + environment = { GO_VERSION = "1.20" } + diff --git a/docs/book/install-and-build.sh b/docs/book/install-and-build.sh index 1d6fc263592..81c72a7bdd8 100755 --- a/docs/book/install-and-build.sh +++ b/docs/book/install-and-build.sh @@ -23,7 +23,10 @@ THIS_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) cd "$THIS_DIR" -[[ -n "$(command -v gimme)" ]] && eval "$(gimme stable)" +if [[ -n "$(command -v gimme)" ]]; then + GO_VERSION=${GO_VERSION:-stable} # Use the provided GO_VERSION or default to 'stable' + eval "$(gimme $GO_VERSION)" +fi echo go version GOBIN=$THIS_DIR/functions go install ./... @@ -60,14 +63,15 @@ esac # grab mdbook # we hardcode linux/amd64 since rust uses a different naming scheme and it's a pain to tran -echo "downloading mdBook-v0.4.21-${arch}-${target}.${ext}" +echo "downloading mdBook-v0.4.34-${arch}-${target}.${ext}" set -x -curl -sL -o /tmp/mdbook.${ext} https://github.com/rust-lang-nursery/mdBook/releases/download/v0.4.2/mdBook-v0.4.2-${arch}-${target}.${ext} +curl -sL -o /tmp/mdbook.${ext} https://github.com/rust-lang/mdBook/releases/download/v0.4.34/mdBook-v0.4.34-${arch}-${target}.${ext} ${cmd} /tmp/mdbook.${ext} chmod +x /tmp/mdbook echo "grabbing the latest released controller-gen" -go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.0 +go version +go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.1 # make sure we add the go bin directory to our path gobin=$(go env GOBIN) diff --git a/netlify.toml b/netlify.toml index 388292ee449..d3dd304a5a0 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,6 @@ [build] base = "docs/book" - command = "./install-and-build.sh" + command = "GO_VERSION=1.20 ./install-and-build.sh" publish = "docs/book/book" functions = "docs/book/functions" From 68abac1dfb5550f7159dec4ce600cd9b6db925bb Mon Sep 17 00:00:00 2001 From: "Tony (TianYi)" Date: Tue, 15 Aug 2023 09:20:36 -0400 Subject: [PATCH 09/11] =?UTF-8?q?=F0=9F=90=9B:=20sync=20kb=20binary=20from?= =?UTF-8?q?=20source=20code=20for=20docs=20(#3520)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: sync kb binary from source code for docs --- Makefile | 2 +- hack/docs/check.sh | 7 ++----- hack/docs/generate.sh | 23 +++++++++++++++++++++++ hack/docs/generate_samples.go | 8 +++++--- 4 files changed, 31 insertions(+), 9 deletions(-) create mode 100755 hack/docs/generate.sh diff --git a/Makefile b/Makefile index 3e49bccab68..701c0cf1892 100644 --- a/Makefile +++ b/Makefile @@ -73,7 +73,7 @@ generate-testdata: ## Update/generate the testdata in $GOPATH/src/sigs.k8s.io/ku .PHONY: generate-docs generate-docs: ## Update/generate the docs in $GOPATH/src/sigs.k8s.io/kubebuilder - go run hack/docs/generate_samples.go + ./hack/docs/generate.sh .PHONY: check-docs check-docs: ## Run the script to ensure that the docs are updated diff --git a/hack/docs/check.sh b/hack/docs/check.sh index 85843ce52c3..b41e41bfc67 100755 --- a/hack/docs/check.sh +++ b/hack/docs/check.sh @@ -14,10 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -source "$(dirname "$0")/../../test/common.sh" - -build_kb - check_directory="$(dirname "$0")/../../docs/book/src/" # Check docs directory first. If there are any uncommitted change, fail the test. @@ -27,7 +23,8 @@ if [[ $(git status ${check_directory} --porcelain) ]]; then exit 1 fi -make generate-docs + +$(dirname "$0")/generate.sh # Check if there are any changes to files under testdata directory. if [[ $(git status ${check_directory} --porcelain) ]]; then diff --git a/hack/docs/generate.sh b/hack/docs/generate.sh new file mode 100755 index 00000000000..ac486ab5aa7 --- /dev/null +++ b/hack/docs/generate.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Copyright 2023 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# 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. + +source "$(dirname "$0")/../../test/common.sh" + +build_kb + +docs_gen_directory="$(dirname "$0")/../../hack/docs/generate_samples.go" +go run ${docs_gen_directory} + diff --git a/hack/docs/generate_samples.go b/hack/docs/generate_samples.go index f2a6171003f..facecea0e68 100644 --- a/hack/docs/generate_samples.go +++ b/hack/docs/generate_samples.go @@ -21,9 +21,11 @@ import ( componentconfig "sigs.k8s.io/kubebuilder/v3/hack/docs/internal/component-config-tutorial" cronjob "sigs.k8s.io/kubebuilder/v3/hack/docs/internal/cronjob-tutorial" - "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util" ) +// Make sure executing `build_kb` to generate kb executable from the source code +const KubebuilderBinName = "/tmp/kubebuilder/bin/kubebuilder" + func main() { fmt.Println("Generating documents...") @@ -36,7 +38,7 @@ func main() { } func UpdateComponentConfigTutorial() { - binaryPath := util.KubebuilderBinName + binaryPath := KubebuilderBinName samplePath := "docs/book/src/component-config-tutorial/testdata/project/" sp := componentconfig.NewSample(binaryPath, samplePath) @@ -51,7 +53,7 @@ func UpdateComponentConfigTutorial() { } func UpdateCronjobTutorial() { - binaryPath := util.KubebuilderBinName + binaryPath := KubebuilderBinName samplePath := "docs/book/src/cronjob-tutorial/testdata/project/" sp := cronjob.NewSample(binaryPath, samplePath) From 1d9d4777089cd8981fff0523b0ccb07026d2f925 Mon Sep 17 00:00:00 2001 From: Claudio Busse Date: Thu, 17 Aug 2023 16:44:49 +0200 Subject: [PATCH 10/11] :book: fix escaped html in markdown code segments --- docs/book/utils/markerdocs/html.go | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/book/utils/markerdocs/html.go b/docs/book/utils/markerdocs/html.go index 42f1a47e1a5..471d8a83b4f 100644 --- a/docs/book/utils/markerdocs/html.go +++ b/docs/book/utils/markerdocs/html.go @@ -39,10 +39,29 @@ type toHTML interface { // Text is a chunk of text in an HTML doc. type Text string -// WriteHTML writes the string as HTML to the given Writer +// WriteHTML writes the string as HTML to the given Writer while accounting for mdBook's handling +// of backticks. Given mdBook's behavior of treating backticked content as raw text, this function +// ensures proper rendering by preventing unnecessary HTML escaping within code snippets. Chunks +// outside of backticks are HTML-escaped for security, while chunks inside backticks remain as raw +// text, preserving mdBook's intended rendering of code content. func (t Text) WriteHTML(w io.Writer) error { - _, err := io.WriteString(w, html.EscapeString(string(t))) - return err + textChunks := strings.Split(string(t), "`") + + for i, chunk := range textChunks { + if i%2 == 0 { // Outside backticks, escape and write HTML + _, err := io.WriteString(w, html.EscapeString(chunk)) + if err != nil { + return err + } + } else { // Inside backticks, write raw HTML + _, err := io.WriteString(w, "`"+chunk+"`") + if err != nil { + return err + } + } + } + + return nil } // Tag is some tag with contents and attributes in an HTML doc. From cbc7872c1ae82b321b4b02c7d53eb3a6c1463dda Mon Sep 17 00:00:00 2001 From: Claudio Busse Date: Thu, 17 Aug 2023 21:25:54 +0200 Subject: [PATCH 11/11] :bug: fix typos in scaffolded makefiles --- Makefile | 2 +- .../testdata/project/Makefile | 16 ++++++++-------- .../cronjob-tutorial/testdata/project/Makefile | 16 ++++++++-------- .../testdata/project/Makefile | 16 ++++++++-------- .../testdata/sampleexternalplugin/v1/Makefile | 2 +- .../v2/scaffolds/internal/templates/makefile.go | 2 +- .../v3/scaffolds/internal/templates/makefile.go | 16 ++++++++-------- .../v4/scaffolds/internal/templates/makefile.go | 16 ++++++++-------- testdata/project-v2/Makefile | 2 +- testdata/project-v3/Makefile | 16 ++++++++-------- testdata/project-v4-declarative-v1/Makefile | 16 ++++++++-------- testdata/project-v4-multigroup/Makefile | 16 ++++++++-------- testdata/project-v4-with-deploy-image/Makefile | 16 ++++++++-------- testdata/project-v4-with-grafana/Makefile | 16 ++++++++-------- testdata/project-v4/Makefile | 16 ++++++++-------- 15 files changed, 92 insertions(+), 92 deletions(-) diff --git a/Makefile b/Makefile index 701c0cf1892..a2e19562d58 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ endif # 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 commands is responsible for reading 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. diff --git a/docs/book/src/component-config-tutorial/testdata/project/Makefile b/docs/book/src/component-config-tutorial/testdata/project/Makefile index 60603908794..ca35b69cc0d 100644 --- a/docs/book/src/component-config-tutorial/testdata/project/Makefile +++ b/docs/book/src/component-config-tutorial/testdata/project/Makefile @@ -29,7 +29,7 @@ all: build # 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 commands is responsible for reading 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. @@ -74,8 +74,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -85,12 +85,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. $(CONTAINER_TOOL) push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/docs/book/src/cronjob-tutorial/testdata/project/Makefile b/docs/book/src/cronjob-tutorial/testdata/project/Makefile index 60603908794..ca35b69cc0d 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/Makefile +++ b/docs/book/src/cronjob-tutorial/testdata/project/Makefile @@ -29,7 +29,7 @@ all: build # 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 commands is responsible for reading 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. @@ -74,8 +74,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -85,12 +85,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. $(CONTAINER_TOOL) push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/docs/book/src/multiversion-tutorial/testdata/project/Makefile b/docs/book/src/multiversion-tutorial/testdata/project/Makefile index 7ff4e8f8ae5..062d6b44a64 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/Makefile +++ b/docs/book/src/multiversion-tutorial/testdata/project/Makefile @@ -23,7 +23,7 @@ all: build # 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 commands is responsible for reading 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. @@ -72,8 +72,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -83,12 +83,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. docker push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/Makefile b/docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/Makefile index f2da5e292db..e1ea7394d55 100644 --- a/docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/Makefile +++ b/docs/book/src/simple-external-plugin-tutorial/testdata/sampleexternalplugin/v1/Makefile @@ -20,7 +20,7 @@ all: build # 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 commands is responsible for reading 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. diff --git a/pkg/plugins/golang/v2/scaffolds/internal/templates/makefile.go b/pkg/plugins/golang/v2/scaffolds/internal/templates/makefile.go index 5aedcb17f0e..94ecf72fad2 100644 --- a/pkg/plugins/golang/v2/scaffolds/internal/templates/makefile.go +++ b/pkg/plugins/golang/v2/scaffolds/internal/templates/makefile.go @@ -74,7 +74,7 @@ all: build # 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 commands is responsible for reading 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. diff --git a/pkg/plugins/golang/v3/scaffolds/internal/templates/makefile.go b/pkg/plugins/golang/v3/scaffolds/internal/templates/makefile.go index 2249c3350fb..6b5d7dfc477 100644 --- a/pkg/plugins/golang/v3/scaffolds/internal/templates/makefile.go +++ b/pkg/plugins/golang/v3/scaffolds/internal/templates/makefile.go @@ -83,7 +83,7 @@ all: build # 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 commands is responsible for reading 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. @@ -128,8 +128,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -139,12 +139,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. docker push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go b/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go index aad92fb4ddb..6e751ad0f51 100644 --- a/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go +++ b/pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go @@ -89,7 +89,7 @@ all: build # 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 commands is responsible for reading 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. @@ -138,8 +138,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -149,12 +149,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. $(CONTAINER_TOOL) push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/testdata/project-v2/Makefile b/testdata/project-v2/Makefile index 0fb3a7ac737..09b2518aa71 100644 --- a/testdata/project-v2/Makefile +++ b/testdata/project-v2/Makefile @@ -18,7 +18,7 @@ all: build # 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 commands is responsible for reading 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. diff --git a/testdata/project-v3/Makefile b/testdata/project-v3/Makefile index 73a01c158dd..d3476d64fd9 100644 --- a/testdata/project-v3/Makefile +++ b/testdata/project-v3/Makefile @@ -23,7 +23,7 @@ all: build # 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 commands is responsible for reading 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. @@ -68,8 +68,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -79,12 +79,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. docker push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/testdata/project-v4-declarative-v1/Makefile b/testdata/project-v4-declarative-v1/Makefile index 60603908794..ca35b69cc0d 100644 --- a/testdata/project-v4-declarative-v1/Makefile +++ b/testdata/project-v4-declarative-v1/Makefile @@ -29,7 +29,7 @@ all: build # 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 commands is responsible for reading 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. @@ -74,8 +74,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -85,12 +85,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. $(CONTAINER_TOOL) push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/testdata/project-v4-multigroup/Makefile b/testdata/project-v4-multigroup/Makefile index 60603908794..ca35b69cc0d 100644 --- a/testdata/project-v4-multigroup/Makefile +++ b/testdata/project-v4-multigroup/Makefile @@ -29,7 +29,7 @@ all: build # 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 commands is responsible for reading 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. @@ -74,8 +74,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -85,12 +85,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. $(CONTAINER_TOOL) push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/testdata/project-v4-with-deploy-image/Makefile b/testdata/project-v4-with-deploy-image/Makefile index 60603908794..ca35b69cc0d 100644 --- a/testdata/project-v4-with-deploy-image/Makefile +++ b/testdata/project-v4-with-deploy-image/Makefile @@ -29,7 +29,7 @@ all: build # 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 commands is responsible for reading 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. @@ -74,8 +74,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -85,12 +85,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. $(CONTAINER_TOOL) push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/testdata/project-v4-with-grafana/Makefile b/testdata/project-v4-with-grafana/Makefile index 60603908794..ca35b69cc0d 100644 --- a/testdata/project-v4-with-grafana/Makefile +++ b/testdata/project-v4-with-grafana/Makefile @@ -29,7 +29,7 @@ all: build # 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 commands is responsible for reading 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. @@ -74,8 +74,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -85,12 +85,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. $(CONTAINER_TOOL) push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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 diff --git a/testdata/project-v4/Makefile b/testdata/project-v4/Makefile index 60603908794..ca35b69cc0d 100644 --- a/testdata/project-v4/Makefile +++ b/testdata/project-v4/Makefile @@ -29,7 +29,7 @@ all: build # 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 commands is responsible for reading 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. @@ -74,8 +74,8 @@ build: manifests generate fmt vet ## Build manager binary. run: manifests generate fmt vet ## Run a controller from your host. go run ./cmd/main.go -# If you wish built the manager image targeting other platforms you can use the --platform flag. -# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. +# 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. @@ -85,12 +85,12 @@ docker-build: test ## Build docker image with the manager. docker-push: ## Push docker image with the manager. $(CONTAINER_TOOL) push ${IMG} -# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# 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: -# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ -# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ -# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) -# To properly provided solutions that supports more than one platform you should use this option. +# - 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