diff --git a/cmd/neofs-cli/modules/container.go b/cmd/neofs-cli/modules/container.go index 8e8b70e15..62e40e925 100644 --- a/cmd/neofs-cli/modules/container.go +++ b/cmd/neofs-cli/modules/container.go @@ -38,8 +38,26 @@ const ( basicACLPrivate = "private" basicACLReadOnly = "public-read" basicACLPublic = "public-read-write" + basicACLAppend = "public-append" + + basicACLNoFinalPrivate = "eacl-private" + basicACLNoFinalReadOnly = "eacl-public-read" + basicACLNoFinalPublic = "eacl-public-read-write" + basicACLNoFinalAppend = "eacl-public-append" ) +var wellKnownBasicACL = map[string]uint32{ + basicACLPublic: acl.PublicBasicRule, + basicACLPrivate: acl.PrivateBasicRule, + basicACLReadOnly: acl.ReadOnlyBasicRule, + basicACLAppend: acl.PublicAppendRule, + + basicACLNoFinalPublic: acl.EACLPublicBasicRule, + basicACLNoFinalPrivate: acl.EACLPrivateBasicRule, + basicACLNoFinalReadOnly: acl.EACLReadOnlyBasicRule, + basicACLNoFinalAppend: acl.EACLPublicAppendRule, +} + const sessionTokenFlag = "session" // path to a file with encoded session token @@ -440,7 +458,7 @@ func initContainerCreateCmd() { flags := createContainerCmd.Flags() - flags.StringVar(&containerACL, "basic-acl", basicACLPrivate, fmt.Sprintf("hex encoded basic ACL value or keywords '%s', '%s', '%s'", basicACLPublic, basicACLPrivate, basicACLReadOnly)) + flags.StringVar(&containerACL, "basic-acl", basicACLPrivate, fmt.Sprintf("hex encoded basic ACL value or keywords like '%s', '%s', '%s'", basicACLPublic, basicACLPrivate, basicACLNoFinalReadOnly)) flags.StringVarP(&containerPolicy, "policy", "p", "", "QL-encoded or JSON-encoded placement policy or path to file with it") flags.StringSliceVarP(&containerAttributes, "attributes", "a", nil, "comma separated pairs of container attributes in form of Key1=Value1,Key2=Value2") flags.StringVarP(&containerNonce, "nonce", "n", "", "UUIDv4 nonce value for container") @@ -651,23 +669,18 @@ func parseAttributes(attributes []string) ([]*container.Attribute, error) { } func parseBasicACL(basicACL string) (uint32, error) { - switch basicACL { - case basicACLPublic: - return acl.PublicBasicRule, nil - case basicACLPrivate: - return acl.PrivateBasicRule, nil - case basicACLReadOnly: - return acl.ReadOnlyBasicRule, nil - default: - basicACL = strings.Trim(strings.ToLower(basicACL), "0x") - - value, err := strconv.ParseUint(basicACL, 16, 32) - if err != nil { - return 0, fmt.Errorf("can't parse basic ACL: %s", basicACL) - } - - return uint32(value), nil + if value, ok := wellKnownBasicACL[basicACL]; ok { + return value, nil } + + basicACL = strings.Trim(strings.ToLower(basicACL), "0x") + + value, err := strconv.ParseUint(basicACL, 16, 32) + if err != nil { + return 0, fmt.Errorf("can't parse basic ACL: %s", basicACL) + } + + return uint32(value), nil } func parseNonce(nonce string) (uuid.UUID, error) { @@ -731,17 +744,7 @@ func prettyPrintContainer(cmd *cobra.Command, cnr *container.Container, jsonEnco cmd.Println("owner ID:", cnr.OwnerID()) basicACL := cnr.BasicACL() - cmd.Printf("basic ACL: %s", strconv.FormatUint(uint64(basicACL), 16)) - switch basicACL { - case acl.PublicBasicRule: - cmd.Printf(" (%s)\n", basicACLPublic) - case acl.PrivateBasicRule: - cmd.Printf(" (%s)\n", basicACLPrivate) - case acl.ReadOnlyBasicRule: - cmd.Printf(" (%s)\n", basicACLReadOnly) - default: - cmd.Println() - } + prettyPrintBasicACL(cmd, basicACL) for _, attribute := range cnr.Attributes() { if attribute.Key() == container.AttributeTimestamp { @@ -821,3 +824,14 @@ func printJSONMarshaler(cmd *cobra.Command, j json.Marshaler, entity string) { } cmd.Println(buf) } + +func prettyPrintBasicACL(cmd *cobra.Command, basicACL uint32) { + cmd.Printf("basic ACL: %.8x", basicACL) + for k, v := range wellKnownBasicACL { + if v == basicACL { + cmd.Printf(" (%s)\n", k) + return + } + } + cmd.Println() +} diff --git a/go.mod b/go.mod index 604139095..d07b44bc0 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/nspcc-dev/hrw v1.0.9 github.com/nspcc-dev/neo-go v0.98.0 github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 - github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211228125935-3edaf9ecb644 + github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211230072947-1fe37df88f80 github.com/nspcc-dev/tzhash v1.4.0 github.com/panjf2000/ants/v2 v2.4.0 github.com/paulmach/orb v0.2.2 diff --git a/go.sum b/go.sum index 3fb24a141..91b8f1d15 100644 Binary files a/go.sum and b/go.sum differ