[REV] Merge branch 'release-3.5' into rmaster

This commit is contained in:
qingguo 2018-03-23 12:36:35 +08:00
commit c2dc0b6113
2 changed files with 20 additions and 1 deletions

View File

@ -223,10 +223,18 @@ func (i *SourceCodeBuildItem) buildImage() error {
i.Logger.Info("开始构建镜像", map[string]string{"step": "builder-exector"})
err = sources.ImageBuild(i.DockerClient, i.RepoInfo.GetCodeBuildAbsPath(), buildOptions, i.Logger, 5)
if err != nil {
i.Logger.Error(fmt.Sprintf("构造镜像%s失败: %s", buildImageName, err.Error()), map[string]string{"step": "builder-exector", "status": "failure"})
i.Logger.Error(fmt.Sprintf("构造镜像%s失败", buildImageName), map[string]string{"step": "builder-exector", "status": "failure"})
logrus.Errorf("build image error: %s", err.Error())
return err
}
// check image exist
_, err := sources.ImageInspectWithRaw(i.DestImage, buildImageName)
if err != nil {
i.Logger.Error(fmt.Sprintf("构造镜像%s失败,请查看Debug日志", buildImageName), map[string]string{"step": "builder-exector", "status": "failure"})
logrus.Errorf("get image inspect error: %s", err.Error())
return err
}
// push image
auth, err := sources.EncodeAuthToBase64(types.AuthConfig{Username: "", Password: ""})
if err != nil {
logrus.Errorf("make auth base63 push image error: %s", err.Error())

View File

@ -250,3 +250,14 @@ func ImageBuild(dockerCli *client.Client, contextDir string, options types.Image
}
return nil
}
//ImageInspectWithRaw get image inspect
func ImageInspectWithRaw(dockerCli *client.Client, image string) (*types.ImageInspect, error) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ins, _, err := dockerCli.ImageInspectWithRaw(ctx, image, false)
if err != nil {
return nil, err
}
return &ins, nil
}