Skip to content

Commit 2f48458

Browse files
committed
Updated kube-api-linter version to the latest. After update relax conditions checks in .golangci-kal.yml (comment out conditions config). The older version was not picking them.
1 parent 44bbc87 commit 2f48458

File tree

12 files changed

+71
-45
lines changed

12 files changed

+71
-45
lines changed

.golangci-kal.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ linters:
3232
disable:
3333
- "*" # We will manually enable new linters after understanding the impact. Disable all by default.
3434
lintersConfig:
35-
conditions:
36-
isFirstField: Warn # Require conditions to be the first field in the status struct.
37-
usePatchStrategy: Forbid # Conditions should not use the patch strategy on CRDs.
38-
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
35+
# conditions:
36+
# isFirstField: Warn # Require conditions to be the first field in the status struct.
37+
# usePatchStrategy: Forbid # Conditions should not use the patch strategy on CRDs.
38+
# useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
3939
# jsonTags:
4040
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
4141
# optionalOrRequired:

api/v1beta1/awsmachine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type AWSMachineSpec struct {
7777
// InstanceType is the type of instance to create. Example: m4.xlarge
7878
// +kubebuilder:validation:Required
7979
// +kubebuilder:validation:MinLength:=2
80-
InstanceType string `json:"instanceType"`
80+
InstanceType string `json:"instanceType,omitempty"`
8181

8282
// AdditionalTags is an optional set of tags to add to an instance, in addition to the ones added by default by the
8383
// AWS provider. If both the AWSCluster and the AWSMachine specify the same tag name with different values, the

api/v1beta2/awsmachine_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ type AWSMachineSpec struct {
114114
// InstanceType is the type of instance to create. Example: m4.xlarge
115115
// +kubebuilder:validation:Required
116116
// +kubebuilder:validation:MinLength:=2
117-
InstanceType string `json:"instanceType"`
117+
InstanceType string `json:"instanceType,omitempty"`
118118

119119
// AdditionalTags is an optional set of tags to add to an instance, in addition to the ones added by default by the
120120
// AWS provider. If both the AWSCluster and the AWSMachine specify the same tag name with different values, the

controlplane/eks/api/v1beta1/types.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ type Addon struct {
127127
// Name is the name of the addon
128128
// +kubebuilder:validation:MinLength:=2
129129
// +kubebuilder:validation:Required
130-
Name string `json:"name"`
130+
Name string `json:"name,omitempty"`
131131
// Version is the version of the addon to use
132132
Version string `json:"version"`
133133
// Configuration of the EKS addon
@@ -223,7 +223,8 @@ type OIDCIdentityProviderConfig struct {
223223
// This is also known as audience. The ID for the client application that makes
224224
// authentication requests to the OpenID identity provider.
225225
// +kubebuilder:validation:Required
226-
ClientID string `json:"clientId"`
226+
// +kubebuilder:validation:MinLength=1
227+
ClientID string `json:"clientId,omitempty"`
227228

228229
// The JWT claim that the provider uses to return your groups.
229230
// +optional
@@ -239,7 +240,8 @@ type OIDCIdentityProviderConfig struct {
239240
//
240241
// IdentityProviderConfigName is a required field
241242
// +kubebuilder:validation:Required
242-
IdentityProviderConfigName string `json:"identityProviderConfigName"`
243+
// +kubebuilder:validation:MinLength=1
244+
IdentityProviderConfigName string `json:"identityProviderConfigName,omitempty"`
243245

244246
// The URL of the OpenID identity provider that allows the API server to discover
245247
// public signing keys for verifying tokens. The URL must begin with https://
@@ -250,7 +252,9 @@ type OIDCIdentityProviderConfig struct {
250252
// and must be publicly accessible over the internet.
251253
//
252254
// +kubebuilder:validation:Required
253-
IssuerURL string `json:"issuerUrl"`
255+
// +kubebuilder:validation:MinLength=1
256+
// +kubebuilder:validation:Pattern=^https://
257+
IssuerURL string `json:"issuerUrl,omitempty"`
254258

255259
// The key value pairs that describe required claims in the identity token.
256260
// If set, each claim is verified to be present in the token with a matching

controlplane/eks/api/v1beta2/types.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ type KubernetesMapping struct {
107107
// RoleMapping represents a mapping from a IAM role to Kubernetes users and groups.
108108
type RoleMapping struct {
109109
// RoleARN is the AWS ARN for the role to map
110-
// +kubebuilder:validation:MinLength:=31
110+
// +kubebuilder:validation:MinLength=31
111111
RoleARN string `json:"rolearn"`
112112
// KubernetesMapping holds the RBAC details for the mapping
113113
KubernetesMapping `json:",inline"`
@@ -116,7 +116,7 @@ type RoleMapping struct {
116116
// UserMapping represents a mapping from an IAM user to Kubernetes users and groups.
117117
type UserMapping struct {
118118
// UserARN is the AWS ARN for the user to map
119-
// +kubebuilder:validation:MinLength:=31
119+
// +kubebuilder:validation:MinLength=31
120120
UserARN string `json:"userarn"`
121121
// KubernetesMapping holds the RBAC details for the mapping
122122
KubernetesMapping `json:",inline"`
@@ -125,9 +125,9 @@ type UserMapping struct {
125125
// Addon represents a EKS addon.
126126
type Addon struct {
127127
// Name is the name of the addon
128-
// +kubebuilder:validation:MinLength:=2
128+
// +kubebuilder:validation:MinLength=2
129129
// +kubebuilder:validation:Required
130-
Name string `json:"name"`
130+
Name string `json:"name,omitempty"`
131131
// Version is the version of the addon to use
132132
Version string `json:"version"`
133133
// Configuration of the EKS addon
@@ -227,7 +227,8 @@ type OIDCIdentityProviderConfig struct {
227227
// This is also known as audience. The ID for the client application that makes
228228
// authentication requests to the OpenID identity provider.
229229
// +kubebuilder:validation:Required
230-
ClientID string `json:"clientId"`
230+
// +kubebuilder:validation:MinLength=1
231+
ClientID string `json:"clientId,omitempty"`
231232

232233
// The JWT claim that the provider uses to return your groups.
233234
// +optional
@@ -243,7 +244,8 @@ type OIDCIdentityProviderConfig struct {
243244
//
244245
// IdentityProviderConfigName is a required field
245246
// +kubebuilder:validation:Required
246-
IdentityProviderConfigName string `json:"identityProviderConfigName"`
247+
// +kubebuilder:validation:MinLength=1
248+
IdentityProviderConfigName string `json:"identityProviderConfigName,omitempty"`
247249

248250
// The URL of the OpenID identity provider that allows the API server to discover
249251
// public signing keys for verifying tokens. The URL must begin with https://
@@ -254,7 +256,9 @@ type OIDCIdentityProviderConfig struct {
254256
// and must be publicly accessible over the internet.
255257
//
256258
// +kubebuilder:validation:Required
257-
IssuerURL string `json:"issuerUrl"`
259+
// +kubebuilder:validation:MinLength=1
260+
// +kubebuilder:validation:Pattern=^https://
261+
IssuerURL string `json:"issuerUrl,omitempty"`
258262

259263
// The key value pairs that describe required claims in the identity token.
260264
// If set, each claim is verified to be present in the token with a matching

controlplane/rosa/api/v1beta2/external_auth_types.go

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ package v1beta2
44
type ExternalAuthProvider struct {
55
// Name of the OIDC provider
66
//
7-
// +kubebuilder:validation:MinLength=1
87
// +kubebuilder:validation:Required
8+
// +kubebuilder:validation:MinLength=1
99
// +required
10-
Name string `json:"name"`
10+
Name string `json:"name,omitempty"`
1111
// Issuer describes attributes of the OIDC token issuer
1212
//
1313
// +kubebuilder:validation:Required
14+
// +kubebuilder:validation:MinLength=1
1415
// +required
15-
Issuer TokenIssuer `json:"issuer"`
16+
Issuer TokenIssuer `json:"issuer,omitzero"`
1617

1718
// OIDCClients contains configuration for the platform's clients that
1819
// need to request tokens from the issuer
@@ -46,9 +47,10 @@ type TokenIssuer struct {
4647
// Must use the https:// scheme.
4748
//
4849
// +kubebuilder:validation:Pattern=`^https:\/\/[^\s]`
50+
// +kubebuilder:validation:MinLength=1
4951
// +kubebuilder:validation:Required
5052
// +required
51-
URL string `json:"issuerURL"`
53+
URL string `json:"issuerURL,omitempty"`
5254

5355
// Audiences is an array of audiences that the token was issued for.
5456
// Valid tokens must include at least one of these values in their
@@ -60,7 +62,7 @@ type TokenIssuer struct {
6062
// +kubebuilder:validation:MinItems=1
6163
// +kubebuilder:validation:MaxItems=10
6264
// +required
63-
Audiences []TokenAudience `json:"audiences"`
65+
Audiences []TokenAudience `json:"audiences,omitempty"`
6466

6567
// CertificateAuthority is a reference to a config map in the
6668
// configuration namespace. The .data of the configMap must contain
@@ -79,23 +81,24 @@ type OIDCClientConfig struct {
7981
// +kubebuilder:validation:MaxLength=256
8082
// +kubebuilder:validation:Required
8183
// +required
82-
ComponentName string `json:"componentName"`
84+
ComponentName string `json:"componentName,omitempty"`
8385

8486
// ComponentNamespace is the namespace of the component that is supposed to consume this
8587
// client configuration
8688
//
8789
// +kubebuilder:validation:MinLength=1
8890
// +kubebuilder:validation:MaxLength=63
8991
// +kubebuilder:validation:Required
92+
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
9093
// +required
91-
ComponentNamespace string `json:"componentNamespace"`
94+
ComponentNamespace string `json:"componentNamespace,omitempty"`
9295

9396
// ClientID is the identifier of the OIDC client from the OIDC provider
9497
//
9598
// +kubebuilder:validation:MinLength=1
9699
// +kubebuilder:validation:Required
97100
// +required
98-
ClientID string `json:"clientID"`
101+
ClientID string `json:"clientID,omitempty"`
99102

100103
// ClientSecret refers to a secret that
101104
// contains the client secret in the `clientSecret` key of the `.data` field
@@ -130,8 +133,9 @@ type PrefixedClaimMapping struct {
130133
// Claim is a JWT token claim to be used in the mapping
131134
//
132135
// +kubebuilder:validation:Required
136+
// +kubebuilder:validation:MinLength=1
133137
// +required
134-
Claim string `json:"claim"`
138+
Claim string `json:"claim,omitempty"`
135139

136140
// Prefix is a string to prefix the value from the token in the result of the
137141
// claim mapping.
@@ -151,8 +155,9 @@ type UsernameClaimMapping struct {
151155
// Claim is a JWT token claim to be used in the mapping
152156
//
153157
// +kubebuilder:validation:Required
158+
// +kubebuilder:validation:MinLength=1
154159
// +required
155-
Claim string `json:"claim"`
160+
Claim string `json:"claim,omitempty"`
156161

157162
// PrefixPolicy specifies how a prefix should apply.
158163
//
@@ -218,7 +223,8 @@ type TokenClaimValidationRule struct {
218223

219224
// RequiredClaim allows configuring a required claim name and its expected value
220225
// +kubebuilder:validation:Required
221-
RequiredClaim TokenRequiredClaim `json:"requiredClaim"`
226+
// +kubebuilder:validation:MinLength=1
227+
RequiredClaim TokenRequiredClaim `json:"requiredClaim,omitzero"`
222228
}
223229

224230
// TokenRequiredClaim allows configuring a required claim name and its expected value.
@@ -229,21 +235,22 @@ type TokenRequiredClaim struct {
229235
// +kubebuilder:validation:MinLength=1
230236
// +kubebuilder:validation:Required
231237
// +required
232-
Claim string `json:"claim"`
238+
Claim string `json:"claim,omitempty"`
233239

234240
// RequiredValue is the required value for the claim.
235241
//
236242
// +kubebuilder:validation:MinLength=1
237243
// +kubebuilder:validation:Required
238244
// +required
239-
RequiredValue string `json:"requiredValue"`
245+
RequiredValue string `json:"requiredValue,omitempty"`
240246
}
241247

242248
// LocalObjectReference references an object in the same namespace.
243249
type LocalObjectReference struct {
244250
// Name is the metadata.name of the referenced object.
245251
//
246252
// +kubebuilder:validation:Required
253+
// +kubebuilder:validation:MinLength=1
247254
// +required
248-
Name string `json:"name"`
255+
Name string `json:"name,omitempty"`
249256
}

exp/api/v1beta1/awsmachinepool_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ type AWSMachinePoolSpec struct {
6060

6161
// AWSLaunchTemplate specifies the launch template and version to use when an instance is launched.
6262
// +kubebuilder:validation:Required
63-
AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate"`
63+
// +kubebuilder:validation:MinProperties=1
64+
AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate,omitzero"`
6465

6566
// MixedInstancesPolicy describes how multiple instance types will be used by the ASG.
6667
MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"`

exp/api/v1beta1/types.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ type EBS struct {
5353
type BlockDeviceMapping struct {
5454
// The device name exposed to the EC2 instance (for example, /dev/sdh or xvdh).
5555
// +kubebuilder:validation:Required
56-
DeviceName string `json:"deviceName"`
56+
// +kubebuilder:validation:MinLength=1
57+
DeviceName string `json:"deviceName,omitempty"`
5758

5859
// You can specify either VirtualName or Ebs, but not both.
5960
// +optional
@@ -227,13 +228,15 @@ type Taint struct {
227228
// Effect specifies the effect for the taint
228229
// +kubebuilder:validation:Required
229230
// +kubebuilder:validation:Enum=no-schedule;no-execute;prefer-no-schedule
230-
Effect TaintEffect `json:"effect"`
231+
Effect TaintEffect `json:"effect,omitempty"`
231232
// Key is the key of the taint
232233
// +kubebuilder:validation:Required
233-
Key string `json:"key"`
234+
// +kubebuilder:validation:MinLength=1
235+
Key string `json:"key,omitempty"`
234236
// Value is the value of the taint
235237
// +kubebuilder:validation:Required
236-
Value string `json:"value"`
238+
// +kubebuilder:validation:MinLength=1
239+
Value string `json:"value,omitempty"`
237240
}
238241

239242
// Equals is used to test if 2 taints are equal.

exp/api/v1beta2/awsmachinepool_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ type AWSMachinePoolSpec struct {
6767

6868
// AWSLaunchTemplate specifies the launch template and version to use when an instance is launched.
6969
// +kubebuilder:validation:Required
70-
AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate"`
70+
// +kubebuilder:validation:MinProperties=1
71+
AWSLaunchTemplate AWSLaunchTemplate `json:"awsLaunchTemplate,omitzero"`
7172

7273
// MixedInstancesPolicy describes how multiple instance types will be used by the ASG.
7374
MixedInstancesPolicy *MixedInstancesPolicy `json:"mixedInstancesPolicy,omitempty"`

exp/api/v1beta2/rosamachinepool_types.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ type RosaMachinePoolSpec struct {
7474
// InstanceType specifies the AWS instance type
7575
//
7676
// +kubebuilder:validation:Required
77-
InstanceType string `json:"instanceType"`
77+
// +kubebuilder:validation:MinLength=1
78+
// +required
79+
InstanceType string `json:"instanceType,omitempty"`
7880

7981
// Autoscaling specifies auto scaling behaviour for this MachinePool.
8082
// required if Replicas is not configured
@@ -125,7 +127,8 @@ type RosaTaint struct {
125127
// The taint key to be applied to a node.
126128
//
127129
// +kubebuilder:validation:Required
128-
Key string `json:"key"`
130+
// +kubebuilder:validation:MinLength=1
131+
Key string `json:"key,omitempty"`
129132
// The taint value corresponding to the taint key.
130133
//
131134
// +kubebuilder:validation:Pattern:=`^(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?$`
@@ -136,7 +139,7 @@ type RosaTaint struct {
136139
//
137140
// +kubebuilder:validation:Required
138141
// +kubebuilder:validation:Enum=NoSchedule;PreferNoSchedule;NoExecute
139-
Effect corev1.TaintEffect `json:"effect"`
142+
Effect corev1.TaintEffect `json:"effect,omitempty"`
140143
}
141144

142145
// RosaMachinePoolAutoScaling specifies scaling options.

0 commit comments

Comments
 (0)