Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_storage_share - Correct the resource_manager_id #21645

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (r MachineLearningDataStoreFileShare) Create() sdk.ResourceFunc {

props := &datastore.AzureFileDatastore{
AccountName: fileShareId.StorageAccountName,
FileShareName: fileShareId.FileshareName,
FileShareName: fileShareId.ShareName,
Description: utils.String(model.Description),
ServiceDataAccessAuthIdentity: utils.ToPtr(datastore.ServiceDataAccessAuthIdentity(model.ServiceDataIdentity)),
Tags: utils.ToPtr(model.Tags),
Expand Down Expand Up @@ -226,7 +226,7 @@ func (r MachineLearningDataStoreFileShare) Update() sdk.ResourceFunc {

props := &datastore.AzureFileDatastore{
AccountName: fileShareId.StorageAccountName,
FileShareName: fileShareId.FileshareName,
FileShareName: fileShareId.ShareName,
Description: utils.String(state.Description),
ServiceDataAccessAuthIdentity: utils.ToPtr(datastore.ServiceDataAccessAuthIdentity(state.ServiceDataIdentity)),
Tags: utils.ToPtr(state.Tags),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ type StorageShareResourceManagerId struct {
ResourceGroup string
StorageAccountName string
FileServiceName string
FileshareName string
ShareName string
}

func NewStorageShareResourceManagerID(subscriptionId, resourceGroup, storageAccountName, fileServiceName, fileshareName string) StorageShareResourceManagerId {
func NewStorageShareResourceManagerID(subscriptionId, resourceGroup, storageAccountName, fileServiceName, shareName string) StorageShareResourceManagerId {
return StorageShareResourceManagerId{
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
StorageAccountName: storageAccountName,
FileServiceName: fileServiceName,
FileshareName: fileshareName,
ShareName: shareName,
}
}

func (id StorageShareResourceManagerId) String() string {
segments := []string{
fmt.Sprintf("Fileshare Name %q", id.FileshareName),
fmt.Sprintf("Share Name %q", id.ShareName),
fmt.Sprintf("File Service Name %q", id.FileServiceName),
fmt.Sprintf("Storage Account Name %q", id.StorageAccountName),
fmt.Sprintf("Resource Group %q", id.ResourceGroup),
Expand All @@ -39,8 +39,8 @@ func (id StorageShareResourceManagerId) String() string {
}

func (id StorageShareResourceManagerId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/fileServices/%s/fileshares/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.StorageAccountName, id.FileServiceName, id.FileshareName)
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/fileServices/%s/shares/%s"
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.StorageAccountName, id.FileServiceName, id.ShareName)
}

// StorageShareResourceManagerID parses a StorageShareResourceManager ID into an StorageShareResourceManagerId struct
Expand Down Expand Up @@ -69,7 +69,7 @@ func StorageShareResourceManagerID(input string) (*StorageShareResourceManagerId
if resourceId.FileServiceName, err = id.PopSegment("fileServices"); err != nil {
return nil, err
}
if resourceId.FileshareName, err = id.PopSegment("fileshares"); err != nil {
if resourceId.ShareName, err = id.PopSegment("shares"); err != nil {
return nil, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var _ resourceids.Id = StorageShareResourceManagerId{}

func TestStorageShareResourceManagerIDFormatter(t *testing.T) {
actual := NewStorageShareResourceManagerID("12345678-1234-9876-4563-123456789012", "resGroup1", "storageAccount1", "fileService1", "share1").ID()
expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/fileshares/share1"
expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/shares/share1"
if actual != expected {
t.Fatalf("Expected %q but got %q", expected, actual)
}
Expand Down Expand Up @@ -80,32 +80,32 @@ func TestStorageShareResourceManagerID(t *testing.T) {
},

{
// missing FileshareName
// missing ShareName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/",
Error: true,
},

{
// missing value for FileshareName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/fileshares/",
// missing value for ShareName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/shares/",
Error: true,
},

{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/fileshares/share1",
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/shares/share1",
Expected: &StorageShareResourceManagerId{
SubscriptionId: "12345678-1234-9876-4563-123456789012",
ResourceGroup: "resGroup1",
StorageAccountName: "storageAccount1",
FileServiceName: "fileService1",
FileshareName: "share1",
ShareName: "share1",
},
},

{
// upper-cased
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.STORAGE/STORAGEACCOUNTS/STORAGEACCOUNT1/FILESERVICES/FILESERVICE1/FILESHARES/SHARE1",
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.STORAGE/STORAGEACCOUNTS/STORAGEACCOUNT1/FILESERVICES/FILESERVICE1/SHARES/SHARE1",
Error: true,
},
}
Expand Down Expand Up @@ -137,8 +137,8 @@ func TestStorageShareResourceManagerID(t *testing.T) {
if actual.FileServiceName != v.Expected.FileServiceName {
t.Fatalf("Expected %q but got %q for FileServiceName", v.Expected.FileServiceName, actual.FileServiceName)
}
if actual.FileshareName != v.Expected.FileshareName {
t.Fatalf("Expected %q but got %q for FileshareName", v.Expected.FileshareName, actual.FileshareName)
if actual.ShareName != v.Expected.ShareName {
t.Fatalf("Expected %q but got %q for ShareName", v.Expected.ShareName, actual.ShareName)
}
}
}
2 changes: 1 addition & 1 deletion internal/services/storage/resourceids.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package storage
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageAccountDefaultBlob -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/blobServices/default
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageContainerResourceManager -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/blobServices/default/containers/container1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageQueueResourceManager -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/queueServices/default/queues/queue1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageShareResourceManager -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/fileshares/share1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageShareResourceManager -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/shares/share1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageSyncGroup -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.StorageSync/storageSyncServices/storageSyncService1/syncGroups/syncGroup1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageSyncService -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.StorageSync/storageSyncServices/storageSyncService1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=StorageSyncCloudEndpoint -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.StorageSync/storageSyncServices/storageSyncService1/syncGroups/syncGroup1/cloudEndpoints/cloudEndpoint1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,26 @@ func TestStorageShareResourceManagerID(t *testing.T) {
},

{
// missing FileshareName
// missing ShareName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/",
Valid: false,
},

{
// missing value for FileshareName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/fileshares/",
// missing value for ShareName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/shares/",
Valid: false,
},

{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/fileshares/share1",
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Storage/storageAccounts/storageAccount1/fileServices/fileService1/shares/share1",
Valid: true,
},

{
// upper-cased
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.STORAGE/STORAGEACCOUNTS/STORAGEACCOUNT1/FILESERVICES/FILESERVICE1/FILESHARES/SHARE1",
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.STORAGE/STORAGEACCOUNTS/STORAGEACCOUNT1/FILESERVICES/FILESERVICE1/SHARES/SHARE1",
Valid: false,
},
}
Expand Down