Skip to content

Commit

Permalink
Update velero-plugin-for-microsoft-azure/volume_snapshotter.go
Browse files Browse the repository at this point in the history
Co-authored-by: JenTing Hsiao <[email protected]>
  • Loading branch information
pavb74 and JenTing Hsiao authored Jul 23, 2021
1 parent 2afd6fc commit 66d25aa
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions velero-plugin-for-microsoft-azure/volume_snapshotter.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,25 @@ func (b *VolumeSnapshotter) Init(config map[string]string) error {

// if config["snapsSkuConfigKey"] is empty, default to nil; otherwise, convert it
var snapshotsSku *disk.SnapshotSku
if val := config[snapsSkuConfigKey]; val != "" {
var snapshotsSkuName disk.SnapshotStorageAccountTypes;
switch val {
case "Premium_LRS": snapshotsSkuName = disk.SnapshotStorageAccountTypesPremiumLRS
case "Standard_LRS": snapshotsSkuName = disk.SnapshotStorageAccountTypesStandardLRS
case "Standard_ZRS": snapshotsSkuName = disk.SnapshotStorageAccountTypesStandardZRS
default:
return errors.New(fmt.Sprintf("Invalid value %s for config key %s (Premium_LRS, Standard_LRS or Standard_ZRS are supported)", val, snapsSkuConfigKey))
}

snapshotsSku = &disk.SnapshotSku{
Name: snapshotsSkuName,
}
} else {
snapshotsSku = nil
}
if val := config[snapsSkuConfigKey]; val != "" {
var snapshotsSkuName disk.SnapshotStorageAccountTypes
var found bool
for _, name := range disk.PossibleSnapshotStorageAccountTypesValues() {
if val == string(name) {
found = true
snapshotsSkuName = name
}
}
if !found {
return fmt.Errorf("Invalid value %s for config key %s (%v are supported)", val, snapsSkuConfigKey, disk.PossibleSnapshotStorageAccountTypesValues())
}

snapshotsSku = &disk.SnapshotSku{
Name: snapshotsSkuName,
}
} else {
snapshotsSku = nil
}

// set up clients
disksClient := disk.NewDisksClientWithBaseURI(env.ResourceManagerEndpoint, envVars[subscriptionIDEnvVar])
Expand Down

0 comments on commit 66d25aa

Please sign in to comment.