Fix some old logic in some CLI commands (#357)

This commit is contained in:
Jeff Mitchell authored and GitHub committed 2020-09-14 12:45:56 -04:00
1 parent 6201357902
commit 1b2f73d1d4
4 files changed
+27 -36

No files matched your search

+5 -6
View File
@@ -135,15 +135,14 @@ func (c *Command) Run(args []string) int {
case "set-members":
switch len(c.flagMembers) {
case 0:
case 1:
if c.flagMembers[0] == "null" {
members = []string{}
}
}
if members == nil {
c.UI.Error("No members supplied via -member")
return 1
case 1:
if c.flagMembers[0] == "null" {
members = nil
}
}
}
groupClient := groups.NewClient(client)
+7 -9
View File
@@ -218,14 +218,12 @@ func (c *Command) Run(args []string) int {
case "set-hosts":
switch len(c.flagHosts) {
case 0:
case 1:
if c.flagHosts[0] == "null" {
hosts = []string{}
}
}
if hosts == nil {
c.UI.Error("No hosts supplied via -host")
return 1
case 1:
if c.flagHosts[0] == "null" {
hosts = nil
}
}
}
@@ -259,11 +257,11 @@ func (c *Command) Run(args []string) int {
case "list":
listedSets, apiErr, err = hostsetClient.List(c.Context, c.flagHostCatalogId, opts...)
case "add-hosts":
set, apiErr, err = hostsetClient.AddHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
set, apiErr, err = hostsetClient.AddHosts(c.Context, c.FlagId, version, hosts, opts...)
case "remove-hosts":
set, apiErr, err = hostsetClient.RemoveHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
set, apiErr, err = hostsetClient.RemoveHosts(c.Context, c.FlagId, version, hosts, opts...)
case "set-hosts":
set, apiErr, err = hostsetClient.SetHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
set, apiErr, err = hostsetClient.SetHosts(c.Context, c.FlagId, version, hosts, opts...)
}
plural := "host set"
+8 -12
View File
@@ -160,27 +160,23 @@ func (c *Command) Run(args []string) int {
case "set-principals":
switch len(c.flagPrincipals) {
case 0:
case 1:
if c.flagPrincipals[0] == "null" {
principals = []string{}
}
}
if principals == nil {
c.UI.Error("No principals supplied via -principal")
return 1
case 1:
if c.flagPrincipals[0] == "null" {
principals = nil
}
}
case "set-grants":
switch len(c.flagGrants) {
case 0:
case 1:
if c.flagGrants[0] == "null" {
grants = []string{}
}
}
if grants == nil {
c.UI.Error("No grants supplied via -grant")
return 1
case 1:
if c.flagGrants[0] == "null" {
grants = nil
}
}
}
+7 -9
View File
@@ -212,14 +212,12 @@ func (c *Command) Run(args []string) int {
case "set-host-sets":
switch len(c.flagHostSets) {
case 0:
case 1:
if c.flagHostSets[0] == "null" {
hostSets = []string{}
}
}
if hostSets == nil {
c.UI.Error("No host-sets supplied via -host-set")
return 1
case 1:
if c.flagHostSets[0] == "null" {
hostSets = nil
}
}
}
@@ -253,11 +251,11 @@ func (c *Command) Run(args []string) int {
case "list":
listedCatalogs, apiErr, err = targetClient.List(c.Context, c.FlagScopeId, opts...)
case "add-host-sets":
target, apiErr, err = targetClient.AddHostSets(c.Context, c.FlagId, version, c.flagHostSets, opts...)
target, apiErr, err = targetClient.AddHostSets(c.Context, c.FlagId, version, hostSets, opts...)
case "remove-host-sets":
target, apiErr, err = targetClient.RemoveHostSets(c.Context, c.FlagId, version, c.flagHostSets, opts...)
target, apiErr, err = targetClient.RemoveHostSets(c.Context, c.FlagId, version, hostSets, opts...)
case "set-host-sets":
target, apiErr, err = targetClient.SetHostSets(c.Context, c.FlagId, version, c.flagHostSets, opts...)
target, apiErr, err = targetClient.SetHostSets(c.Context, c.FlagId, version, hostSets, opts...)
}
plural := "target"