-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Extend tsh clusters
output with "Cluster Type" and "Selected" columns
#5051
Conversation
Its purpose is to indicate the user's selected cluster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious what others think, but I wonder why you opted for a more complicated approach with splitting the proxy GetAllClusters into 2 methods, rather than just keeping the API as-is and comparing each cluster name with the name of the root cluster.
Something like:
rootClusterName, err := proxyClient.RootClusterName()
// handle err
sort.Slice(clusters, func(i, j int) bool { clusters[i].GetName() == rootClusterName })
for _, cluster := range clusters {
kind := "root"
if cluster.GetName() != rootClusterName {
kind = "leaf"
}
t.AddRow(...)
}
Think the implementation would be a bit simpler/cleaner and proxy client interface wouldn't need to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the GetLeafClusters
over GetAllClusters
, so that we don't have to pretend like the local (root) cluster is a services.RemoteCluster
.
But maybe remove GetRootCluster
, and call proxyClient.RootClusterName
directly in tsh.
Wrapping root cluster in a services.RemoteCluster
feels like we're fighting the type system for the sake of some code de-duplication in tsh.
My thought process was basically the following:
I originally contemplated an option to retain |
@awly Note that To avoid the impression that we're fighting the type system we could perhaps just abstract away those methods of |
The connection status and last heartbeat are set to constant values and we're not likely to change that (if you're talking to the root cluster, it's obviously online and last seen at the time of request). |
6c5922c
to
2c43a3f
Compare
6aad190
to
f0339c7
Compare
f0339c7
to
c20fb56
Compare
tsh clusters
output with "Cluster Type" and "Active" columnstsh clusters
output with "Cluster Type" and "Selected" columns
Fixes #4965, implementing the output format proposed therein. The additional columns are printed by default, it didn't seem necessary to introduce a
-v
flag.