Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
c5becb36
M
minikube
项目概览
Chu Peng 楚鹏
/
minikube
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
minikube
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c5becb36
编写于
6月 09, 2017
作者:
T
Travis Cline
提交者:
dlorenc
6月 22, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow control of user and group ids for mount
上级
55ea14fb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
6 deletion
+14
-6
cmd/minikube/cmd/mount.go
cmd/minikube/cmd/mount.go
+6
-2
pkg/minikube/cluster/cluster.go
pkg/minikube/cluster/cluster.go
+2
-2
pkg/minikube/cluster/commands.go
pkg/minikube/cluster/commands.go
+6
-2
未找到文件。
cmd/minikube/cmd/mount.go
浏览文件 @
c5becb36
...
...
@@ -35,6 +35,8 @@ import (
var
mountIP
string
var
isKill
bool
var
uid
int
var
gid
int
// mountCmd represents the mount command
var
mountCmd
=
&
cobra
.
Command
{
...
...
@@ -52,7 +54,7 @@ var mountCmd = &cobra.Command{
if
len
(
args
)
!=
1
{
errText
:=
`Please specify the directory to be mounted:
\t
minikube mount HOST_MOUNT_DIRECTORY:VM_MOUNT_DIRECTORY(ex:"/host-home:/vm-home")
minikube mount HOST_MOUNT_DIRECTORY:VM_MOUNT_DIRECTORY(ex:"/host-home:/vm-home")
`
fmt
.
Fprintln
(
os
.
Stderr
,
errText
)
os
.
Exit
(
1
)
...
...
@@ -128,7 +130,7 @@ var mountCmd = &cobra.Command{
ufs
.
StartServer
(
net
.
JoinHostPort
(
ip
.
String
(),
port
),
debugVal
,
hostPath
)
wg
.
Done
()
}()
err
=
cluster
.
MountHost
(
api
,
vmPath
,
ip
,
port
)
err
=
cluster
.
MountHost
(
api
,
vmPath
,
ip
,
port
,
uid
,
gid
)
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
os
.
Exit
(
1
)
...
...
@@ -140,5 +142,7 @@ var mountCmd = &cobra.Command{
func
init
()
{
mountCmd
.
Flags
()
.
StringVar
(
&
mountIP
,
"ip"
,
""
,
"Specify the ip that the mount should be setup on"
)
mountCmd
.
Flags
()
.
BoolVar
(
&
isKill
,
"kill"
,
false
,
"Kill the mount process spawned by minikube start"
)
mountCmd
.
Flags
()
.
IntVar
(
&
uid
,
"uid"
,
1001
,
"Default user id used for the mount"
)
mountCmd
.
Flags
()
.
IntVar
(
&
gid
,
"gid"
,
1001
,
"Default group id used for the mount"
)
RootCmd
.
AddCommand
(
mountCmd
)
}
pkg/minikube/cluster/cluster.go
浏览文件 @
c5becb36
...
...
@@ -449,7 +449,7 @@ func GetHostLogs(api libmachine.API, follow bool) (string, error) {
}
// MountHost runs the mount command from the 9p client on the VM to the 9p server on the host
func
MountHost
(
api
libmachine
.
API
,
path
string
,
ip
net
.
IP
,
port
string
)
error
{
func
MountHost
(
api
libmachine
.
API
,
path
string
,
ip
net
.
IP
,
port
string
,
uid
,
gid
int
)
error
{
host
,
err
:=
CheckIfApiExistsAndLoad
(
api
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"Error checking that api exists and loading it"
)
...
...
@@ -461,7 +461,7 @@ func MountHost(api libmachine.API, path string, ip net.IP, port string) error {
}
}
host
.
RunSSHCommand
(
GetMountCleanupCommand
(
path
))
mountCmd
,
err
:=
GetMountCommand
(
ip
,
path
,
port
)
mountCmd
,
err
:=
GetMountCommand
(
ip
,
path
,
port
,
uid
,
gid
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"Error getting mount command"
)
}
...
...
pkg/minikube/cluster/commands.go
浏览文件 @
c5becb36
...
...
@@ -233,20 +233,24 @@ func GetMountCleanupCommand(path string) string {
var
mountTemplate
=
`
sudo mkdir -p {{.Path}} || true;
sudo mount -t 9p -o trans=tcp -o port={{.Port}} -o uid=
1001 -o gid=1001
{{.IP}} {{.Path}};
sudo mount -t 9p -o trans=tcp -o port={{.Port}} -o uid=
{{.UID}} -o gid={{.GID}}
{{.IP}} {{.Path}};
sudo chmod 775 {{.Path}};`
func
GetMountCommand
(
ip
net
.
IP
,
path
string
,
port
string
)
(
string
,
error
)
{
func
GetMountCommand
(
ip
net
.
IP
,
path
,
port
string
,
uid
,
gid
int
)
(
string
,
error
)
{
t
:=
template
.
Must
(
template
.
New
(
"mountCommand"
)
.
Parse
(
mountTemplate
))
buf
:=
bytes
.
Buffer
{}
data
:=
struct
{
IP
string
Path
string
Port
string
UID
int
GID
int
}{
IP
:
ip
.
String
(),
Path
:
path
,
Port
:
port
,
UID
:
uid
,
GID
:
gid
,
}
if
err
:=
t
.
Execute
(
&
buf
,
data
);
err
!=
nil
{
return
""
,
err
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录