Change ACL to Access
This commit is contained in:
+5
-6
@@ -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 {
|
||||
|
||||
+22
-22
@@ -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
|
||||
}
|
||||
+11
-11
@@ -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) {
|
||||
|
||||
+2
-2
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user