Skip to content

Commit

Permalink
clusterctl describe show Cluster conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Oct 17, 2021
1 parent d2a110e commit ac92fdf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/clusterctl/client/tree/discovery.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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())

Expand Down
7 changes: 7 additions & 0 deletions cmd/clusterctl/client/tree/tree.go
Expand Up @@ -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,
Expand Down

0 comments on commit ac92fdf

Please sign in to comment.