Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
Update error handling in scripts from cf-operator
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Manno committed Feb 3, 2020
1 parent d565f16 commit cd63a7d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions bin/build-helm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ cp -r "${GIT_ROOT}/deploy/helm" "${output_dir}"
perl -pi -e "s|repository: .*|repository: ${DOCKER_IMAGE_REPOSITORY}|g" "${output_dir}/quarks-job/values.yaml"
perl -pi -e "s|org: .*|org: ${DOCKER_IMAGE_ORG}|g" "${output_dir}/quarks-job/values.yaml"
perl -pi -e "s|tag: .*|tag: ${DOCKER_IMAGE_TAG}|g" "${output_dir}/quarks-job/values.yaml"
perl -pi -e "s|version: .*|version: ${version}|g" "${output_dir}/cf-operator/Chart.yaml"
perl -pi -e "s|appVersion: .*|appVersion: ${version}|g" "${output_dir}/cf-operator/Chart.yaml"
perl -pi -e "s|version: .*|version: ${version}|g" "${output_dir}/quarks-job/Chart.yaml"
perl -pi -e "s|appVersion: .*|appVersion: ${version}|g" "${output_dir}/quarks-job/Chart.yaml"

tar -C "${output_dir}" -czvf "${filename}" quarks-job

Expand Down
4 changes: 2 additions & 2 deletions bin/include/docker
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ if [ -z ${DOCKER_IMAGE_ORG+x} ]; then
fi

if [ -z ${DOCKER_IMAGE_TAG+x} ]; then
DOCKER_IMAGE_TAG=${ARTIFACT_VERSION}
DOCKER_IMAGE_TAG="$ARTIFACT_VERSION"
export DOCKER_IMAGE_TAG
fi

if [ -z ${DOCKER_IMAGE_REPOSITORY} ]; then
if [ -z ${DOCKER_IMAGE_REPOSITORY+x} ]; then
DOCKER_IMAGE_REPOSITORY="quarks-job"
export DOCKER_IMAGE_REPOSITORY
fi
3 changes: 2 additions & 1 deletion bin/include/testing
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/bin/bash

function setup_testing_tmp {
if [ -z "${CF_OPERATOR_TESTING_TMP}" ]
if [ -z ${CF_OPERATOR_TESTING_TMP+x} ]
then
echo "[Error] Env variable \$CF_OPERATOR_TESTING_TMP is not set. Please set to continue."
exit 1
fi

SKIP_CF_OPERATOR_TESTING_TMP_CLEANUP=${SKIP_CF_OPERATOR_TESTING_TMP_CLEANUP:-}
if [ "$SKIP_CF_OPERATOR_TESTING_TMP_CLEANUP" != "true" ]
then
echo "${CF_OPERATOR_TESTING_TMP} will be cleaned up after the tests. Set SKIP_CF_OPERATOR_TESTING_TMP_CLEANUP=true to skip cleanup."
Expand Down
17 changes: 4 additions & 13 deletions bin/include/versioning
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
#!/bin/bash

set +o errexit +o nounset

test -n "${XTRACE}" && set -o xtrace

set -o errexit -o nounset

GIT_ROOT=${GIT_ROOT:-$(git rev-parse --show-toplevel)}
GIT_DESCRIBE=$(git describe --tags --long || (git tag -a v0.0.0 -m "tag v0.0.0"; git describe --tags --long))
GIT_BRANCH=$(git name-rev --name-only HEAD)
GIT_BRANCH=${GIT_BRANCH:-$(git name-rev --name-only HEAD)}

GIT_COMMITS=$(echo "${GIT_DESCRIBE}" | awk -F - '{ print $2 }' )
GIT_COMMITS=$(echo "${GIT_DESCRIBE}" | awk -F - '{ print $2 }')
GIT_SHA=$(echo "${GIT_DESCRIBE}" | awk -F - '{ print $3 }' )
GIT_DIRTY=$(echo "${GIT_DESCRIBE}" | awk -F - '{ print $4 }' )
GIT_TAG=$(echo "${GIT_DESCRIBE}" | awk -F - '{ print $1 }' )
[ -z "$(git status --porcelain)" ] || GIT_TAG="${GIT_TAG}-dirty"
GIT_TAG=$(echo "${GIT_DESCRIBE}" | awk -F - '{ print $1 }')
[ -z "$(git status --porcelain -uno | grep -v -E '^ M (integration|e2e|docs)')" ] || GIT_TAG="${GIT_TAG}-dirty"

ARTIFACT_NAME=$(basename "$(git config --get remote.origin.url)" .git)
ARTIFACT_VERSION="${GIT_TAG}-${GIT_COMMITS}.${GIT_SHA}"

set +o errexit +o nounset +o xtrace
2 changes: 1 addition & 1 deletion bin/test-cli-e2e
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eu
set -euo pipefail

GIT_ROOT="${GIT_ROOT:-$(git rev-parse --show-toplevel)}"
. "${GIT_ROOT}/bin/include/versioning"
Expand Down
5 changes: 3 additions & 2 deletions bin/test-integration
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eu
set -euo pipefail

GIT_ROOT="${GIT_ROOT:-$(git rev-parse --show-toplevel)}"
. "${GIT_ROOT}/bin/include/versioning"
Expand All @@ -23,7 +23,8 @@ code.cloudfoundry.org/quarks-job/pkg/kube/operator/...,\
code.cloudfoundry.org/quarks-job/pkg/kube/controllers/..."

# Run code coverage only in CI
if [ -n "$COVERAGE" ]; then
COV_ARG=""
if [ ${COVERAGE+x} ]; then
COV_ARG="-cover -outputdir=./code-coverage -coverprofile=${GOVER_FILE} -coverpkg ${pkgs}"
mkdir -p code-coverage
fi
Expand Down
2 changes: 1 addition & 1 deletion bin/test-unit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -e
set -euo pipefail

GOVER_FILE=${GOVER_FILE:-gover-unit.coverprofile}

Expand Down

0 comments on commit cd63a7d

Please sign in to comment.