Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
6c08fedf
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 搜索 >>
提交
6c08fedf
编写于
11月 26, 2019
作者:
M
Medya Gh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove cyclic depdenecy and make cluster pkg smaller
上级
72b17439
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
37 addition
and
22 deletion
+37
-22
cmd/minikube/cmd/delete.go
cmd/minikube/cmd/delete.go
+2
-2
cmd/minikube/cmd/delete_test.go
cmd/minikube/cmd/delete_test.go
+2
-2
pkg/minikube/machine/cache_images.go
pkg/minikube/machine/cache_images.go
+28
-13
pkg/minikube/machine/machine.go
pkg/minikube/machine/machine.go
+4
-4
pkg/minikube/machine/machine_test.go
pkg/minikube/machine/machine_test.go
+1
-1
未找到文件。
cmd/minikube/cmd/delete.go
浏览文件 @
6c08fedf
...
...
@@ -163,7 +163,7 @@ func DeleteProfiles(profiles []*pkg_config.Profile) []error {
err
:=
deleteProfile
(
profile
)
if
err
!=
nil
{
mm
,
loadErr
:=
cluster
.
LoadMachine
(
profile
.
Name
)
mm
,
loadErr
:=
machine
.
LoadMachine
(
profile
.
Name
)
if
!
profile
.
IsValid
()
||
(
loadErr
!=
nil
||
!
mm
.
IsValid
())
{
invalidProfileDeletionErrs
:=
deleteInvalidProfile
(
profile
)
...
...
@@ -263,7 +263,7 @@ func deleteInvalidProfile(profile *pkg_config.Profile) []error {
}
}
pathToMachine
:=
cluster
.
MachinePath
(
profile
.
Name
,
localpath
.
MiniPath
())
pathToMachine
:=
machine
.
MachinePath
(
profile
.
Name
,
localpath
.
MiniPath
())
if
_
,
err
:=
os
.
Stat
(
pathToMachine
);
!
os
.
IsNotExist
(
err
)
{
err
:=
os
.
RemoveAll
(
pathToMachine
)
if
err
!=
nil
{
...
...
cmd/minikube/cmd/delete_test.go
浏览文件 @
6c08fedf
...
...
@@ -26,9 +26,9 @@ import (
"github.com/otiai10/copy"
"github.com/spf13/viper"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/config"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/machine"
)
// except returns a list of strings, minus the excluded ones
...
...
@@ -117,7 +117,7 @@ func TestDeleteProfile(t *testing.T) {
t
.
Errorf
(
"Profile folder of profile
\"
%s
\"
was not deleted"
,
profile
.
Name
)
}
pathToMachine
:=
cluster
.
MachinePath
(
profile
.
Name
,
localpath
.
MiniPath
())
pathToMachine
:=
machine
.
MachinePath
(
profile
.
Name
,
localpath
.
MiniPath
())
if
_
,
err
:=
os
.
Stat
(
pathToMachine
);
!
os
.
IsNotExist
(
err
)
{
t
.
Errorf
(
"Profile folder of profile
\"
%s
\"
was not deleted"
,
profile
.
Name
)
}
...
...
pkg/minikube/machine/cache_images.go
浏览文件 @
6c08fedf
...
...
@@ -27,6 +27,7 @@ import (
"sync"
"time"
"github.com/docker/machine/libmachine/state"
"github.com/golang/glog"
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
...
...
@@ -38,6 +39,7 @@ import (
"golang.org/x/sync/errgroup"
"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/constants"
...
...
@@ -95,7 +97,6 @@ func CacheImages(images []string, cacheDir string) error {
func
LoadImages
(
cmd
command
.
Runner
,
images
[]
string
,
cacheDir
string
)
error
{
glog
.
Infof
(
"LoadImages start: %s"
,
images
)
defer
glog
.
Infof
(
"LoadImages end"
)
var
g
errgroup
.
Group
// Load profile cluster config from file
cc
,
err
:=
config
.
Load
()
...
...
@@ -121,7 +122,7 @@ func LoadImages(cmd command.Runner, images []string, cacheDir string) error {
return
nil
}
// CacheAndLoadImages caches and loads images
// CacheAndLoadImages caches and loads images
to all profiles
func
CacheAndLoadImages
(
images
[]
string
)
error
{
if
err
:=
CacheImages
(
images
,
constants
.
ImageCacheDir
);
err
!=
nil
{
return
err
...
...
@@ -131,20 +132,34 @@ func CacheAndLoadImages(images []string) error {
return
err
}
defer
api
.
Close
()
cc
,
err
:=
config
.
Load
()
profiles
,
_
,
err
:=
config
.
ListProfiles
()
// need to load image to all profiles
if
err
!=
nil
{
return
err
return
err
ors
.
Wrap
(
err
,
"list profiles"
)
}
h
,
err
:=
api
.
Load
(
cc
.
Name
)
for
_
,
p
:=
range
profiles
{
// adding images to all the profiles
pName
:=
p
.
Name
// capture the loop variable
status
,
err
:=
cluster
.
GetHostStatus
(
api
,
pName
)
if
err
!=
nil
{
glog
.
Warningf
(
"skipping loading cache for profile %s"
,
pName
)
glog
.
Errorf
(
"error getting status for %s: %v"
,
pName
,
err
)
continue
// try next machine
}
if
status
==
state
.
Running
.
String
()
{
// the not running hosts will load on next start
h
,
err
:=
api
.
Load
(
pName
)
if
err
!=
nil
{
return
err
}
runner
,
err
:=
CommandRunner
(
h
)
cr
,
err
:=
CommandRunner
(
h
)
if
err
!=
nil
{
return
err
}
return
LoadImages
(
runner
,
images
,
constants
.
ImageCacheDir
)
err
=
LoadImages
(
cr
,
images
,
constants
.
ImageCacheDir
)
if
err
!=
nil
{
glog
.
Warningf
(
"Failed to load cached images for profile %s. make sure the profile is running. %v"
,
pName
,
err
)
}
}
}
return
err
}
// # ParseReference cannot have a : in the directory path
...
...
pkg/minikube/
cluster
/machine.go
→
pkg/minikube/
machine
/machine.go
浏览文件 @
6c08fedf
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
cluster
package
machine
import
(
"io/ioutil"
...
...
@@ -23,8 +23,8 @@ import (
"github.com/docker/machine/libmachine/host"
"github.com/golang/glog"
"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/cluster"
"k8s.io/minikube/pkg/minikube/localpath"
"k8s.io/minikube/pkg/minikube/machine"
)
// Machine contains information about a machine
...
...
@@ -85,12 +85,12 @@ func ListMachines(miniHome ...string) (validMachines []*Machine, inValidMachines
// LoadMachine loads a machine or throws an error if the machine could not be loadedG
func
LoadMachine
(
name
string
)
(
*
Machine
,
error
)
{
api
,
err
:=
machine
.
NewAPIClient
()
api
,
err
:=
NewAPIClient
()
if
err
!=
nil
{
return
nil
,
err
}
h
,
err
:=
CheckIfHostExistsAndLoad
(
api
,
name
)
h
,
err
:=
cluster
.
CheckIfHostExistsAndLoad
(
api
,
name
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
pkg/minikube/
cluster
/machine_test.go
→
pkg/minikube/
machine
/machine_test.go
浏览文件 @
6c08fedf
...
...
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package
cluster
package
machine
import
(
"io/ioutil"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录