Skip to content

Commit

Permalink
New resource: azurerm_storage_account_local_user (#19592)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Harvey <[email protected]>
Co-authored-by: kt <[email protected]>
Fix #19536
  • Loading branch information
magodo authored Jan 12, 2023
1 parent 0876f93 commit 355e27d
Show file tree
Hide file tree
Showing 8 changed files with 1,069 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/acceptance/check/that.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ func (t thatWithKeyType) IsEmpty() pluginsdk.TestCheckFunc {
return resource.TestCheckResourceAttr(t.resourceName, t.key, "")
}

// IsNotEmpty returns a TestCheckFunc which validates that the specific key is not empty on the resource
func (t thatWithKeyType) IsNotEmpty() pluginsdk.TestCheckFunc {
return resource.TestCheckResourceAttrWith(t.resourceName, t.key, func(value string) error {
if value == "" {
return fmt.Errorf("value is empty")
}
return nil
})
}

// IsSet returns a TestCheckFunc which validates that the specific key is set on the resource
func (t thatWithKeyType) IsSet() pluginsdk.TestCheckFunc {
return resource.TestCheckResourceAttrSet(t.resourceName, t.key)
Expand Down
1 change: 1 addition & 0 deletions internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
sentinel.Registration{},
serviceconnector.Registration{},
servicefabricmanaged.Registration{},
storage.Registration{},
orbital.Registration{},
streamanalytics.Registration{},
search.Registration{},
Expand Down
6 changes: 6 additions & 0 deletions internal/services/storage/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
storage_v2022_05_01 "github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01"
"github.com/hashicorp/go-azure-sdk/resource-manager/storage/2022-05-01/localusers"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/storage/shim"
"github.com/tombuildsstuff/giovanni/storage/2019-12-12/blob/accounts"
Expand All @@ -26,6 +27,7 @@ import (

type Client struct {
AccountsClient *storage.AccountsClient
LocalUsersClient *localusers.LocalUsersClient
FileSystemsClient *filesystems.Client
ADLSGen2PathsClient *paths.Client
ManagementPoliciesClient *storage.ManagementPoliciesClient
Expand All @@ -49,6 +51,9 @@ func NewClient(options *common.ClientOptions) *Client {
accountsClient := storage.NewAccountsClientWithBaseURI(options.ResourceManagerEndpoint, options.SubscriptionId)
options.ConfigureClient(&accountsClient.Client, options.ResourceManagerAuthorizer)

localUsersClient := localusers.NewLocalUsersClientWithBaseURI(options.ResourceManagerEndpoint)
localUsersClient.Client.Authorizer = options.ResourceManagerAuthorizer

fileSystemsClient := filesystems.NewWithEnvironment(options.Environment)
options.ConfigureClient(&fileSystemsClient.Client, options.StorageAuthorizer)

Expand Down Expand Up @@ -88,6 +93,7 @@ func NewClient(options *common.ClientOptions) *Client {
// (which should fix #2977) when the storage clients have been moved in here
client := Client{
AccountsClient: &accountsClient,
LocalUsersClient: &localUsersClient,
FileSystemsClient: &fileSystemsClient,
ADLSGen2PathsClient: &adlsGen2PathsClient,
ManagementPoliciesClient: &managementPoliciesClient,
Expand Down
10 changes: 10 additions & 0 deletions internal/services/storage/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,13 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource {
"azurerm_storage_sync_group": resourceStorageSyncGroup(),
}
}

func (r Registration) DataSources() []sdk.DataSource {
return []sdk.DataSource{}
}

func (r Registration) Resources() []sdk.Resource {
return []sdk.Resource{
LocalUserResource{},
}
}
Loading

0 comments on commit 355e27d

Please sign in to comment.