Skip to content

Commit

Permalink
Merge pull request #2775 from uselagoon/tug-lagoon2
Browse files Browse the repository at this point in the history
small fixes to make tug system lagoon 2 compatible
  • Loading branch information
Schnitzel authored Jul 20, 2021
2 parents d6df42e + 2d9c274 commit 6662816
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
27 changes: 25 additions & 2 deletions images/oc-build-deploy-dind/build-deploy-docker-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,35 @@ function cronScheduleMoreOftenThanXMinutes() {
### PREPARATION
##############################################

DEPLOY_TYPE=$(cat .lagoon.yml | shyaml get-value environments.${BRANCH//./\\.}.deploy-type default)

### Compatibility for new Lagoon 2.0 variables

# Only if TYPE is not set and BUILD_TYPE is set
if [[ -z ${TYPE+x} && ! -z ${BUILD_TYPE+x} ]]; then
TYPE=${BUILD_TYPE}
fi

# Only if SAFE_BRANCH is not set and BRANCH is set
if [[ -z ${SAFE_BRANCH+x} && ! -z ${BRANCH+x} ]]; then
SAFE_BRANCH=${BRANCH}
fi

# Only if SAFE_PROJECT is not set and PROJECT is set
if [[ -z ${SAFE_PROJECT+x} && ! -z ${PROJECT+x} ]]; then
SAFE_PROJECT=${PROJECT}
fi


# Only if OPENSHIFT_NAME is not set and KUBERNETES is set
if [[ -z ${OPENSHIFT_NAME+x} && ! -z ${KUBERNETES+x} ]]; then
OPENSHIFT_NAME=${KUBERNETES}
fi

# Load path of docker-compose that should be used
set +x # reduce noise in build logs
DOCKER_COMPOSE_YAML=($(cat .lagoon.yml | shyaml get-value docker-compose-yaml))

DEPLOY_TYPE=$(cat .lagoon.yml | shyaml get-value environments.${BRANCH//./\\.}.deploy-type default)

# Load all Services that are defined
COMPOSE_SERVICES=($(cat $DOCKER_COMPOSE_YAML | shyaml keys services))

Expand Down
7 changes: 6 additions & 1 deletion images/oc-build-deploy-dind/build-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ fi
set +x
DOCKER_REGISTRY_TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)

docker login -u=jenkins -p="${DOCKER_REGISTRY_TOKEN}" ${OPENSHIFT_REGISTRY}
DEPLOY_TYPE=$(cat .lagoon.yml | shyaml get-value environments.${BRANCH//./\\.}.deploy-type default)

# Do not run if this a DEPLOY_TYPE=tug which means we just push images to an external registry, we don't need to be logged into the OpenShift Registry
if [[ ! $DEPLOY_TYPE == "tug" ]]; then
docker login -u=jenkins -p="${DOCKER_REGISTRY_TOKEN}" ${OPENSHIFT_REGISTRY}
fi

INTERNAL_REGISTRY_LOGGED_IN="false"
if [ ! -z ${INTERNAL_REGISTRY_URL} ] && [ ! -z ${INTERNAL_REGISTRY_USERNAME} ] && [ ! -z ${INTERNAL_REGISTRY_PASSWORD} ] ; then
Expand Down

0 comments on commit 6662816

Please sign in to comment.