Rename mount.IsBind to mount.MakeBindOpts

This commit is contained in:
Travis Rhoden 2019-08-27 10:16:10 -06:00
parent bcb464db7b
commit ef855c7c08
No known key found for this signature in database
GPG Key ID: 6B4B921EC4ECF91A
5 changed files with 7 additions and 7 deletions

View File

@ -201,11 +201,11 @@ func IsNotMountPoint(mounter Interface, file string) (bool, error) {
return notMnt, nil return notMnt, nil
} }
// IsBind detects whether a bind mount is being requested and makes the remount options to // MakeBindOpts detects whether a bind mount is being requested and makes the remount options to
// use in case of bind mount, due to the fact that bind mount doesn't respect mount options. // use in case of bind mount, due to the fact that bind mount doesn't respect mount options.
// The list equals: // The list equals:
// options - 'bind' + 'remount' (no duplicate) // options - 'bind' + 'remount' (no duplicate)
func IsBind(options []string) (bool, []string, []string) { func MakeBindOpts(options []string) (bool, []string, []string) {
// Because we have an FD opened on the subpath bind mount, the "bind" option // Because we have an FD opened on the subpath bind mount, the "bind" option
// needs to be included, otherwise the mount target will error as busy if you // needs to be included, otherwise the mount target will error as busy if you
// remount as readonly. // remount as readonly.

View File

@ -73,7 +73,7 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
// Path to mounter binary if containerized mounter is needed. Otherwise, it is set to empty. // Path to mounter binary if containerized mounter is needed. Otherwise, it is set to empty.
// All Linux distros are expected to be shipped with a mount utility that a support bind mounts. // All Linux distros are expected to be shipped with a mount utility that a support bind mounts.
mounterPath := "" mounterPath := ""
bind, bindOpts, bindRemountOpts := IsBind(options) bind, bindOpts, bindRemountOpts := MakeBindOpts(options)
if bind { if bind {
err := mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindOpts) err := mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindOpts)
if err != nil { if err != nil {

View File

@ -21,7 +21,7 @@ import (
"testing" "testing"
) )
func TestIsBind(t *testing.T) { func TestMakeBindOpts(t *testing.T) {
tests := []struct { tests := []struct {
mountOption []string mountOption []string
isBind bool isBind bool
@ -43,7 +43,7 @@ func TestIsBind(t *testing.T) {
}, },
} }
for _, test := range tests { for _, test := range tests {
bind, bindOpts, bindRemountOpts := IsBind(test.mountOption) bind, bindOpts, bindRemountOpts := MakeBindOpts(test.mountOption)
if bind != test.isBind { if bind != test.isBind {
t.Errorf("Expected bind to be %v but got %v", test.isBind, bind) t.Errorf("Expected bind to be %v but got %v", test.isBind, bind)
} }

View File

@ -68,7 +68,7 @@ func (mounter *Mounter) Mount(source string, target string, fstype string, optio
bindSource := source bindSource := source
// tell it's going to mount azure disk or azure file according to options // tell it's going to mount azure disk or azure file according to options
if bind, _, _ := IsBind(options); bind { if bind, _, _ := MakeBindOpts(options); bind {
// mount azure disk // mount azure disk
bindSource = NormalizeWindowsPath(source) bindSource = NormalizeWindowsPath(source)
} else { } else {

View File

@ -47,7 +47,7 @@ var _ mount.Interface = &execMounter{}
// Mount runs mount(8) using given exec interface. // Mount runs mount(8) using given exec interface.
func (m *execMounter) Mount(source string, target string, fstype string, options []string) error { func (m *execMounter) Mount(source string, target string, fstype string, options []string) error {
bind, bindOpts, bindRemountOpts := mount.IsBind(options) bind, bindOpts, bindRemountOpts := mount.MakeBindOpts(options)
if bind { if bind {
err := m.doExecMount(source, target, fstype, bindOpts) err := m.doExecMount(source, target, fstype, bindOpts)