diff --git a/cmd/clusterctl/client/tree/discovery.go b/cmd/clusterctl/client/tree/discovery.go index 50d6638bb0fa..c90f18680495 100644 --- a/cmd/clusterctl/client/tree/discovery.go +++ b/cmd/clusterctl/client/tree/discovery.go @@ -19,6 +19,7 @@ package tree import ( "context" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" "sigs.k8s.io/cluster-api/controllers/external" "sigs.k8s.io/cluster-api/util" @@ -56,6 +57,12 @@ func Discovery(ctx context.Context, c client.Client, namespace, name string, opt return nil, err } + // Enforce TypeMeta to make sure checks on GVK works properly. + cluster.TypeMeta = metav1.TypeMeta{ + Kind: "Cluster", + APIVersion: clusterv1.GroupVersion.String(), + } + // Create an object tree with the cluster as root tree := NewObjectTree(cluster, options.toObjectTreeOptions()) diff --git a/cmd/clusterctl/client/tree/tree.go b/cmd/clusterctl/client/tree/tree.go index f6b8d66e329f..af201ffe042a 100644 --- a/cmd/clusterctl/client/tree/tree.go +++ b/cmd/clusterctl/client/tree/tree.go @@ -55,6 +55,13 @@ type ObjectTree struct { // NewObjectTree creates a new object tree with the given root and options. func NewObjectTree(root client.Object, options ObjectTreeOptions) *ObjectTree { + + // If it is requested to show all the conditions for the root, add + // the ShowObjectConditionsAnnotation to signal this to the presentation layer. + if isObjDebug(root, options.ShowOtherConditions) { + addAnnotation(root, ShowObjectConditionsAnnotation, "True") + } + return &ObjectTree{ root: root, options: options,