Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Chu Peng 楚鹏
minikube
提交
a590ab76
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,发现更多精彩内容 >>
未验证
提交
a590ab76
编写于
12月 30, 2020
作者:
M
Medya Ghazizadeh
提交者:
GitHub
12月 30, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10058 from lingsamuel/auto-latest
fix "cache add" command error when not specifying :latest tag
上级
358c9c55
b79ab3fe
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
66 addition
and
0 deletion
+66
-0
pkg/minikube/image/cache.go
pkg/minikube/image/cache.go
+1
-0
pkg/minikube/image/image.go
pkg/minikube/image/image.go
+19
-0
pkg/minikube/image/image_test.go
pkg/minikube/image/image_test.go
+45
-0
pkg/minikube/machine/cache_images.go
pkg/minikube/machine/cache_images.go
+1
-0
未找到文件。
pkg/minikube/image/cache.go
浏览文件 @
a590ab76
...
...
@@ -76,6 +76,7 @@ func SaveToDir(images []string, cacheDir string) error {
// saveToTarFile caches an image
func
saveToTarFile
(
iname
,
rawDest
string
)
error
{
iname
=
normalizeTagName
(
iname
)
start
:=
time
.
Now
()
defer
func
()
{
klog
.
Infof
(
"cache image %q -> %q took %s"
,
iname
,
rawDest
,
time
.
Since
(
start
))
...
...
pkg/minikube/image/image.go
浏览文件 @
a590ab76
...
...
@@ -212,3 +212,22 @@ func cleanImageCacheDir() error {
})
return
err
}
// normalizeTagName automatically tag latest to image
// Example:
// nginx -> nginx:latest
// localhost:5000/nginx -> localhost:5000/nginx:latest
// localhost:5000/nginx:latest -> localhost:5000/nginx:latest
// docker.io/dotnet/core/sdk -> docker.io/dotnet/core/sdk:latest
func
normalizeTagName
(
image
string
)
string
{
base
:=
image
tag
:=
"latest"
// From google/go-containerregistry/pkg/name/tag.go
parts
:=
strings
.
Split
(
strings
.
TrimSpace
(
image
),
":"
)
if
len
(
parts
)
>
1
&&
!
strings
.
Contains
(
parts
[
len
(
parts
)
-
1
],
"/"
)
{
base
=
strings
.
Join
(
parts
[
:
len
(
parts
)
-
1
],
":"
)
tag
=
parts
[
len
(
parts
)
-
1
]
}
return
base
+
":"
+
tag
}
pkg/minikube/image/image_test.go
浏览文件 @
a590ab76
...
...
@@ -46,3 +46,48 @@ func TestTag(t *testing.T) {
})
}
}
func
TestNormalizeImageName
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
image
string
expected
string
}{
{
image
:
"nginx"
,
expected
:
"nginx:latest"
,
},
{
image
:
"localhost:5000/nginx"
,
expected
:
"localhost:5000/nginx:latest"
,
},
{
image
:
"localhost:5000/nginx:3.0"
,
expected
:
"localhost:5000/nginx:3.0"
,
},
{
image
:
"localhost:5000/nginx:latest"
,
expected
:
"localhost:5000/nginx:latest"
,
},
{
image
:
"docker.io/nginx"
,
expected
:
"docker.io/nginx:latest"
,
},
{
image
:
"nginx:3.0"
,
expected
:
"nginx:3.0"
,
},
{
image
:
"docker.io/dotnet/core/sdk"
,
expected
:
"docker.io/dotnet/core/sdk:latest"
,
},
}
for
_
,
c
:=
range
cases
{
t
.
Run
(
c
.
image
,
func
(
t
*
testing
.
T
)
{
got
:=
normalizeTagName
(
c
.
image
)
if
got
!=
c
.
expected
{
t
.
Errorf
(
"Normalize error: expected: %v, got: %v"
,
c
.
expected
,
got
)
}
})
}
}
pkg/minikube/machine/cache_images.go
浏览文件 @
a590ab76
...
...
@@ -218,6 +218,7 @@ func CacheAndLoadImages(images []string) error {
if
err
!=
nil
{
failed
=
append
(
failed
,
m
)
klog
.
Warningf
(
"Failed to load cached images for profile %s. make sure the profile is running. %v"
,
pName
,
err
)
continue
}
succeeded
=
append
(
succeeded
,
m
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录