forked from TrueCloudLab/frostfs-node
[#528] cli: Define keyword constants for predefined basic ACL values
Define constants for `public`/`private`/`readonly` keywords of predefined basic ACL values. Use constants instead of repeating string literals. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
eb26f92678
commit
8f9e7c2a63
1 changed files with 15 additions and 8 deletions
|
@ -32,6 +32,13 @@ const (
|
||||||
awaitTimeout = 120 // in seconds
|
awaitTimeout = 120 // in seconds
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// keywords of predefined basic ACL values
|
||||||
|
const (
|
||||||
|
basicACLPrivate = "private"
|
||||||
|
basicACLReadOnly = "readonly"
|
||||||
|
basicACLPublic = "public"
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
containerOwner string
|
containerOwner string
|
||||||
|
|
||||||
|
@ -509,8 +516,8 @@ func init() {
|
||||||
listContainersCmd.Flags().StringVar(&containerOwner, "owner", "", "owner of containers (omit to use owner from private key)")
|
listContainersCmd.Flags().StringVar(&containerOwner, "owner", "", "owner of containers (omit to use owner from private key)")
|
||||||
|
|
||||||
// container create
|
// container create
|
||||||
createContainerCmd.Flags().StringVar(&containerACL, "basic-acl", "private",
|
createContainerCmd.Flags().StringVar(&containerACL, "basic-acl", basicACLPrivate,
|
||||||
"hex encoded basic ACL value or keywords 'public', 'private', 'readonly'")
|
fmt.Sprintf("hex encoded basic ACL value or keywords '%s', '%s', '%s'", basicACLPublic, basicACLPrivate, basicACLReadOnly))
|
||||||
createContainerCmd.Flags().StringVarP(&containerPolicy, "policy", "p", "",
|
createContainerCmd.Flags().StringVarP(&containerPolicy, "policy", "p", "",
|
||||||
"QL-encoded or JSON-encoded placement policy or path to file with it")
|
"QL-encoded or JSON-encoded placement policy or path to file with it")
|
||||||
createContainerCmd.Flags().StringSliceVarP(&containerAttributes, "attributes", "a", nil,
|
createContainerCmd.Flags().StringSliceVarP(&containerAttributes, "attributes", "a", nil,
|
||||||
|
@ -615,11 +622,11 @@ func parseAttributes(attributes []string) ([]*container.Attribute, error) {
|
||||||
|
|
||||||
func parseBasicACL(basicACL string) (uint32, error) {
|
func parseBasicACL(basicACL string) (uint32, error) {
|
||||||
switch basicACL {
|
switch basicACL {
|
||||||
case "public":
|
case basicACLPublic:
|
||||||
return acl.PublicBasicRule, nil
|
return acl.PublicBasicRule, nil
|
||||||
case "private":
|
case basicACLPrivate:
|
||||||
return acl.PrivateBasicRule, nil
|
return acl.PrivateBasicRule, nil
|
||||||
case "readonly":
|
case basicACLReadOnly:
|
||||||
return acl.ReadOnlyBasicRule, nil
|
return acl.ReadOnlyBasicRule, nil
|
||||||
default:
|
default:
|
||||||
basicACL = strings.Trim(strings.ToLower(basicACL), "0x")
|
basicACL = strings.Trim(strings.ToLower(basicACL), "0x")
|
||||||
|
@ -692,11 +699,11 @@ func prettyPrintContainer(cnr *container.Container, jsonEncoding bool) {
|
||||||
fmt.Printf("basic ACL: %s", strconv.FormatUint(uint64(basicACL), 16))
|
fmt.Printf("basic ACL: %s", strconv.FormatUint(uint64(basicACL), 16))
|
||||||
switch basicACL {
|
switch basicACL {
|
||||||
case acl.PublicBasicRule:
|
case acl.PublicBasicRule:
|
||||||
fmt.Println(" (public)")
|
fmt.Printf(" (%s)\n", basicACLPublic)
|
||||||
case acl.PrivateBasicRule:
|
case acl.PrivateBasicRule:
|
||||||
fmt.Println(" (private)")
|
fmt.Printf(" (%s)\n", basicACLPrivate)
|
||||||
case acl.ReadOnlyBasicRule:
|
case acl.ReadOnlyBasicRule:
|
||||||
fmt.Println(" (readonly)")
|
fmt.Printf(" (%s)\n", basicACLReadOnly)
|
||||||
default:
|
default:
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue