-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
~/.minikube/files as rootfs "layer" #2110
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ import ( | |
"path/filepath" | ||
"strconv" | ||
|
||
"github.com/golang/glog" | ||
"github.com/pkg/errors" | ||
"k8s.io/minikube/pkg/minikube/config" | ||
"k8s.io/minikube/pkg/minikube/constants" | ||
"k8s.io/minikube/pkg/util" | ||
|
@@ -196,22 +196,53 @@ var Addons = map[string]*Addon{ | |
}, false, "registry-creds"), | ||
} | ||
|
||
func AddMinikubeDirToAssets(minipath string, vmpath string, assetList *[]CopyableFile) { | ||
// loop over $MINIKUBE_HOME/minipath and add them to assets | ||
searchDir := constants.MakeMiniPath(minipath) | ||
err := filepath.Walk(searchDir, func(miniFile string, f os.FileInfo, err error) error { | ||
isDir, err := util.IsDirectory(miniFile) | ||
if err == nil && !isDir { | ||
f, err := NewFileAsset(miniFile, vmpath, filepath.Base(miniFile), "0640") | ||
if err == nil { | ||
*assetList = append(*assetList, f) | ||
func AddMinikubeDirAssets(assets *[]CopyableFile) error { | ||
if err := addMinikubeDirToAssets(constants.MakeMiniPath("addons"), constants.AddonsPath, assets); err != nil { | ||
return errors.Wrap(err, "adding addons folder to assets") | ||
} | ||
if err := addMinikubeDirToAssets(constants.MakeMiniPath("files"), "", assets); err != nil { | ||
return errors.Wrap(err, "adding files rootfs to assets") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// AddMinikubeDirToAssets adds all the files in the basedir argument to the list | ||
// of files to be copied to the vm. If vmpath is left blank, the files will be | ||
// transferred to the location according to their relative minikube folder path. | ||
func addMinikubeDirToAssets(basedir, vmpath string, assets *[]CopyableFile) error { | ||
err := filepath.Walk(basedir, func(hostpath string, info os.FileInfo, err error) error { | ||
isDir, err := util.IsDirectory(hostpath) | ||
if err != nil { | ||
return errors.Wrapf(err, "checking if %s is directory", hostpath) | ||
} | ||
if !isDir { | ||
if vmpath == "" { | ||
rPath, err := filepath.Rel(basedir, hostpath) | ||
if err != nil { | ||
return errors.Wrap(err, "generating relative path") | ||
} | ||
rPath = filepath.Dir(rPath) | ||
vmpath = filepath.Join("/", rPath) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I think this one needs to be a path.Join There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well the tricky thing is that I'm using the host path to determine the remote path. so rPath is always the relative path to your MINIKUBE_HOME. Essentially it boils down to - how to do you translate a unix path from a partial windows path? I don't think we can just reverse the slashes and call it day. |
||
} | ||
permString := fmt.Sprintf("%o", info.Mode().Perm()) | ||
// The conversion will strip the leading 0 if present, so add it back | ||
// if we need to. | ||
if len(permString) == 3 { | ||
permString = fmt.Sprintf("0%s", permString) | ||
} | ||
} else if err != nil { | ||
glog.Infoln(fmt.Sprintf("Error encountered while walking %s: ", searchDir), err) | ||
|
||
f, err := NewFileAsset(hostpath, vmpath, filepath.Base(hostpath), permString) | ||
if err != nil { | ||
return errors.Wrapf(err, "creating file asset for %s", hostpath) | ||
} | ||
*assets = append(*assets, f) | ||
} | ||
|
||
return nil | ||
}) | ||
if err != nil { | ||
glog.Infoln(fmt.Sprintf("Error encountered while walking %s: ", searchDir), err) | ||
return errors.Wrap(err, "walking filepath") | ||
} | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this will work with Windows as you stated. Should be able to massage the paths though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the tests will cover this, I don't think any integration tests use the .minikube/files dir.