Skip to content

Commit 54d08f3

Browse files
committed
fixup! build: Integrate with vscode
1 parent 4eb4877 commit 54d08f3

File tree

18 files changed

+254
-249
lines changed

18 files changed

+254
-249
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ jobs:
211211
run: devbox run -- make pre-commit
212212
env:
213213
SKIP: no-commit-to-branch,golangci-lint,actionlint-system
214+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
214215

215216
lint-test-helm:
216217
runs-on: ubuntu-24.04

.golangci-kal.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.golangci.yml

Lines changed: 79 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ linters:
2323
- govet
2424
- importas
2525
- ineffassign
26+
- kubeapilinter
2627
- lll
2728
- misspell
2829
- nolintlint
@@ -74,8 +75,55 @@ linters:
7475
- github.com/onsi/gomega
7576
testifylint:
7677
enable-all: true
78+
custom:
79+
kubeapilinter:
80+
type: module
81+
description: KAL is the Kube-API-Linter and lints Kube like APIs based on API conventions and best practices.
82+
settings:
83+
linters:
84+
enable:
85+
# - "commentstart" # Ensure comments start with the serialized version of the field name.
86+
# - "conditions" # Ensure conditions have the correct json tags and markers.
87+
- "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
88+
- "integers" # Ensure only int32 and int64 are used for integers.
89+
- "jsontags" # Ensure every field has a json tag.
90+
- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
91+
- "nobools" # Bools do not evolve over time, should use enums instead.
92+
- "nofloats" # Ensure floats are not used.
93+
# - "nomaps" # Ensure maps are not used.
94+
# - "nophase" # Ensure phases are not used, as they are not extensible.
95+
- "optionalfields" # Ensure that all fields marked as optional adhere to being pointers and
96+
# having the `omitempty` value in their `json` tag where appropriate.
97+
- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
98+
- "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
99+
# - "ssatags" # Ensure array fields have the appropriate listType markers
100+
# - "statusoptional" # Ensure all first children within status should be optional.
101+
# - "statussubresource" # All root objects that have a `status` field should have a status subresource.
102+
- "uniquemarkers" # Ensure that types and fields do not contain more than a single definition of a marker that should only be present once.
103+
104+
# Linters below this line are disabled, pending conversation on how and when to enable them.
105+
disable:
106+
- "*" # We will manually enable new linters after understanding the impact. Disable all by default.
107+
lintersConfig:
108+
optionalfields:
109+
pointers:
110+
preference: WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
111+
jsontags:
112+
jsonTagRegex: "^[a-z][a-z0-9-]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
113+
optionalorrequired:
114+
preferredOptionalMarker: kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
115+
preferredRequiredMarker: kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
77116
exclusions:
78-
generated: lax
117+
generated: strict
118+
paths:
119+
# Ignore generated files.
120+
- zz_generated.*\.go$
121+
# Ignore external API packages.
122+
- external/
123+
# Ignore test files.
124+
- '.+_test\.go$'
125+
# Ignore aggregate types.
126+
- 'aggregate_types\.go$'
79127
presets:
80128
- comments
81129
- common-false-positives
@@ -103,11 +151,36 @@ linters:
103151
- gocritic
104152
path: internal/test/envtest
105153
text: 'hugeParam: input is heavy'
106-
paths:
107-
- external
108-
- third_party$
109-
- builtin$
110-
- examples$
154+
155+
# START kube-api-linter rules
156+
- path: ".*"
157+
text: "optionalorrequired: embedded field must be marked as kubebuilder:validation:Optional or kubebuilder:validation:Required"
158+
linters:
159+
- kubeapilinter
160+
161+
# kube-api-linter does not handle formats correctly yet.
162+
- path: '/addon_types\.go$'
163+
text: "maxlength: field (Start|End) must have a maximum length, add kubebuilder:validation:MaxLength marker"
164+
linters:
165+
- kubeapilinter
166+
- path: '/common_types\.go$'
167+
text: "maxlength: field Address must have a maximum length, add kubebuilder:validation:MaxLength marker"
168+
linters:
169+
- kubeapilinter
170+
171+
# kube-api-linter does not handle patterns correctly yet.
172+
- path: '/aws_(clusterconfig|node)_types\.go$'
173+
text: "maxlength: field (ID|IAMInstanceProfile|InstanceType|Org) must have a maximum length, add kubebuilder:validation:MaxLength marker"
174+
linters:
175+
- kubeapilinter
176+
- path: '/(nutanix_)?(clusterconfig)_types\.go$'
177+
text: "maxlength: field (URL|Tag) must have a maximum length, add kubebuilder:validation:MaxLength marker"
178+
linters:
179+
- kubeapilinter
180+
- path-except: "^/api/"
181+
linters:
182+
- kubeapilinter
183+
# END kube-api-linter rules
111184
formatters:
112185
enable:
113186
- gci

.pre-commit-config.yaml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ repos:
1515
language: system
1616
files: "(.*\\.go|go.mod|go.sum|go.mk)$"
1717
pass_filenames: false
18+
- id: check-coredns-versions
19+
name: check-coredns-versions
20+
entry: make coredns.sync
21+
language: system
22+
files: "^api/versions/coredns.go$"
1823
- id: golangci-lint
1924
name: golangci-lint
2025
entry: make lint
2126
language: system
2227
files: "(.*\\.go|go.mod|go.sum|go.mk)$"
2328
pass_filenames: false
24-
- id: kube-api-linter
25-
name: kube-api-linter
26-
entry: make lint-kube-api
27-
language: system
28-
files: "((^api/(.*\\.go|go.mod|go.sum))|go.mk)$"
29-
pass_filenames: false
3029
- id: chart-docs
3130
name: chart-docs
3231
entry: make chart-docs
@@ -69,11 +68,6 @@ repos:
6968
language: system
7069
files: "^devbox.(yaml|lock)$"
7170
pass_filenames: false
72-
- id: check-coredns-versions
73-
name: check-coredns-versions
74-
entry: make coredns.sync
75-
language: system
76-
files: "^api/versions/coredns.go$"
7771
- repo: https://github.com/tekwizely/pre-commit-golang
7872
rev: v1.0.0-rc.1
7973
hooks:

api/v1alpha1/addon_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ type StorageClassConfig struct {
284284

285285
// If the storage class should allow volume expanding
286286
// +kubebuilder:validation:Optional
287-
AllowExpansion bool `json:"allowExpansion,omitempty"` //nolint:kubeapilinter,lll // Leave as bool for backward compatibility and this comment makes it a long line.
287+
AllowExpansion bool `json:"allowExpansion,omitempty"`
288288
}
289289

290290
type CSICredentials struct {

api/v1alpha1/nutanix_clusterconfig_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type NutanixPrismCentralEndpointSpec struct {
3535

3636
// use insecure connection to Prism Central endpoint
3737
// +kubebuilder:validation:Optional
38-
Insecure bool `json:"insecure,omitempty"` //nolint:kubeapilinter // Leave as bool for backward compatibility.
38+
Insecure bool `json:"insecure,omitempty"`
3939

4040
// A base64 PEM encoded x509 cert for the RootCA that was used to create
4141
// the certificate for a Prism Central that uses certificates that were issued by a non-publicly trusted RootCA.

api/versions/coredns.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/pkg/testutils/capitest/variables.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ func ValidateDiscoverVariables[V mutation.DiscoverVariables](
3434
handlerCreator func() V,
3535
variableTestDefs ...VariableTestDef,
3636
) {
37+
t.Helper()
38+
3739
ValidateDiscoverVariablesAs[V, any](
3840
t,
3941
variableName,

common/pkg/testutils/openapi/cel.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func validateCELRecursively(
7070
continue
7171
}
7272

73-
jsonName := jsonFieldName(fieldType)
73+
jsonName := jsonFieldName(&fieldType)
7474
if jsonName == "" {
7575
continue
7676
}
@@ -99,13 +99,13 @@ func reflectValueToInterface(v reflect.Value) interface{} {
9999
return v.Interface()
100100
}
101101

102-
func jsonFieldName(field reflect.StructField) string {
103-
tag := field.Tag.Get("json")
102+
func jsonFieldName(fld *reflect.StructField) string {
103+
tag := fld.Tag.Get("json")
104104
if tag == "-" {
105105
return ""
106106
}
107107
if tag == "" {
108-
return field.Name
108+
return fld.Name
109109
}
110110
return strings.Split(tag, ",")[0]
111111
}

devbox.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -854,50 +854,50 @@
854854
}
855855
},
856856
"golangci-lint@latest": {
857-
"last_modified": "2025-07-04T02:32:11Z",
858-
"resolved": "github:NixOS/nixpkgs/472908faa934435cf781ae8fac77291af3d137d3#golangci-lint",
857+
"last_modified": "2025-07-18T03:30:42Z",
858+
"resolved": "github:NixOS/nixpkgs/e821e03193486359aa942372be2d9c1f377b7a18#golangci-lint",
859859
"source": "devbox-search",
860-
"version": "2.2.1",
860+
"version": "2.2.2",
861861
"systems": {
862862
"aarch64-darwin": {
863863
"outputs": [
864864
{
865865
"name": "out",
866-
"path": "/nix/store/y34ymr5fc4nywh487v49djqzplqy8nih-golangci-lint-2.2.1",
866+
"path": "/nix/store/00sy2bp921ax5cxphxz0ifgax6i97mx7-golangci-lint-2.2.2",
867867
"default": true
868868
}
869869
],
870-
"store_path": "/nix/store/y34ymr5fc4nywh487v49djqzplqy8nih-golangci-lint-2.2.1"
870+
"store_path": "/nix/store/00sy2bp921ax5cxphxz0ifgax6i97mx7-golangci-lint-2.2.2"
871871
},
872872
"aarch64-linux": {
873873
"outputs": [
874874
{
875875
"name": "out",
876-
"path": "/nix/store/yvlh8x7mmlg7j8vqbzjslngipvkgfgdc-golangci-lint-2.2.1",
876+
"path": "/nix/store/gvay3vc5ll70dfryiy6qa16w3ybagiq7-golangci-lint-2.2.2",
877877
"default": true
878878
}
879879
],
880-
"store_path": "/nix/store/yvlh8x7mmlg7j8vqbzjslngipvkgfgdc-golangci-lint-2.2.1"
880+
"store_path": "/nix/store/gvay3vc5ll70dfryiy6qa16w3ybagiq7-golangci-lint-2.2.2"
881881
},
882882
"x86_64-darwin": {
883883
"outputs": [
884884
{
885885
"name": "out",
886-
"path": "/nix/store/zji7s77vyb0l2gpnz1nsa7al4w83rjw6-golangci-lint-2.2.1",
886+
"path": "/nix/store/9pxfg0y3hiaf08vnzk2fs4qh76r2kd22-golangci-lint-2.2.2",
887887
"default": true
888888
}
889889
],
890-
"store_path": "/nix/store/zji7s77vyb0l2gpnz1nsa7al4w83rjw6-golangci-lint-2.2.1"
890+
"store_path": "/nix/store/9pxfg0y3hiaf08vnzk2fs4qh76r2kd22-golangci-lint-2.2.2"
891891
},
892892
"x86_64-linux": {
893893
"outputs": [
894894
{
895895
"name": "out",
896-
"path": "/nix/store/p1144qggxazwz6791avlf6cqzyvkh8cv-golangci-lint-2.2.1",
896+
"path": "/nix/store/z0d7708yc7d0z6nj0mwalbi6hf79yj68-golangci-lint-2.2.2",
897897
"default": true
898898
}
899899
],
900-
"store_path": "/nix/store/p1144qggxazwz6791avlf6cqzyvkh8cv-golangci-lint-2.2.1"
900+
"store_path": "/nix/store/z0d7708yc7d0z6nj0mwalbi6hf79yj68-golangci-lint-2.2.2"
901901
}
902902
}
903903
},

0 commit comments

Comments
 (0)