From e33a754874948fef9e1621fe1858579041384240 Mon Sep 17 00:00:00 2001 From: DiptoChakrabarty Date: Fri, 3 Dec 2021 00:00:25 +0530 Subject: [PATCH 1/3] replace disable echo with echo in clusterctl describe commands --- cmd/clusterctl/client/describe.go | 6 +++--- cmd/clusterctl/client/tree/discovery.go | 2 +- cmd/clusterctl/client/tree/discovery_test.go | 4 ++-- cmd/clusterctl/client/tree/tree.go | 4 ++-- cmd/clusterctl/client/tree/tree_test.go | 2 +- cmd/clusterctl/cmd/describe_cluster.go | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/clusterctl/client/describe.go b/cmd/clusterctl/client/describe.go index d5d7d38f8b16..b744d3251eaf 100644 --- a/cmd/clusterctl/client/describe.go +++ b/cmd/clusterctl/client/describe.go @@ -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 disable hiding 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. @@ -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, }) } diff --git a/cmd/clusterctl/client/tree/discovery.go b/cmd/clusterctl/client/tree/discovery.go index 09f876e9d32b..bc1ad4eb8caa 100644 --- a/cmd/clusterctl/client/tree/discovery.go +++ b/cmd/clusterctl/client/tree/discovery.go @@ -37,7 +37,7 @@ type DiscoverOptions struct { // DisableNoEcho disable hiding 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. diff --git a/cmd/clusterctl/client/tree/discovery_test.go b/cmd/clusterctl/client/tree/discovery_test.go index 5dd63383cf13..58db7f740cbf 100644 --- a/cmd/clusterctl/client/tree/discovery_test.go +++ b/cmd/clusterctl/client/tree/discovery_test.go @@ -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( diff --git a/cmd/clusterctl/client/tree/tree.go b/cmd/clusterctl/client/tree/tree.go index 3e68709698a4..9afd038c2831 100644 --- a/cmd/clusterctl/client/tree/tree.go +++ b/cmd/clusterctl/client/tree/tree.go @@ -41,7 +41,7 @@ type ObjectTreeOptions struct { // DisableNoEcho disables hiding 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 @@ -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 } diff --git a/cmd/clusterctl/client/tree/tree_test.go b/cmd/clusterctl/client/tree/tree_test.go index cb5375375e26..3ef3055a48f3 100644 --- a/cmd/clusterctl/client/tree/tree_test.go +++ b/cmd/clusterctl/client/tree/tree_test.go @@ -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)), diff --git a/cmd/clusterctl/cmd/describe_cluster.go b/cmd/clusterctl/cmd/describe_cluster.go index bf804c4c1f06..2d299be4c720 100644 --- a/cmd/clusterctl/cmd/describe_cluster.go +++ b/cmd/clusterctl/cmd/describe_cluster.go @@ -56,7 +56,7 @@ type describeClusterOptions struct { namespace string showOtherConditions string showMachineSets bool - disableNoEcho bool + echo bool grouping bool disableGrouping bool } @@ -108,7 +108,7 @@ func init() { describeClusterClusterCmd.Flags().BoolVar(&dc.showMachineSets, "show-machinesets", false, "Show MachineSet objects.") - describeClusterClusterCmd.Flags().BoolVar(&dc.disableNoEcho, "disable-no-echo", false, ""+ + describeClusterClusterCmd.Flags().BoolVar(&dc.echo, "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().BoolVar(&dc.grouping, "grouping", true, "Groups machines when ready condition has the same Status, Severity and Reason.") @@ -141,7 +141,7 @@ func runDescribeCluster(name string) error { ClusterName: name, ShowOtherConditions: dc.showOtherConditions, ShowMachineSets: dc.showMachineSets, - DisableNoEcho: dc.disableNoEcho, + Echo: dc.Echo, Grouping: dc.grouping && !dc.disableGrouping, }) if err != nil { From 773a6af31a923979cf61e08d146b4e9d55f80b6b Mon Sep 17 00:00:00 2001 From: DiptoChakrabarty Date: Fri, 3 Dec 2021 22:10:51 +0530 Subject: [PATCH 2/3] modify comment --- cmd/clusterctl/client/describe.go | 2 +- cmd/clusterctl/client/tree/discovery.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/clusterctl/client/describe.go b/cmd/clusterctl/client/describe.go index b744d3251eaf..fa2512797ce9 100644 --- a/cmd/clusterctl/client/describe.go +++ b/cmd/clusterctl/client/describe.go @@ -41,7 +41,7 @@ type DescribeClusterOptions struct { // ShowMachineSets instructs the discovery process to include machine sets in the ObjectTree. ShowMachineSets bool - // Echo 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) Echo bool diff --git a/cmd/clusterctl/client/tree/discovery.go b/cmd/clusterctl/client/tree/discovery.go index bc1ad4eb8caa..f4bba860bf02 100644 --- a/cmd/clusterctl/client/tree/discovery.go +++ b/cmd/clusterctl/client/tree/discovery.go @@ -35,7 +35,7 @@ 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) Echo bool From ae2b0363cb7c3231305fdae3e99edc9e6226ffe4 Mon Sep 17 00:00:00 2001 From: DiptoChakrabarty Date: Sat, 4 Dec 2021 20:57:30 +0530 Subject: [PATCH 3/3] mark disable echo flag as deprecated and modify comment --- cmd/clusterctl/client/tree/tree.go | 2 +- cmd/clusterctl/cmd/describe_cluster.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/clusterctl/client/tree/tree.go b/cmd/clusterctl/client/tree/tree.go index 9afd038c2831..a4a5a4be15b6 100644 --- a/cmd/clusterctl/client/tree/tree.go +++ b/cmd/clusterctl/client/tree/tree.go @@ -39,7 +39,7 @@ 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) Echo bool diff --git a/cmd/clusterctl/cmd/describe_cluster.go b/cmd/clusterctl/cmd/describe_cluster.go index 2d299be4c720..3e23ac6285bd 100644 --- a/cmd/clusterctl/cmd/describe_cluster.go +++ b/cmd/clusterctl/cmd/describe_cluster.go @@ -57,6 +57,7 @@ type describeClusterOptions struct { showOtherConditions string showMachineSets bool echo bool + disableNoEcho bool grouping bool disableGrouping bool } @@ -109,7 +110,11 @@ func init() { "Show MachineSet objects.") describeClusterClusterCmd.Flags().BoolVar(&dc.echo, "echo", false, ""+ + "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, @@ -141,7 +146,7 @@ func runDescribeCluster(name string) error { ClusterName: name, ShowOtherConditions: dc.showOtherConditions, ShowMachineSets: dc.showMachineSets, - Echo: dc.Echo, + Echo: dc.echo || dc.disableNoEcho, Grouping: dc.grouping && !dc.disableGrouping, }) if err != nil {