@ -29,26 +29,26 @@ const ResourceARNPrefix = "arn:aws:s3:::"
// Resource - resource in policy statement.
type Resource struct {
b ucketName string
p attern string
B ucketName string
P attern string
}
func ( r Resource ) isBucketPattern ( ) bool {
return ! strings . Contains ( r . p attern, "/" )
return ! strings . Contains ( r . P attern, "/" )
}
func ( r Resource ) isObjectPattern ( ) bool {
return strings . Contains ( r . p attern, "/" ) || strings . Contains ( r . b ucketName, "*" )
return strings . Contains ( r . P attern, "/" ) || strings . Contains ( r . B ucketName, "*" )
}
// IsValid - checks whether Resource is valid or not.
func ( r Resource ) IsValid ( ) bool {
return r . b ucketName != "" && r . p attern != ""
return r . B ucketName != "" && r . P attern != ""
}
// Match - matches object name with resource pattern.
func ( r Resource ) Match ( resource string ) bool {
return wildcard . Match ( r . p attern, resource )
return wildcard . Match ( r . P attern, 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 . p attern
return ResourceARNPrefix + r . P attern
}
// 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 . b ucketName, bucketName ) {
if ! wildcard . Match ( r . B ucketName, bucketName ) {
return fmt . Errorf ( "bucket name does not match" )
}
@ -108,8 +108,8 @@ func parseResource(s string) (Resource, error) {
}
return Resource {
b ucketName: bucketName ,
p attern: pattern ,
B ucketName: bucketName ,
P attern: pattern ,
} , nil
}
@ -125,7 +125,7 @@ func NewResource(bucketName, keyName string) Resource {
}
return Resource {
b ucketName: bucketName ,
p attern: pattern ,
B ucketName: bucketName ,
P attern: pattern ,
}
}