diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index 604b0109ae83..b6db690e76fa 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -302,14 +302,15 @@ func addMinikubeDirToAssets(basedir, vmpath string, assets *[]CopyableFile) erro return errors.Wrapf(err, "checking if %s is directory", hostpath) } if !isDir { - if vmpath == "" { + vmdir := vmpath + if vmdir == "" { rPath, err := filepath.Rel(basedir, hostpath) if err != nil { return errors.Wrap(err, "generating relative path") } rPath = filepath.Dir(rPath) rPath = filepath.ToSlash(rPath) - vmpath = path.Join("/", rPath) + vmdir = path.Join("/", rPath) } permString := fmt.Sprintf("%o", info.Mode().Perm()) // The conversion will strip the leading 0 if present, so add it back @@ -318,7 +319,7 @@ func addMinikubeDirToAssets(basedir, vmpath string, assets *[]CopyableFile) erro permString = fmt.Sprintf("0%s", permString) } - f, err := NewFileAsset(hostpath, vmpath, filepath.Base(hostpath), permString) + f, err := NewFileAsset(hostpath, vmdir, filepath.Base(hostpath), permString) if err != nil { return errors.Wrapf(err, "creating file asset for %s", hostpath) }