Skip to content

Commit cc90a46

Browse files
committed
cmd: update api-resources
1 parent 9d4ff40 commit cc90a46

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

cmd/cli/api_resources.go

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var apiResourcesCmd = &cobra.Command{
2626
resources := []res{
2727
{Name: "applications", ShortNames: "app,apps", APIVersion: v1.APIVersion, Managed: true, Kind: "Application"},
2828
{Name: "components", ShortNames: "comp,comps", APIVersion: v1.APIVersion, Managed: true, Kind: "Component"},
29-
{Name: "virtualmachines", ShortNames: "vm,vms", APIVersion: v1.APIVersion, Managed: false, Kind: "VirtualMachine"},
29+
{Name: "virtualmachines", ShortNames: "vm,vms", APIVersion: v1.APIVersion, Managed: true, Kind: "VirtualMachine"},
3030
{Name: "virtualmachinespecs", ShortNames: "vmspec,vmspecs", APIVersion: v1.APIVersion, Managed: true, Kind: "VirtualMachineSpec"},
3131
{Name: "networks", ShortNames: "net,nets,network,networks", APIVersion: v1.APIVersion, Managed: false, Kind: "Network"},
3232
{Name: "volumes", ShortNames: "vol,vols,volume,volumes", APIVersion: v1.APIVersion, Managed: false, Kind: "Volume"},
@@ -37,11 +37,41 @@ var apiResourcesCmd = &cobra.Command{
3737
}
3838

3939
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
40-
fmt.Fprintln(w, "NAME\tSHORTNAMES\tAPIVERSION\tManaged\tKIND")
40+
fmt.Fprintln(w, "NAME\tSHORTNAMES\tAPIVERSION\tManaged\tSupported\tKIND")
4141

4242
for _, r := range resources {
43-
fmt.Fprintf(w, "%s\t%s\t%s\t%t\t%s\n",
44-
r.Name, r.ShortNames, r.APIVersion, r.Managed, r.Kind)
43+
supported := true
44+
if standalone {
45+
// In standalone mode, controller-managed resources are not supported
46+
// except VirtualMachine which is supported in both modes.
47+
switch r.Kind {
48+
case "VirtualMachine":
49+
supported = true
50+
case "Application", "Component", "VirtualMachineSpec":
51+
supported = false
52+
default:
53+
supported = true
54+
}
55+
}
56+
var suppStr string
57+
if supported {
58+
suppStr = "yes"
59+
} else {
60+
suppStr = "no"
61+
}
62+
63+
// Managed column: show boolean in controller mode, "n/a" in standalone mode
64+
var managedStr string
65+
if standalone {
66+
managedStr = "n/a"
67+
} else if r.Managed {
68+
managedStr = "yes"
69+
} else {
70+
managedStr = "no"
71+
}
72+
73+
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\t%s\n",
74+
r.Name, r.ShortNames, r.APIVersion, managedStr, suppStr, r.Kind)
4575
}
4676

4777
w.Flush()

0 commit comments

Comments
 (0)