Skip to content

Commit

Permalink
update validation to allow superuser value (#16215)
Browse files Browse the repository at this point in the history
  • Loading branch information
catriona-m committed Apr 5, 2022
1 parent dad0a2f commit 502bfcc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ func resourceStorageDataLakeGen2FileSystem() *pluginsdk.Resource {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.IsUUID,
ValidateFunc: validation.Any(validation.IsUUID, validation.StringInSlice([]string{"$superuser"}, false)),
},

"group": {
Type: pluginsdk.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.IsUUID,
ValidateFunc: validation.Any(validation.IsUUID, validation.StringInSlice([]string{"$superuser"}, false)),
},

"ace": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ func TestAccStorageDataLakeGen2FileSystem_withOwnerGroup(t *testing.T) {
})
}

func TestAccStorageDataLakeGen2FileSystem_withSuperUsers(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_storage_data_lake_gen2_filesystem", "test")
r := StorageDataLakeGen2FileSystemResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.withSuperUsers(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (r StorageDataLakeGen2FileSystemResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := filesystems.ParseResourceID(state.ID)
if err != nil {
Expand Down Expand Up @@ -340,3 +355,27 @@ resource "azurerm_storage_data_lake_gen2_filesystem" "test" {
}
`, template, data.RandomInteger)
}

func (r StorageDataLakeGen2FileSystemResource) withSuperUsers(data acceptance.TestData) string {
template := r.template(data)
return fmt.Sprintf(`
%s
provider "azuread" {}
resource "azuread_application" "test" {
display_name = "acctestspa%[2]d"
}
resource "azuread_service_principal" "test" {
application_id = azuread_application.test.application_id
}
resource "azurerm_storage_data_lake_gen2_filesystem" "test" {
name = "acctest-%[2]d"
storage_account_id = azurerm_storage_account.test.id
owner = "$superuser"
group = "$superuser"
}
`, template, data.RandomInteger)
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ The following arguments are supported:

* `ace` - (Optional) One or more `ace` blocks as defined below to specify the entries for the ACL for the path.

* `owner` - (Optional) Specifies the Object ID of the Azure Active Directory User to make the owning user of the root path (i.e. `/`).
* `owner` - (Optional) Specifies the Object ID of the Azure Active Directory User to make the owning user of the root path (i.e. `/`). Possible values also include `$superuser`.

* `group` - (Optional) Specifies the Object ID of the Azure Active Directory Group to make the owning group of the root path (i.e. `/`).
* `group` - (Optional) Specifies the Object ID of the Azure Active Directory Group to make the owning group of the root path (i.e. `/`). Possible values also include `$superuser`.

~> **NOTE:** The Storage Account requires `account_kind` to be either `StorageV2` or `BlobStorage`. In addition, `is_hns_enabled` has to be set to `true`.

Expand Down

0 comments on commit 502bfcc

Please sign in to comment.