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

Commit

Permalink
Review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
venilnoronha committed Jun 28, 2017
1 parent 6011080 commit 8629110
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion vmdk_plugin/drivers/photon/photon_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func validateCreateOptions(r volume.Request) error {
}

// Check whether the fstype filesystem is supported.
errFstype := fs.AssertFsSupport(r.Options[fsTypeTag])
errFstype := fs.VerifyFSSupport(r.Options[fsTypeTag])
if errFstype != nil {
log.WithFields(log.Fields{"name": r.Name,
"fstype": r.Options[fsTypeTag]}).Error("Not found ")
Expand Down
7 changes: 3 additions & 4 deletions vmdk_plugin/drivers/vmdk/vmdk_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ import (
"github.com/vmware/docker-volume-vsphere/vmdk_plugin/utils/refcount"
)

const (
version = "vSphere Volume Driver v0.4"
)
const version = "vSphere Volume Driver v0.4"

// VolumeDriver - VMDK driver struct
type VolumeDriver struct {
Expand Down Expand Up @@ -189,6 +187,7 @@ func (d *VolumeDriver) MountVolume(name string, fstype string, id string, isRead

volDev, err := d.ops.Attach(name, nil)
if err != nil {
log.WithFields(log.Fields{"name": name, "error": err}).Error("Attach volume failed ")
return mountpoint, err
}

Expand Down Expand Up @@ -356,7 +355,7 @@ func (d *VolumeDriver) Create(r volume.Request) volume.Response {
}

// Check whether the fstype filesystem is supported.
errFstype := fs.AssertFsSupport(r.Options["fstype"])
errFstype := fs.VerifyFSSupport(r.Options["fstype"])
if errFstype != nil {
log.WithFields(log.Fields{"name": r.Name, "fstype": r.Options["fstype"]}).Error("Not found ")
return volume.Response{Err: errFstype.Error()}
Expand Down
2 changes: 1 addition & 1 deletion vmdk_plugin/drivers/vmdk/vmdkops/mock_vmdkcmd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func createBlockDevice(label string, opts map[string]string) error {
if _, result := opts["fstype"]; result == false {
opts["fstype"] = fs.FstypeDefault
}
errFstype := fs.AssertFsSupport(opts["fstype"])
errFstype := fs.VerifyFSSupport(opts["fstype"])
if errFstype != nil {
return fmt.Errorf("Not found mkfs for %s", opts["fstype"])
}
Expand Down
4 changes: 1 addition & 3 deletions vmdk_plugin/drivers/vmdk/vmdkops/mock_vmdkcmd_unsupported.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

package vmdkops

import (
"errors"
)
import "errors"

// UnsupportedMockCmd struct.
type UnsupportedMockCmd struct{}
Expand Down
3 changes: 3 additions & 0 deletions vmdk_plugin/drivers/vmdk/vmdkops/vmdkops.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (v VmdkOps) RawAttach(name string, opts map[string]string) ([]byte, error)
log.Debugf("vmdkOps.Attach name=%s", name)
str, err := v.Cmd.Run("attach", name, opts)
if err != nil {
log.WithFields(log.Fields{"name": name, "opts": opts, "error": err}).Error("RawAttach failed ")
return nil, err
}
return str, nil
Expand All @@ -80,6 +81,8 @@ func (v VmdkOps) Attach(name string, opts map[string]string) (*fs.VolumeDevSpec,
var volDev fs.VolumeDevSpec
err = json.Unmarshal(str, &volDev)
if err != nil {
log.WithFields(log.Fields{"name": name, "opts": opts, "bytes": str,
"error": err}).Error("Failed to unmarshal ")
return nil, err
}
return &volDev, nil
Expand Down
2 changes: 0 additions & 2 deletions vmdk_plugin/utils/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// This is the filesystem interface for mounting volumes on the guest.

package fs

// VolumeDevSpec - volume spec returned from the server on an attach
Expand Down
7 changes: 5 additions & 2 deletions vmdk_plugin/utils/fs/fs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func devAttachWaitPrep(devPath string) (*inotify.Watcher, error) {
func DevAttachWait(watcher *inotify.Watcher, volDev *VolumeDevSpec) error {
device, err := getDevicePath(volDev)
if err != nil {
log.WithFields(log.Fields{"volDev": *volDev, "err": err}).Error("Failed to get device path ")
return err
}
devAttachWait(watcher, device)
Expand Down Expand Up @@ -133,6 +134,7 @@ func Mkdir(path string) error {
func Mkfs(fstype string, label string, volDev *VolumeDevSpec) error {
device, err := getDevicePath(volDev)
if err != nil {
log.WithFields(log.Fields{"volDev": *volDev, "err": err}).Error("Failed to get device path ")
return err
}
return MkfsByDevicePath(fstype, label, device)
Expand Down Expand Up @@ -161,8 +163,8 @@ func MkfsByDevicePath(fstype string, label string, device string) error {
return nil
}

// AssertFsSupport checks whether the fstype filesystem is supported.
func AssertFsSupport(fstype string) error {
// VerifyFSSupport checks whether the fstype filesystem is supported.
func VerifyFSSupport(fstype string) error {
supportedFs := mkfsLookup()
_, result := supportedFs[fstype]
if result == false {
Expand Down Expand Up @@ -197,6 +199,7 @@ func mkfsLookup() map[string]string {
func Mount(mountpoint string, fstype string, volDev *VolumeDevSpec, isReadOnly bool) error {
device, err := getDevicePath(volDev)
if err != nil {
log.WithFields(log.Fields{"volDev": *volDev, "err": err}).Error("Failed to get device path ")
return err
}
return MountByDevicePath(mountpoint, fstype, device, isReadOnly)
Expand Down

0 comments on commit 8629110

Please sign in to comment.