diff --git a/cmd/s2i/main.go b/cmd/s2i/main.go index 4b5db2ac4..0b9db5251 100644 --- a/cmd/s2i/main.go +++ b/cmd/s2i/main.go @@ -216,7 +216,7 @@ func newCmdRebuild(cfg *api.Config) *cobra.Command { cfg.PullAuthentication = docker.LoadAndGetImageRegistryAuth(r, cfg.Tag) } - err := build.GenerateConfigFromLabels(cfg) + err := build.GenerateConfigFromLabels(cfg, true) checkErr(err) if len(args) >= 2 { diff --git a/hack/test-stirunimage.sh b/hack/test-stirunimage.sh index 30655a29c..f46456457 100755 --- a/hack/test-stirunimage.sh +++ b/hack/test-stirunimage.sh @@ -62,15 +62,6 @@ function test_debug() { echo } -set +e -img_count=$(docker images | grep -c sti_test/sti-fake) -set -e - -if [ "${img_count}" != "10" ]; then - echo "You do not have necessary test images, be sure to run 'hack/build-test-images.sh' beforehand." - exit 1 -fi - trap cleanup EXIT SIGINT echo "working dir: ${WORK_DIR}" @@ -114,6 +105,12 @@ check_result $? "" grep "Copying sources" "${WORK_DIR}/s2i-non-repo.log" check_result $? "${WORK_DIR}/s2i-non-repo.log" +test_debug "s2i rebuild" +s2i build https://github.com/openshift/sti-php.git --context-dir=5.5/test/test-app registry.access.redhat.com/openshift3/php-55-rhel7 rack-test-app --incremental=true --loglevel=5 &> "${WORK_DIR}/s2i-pre-rebuild.log" +check_result $? "${WORK_DIR}/s2i-pre-rebuild.log" +s2i rebuild rack-test-app:latest rack-test-app:v1 --force-pull=false -p never --loglevel=5 &> "${WORK_DIR}/s2i-rebuild.log" +check_result $? "${WORK_DIR}/s2i-rebuild.log" + test_debug "s2i usage" s2i usage openshift/ruby-20-centos7 &> "${WORK_DIR}/s2i-usage.log" diff --git a/pkg/api/describe/describer.go b/pkg/api/describe/describer.go index 2821bef23..2c9d99162 100644 --- a/pkg/api/describe/describer.go +++ b/pkg/api/describe/describer.go @@ -97,7 +97,7 @@ func describeBuilderImage(config *api.Config, image string, out io.Writer) { Tag: config.Tag, IncrementalAuthentication: config.IncrementalAuthentication, } - build.GenerateConfigFromLabels(c) + build.GenerateConfigFromLabels(c, false) if len(c.DisplayName) > 0 { fmt.Fprintf(out, "Builder Name:\t%s\n", c.DisplayName) } diff --git a/pkg/build/config.go b/pkg/build/config.go index a9dced39c..f29f13337 100644 --- a/pkg/build/config.go +++ b/pkg/build/config.go @@ -9,8 +9,14 @@ import ( // GenerateConfigFromLabels generates the S2I Config struct from the Docker // image labels. -func GenerateConfigFromLabels(config *api.Config) error { - result, err := docker.GetBuilderImage(config) +func GenerateConfigFromLabels(config *api.Config, rebuild bool) error { + var result *docker.PullResult + var err error + if rebuild { + result, err = docker.GetRebuildImage(config) + } else { + result, err = docker.GetBuilderImage(config) + } if err != nil { return err } diff --git a/pkg/docker/util.go b/pkg/docker/util.go index e540f7489..89b22e5be 100644 --- a/pkg/docker/util.go +++ b/pkg/docker/util.go @@ -286,6 +286,28 @@ func GetBuilderImage(config *api.Config) (*PullResult, error) { return r, nil } +// GetRebuildImage obtains the metadata information for the image +// specified in a s2i rebuild operation. Assumptions are made that +// the build is available locally since it should have been previously built. +func GetRebuildImage(config *api.Config) (*PullResult, error) { + d, err := New(config.DockerConfig, config.PullAuthentication) + if err != nil { + return nil, err + } + + r, err := PullImage(config.Tag, d, api.PullNever, false) + if err != nil { + return nil, err + } + + err = CheckAllowedUser(d, config.Tag, config.AllowedUIDs, r.OnBuild) + if err != nil { + return nil, err + } + + return r, nil +} + // GetRuntimeImage processes the config and performs operations necessary to make // the Docker image specified as RuntimeImage available locally. func GetRuntimeImage(config *api.Config, docker Docker) error {