Comments (8)
Thank you a lot for raising it.
You are using the Makefile of go/v3. The layout go/v3 has been deprecated for a long time and will no longer be available in the next N+2 release
See;
Therefore, could you please check the Makefile: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/Makefile
And let us know if you would like to propose changes.
Also, assuming yes, can you let us know your motivation? What problems do you have now that would be sorted out with the changes proposed?
from kubebuilder.
Yes, I indirectly use Makefile of go/v3, because I use the one created by Operator SDK. Should I ask there when they will start to use go/v4? (I think there is already an alpha version)
Will take a look into Makefile of go/v4 and get back to you, thanks!
from kubebuilder.
They are using go/v4: https://github.com/operator-framework/operator-sdk/tree/master/testdata/go/v4
And kubebuilder 3.12: https://github.com/operator-framework/operator-sdk/blob/master/go.mod#L46
And their default plugin is go/v4 either: https://github.com/kubernetes-sigs/kubebuilder/blob/master/cmd/main.go#L91
When you created the project, the go.v4 with Operator-SDK, go/v4 maybe was not the default plugin yet.
Please check the Makefile of go/v4 and let us know if you have any suggestions and why.
from kubebuilder.
You were right, I can use go/v4
with Operator SDK. Example command
operator-sdk \
--plugins go.kubebuilder.io/v4-alpha \
--project-version 3 \
init --project-name=<name> \
--repo=<repo> \
--domain=<domain>
About changes I would suggest
- add a CI command. The idea would be a similar to
test
command. The motivation is if we use it in a CI environment, it can give us false positives (example, I new contributor to a project proposed some changes, but did not runfmt
ormanifest
command, which the command does automatically). - add a version check to
golangci-lint
(maybe to all tools), like is done with kustomize. Also, removefmt
andvet
commands? I am not yet totally familiar withgolangci-lint
, but I believe it does the same withlint
andlint-fix
comamnds. As motivation, users can silent use wrong version of tools in local environment.
If the changes are accepeted, I would be glad to work on adding them 😄
from kubebuilder.
You are using an old release of Operator-SDK
If you use it from the source or the latest release: https://github.com/kubernetes-sigs/kubebuilder/blob/v3.13.0/cmd/main.go#L60-L63
You should get the go/v4 layout by just running operator-sdk init
Also, the name of the plugin is go/v4
go/v4-alpha was its name until it came to be stabilized.
from kubebuilder.
I think not. I am using 1.32.0 for my tests. Reference https://github.com/operator-framework/operator-sdk/releases
If I try to run like this
operator-sdk \
--plugins go/v4 \ # or go.kubebuilder.io/v4
--project-version 3 \
init --project-name=<> --repo=<> \
--domain=<>
I get this error
FATA[0000] no plugin could be resolved with key "go/v4" for project version "3"
And in the help command, I see this
Default plugin keys: "go.kubebuilder.io/v3"
Default project version: "3"
Maybe on master is already updated, but did not try with it.
But for suggestions on the Makefile, I used this as base https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/Makefile
from kubebuilder.
FATA[0000] no plugin could be resolved with key "go/v4" for project version "3"
Response: You should consider raising an issue against the Operator-SDK repository. The maintainers need to look into this issue. According to the Kubebuilder code (source code reference), the default plugin is go/v4
. Thus, running either operator-sdk init
or operator-sdk init --plugins=go/v4
should yield the same result.
But for suggestions on the Makefile, I used this as base https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/Makefile
Regarding your request:
Improve help messages. Example: Run go vet against code for me that usually work with Python, this is not clear.
Kubebuilder doesn't support Python; it's tailored for Go. The go vet
command is a Go-specific tool. If there's confusion about this, could you specify how the documentation or help messages could be improved for better clarity?
test command seems to do too many things
The test
target in the Makefile is designed to run a series of commands including manifest generation, formatting, and vetting before executing the tests. Here's the snippet:
.PHONY: test
test: manifests generate fmt vet envtest ## Run tests.
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e) -coverprofile cover.out
Suggestion of a new command
A ci command would be awesome! Something that checks if Go code is formatted, if files are up to date (were generated), etc. Example of auxiliary command idea for this task
It could be misleading as it might imply end-to-end testing rather than format checks. However, the existing fmt and vet targets cover your requirements:
.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...
.PHONY: vet
vet: ## Run go vet against code.
go vet ./...
These commands are already part of the make test target, aligning with what you're looking for (a target to do all those tests, ensure that the files are generated, it only is not called ci because of the reason described above). Additionally, the lint target utilizes golangci-lint, a popular linter in Go projects:
.PHONY: lint
lint: golangci-lint ## Run golangci-lint linter & yamllint
$(GOLANGCI_LINT) run
It appears we already have the functionality you're requesting. The confusion might stem from unfamiliarity with the Go language, which is the primary language supported by Kubebuilder.
I believe we can consider this issue resolved. However, if you have further suggestions or specific change requests, please feel free to raise an issue with detailed explanations.
I hope that you do not mind but I am closing this one.
from kubebuilder.
I will try to open a PR with my suggestions when I have time
from kubebuilder.
Related Issues (20)
- Custom webhook naming (for mutate or validator) HOT 10
- Failed to initialize project: unable to run post-scaffold HOT 4
- [Assessment and POC] - Integrate Server-Side-Apply Support in Kubebuilder via Controller-Tools and Code-Generator Enhancements
- Add support for configuring `boilerplatePath` during API scaffolding on plugin `base.go.kubebuilder.io/v4` HOT 14
- Watching Externally Managed Resources: source.Kind is a function but it's used as a type in example in kubebuilder book HOT 2
- Unexpected CR conversion behavior
- Feature request: `+kubebuilder:validation:UniqueItems` for uniqueness of field among structs HOT 7
- Analysis and Compliance Strategy for New Cyber Resilience Act HOT 3
- Standardize installation of golang tools with better version support HOT 1
- Avoid usage of newly deprecated webhook.Validator and webhook.Defaulter interfaces HOT 16
- Getting started guide various small typos/fixes HOT 2
- Development: automate squash commits HOT 3
- versionPattern should be more flexible to allow internal versions HOT 3
- Support for IBM Z (s390x architecture) HOT 1
- `exampleFile.txt` get expanded for every unit-test HOT 1
- Ensure that the projects with webhooks can work well with the latest version of cert-manager
- webhook patches has not been generated properly for projects with multi-group layout
- duplicited CRD in dist/install.yaml HOT 14
- Incorrect case for function doc in "Implementing a ConJob" tutorial HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubebuilder.