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

🌱 Replace disable-echo option with echo option in clusterctl describe #5787

Merged
merged 3 commits into from
Dec 8, 2021
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
6 changes: 3 additions & 3 deletions cmd/clusterctl/client/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ type DescribeClusterOptions struct {
// ShowMachineSets instructs the discovery process to include machine sets in the ObjectTree.
ShowMachineSets bool

// DisableNoEcho disable hiding MachineInfrastructure or BootstrapConfig objects if the object's ready condition is true
// Echo displays MachineInfrastructure or BootstrapConfig objects if the object's ready condition is true
// or it has the same Status, Severity and Reason of the parent's object ready condition (it is an echo)
DisableNoEcho bool
Echo bool

// Grouping groups machines objects in case the ready conditions
// have the same Status, Severity and Reason.
Expand Down Expand Up @@ -82,7 +82,7 @@ func (c *clusterctlClient) DescribeCluster(options DescribeClusterOptions) (*tre
return tree.Discovery(context.TODO(), client, options.Namespace, options.ClusterName, tree.DiscoverOptions{
ShowOtherConditions: options.ShowOtherConditions,
ShowMachineSets: options.ShowMachineSets,
DisableNoEcho: options.DisableNoEcho,
Echo: options.Echo,
Grouping: options.Grouping,
})
}
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/tree/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type DiscoverOptions struct {
// ShowMachineSets instructs the discovery process to include machine sets in the ObjectTree.
ShowMachineSets bool

// DisableNoEcho disable hiding MachineInfrastructure or BootstrapConfig objects if the object's ready condition is true
// Echo displays MachineInfrastructure or BootstrapConfig objects if the object's ready condition is true
// or it has the same Status, Severity and Reason of the parent's object ready condition (it is an echo)
DisableNoEcho bool
Echo bool

// Grouping groups machine objects in case the ready conditions
// have the same Status, Severity and Reason.
Expand Down
4 changes: 2 additions & 2 deletions cmd/clusterctl/client/tree/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ func Test_Discovery(t *testing.T) {
name: "Discovery with grouping and no-echo disabled",
args: args{
discoverOptions: DiscoverOptions{
Grouping: false,
DisableNoEcho: true,
Grouping: false,
Echo: true,
},
objs: test.NewFakeCluster("ns1", "cluster1").
WithControlPlane(
Expand Down
6 changes: 3 additions & 3 deletions cmd/clusterctl/client/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ type ObjectTreeOptions struct {
// ShowMachineSets instructs the discovery process to include machine sets in the ObjectTree.
ShowMachineSets bool

// DisableNoEcho disables hiding objects if the object's ready condition has the
// Echo displays objects if the object's ready condition has the
// same Status, Severity and Reason of the parent's object ready condition (it is an echo)
DisableNoEcho bool
Echo bool

// Grouping groups sibling object in case the ready conditions
// have the same Status, Severity and Reason
Expand Down Expand Up @@ -92,7 +92,7 @@ func (od ObjectTree) Add(parent, obj client.Object, opts ...AddObjectOption) (ad
// If the object should be hidden if the object's ready condition is true ot it has the
// same Status, Severity and Reason of the parent's object ready condition (it is an echo),
// return early.
if addOpts.NoEcho && !od.options.DisableNoEcho {
if addOpts.NoEcho && !od.options.Echo {
if (objReady != nil && objReady.Status == corev1.ConditionTrue) || hasSameReadyStatusSeverityAndReason(parentReady, objReady) {
return false, false
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/clusterctl/client/tree/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func Test_Add_NoEcho(t *testing.T) {
{
name: "should add if NoEcho option is present, objects have same ReadyCondition, but NoEcho is disabled",
args: args{
treeOptions: ObjectTreeOptions{DisableNoEcho: true},
treeOptions: ObjectTreeOptions{Echo: true},
addOptions: []AddObjectOption{NoEcho(true)},
obj: fakeMachine("my-machine",
withMachineCondition(conditions.TrueCondition(clusterv1.ReadyCondition)),
Expand Down
7 changes: 6 additions & 1 deletion cmd/clusterctl/cmd/describe_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type describeClusterOptions struct {
namespace string
showOtherConditions string
showMachineSets bool
echo bool
fabriziopandini marked this conversation as resolved.
Show resolved Hide resolved
disableNoEcho bool
grouping bool
disableGrouping bool
Expand Down Expand Up @@ -108,8 +109,12 @@ func init() {
describeClusterClusterCmd.Flags().BoolVar(&dc.showMachineSets, "show-machinesets", false,
"Show MachineSet objects.")

describeClusterClusterCmd.Flags().BoolVar(&dc.echo, "echo", false, ""+
fabriziopandini marked this conversation as resolved.
Show resolved Hide resolved
"Show MachineInfrastructure and BootstrapConfig when ready condition is true or it has the Status, Severity and Reason of the machine's object.")
describeClusterClusterCmd.Flags().BoolVar(&dc.disableNoEcho, "disable-no-echo", false, ""+
"Disable hiding of a MachineInfrastructure and BootstrapConfig when ready condition is true or it has the Status, Severity and Reason of the machine's object.")
_ = describeClusterClusterCmd.Flags().MarkDeprecated("disable-no-echo",
"use --echo instead.")
describeClusterClusterCmd.Flags().BoolVar(&dc.grouping, "grouping", true,
"Groups machines when ready condition has the same Status, Severity and Reason.")
describeClusterClusterCmd.Flags().BoolVar(&dc.disableGrouping, "disable-grouping", false,
Expand Down Expand Up @@ -141,7 +146,7 @@ func runDescribeCluster(name string) error {
ClusterName: name,
ShowOtherConditions: dc.showOtherConditions,
ShowMachineSets: dc.showMachineSets,
DisableNoEcho: dc.disableNoEcho,
Echo: dc.echo || dc.disableNoEcho,
Grouping: dc.grouping && !dc.disableGrouping,
})
if err != nil {
Expand Down