Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
5b5442be
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,发现更多精彩内容 >>
提交
5b5442be
编写于
5月 31, 2017
作者:
D
dlorenc
提交者:
dlorenc
6月 14, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move more code into the local host implementation.
上级
2ab15662
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
47 addition
and
48 deletion
+47
-48
cmd/minikube/cmd/config/open.go
cmd/minikube/cmd/config/open.go
+1
-1
cmd/minikube/cmd/config/util.go
cmd/minikube/cmd/config/util.go
+1
-9
cmd/minikube/cmd/dashboard.go
cmd/minikube/cmd/dashboard.go
+1
-1
cmd/minikube/cmd/delete.go
cmd/minikube/cmd/delete.go
+1
-1
cmd/minikube/cmd/env.go
cmd/minikube/cmd/env.go
+1
-1
cmd/minikube/cmd/ip.go
cmd/minikube/cmd/ip.go
+1
-1
cmd/minikube/cmd/logs.go
cmd/minikube/cmd/logs.go
+1
-1
cmd/minikube/cmd/mount.go
cmd/minikube/cmd/mount.go
+1
-1
cmd/minikube/cmd/root.go
cmd/minikube/cmd/root.go
+0
-3
cmd/minikube/cmd/service.go
cmd/minikube/cmd/service.go
+1
-1
cmd/minikube/cmd/service_list.go
cmd/minikube/cmd/service_list.go
+1
-1
cmd/minikube/cmd/ssh.go
cmd/minikube/cmd/ssh.go
+1
-1
cmd/minikube/cmd/start.go
cmd/minikube/cmd/start.go
+1
-1
cmd/minikube/cmd/status.go
cmd/minikube/cmd/status.go
+1
-1
cmd/minikube/cmd/stop.go
cmd/minikube/cmd/stop.go
+1
-1
pkg/minikube/machine/client.go
pkg/minikube/machine/client.go
+33
-23
未找到文件。
cmd/minikube/cmd/config/open.go
浏览文件 @
5b5442be
...
...
@@ -57,7 +57,7 @@ var addonsOpenCmd = &cobra.Command{
}
addonName
:=
args
[
0
]
//TODO(r2d4): config should not reference API, pull this out
api
,
err
:=
machine
.
NewAPIClient
(
GetClientType
()
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/config/util.go
浏览文件 @
5b5442be
...
...
@@ -24,7 +24,6 @@ import (
"github.com/docker/machine/libmachine/drivers"
"github.com/pkg/errors"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
...
...
@@ -82,13 +81,6 @@ func SetBool(m config.MinikubeConfig, name string, val string) error {
return
nil
}
func
GetClientType
()
machine
.
ClientType
{
if
viper
.
GetBool
(
useVendoredDriver
)
{
return
machine
.
ClientTypeLocal
}
return
machine
.
ClientTypeRPC
}
func
EnableOrDisableAddon
(
name
string
,
val
string
)
error
{
enable
,
err
:=
strconv
.
ParseBool
(
val
)
...
...
@@ -97,7 +89,7 @@ func EnableOrDisableAddon(name string, val string) error {
}
//TODO(r2d4): config package should not reference API, pull this out
api
,
err
:=
machine
.
NewAPIClient
(
GetClientType
()
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/dashboard.go
浏览文件 @
5b5442be
...
...
@@ -42,7 +42,7 @@ var dashboardCmd = &cobra.Command{
Short
:
"Opens/displays the kubernetes dashboard URL for your local cluster"
,
Long
:
`Opens/displays the kubernetes dashboard URL for your local cluster`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/delete.go
浏览文件 @
5b5442be
...
...
@@ -34,7 +34,7 @@ var deleteCmd = &cobra.Command{
associated files.`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
fmt
.
Println
(
"Deleting local Kubernetes cluster..."
)
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/env.go
浏览文件 @
5b5442be
...
...
@@ -286,7 +286,7 @@ var dockerEnvCmd = &cobra.Command{
Long
:
`sets up docker env variables; similar to '$(docker-machine env)'`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/ip.go
浏览文件 @
5b5442be
...
...
@@ -32,7 +32,7 @@ var ipCmd = &cobra.Command{
Short
:
"Retrieve the IP address of the running cluster."
,
Long
:
`Retrieves the IP address of the running cluster, and writes it to STDOUT.`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/logs.go
浏览文件 @
5b5442be
...
...
@@ -37,7 +37,7 @@ var logsCmd = &cobra.Command{
Short
:
"Gets the logs of the running localkube instance, used for debugging minikube, not user code"
,
Long
:
`Gets the logs of the running localkube instance, used for debugging minikube, not user code.`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/mount.go
浏览文件 @
5b5442be
...
...
@@ -86,7 +86,7 @@ var mountCmd = &cobra.Command{
if
glog
.
V
(
1
)
{
debugVal
=
1
// ufs.StartServer takes int debug param
}
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/root.go
浏览文件 @
5b5442be
...
...
@@ -95,9 +95,6 @@ Please use --v=3 to show libmachine logs, and --v=7 for debug level libmachine l
`
)
}
//TODO(r2d4): config should not reference API
clientType
=
configCmd
.
GetClientType
()
logDir
:=
pflag
.
Lookup
(
"log_dir"
)
if
!
logDir
.
Changed
{
logDir
.
Value
.
Set
(
constants
.
MakeMiniPath
(
"logs"
))
...
...
cmd/minikube/cmd/service.go
浏览文件 @
5b5442be
...
...
@@ -60,7 +60,7 @@ var serviceCmd = &cobra.Command{
}
svc
:=
args
[
0
]
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/service_list.go
浏览文件 @
5b5442be
...
...
@@ -37,7 +37,7 @@ var serviceListCmd = &cobra.Command{
Short
:
"Lists the URLs for the services in your local cluster"
,
Long
:
`Lists the URLs for the services in your local cluster`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/ssh.go
浏览文件 @
5b5442be
...
...
@@ -33,7 +33,7 @@ var sshCmd = &cobra.Command{
Short
:
"Log into or run a command on a machine with SSH; similar to 'docker-machine ssh'"
,
Long
:
"Log into or run a command on a machine with SSH; similar to 'docker-machine ssh'"
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/start.go
浏览文件 @
5b5442be
...
...
@@ -81,7 +81,7 @@ assumes you have already installed one of the VM drivers: virtualbox/vmwarefusio
}
func
runStart
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/status.go
浏览文件 @
5b5442be
...
...
@@ -43,7 +43,7 @@ var statusCmd = &cobra.Command{
Short
:
"Gets the status of a local kubernetes cluster"
,
Long
:
`Gets the status of a local kubernetes cluster.`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
cmd/minikube/cmd/stop.go
浏览文件 @
5b5442be
...
...
@@ -34,7 +34,7 @@ var stopCmd = &cobra.Command{
itself, leaving all files intact. The cluster can be started again with the "start" command.`
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
fmt
.
Println
(
"Stopping local Kubernetes cluster..."
)
api
,
err
:=
machine
.
NewAPIClient
(
clientType
)
api
,
err
:=
machine
.
NewAPIClient
()
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stderr
,
"Error getting client: %s
\n
"
,
err
)
os
.
Exit
(
1
)
...
...
pkg/minikube/machine/client.go
浏览文件 @
5b5442be
...
...
@@ -58,9 +58,10 @@ type localClientFactory struct{}
func
(
*
localClientFactory
)
NewClient
(
storePath
,
certsDir
string
)
libmachine
.
API
{
return
&
LocalClient
{
certsDir
:
certsDir
,
storePath
:
storePath
,
Filestore
:
persist
.
NewFilestore
(
storePath
,
certsDir
,
certsDir
),
certsDir
:
certsDir
,
storePath
:
storePath
,
Filestore
:
persist
.
NewFilestore
(
storePath
,
certsDir
,
certsDir
),
legacyClient
:
(
&
rpcClientFactory
{})
.
NewClient
(
storePath
,
certsDir
),
}
}
...
...
@@ -72,30 +73,18 @@ func (*rpcClientFactory) NewClient(storePath, certsDir string) libmachine.API {
return
c
}
var
clientFactories
=
map
[
ClientType
]
clientFactory
{
// ClientTypeNative: &nativeClientFactory{},
ClientTypeLocal
:
&
localClientFactory
{},
ClientTypeRPC
:
&
rpcClientFactory
{},
}
const
(
ClientTypeLocal
ClientType
=
iota
ClientTypeRPC
// ClientTypeNative
)
// Gets a new client depending on the clientType specified
// defaults to the libmachine client
func
NewAPIClient
(
clientType
ClientType
)
(
libmachine
.
API
,
error
)
{
func
NewAPIClient
()
(
libmachine
.
API
,
error
)
{
storePath
:=
constants
.
GetMinipath
()
certsDir
:=
constants
.
MakeMiniPath
(
"certs"
)
newClientFactory
,
ok
:=
clientFactories
[
clientType
]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"No implementation for API client type %d"
,
clientType
)
}
return
newClientFactory
.
NewClient
(
storePath
,
certsDir
),
nil
return
&
LocalClient
{
certsDir
:
certsDir
,
storePath
:
storePath
,
Filestore
:
persist
.
NewFilestore
(
storePath
,
certsDir
,
certsDir
),
legacyClient
:
(
&
rpcClientFactory
{})
.
NewClient
(
storePath
,
certsDir
),
},
nil
}
func
getDriver
(
driverName
string
,
rawDriver
[]
byte
)
(
drivers
.
Driver
,
error
)
{
...
...
@@ -131,9 +120,15 @@ type LocalClient struct {
certsDir
string
storePath
string
*
persist
.
Filestore
legacyClient
libmachine
.
API
}
func
(
api
*
LocalClient
)
NewHost
(
driverName
string
,
rawDriver
[]
byte
)
(
*
host
.
Host
,
error
)
{
// If not should get Driver, use legacy
if
_
,
ok
:=
driverMap
[
driverName
];
!
ok
{
return
api
.
legacyClient
.
NewHost
(
driverName
,
rawDriver
)
}
driver
,
err
:=
getDriver
(
driverName
,
rawDriver
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"Error getting driver"
)
...
...
@@ -168,6 +163,11 @@ func (api *LocalClient) Load(name string) (*host.Host, error) {
return
nil
,
errors
.
Wrap
(
err
,
"Error loading host from store"
)
}
// If not should get Driver, use legacy
if
_
,
ok
:=
driverMap
[
h
.
DriverName
];
!
ok
{
return
api
.
legacyClient
.
Load
(
name
)
}
h
.
Driver
,
err
=
getDriver
(
h
.
DriverName
,
h
.
RawDriver
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"Error loading driver from host"
)
...
...
@@ -176,9 +176,19 @@ func (api *LocalClient) Load(name string) (*host.Host, error) {
return
h
,
nil
}
func
(
api
*
LocalClient
)
Close
()
error
{
return
nil
}
func
(
api
*
LocalClient
)
Close
()
error
{
if
api
.
legacyClient
!=
nil
{
return
api
.
legacyClient
.
Close
()
}
return
nil
}
func
(
api
*
LocalClient
)
Create
(
h
*
host
.
Host
)
error
{
if
_
,
ok
:=
driverMap
[
h
.
Driver
.
DriverName
()];
!
ok
{
return
api
.
legacyClient
.
Create
(
h
)
}
steps
:=
[]
struct
{
name
string
f
func
()
error
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录