Skip to content

Commit

Permalink
ClusterClass: add condition for references with outdated apiVersions
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Büringer [email protected]
  • Loading branch information
sbueringer committed Sep 21, 2022
1 parent cdc2977 commit 7157169
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 16 deletions.
7 changes: 7 additions & 0 deletions api/v1alpha4/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func (src *ClusterClass) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Workers.MachineDeployments[i].MachineHealthCheck = restored.Spec.Workers.MachineDeployments[i].MachineHealthCheck
}

dst.Status = restored.Status

return nil
}

Expand Down Expand Up @@ -339,3 +341,8 @@ func Convert_v1beta1_MachineStatus_To_v1alpha4_MachineStatus(in *clusterv1.Machi
// MachineStatus.CertificatesExpiryDate has been added in v1beta1.
return autoConvert_v1beta1_MachineStatus_To_v1alpha4_MachineStatus(in, out, s)
}

func Convert_v1beta1_ClusterClass_To_v1alpha4_ClusterClass(in *clusterv1.ClusterClass, out *ClusterClass, s apiconversion.Scope) error {
// ClusterClass.Status has been added in v1beta1.
return autoConvert_v1beta1_ClusterClass_To_v1alpha4_ClusterClass(in, out, s)
}
16 changes: 6 additions & 10 deletions api/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 24 additions & 1 deletion api/v1beta1/clusterclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ import (
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=clusterclasses,shortName=cc,scope=Namespaced,categories=cluster-api
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="Time duration since creation of ClusterClass"

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

Spec ClusterClassSpec `json:"spec,omitempty"`
Spec ClusterClassSpec `json:"spec,omitempty"`
Status ClusterClassStatus `json:"status,omitempty"`
}

// ClusterClassSpec describes the desired state of the ClusterClass.
Expand Down Expand Up @@ -468,6 +470,27 @@ type LocalObjectTemplate struct {
Ref *corev1.ObjectReference `json:"ref"`
}

// ANCHOR: ClusterClassStatus

// ClusterClassStatus defines the observed state of the ClusterClass.
type ClusterClassStatus struct {
// Conditions defines current observed state of the ClusterClass.
// +optional
Conditions Conditions `json:"conditions,omitempty"`
}

// GetConditions returns the set of conditions for this object.
func (c *ClusterClass) GetConditions() Conditions {
return c.Status.Conditions
}

// SetConditions sets the conditions on this object.
func (c *ClusterClass) SetConditions(conditions Conditions) {
c.Status.Conditions = conditions
}

// ANCHOR_END: ClusterClassStatus

// +kubebuilder:object:root=true

// ClusterClassList contains a list of Cluster.
Expand Down
12 changes: 12 additions & 0 deletions api/v1beta1/condition_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,15 @@ const (
// not yet completed because at least one of the lifecycle hooks is blocking.
TopologyReconciledHookBlockingReason = "LifecycleHookBlocking"
)

// Conditions amd condition reasons for ClusterClass.
const (
// ClusterClassValidationSucceededCondition documents if the validation of the ClusterClass
// succeeded.
ClusterClassValidationSucceededCondition ConditionType = "ClusterClassValidationSucceeded"

// ClusterClassOutdatedAPIVersionsInReferencesReason (Severity=Warning) documents that
// the ClusterClass contains references which are not using the latest apiVersion
// (according to the labels on the corresponding CRDs).
ClusterClassOutdatedAPIVersionsInReferencesReason = "OutdatedAPIVersionsInReferences"
)
23 changes: 23 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 37 additions & 1 deletion api/v1beta1/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 51 additions & 1 deletion config/crd/bases/cluster.x-k8s.io_clusterclasses.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ rules:
- patch
- update
- watch
- apiGroups:
- cluster.x-k8s.io
resources:
- clusterclasses
- clusterclasses/status
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
- cluster.x-k8s.io
resources:
Expand Down
Loading

0 comments on commit 7157169

Please sign in to comment.