Skip to content

Commit b390ed4

Browse files
authored
Merge pull request #677 from shiftstack/orc-lint
Add ORC API linter to enforce ORC specific rules
2 parents 0ff2b62 + a766ecf commit b390ed4

31 files changed

Lines changed: 620 additions & 29 deletions

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ linters:
6262
- statusoptional
6363
- statussubresource
6464
- uniquemarkers
65+
- noopenstackidref
6566
lintersConfig:
6667
conditions:
6768
isFirstField: Warn

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ lint: golangci-kal ## Run golangci-kal linter
139139
$(GOLANGCI_KAL) run
140140

141141
.PHONY: lint-fix
142-
lint-fix: golangci-kal ## Run golangci-lint linter and perform fixes
142+
lint-fix: golangci-kal ## Run golangci-kal linter and perform fixes
143143
$(GOLANGCI_KAL) run --fix
144144

145145
##@ Build
@@ -315,7 +315,6 @@ KUSTOMIZE_VERSION ?= v5.6.0
315315
CONTROLLER_TOOLS_VERSION ?= v0.17.1
316316
ENVTEST_VERSION ?= release-0.22
317317
GOLANGCI_LINT_VERSION ?= v2.7.2
318-
KAL_VERSION ?= v0.0.0-20260205134631-d65d24a9df89
319318
MOCKGEN_VERSION ?= v0.5.0
320319
KUTTL_VERSION ?= v0.24.0
321320
GOVULNCHECK_VERSION ?= v1.1.4
@@ -346,8 +345,8 @@ version: $(GOLANGCI_LINT_VERSION)
346345
name: golangci-kube-api-linter
347346
destination: $(LOCALBIN)
348347
plugins:
349-
- module: 'sigs.k8s.io/kube-api-linter'
350-
version: $(KAL_VERSION)
348+
- module: 'github.com/k-orc/openstack-resource-controller/v2/tools/orc-api-linter'
349+
path: ./tools/orc-api-linter
351350
endef
352351
export custom-gcl
353352

@@ -357,6 +356,7 @@ CUSTOM_GCL_FILE ?= $(shell pwd)/.custom-gcl.yml
357356
golangci-kal: $(GOLANGCI_KAL)
358357
$(GOLANGCI_KAL): $(LOCALBIN) $(GOLANGCI_LINT)
359358
$(file >$(CUSTOM_GCL_FILE),$(custom-gcl))
359+
cd tools/orc-api-linter && go mod tidy
360360
$(GOLANGCI_LINT) custom
361361

362362
.PHONY: mockgen

api/v1alpha1/port_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type HostID struct {
5959
// This is mutually exclusive with serverRef.
6060
// +kubebuilder:validation:MaxLength=36
6161
// +optional
62-
ID string `json:"id,omitempty"`
62+
ID string `json:"id,omitempty"` //nolint:kubeapilinter // intentionally allow raw ID
6363

6464
// serverRef is a reference to an ORC Server resource from which to
6565
// retrieve the hostID for port binding. The hostID will be read from
@@ -167,7 +167,7 @@ type PortResourceSpec struct {
167167
// +kubebuilder:validation:MaxItems:=64
168168
// +listType=set
169169
// +optional
170-
SecurityGroupRefs []OpenStackName `json:"securityGroupRefs,omitempty"`
170+
SecurityGroupRefs []OpenStackName `json:"securityGroupRefs,omitempty"` //nolint:kubeapilinter // https://github.com/k-orc/openstack-resource-controller/issues/438
171171

172172
// vnicType specifies the type of vNIC which this port should be
173173
// attached to. This is used to determine which mechanism driver(s) to
@@ -209,7 +209,7 @@ type PortResourceSpec struct {
209209
// binding host, not the value specified here.
210210
// +optional
211211
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="hostID is immutable"
212-
HostID *HostID `json:"hostID,omitempty"`
212+
HostID *HostID `json:"hostID,omitempty"` //nolint:kubeapilinter // HostID provides both raw ID and ServerRef options
213213
}
214214

215215
type PortResourceStatus struct {

api/v1alpha1/zz_generated.domain-resource.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.flavor-resource.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.floatingip-resource.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.group-resource.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.image-resource.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.keypair-resource.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.network-resource.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)