Skip to content

docs: Fix installation instructions for golangci-lint v2 compatibility#175

Merged
JoelSpeed merged 2 commits intokubernetes-sigs:mainfrom
krishagarwal278:KAL-45
Nov 6, 2025
Merged

docs: Fix installation instructions for golangci-lint v2 compatibility#175
JoelSpeed merged 2 commits intokubernetes-sigs:mainfrom
krishagarwal278:KAL-45

Conversation

@krishagarwal278
Copy link
Contributor

@krishagarwal278 krishagarwal278 commented Oct 31, 2025

@JoelSpeed I've updated the README to fix the installation issues.

Main changes:

  • Module mode now uses v2.5.0 and includes the pseudo-version format you showed in the cluster-api example, plus instructions on how to generate it
  • Fixed the plugin build instructions to use the vendor directory like you suggested:
    go mod vendor
    go build -mod=vendor -buildmode=plugin -o bin/kube-api-linter.so ./vendor/sigs.k8s.io/kube-api-linter
  • Added version: "2" to all the .golangci.yml examples
  • Fixed up the Makefile and standalone build docs to be consistent with the actual directory structure

Fixes #145

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 31, 2025
@krishagarwal278
Copy link
Contributor Author

I've tested the standalone binary build with make build and it works fine. Let me know if anything needs adjusting!

.custom-gcl.yml Outdated
- module: 'sigs.k8s.io/kube-api-linter'
path: ./
- module: 'sigs.k8s.io/kube-api-linter'
version: 'v0.0.0-20251029172002-9992248f8813'
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably still want this to point to the local path, this isn't an example necessarily but a way to build what's in the repo locally

Makefile Outdated
.PHONY: build
build: ## Build the golangci-lint custom plugin binary.
go build -o ./bin ./cmd/golangci-lint-kube-api-linter
go build -o ./bin/golangci-lint-kube-api-linter ./cmd/golangci-lint-kube-api-linter
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually make a difference? On my machine the before and after appear to produce the same results

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the build works the same for me. Reverted 👍🏻

README.md Outdated

```shell
golangci-kube-api-linter run path/to/api/types --fix
./bin/golangci-lint-kube-api-linter run path/to/api/types --fix
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess generally we expect people to sort their own path, maybe we don't need to prefix the bin here?

README.md Outdated

[golangci-lint-plugin-docs]: https://golangci-lint.run/plugins/go-plugins/

**Important**: The plugin must be built from the vendor directory, not directly from the module path.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this true? Many projects don't use vendor, I expect they can still use the plugin no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right just tested that locally, making vendor optional 👍🏻

**Step 2**: Build the plugin from the vendor directory:

```shell
go build -buildmode=plugin -o bin/kube-api-linter.so sigs.k8s.io/kube-api-linter/pkg/plugin
Copy link
Contributor

Choose a reason for hiding this comment

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

Losing pkg/plugin here is not correct. The root module is for module mode, the plugin path is for the plugin mode, they are different codepaths to build

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 4, 2025
README.md Outdated
Comment on lines 48 to 52
To get the correct pseudo-version for the latest commit, run:

```bash
TZ=UTC git --no-pager show --quiet --abbrev=12 --date='format-local:%Y%m%d%H%M%S' --format="%cd-%h"
```
Copy link
Contributor

Choose a reason for hiding this comment

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

This is assuming they have a local version of kube-api-linter checked out right?

https://pkg.go.dev/sigs.k8s.io/kube-api-linter?tab=versions is probably a good source of truth for the latest version string

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that's right.
maybe suggesting to check the latest version as a better source of truth would be a better idea?

Suggested change
To get the correct pseudo-version for the latest commit, run:
```bash
TZ=UTC git --no-pager show --quiet --abbrev=12 --date='format-local:%Y%m%d%H%M%S' --format="%cd-%h"
```
To find the latest version listed, check [pkg.go.dev/sigs.k8s.io/kube-api-linter?tab=versions](https://pkg.go.dev/sigs.k8s.io/kube-api-linter?tab=versions)

README.md Outdated

```yaml
version: "2"

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason for this additional whitespace?

README.md Outdated

The output binary will be a combination of the initial `golangci-lint` binary and the Kube API linter plugin.
This means that you can use any of the standard `golangci-lint` configuration or flags to run the binary, but may also include the Kube API Linter rules.
The output binary `./bin/golangci-lint-kube-api-linter` will be a combination of the `golangci-lint` binary with the Kube API Linter included as a module.
Copy link
Contributor

Choose a reason for hiding this comment

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

will it always be ./bin/... as the pathing from golangci-lint custom?

README.md Outdated
go build -buildmode=plugin -o $(OUTPUT_DIR)/kube-api-linter.so sigs.k8s.io/kube-api-linter/pkg/plugin
```

Example - building into a `bin` directory:
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need an explicit example of building into a specific directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, a single example should suffice too 👍🏻

@krishagarwal278
Copy link
Contributor Author

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 5, 2025
Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

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

These changes look fine to me.

@JoelSpeed over to you for any additional comments.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 5, 2025
@JoelSpeed
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: everettraven, JoelSpeed, krishagarwal278

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 6, 2025
@JoelSpeed JoelSpeed merged commit eff876c into kubernetes-sigs:main Nov 6, 2025
4 checks passed
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Installation instructions do not work with golangci-lint v2

4 participants