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
}
// 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.
// The list equals:
// 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
// needs to be included, otherwise the mount target will error as busy if you
// 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.
// All Linux distros are expected to be shipped with a mount utility that a support bind mounts.
mounterPath := ""
bind, bindOpts, bindRemountOpts := IsBind(options)
bind, bindOpts, bindRemountOpts := MakeBindOpts(options)
if bind {
err := mounter.doMount(mounterPath, defaultMountCommand, source, target, fstype, bindOpts)
if err != nil {

View File

@ -21,7 +21,7 @@ import (
"testing"
)
func TestIsBind(t *testing.T) {
func TestMakeBindOpts(t *testing.T) {
tests := []struct {
mountOption []string
isBind bool
@ -43,7 +43,7 @@ func TestIsBind(t *testing.T) {
},
}
for _, test := range tests {
bind, bindOpts, bindRemountOpts := IsBind(test.mountOption)
bind, bindOpts, bindRemountOpts := MakeBindOpts(test.mountOption)
if bind != test.isBind {
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
// 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
bindSource = NormalizeWindowsPath(source)
} else {

View File

@ -47,7 +47,7 @@ var _ mount.Interface = &execMounter{}
// Mount runs mount(8) using given exec interface.
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 {
err := m.doExecMount(source, target, fstype, bindOpts)