Generate new version of SDK resources and Add Tests (#331)

This commit is contained in:
Todd Knight authored and GitHub committed 2020-09-08 16:27:51 -04:00
1 parent 96e4b1cdba
commit c3ecea172d
93 files changed
+3414 -2826

No files matched your search

@@ -37,10 +37,12 @@ func (c *Command) Synopsis() string {
var flagsMap = map[string][]string{
"read": {"id"},
"delete": {"id"},
"list": {"scope-id"},
}
func (c *Command) Help() string {
helpMap := common.HelpMap("auth-method")
var helpStr string
switch c.Func {
case "":
return base.WrapForHelpText([]string{
@@ -55,7 +57,7 @@ func (c *Command) Help() string {
" Please see the auth-methods subcommand help for detailed usage information.",
})
case "create":
return base.WrapForHelpText([]string{
helpStr = base.WrapForHelpText([]string{
"Usage: boundary auth-methods create [type] [sub command] [options] [args]",
"",
" This command allows create operations on Boundary auth-method resources. Example:",
@@ -67,7 +69,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 auth-methods update [type] [sub command] [options] [args]",
"",
" This command allows update operations on Boundary auth-method resources. Example:",
@@ -79,8 +81,9 @@ func (c *Command) Help() string {
" Please see the typed subcommand help for detailed usage information.",
})
default:
return helpMap[c.Func]() + c.Flags().Help()
helpStr = helpMap[c.Func]()
}
return helpStr + c.Flags().Help()
}
func (c *Command) Flags() *base.FlagSets {
@@ -119,6 +122,10 @@ func (c *Command) Run(args []string) int {
c.UI.Error("ID is required but not passed in via -id")
return 1
}
if strutil.StrListContains(flagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
c.UI.Error("Scope ID must be passed in via -scope-id")
return 1
}
client, err := c.Client()
if err != nil {
@@ -157,7 +164,7 @@ func (c *Command) Run(args []string) int {
case "delete":
existed, apiErr, err = authmethodClient.Delete(c.Context, c.FlagId, opts...)
case "list":
listedMethods, apiErr, err = authmethodClient.List(c.Context, opts...)
listedMethods, apiErr, err = authmethodClient.List(c.Context, c.FlagScopeId, opts...)
}
plural := "auth method"
@@ -26,6 +26,7 @@ func generateAuthMethodTableOutput(in *authmethods.AuthMethod) 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),
@@ -32,7 +32,7 @@ func (c *PasswordCommand) Synopsis() string {
}
var passwordFlagsMap = map[string][]string{
"create": {"name", "description"},
"create": {"scope-id", "name", "description"},
"update": {"id", "name", "description", "version"},
}
@@ -102,6 +102,10 @@ func (c *PasswordCommand) Run(args []string) int {
c.UI.Error("ID is required but not passed in via -id")
return 1
}
if strutil.StrListContains(passwordFlagsMap[c.Func], "scope-id") && c.FlagScopeId == "" {
c.UI.Error("Scope ID must be passed in via -scope-id")
return 1
}
client, err := c.Client()
if err != nil {
@@ -174,7 +178,7 @@ func (c *PasswordCommand) Run(args []string) int {
default:
switch c.FlagVersion {
case 0:
opts = append(opts, authmethods.WithAutomaticVersioning())
opts = append(opts, authmethods.WithAutomaticVersioning(true))
default:
version = uint32(c.FlagVersion)
}
@@ -185,7 +189,7 @@ func (c *PasswordCommand) Run(args []string) int {
switch c.Func {
case "create":
method, apiErr, err = authmethodClient.Create(c.Context, "password", opts...)
method, apiErr, err = authmethodClient.Create(c.Context, "password", c.FlagScopeId, opts...)
case "update":
method, apiErr, err = authmethodClient.Update(c.Context, c.FlagId, version, opts...)
}