feat: static json credentials (#2423)

This commit is contained in:
Damian Debkowski authored and GitHub committed 2022-09-16 15:00:04 -07:00
1 parent 8c53d931aa
commit 546c5dc5be
42 files changed
+3207 -165

No files matched your search

+52 -2
View File
@@ -124,7 +124,7 @@ func PopulateAttributeFlags(c *base.Command, f *base.FlagSet, flagNames map[stri
f.StringVar(&base.StringVar{
Name: "attributes",
Target: &c.FlagAttributes,
Usage: `A JSON map value to use as the entirety of the request's attributes map. Usually this will be sourced from a file via "file://" syntax.`,
Usage: `A JSON map value to use as the entirety of the request's attributes map. Usually this will be sourced from a file via "file://" syntax. Is exclusive with the other attr flags.`,
})
case "attr":
f.CombinationSliceVar(&base.CombinationSliceVar{
@@ -174,7 +174,7 @@ func PopulateSecretFlags(c *base.Command, f *base.FlagSet, flagNames map[string]
f.StringVar(&base.StringVar{
Name: "secrets",
Target: &c.FlagSecrets,
Usage: `A JSON map value to use as the entirety of the request's secrets map. Usually this will be sourced from a file via "file://" syntax.`,
Usage: `A JSON map value to use as the entirety of the request's secrets map. Usually this will be sourced from a file via "file://" syntax. Is exclusive with the other secret flags.`,
})
case "secret":
f.CombinationSliceVar(&base.CombinationSliceVar{
@@ -216,6 +216,56 @@ func PopulateSecretFlags(c *base.Command, f *base.FlagSet, flagNames map[string]
}
}
func PopulateObjectFlags(c *base.Command, f *base.FlagSet, flagNames map[string][]string, command string) {
keyDelimiter := "."
for _, name := range flagNames[command] {
switch name {
case "object":
f.StringVar(&base.StringVar{
Name: "object",
Target: &c.FlagObject,
Usage: `A JSON map value to use as the entirety of the request's object map. Usually this will be sourced from a file via "file://" syntax. Is exclusive with the other kv flags.`,
})
case "kv":
f.CombinationSliceVar(&base.CombinationSliceVar{
Name: "kv",
Target: &c.FlagKv,
KvSplit: true,
KeyDelimiter: &keyDelimiter,
ProtoCompatKey: true,
Usage: `A key=value pair to add to the request's object map. The type is automatically inferred. Use -string-kv, -bool-kv, or -num-kv if the type needs to be overridden. Can be specified multiple times. Supports sourcing values from files via "file://" and env vars via "env://"`,
})
case "string-kv":
f.CombinationSliceVar(&base.CombinationSliceVar{
Name: "string-kv",
Target: &c.FlagKv,
KvSplit: true,
KeyDelimiter: &keyDelimiter,
ProtoCompatKey: true,
Usage: `A key=value string value to add to the request's object map. Can be specified multiple times. Supports sourcing values from files via "file://" and env vars via "env://"`,
})
case "bool-kv":
f.CombinationSliceVar(&base.CombinationSliceVar{
Name: "bool-kv",
Target: &c.FlagKv,
KvSplit: true,
KeyDelimiter: &keyDelimiter,
ProtoCompatKey: true,
Usage: `A key=value bool value to add to the request's object map. Can be specified multiple times. Supports sourcing values from files via "file://" and env vars via "env://"`,
})
case "num-kv":
f.CombinationSliceVar(&base.CombinationSliceVar{
Name: "num-kv",
Target: &c.FlagKv,
KvSplit: true,
KeyDelimiter: &keyDelimiter,
ProtoCompatKey: true,
Usage: `A key=value numeric value to add to the request's object map. Can be specified multiple times. Supports sourcing values from files via "file://" and env vars via "env://"`,
})
}
}
}
// From https://stackoverflow.com/a/13340826, modified to remove exponents
var jsonNumberRegex = regexp.MustCompile(`^-?(?:0|[1-9]\d*)(?:\.\d+)?$`)