Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
666bde96
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
666bde96
编写于
2月 07, 2020
作者:
T
Thomas Strömberg
提交者:
GitHub
2月 07, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6540 from tstromberg/powershell-env-bugfixes
Fix a variety of bugs in `docker-env` output
上级
10ef863f
c195d5a5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
90 addition
and
160 deletion
+90
-160
cmd/minikube/cmd/env.go
cmd/minikube/cmd/env.go
+51
-62
cmd/minikube/cmd/env_test.go
cmd/minikube/cmd/env_test.go
+39
-98
未找到文件。
cmd/minikube/cmd/env.go
浏览文件 @
666bde96
...
...
@@ -50,20 +50,18 @@ var envTmpl = fmt.Sprintf("{{ .Prefix }}%s{{ .Delimiter }}{{ .DockerTLSVerify }}
const
(
fishSetPfx
=
"set -gx "
fishSetSfx
=
"
\"
;
\n
"
fishSetSfx
=
"
\"\n
"
fishSetDelim
=
"
\"
"
fishUnsetPfx
=
"set -e "
fishUnsetSfx
=
";
\n
"
fishUnsetDelim
=
""
fishUnsetPfx
=
"set -e "
fishUnsetSfx
=
"
\n
"
psSetPfx
=
"$Env:"
psSetSfx
=
"
\"\n
"
psSetDelim
=
" =
\"
"
psUnsetPfx
=
`Remove-Item Env:\\`
psUnsetSfx
=
"
\n
"
psUnsetDelim
=
""
psUnsetPfx
=
`Remove-Item Env:\\`
psUnsetSfx
=
"
\n
"
cmdSetPfx
=
"SET "
cmdSetSfx
=
"
\n
"
...
...
@@ -85,9 +83,8 @@ const (
bashSetSfx
=
"
\"\n
"
bashSetDelim
=
"=
\"
"
bashUnsetPfx
=
"unset "
bashUnsetSfx
=
"
\n
"
bashUnsetDelim
=
""
bashUnsetPfx
=
"unset "
bashUnsetSfx
=
"
\n
"
nonePfx
=
""
noneSfx
=
"
\n
"
...
...
@@ -124,7 +121,7 @@ type NoProxyGetter interface {
type
EnvNoProxyGetter
struct
{}
func
generateUsageHint
(
profile
,
sh
string
)
string
{
const
usgPlz
=
"
Please run command bellow to point your shell to minikube's docker-daemon
:"
const
usgPlz
=
"
To point your shell to minikube's docker-daemon, run
:"
var
usgCmd
=
fmt
.
Sprintf
(
"minikube -p %s docker-env"
,
profile
)
var
usageHintMap
=
map
[
string
]
string
{
"bash"
:
fmt
.
Sprintf
(
`
...
...
@@ -135,18 +132,15 @@ func generateUsageHint(profile, sh string) string {
# %s
# eval (%s)
`
,
usgPlz
,
usgCmd
),
"powershell"
:
fmt
.
Sprintf
(
`
# %s
"powershell"
:
fmt
.
Sprintf
(
`# %s
# & %s | Invoke-Expression
`
,
usgPlz
,
usgCmd
),
"cmd"
:
fmt
.
Sprintf
(
`
REM %s
`
,
usgPlz
,
usgCmd
),
"cmd"
:
fmt
.
Sprintf
(
`REM %s
REM @FOR /f "tokens=*" %%i IN ('%s') DO @%%i
`
,
usgPlz
,
usgCmd
),
"emacs"
:
fmt
.
Sprintf
(
`
;; %s
`
,
usgPlz
,
usgCmd
),
"emacs"
:
fmt
.
Sprintf
(
`;; %s
;; (with-temp-buffer (shell-command "%s" (current-buffer)) (eval-buffer))
`
,
usgPlz
,
usgCmd
),
`
,
usgPlz
,
usgCmd
),
}
hint
,
ok
:=
usageHintMap
[
sh
]
...
...
@@ -213,46 +207,6 @@ func shellCfgSet(ec EnvConfig, envMap map[string]string) *ShellConfig {
return
s
}
// shellCfgUnset generates context variables for "docker-env -u"
func
shellCfgUnset
(
ec
EnvConfig
)
*
ShellConfig
{
s
:=
&
ShellConfig
{
UsageHint
:
generateUsageHint
(
ec
.
profile
,
ec
.
shell
),
}
if
ec
.
noProxy
{
s
.
NoProxyVar
,
s
.
NoProxyValue
=
defaultNoProxyGetter
.
GetNoProxyVar
()
}
switch
ec
.
shell
{
case
"fish"
:
s
.
Prefix
=
fishUnsetPfx
s
.
Suffix
=
fishUnsetSfx
s
.
Delimiter
=
fishUnsetDelim
case
"powershell"
:
s
.
Prefix
=
psUnsetPfx
s
.
Suffix
=
psUnsetSfx
s
.
Delimiter
=
psUnsetDelim
case
"cmd"
:
s
.
Prefix
=
cmdUnsetPfx
s
.
Suffix
=
cmdUnsetSfx
s
.
Delimiter
=
cmdUnsetDelim
case
"emacs"
:
s
.
Prefix
=
emacsUnsetPfx
s
.
Suffix
=
emacsUnsetSfx
s
.
Delimiter
=
emacsUnsetDelim
case
"none"
:
s
.
Prefix
=
nonePfx
s
.
Suffix
=
noneSfx
s
.
Delimiter
=
noneDelim
s
.
UsageHint
=
""
default
:
s
.
Prefix
=
bashUnsetPfx
s
.
Suffix
=
bashUnsetSfx
s
.
Delimiter
=
bashUnsetDelim
}
return
s
}
// GetNoProxyVar gets the no_proxy var
func
(
EnvNoProxyGetter
)
GetNoProxyVar
()
(
string
,
string
)
{
// first check for an existing lower case no_proxy var
...
...
@@ -379,8 +333,43 @@ func setScript(ec EnvConfig, w io.Writer) error {
// setScript writes out a shell-compatible 'docker-env unset' script
func
unsetScript
(
ec
EnvConfig
,
w
io
.
Writer
)
error
{
tmpl
:=
template
.
Must
(
template
.
New
(
"envConfig"
)
.
Parse
(
envTmpl
))
return
tmpl
.
Execute
(
w
,
shellCfgUnset
(
ec
))
vars
:=
[]
string
{
constants
.
DockerTLSVerifyEnv
,
constants
.
DockerHostEnv
,
constants
.
DockerCertPathEnv
,
constants
.
MinikubeActiveDockerdEnv
,
}
if
ec
.
noProxy
{
k
,
_
:=
defaultNoProxyGetter
.
GetNoProxyVar
()
if
k
!=
""
{
vars
=
append
(
vars
,
k
)
}
}
var
sb
strings
.
Builder
switch
ec
.
shell
{
case
"fish"
:
for
_
,
v
:=
range
vars
{
sb
.
WriteString
(
fmt
.
Sprintf
(
"%s%s%s"
,
fishUnsetPfx
,
v
,
fishUnsetSfx
))
}
case
"powershell"
:
sb
.
WriteString
(
fmt
.
Sprintf
(
"%s%s%s"
,
psUnsetPfx
,
strings
.
Join
(
vars
,
" Env:
\\\\
"
),
psUnsetSfx
))
case
"cmd"
:
for
_
,
v
:=
range
vars
{
sb
.
WriteString
(
fmt
.
Sprintf
(
"%s%s%s%s"
,
cmdUnsetPfx
,
v
,
cmdUnsetDelim
,
cmdUnsetSfx
))
}
case
"emacs"
:
for
_
,
v
:=
range
vars
{
sb
.
WriteString
(
fmt
.
Sprintf
(
"%s%s%s%s"
,
emacsUnsetPfx
,
v
,
emacsUnsetDelim
,
emacsUnsetSfx
))
}
case
"none"
:
sb
.
WriteString
(
fmt
.
Sprintf
(
"%s%s%s"
,
nonePfx
,
strings
.
Join
(
vars
,
" "
),
noneSfx
))
default
:
sb
.
WriteString
(
fmt
.
Sprintf
(
"%s%s%s"
,
bashUnsetPfx
,
strings
.
Join
(
vars
,
" "
),
bashUnsetSfx
))
}
_
,
err
:=
w
.
Write
([]
byte
(
sb
.
String
()))
return
err
}
// dockerURL returns a the docker endpoint URL for an ip/port pair.
...
...
cmd/minikube/cmd/env_test.go
浏览文件 @
666bde96
...
...
@@ -47,16 +47,10 @@ export DOCKER_HOST="tcp://127.0.0.1:2376"
export DOCKER_CERT_PATH="/certs"
export MINIKUBE_ACTIVE_DOCKERD="bash"
#
Please run command bellow to point your shell to minikube's docker-daemon
:
#
To point your shell to minikube's docker-daemon, run
:
# eval $(minikube -p bash docker-env)
`
,
`unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset MINIKUBE_ACTIVE_DOCKERD
# Please run command bellow to point your shell to minikube's docker-daemon :
# eval $(minikube -p bash docker-env)
`unset DOCKER_TLS_VERIFY DOCKER_HOST DOCKER_CERT_PATH MINIKUBE_ACTIVE_DOCKERD
`
,
},
{
...
...
@@ -67,36 +61,27 @@ export DOCKER_HOST="tcp://[fe80::215:5dff:fe00:a903]:2376"
export DOCKER_CERT_PATH="/certs"
export MINIKUBE_ACTIVE_DOCKERD="ipv6"
#
Please run command bellow to point your shell to minikube's docker-daemon
:
#
To point your shell to minikube's docker-daemon, run
:
# eval $(minikube -p ipv6 docker-env)
`
,
`unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset MINIKUBE_ACTIVE_DOCKERD
# Please run command bellow to point your shell to minikube's docker-daemon :
# eval $(minikube -p ipv6 docker-env)
`unset DOCKER_TLS_VERIFY DOCKER_HOST DOCKER_CERT_PATH MINIKUBE_ACTIVE_DOCKERD
`
,
},
{
EnvConfig
{
profile
:
"fish"
,
shell
:
"fish"
,
driver
:
"kvm2"
,
hostIP
:
"127.0.0.1"
,
certsDir
:
"/certs"
},
nil
,
`set -gx DOCKER_TLS_VERIFY "1"
;
set -gx DOCKER_HOST "tcp://127.0.0.1:2376"
;
set -gx DOCKER_CERT_PATH "/certs"
;
set -gx MINIKUBE_ACTIVE_DOCKERD "fish"
;
`set -gx DOCKER_TLS_VERIFY "1"
set -gx DOCKER_HOST "tcp://127.0.0.1:2376"
set -gx DOCKER_CERT_PATH "/certs"
set -gx MINIKUBE_ACTIVE_DOCKERD "fish"
#
Please run command bellow to point your shell to minikube's docker-daemon
:
#
To point your shell to minikube's docker-daemon, run
:
# eval (minikube -p fish docker-env)
`
,
`set -e DOCKER_TLS_VERIFY;
set -e DOCKER_HOST;
set -e DOCKER_CERT_PATH;
set -e MINIKUBE_ACTIVE_DOCKERD;
# Please run command bellow to point your shell to minikube's docker-daemon :
# eval (minikube -p fish docker-env)
`set -e DOCKER_TLS_VERIFY
set -e DOCKER_HOST
set -e DOCKER_CERT_PATH
set -e MINIKUBE_ACTIVE_DOCKERD
`
,
},
{
...
...
@@ -106,19 +91,12 @@ set -e MINIKUBE_ACTIVE_DOCKERD;
$Env:DOCKER_HOST = "tcp://192.168.0.1:2376"
$Env:DOCKER_CERT_PATH = "/certs"
$Env:MINIKUBE_ACTIVE_DOCKERD = "powershell"
# Please run command bellow to point your shell to minikube's docker-daemon :
# To point your shell to minikube's docker-daemon, run:
# & minikube -p powershell docker-env | Invoke-Expression
`
,
`Remove-Item Env:\\DOCKER_TLS_VERIFY
Remove-Item Env:\\DOCKER_HOST
Remove-Item Env:\\DOCKER_CERT_PATH
Remove-Item Env:\\MINIKUBE_ACTIVE_DOCKERD
`
,
# Please run command bellow to point your shell to minikube's docker-daemon :
# & minikube -p powershell docker-env | Invoke-Expression
`
,
`Remove-Item Env:\\DOCKER_TLS_VERIFY Env:\\DOCKER_HOST Env:\\DOCKER_CERT_PATH Env:\\MINIKUBE_ACTIVE_DOCKERD
`
,
},
{
EnvConfig
{
profile
:
"cmd"
,
shell
:
"cmd"
,
driver
:
"hyperv"
,
hostIP
:
"192.168.0.1"
,
certsDir
:
"/certs"
},
...
...
@@ -127,19 +105,15 @@ Remove-Item Env:\\MINIKUBE_ACTIVE_DOCKERD
SET DOCKER_HOST=tcp://192.168.0.1:2376
SET DOCKER_CERT_PATH=/certs
SET MINIKUBE_ACTIVE_DOCKERD=cmd
REM Please run command bellow to point your shell to minikube's docker-daemon :
REM To point your shell to minikube's docker-daemon, run:
REM @FOR /f "tokens=*" %i IN ('minikube -p cmd docker-env') DO @%i
`
,
`
,
`SET DOCKER_TLS_VERIFY=
SET DOCKER_HOST=
SET DOCKER_CERT_PATH=
SET MINIKUBE_ACTIVE_DOCKERD=
REM Please run command bellow to point your shell to minikube's docker-daemon :
REM @FOR /f "tokens=*" %i IN ('minikube -p cmd docker-env') DO @%i
`
,
`
,
},
{
EnvConfig
{
profile
:
"emacs"
,
shell
:
"emacs"
,
driver
:
"hyperv"
,
hostIP
:
"192.168.0.1"
,
certsDir
:
"/certs"
},
...
...
@@ -148,18 +122,14 @@ REM @FOR /f "tokens=*" %i IN ('minikube -p cmd docker-env') DO @%i
(setenv "DOCKER_HOST" "tcp://192.168.0.1:2376")
(setenv "DOCKER_CERT_PATH" "/certs")
(setenv "MINIKUBE_ACTIVE_DOCKERD" "emacs")
;; Please run command bellow to point your shell to minikube's docker-daemon :
;; To point your shell to minikube's docker-daemon, run:
;; (with-temp-buffer (shell-command "minikube -p emacs docker-env" (current-buffer)) (eval-buffer))
`
,
`
,
`(setenv "DOCKER_TLS_VERIFY" nil)
(setenv "DOCKER_HOST" nil)
(setenv "DOCKER_CERT_PATH" nil)
(setenv "MINIKUBE_ACTIVE_DOCKERD" nil)
;; Please run command bellow to point your shell to minikube's docker-daemon :
;; (with-temp-buffer (shell-command "minikube -p emacs docker-env" (current-buffer)) (eval-buffer))
`
,
`
,
},
{
EnvConfig
{
profile
:
"bash-no-proxy"
,
shell
:
"bash"
,
driver
:
"kvm2"
,
hostIP
:
"127.0.0.1"
,
certsDir
:
"/certs"
,
noProxy
:
true
},
...
...
@@ -170,18 +140,11 @@ export DOCKER_CERT_PATH="/certs"
export MINIKUBE_ACTIVE_DOCKERD="bash-no-proxy"
export NO_PROXY="127.0.0.1"
#
Please run command bellow to point your shell to minikube's docker-daemon
:
#
To point your shell to minikube's docker-daemon, run
:
# eval $(minikube -p bash-no-proxy docker-env)
`
,
`unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset MINIKUBE_ACTIVE_DOCKERD
unset NO_PROXY127.0.0.1
# Please run command bellow to point your shell to minikube's docker-daemon :
# eval $(minikube -p bash-no-proxy docker-env)
`unset DOCKER_TLS_VERIFY DOCKER_HOST DOCKER_CERT_PATH MINIKUBE_ACTIVE_DOCKERD NO_PROXY
`
,
},
{
...
...
@@ -193,41 +156,26 @@ export DOCKER_CERT_PATH="/certs"
export MINIKUBE_ACTIVE_DOCKERD="bash-no-proxy-lower"
export no_proxy="127.0.0.1"
#
Please run command bellow to point your shell to minikube's docker-daemon
:
#
To point your shell to minikube's docker-daemon, run
:
# eval $(minikube -p bash-no-proxy-lower docker-env)
`
,
`unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset MINIKUBE_ACTIVE_DOCKERD
unset no_proxy127.0.0.1
# Please run command bellow to point your shell to minikube's docker-daemon :
# eval $(minikube -p bash-no-proxy-lower docker-env)
`unset DOCKER_TLS_VERIFY DOCKER_HOST DOCKER_CERT_PATH MINIKUBE_ACTIVE_DOCKERD no_proxy
`
,
},
{
EnvConfig
{
profile
:
"bash-no-proxy-idempotent"
,
shell
:
"bash"
,
driver
:
"kvm2"
,
hostIP
:
"127.0.0.1"
,
certsDir
:
"/certs"
,
noProxy
:
true
},
&
FakeNoProxyGetter
{
"no_proxy"
,
"127.0.0.1"
},
`export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://127.0.0.1:2376"
export DOCKER_CERT_PATH="/certs"
export MINIKUBE_ACTIVE_DOCKERD="bash-no-proxy-idempotent"
export no_proxy="127.0.0.1"
# Please run command bellow to point your shell to minikube's docker-daemon :
# eval $(minikube -p bash-no-proxy-idempotent docker-env)
EnvConfig
{
profile
:
"powershell-no-proxy-idempotent"
,
shell
:
"powershell"
,
driver
:
"hyperv"
,
hostIP
:
"192.168.0.1"
,
certsDir
:
"/certs"
,
noProxy
:
true
},
&
FakeNoProxyGetter
{
"no_proxy"
,
"192.168.0.1"
},
`$Env:DOCKER_TLS_VERIFY = "1"
$Env:DOCKER_HOST = "tcp://192.168.0.1:2376"
$Env:DOCKER_CERT_PATH = "/certs"
$Env:MINIKUBE_ACTIVE_DOCKERD = "powershell-no-proxy-idempotent"
$Env:no_proxy = "192.168.0.1"
# To point your shell to minikube's docker-daemon, run:
# & minikube -p powershell-no-proxy-idempotent docker-env | Invoke-Expression
`
,
`unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset MINIKUBE_ACTIVE_DOCKERD
unset no_proxy127.0.0.1
# Please run command bellow to point your shell to minikube's docker-daemon :
# eval $(minikube -p bash-no-proxy-idempotent docker-env)
`Remove-Item Env:\\DOCKER_TLS_VERIFY Env:\\DOCKER_HOST Env:\\DOCKER_CERT_PATH Env:\\MINIKUBE_ACTIVE_DOCKERD Env:\\no_proxy
`
,
},
{
...
...
@@ -239,18 +187,11 @@ export DOCKER_CERT_PATH="/certs"
export MINIKUBE_ACTIVE_DOCKERD="sh-no-proxy-add"
export NO_PROXY="192.168.0.1,10.0.0.4,127.0.0.1"
#
Please run command bellow to point your shell to minikube's docker-daemon
:
#
To point your shell to minikube's docker-daemon, run
:
# eval $(minikube -p sh-no-proxy-add docker-env)
`
,
`unset DOCKER_TLS_VERIFY
unset DOCKER_HOST
unset DOCKER_CERT_PATH
unset MINIKUBE_ACTIVE_DOCKERD
unset NO_PROXY192.168.0.1,10.0.0.4
# Please run command bellow to point your shell to minikube's docker-daemon :
# eval $(minikube -p sh-no-proxy-add docker-env)
`unset DOCKER_TLS_VERIFY DOCKER_HOST DOCKER_CERT_PATH MINIKUBE_ACTIVE_DOCKERD NO_PROXY
`
,
},
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录