-
Notifications
You must be signed in to change notification settings - Fork 68
WIP: Fix API k8s API conventions and Kube API linter check #2394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
a3d27bb
18053e1
3daa019
870c483
0198d4b
070424b
c565f79
b0e0d65
5feea3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| version: v2.7.2 | ||
| name: golangci-lint-kube-api | ||
| destination: ./bin | ||
|
|
||
| plugins: | ||
| - module: sigs.k8s.io/kube-api-linter | ||
| version: latest |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,11 +58,12 @@ type ClusterCatalog struct { | |||||
|
|
||||||
| // metadata is the standard object's metadata. | ||||||
| // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata | ||||||
| metav1.ObjectMeta `json:"metadata"` | ||||||
| // +optional | ||||||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||||||
|
|
||||||
| // spec is a required field that defines the desired state of the ClusterCatalog. | ||||||
| // The controller ensures that the catalog is unpacked and served over the catalog content HTTP server. | ||||||
| // +kubebuilder:validation:Required | ||||||
| // +required | ||||||
| Spec ClusterCatalogSpec `json:"spec"` | ||||||
|
|
||||||
| // status contains the following information about the state of the ClusterCatalog: | ||||||
|
|
@@ -81,11 +82,11 @@ type ClusterCatalogList struct { | |||||
|
|
||||||
| // metadata is the standard object's metadata. | ||||||
| // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata | ||||||
| metav1.ListMeta `json:"metadata"` | ||||||
| metav1.ListMeta `json:"metadata,omitempty"` | ||||||
|
||||||
| metav1.ListMeta `json:"metadata,omitempty"` | |
| metav1.ListMeta `json:"metadata"` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ type ClusterExtensionSpec struct { | |
| // +kubebuilder:validation:MaxLength:=63 | ||
| // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="namespace is immutable" | ||
| // +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?$\")",message="namespace must be a valid DNS1123 label" | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| Namespace string `json:"namespace"` | ||
|
|
||
| // serviceAccount specifies a ServiceAccount used to perform all interactions with the cluster | ||
|
|
@@ -72,7 +72,7 @@ type ClusterExtensionSpec struct { | |
| // The ServiceAccount must exist in the namespace referenced in the spec. | ||
| // The serviceAccount field is required. | ||
| // | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| ServiceAccount ServiceAccountReference `json:"serviceAccount"` | ||
|
|
||
| // source is required and selects the installation source of content for this ClusterExtension. | ||
|
|
@@ -88,7 +88,7 @@ type ClusterExtensionSpec struct { | |
| // catalog: | ||
| // packageName: example-package | ||
| // | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| Source SourceConfig `json:"source"` | ||
|
|
||
| // install is optional and configures installation options for the ClusterExtension, | ||
|
|
@@ -127,7 +127,7 @@ type SourceConfig struct { | |
| // | ||
| // +unionDiscriminator | ||
| // +kubebuilder:validation:Enum:="Catalog" | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| SourceType string `json:"sourceType"` | ||
|
|
||
| // catalog configures how information is sourced from a catalog. | ||
|
|
@@ -167,7 +167,7 @@ type ClusterExtensionConfig struct { | |
| // | ||
| // +unionDiscriminator | ||
| // +kubebuilder:validation:Enum:="Inline" | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| ConfigType ClusterExtensionConfigType `json:"configType"` | ||
|
|
||
| // inline contains JSON or YAML values specified directly in the ClusterExtension. | ||
|
|
@@ -206,11 +206,10 @@ type CatalogFilter struct { | |
| // | ||
| // [RFC 1123]: https://tools.ietf.org/html/rfc1123 | ||
| // | ||
| // +kubebuilder:validation.Required | ||
| // +kubebuilder:validation:MaxLength:=253 | ||
| // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="packageName is immutable" | ||
| // +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="packageName must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters" | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| PackageName string `json:"packageName"` | ||
|
|
||
| // version is an optional semver constraint (a specific version or range of versions). | ||
|
|
@@ -393,7 +392,7 @@ type ServiceAccountReference struct { | |
| // +kubebuilder:validation:MaxLength:=253 | ||
| // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable" | ||
| // +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="name must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters" | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| Name string `json:"name"` | ||
| } | ||
|
|
||
|
|
@@ -421,7 +420,7 @@ type CRDUpgradeSafetyPreflightConfig struct { | |
| // When set to "Strict", the CRD Upgrade Safety pre-flight check runs during an upgrade operation. | ||
| // | ||
|
Comment on lines
420
to
421
|
||
| // +kubebuilder:validation:Enum:="None";"Strict" | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| Enforcement CRDUpgradeSafetyEnforcement `json:"enforcement"` | ||
| } | ||
|
|
||
|
|
@@ -445,21 +444,22 @@ type BundleMetadata struct { | |
| // It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), | ||
| // start and end with an alphanumeric character, and be no longer than 253 characters. | ||
| // | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| // +kubebuilder:validation:XValidation:rule="self.matches(\"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$\")",message="packageName must be a valid DNS1123 subdomain. It must contain only lowercase alphanumeric characters, hyphens (-) or periods (.), start and end with an alphanumeric character, and be no longer than 253 characters" | ||
| Name string `json:"name"` | ||
|
|
||
| // version is required and references the version that this bundle represents. | ||
| // It follows the semantic versioning standard as defined in https://semver.org/. | ||
| // | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| // +kubebuilder:validation:XValidation:rule="self.matches(\"^([0-9]+)(\\\\.[0-9]+)?(\\\\.[0-9]+)?(-([-0-9A-Za-z]+(\\\\.[-0-9A-Za-z]+)*))?(\\\\+([-0-9A-Za-z]+(-\\\\.[-0-9A-Za-z]+)*))?\")",message="version must be well-formed semver" | ||
| Version string `json:"version"` | ||
| } | ||
|
|
||
| // RevisionStatus defines the observed state of a ClusterExtensionRevision. | ||
| type RevisionStatus struct { | ||
| // name of the ClusterExtensionRevision resource | ||
| // +required | ||
| Name string `json:"name"` | ||
| // conditions optionally expose Progressing and Available condition of the revision, | ||
| // in case when it is not yet marked as successfully installed (condition Succeeded is not set to True). | ||
|
|
@@ -521,7 +521,7 @@ type ClusterExtensionInstallStatus struct { | |
| // A "bundle" is a versioned set of content that represents the resources that need to be applied | ||
| // to a cluster to install a package. | ||
| // | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| Bundle BundleMetadata `json:"bundle"` | ||
| } | ||
|
|
||
|
|
@@ -559,7 +559,7 @@ type ClusterExtensionList struct { | |
|
|
||
| // items is a required list of ClusterExtension objects. | ||
| // | ||
| // +kubebuilder:validation:Required | ||
| // +required | ||
| Items []ClusterExtension `json:"items"` | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exclusion rule appears to be inverted. The configuration "path-except: ^api/" with "linters: - kubeapilinter" means the kubeapilinter will be excluded from running on paths matching ^api/, which is the opposite of what's intended. The kubeapilinter should specifically check the api/ directory for Kubernetes API conventions. Consider using a positive path filter instead, or use the issues exclusion syntax to only run kubeapilinter on api/ paths.