-
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.
azurerm_spring_cloud_connection
, azurerm_app_service_connection
: …
…fix inaccurate storage blob resource id (#18699)
- Loading branch information
1 parent
22843c3
commit 0ab4862
Showing
10 changed files
with
474 additions
and
4 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
75 changes: 75 additions & 0 deletions
75
internal/services/storage/parse/storage_account_default_blob.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,75 @@ | ||
package parse | ||
|
||
// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" | ||
) | ||
|
||
type StorageAccountDefaultBlobId struct { | ||
SubscriptionId string | ||
ResourceGroup string | ||
StorageAccountName string | ||
BlobServiceName string | ||
} | ||
|
||
func NewStorageAccountDefaultBlobID(subscriptionId, resourceGroup, storageAccountName, blobServiceName string) StorageAccountDefaultBlobId { | ||
return StorageAccountDefaultBlobId{ | ||
SubscriptionId: subscriptionId, | ||
ResourceGroup: resourceGroup, | ||
StorageAccountName: storageAccountName, | ||
BlobServiceName: blobServiceName, | ||
} | ||
} | ||
|
||
func (id StorageAccountDefaultBlobId) String() string { | ||
segments := []string{ | ||
fmt.Sprintf("Blob Service Name %q", id.BlobServiceName), | ||
fmt.Sprintf("Storage Account Name %q", id.StorageAccountName), | ||
fmt.Sprintf("Resource Group %q", id.ResourceGroup), | ||
} | ||
segmentsStr := strings.Join(segments, " / ") | ||
return fmt.Sprintf("%s: (%s)", "Storage Account Default Blob", segmentsStr) | ||
} | ||
|
||
func (id StorageAccountDefaultBlobId) ID() string { | ||
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/blobServices/%s" | ||
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.StorageAccountName, id.BlobServiceName) | ||
} | ||
|
||
// StorageAccountDefaultBlobID parses a StorageAccountDefaultBlob ID into an StorageAccountDefaultBlobId struct | ||
func StorageAccountDefaultBlobID(input string) (*StorageAccountDefaultBlobId, error) { | ||
id, err := resourceids.ParseAzureResourceID(input) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
resourceId := StorageAccountDefaultBlobId{ | ||
SubscriptionId: id.SubscriptionID, | ||
ResourceGroup: id.ResourceGroup, | ||
} | ||
|
||
if resourceId.SubscriptionId == "" { | ||
return nil, fmt.Errorf("ID was missing the 'subscriptions' element") | ||
} | ||
|
||
if resourceId.ResourceGroup == "" { | ||
return nil, fmt.Errorf("ID was missing the 'resourceGroups' element") | ||
} | ||
|
||
if resourceId.StorageAccountName, err = id.PopSegment("storageAccounts"); err != nil { | ||
return nil, err | ||
} | ||
if resourceId.BlobServiceName, err = id.PopSegment("blobServices"); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := id.ValidateNoEmptySegments(input); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &resourceId, nil | ||
} |
Oops, something went wrong.