Skip to content

Commit 0f89bf1

Browse files
committed
Align v1beta2 contract to API conventions around optional fields
1 parent 5f9c050 commit 0f89bf1

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

docs/book/src/developer/providers/contracts/bootstrap-config.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,20 @@ type FooConfigList struct {
199199

200200
### BootstrapConfig: data secret
201201

202-
Each BootstrapConfig MUST store generated bootstrap data into a Kubernetes Secret.
202+
Each BootstrapConfig MUST store generated bootstrap data into a Kubernetes Secret and surface the secret name in .status.dataSecretName.
203+
204+
```go
205+
type FooConfigStatus struct {
206+
// dataSecretName is the name of the secret that stores the bootstrap data script.
207+
// +optional
208+
// +kubebuilder:validation:MinLength=1
209+
// +kubebuilder:validation:MaxLength=253
210+
DataSecretName string `json:"dataSecretName,omitempty"`
211+
212+
// See other rules for more details about mandatory/optional fields in BootstrapConfig status.
213+
// Other fields SHOULD be added based on the needs of your provider.
214+
}
215+
```
203216

204217
The Secret containing bootstrap data must:
205218

@@ -236,7 +249,7 @@ type FooConfigInitializationStatus struct {
236249
// dataSecretCreated is true when the Machine's boostrap secret is created.
237250
// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate initial Machine provisioning.
238251
// +optional
239-
DataSecretCreated bool `json:"dataSecretCreated,omitempty"`
252+
DataSecretCreated *bool `json:"dataSecretCreated,omitempty"`
240253
}
241254
```
242255

docs/book/src/developer/providers/contracts/control-plane.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ type FooControlPlaneSpec struct {
350350
// version defines the desired Kubernetes version for the control plane.
351351
// The value must be a valid semantic version; also if the value provided by the user does not start with the v prefix, it
352352
// must be added.
353+
// +required
354+
// +kubebuilder:validation:MinLength=1
355+
// +kubebuilder:validation:MaxLength=256
353356
Version string `json:"version"`
354357

355358
// See other rules for more details about mandatory/optional fields in ControlPlane spec.
@@ -364,13 +367,17 @@ type FooControlPlaneStatus struct {
364367
// version represents the minimum Kubernetes version for the control plane machines
365368
// in the cluster.
366369
// +optional
367-
Version *string `json:"version,omitempty"`
370+
// +kubebuilder:validation:MinLength=1
371+
// +kubebuilder:validation:MaxLength=256
372+
Version string `json:"version,omitempty"`
368373

369374
// See other rules for more details about mandatory/optional fields in ControlPlane status.
370375
// Other fields SHOULD be added based on the needs of your provider.
371376
}
372377
```
373378

379+
NOTE: To align with API conventions, we recommend since the v1beta2 contract that the `Version` field should be
380+
of type `string` (it was `*string` before). Both are compatible with the v1beta2 contract though.
374381
NOTE: The minimum Kubernetes version, and more specifically the API server version, will be used to determine
375382
when a control plane is fully upgraded (spec.version == status.version) and for enforcing Kubernetes version skew
376383
policies when a Cluster derived from a ClusterClass is managed by the Topology controller.
@@ -480,13 +487,16 @@ managed control plane providers for AKS, EKS, GKE etc), you SHOULD also implemen
480487
type FooControlPlaneStatus struct {
481488
// externalManagedControlPlane is a bool that should be set to true if the Node objects do not exist in the cluster.
482489
// +optional
483-
ExternalManagedControlPlane bool `json:"externalManagedControlPlane,omitempty"`
490+
ExternalManagedControlPlane *bool `json:"externalManagedControlPlane,omitempty"`
484491

485492
// See other rules for more details about mandatory/optional fields in ControlPlane status.
486493
// Other fields SHOULD be added based on the needs of your provider.
487494
}
488495
```
489496

497+
NOTE: To align with API conventions, we recommend since the v1beta2 contract that the `ExternalManagedControlPlane` field should be
498+
of type `*bool` (it was `bool` before). Both are compatible with the v1beta2 contract though.
499+
490500
Please note that by representing each control plane instance as Cluster API machine, each control plane instance
491501
can benefit from several Cluster API behaviours, for example:
492502
- Machine provisioning workflow (in coordination with an InfraMachine and a BootstrapConfig of your choice)
@@ -521,7 +531,7 @@ type FooControlPlaneInitializationStatus struct {
521531
// the control plane is fully provisioned or not.
522532
// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate initial Cluster provisioning.
523533
// +optional
524-
ControlPlaneInitialized bool `json:"controlPlaneInitialized,omitempty"`
534+
ControlPlaneInitialized *bool `json:"controlPlaneInitialized,omitempty"`
525535
}
526536
```
527537

docs/book/src/developer/providers/contracts/infra-cluster.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ type FooClusterStatus struct {
265265

266266
`FailureDomain` is defined as:
267267
- `name string`: the name of the failure domain (must be unique)
268-
- `controlPlane bool`: indicates if failure domain is appropriate for running control plane instances.
268+
- `controlPlane *bool`: indicates if failure domain is appropriate for running control plane instances.
269269
- `attributes map[string]string`: arbitrary attributes for users to apply to a failure domain.
270270

271271
Once `status.failureDomains` is set on the InfraCluster resource and the [InfraCluster initialization completed],
@@ -307,7 +307,7 @@ type FooClusterInitializationStatus struct {
307307
// provisioned is true when the infrastructure provider reports that the Cluster's infrastructure is fully provisioned.
308308
// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate initial Cluster provisioning.
309309
// +optional
310-
Provisioned bool `json:"provisioned,omitempty"`
310+
Provisioned *bool `json:"provisioned,omitempty"`
311311
}
312312
```
313313

docs/book/src/developer/providers/contracts/infra-machine.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,17 @@ type FooMachineSpec struct {
210210
// For Kubernetes Nodes running on the Foo provider, this value is set by the corresponding CPI component
211211
// and it has the format docker:////<vm-name>.
212212
// +optional
213-
ProviderID *string `json:"providerID,omitempty"`
213+
// +kubebuilder:validation:MinLength=1
214+
// +kubebuilder:validation:MaxLength=512
215+
ProviderID string `json:"providerID,omitempty"`
214216

215217
// See other rules for more details about mandatory/optional fields in InfraMachine spec.
216218
// Other fields SHOULD be added based on the needs of your provider.
217219
}
218220
```
219221

222+
NOTE: To align with API conventions, we recommend since the v1beta2 contract that the `ProviderID` field should be
223+
of type `string` (it was `*string` before). Both are compatible with the v1beta2 contract though.
220224
Once `spec.providerID` is set on the InfraMachine resource and the [InfraMachine initialization completed],
221225
the Cluster controller will surface this info in Machine's `spec.providerID`.
222226

@@ -248,7 +252,10 @@ new corresponding field (also in status).
248252
type FooMachineStatus struct {
249253
// failureDomain is the unique identifier of the failure domain where this Machine has been placed in.
250254
// For this Foo infrastructure provider, the name is equivalent to the name of one of the available regions.
251-
FailureDomain *string `json:"failureDomain,omitempty"`
255+
// +optional
256+
// +kubebuilder:validation:MinLength=1
257+
// +kubebuilder:validation:MaxLength=256
258+
FailureDomain string `json:"failureDomain,omitempty"`
252259

253260
// See other rules for more details about mandatory/optional fields in InfraMachineStatus.
254261
// Other fields SHOULD be added based on the needs of your provider.
@@ -301,7 +308,7 @@ type FooMachineInitializationStatus struct {
301308
// provisioned is true when the infrastructure provider reports that the Machine's infrastructure is fully provisioned.
302309
// NOTE: this field is part of the Cluster API contract, and it is used to orchestrate initial Machine provisioning.
303310
// +optional
304-
Provisioned bool `json:"provisioned,omitempty"`
311+
Provisioned *bool `json:"provisioned,omitempty"`
305312
}
306313
```
307314

0 commit comments

Comments
 (0)