-
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.
- Loading branch information
1 parent
8ddf34f
commit 957cb32
Showing
5 changed files
with
111 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package azurerm | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
type UnmanagedDiskMetadata struct { | ||
StorageContainerName string | ||
StorageAccountName string | ||
BlobName string | ||
ResourceGroupName string | ||
} | ||
|
||
func storageAccountNameForUnmanagedDisk(uri string, meta interface{}) (*UnmanagedDiskMetadata, error) { | ||
vhdURL, err := url.Parse(uri) | ||
if err != nil { | ||
return nil, fmt.Errorf("Cannot parse Disk VHD URI: %s", err) | ||
} | ||
|
||
// VHD URI is in the form: https://storageAccountName.blob.core.windows.net/containerName/blobName | ||
storageAccountName := strings.Split(vhdURL.Host, ".")[0] | ||
path := strings.Split(strings.TrimPrefix(vhdURL.Path, "/"), "/") | ||
containerName := path[0] | ||
blobName := path[1] | ||
|
||
resourceGroupName, err := findStorageAccountResourceGroup(meta, storageAccountName) | ||
if err != nil { | ||
return nil, fmt.Errorf("Error finding resource group for storage account %s: %+v", storageAccountName, err) | ||
} | ||
|
||
metadata := UnmanagedDiskMetadata{ | ||
BlobName: blobName, | ||
StorageContainerName: containerName, | ||
StorageAccountName: storageAccountName, | ||
ResourceGroupName: resourceGroupName, | ||
} | ||
return &metadata, nil | ||
} |
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