fix: honour -o json/custom across missing and broken commands#586
fix: honour -o json/custom across missing and broken commands#586alubbock wants to merge 8 commits into
Conversation
…fig and network show
| ow.AppendDataWithLabel("status", network.Status, "Status") | ||
| ow.AppendDataWithLabel("ipv4_enabled", utility.BoolToYesNo(network.IPv4Enabled), "IPv4 Enabled") | ||
| ow.AppendDataWithLabel("ipv6_enabled", utility.BoolToYesNo(network.IPv6Enabled), "IPv6 Enabled") | ||
| ow.AppendDataWithLabel("vlan_id", fmt.Sprintf("%d", network.VlanID), "VLAN ID") |
There was a problem hiding this comment.
The fields vlan_id, physical_interface, allocation_pool_v4_start and allocation_pool_v4_end should only be displayed if the network is VLAN-enabled.
This way, vlan_id is shown in the JSON output as "vlan_id":"0", whereas the other fields are silently dropped because they're empty. I would add a guard here to prevent vlan_id from appearing in the JSON output as it's happening in the human formatting.
There was a problem hiding this comment.
Also a minor nitpick, we're using strconv.Itoa(network.VlanID) in network_list.go, we should probably stick to that for consistency.
| fmt.Println("\nVLAN Details:") | ||
| fmt.Printf("VLAN ID: %d\n", network.VlanID) | ||
| fmt.Printf("Hardware Address: %s\n", network.PhysicalInterface) | ||
| fmt.Printf("Gateway IPv4: %s\n", network.GatewayIPv4) |
There was a problem hiding this comment.
This is actually a pre-existing "bug" we could solve here: we can show the gateway IP even for non-VLAN networks, so this can be moved outside the guard.
| utility.Error("%s", err) | ||
| os.Exit(1) | ||
| } | ||
| fmt.Println("Instance ID is: ", instance.ID) |
There was a problem hiding this comment.
By removing this line, the human-form output no longer shows the UUID of the instance, but only the hostname. Consider adding it (between parentheses?) in the human-form output, next to the hostname
Several commands ignored the
-o jsonand-o customflags, alwaysprinting plain text regardless. One command (
kubernetes cluster remove)had a latent bug where
-o jsonalso triggered the custom formatter.Missing output format handling (always printed plain text):
kubernetes node-pool instance-deletekubernetes cluster remove(also hadWriteCustomOutputinside the"json"case, so-o jsonproduced both outputs)apikey remove/apikey setinstance public-ip/instance recoverykubernetes update-kubeconfignetwork showAlso fixed in
instance recovery: afmt.Println("Instance ID is: …")that fired before the API call, unconditionally, on everyinvocation.