diff --git a/access-main.go b/access-main.go index 7e5901b4..ddf5d3b1 100644 --- a/access-main.go +++ b/access-main.go @@ -65,7 +65,7 @@ EXAMPLES: type AccessMessage struct { Status string `json:"status"` Bucket string `json:"bucket"` - Perms bucketPerms `json:"permission"` + Perms accessPerms `json:"permission"` } func (s AccessMessage) String() string { @@ -85,8 +85,8 @@ func checkAccessSyntax(ctx *cli.Context) { if len(ctx.Args()) < 2 { cli.ShowCommandHelpAndExit(ctx, "access", 1) // last argument is exit code } - perms := bucketPerms(ctx.Args().First()) - if !perms.isValidBucketPERM() { + perms := accessPerms(ctx.Args().First()) + if !perms.isValidAccessPERM() { fatalIf(errDummy().Trace(), "Unrecognized permission ‘"+perms.String()+"’. Allowed values are [private, public, readonly].") } @@ -104,8 +104,7 @@ func mainAccess(ctx *cli.Context) { "Access": color.New(color.FgGreen, color.Bold), }) - perms := bucketPerms(ctx.Args().First()) - + perms := accessPerms(ctx.Args().First()) config := mustGetMcConfig() for _, arg := range ctx.Args().Tail() { targetURL, err := getCanonicalizedURL(arg, config.Aliases) @@ -121,7 +120,7 @@ func mainAccess(ctx *cli.Context) { } } -func doUpdateAccessCmd(targetURL string, targetPERMS bucketPerms) *probe.Error { +func doUpdateAccessCmd(targetURL string, targetPERMS accessPerms) *probe.Error { var clnt client.Client clnt, err := target2Client(targetURL) if err != nil { diff --git a/access-perms.go b/access.go similarity index 59% rename from access-perms.go rename to access.go index 96cddd2e..cc4a4c85 100644 --- a/access-perms.go +++ b/access.go @@ -18,8 +18,8 @@ package main import "github.com/minio/minio/pkg/probe" -// isValidBucketPERM - is provided acl string supported -func (b bucketPerms) isValidBucketPERM() bool { +// isValidAccessPERM - is provided acl string supported +func (b accessPerms) isValidAccessPERM() bool { switch true { case b.isPrivate(): fallthrough @@ -34,19 +34,19 @@ func (b bucketPerms) isValidBucketPERM() bool { } } -// bucketPerms - bucket level access control -type bucketPerms string +// accessPerms - access level access control +type accessPerms string -// different types of ACL's currently supported for buckets +// different types of ACL's currently supported for accesss const ( - bucketPrivate = bucketPerms("private") - bucketReadOnly = bucketPerms("readonly") - bucketPublic = bucketPerms("public") - bucketAuthenticated = bucketPerms("authenticated") + accessPrivate = accessPerms("private") + accessReadOnly = accessPerms("readonly") + accessPublic = accessPerms("public") + accessAuthenticated = accessPerms("authenticated") ) -func (b bucketPerms) String() string { - if !b.isValidBucketPERM() { +func (b accessPerms) String() string { + if !b.isValidAccessPERM() { return string(b) } if b.isReadOnly() { @@ -62,30 +62,30 @@ func (b bucketPerms) String() string { } // IsPrivate - is acl Private -func (b bucketPerms) isPrivate() bool { - return b == bucketPrivate +func (b accessPerms) isPrivate() bool { + return b == accessPrivate } // IsPublicRead - is acl PublicRead -func (b bucketPerms) isReadOnly() bool { - return b == bucketReadOnly +func (b accessPerms) isReadOnly() bool { + return b == accessReadOnly } // IsPublicReadWrite - is acl PublicReadWrite -func (b bucketPerms) isPublic() bool { - return b == bucketPublic +func (b accessPerms) isPublic() bool { + return b == accessPublic } // IsAuthenticated - is acl AuthenticatedRead -func (b bucketPerms) isAuthenticated() bool { - return b == bucketAuthenticated +func (b accessPerms) isAuthenticated() bool { + return b == accessAuthenticated } -// getConfigACL - read ACL from config -func getConfigACL() (acl string, err *probe.Error) { +// getDefaultAccess - read ACL from config +func getDefaultAccess() (acl string, err *probe.Error) { config, err := getMcConfig() if err != nil { return "", err.Trace() } - return config.ACL, nil + return config.Access, nil } diff --git a/cmd_test.go b/cmd_test.go index 0acfcd57..389d19d5 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -114,8 +114,8 @@ func (s *CmdTestSuite) TestNewConfigV2(c *C) { perr = config.Load(configFile) c.Assert(perr, IsNil) data := config.Data().(*configV3) + c.Assert(data.Access, Equals, "private") - c.Assert(data.ACL, Equals, "private") type aliases struct { name string url string @@ -184,23 +184,23 @@ func (s *CmdTestSuite) TestArgs2URL(c *C) { } func (s *CmdTestSuite) TestValidPERMS(c *C) { - perms := bucketPerms("private") - c.Assert(perms.isValidBucketPERM(), Equals, true) + perms := accessPerms("private") + c.Assert(perms.isValidAccessPERM(), Equals, true) c.Assert(perms.String(), Equals, "private") - perms = bucketPerms("public") - c.Assert(perms.isValidBucketPERM(), Equals, true) + perms = accessPerms("public") + c.Assert(perms.isValidAccessPERM(), Equals, true) c.Assert(perms.String(), Equals, "public-read-write") - perms = bucketPerms("readonly") - c.Assert(perms.isValidBucketPERM(), Equals, true) + perms = accessPerms("readonly") + c.Assert(perms.isValidAccessPERM(), Equals, true) c.Assert(perms.String(), Equals, "public-read") - perms = bucketPerms("authenticated") - c.Assert(perms.isValidBucketPERM(), Equals, true) + perms = accessPerms("authenticated") + c.Assert(perms.isValidAccessPERM(), Equals, true) c.Assert(perms.String(), Equals, "authenticated-read") } func (s *CmdTestSuite) TestInvalidPERMS(c *C) { - perms := bucketPerms("invalid") - c.Assert(perms.isValidBucketPERM(), Equals, false) + perms := accessPerms("invalid") + c.Assert(perms.isValidAccessPERM(), Equals, false) } func (s *CmdTestSuite) TestGetMcConfigDir(c *C) { diff --git a/common-methods.go b/common-methods.go index a5b1f19f..32b54415 100644 --- a/common-methods.go +++ b/common-methods.go @@ -157,11 +157,11 @@ func getNewClient(urlStr string, auth hostConfig) (client.Client, *probe.Error) s3Config.AppVersion = globalMCVersion s3Config.AppComments = []string{os.Args[0], runtime.GOOS, runtime.GOARCH} s3Config.HostURL = urlStr - acl, err := getConfigACL() + access, err := getDefaultAccess() if err != nil { return nil, err.Trace() } - s3Config.ACL = acl + s3Config.ACL = accessPerms(access).String() s3Config.Debug = globalDebugFlag s3Client, err := s3.New(s3Config) if err != nil { diff --git a/config.go b/config.go index 7fd6d48c..5fa65823 100644 --- a/config.go +++ b/config.go @@ -36,7 +36,7 @@ type configV2 struct { type configV3 struct { Version string - ACL string + Access string Aliases map[string]string Hosts map[string]hostConfig } @@ -265,7 +265,7 @@ func migrateConfigV2ToV3() { confV3.Aliases = mcConfigV2.Data().(*configV2).Aliases confV3.Hosts = mcConfigV2.Data().(*configV2).Hosts confV3.Version = globalMCConfigVersion - confV3.ACL = "private" + confV3.Access = "private" mcNewConfigV3, err := quick.New(confV3) fatalIf(err.Trace(), "Unable to initialize quick config.") @@ -355,7 +355,7 @@ func newConfigV3() *configV3 { aliases["dl"] = "https://dl.minio.io:9000" aliases["localhost"] = "http://localhost:9000" conf.Aliases = aliases - conf.ACL = "private" + conf.Access = "private" return conf }