Skip to content

Commit b26829f

Browse files
committed
chore: migrate to new CAPI contract (#30)
1 parent 9b0c521 commit b26829f

5 files changed

Lines changed: 34 additions & 4 deletions

File tree

api/v1alpha1/hostedcontrolplane_types.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
//+kubebuilder:resource:path=hostedcontrolplanes,scope=Namespaced,categories=cluster-api,shortName=hcp
1818
//+kubebuilder:subresource:status
1919
//+kubebuilder:storageversion
20-
//+kubebuilder:printcolumn:name="Initialized",type=boolean,JSONPath=`.status.initialized`
20+
//+kubebuilder:printcolumn:name="Initialized",type=boolean,JSONPath=`.status.initialization.controlPlaneInitialized`
2121
//+kubebuilder:printcolumn:name="API Server Available",type=string,JSONPath=`.status.conditions[?(@.type == "Ready")].status`
2222
//+kubebuilder:printcolumn:name="Replicas",type=integer,JSONPath=`.spec.replicas`
2323
//+kubebuilder:printcolumn:name="Ready",type=integer,JSONPath=`.status.readyReplicas`
@@ -243,6 +243,8 @@ type HostedControlPlaneStatus struct {
243243
//+kubebuilder:validation:Optional
244244
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
245245
//+kubebuilder:validation:Optional
246+
UpToDateReplicas int32 `json:"upToDateReplicas,omitempty"`
247+
//+kubebuilder:validation:Optional
246248
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
247249
//+kubebuilder:validation:Optional
248250
UnavailableReplicas int32 `json:"unavailableReplicas,omitempty"`
@@ -251,14 +253,19 @@ type HostedControlPlaneStatus struct {
251253
// https://cluster-api.sigs.k8s.io/developer/providers/contracts/control-plane
252254

253255
//+kubebuilder:validation:Optional
254-
Initialized bool `json:"initialized"`
256+
Initialization HostedControlPlaneInitializationStatus `json:"initialization,omitempty"`
255257
//+kubebuilder:validation:Optional
256258
Ready bool `json:"ready"`
257259
//+kubebuilder:validation:Optional
258260
Version string `json:"version,omitempty"`
259261
ExternalManagedControlPlane *bool `json:"externalManagedControlPlane"`
260262
}
261263

264+
type HostedControlPlaneInitializationStatus struct {
265+
//+kubebuilder:validation:Optional
266+
ControlPlaneInitialized *bool `json:"controlPlaneInitialized,omitempty"`
267+
}
268+
262269
//+kubebuilder:object:root=true
263270

264271
type HostedControlPlaneList struct {

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/hostedcontrolplane/lifecycle_phases_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ func TestHostedControlPlane_FullLifecycle(t *testing.T) {
13921392
return condition.Type != capiv2.PausedCondition && condition.Status != metav1.ConditionTrue
13931393
})).To(BeEmpty())
13941394
g.Expect(hcp.Status.Ready).To(BeTrue())
1395-
g.Expect(hcp.Status.Initialized).To(BeTrue())
1395+
g.Expect(hcp.Status.Initialization.ControlPlaneInitialized).To(PointTo(BeTrue()))
13961396

13971397
// Check that major conditions exist
13981398
majorConditions := []string{

pkg/reconcilers/apiserverresources/apiserverresources.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ func (arr *apiServerResourcesReconciler) reconcileAPIServerDeployment(
409409
hostedControlPlane.Status.UnavailableReplicas = deployment.Status.UnavailableReplicas
410410
hostedControlPlane.Status.ReadyReplicas = deployment.Status.ReadyReplicas
411411
hostedControlPlane.Status.UpdatedReplicas = deployment.Status.UpdatedReplicas
412+
hostedControlPlane.Status.UpToDateReplicas = deployment.Status.UpdatedReplicas
412413
return ready, nil
413414
}
414415
},

pkg/reconcilers/workload/reconciler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020
bootstrapapi "k8s.io/cluster-bootstrap/token/api"
2121
konstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
22+
"k8s.io/utils/ptr"
2223
capiv2 "sigs.k8s.io/cluster-api/api/core/v1beta2"
2324
"sigs.k8s.io/cluster-api/util/conditions"
2425
)
@@ -266,7 +267,7 @@ func (wr *workloadClusterReconciler) ReconcileWorkloadClusterResources(
266267
}
267268
}
268269

269-
hostedControlPlane.Status.Initialized = true
270+
hostedControlPlane.Status.Initialization.ControlPlaneInitialized = ptr.To(true)
270271

271272
return "", nil
272273
},

0 commit comments

Comments
 (0)