Skip to content

Commit d4173bf

Browse files
authored
Merge pull request #3582 from sbueringer/pr-enable-kal-ci
✨ Enable KAL in CI
2 parents bcb05f2 + 7dff9e1 commit d4173bf

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

.github/workflows/pr-golangci-lint.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ jobs:
3232
with:
3333
version: v2.1.0
3434
working-directory: ${{matrix.working-directory}}
35+
- name: Lint API
36+
run: make lint-api

.golangci-kal.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@ linters:
1616
enable:
1717
- "commentstart" # Ensure comments start with the serialized version of the field name.
1818
- "conditions" # Ensure conditions have the correct json tags and markers.
19+
- "conflictingmarkers"
1920
- "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
2021
- "integers" # Ensure only int32 and int64 are used for integers.
2122
- "jsontags" # Ensure every field has a json tag.
2223
- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
2324
- "nobools" # Bools do not evolve over time, should use enums instead.
2425
- "nofloats" # Ensure floats are not used.
2526
- "nomaps" # Ensure maps are not used.
27+
- "notimestamp" # Prevents usage of 'Timestamp' fields
2628
- "optionalfields" # Ensure that all fields marked as optional adhere to being pointers and
2729
# having the `omitempty` value in their `json` tag where appropriate.
2830
- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
2931
- "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
3032
- "ssatags" # Ensure array fields have the appropriate listType markers
3133
- "statusoptional" # Ensure all first children within status should be optional.
3234
- "statussubresource" # All root objects that have a `status` field should have a status subresource.
33-
- "notimestamp" # Prevents usage of 'Timestamp' fields
3435
- "uniquemarkers" # Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
3536

3637
# Per discussion in July 2024, we are keeping phase fields for now.
@@ -42,6 +43,13 @@ linters:
4243
disable:
4344
- "*" # We will manually enable new linters after understanding the impact. Disable all by default.
4445
lintersConfig:
46+
conflictingmarkers:
47+
conflicts:
48+
- name: "default_vs_required"
49+
sets:
50+
- ["default", "kubebuilder:default"]
51+
- ["required", "kubebuilder:validation:Required", "k8s:required"]
52+
description: "A field with a default value cannot be required"
4553
conditions:
4654
isFirstField: Warn # Require conditions to be the first field in the status struct.
4755
usePatchStrategy: Forbid # Forbid patchStrategy markers on the Conditions field.
@@ -52,15 +60,6 @@ linters:
5260
policy: SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
5361
omitempty:
5462
policy: SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
55-
# jsontags:
56-
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
57-
# optionalorrequired:
58-
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
59-
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
60-
# requiredfields:
61-
# pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers.
62-
# ssatags:
63-
# listTypeSetUsage: Warn | Ignore # The policy for listType=set usage on object arrays. Defaults to `Warn`.
6463

6564
exclusions:
6665
generated: strict
@@ -71,7 +70,7 @@ linters:
7170
- ".*_test.go" # Exclude test files.
7271
rules:
7372
## KAL should only run on API folders.
74-
- path-except: "apis/vmware/v1beta1//*"
73+
- path-except: "api//*"
7574
linters:
7675
- kubeapilinter
7776

@@ -96,4 +95,3 @@ issues:
9695
max-same-issues: 0
9796
max-issues-per-linter: 0
9897
new-from-merge-base: main
99-
#new-from-rev: 2b8b70e3

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,11 @@ generate-test-infra-prowjobs: $(PROWJOB_GEN) ## Generates the prowjob configurat
470470
##@ lint and verify:
471471

472472
.PHONY: lint
473-
lint: $(GOLANGCI_LINT) ## Lint the codebase
473+
lint: $(GOLANGCI_LINT) $(GOLANGCI_LINT_KAL) ## Lint the codebase
474474
$(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS)
475475
cd $(TEST_DIR); $(GOLANGCI_LINT) run --path-prefix $(TEST_DIR) --config $(ROOT_DIR)/.golangci.yml -v $(GOLANGCI_LINT_EXTRA_ARGS)
476476
cd $(PACKAGING_DIR); $(GOLANGCI_LINT) run --path-prefix $(PACKAGING_DIR) --config $(ROOT_DIR)/.golangci.yml -v $(GOLANGCI_LINT_EXTRA_ARGS)
477+
$(GOLANGCI_LINT_KAL) run -v --config $(ROOT_DIR)/.golangci-kal.yml $(GOLANGCI_LINT_EXTRA_ARGS)
477478

478479
.PHONY: lint-fix
479480
lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter

hack/tools/.custom-gcl.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@ version: v2.1.0
22
name: golangci-lint-kube-api-linter
33
destination: ./bin
44
plugins:
5-
- module: 'sigs.k8s.io/kube-api-linter'
6-
path: ../../../kube-api-linter
7-
# using JoelSpeed/required-fields-v2 branch for now
5+
- module: 'sigs.k8s.io/kube-api-linter'
6+
version: v0.0.0-20250808120943-48643eb2563d

0 commit comments

Comments
 (0)