From 64288d6eb53cc134a1f85851dcaf7dee76fecca6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 16 May 2018 16:17:00 -0700 Subject: [PATCH] fix: export policy.Resource for remote RPC policy updates (#5941) This PR fixes a regression where the remote bucket policies were not updated due to policy.Resource not having exported fields, gob fails with unexported fields while marshalling. --- pkg/policy/resource.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/policy/resource.go b/pkg/policy/resource.go index ed17d806f..1e029b745 100644 --- a/pkg/policy/resource.go +++ b/pkg/policy/resource.go @@ -29,26 +29,26 @@ const ResourceARNPrefix = "arn:aws:s3:::" // Resource - resource in policy statement. type Resource struct { - bucketName string - pattern string + BucketName string + Pattern string } func (r Resource) isBucketPattern() bool { - return !strings.Contains(r.pattern, "/") + return !strings.Contains(r.Pattern, "/") } func (r Resource) isObjectPattern() bool { - return strings.Contains(r.pattern, "/") || strings.Contains(r.bucketName, "*") + return strings.Contains(r.Pattern, "/") || strings.Contains(r.BucketName, "*") } // IsValid - checks whether Resource is valid or not. func (r Resource) IsValid() bool { - return r.bucketName != "" && r.pattern != "" + return r.BucketName != "" && r.Pattern != "" } // Match - matches object name with resource pattern. func (r Resource) Match(resource string) bool { - return wildcard.Match(r.pattern, resource) + return wildcard.Match(r.Pattern, resource) } // MarshalJSON - encodes Resource to JSON data. @@ -61,7 +61,7 @@ func (r Resource) MarshalJSON() ([]byte, error) { } func (r Resource) String() string { - return ResourceARNPrefix + r.pattern + return ResourceARNPrefix + r.Pattern } // UnmarshalJSON - decodes JSON data to Resource. @@ -87,7 +87,7 @@ func (r Resource) Validate(bucketName string) error { return fmt.Errorf("invalid resource") } - if !wildcard.Match(r.bucketName, bucketName) { + if !wildcard.Match(r.BucketName, bucketName) { return fmt.Errorf("bucket name does not match") } @@ -108,8 +108,8 @@ func parseResource(s string) (Resource, error) { } return Resource{ - bucketName: bucketName, - pattern: pattern, + BucketName: bucketName, + Pattern: pattern, }, nil } @@ -125,7 +125,7 @@ func NewResource(bucketName, keyName string) Resource { } return Resource{ - bucketName: bucketName, - pattern: pattern, + BucketName: bucketName, + Pattern: pattern, } }