Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
isula-build
提交
11e1b458
I
isula-build
项目概览
openeuler
/
isula-build
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
isula-build
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
11e1b458
编写于
7月 29, 2020
作者:
O
openeuler-ci-bot
提交者:
Gitee
7月 29, 2020
浏览文件
操作
浏览文件
下载
差异文件
!9 isula-build: fix build FROM local store image failed
Merge pull request !9 from Grooooot/master
上级
57513267
eb426252
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
32 addition
and
13 deletion
+32
-13
builder/dockerfile/builder.go
builder/dockerfile/builder.go
+22
-10
builder/dockerfile/builder_test.go
builder/dockerfile/builder_test.go
+5
-0
image/image.go
image/image.go
+5
-3
未找到文件。
builder/dockerfile/builder.go
浏览文件 @
11e1b458
...
...
@@ -104,7 +104,15 @@ func NewBuilder(ctx context.Context, store store.Store, req *pb.BuildRequest, ru
Iidfile
:
req
.
GetIidfile
(),
}
b
.
parseStaticBuildOpts
(
req
)
b
.
buildOpts
.
Tag
=
parseTag
(
req
.
Output
)
tag
:=
parseTag
(
req
.
Output
)
if
tag
!=
""
{
candidates
,
_
,
rerr
:=
image
.
ResolveName
(
tag
,
nil
,
b
.
localStore
)
if
rerr
!=
nil
||
len
(
candidates
)
==
0
{
return
nil
,
errors
.
Wrapf
(
rerr
,
"parse target tag %v err"
,
tag
)
}
b
.
buildOpts
.
Tag
=
candidates
[
0
]
}
// prepare workdirs for dockerfile builder
for
_
,
dir
:=
range
[]
string
{
buildDir
,
runDir
}
{
...
...
@@ -511,25 +519,29 @@ func (b *Builder) OutputPipeWrapper() *exporter.PipeWrapper {
func
parseTag
(
output
string
)
string
{
outputFields
:=
strings
.
Split
(
output
,
":"
)
if
(
outputFields
[
0
]
==
"docker-daemon"
||
outputFields
[
0
]
==
"isulad"
)
&&
len
(
outputFields
)
>
1
{
return
strings
.
Join
(
outputFields
[
1
:
],
":"
)
}
const
archiveOutputWithoutTagLen
=
2
if
outputFields
[
0
]
==
"docker-archive"
&&
len
(
outputFields
)
>
archiveOutputWithoutTagLen
{
var
tag
string
switch
{
case
(
outputFields
[
0
]
==
"docker-daemon"
||
outputFields
[
0
]
==
"isulad"
)
&&
len
(
outputFields
)
>
1
:
tag
=
strings
.
Join
(
outputFields
[
1
:
],
":"
)
case
outputFields
[
0
]
==
"docker-archive"
&&
len
(
outputFields
)
>
archiveOutputWithoutTagLen
:
if
len
(
outputFields
[
archiveOutputWithoutTagLen
:
])
==
1
{
outputFields
=
append
(
outputFields
,
"latest"
)
}
return
strings
.
Join
(
outputFields
[
archiveOutputWithoutTagLen
:
],
":"
)
}
if
outputFields
[
0
]
==
"docker"
&&
len
(
outputFields
)
>
1
{
tag
=
strings
.
Join
(
outputFields
[
archiveOutputWithoutTagLen
:
],
":"
)
case
outputFields
[
0
]
==
"docker"
&&
len
(
outputFields
)
>
1
:
repoAndTag
:=
strings
.
Join
(
outputFields
[
1
:
],
":"
)
// repo format regexp, "//registry.example.com/" for example
repo
:=
regexp
.
MustCompile
(
`^\/\/[\w\.\-\:]+\/`
)
.
FindString
(
repoAndTag
)
if
repo
==
""
{
return
""
}
return
repoAndTag
[
len
(
repo
)
:
]
tag
=
repoAndTag
[
len
(
repo
)
:
]
if
len
(
strings
.
Split
(
tag
,
":"
))
==
1
{
tag
+=
":latest"
}
}
return
""
return
tag
}
builder/dockerfile/builder_test.go
浏览文件 @
11e1b458
...
...
@@ -1295,6 +1295,11 @@ func TestParseTag(t *testing.T) {
output
:
"docker://localhost:5000/isula/test:latest"
,
tag
:
"isula/test:latest"
,
},
{
name
:
"docker output"
,
output
:
"docker://localhost:5000/isula/test"
,
tag
:
"isula/test:latest"
,
},
{
name
:
"invalid docker output"
,
output
:
"docker:localhost:5000/isula/test:latest"
,
...
...
image/image.go
浏览文件 @
11e1b458
...
...
@@ -132,7 +132,7 @@ func pullImage(opt pullOption) (types.ImageReference, error) {
func
pullAndGetImageInfo
(
opt
*
PrepareImageOptions
)
(
types
.
ImageReference
,
*
storage
.
Image
,
error
)
{
pLog
:=
logrus
.
WithField
(
util
.
LogKeyBuildID
,
opt
.
Ctx
.
Value
(
util
.
LogFieldKey
(
util
.
LogKeyBuildID
)))
candidates
,
transport
,
err
:=
r
esolveName
(
opt
.
FromImage
,
opt
.
SystemContext
,
opt
.
Store
)
candidates
,
transport
,
err
:=
R
esolveName
(
opt
.
FromImage
,
opt
.
SystemContext
,
opt
.
Store
)
if
err
!=
nil
{
return
nil
,
nil
,
errors
.
Wrapf
(
err
,
"error parsing reference to image %q"
,
opt
.
FromImage
)
}
...
...
@@ -476,7 +476,7 @@ func ResolveImageName(s string, resolveArg func(string) string) (string, error)
// FindImage get the image from storage by image describe
func
FindImage
(
store
store
.
Store
,
image
string
)
(
types
.
ImageReference
,
*
storage
.
Image
,
error
)
{
names
,
_
,
err
:=
r
esolveName
(
image
,
nil
,
store
)
names
,
_
,
err
:=
R
esolveName
(
image
,
nil
,
store
)
if
err
!=
nil
{
return
nil
,
nil
,
errors
.
Wrapf
(
err
,
"error parsing name %q"
,
image
)
}
...
...
@@ -508,7 +508,9 @@ func FindImage(store store.Store, image string) (types.ImageReference, *storage.
return
ref
,
img
,
nil
}
func
resolveName
(
name
string
,
sc
*
types
.
SystemContext
,
store
store
.
Store
)
([]
string
,
string
,
error
)
{
// ResolveName checks whether the image name is valid, if the name does not include a domain,
// returns a list of candidates it might be
func
ResolveName
(
name
string
,
sc
*
types
.
SystemContext
,
store
store
.
Store
)
([]
string
,
string
,
error
)
{
// 1. check name valid
if
name
==
""
{
return
nil
,
""
,
nil
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录