Skip to content

Commit

Permalink
Merge pull request #418 from anshulahuja98/rg
Browse files Browse the repository at this point in the history
Add resource group parameter to volumesnapshot
  • Loading branch information
andyzhangx committed Jun 1, 2020
2 parents d16af41 + e71d9ae commit 783c6fc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/azuredisk/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,13 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
return nil, status.Error(codes.InvalidArgument, "snapshot name must be provided")
}

resourceGroup, err := getResourceGroupFromURI(sourceVolumeID)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "could not get resource group from diskURI(%s) with error(%v)", sourceVolumeID, err)
}

snapshotName = getValidDiskName(snapshotName)

var customTags string
// set incremental snapshot as true by default
incremental := true
var resourceGroup string
var err error

parameters := req.GetParameters()
for k, v := range parameters {
Expand All @@ -585,10 +582,18 @@ func (d *Driver) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequ
if v == "false" {
incremental = false
}
case "resourcegroup":
resourceGroup = v
default:
return nil, fmt.Errorf("AzureDisk - invalid option %s in VolumeSnapshotClass", k)
}
}
if resourceGroup == "" {
resourceGroup, err = getResourceGroupFromURI(sourceVolumeID)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "could not get resource group from diskURI(%s) with error(%v)", sourceVolumeID, err)
}
}

customTagsMap, err := volumehelper.ConvertTagsToMap(customTags)
if err != nil {
Expand Down

0 comments on commit 783c6fc

Please sign in to comment.