Skip to content

:WIP sparkles: Add KAL and fix missing parts from tutorials #4888

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

Closed

Conversation

camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Jun 26, 2025

  • Add support for kube-api-linter to validate Kubernetes API definitions
    More info: https://github.com/kubernetes-sigs/kube-api-linter
  • Fix all tutorials (getting-started, cronjob, multiversion) to comply with lint rules
  • Update all plugins scaffolds to according to rules
  • Adjust GitHub Actions to build and run the new custom linter in CI

Experimental PR for: #4809

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 26, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 26, 2025
@camilamacedo86 camilamacedo86 force-pushed the custom-linter branch 2 times, most recently from bdee88d to b2c3dbb Compare June 26, 2025 17:28
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 26, 2025
@camilamacedo86 camilamacedo86 changed the title (experimental) - Add kube-api custom lint ✨ (go/v4,deploy-image/alpha-v1) feat: integrate kube-api-linter and fix scaffolds Jun 26, 2025
@camilamacedo86 camilamacedo86 changed the title ✨ (go/v4,deploy-image/alpha-v1) feat: integrate kube-api-linter and fix scaffolds :WIP sparkles: (go/v4,deploy-image/alpha-v1) feat: integrate kube-api-linter and fix scaffolds Jun 26, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 26, 2025
@camilamacedo86 camilamacedo86 force-pushed the custom-linter branch 5 times, most recently from 083eab9 to d1e8ffe Compare June 27, 2025 07:49
mkdir -p $(KUBE_API_LINTER_BUILD_DIR)
cd $(KUBE_API_LINTER_BUILD_DIR) && \
go mod init local-kube-api-linter && \
go get sigs.k8s.io/kube-api-linter@latest
Copy link
Member Author

@camilamacedo86 camilamacedo86 Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@everettraven @JoelSpeed
Do you see a better way to install with Golang CI 2x?

Would it be possible to do a release of the linter like any initial version, such as v0.1.0, and provide its binary so that we can download it here instead to simplify the install?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're currently trying to build this as a plugin, which means you also need to build the golangci-lint binary within the same Go module so that they share dependencies.

I would recommend using the module version of KAL where you compile a complete custom version of golangci-lint with KAL installed. In the future I hope to have a complete CLI released that is a custom version of golangci-lint, I'll see if I can do something about that next week as that might make this easier

@camilamacedo86 camilamacedo86 force-pushed the custom-linter branch 3 times, most recently from a8c6c0d to 3400dd5 Compare June 27, 2025 09:47
mkdir -p $(KUBE_API_LINTER_BUILD_DIR)
cd $(KUBE_API_LINTER_BUILD_DIR) && \
go mod init local-kube-api-linter && \
go get sigs.k8s.io/kube-api-linter@latest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're currently trying to build this as a plugin, which means you also need to build the golangci-lint binary within the same Go module so that they share dependencies.

I would recommend using the module version of KAL where you compile a complete custom version of golangci-lint with KAL installed. In the future I hope to have a complete CLI released that is a custom version of golangci-lint, I'll see if I can do something about that next week as that might make this easier

// Valid values are:
// - "Allow" (default): allows CronJobs to run concurrently;
// - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet;
// - "Replace": cancels currently running job and replaces it with a new one
// +optional
ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"`
// +kubebuilder:default:=Allow
ConcurrencyPolicy *ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty string is a valid value here? If it's not a valid choice, then this field doesn't need to be a pointer, that could be a bug in KAL

Copy link
Member Author

@camilamacedo86 camilamacedo86 Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think that should be a valid value. So, I will try to track this one.
Thank you

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the enum and it's not in the list of valid values, so I'm surprised this would be a pointer

Comment on lines +233 to +243
@echo "Setting up local module for kube-api-linter plugin..."
mkdir -p $(KUBE_API_LINTER_BUILD_DIR)
cd $(KUBE_API_LINTER_BUILD_DIR) && \
go mod init local-kube-api-linter && \
go get sigs.k8s.io/kube-api-linter@latest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this achieve? Why was it needed?

Copy link
Member Author

@camilamacedo86 camilamacedo86 Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to allow us to build the linter locally.
I created the module inside the hack dir to not add any dep to the project itself.
But if we have a release, an easier way by like downloading it then we can remove it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach taken for K/K and other repos has generally to have a separate go.mod for tools (new Go tools directives), and then this doesn't add deps to the main go.mod, but does allow all of the tools to built using the same environment.

I need it to have the linter and be able to build it locally in the hack dir, and without adding any dependencies to the project itself.

But you're building it with the first command, so I'm not sure why there's then a second get of the linter after you've already built the plugin?

Could we start to do releases? Would it be possible to provide it so that it can be downloaded instead of building it?

This is on the todo, but has been lower priority, as so far everyone who has used it has largely been ok with the plugin or module way of building things

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 30, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 1, 2025
@camilamacedo86 camilamacedo86 force-pushed the custom-linter branch 5 times, most recently from baebf42 to 0e008e2 Compare July 6, 2025 10:28
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 7, 2025
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 9, 2025
@camilamacedo86 camilamacedo86 force-pushed the custom-linter branch 3 times, most recently from 5bd34fc to 416eafe Compare July 9, 2025 19:56
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 9, 2025
@camilamacedo86 camilamacedo86 force-pushed the custom-linter branch 3 times, most recently from faa4c72 to 602961f Compare July 20, 2025 03:29
@camilamacedo86 camilamacedo86 changed the title :WIP sparkles: (go/v4,deploy-image/alpha-v1) feat: integrate kube-api-linter and fix scaffolds :WIP sparkles: Add KAL and fix missing parts from tutorials Jul 20, 2025
@camilamacedo86 camilamacedo86 force-pushed the custom-linter branch 3 times, most recently from f4cfc8e to ba1a810 Compare July 20, 2025 18:27
@k8s-ci-robot
Copy link
Contributor

@camilamacedo86: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubebuilder-e2e-k8s-1-31-4 7b93ca6 link true /test pull-kubebuilder-e2e-k8s-1-31-4
pull-kubebuilder-e2e-k8s-1-32-0 7b93ca6 link true /test pull-kubebuilder-e2e-k8s-1-32-0

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@camilamacedo86
Copy link
Member Author

I broke the install.
I am closing this one
We already used to discuss and we opened other PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants