-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 #9917 from ross-p-smith/adls-root-acl
Allow ADLS File System to have ACLs added to the root
- Loading branch information
Showing
8 changed files
with
457 additions
and
84 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
azurerm/internal/services/storage/parse/storage_filesystem_ace.go
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,69 @@ | ||
package parse | ||
|
||
import ( | ||
"github.com/google/uuid" | ||
"github.com/tombuildsstuff/giovanni/storage/accesscontrol" | ||
) | ||
|
||
func ExpandDataLakeGen2AceList(input []interface{}) (*accesscontrol.ACL, error) { | ||
if len(input) == 0 { | ||
return nil, nil | ||
} | ||
aceList := make([]accesscontrol.ACE, len(input)) | ||
|
||
for i := 0; i < len(input); i++ { | ||
v := input[i].(map[string]interface{}) | ||
|
||
isDefault := false | ||
if scopeRaw, ok := v["scope"]; ok { | ||
if scopeRaw.(string) == "default" { | ||
isDefault = true | ||
} | ||
} | ||
|
||
tagType := accesscontrol.TagType(v["type"].(string)) | ||
|
||
var id *uuid.UUID | ||
if raw, ok := v["id"]; ok && raw != "" { | ||
idTemp, err := uuid.Parse(raw.(string)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
id = &idTemp | ||
} | ||
|
||
permissions := v["permissions"].(string) | ||
|
||
ace := accesscontrol.ACE{ | ||
IsDefault: isDefault, | ||
TagType: tagType, | ||
TagQualifier: id, | ||
Permissions: permissions, | ||
} | ||
aceList[i] = ace | ||
} | ||
|
||
return &accesscontrol.ACL{Entries: aceList}, nil | ||
} | ||
|
||
func FlattenDataLakeGen2AceList(acl accesscontrol.ACL) []interface{} { | ||
output := make([]interface{}, len(acl.Entries)) | ||
|
||
for i, v := range acl.Entries { | ||
ace := make(map[string]interface{}) | ||
|
||
scope := "access" | ||
if v.IsDefault { | ||
scope = "default" | ||
} | ||
ace["scope"] = scope | ||
ace["type"] = string(v.TagType) | ||
if v.TagQualifier != nil { | ||
ace["id"] = v.TagQualifier.String() | ||
} | ||
ace["permissions"] = v.Permissions | ||
|
||
output[i] = ace | ||
} | ||
return output | ||
} |
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.