1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-24 08:02:18 +02:00

always update docker image when :latest tag

This commit is contained in:
masarakki 2015-03-07 10:24:23 +09:00
parent 74450d59d1
commit 70e24d7c6c
2 changed files with 25 additions and 2 deletions

View File

@ -234,8 +234,8 @@ func (b *Builder) setup() error {
log.Info("creating build image")
// check for build container (ie bradrydzewski/go:1.2)
// and download if it doesn't already exist
if _, err := b.dockerClient.Images.Inspect(b.Build.Image); err == docker.ErrNotFound {
// and download if it doesn't already exist or it's :latest tag
if _, err := b.dockerClient.Images.Inspect(b.Build.Image); err == docker.ErrNotFound || strings.HasSuffix(b.Build.Image, ":latest") {
// download the image if it doesn't exist
if err := b.dockerClient.Images.Pull(b.Build.Image); err != nil {
return fmt.Errorf("Error: Unable to pull image %s. %s", b.Build.Image, err)

View File

@ -224,6 +224,29 @@ func TestSetupErrorImagePull(t *testing.T) {
}
}
// TestSetupErrorUpdate will test our ability to handle a
// failure when the build image cannot be updated
func TestSetupErrorUpdate(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/v1.9/images/create", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusBadRequest)
})
b := Builder{}
b.Repo = &repo.Repo{}
b.Repo.Path = "git://github.com/drone/drone.git"
b.Build = &script.Build{}
b.Build.Image = "bradrydzewski/go:latest"
b.dockerClient = client
var got, want = b.setup(), fmt.Errorf("Error: Unable to pull image bradrydzewski/go:latest. %s", docker.ErrBadRequest)
if got == nil || got.Error() != want.Error() {
t.Errorf("Expected error %s, got %s", want, got)
}
}
// TestSetupErrorBuild will test our ability to handle a failure
// when creating a Docker image with the injected build script,
// ssh keys, etc.