Generate new version of SDK resources and Add Tests (#331)
This commit is contained in:
1 parent
96e4b1cdba
commit
c3ecea172d
93 files changed
+3414
-2826
No files matched your search
@@ -13,6 +13,7 @@ func generateHostSetTableOutput(in *hostsets.HostSet) string {
|
||||
|
||||
nonAttributeMap := map[string]interface{}{
|
||||
"ID": in.Id,
|
||||
"Scope ID": in.Scope.Id,
|
||||
"Version": in.Version,
|
||||
"Type": in.Type,
|
||||
"Created Time": in.CreatedTime.Local().Format(time.RFC3339),
|
||||
@@ -55,23 +56,15 @@ func generateHostSetTableOutput(in *hostsets.HostSet) string {
|
||||
)
|
||||
|
||||
if len(in.HostIds) > 0 {
|
||||
if true {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Host IDs:"),
|
||||
)
|
||||
}
|
||||
ret = append(ret,
|
||||
" Host IDs:",
|
||||
base.WrapSlice(4, in.HostIds),
|
||||
)
|
||||
}
|
||||
|
||||
if len(in.Attributes) > 0 {
|
||||
if true {
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Attributes: %s", ""),
|
||||
)
|
||||
}
|
||||
ret = append(ret,
|
||||
fmt.Sprintf(" Attributes: %s", ""),
|
||||
base.WrapMap(4, maxLength, in.Attributes),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ func (c *Command) Synopsis() string {
|
||||
var flagsMap = map[string][]string{
|
||||
"read": {"id"},
|
||||
"delete": {"id"},
|
||||
"list": {"host-catalog-id"},
|
||||
"add-hosts": {"id", "host", "version"},
|
||||
"set-hosts": {"id", "host", "version"},
|
||||
"remove-hosts": {"id", "host", "version"},
|
||||
@@ -53,6 +54,7 @@ var flagsMap = map[string][]string{
|
||||
|
||||
func (c *Command) Help() string {
|
||||
helpMap := common.HelpMap("host-set")
|
||||
var helpStr string
|
||||
switch c.Func {
|
||||
case "":
|
||||
return base.WrapForHelpText([]string{
|
||||
@@ -67,7 +69,7 @@ func (c *Command) Help() string {
|
||||
" Please see the host-sets subcommand help for detailed usage information.",
|
||||
})
|
||||
case "create":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets create [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows create operations on Boundary host-set resources. Example:",
|
||||
@@ -79,7 +81,7 @@ func (c *Command) Help() string {
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "update":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets update [type] [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows update operations on Boundary host-set resources. Example:",
|
||||
@@ -91,7 +93,7 @@ func (c *Command) Help() string {
|
||||
" Please see the typed subcommand help for detailed usage information.",
|
||||
})
|
||||
case "add-hosts":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets add-hosts [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows adding hosts to host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
|
||||
@@ -101,7 +103,7 @@ func (c *Command) Help() string {
|
||||
` $ boundary host-sets add-hosts -id hsst_1234567890 -host hst_1234567890 -host hst_0987654321`,
|
||||
})
|
||||
case "remove-hosts":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets remove-hosts [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows removing hosts from host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
|
||||
@@ -111,7 +113,7 @@ func (c *Command) Help() string {
|
||||
` $ boundary host-sets remove-hosts -id hsst_1234567890 -host hst_0987654321`,
|
||||
})
|
||||
case "set-hosts":
|
||||
return base.WrapForHelpText([]string{
|
||||
helpStr = base.WrapForHelpText([]string{
|
||||
"Usage: boundary host-sets set-hosts [sub command] [options] [args]",
|
||||
"",
|
||||
" This command allows setting the complete set of hosts on host-set resources, if the types match and the operation is allowed by the given host-set type. Example:",
|
||||
@@ -121,8 +123,9 @@ func (c *Command) Help() string {
|
||||
` $ boundary host-sets remove-hosts -id hsst_1234567890 -host hst_1234567890`,
|
||||
})
|
||||
default:
|
||||
return helpMap[c.Func]() + c.Flags().Help()
|
||||
helpStr = helpMap[c.Func]()
|
||||
}
|
||||
return helpStr + c.Flags().Help()
|
||||
}
|
||||
|
||||
func (c *Command) Flags() *base.FlagSets {
|
||||
@@ -134,14 +137,14 @@ func (c *Command) Flags() *base.FlagSets {
|
||||
common.PopulateCommonFlags(c.Command, f, resource.HostSet.String(), flagsMap[c.Func])
|
||||
}
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host-set resource",
|
||||
})
|
||||
|
||||
for _, name := range flagsMap[c.Func] {
|
||||
switch name {
|
||||
case "host-catalog-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host-set resource",
|
||||
})
|
||||
case "host":
|
||||
f.StringSliceVar(&base.StringSliceVar{
|
||||
Name: "host",
|
||||
@@ -174,11 +177,14 @@ func (c *Command) Run(args []string) int {
|
||||
c.UI.Error(err.Error())
|
||||
return 1
|
||||
}
|
||||
|
||||
if strutil.StrListContains(flagsMap[c.Func], "id") && c.FlagId == "" {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
if strutil.StrListContains(flagsMap[c.Func], "host-catalog-id") && c.flagHostCatalogId == "" {
|
||||
c.UI.Error("Host Catalog ID must be passed in via -host-catalog-id")
|
||||
return 1
|
||||
}
|
||||
|
||||
client, err := c.Client()
|
||||
if err != nil {
|
||||
@@ -232,7 +238,7 @@ func (c *Command) Run(args []string) int {
|
||||
case "add-hosts", "remove-hosts", "set-hosts":
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, hostsets.WithAutomaticVersioning())
|
||||
opts = append(opts, hostsets.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -250,17 +256,17 @@ func (c *Command) Run(args []string) int {
|
||||
|
||||
switch c.Func {
|
||||
case "read":
|
||||
set, apiErr, err = hostsetClient.Read(c.Context, c.flagHostCatalogId, c.FlagId, opts...)
|
||||
set, apiErr, err = hostsetClient.Read(c.Context, c.FlagId, opts...)
|
||||
case "delete":
|
||||
existed, apiErr, err = hostsetClient.Delete(c.Context, c.flagHostCatalogId, c.FlagId, opts...)
|
||||
existed, apiErr, err = hostsetClient.Delete(c.Context, c.FlagId, opts...)
|
||||
case "list":
|
||||
listedSets, apiErr, err = hostsetClient.List(c.Context, c.flagHostCatalogId, opts...)
|
||||
case "add-hosts":
|
||||
set, apiErr, err = hostsetClient.AddHosts(c.Context, c.flagHostCatalogId, c.FlagId, version, c.flagHosts, opts...)
|
||||
set, apiErr, err = hostsetClient.AddHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
|
||||
case "remove-hosts":
|
||||
set, apiErr, err = hostsetClient.RemoveHosts(c.Context, c.flagHostCatalogId, c.FlagId, version, c.flagHosts, opts...)
|
||||
set, apiErr, err = hostsetClient.RemoveHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
|
||||
case "set-hosts":
|
||||
set, apiErr, err = hostsetClient.SetHosts(c.Context, c.flagHostCatalogId, c.FlagId, version, c.flagHosts, opts...)
|
||||
set, apiErr, err = hostsetClient.SetHosts(c.Context, c.FlagId, version, c.flagHosts, opts...)
|
||||
}
|
||||
|
||||
plural := "host set"
|
||||
|
||||
@@ -30,7 +30,7 @@ func (c *StaticCommand) Synopsis() string {
|
||||
}
|
||||
|
||||
var staticFlagsMap = map[string][]string{
|
||||
"create": {"name", "description"},
|
||||
"create": {"host-catalog-id", "name", "description"},
|
||||
"update": {"id", "name", "description", "version"},
|
||||
}
|
||||
|
||||
@@ -71,11 +71,16 @@ func (c *StaticCommand) Flags() *base.FlagSets {
|
||||
common.PopulateCommonFlags(c.Command, f, "static-type host-set", staticFlagsMap[c.Func])
|
||||
}
|
||||
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host-set resource",
|
||||
})
|
||||
for _, name := range staticFlagsMap[c.Func] {
|
||||
switch name {
|
||||
case "host-catalog-id":
|
||||
f.StringVar(&base.StringVar{
|
||||
Name: "host-catalog-id",
|
||||
Target: &c.flagHostCatalogId,
|
||||
Usage: "The host-catalog resource in which to create or update the host-set resource",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return set
|
||||
}
|
||||
@@ -104,8 +109,7 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
c.UI.Error("ID is required but not passed in via -id")
|
||||
return 1
|
||||
}
|
||||
|
||||
if c.flagHostCatalogId == "" {
|
||||
if strutil.StrListContains(staticFlagsMap[c.Func], "host-catalog-id") && c.flagHostCatalogId == "" {
|
||||
c.UI.Error("Host Catalog ID must be passed in via -host-catalog-id")
|
||||
return 1
|
||||
}
|
||||
@@ -144,7 +148,7 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
default:
|
||||
switch c.FlagVersion {
|
||||
case 0:
|
||||
opts = append(opts, hostsets.WithAutomaticVersioning())
|
||||
opts = append(opts, hostsets.WithAutomaticVersioning(true))
|
||||
default:
|
||||
version = uint32(c.FlagVersion)
|
||||
}
|
||||
@@ -157,7 +161,7 @@ func (c *StaticCommand) Run(args []string) int {
|
||||
case "create":
|
||||
set, apiErr, err = hostsetClient.Create(c.Context, c.flagHostCatalogId, opts...)
|
||||
case "update":
|
||||
set, apiErr, err = hostsetClient.Update(c.Context, c.flagHostCatalogId, c.FlagId, version, opts...)
|
||||
set, apiErr, err = hostsetClient.Update(c.Context, c.FlagId, version, opts...)
|
||||
}
|
||||
|
||||
plural := "static-type host-set"
|
||||
|
||||
Reference in new issue
Block a user