Skip to content

Commit 4a56243

Browse files
committed
enable the optionalorrequired linter for the various APIs
1 parent 7bd25af commit 4a56243

12 files changed

+200
-4
lines changed

.golangci-kal.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ linters:
1616
description: Kube API LInter lints Kube like APIs based on API conventions and best practices.
1717
settings:
1818
linters:
19-
enable:
20-
- "commentstart"
19+
# TODO: remove linters from this list as we add support from them
2120
disable:
22-
- "*"
21+
- "ssatags"
22+
- "nomaps"
23+
- "integers"
24+
- "conditions"
25+
- "jsontags"
26+
- "requiredfields"
27+
- "optionalfields"
2328
lintersConfig: { }
2429
exclusions:
2530
rules:

api/v1alpha2/addressset_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import (
2323
// AddressSetSpec defines the desired state of AddressSet
2424
type AddressSetSpec struct {
2525
// ipv4 defines a list of IPv4 address strings
26+
// +optional
2627
IPv4 *[]string `json:"ipv4,omitempty"`
2728
// ipv6 defines a list of IPv6 address strings
29+
// +optional
2830
IPv6 *[]string `json:"ipv6,omitempty"`
2931
}
3032

@@ -41,10 +43,13 @@ type AddressSetStatus struct {
4143
type AddressSet struct {
4244
metav1.TypeMeta `json:",inline"`
4345
// metadata is the standard object's metadata.
46+
// +optional
4447
metav1.ObjectMeta `json:"metadata,omitempty"`
4548
// spec is the desired state of the AddressSet
49+
// +optional
4650
Spec AddressSetSpec `json:"spec,omitempty"`
4751
// status is the observed state of the AddressSet
52+
// +optional
4853
Status AddressSetStatus `json:"status,omitempty"`
4954
}
5055

api/v1alpha2/firewallrule_types.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,33 @@ import (
2525
// FirewallRuleSpec defines the desired state of FirewallRule.
2626
type FirewallRuleSpec struct {
2727
// action is the action to take when the rule matches.
28+
// +required
2829
Action string `json:"action"`
30+
2931
// label is the label of the rule.
32+
// +required
3033
Label string `json:"label"`
34+
3135
// description is the description of the rule.
36+
// +optional
3237
Description string `json:"description,omitempty"`
38+
3339
// ports is the ports to apply the rule to.
40+
// +optional
3441
Ports string `json:"ports,omitempty"`
42+
3543
// protocol is the protocol to apply the rule to.
3644
// +kubebuilder:validation:Enum=TCP;UDP;ICMP;IPENCAP
45+
// +required
3746
Protocol linodego.NetworkProtocol `json:"protocol"`
47+
3848
// addresses is a list of addresses to apply the rule to.
49+
// +optional
3950
Addresses *NetworkAddresses `json:"addresses,omitempty"`
51+
4052
// addressSetRefs is a list of references to AddressSets as an alternative to
4153
// using Addresses but can be used in conjunction with it.
54+
// +optional
4255
AddressSetRefs []*corev1.ObjectReference `json:"addressSetRefs,omitempty"`
4356
}
4457

@@ -47,8 +60,11 @@ type FirewallRuleSpec struct {
4760
// for linodego.NetworkAddresses
4861
type NetworkAddresses struct {
4962
// ipv4 defines a list of IPv4 address strings.
63+
// +optional
5064
IPv4 *[]string `json:"ipv4,omitempty"`
65+
5166
// ipv6 defines a list of IPv6 address strings.
67+
// +optional
5268
IPv6 *[]string `json:"ipv6,omitempty"`
5369
}
5470

@@ -66,11 +82,17 @@ type FirewallRuleStatus struct {
6682
// FirewallRule is the Schema for the firewallrules API
6783
type FirewallRule struct {
6884
metav1.TypeMeta `json:",inline"`
85+
6986
// metadata is the standard object's metadata.
87+
// +optional
7088
metav1.ObjectMeta `json:"metadata,omitempty"`
89+
7190
// spec is the desired state of the FirewallRule.
91+
// +optional
7292
Spec FirewallRuleSpec `json:"spec,omitempty"`
93+
7394
// status is the observed state of the FirewallRule.
95+
// +optional
7496
Status FirewallRuleStatus `json:"status,omitempty"`
7597
}
7698

@@ -80,6 +102,7 @@ type FirewallRule struct {
80102
type FirewallRuleList struct {
81103
metav1.TypeMeta `json:",inline"`
82104
// metadata is the standard object's metadata.
105+
// +optional
83106
metav1.ListMeta `json:"metadata,omitempty"`
84107
// items is a list of FirewallRule.
85108
Items []FirewallRule `json:"items"`

api/v1alpha2/linodecluster_types.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const (
3131
// LinodeClusterSpec defines the desired state of LinodeCluster
3232
type LinodeClusterSpec struct {
3333
// region the LinodeCluster lives in.
34+
// +required
3435
Region string `json:"region"`
3536

3637
// controlPlaneEndpoint represents the endpoint used to communicate with the LinodeCluster control plane
@@ -102,11 +103,17 @@ type LinodeClusterStatus struct {
102103
// LinodeCluster is the Schema for the linodeclusters API
103104
type LinodeCluster struct {
104105
metav1.TypeMeta `json:",inline"`
106+
105107
// metadata is the standard object's metadata.
108+
// +optional
106109
metav1.ObjectMeta `json:"metadata,omitempty"`
110+
107111
// spec is the desired state of the LinodeCluster.
112+
// +optional
108113
Spec LinodeClusterSpec `json:"spec,omitempty"`
114+
109115
// status is the observed state of the LinodeCluster.
116+
// +optional
110117
Status LinodeClusterStatus `json:"status,omitempty"`
111118
}
112119

@@ -139,56 +146,69 @@ type NetworkSpec struct {
139146
// +kubebuilder:default=NodeBalancer
140147
// +optional
141148
LoadBalancerType string `json:"loadBalancerType,omitempty"`
149+
142150
// dnsProvider is the provider who manages the domain.
143151
// Ignored if the LoadBalancerType is set to anything other than dns
144152
// If not set, defaults linode dns
145153
// +kubebuilder:validation:Enum=linode;akamai
146154
// +optional
147155
DNSProvider string `json:"dnsProvider,omitempty"`
156+
148157
// dnsRootDomain is the root domain used to create a DNS entry for the control-plane endpoint.
149158
// Ignored if the LoadBalancerType is set to anything other than dns
150159
// +optional
151160
DNSRootDomain string `json:"dnsRootDomain,omitempty"`
161+
152162
// dnsUniqueIdentifier is the unique identifier for the DNS. This let clusters with the same name have unique
153163
// DNS record
154164
// Ignored if the LoadBalancerType is set to anything other than dns
155165
// If not set, CAPL will create a unique identifier for you
156166
// +optional
157167
DNSUniqueIdentifier string `json:"dnsUniqueIdentifier,omitempty"`
168+
158169
// dnsTTLsec is the TTL for the domain record
159170
// Ignored if the LoadBalancerType is set to anything other than dns
160171
// If not set, defaults to 30
161172
// +optional
162173
DNSTTLSec int `json:"dnsTTLsec,omitempty"`
174+
163175
// dnsSubDomainOverride is used to override CAPL's construction of the controlplane endpoint
164176
// If set, this will override the DNS subdomain from <clustername>-<uniqueid>.<rootdomain> to <overridevalue>.<rootdomain>
165177
// +optional
166178
DNSSubDomainOverride string `json:"dnsSubDomainOverride,omitempty"`
179+
167180
// apiserverLoadBalancerPort used by the api server. It must be valid ports range (1-65535).
168181
// If omitted, default value is 6443.
169182
// +kubebuilder:validation:Minimum=1
170183
// +kubebuilder:validation:Maximum=65535
171184
// +optional
172185
ApiserverLoadBalancerPort int `json:"apiserverLoadBalancerPort,omitempty"`
186+
173187
// nodeBalancerID is the id of NodeBalancer.
174188
// +optional
175189
NodeBalancerID *int `json:"nodeBalancerID,omitempty"`
190+
176191
// nodeBalancerFirewallID is the id of NodeBalancer Firewall.
177192
// +optional
178193
NodeBalancerFirewallID *int `json:"nodeBalancerFirewallID,omitempty"`
194+
179195
// apiserverNodeBalancerConfigID is the config ID of api server NodeBalancer config.
180196
// +optional
181197
ApiserverNodeBalancerConfigID *int `json:"apiserverNodeBalancerConfigID,omitempty"`
198+
182199
// additionalPorts contains list of ports to be configured with NodeBalancer.
183200
// +optional
184201
AdditionalPorts []LinodeNBPortConfig `json:"additionalPorts,omitempty"`
202+
185203
// subnetName is the name/label of the VPC subnet to be used by the cluster
186204
// +optional
187205
SubnetName string `json:"subnetName,omitempty"`
206+
188207
// useVlan provisions a cluster that uses VLANs instead of VPCs. IPAM is managed internally.
189208
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
190209
// +optional
191210
UseVlan bool `json:"useVlan,omitempty"`
211+
192212
// nodeBalancerBackendIPv4Range is the subnet range we want to provide for creating nodebalancer in VPC.
193213
// example: 10.10.10.0/30
194214
// +optional
@@ -209,7 +229,9 @@ type LinodeNBPortConfig struct {
209229
// port configured on the NodeBalancer. It must be valid port range (1-65535).
210230
// +kubebuilder:validation:Minimum=1
211231
// +kubebuilder:validation:Maximum=65535
232+
// +required
212233
Port int `json:"port"`
234+
213235
// nodeBalancerConfigID is the config ID of port's NodeBalancer config.
214236
// +optional
215237
NodeBalancerConfigID *int `json:"nodeBalancerConfigID,omitempty"`
@@ -222,11 +244,11 @@ type ObjectStore struct {
222244
//
223245
// This is used to generate presigned URLs for S3 Bucket objects, which are used by
224246
// control-plane and worker nodes to fetch bootstrap data.
225-
//
226247
// +optional
227248
PresignedURLDuration *metav1.Duration `json:"presignedURLDuration,omitempty"`
228249

229250
// credentialsRef is a reference to a Secret that contains the credentials to use for accessing the Cluster Object Store.
251+
// +optional
230252
CredentialsRef corev1.SecretReference `json:"credentialsRef,omitempty"`
231253
}
232254

api/v1alpha2/linodeclustertemplate_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import (
2323
// LinodeClusterTemplateSpec defines the desired state of LinodeClusterTemplate
2424
type LinodeClusterTemplateSpec struct {
2525
// template defines the specification for a LinodeCluster.
26+
// +required
2627
Template LinodeClusterTemplateResource `json:"template"`
2728
}
2829

2930
// LinodeClusterTemplateResource describes the data needed to create a LinodeCluster from a template.
3031
type LinodeClusterTemplateResource struct {
3132
// spec is the specification of the LinodeCluster.
33+
// +required
3234
Spec LinodeClusterSpec `json:"spec"`
3335
}
3436

@@ -40,8 +42,11 @@ type LinodeClusterTemplateResource struct {
4042
type LinodeClusterTemplate struct {
4143
metav1.TypeMeta `json:",inline"`
4244
// metadata is the standard object's metadata.
45+
// +optional
4346
metav1.ObjectMeta `json:"metadata,omitempty"`
47+
4448
// spec is the desired state of the LinodeClusterTemplate.
49+
// +optional
4550
Spec LinodeClusterTemplateSpec `json:"spec,omitempty"`
4651
}
4752

api/v1alpha2/linodefirewall_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,15 @@ type LinodeFirewallStatus struct {
135135
type LinodeFirewall struct {
136136
metav1.TypeMeta `json:",inline"`
137137
// metadata is the standard object's metadata.
138+
// +optional
138139
metav1.ObjectMeta `json:"metadata,omitempty"`
140+
139141
// spec is the desired state of the LinodeFirewall.
142+
// +optional
140143
Spec LinodeFirewallSpec `json:"spec,omitempty"`
144+
141145
// status is the observed state of the LinodeFirewall.
146+
// +optional
142147
Status LinodeFirewallStatus `json:"status,omitempty"`
143148
}
144149

0 commit comments

Comments
 (0)