Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
99ac1a81
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 搜索 >>
提交
99ac1a81
编写于
7月 04, 2019
作者:
M
Medya Gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moving command runner to its own package
上级
68c546ff
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
42 addition
and
35 deletion
+42
-35
cmd/minikube/cmd/config/util.go
cmd/minikube/cmd/config/util.go
+2
-2
cmd/minikube/cmd/start.go
cmd/minikube/cmd/start.go
+2
-1
pkg/drivers/hyperkit/driver_test.go
pkg/drivers/hyperkit/driver_test.go
+1
-1
pkg/drivers/none/none.go
pkg/drivers/none/none.go
+7
-7
pkg/minikube/bootstrapper/certs.go
pkg/minikube/bootstrapper/certs.go
+2
-1
pkg/minikube/bootstrapper/certs_test.go
pkg/minikube/bootstrapper/certs_test.go
+2
-1
pkg/minikube/bootstrapper/kubeadm/kubeadm.go
pkg/minikube/bootstrapper/kubeadm/kubeadm.go
+3
-2
pkg/minikube/command/command_runner.go
pkg/minikube/command/command_runner.go
+3
-3
pkg/minikube/command/exec_runner.go
pkg/minikube/command/exec_runner.go
+1
-1
pkg/minikube/command/fake_runner.go
pkg/minikube/command/fake_runner.go
+1
-1
pkg/minikube/command/ssh_runner.go
pkg/minikube/command/ssh_runner.go
+1
-1
pkg/minikube/cruntime/cruntime.go
pkg/minikube/cruntime/cruntime.go
+1
-1
pkg/minikube/logs/logs.go
pkg/minikube/logs/logs.go
+4
-3
pkg/minikube/machine/cache_binaries.go
pkg/minikube/machine/cache_binaries.go
+2
-1
pkg/minikube/machine/cache_images.go
pkg/minikube/machine/cache_images.go
+3
-2
pkg/minikube/machine/client.go
pkg/minikube/machine/client.go
+4
-4
pkg/provision/buildroot.go
pkg/provision/buildroot.go
+3
-3
未找到文件。
cmd/minikube/cmd/config/util.go
浏览文件 @
99ac1a81
...
...
@@ -24,8 +24,8 @@ import (
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/console"
"k8s.io/minikube/pkg/minikube/constants"
...
...
@@ -154,7 +154,7 @@ func isAddonAlreadySet(addon *assets.Addon, enable bool) error {
return
nil
}
func
enableOrDisableAddonInternal
(
addon
*
assets
.
Addon
,
cmd
bootstrapper
.
Command
Runner
,
data
interface
{},
enable
bool
)
error
{
func
enableOrDisableAddonInternal
(
addon
*
assets
.
Addon
,
cmd
command
.
Runner
,
data
interface
{},
enable
bool
)
error
{
var
err
error
// check addon status before enabling/disabling it
if
err
:=
isAddonAlreadySet
(
addon
,
enable
);
err
!=
nil
{
...
...
cmd/minikube/cmd/start.go
浏览文件 @
99ac1a81
...
...
@@ -48,6 +48,7 @@ import (
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/command"
cfg
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/console"
"k8s.io/minikube/pkg/minikube/constants"
...
...
@@ -756,7 +757,7 @@ func configureRuntimes(runner cruntime.CommandRunner) cruntime.Manager {
}
// bootstrapCluster starts Kubernetes using the chosen bootstrapper
func
bootstrapCluster
(
bs
bootstrapper
.
Bootstrapper
,
r
cruntime
.
Manager
,
runner
bootstrapper
.
Command
Runner
,
kc
cfg
.
KubernetesConfig
,
preexisting
bool
,
isUpgrade
bool
)
{
func
bootstrapCluster
(
bs
bootstrapper
.
Bootstrapper
,
r
cruntime
.
Manager
,
runner
command
.
Runner
,
kc
cfg
.
KubernetesConfig
,
preexisting
bool
,
isUpgrade
bool
)
{
// hum. bootstrapper.Bootstrapper should probably have a Name function.
bsName
:=
viper
.
GetString
(
cmdcfg
.
Bootstrapper
)
...
...
pkg/drivers/hyperkit/driver_test.go
浏览文件 @
99ac1a81
...
...
@@ -67,7 +67,7 @@ func Test_portExtraction(t *testing.T) {
}
func
Test_defaultDiskSize
(
t
*
testing
.
T
)
{
expectedDefaultDiscSize
:=
commonutil
.
Calculate
Disk
SizeInMB
(
constants
.
DefaultDiskSize
)
expectedDefaultDiscSize
:=
commonutil
.
CalculateSizeInMB
(
constants
.
DefaultDiskSize
)
driver
:=
NewDriver
(
""
,
""
)
got
:=
driver
.
DiskSize
if
got
!=
expectedDefaultDiscSize
{
...
...
pkg/drivers/none/none.go
浏览文件 @
99ac1a81
...
...
@@ -25,8 +25,8 @@ import (
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/net"
pkgdrivers
"k8s.io/minikube/pkg/drivers"
// TODO(tstromberg): Extract CommandRunner into its own package
"k8s.io/minikube/pkg/minikube/
bootstrapper
"
pkgdrivers
"k8s.io/minikube/pkg/drivers"
"k8s.io/minikube/pkg/minikube/
command
"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/cruntime"
)
...
...
@@ -47,7 +47,7 @@ type Driver struct {
*
pkgdrivers
.
CommonDriver
URL
string
runtime
cruntime
.
Manager
exec
bootstrapper
.
Command
Runner
exec
command
.
Runner
}
// Config is configuration for the None driver
...
...
@@ -59,7 +59,7 @@ type Config struct {
// NewDriver returns a fully configured None driver
func
NewDriver
(
c
Config
)
*
Driver
{
runner
:=
&
bootstrapper
.
ExecRunner
{}
runner
:=
&
command
.
ExecRunner
{}
runtime
,
err
:=
cruntime
.
New
(
cruntime
.
Config
{
Type
:
c
.
ContainerRuntime
,
Runner
:
runner
})
// Libraries shouldn't panic, but there is no way for drivers to return error :(
if
err
!=
nil
{
...
...
@@ -216,19 +216,19 @@ func (d *Driver) RunSSHCommandFromDriver() error {
}
// stopKubelet idempotently stops the kubelet
func
stopKubelet
(
exec
bootstrapper
.
Command
Runner
)
error
{
func
stopKubelet
(
exec
command
.
Runner
)
error
{
glog
.
Infof
(
"stopping kubelet.service ..."
)
return
exec
.
Run
(
"sudo systemctl stop kubelet.service"
)
}
// restartKubelet restarts the kubelet
func
restartKubelet
(
exec
bootstrapper
.
Command
Runner
)
error
{
func
restartKubelet
(
exec
command
.
Runner
)
error
{
glog
.
Infof
(
"restarting kubelet.service ..."
)
return
exec
.
Run
(
"sudo systemctl restart kubelet.service"
)
}
// checkKubelet returns an error if the kubelet is not running.
func
checkKubelet
(
exec
bootstrapper
.
Command
Runner
)
error
{
func
checkKubelet
(
exec
command
.
Runner
)
error
{
glog
.
Infof
(
"checking for running kubelet ..."
)
return
exec
.
Run
(
"systemctl is-active --quiet service kubelet"
)
}
pkg/minikube/bootstrapper/certs.go
浏览文件 @
99ac1a81
...
...
@@ -29,6 +29,7 @@ import (
"k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/tools/clientcmd/api/latest"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/util"
...
...
@@ -42,7 +43,7 @@ var (
)
// SetupCerts gets the generated credentials required to talk to the APIServer.
func
SetupCerts
(
cmd
Command
Runner
,
k8s
config
.
KubernetesConfig
)
error
{
func
SetupCerts
(
cmd
command
.
Runner
,
k8s
config
.
KubernetesConfig
)
error
{
localPath
:=
constants
.
GetMinipath
()
glog
.
Infof
(
"Setting up certificates for IP: %s
\n
"
,
k8s
.
NodeIP
)
...
...
pkg/minikube/bootstrapper/certs_test.go
浏览文件 @
99ac1a81
...
...
@@ -21,6 +21,7 @@ import (
"path/filepath"
"testing"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/tests"
...
...
@@ -31,7 +32,7 @@ func TestSetupCerts(t *testing.T) {
tempDir
:=
tests
.
MakeTempDir
()
defer
os
.
RemoveAll
(
tempDir
)
f
:=
NewFakeCommandRunner
()
f
:=
command
.
NewFakeCommandRunner
()
k8s
:=
config
.
KubernetesConfig
{
APIServerName
:
constants
.
APIServerName
,
DNSDomain
:
constants
.
ClusterDNSDomain
,
...
...
pkg/minikube/bootstrapper/kubeadm/kubeadm.go
浏览文件 @
99ac1a81
...
...
@@ -36,6 +36,7 @@ import (
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/console"
"k8s.io/minikube/pkg/minikube/constants"
...
...
@@ -94,7 +95,7 @@ var SkipAdditionalPreflights = map[string][]string{}
// Bootstrapper is a bootstrapper using kubeadm
type
Bootstrapper
struct
{
c
bootstrapper
.
Command
Runner
c
command
.
Runner
}
// NewKubeadmBootstrapper creates a new kubeadm.Bootstrapper
...
...
@@ -640,7 +641,7 @@ func copyConfig(cfg config.KubernetesConfig, files []assets.CopyableFile, kubead
return
files
}
func
downloadBinaries
(
cfg
config
.
KubernetesConfig
,
c
bootstrapper
.
Command
Runner
)
error
{
func
downloadBinaries
(
cfg
config
.
KubernetesConfig
,
c
command
.
Runner
)
error
{
var
g
errgroup
.
Group
for
_
,
bin
:=
range
constants
.
GetKubeadmCachedBinaries
()
{
bin
:=
bin
...
...
pkg/minikube/
bootstrapper
/command_runner.go
→
pkg/minikube/
command
/command_runner.go
浏览文件 @
99ac1a81
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
bootstrapper
package
command
import
(
"fmt"
...
...
@@ -24,8 +24,8 @@ import (
"k8s.io/minikube/pkg/minikube/assets"
)
//
Command
Runner represents an interface to run commands.
type
Command
Runner
interface
{
// Runner represents an interface to run commands.
type
Runner
interface
{
// Run starts the specified command and waits for it to complete.
Run
(
cmd
string
)
error
...
...
pkg/minikube/
bootstrapper
/exec_runner.go
→
pkg/minikube/
command
/exec_runner.go
浏览文件 @
99ac1a81
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
bootstrapper
package
command
import
(
"bytes"
...
...
pkg/minikube/
bootstrapper
/fake_runner.go
→
pkg/minikube/
command
/fake_runner.go
浏览文件 @
99ac1a81
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
bootstrapper
package
command
import
(
"bytes"
...
...
pkg/minikube/
bootstrapper
/ssh_runner.go
→
pkg/minikube/
command
/ssh_runner.go
浏览文件 @
99ac1a81
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
bootstrapper
package
command
import
(
"bytes"
...
...
pkg/minikube/cruntime/cruntime.go
浏览文件 @
99ac1a81
...
...
@@ -25,7 +25,7 @@ import (
"k8s.io/minikube/pkg/minikube/console"
)
// CommandRunner is the subset of
bootstrapper.Command
Runner this package consumes
// CommandRunner is the subset of
command.
Runner this package consumes
type
CommandRunner
interface
{
Run
(
string
)
error
CombinedOutput
(
string
)
(
string
,
error
)
...
...
pkg/minikube/logs/logs.go
浏览文件 @
99ac1a81
...
...
@@ -28,6 +28,7 @@ import (
"github.com/golang/glog"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/console"
"k8s.io/minikube/pkg/minikube/cruntime"
)
...
...
@@ -54,7 +55,7 @@ var importantPods = []string{
const
lookBackwardsCount
=
200
// Follow follows logs from multiple files in tail(1) format
func
Follow
(
r
cruntime
.
Manager
,
bs
bootstrapper
.
Bootstrapper
,
runner
bootstrapper
.
Command
Runner
)
error
{
func
Follow
(
r
cruntime
.
Manager
,
bs
bootstrapper
.
Bootstrapper
,
runner
command
.
Runner
)
error
{
cs
:=
[]
string
{}
for
_
,
v
:=
range
logCommands
(
r
,
bs
,
0
,
true
)
{
cs
=
append
(
cs
,
v
+
" &"
)
...
...
@@ -69,7 +70,7 @@ func IsProblem(line string) bool {
}
// FindProblems finds possible root causes among the logs
func
FindProblems
(
r
cruntime
.
Manager
,
bs
bootstrapper
.
Bootstrapper
,
runner
bootstrapper
.
Command
Runner
)
map
[
string
][]
string
{
func
FindProblems
(
r
cruntime
.
Manager
,
bs
bootstrapper
.
Bootstrapper
,
runner
command
.
Runner
)
map
[
string
][]
string
{
pMap
:=
map
[
string
][]
string
{}
cmds
:=
logCommands
(
r
,
bs
,
lookBackwardsCount
,
false
)
for
name
,
cmd
:=
range
cmds
{
...
...
@@ -110,7 +111,7 @@ func OutputProblems(problems map[string][]string, maxLines int) {
}
// Output displays logs from multiple sources in tail(1) format
func
Output
(
r
cruntime
.
Manager
,
bs
bootstrapper
.
Bootstrapper
,
runner
bootstrapper
.
Command
Runner
,
lines
int
)
error
{
func
Output
(
r
cruntime
.
Manager
,
bs
bootstrapper
.
Bootstrapper
,
runner
command
.
Runner
,
lines
int
)
error
{
cmds
:=
logCommands
(
r
,
bs
,
lines
,
false
)
// These are not technically logs, but are useful to have in bug reports.
...
...
pkg/minikube/machine/cache_binaries.go
浏览文件 @
99ac1a81
...
...
@@ -28,6 +28,7 @@ import (
"golang.org/x/sync/errgroup"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/console"
"k8s.io/minikube/pkg/minikube/constants"
)
...
...
@@ -90,7 +91,7 @@ func CacheBinary(binary, version, osName, archName string) (string, error) {
}
// CopyBinary copies previously cached binaries into the path
func
CopyBinary
(
cr
bootstrapper
.
Command
Runner
,
binary
,
path
string
)
error
{
func
CopyBinary
(
cr
command
.
Runner
,
binary
,
path
string
)
error
{
f
,
err
:=
assets
.
NewFileAsset
(
path
,
"/usr/bin"
,
binary
,
"0755"
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"new file asset"
)
...
...
pkg/minikube/machine/cache_images.go
浏览文件 @
99ac1a81
...
...
@@ -35,6 +35,7 @@ import (
"golang.org/x/sync/errgroup"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/bootstrapper"
"k8s.io/minikube/pkg/minikube/command"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/cruntime"
...
...
@@ -84,7 +85,7 @@ func CacheImages(images []string, cacheDir string) error {
}
// LoadImages loads previously cached images into the container runtime
func
LoadImages
(
cmd
bootstrapper
.
Command
Runner
,
images
[]
string
,
cacheDir
string
)
error
{
func
LoadImages
(
cmd
command
.
Runner
,
images
[]
string
,
cacheDir
string
)
error
{
var
g
errgroup
.
Group
// Load profile cluster config from file
cc
,
err
:=
config
.
Load
()
...
...
@@ -194,7 +195,7 @@ func getWindowsVolumeNameCmd(d string) (string, error) {
}
// loadImageFromCache loads a single image from the cache
func
loadImageFromCache
(
cr
bootstrapper
.
Command
Runner
,
k8s
config
.
KubernetesConfig
,
src
string
)
error
{
func
loadImageFromCache
(
cr
command
.
Runner
,
k8s
config
.
KubernetesConfig
,
src
string
)
error
{
glog
.
Infof
(
"Loading image from cache: %s"
,
src
)
filename
:=
filepath
.
Base
(
src
)
if
_
,
err
:=
os
.
Stat
(
src
);
err
!=
nil
{
...
...
pkg/minikube/machine/client.go
浏览文件 @
99ac1a81
...
...
@@ -40,7 +40,7 @@ import (
"github.com/docker/machine/libmachine/swarm"
"github.com/docker/machine/libmachine/version"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/
bootstrapper
"
"k8s.io/minikube/pkg/minikube/
command
"
"k8s.io/minikube/pkg/minikube/constants"
"k8s.io/minikube/pkg/minikube/exit"
"k8s.io/minikube/pkg/minikube/registry"
...
...
@@ -145,15 +145,15 @@ func (api *LocalClient) Close() error {
}
// CommandRunner returns best available command runner for this host
func
CommandRunner
(
h
*
host
.
Host
)
(
bootstrapper
.
Command
Runner
,
error
)
{
func
CommandRunner
(
h
*
host
.
Host
)
(
command
.
Runner
,
error
)
{
if
h
.
DriverName
==
constants
.
DriverNone
{
return
&
bootstrapper
.
ExecRunner
{},
nil
return
&
command
.
ExecRunner
{},
nil
}
client
,
err
:=
sshutil
.
NewSSHClient
(
h
.
Driver
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"getting ssh client for bootstrapper"
)
}
return
bootstrapper
.
NewSSHRunner
(
client
),
nil
return
command
.
NewSSHRunner
(
client
),
nil
}
// Create creates the host
...
...
pkg/provision/buildroot.go
浏览文件 @
99ac1a81
...
...
@@ -37,7 +37,7 @@ import (
"github.com/docker/machine/libmachine/swarm"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/assets"
"k8s.io/minikube/pkg/minikube/
bootstrapper
"
"k8s.io/minikube/pkg/minikube/
command
"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/sshutil"
"k8s.io/minikube/pkg/util"
...
...
@@ -314,7 +314,7 @@ func configureAuth(p *BuildrootProvisioner) error {
}
func
copyHostCerts
(
authOptions
auth
.
Options
)
error
{
execRunner
:=
&
bootstrapper
.
ExecRunner
{}
execRunner
:=
&
command
.
ExecRunner
{}
hostCerts
:=
map
[
string
]
string
{
authOptions
.
CaCertPath
:
path
.
Join
(
authOptions
.
StorePath
,
"ca.pem"
),
authOptions
.
ClientCertPath
:
path
.
Join
(
authOptions
.
StorePath
,
"cert.pem"
),
...
...
@@ -345,7 +345,7 @@ func copyRemoteCerts(authOptions auth.Options, driver drivers.Driver) error {
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"provisioning: error getting ssh client"
)
}
sshRunner
:=
bootstrapper
.
NewSSHRunner
(
sshClient
)
sshRunner
:=
command
.
NewSSHRunner
(
sshClient
)
for
src
,
dst
:=
range
remoteCerts
{
f
,
err
:=
assets
.
NewFileAsset
(
src
,
path
.
Dir
(
dst
),
filepath
.
Base
(
dst
),
"0640"
)
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录