-
Notifications
You must be signed in to change notification settings - Fork 1.6k
✨ (API, CLI, go/v4) Add cliVersion field to the PROJECT file configuration to store the CLI binary version used to scaffold projects. #4621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi @vitorfloriano. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terrific 🎉 . Thank you a lot for your contribution 🥇
dff6ef1
to
6ab4d37
Compare
6ab4d37
to
23c1e26
Compare
edb23a1
to
3aeef07
Compare
needs rebase, do a git pull from |
3aeef07
to
1319415
Compare
1319415
to
28ff872
Compare
28ff872
to
a28a293
Compare
a28a293
to
d1c79bb
Compare
Hi @vitorfloriano IMO it is very close to fly 🚀 |
This commit adds a new field to the PROJECT file: cliVersion. Additionally, it updates the documentation in the Project Configuration Reference to include the new cliVersion field. It also updates the PROJECT file scaffolded in the docs and in testdata.
d1c79bb
to
2fcc548
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ This change seems safe to approve.
The package sigs.k8s.io/kubebuilder/v4/pkg/config/v3 is used directly by consumers, but in practice they usually do not implement the Config interface themselves. Instead, they rely on the provided implementation, such as cfgv3.Cfg.
As a result, adding the GetCliVersion and SetCliVersion methods to the interface is not a breaking change for consumers who simply use the config objects. These consumers won't need to do anything differently.
However, if a project chooses to implement the Config interface themselves, they would now be required to implement the new methods. For example:
type MyCustomConfig struct {
// fields...
}
func (c *MyCustomConfig) GetCliVersion() string {
return "v4.6.0"
}
func (c *MyCustomConfig) SetCliVersion(version string) error {
// optionally store it somewhere
return nil
}
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, vitorfloriano The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Furtheremore, we also validate the change here: #4760 (comment) |
* chore: simplify test variable declarations for CLI tests Replaced redundant multi-line `var` blocks with single-line declarations in `version_test.go` and `completion_test.go`. This reduces visual noise and aligns with idiomatic Go style for concise test setup. * chore: improve readability of test case for alternative delimiters Reformatted the inline struct definition in `scaffold_test.go` to a multi-line layout. * chore: add gofumpt to golangci-lint configuration Enabled the `gofumpt` linter in `.golangci.yml` to enforce stricter formatting rules and ensure consistency with gofumpt standards across the codebase. * 📖 bump sigs.k8s.io/kubebuilder/v4 Bumps [sigs.k8s.io/kubebuilder/v4](https://github.com/kubernetes-sigs/kubebuilder) from 4.5.1 to 4.5.2. - [Release notes](https://github.com/kubernetes-sigs/kubebuilder/releases) - [Changelog](https://github.com/kubernetes-sigs/kubebuilder/blob/master/RELEASE.md) - [Commits](v4.5.1...v4.5.2) --- updated-dependencies: - dependency-name: sigs.k8s.io/kubebuilder/v4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * chore: unify import alias for network-policy Replaces import alias `network_policy` with `networkpolicy` to follow Go naming conventions. * chore: normalize error messages and wrap errors using %w - Use %w consistently in fmt.Errorf for proper error wrapping - Normalize error message casing for consistency - Adjust tests to reflect updated error strings * chore: normalize error messages and wrap errors using %w - Use %w consistently in fmt.Errorf for proper error wrapping * chore: normalize error messages and wrap errors using %w - Use %w consistently in fmt.Errorf for proper error wrapping * 🌱 (chore): wrap errors with `%w` and normalize formatting in `kustomize/v2` Replaced uses of `%v` with `%w` in `fmt.Errorf` to support proper error wrapping. Standardized formatting style, e.g. quoting strings with `%q` where appropriate. * 🌱 (chore): wrap file and I/O errors with `%w` in `pkg` - Replaced legacy `%v` error wrapping with `%w` in `fmt.Errorf(...)` calls - Applied `%q` for path-related variables to improve clarity - Affected areas include `helm/v1alpha`, `external/helpers`, and `model/resource` * 🌱 (chore): wrap conversion errors with `%w` in `crd_version_conversion.md` design doc - Updated `fmt.Errorf` to use `%w` for proper error wrapping in code snippets - Improves consistency and error traceability in example code * 🌱 (chore): wrap test command execution errors with `%w` in test utils - Use `%w` in `fmt.Errorf` for proper error wrapping - Quote string with `%q` for clarity - Applied consistently across all testdata and tutorial utility files * 🌱 (chore): remove unnecessary blank lines across plugin configuration and options - Removed stray empty lines in `grafana`, `golang`, and CLI plugin logic - Keeps code formatting consistent and clean * 🌱 (chore): wrap error with `%w` in `test_context.go` for improved diagnostics - Updated error formatting to use `%w` in `fmt.Errorf` for proper error chaining - Affects command execution error reporting in test context * Update getting-started.md Fix incorrect samples location * fix: avoid shadowing of 'config' and 'resource' in golang/v4 plugins Renamed variables and function parameters in pkg/plugins/golang/v4 to avoid shadowing imported packages: 'config' → 'cfg', and 'resource' → 'res'. This includes updates to the webhook, scaffolds (api, edit, init, webhook), and internal validation logic. These changes improve code readability and prevent potential issues when using package-level identifiers within the same scope. * 🌱 (chore): fix improper usage of `errors.As` in scaffold tests This fixes a misuse of `errors.As` where a non-pointer was passed as the second argument. Go requires the second argument to be a pointer to an interface or a type implementing the `error` interface. The test helper now correctly uses `&errType` to ensure proper error assertion and avoid false negatives or runtime issues. * util: clarify usage context of ReplaceRegexInFile Update the comment to note that the function is currently unused in the Kubebuilder codebase, but used by other projects and may be used internally in the future. * fix: avoid shadowing of 'config', 'store', and 'resource' in cli/alpha/generate Renamed variables and function parameters in pkg/cli/alpha/internal/generate.go to avoid shadowing imported packages: 'config' → 'cfg', 'store' → 's', 'resource' → 'res' and 'resource' → 'resourceData'. This improves code readability and prevents potential issues when calling package-level functions. * chore: enable shadow checks via import-shadowing linter Now that all variable shadowing issues have been resolved in previous commits, the `shadow` linter in govet is enabled and `import-shadowing` rule from revive is activated, to ensure consistent detection of future shadowing problems. * 🌱 (chore): enable `whitespace` linter in golangci-lint config Adds `whitespace` to the list of active linters in `.golangci.yml` to enforce consistent formatting and improve code cleanliness. * 🌱 (chore): enable `asciicheck` and `bidichk` for improved code safety and clarity - Added `asciicheck` to detect non-ASCII characters in identifiers and strings. Helps prevent hidden bugs and improves readability across systems. - Added `bidichk` to catch Unicode bidirectional control characters. Protects against visual code obfuscation and potential security vulnerabilities. These linters help enforce safer and more maintainable Go code, especially in kubebuilders collaborative environment with many contributors. * 🐛 enable `import-shadowing` linter in .golangci.yml files This PR adds the `import-shadowing` linter to all `.golangci.yml` configuration files across test projects and templates. The `import-shadowing` linter detects cases where a package import shadows an existing variable, which can lead to subtle bugs. * 🌱 (chore): isolate mutable test data in CLI spec to avoid Ginkgo pollution * 🌱 (chore): move mutable test declarations into BeforeEach to ensure clean test state * 🌱 (chore): move mutable test declarations into BeforeEach to ensure clean test state * 🌱 (chore): move mutable test declarations into BeforeEach to ensure clean test state * 🌱 (chore): move mutable test declarations into BeforeEach to ensure clean test state * 🌱 (chore): align stage test suite with Ginkgo conventions and cleanup * 🌱 (chore): isolate mutable resource test state with BeforeEach * 🌱 (chore): refactor shared setup logic in plugins into BeforeEach to isolate test state * 🌱 (chore): refactor shared setup logic in plugin into BeforeEach to isolate test state * fix: use limited scoped error in generated main.go * Updated migration pages and added index for better navigation removed prerequisite and verfication steps changed the header removed toc * Updated 404 page updated error page updated book.toml Delete docs/book/src/404.md * 🌱 fix (ci): fix lint issue: shadow: declaration of pluginCfg shadows declaration (#4725) fix (ci): fix lint issue: shadow: declaration of pluginCfg shadows declaration Fix plugin config test by resetting struct to avoid value reuse Avoids test contamination caused by shared PluginConfig variable by explicitly resetting it before decoding in each test case. Also resolves shadowing linter errors reported by golangci-lint. * 🌱 (chore): enable ginkgolinter forbid-focus-container 🌱 enable ginkgolinter forbid-focus-container This PR adds the following configuration to `.golangci.yml`: ```yaml linters-settings: ginkgolinter: forbid-focus-container: true ``` Enabling forbid-focus-container protects the code in the repository against accident commiting of debug code. A contributeor may use ginkgo's focus container (e.g. `FIt`, `FContext` etc. or by adding the `Focus` decorator), in order to locally debug a specific test. Merging a ginkgo's focus container will prevent running of all the other tests in CI. Signed-off-by: Nahshon Unna-Tsameret <[email protected]> * 🌱 (chore): enable ginkgolinter forbid-spec-pollution to enforce isolated test specs * fix: Use dynamic controller-runtime version in doc generator Replace hardcoded controller-runtime version in hack/docs/internal/cronjob-tutorial/generate_cronjob.go with a reference to the ControllerRuntimeVersion constant from the scaffolding package. This prevents the docs generation from breaking when the controller-runtime version is updated in the scaffolding logic, ensuring that `make generate-docs` remains stable across version bumps. Update hack/docs/internal/cronjob-tutorial/generate_cronjob.go Co-authored-by: Saan <[email protected]> Update hack/docs/internal/cronjob-tutorial/generate_cronjob.go Co-authored-by: Kersten Burkhardt <[email protected]> * 🌱 (chore): replace errors.As() with MatchError() in error assertions This update improves Gomega assertions by replacing `errors.As()` with `MatchError()` where the test intends to match specific error types rather than extract them. This change simplifies the assertions and improves readability, aligning with idiomatic Gomega style. * 📖 Fixed grammatical errors in designs doc (#4716) Fixed grammatical error in designs doc few more typos * 🌱 Add kubernetesVendorVersion for binary builds with LD_FLAGS This commit adds a kubernetesVendorVersion flag to Makefile. Rely on ldflags to set kubernetesVendorVersion, similarly to the other variables in cmd/version.go. Use a single variable to define K8S_VERSION for both ldflags and the goreleaser configuration. * update golang version to v1.2.4.0 Signed-off-by: dongjiang <[email protected]> fix golangci lint Signed-off-by: dongjiang <[email protected]> revent golangcl-lint Signed-off-by: dongjiang <[email protected]> add go install mode Signed-off-by: dongjiang <[email protected]> * 🌱 (chore): replace `%v` with `%w` in deploy-image v1alpha1 plugin errors - Ensured proper error wrapping using `fmt.Errorf(..., %w, ...)` throughout `scaffolds/api.go` - Used %q for filenames and paths for better formatting * 🌱 Fix golangci-lint wrong configurations (#4726) Fix golangci-lint configurations The current file is wrong with duplicated key: the `linters-settings.ginkgolinter` key, appears twice. This PR merges the duplicated keys into one. Signed-off-by: Nahshon Unna-Tsameret <[email protected]> * 🌱 (chore): replace empty slice literals with idiomatic var decls for []metav1.Condition, []templates.CustomMetricItem and []external.Flag * 🌱 (chore): improve error wrapping for generate command execution * 🌱 (chore): wrap errors using `%w` and improve formatting in golang plugin Replaced usage of `%v` with `%w` in `fmt.Errorf` calls to enable proper error chaining across: - `pkg/plugins/golang/repository.go` - `go_version.go` - `v4/scaffolds/api.go` Also improved formatting by quoting dynamic values with `%q` and removed redundant error wrapping logic. * 🌱 (chore): consistently wrap and enrich error messages across helm plugin * 🌱 (chore): improve error context and wrapping in utility and test helpers * 🌱 (chore): use `errors.As` and wrap exec errors in repository.go Refactored error handling in `repository.go`: - Replaced type assertion with `errors.As` for `*exec.ExitError` - Ensured command stderr is preserved in the wrapped `fmt.Errorf` output - Set up for better error introspection and debugging * 🌱 (chore): add detailed error wrapping across Golang plugin commands * 🌱 (chore): improve error context in common kustomize plugin scaffolds * 🌱 (chore): add error context to golang scaffolder execution steps * 🌱 (chore): improve error wrapping for external plugin discovery and config loading * 🌱 (chore): wrap config parsing and validation errors with contextual messages * 🌱 (chore): wrap plugin and util error returns for better context * 🌱 (chore): check and return error from os.WriteFile when writing litout.json * 🌱 (chore): use pointer receiver for Validate and rename shadowed var * 🌱 (chore): wrap deploy-image plugin errors with contextual messages * 🌱 (chore): remove unnecessary string() and []byte conversions * 🌱 (refactor): add contextual error wrapping for external plugin helpers * 🌱 (chore): wrap plugin and util error returns for better context * 🌱 (chore): handle flag parsing errors in sample external plugin This improves the robustness of the external plugin examples in the docs by adding proper error handling when parsing flags with `pflag`. If parsing fails, the plugin sets `pluginResponse.Error = true` and includes a clear error message in `ErrorMsgs`, preventing silent failures and making debugging easier for plugin authors following the tutorial. * 🌱 Bump github.com/onsi/gomega from 1.36.3 to 1.37.0 Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.36.3 to 1.37.0. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](onsi/gomega@v1.36.3...v1.37.0) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-version: 1.37.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * 🌱 (chore): clean up and unify error messages in golang/v4 plugin - Lowercased error messages for consistency - Removed redundant punctuation from error strings - Improved clarity of multi-line `fmt.Errorf` usage * 🌱 (chore): consistently wrap and enrich error messages across test utils It standardizes error handling and improves traceability. * Update versions_compatibility_supportability.md Fix link pointing to the wrong page * ✨ (API, CLI, go/v4) Add cliVersion field to the PROJECT file configuration to store the CLI binary version used to scaffold projects. (#4621) Add cliVersion field to PROJECT file This commit adds a new field to the PROJECT file: cliVersion. Additionally, it updates the documentation in the Project Configuration Reference to include the new cliVersion field. It also updates the PROJECT file scaffolded in the docs and in testdata. * 🌱 use `env:` to set variable. Otherwise quoting issues. If the title contains quotes, the currrent GitHub Action will fail to run. * 🌱 (chore): handle flag parsing errors in simple external plugin tutorial API scaffolder * refactor(e2e-setup): update Kind cluster naming for e2e tests change default Kind cluster names to be project-specific for e2e tests Previously, the default Kind cluster name was "kind", which could lead to conflicts when running multiple e2e tests concurrently across different projects. This change updates the Kind cluster name to be project-specific, reducing potential conflicts and improving the isolation of e2e test environments. * update golangci-lint v2 Signed-off-by: dongjiang <[email protected]> revert by codereview and make generate Signed-off-by: dongjiang <[email protected]> * 🌱 Bump github.com/onsi/ginkgo/v2 from 2.23.3 to 2.23.4 Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.23.3 to 2.23.4. - [Release notes](https://github.com/onsi/ginkgo/releases) - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md) - [Commits](onsi/ginkgo@v2.23.3...v2.23.4) --- updated-dependencies: - dependency-name: github.com/onsi/ginkgo/v2 dependency-version: 2.23.4 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * Upgrade controller-tools from v0.17.2 to v0.17.3 * 🌱 Bump golang.org/x/text from 0.23.0 to 0.24.0 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.23.0 to 0.24.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](golang/text@v0.23.0...v0.24.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-version: 0.24.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * 🌱 (chore): wrap and contextualize errors across Grafana plugin * fix staticcheck lint issues - ST1008 and ST1008 * 🌱 Bump golang.org/x/tools from 0.31.0 to 0.32.0 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.31.0 to 0.32.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](golang/tools@v0.31.0...v0.32.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-version: 0.32.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * fix(makefile): correct GNU sed detection method change sed detection from checking OS to checking for GNU version to ensure compatibility across different environments * (Follow up of : #4752 - Upgrade GolangCI) - fix: address staticcheck linter issues (ST1005, QF1008) in scaffolds and tutorials Co-Author: dongjiang <[email protected]> * fix bug Signed-off-by: dongjiang <[email protected]> update by codereview Signed-off-by: dongjiang <[email protected]> * 🌱 (chore): Enable wrapcheck linter (#4721) 🌱 (chore): enable wrapcheck via golangci-lint * Add control-plane labels to metrics service and ServiceMonitor templates * Removing goinstall mode * (testdata): Upgrade version used in the samples under testdata * 🐛 Remove redundant/noisy godebug default= lines from go.mod. (#4787) Remove redundant/noisy godebug default= lines from go.mod. * Removing calico - using default CNI from Kind * 🌱 Bump golang.org/x/text from 0.24.0 to 0.25.0 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.24.0 to 0.25.0. - [Release notes](https://github.com/golang/text/releases) - [Commits](golang/text@v0.24.0...v0.25.0) --- updated-dependencies: - dependency-name: golang.org/x/text dependency-version: 0.25.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * 🌱 Bump golang.org/x/tools from 0.32.0 to 0.33.0 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.32.0 to 0.33.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](golang/tools@v0.32.0...v0.33.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-version: 0.33.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * ✨ update golangci-lint to v2.1.0 and lint-action to v8 * bump controller-tools to v0.18.0 Signed-off-by: Adem Baccara <[email protected]> * append project name to conversion webhook service name * Fix: correct make command for updating RBAC to 'make manifests' * docs: fix heading formatting for 'ownerRef and cascading events' *⚠️ Upgrade controller-runtime (v0.20.4 to v0.21.0) and k8s version ( 1.32 => 1.33 ) (#4813) Upgrade controller-runtime (v0.20.4 to v0.21.0) and k8s version ( 1.32 => 1.33 ) * 🌱 Bump joelanford/go-apidiff from 0.8.2 to 0.8.3 Bumps [joelanford/go-apidiff](https://github.com/joelanford/go-apidiff) from 0.8.2 to 0.8.3. - [Release notes](https://github.com/joelanford/go-apidiff/releases) - [Commits](joelanford/go-apidiff@v0.8.2...v0.8.3) --- updated-dependencies: - dependency-name: joelanford/go-apidiff dependency-version: 0.8.3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * fix: revert registry added to docker images by mistake * (rbac) fix: improve role comment clarity by replacing {{ .ProjectName }} with rendered project name * 🐛 refactor: inline getKubebuilderVersion into cli.WithCliVersion setup (#4821) refactor: inline getKubebuilderVersion into cli.WithCliVersion setup --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Nahshon Unna-Tsameret <[email protected]> Signed-off-by: dongjiang <[email protected]> Signed-off-by: Adem Baccara <[email protected]> Co-authored-by: Kersten Burkhardt <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Kubernetes Prow Robot <[email protected]> Co-authored-by: fferrann <[email protected]> Co-authored-by: koba1t <[email protected]> Co-authored-by: Kuzuri247 <[email protected]> Co-authored-by: Nahshon Unna-Tsameret <[email protected]> Co-authored-by: Pranchal Shah <[email protected]> Co-authored-by: Kersten Burkhardt <[email protected]> Co-authored-by: RAHUL SINGH <[email protected]> Co-authored-by: vitorfloriano <[email protected]> Co-authored-by: dongjiang <[email protected]> Co-authored-by: Nahshon Unna Tsameret <[email protected]> Co-authored-by: Lucas Possani <[email protected]> Co-authored-by: Thomas Guettler <[email protected]> Co-authored-by: sarthaksarthak9 <[email protected]> Co-authored-by: Laurent Demailly <[email protected]> Co-authored-by: ira-pandey1 <[email protected]> Co-authored-by: Ansh Garhewal <[email protected]> Co-authored-by: Adem Baccara <[email protected]> Co-authored-by: Fabian Hirscher <[email protected]> Co-authored-by: Vaishnav88sk <[email protected]>
This PR adds a new field to the PROJECT file:
cliVersion.
Additionally, it updates the documentation in the Project Configuration Reference to include the new
cliVersion
field.It also updates the PROJECT file scaffolded in the docs and in testdata.
Closes: #4398
Test Steps:
~/kubebuilder$ goreleaser release --snapshot --skip=publish -f ./build/.goreleaser.yml
~/kubebuilder/dist/kubebuilder_linux_amd64_v1/kubebuilder init --domain example.com --repo github.com/test/example-operator