forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#1 from mohsha-msft/track2-mohit/test-migrati…
…on-2 Track2 mohit/test migration 2
- Loading branch information
Showing
30 changed files
with
9,164 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package azblob | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
) | ||
|
||
// The AccessPolicyPermission type simplifies creating the permissions string for a container's access policy. | ||
// Initialize an instance of this type and then call its String method to set AccessPolicy's Permission field. | ||
type AccessPolicyPermission struct { | ||
Read, Add, Create, Write, Delete, List bool | ||
} | ||
|
||
// String produces the access policy permission string for an Azure Storage container. | ||
// Call this method to set AccessPolicy's Permission field. | ||
func (p AccessPolicyPermission) String() string { | ||
var b bytes.Buffer | ||
if p.Read { | ||
b.WriteRune('r') | ||
} | ||
if p.Add { | ||
b.WriteRune('a') | ||
} | ||
if p.Create { | ||
b.WriteRune('c') | ||
} | ||
if p.Write { | ||
b.WriteRune('w') | ||
} | ||
if p.Delete { | ||
b.WriteRune('d') | ||
} | ||
if p.List { | ||
b.WriteRune('l') | ||
} | ||
return b.String() | ||
} | ||
|
||
// Parse initializes the AccessPolicyPermission's fields from a string. | ||
func (p *AccessPolicyPermission) Parse(s string) error { | ||
*p = AccessPolicyPermission{} // Clear the flags | ||
for _, r := range s { | ||
switch r { | ||
case 'r': | ||
p.Read = true | ||
case 'a': | ||
p.Add = true | ||
case 'c': | ||
p.Create = true | ||
case 'w': | ||
p.Write = true | ||
case 'd': | ||
p.Delete = true | ||
case 'l': | ||
p.List = true | ||
default: | ||
return fmt.Errorf("invalid permission: '%v'", r) | ||
} | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.