Skip to content

Commit 9311747

Browse files
committed
experiment
1 parent a54621c commit 9311747

File tree

48 files changed

+940
-283
lines changed

Some content is hidden

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

48 files changed

+940
-283
lines changed

.golangci-kal.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ linters:
4343
isFirstField: Warn # Require conditions to be the first field in the status struct.
4444
usePatchStrategy: Forbid # Require conditions to be the first field in the status struct.
4545
useProtobuf: Forbid # We don't use protobuf, so protobuf tags are not required.
46-
# jsonTags:
47-
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
48-
# optionalOrRequired:
49-
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
50-
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
5146
optionalFields:
5247
pointers:
53-
preference: Always # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
48+
preference: WhenRequired # Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
5449
policy: SuggestFix # SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
5550
omitempty:
5651
policy: SuggestFix # SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
52+
# jsonTags:
53+
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
54+
# optionalOrRequired:
55+
# preferredOptionalMarker: optional | kubebuilder:validation:Optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
56+
# preferredRequiredMarker: required | kubebuilder:validation:Required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.
5757
# requiredFields:
5858
# pointerPolicy: Warn | SuggestFix # Defaults to `SuggestFix`. We want our required fields to not be pointers.
5959

@@ -78,7 +78,7 @@ linters:
7878
text: "Conditions field must be a slice of metav1.Condition"
7979
linters:
8080
- kubeapilinter
81-
- path: "api/addons/v1beta1/*|api/bootstrap/kubeadm/v1beta1/*|api/controlplane/kubeadm/v1beta1/*|api/core/v1beta1/*|api/ipam/v1beta1/*|api/ipam/v1alpha1/*|api/runtime/v1alpha1/*"
81+
- path: "api/addons/v1beta1/*|api/bootstrap/kubeadm/v1beta1/*|api/controlplane/kubeadm/v1beta1/*|api/core/v1beta1/*|api/ipam/v1beta1/*|api/ipam/v1alpha1/*|api/runtime/v1alpha1/*|cmd/clusterctl/api/v1alpha3/*"
8282
text: "optionalfields"
8383
linters:
8484
- kubeapilinter
@@ -155,6 +155,25 @@ linters:
155155
text: "field Ref is marked as required, should not be a pointer"
156156
linters:
157157
- kubeapilinter
158+
159+
## TODO: optional required tasks.
160+
# Move up
161+
# Audit the entire hook types + builtins from a serialization point of view (this is not a CRD)
162+
- path: "api/runtime/hooks/v1alpha1/*"
163+
text: "optionalfields"
164+
linters:
165+
- kubeapilinter
166+
# FailureMessage will be removed when v1beta1 is removed
167+
- path: "api/*"
168+
text: "field FailureMessage is optional and does not allow the zero value"
169+
linters:
170+
- kubeapilinter
171+
# Take a closer look
172+
- path: ".*"
173+
text: "field Spec|Status is optional"
174+
linters:
175+
- kubeapilinter
176+
158177
issues:
159178
max-same-issues: 0
160179
max-issues-per-linter: 0

api/addons/v1beta2/clusterresourceset_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ type ClusterResourceSetStatus struct {
129129

130130
// observedGeneration reflects the generation of the most recently observed ClusterResourceSet.
131131
// +optional
132+
// +kubebuilder:validation:Minimum=1
132133
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
133134

134135
// deprecated groups all the status fields that are deprecated and will be removed when all the nested field are removed.

api/bootstrap/kubeadm/v1beta1/conversion.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2323
apimachineryconversion "k8s.io/apimachinery/pkg/conversion"
24+
"k8s.io/utils/ptr"
2425
"sigs.k8s.io/controller-runtime/pkg/conversion"
2526

2627
bootstrapv1 "sigs.k8s.io/cluster-api/api/bootstrap/kubeadm/v1beta2"
@@ -195,7 +196,7 @@ func Convert_v1beta2_KubeadmConfigStatus_To_v1beta1_KubeadmConfigStatus(in *boot
195196

196197
// Move initialization to old fields
197198
if in.Initialization != nil {
198-
out.Ready = in.Initialization.DataSecretCreated
199+
out.Ready = ptr.Deref(in.Initialization.DataSecretCreated, false)
199200
}
200201

201202
// Move new conditions (v1beta2) to the v1beta2 field.
@@ -299,7 +300,7 @@ func Convert_v1beta1_KubeadmConfigStatus_To_v1beta2_KubeadmConfigStatus(in *Kube
299300
if out.Initialization == nil {
300301
out.Initialization = &bootstrapv1.KubeadmConfigInitializationStatus{}
301302
}
302-
out.Initialization.DataSecretCreated = in.Ready
303+
out.Initialization.DataSecretCreated = ptr.To(in.Ready)
303304
}
304305
return nil
305306
}

0 commit comments

Comments
 (0)