Skip to content

Commit fe06ced

Browse files
committed
Enable optionalorrequired linter
1 parent c0ef9f4 commit fe06ced

File tree

149 files changed

+1497
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+1497
-44
lines changed

.golangci-kal.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ linters:
2424
#- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
2525
#- "nobools" # Bools do not evolve over time, should use enums instead.
2626
#- "nofloats" # Ensure floats are not used.
27-
#- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
27+
- "optionalorrequired" # Every field should be marked as `+optional` or `+required`.
2828
# - "requiredfields" # Required fields should not be pointers, and should not have `omitempty`.
2929
- "statussubresource" # All root objects that have a `status` field should have a status subresource.
3030

api/v1beta1/awscluster_types.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ const (
3434
// AWSClusterSpec defines the desired state of an EC2-based Kubernetes cluster.
3535
type AWSClusterSpec struct {
3636
// NetworkSpec encapsulates all things related to AWS network.
37+
// +optional
3738
NetworkSpec NetworkSpec `json:"network,omitempty"`
3839

3940
// The AWS Region the cluster lives in.
41+
// +optional
4042
Region string `json:"region,omitempty"`
4143

4244
// SSHKeyName is the name of the ssh key to attach to the bastion host. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name)
@@ -81,6 +83,7 @@ type AWSClusterSpec struct {
8183
// up machine images when a machine does not specify an AMI. When set, this
8284
// will be used for all cluster machines unless a machine specifies a
8385
// different ImageLookupBaseOS.
86+
// +optional
8487
ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"`
8588

8689
// Bastion contains options to configure the bastion host.
@@ -91,6 +94,7 @@ type AWSClusterSpec struct {
9194

9295
// IdentityRef is a reference to an identity to be used when reconciling the managed control plane.
9396
// If no identity is specified, the default identity for this controller will be used.
97+
// +optional
9498
IdentityRef *AWSIdentityReference `json:"identityRef,omitempty"`
9599

96100
// S3Bucket contains options to configure a supporting S3 bucket for this
@@ -119,10 +123,12 @@ var (
119123
type AWSIdentityReference struct {
120124
// Name of the identity.
121125
// +kubebuilder:validation:MinLength=1
126+
// +required
122127
Name string `json:"name"`
123128

124129
// Kind of the identity.
125130
// +kubebuilder:validation:Enum=AWSClusterControllerIdentity;AWSClusterRoleIdentity;AWSClusterStaticIdentity
131+
// +required
126132
Kind AWSIdentityKind `json:"kind"`
127133
}
128134

@@ -146,6 +152,7 @@ type Bastion struct {
146152
// InstanceType will use the specified instance type for the bastion. If not specified,
147153
// Cluster API Provider AWS will use t3.micro for all regions except us-east-1, where t2.micro
148154
// will be the default.
155+
// +optional
149156
InstanceType string `json:"instanceType,omitempty"`
150157

151158
// AMI will use the specified AMI to boot the bastion. If not specified,
@@ -200,27 +207,35 @@ type AWSLoadBalancerSpec struct {
200207
// AWSClusterStatus defines the observed state of AWSCluster.
201208
type AWSClusterStatus struct {
202209
// +kubebuilder:default=false
210+
// +required
203211
Ready bool `json:"ready"`
212+
// +optional
204213
Network NetworkStatus `json:"networkStatus,omitempty"`
214+
// +optional
205215
FailureDomains clusterv1.FailureDomains `json:"failureDomains,omitempty"`
216+
// +optional
206217
Bastion *Instance `json:"bastion,omitempty"`
218+
// +optional
207219
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
208220
}
209221

210222
// S3Bucket defines a supporting S3 bucket for the cluster, currently can be optionally used for Ignition.
211223
type S3Bucket struct {
212224
// ControlPlaneIAMInstanceProfile is a name of the IAMInstanceProfile, which will be allowed
213225
// to read control-plane node bootstrap data from S3 Bucket.
226+
// +required
214227
ControlPlaneIAMInstanceProfile string `json:"controlPlaneIAMInstanceProfile"`
215228

216229
// NodesIAMInstanceProfiles is a list of IAM instance profiles, which will be allowed to read
217230
// worker nodes bootstrap data from S3 Bucket.
231+
// +required
218232
NodesIAMInstanceProfiles []string `json:"nodesIAMInstanceProfiles"`
219233

220234
// Name defines name of S3 Bucket to be created.
221235
// +kubebuilder:validation:MinLength:=3
222236
// +kubebuilder:validation:MaxLength:=63
223237
// +kubebuilder:validation:Pattern=`^[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$`
238+
// +required
224239
Name string `json:"name"`
225240
}
226241

@@ -237,9 +252,12 @@ type S3Bucket struct {
237252
// AWSCluster is the schema for Amazon EC2 based Kubernetes Cluster API.
238253
type AWSCluster struct {
239254
metav1.TypeMeta `json:",inline"`
255+
// +optional
240256
metav1.ObjectMeta `json:"metadata,omitempty"`
241257

258+
// +optional
242259
Spec AWSClusterSpec `json:"spec,omitempty"`
260+
// +optional
243261
Status AWSClusterStatus `json:"status,omitempty"`
244262
}
245263

@@ -249,7 +267,9 @@ type AWSCluster struct {
249267
// AWSClusterList contains a list of AWSCluster.
250268
type AWSClusterList struct {
251269
metav1.TypeMeta `json:",inline"`
270+
// +optional
252271
metav1.ListMeta `json:"metadata,omitempty"`
272+
// +required
253273
Items []AWSCluster `json:"items"`
254274
}
255275

api/v1beta1/awsclustertemplate_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
// AWSClusterTemplateSpec defines the desired state of AWSClusterTemplate.
2626
type AWSClusterTemplateSpec struct {
27+
// +required
2728
Template AWSClusterTemplateResource `json:"template"`
2829
}
2930

@@ -35,8 +36,10 @@ type AWSClusterTemplateSpec struct {
3536
// AWSClusterTemplate is the schema for Amazon EC2 based Kubernetes Cluster Templates.
3637
type AWSClusterTemplate struct {
3738
metav1.TypeMeta `json:",inline"`
39+
// +optional
3840
metav1.ObjectMeta `json:"metadata,omitempty"`
3941

42+
// +optional
4043
Spec AWSClusterTemplateSpec `json:"spec,omitempty"`
4144
}
4245

@@ -45,7 +48,9 @@ type AWSClusterTemplate struct {
4548
// AWSClusterTemplateList contains a list of AWSClusterTemplate.
4649
type AWSClusterTemplateList struct {
4750
metav1.TypeMeta `json:",inline"`
51+
// +optional
4852
metav1.ListMeta `json:"metadata,omitempty"`
53+
// +required
4954
Items []AWSClusterTemplate `json:"items"`
5055
}
5156

@@ -59,5 +64,6 @@ type AWSClusterTemplateResource struct {
5964
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
6065
// +optional
6166
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
67+
// +required
6268
Spec AWSClusterSpec `json:"spec"`
6369
}

api/v1beta1/awsidentity_types.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,24 @@ type AllowedNamespaces struct {
5353
// AWSRoleSpec defines the specifications for all identities based around AWS roles.
5454
type AWSRoleSpec struct {
5555
// The Amazon Resource Name (ARN) of the role to assume.
56+
// +required
5657
RoleArn string `json:"roleARN"`
5758
// An identifier for the assumed role session
59+
// +optional
5860
SessionName string `json:"sessionName,omitempty"`
5961
// The duration, in seconds, of the role session before it is renewed.
6062
// +kubebuilder:validation:Minimum:=900
6163
// +kubebuilder:validation:Maximum:=43200
64+
// +optional
6265
DurationSeconds int32 `json:"durationSeconds,omitempty"`
6366
// An IAM policy as a JSON-encoded string that you want to use as an inline session policy.
67+
// +optional
6468
InlinePolicy string `json:"inlinePolicy,omitempty"`
6569

6670
// The Amazon Resource Names (ARNs) of the IAM managed policies that you want
6771
// to use as managed session policies.
6872
// The policies must exist in the same account as the role.
73+
// +optional
6974
PolicyARNs []string `json:"policyARNs,omitempty"`
7075
}
7176

@@ -77,9 +82,11 @@ type AWSRoleSpec struct {
7782
// It represents a reference to an AWS access key ID and secret access key, stored in a secret.
7883
type AWSClusterStaticIdentity struct {
7984
metav1.TypeMeta `json:",inline"`
85+
// +optional
8086
metav1.ObjectMeta `json:"metadata,omitempty"`
8187

8288
// Spec for this AWSClusterStaticIdentity
89+
// +optional
8390
Spec AWSClusterStaticIdentitySpec `json:"spec,omitempty"`
8491
}
8592

@@ -89,7 +96,9 @@ type AWSClusterStaticIdentity struct {
8996
// AWSClusterStaticIdentityList contains a list of AWSClusterStaticIdentity.
9097
type AWSClusterStaticIdentityList struct {
9198
metav1.TypeMeta `json:",inline"`
99+
// +optional
92100
metav1.ListMeta `json:"metadata,omitempty"`
101+
// +required
93102
Items []AWSClusterStaticIdentity `json:"items"`
94103
}
95104

@@ -101,6 +110,7 @@ type AWSClusterStaticIdentitySpec struct {
101110
// AccessKeyID: AKIAIOSFODNN7EXAMPLE
102111
// SecretAccessKey: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
103112
// SessionToken: Optional
113+
// +required
104114
SecretRef string `json:"secretRef"`
105115
}
106116

@@ -112,9 +122,11 @@ type AWSClusterStaticIdentitySpec struct {
112122
// It is used to assume a role using the provided sourceRef.
113123
type AWSClusterRoleIdentity struct {
114124
metav1.TypeMeta `json:",inline"`
125+
// +optional
115126
metav1.ObjectMeta `json:"metadata,omitempty"`
116127

117128
// Spec for this AWSClusterRoleIdentity.
129+
// +optional
118130
Spec AWSClusterRoleIdentitySpec `json:"spec,omitempty"`
119131
}
120132

@@ -124,7 +136,9 @@ type AWSClusterRoleIdentity struct {
124136
// AWSClusterRoleIdentityList contains a list of AWSClusterRoleIdentity.
125137
type AWSClusterRoleIdentityList struct {
126138
metav1.TypeMeta `json:",inline"`
139+
// +optional
127140
metav1.ListMeta `json:"metadata,omitempty"`
141+
// +required
128142
Items []AWSClusterRoleIdentity `json:"items"`
129143
}
130144

@@ -146,6 +160,7 @@ type AWSClusterRoleIdentitySpec struct {
146160

147161
// SourceIdentityRef is a reference to another identity which will be chained to do
148162
// role assumption. All identity types are accepted.
163+
// +optional
149164
SourceIdentityRef *AWSIdentityReference `json:"sourceIdentityRef,omitempty"`
150165
}
151166

@@ -157,9 +172,11 @@ type AWSClusterRoleIdentitySpec struct {
157172
// It is used to grant access to use Cluster API Provider AWS Controller credentials.
158173
type AWSClusterControllerIdentity struct {
159174
metav1.TypeMeta `json:",inline"`
175+
// +optional
160176
metav1.ObjectMeta `json:"metadata,omitempty"`
161177

162178
// Spec for this AWSClusterControllerIdentity.
179+
// +optional
163180
Spec AWSClusterControllerIdentitySpec `json:"spec,omitempty"`
164181
}
165182

@@ -169,7 +186,9 @@ type AWSClusterControllerIdentity struct {
169186
// AWSClusterControllerIdentityList contains a list of AWSClusterControllerIdentity.
170187
type AWSClusterControllerIdentityList struct {
171188
metav1.TypeMeta `json:",inline"`
189+
// +optional
172190
metav1.ListMeta `json:"metadata,omitempty"`
191+
// +required
173192
Items []AWSClusterControllerIdentity `json:"items"`
174193
}
175194

api/v1beta1/awsmachine_types.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ var (
4545
// AWSMachineSpec defines the desired state of an Amazon EC2 instance.
4646
type AWSMachineSpec struct {
4747
// ProviderID is the unique identifier as specified by the cloud provider.
48+
// +optional
4849
ProviderID *string `json:"providerID,omitempty"`
4950

5051
// InstanceID is the EC2 instance ID for this machine.
52+
// +optional
5153
InstanceID *string `json:"instanceID,omitempty"`
5254

5355
// AMI is the reference to the AMI from which to create the machine instance.
56+
// +optional
5457
AMI AMIReference `json:"ami,omitempty"`
5558

5659
// ImageLookupFormat is the AMI naming format to look up the image for this
@@ -68,14 +71,16 @@ type AWSMachineSpec struct {
6871
ImageLookupFormat string `json:"imageLookupFormat,omitempty"`
6972

7073
// ImageLookupOrg is the AWS Organization ID to use for image lookup if AMI is not set.
74+
// +optional
7175
ImageLookupOrg string `json:"imageLookupOrg,omitempty"`
7276

7377
// ImageLookupBaseOS is the name of the base operating system to use for
7478
// image lookup the AMI is not set.
79+
// +optional
7580
ImageLookupBaseOS string `json:"imageLookupBaseOS,omitempty"`
7681

7782
// InstanceType is the type of instance to create. Example: m4.xlarge
78-
// +kubebuilder:validation:Required
83+
// +required
7984
// +kubebuilder:validation:MinLength:=2
8085
InstanceType string `json:"instanceType"`
8186

@@ -107,6 +112,7 @@ type AWSMachineSpec struct {
107112
// FailureDomain is the failure domain unique identifier this Machine should be attached to, as defined in Cluster API.
108113
// For this infrastructure provider, the ID is equivalent to an AWS Availability Zone.
109114
// If multiple subnets are matched for the availability zone, the first one returned is picked.
115+
// +optional
110116
FailureDomain *string `json:"failureDomain,omitempty"`
111117

112118
// Subnet is a reference to the subnet to use for this instance. If not specified,
@@ -165,6 +171,7 @@ type CloudInit struct {
165171
// or AWS Systems Manager Parameter Store to ensure privacy of userdata.
166172
// By default, a cloud-init boothook shell script is prepended to download
167173
// the userdata from Secrets Manager and additionally delete the secret.
174+
// +optional
168175
InsecureSkipSecretsManager bool `json:"insecureSkipSecretsManager,omitempty"`
169176

170177
// SecretCount is the number of secrets used to form the complete secret
@@ -207,6 +214,7 @@ type AWSMachineStatus struct {
207214
Interruptible bool `json:"interruptible,omitempty"`
208215

209216
// Addresses contains the AWS instance associated addresses.
217+
// +optional
210218
Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"`
211219

212220
// InstanceState is the state of the AWS instance for this machine.
@@ -269,9 +277,12 @@ type AWSMachineStatus struct {
269277
// AWSMachine is the schema for Amazon EC2 machines.
270278
type AWSMachine struct {
271279
metav1.TypeMeta `json:",inline"`
280+
// +optional
272281
metav1.ObjectMeta `json:"metadata,omitempty"`
273282

283+
// +optional
274284
Spec AWSMachineSpec `json:"spec,omitempty"`
285+
// +optional
275286
Status AWSMachineStatus `json:"status,omitempty"`
276287
}
277288

@@ -291,7 +302,9 @@ func (r *AWSMachine) SetConditions(conditions clusterv1.Conditions) {
291302
// AWSMachineList contains a list of Amazon EC2 machines.
292303
type AWSMachineList struct {
293304
metav1.TypeMeta `json:",inline"`
305+
// +optional
294306
metav1.ListMeta `json:"metadata,omitempty"`
307+
// +required
295308
Items []AWSMachine `json:"items"`
296309
}
297310

api/v1beta1/awsmachinetemplate_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type AWSMachineTemplateStatus struct {
3434

3535
// AWSMachineTemplateSpec defines the desired state of AWSMachineTemplate.
3636
type AWSMachineTemplateSpec struct {
37+
// +required
3738
Template AWSMachineTemplateResource `json:"template"`
3839
}
3940

@@ -44,9 +45,12 @@ type AWSMachineTemplateSpec struct {
4445
// AWSMachineTemplate is the schema for the Amazon EC2 Machine Templates API.
4546
type AWSMachineTemplate struct {
4647
metav1.TypeMeta `json:",inline"`
48+
// +optional
4749
metav1.ObjectMeta `json:"metadata,omitempty"`
4850

51+
// +optional
4952
Spec AWSMachineTemplateSpec `json:"spec,omitempty"`
53+
// +optional
5054
Status AWSMachineTemplateStatus `json:"status,omitempty"`
5155
}
5256

@@ -56,7 +60,9 @@ type AWSMachineTemplate struct {
5660
// AWSMachineTemplateList contains a list of AWSMachineTemplate.
5761
type AWSMachineTemplateList struct {
5862
metav1.TypeMeta `json:",inline"`
63+
// +optional
5964
metav1.ListMeta `json:"metadata,omitempty"`
65+
// +required
6066
Items []AWSMachineTemplate `json:"items"`
6167
}
6268

@@ -68,6 +74,7 @@ type AWSMachineTemplateResource struct {
6874
ObjectMeta clusterv1.ObjectMeta `json:"metadata,omitempty"`
6975

7076
// Spec is the specification of the desired behavior of the machine.
77+
// +required
7178
Spec AWSMachineSpec `json:"spec"`
7279
}
7380

0 commit comments

Comments
 (0)