Skip to content
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

🌱 clusterctl describe show Cluster conditions #5437

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
7 changes: 7 additions & 0 deletions cmd/clusterctl/client/tree/discovery.go
Original file line number Diff line number Diff line change
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
6 changes: 6 additions & 0 deletions cmd/clusterctl/client/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ 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