From a1aff76396472755a0c6de68e2650990308dfe35 Mon Sep 17 00:00:00 2001 From: Oliver Bristow Date: Tue, 26 Dec 2017 22:51:19 +0000 Subject: [PATCH 1/2] Test building+pusing an image to a repository registry --- .../docker-compose-build-image.yml | 7 +++++ script/test_in_openshift/lib.sh | 15 +++++++++++ script/test_in_openshift/run.sh | 4 +-- script/test_in_openshift/tests/build.sh | 26 +++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 script/test_in_openshift/compose-files/buildconfig/docker-compose-build-image.yml create mode 100755 script/test_in_openshift/tests/build.sh diff --git a/script/test_in_openshift/compose-files/buildconfig/docker-compose-build-image.yml b/script/test_in_openshift/compose-files/buildconfig/docker-compose-build-image.yml new file mode 100644 index 00000000..64852070 --- /dev/null +++ b/script/test_in_openshift/compose-files/buildconfig/docker-compose-build-image.yml @@ -0,0 +1,7 @@ +version: "2" + +services: + foo: + build: "./build" + image: "172.30.1.1:5000/myproject/test-image" + command: sleep 100 diff --git a/script/test_in_openshift/lib.sh b/script/test_in_openshift/lib.sh index c4d85ed0..c9de681c 100644 --- a/script/test_in_openshift/lib.sh +++ b/script/test_in_openshift/lib.sh @@ -50,6 +50,21 @@ function convert::oc_cluster_up () { convert::run_cmd "oc login -u system:admin" } +function convert::oc_registry_login () { + # wait for the registry to become available + local counter=0 + while ! curl --fail --silent http://172.30.1.1:5000/healthz; do + counter=$(($counter + 1)) + if [ $counter = 48 ]; then + echo "Registry did not become available in time" + break + fi + sleep 5 + done + oc serviceaccounts get-token builder \ + | docker login --password-stdin -u builder 172.30.1.1:5000 +} + function convert::oc_cluster_down () { convert::run_cmd "oc cluster down" diff --git a/script/test_in_openshift/run.sh b/script/test_in_openshift/run.sh index 419bc264..0ed2ec3c 100755 --- a/script/test_in_openshift/run.sh +++ b/script/test_in_openshift/run.sh @@ -33,10 +33,10 @@ if [ -z $(whereis oc | awk '{ print $2 }') ]; then fi convert::oc_cluster_up - +convert::oc_registry_login if [ -z $1 ]; then - for test_case in $KOMPOSE_ROOT/script/test_in_openshift/tests/*; do + for test_case in $KOMPOSE_ROOT/script/test_in_openshift/tests/*.sh; do $test_case; exit_status=$? if [ $exit_status -ne 0 ]; then openshift_exit_status=1 diff --git a/script/test_in_openshift/tests/build.sh b/script/test_in_openshift/tests/build.sh new file mode 100755 index 00000000..01cdf2ae --- /dev/null +++ b/script/test_in_openshift/tests/build.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# Copyright 2017 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +KOMPOSE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/../../..) +source $KOMPOSE_ROOT/script/test/cmd/lib.sh +source $KOMPOSE_ROOT/script/test_in_openshift/lib.sh + +convert::print_msg "Running tests for build+push" + +docker_compose_file="${KOMPOSE_ROOT}/script/test_in_openshift/compose-files/buildconfig/docker-compose-build-image.yml" +convert::kompose_up $docker_compose_file +convert::kompose_down $docker_compose_file From 4912f54393724ac2f775c8b4fb0971900861007b Mon Sep 17 00:00:00 2001 From: Oliver Bristow Date: Tue, 26 Dec 2017 22:51:42 +0000 Subject: [PATCH 2/2] Fix pushing image to registry #893 --- pkg/utils/docker/push.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/docker/push.go b/pkg/utils/docker/push.go index bb5eff8b..6cf68921 100644 --- a/pkg/utils/docker/push.go +++ b/pkg/utils/docker/push.go @@ -49,7 +49,7 @@ func (c *Push) PushImage(fullImageName string) error { // Let's setup the push and authentication options options := dockerlib.PushImageOptions{ - Name: parsedImage.Name(), + Name: fullImageName, Registry: parsedImage.Registry(), OutputStream: outputBuffer, }