Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci-kal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ linters:
- "conditions" # Ensure conditions have the correct json tags and markers.
- "conflictingmarkers"
- "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
#- "forbiddenmarkers" # Ensure that types and fields do not contain any markers that are forbidden.
Copy link
Member Author

Choose a reason for hiding this comment

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

I definitely want to surface the linter here to make folks aware that this exists

@JoelSpeed Do you have any suggestions about markers that we should forbid?

Copy link
Contributor

Choose a reason for hiding this comment

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

This new rule is actually a basis for other rules to be implemented, e.g. nonullable (Already done) which prevents folks from using +nullable is just a static config to this linter.

At the moment, I think this is really for folks who have custom or specific reasons to prevent the usage of a specific marker.

Scanning through the Kubebuilder markers, its possible as a project that we might decide we don't want anything that is +kubebuilder:validation:Schemaless or uses +kubebuilder:validation:UniqueItems (IIRC this doesn't actually work)

Copy link
Member Author

@sbueringer sbueringer Sep 2, 2025

Choose a reason for hiding this comment

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

We need Schemaless in a few cases, but I think we'll have discussions anyway if we want to add this to any new fields. I'll add a rule for UniqueItems.

EDIT: Or maybe I'll just leave it as is for now. I have no plans to start using UniqueItems but if I want to forbid it I would probably want to link to an issue that mentions that it doesn't work (but probably not worth the effort to look this up)

- "integers" # Ensure only int32 and int64 are used for integers.
- "jsontags" # Ensure every field has a json tag.
- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
- "nobools" # Bools do not evolve over time, should use enums instead.
- "nofloats" # Ensure floats are not used.
- "nomaps" # Ensure maps are not used.
- "nonullable" # Ensure that types and fields do not have the nullable marker.
- "notimestamp" # Prevents usage of 'Timestamp' fields
- "optionalfields" # Ensure that all fields marked as optional adhere to being pointers and
# having the `omitempty` value in their `json` tag where appropriate.
Expand Down
2 changes: 1 addition & 1 deletion hack/tools/.custom-gcl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name: golangci-lint-kube-api-linter
destination: ./bin
plugins:
- module: 'sigs.k8s.io/kube-api-linter'
version: v0.0.0-20250819121536-a575e84f4ce8
version: v0.0.0-20250902135116-ef33eac3b92b