Skip to content

🌱 Improve CC RefVersionsUpToDate condition message #12472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions internal/controllers/clusterclass/clusterclass_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,6 @@ func dropFalsePtrBool(in *clusterv1.JSONSchemaProps) *clusterv1.JSONSchemaProps
return ret
}

func refString(ref *corev1.ObjectReference) string {
return fmt.Sprintf("%s %s/%s", ref.GroupVersionKind().String(), ref.Namespace, ref.Name)
}

func (r *Reconciler) reconcileExternal(ctx context.Context, clusterClass *clusterv1.ClusterClass, ref *corev1.ObjectReference) error {
obj, err := external.Get(ctx, r.Client, ref)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ func setRefVersionsUpToDateCondition(_ context.Context, clusterClass *clusterv1.
}

if len(outdatedRefs) > 0 {
var msg []string
var msg = []string{
"The following templateRefs are not using the latest apiVersion:",
}
for _, outdatedRef := range outdatedRefs {
msg = append(msg, fmt.Sprintf("* templateRef %q should be %q", refString(outdatedRef.Outdated), refString(outdatedRef.UpToDate)))
msg = append(msg, fmt.Sprintf("* %s %s: current: %s, latest: %s", outdatedRef.Outdated.Kind, outdatedRef.Outdated.Name,
outdatedRef.Outdated.GroupVersionKind().Version, outdatedRef.UpToDate.GroupVersionKind().Version))
}
v1beta1conditions.Set(clusterClass,
v1beta1conditions.FalseCondition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ func TestSetRefVersionsUpToDateCondition(t *testing.T) {
Type: clusterv1.ClusterClassRefVersionsUpToDateCondition,
Status: metav1.ConditionFalse,
Reason: clusterv1.ClusterClassRefVersionsNotUpToDateReason,
Message: "* templateRef \"controlplane.cluster.x-k8s.io/v1beta2, Kind=KubeadmControlPlaneTemplate default/test-kcp\" should be " +
"\"controlplane.cluster.x-k8s.io/v99, Kind=KubeadmControlPlaneTemplate default/test-kcp\"\n" +
"* templateRef \"infrastructure.cluster.x-k8s.io/v1beta2, Kind=DockerMachineTemplate default/test-dmt\" should be " +
"\"infrastructure.cluster.x-k8s.io/v99, Kind=DockerMachineTemplate default/test-dmt\"",
Message: "The following templateRefs are not using the latest apiVersion:\n" +
"* KubeadmControlPlaneTemplate test-kcp: current: v1beta2, latest: v99\n" +
"* DockerMachineTemplate test-dmt: current: v1beta2, latest: v99",
},
},
{
Expand Down