Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Fixed request options init for create op. #1636

Merged
merged 1 commit into from
Jul 27, 2017
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
8 changes: 6 additions & 2 deletions client_plugin/drivers/photon/photon_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,11 @@ func NewVolumeDriver(cfg config.Config, mountDir string) *VolumeDriver {
}

// validateCreateOptions validates the volume create request.
func validateCreateOptions(r volume.Request) error {
func validateCreateOptions(r *volume.Request) error {
if r.Options == nil {
r.Options = make(map[string]string)
}

// Clone isn't supported
if _, result := r.Options["clone-from"]; result == true {
return fmt.Errorf("Unrecognized option - clone-from")
Expand Down Expand Up @@ -439,7 +443,7 @@ func (d *VolumeDriver) UnmountVolume(name string) error {
func (d *VolumeDriver) Create(r volume.Request) volume.Response {
log.WithFields(log.Fields{"name": r.Name, "option": r.Options}).Info("Creating volume ")

err := validateCreateOptions(r)
err := validateCreateOptions(&r)
if err != nil {
return volume.Response{Err: err.Error()}
}
Expand Down
7 changes: 4 additions & 3 deletions client_plugin/drivers/vmdk/vmdk_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ func (d *VolumeDriver) processMount(r volume.MountRequest) volume.Response {
return volume.Response{Mountpoint: mountpoint}
}

// prepareCreateOptions sets default options for create request r.
func (d *VolumeDriver) prepareCreateOptions(r volume.Request) error {
// prepareCreateOptions sets default options for the given request, allocates
// request options if needed
func (d *VolumeDriver) prepareCreateOptions(r *volume.Request) error {
if r.Options == nil {
r.Options = make(map[string]string)
}
Expand Down Expand Up @@ -332,7 +333,7 @@ func (d *VolumeDriver) detachAndRemove(name string) {

// Create creates a volume.
func (d *VolumeDriver) Create(r volume.Request) volume.Response {
err := d.prepareCreateOptions(r)
err := d.prepareCreateOptions(&r)
if err != nil {
log.WithFields(log.Fields{"name": r.Name, "error": err}).Error("Failed to prepare options ")
return volume.Response{Err: err.Error()}
Expand Down