Giter Site home page Giter Site logo

Comments (8)

camilamacedo86 avatar camilamacedo86 commented on July 22, 2024

Hi @mateusoliveira43

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.

mateusoliveira43 avatar mateusoliveira43 commented on July 22, 2024

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.

camilamacedo86 avatar camilamacedo86 commented on July 22, 2024

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.

mateusoliveira43 avatar mateusoliveira43 commented on July 22, 2024

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 run fmt or manifest command, which the command does automatically).
  • add a version check to golangci-lint (maybe to all tools), like is done with kustomize. Also, remove fmt and vet commands? I am not yet totally familiar with golangci-lint, but I believe it does the same with lint and lint-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.

camilamacedo86 avatar camilamacedo86 commented on July 22, 2024

@mateusoliveira43

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.

mateusoliveira43 avatar mateusoliveira43 commented on July 22, 2024

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.

camilamacedo86 avatar camilamacedo86 commented on July 22, 2024

Hi @mateusoliveira43,

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.

mateusoliveira43 avatar mateusoliveira43 commented on July 22, 2024

I will try to open a PR with my suggestions when I have time

from kubebuilder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.