Skip to content

Commit 9661ea3

Browse files
authored
Merge pull request #7259 from sbueringer/pr-cc-outdated-condition
🌱 ClusterClass: add condition for references with outdated apiVersions
2 parents c0a247b + c14e9fc commit 9661ea3

File tree

9 files changed

+238
-16
lines changed

9 files changed

+238
-16
lines changed

api/v1alpha4/conversion.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ func (src *ClusterClass) ConvertTo(dstRaw conversion.Hub) error {
125125
dst.Spec.Workers.MachineDeployments[i].MachineHealthCheck = restored.Spec.Workers.MachineDeployments[i].MachineHealthCheck
126126
}
127127

128+
dst.Status = restored.Status
129+
128130
return nil
129131
}
130132

@@ -352,3 +354,8 @@ func Convert_v1beta1_MachineStatus_To_v1alpha4_MachineStatus(in *clusterv1.Machi
352354
// MachineStatus.CertificatesExpiryDate has been added in v1beta1.
353355
return autoConvert_v1beta1_MachineStatus_To_v1alpha4_MachineStatus(in, out, s)
354356
}
357+
358+
func Convert_v1beta1_ClusterClass_To_v1alpha4_ClusterClass(in *clusterv1.ClusterClass, out *ClusterClass, s apiconversion.Scope) error {
359+
// ClusterClass.Status has been added in v1beta1.
360+
return autoConvert_v1beta1_ClusterClass_To_v1alpha4_ClusterClass(in, out, s)
361+
}

api/v1alpha4/zz_generated.conversion.go

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

api/v1beta1/clusterclass_types.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ import (
2828
// +kubebuilder:object:root=true
2929
// +kubebuilder:resource:path=clusterclasses,shortName=cc,scope=Namespaced,categories=cluster-api
3030
// +kubebuilder:storageversion
31+
// +kubebuilder:subresource:status
3132
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of ClusterClass"
3233

3334
// ClusterClass is a template which can be used to create managed topologies.
3435
type ClusterClass struct {
3536
metav1.TypeMeta `json:",inline"`
3637
metav1.ObjectMeta `json:"metadata,omitempty"`
3738

38-
Spec ClusterClassSpec `json:"spec,omitempty"`
39+
Spec ClusterClassSpec `json:"spec,omitempty"`
40+
Status ClusterClassStatus `json:"status,omitempty"`
3941
}
4042

4143
// ClusterClassSpec describes the desired state of the ClusterClass.
@@ -475,6 +477,27 @@ type LocalObjectTemplate struct {
475477
Ref *corev1.ObjectReference `json:"ref"`
476478
}
477479

480+
// ANCHOR: ClusterClassStatus
481+
482+
// ClusterClassStatus defines the observed state of the ClusterClass.
483+
type ClusterClassStatus struct {
484+
// Conditions defines current observed state of the ClusterClass.
485+
// +optional
486+
Conditions Conditions `json:"conditions,omitempty"`
487+
}
488+
489+
// GetConditions returns the set of conditions for this object.
490+
func (c *ClusterClass) GetConditions() Conditions {
491+
return c.Status.Conditions
492+
}
493+
494+
// SetConditions sets the conditions on this object.
495+
func (c *ClusterClass) SetConditions(conditions Conditions) {
496+
c.Status.Conditions = conditions
497+
}
498+
499+
// ANCHOR_END: ClusterClassStatus
500+
478501
// +kubebuilder:object:root=true
479502

480503
// ClusterClassList contains a list of Cluster.

api/v1beta1/condition_consts.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,3 +282,16 @@ const (
282282
// not yet completed because at least one of the lifecycle hooks is blocking.
283283
TopologyReconciledHookBlockingReason = "LifecycleHookBlocking"
284284
)
285+
286+
// Conditions and condition reasons for ClusterClass.
287+
const (
288+
// ClusterClassRefVersionsUpToDateCondition documents if the references in the ClusterClass are
289+
// up-to-date (i.e. they are using the latest apiVersion of the current Cluster API contract from
290+
// the corresponding CRD).
291+
ClusterClassRefVersionsUpToDateCondition ConditionType = "RefVersionsUpToDate"
292+
293+
// ClusterClassOutdatedRefVersionsReason (Severity=Warning) that the references in the ClusterClass are not
294+
// up-to-date (i.e. they are not using the latest apiVersion of the current Cluster API contract from
295+
// the corresponding CRD).
296+
ClusterClassOutdatedRefVersionsReason = "OutdatedRefVersions"
297+
)

api/v1beta1/zz_generated.deepcopy.go

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

api/v1beta1/zz_generated.openapi.go

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

Lines changed: 51 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/rbac/role.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@ rules:
8181
- patch
8282
- update
8383
- watch
84+
- apiGroups:
85+
- cluster.x-k8s.io
86+
resources:
87+
- clusterclasses
88+
- clusterclasses/status
89+
verbs:
90+
- get
91+
- list
92+
- patch
93+
- update
94+
- watch
8495
- apiGroups:
8596
- cluster.x-k8s.io
8697
resources:

0 commit comments

Comments
 (0)