From b83791f723a7309a504b2f170029eae00f3e2748 Mon Sep 17 00:00:00 2001 From: Ole Reidar Holm Date: Wed, 15 May 2019 10:43:07 +0200 Subject: [PATCH] Pack to specified location & push to gcs --- src/commands/authenticate-gcp.yml | 14 ++++++++------ src/commands/push-helm-chart-to-gcs.yml | 24 +++++++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/commands/authenticate-gcp.yml b/src/commands/authenticate-gcp.yml index a42d26a..2959d71 100644 --- a/src/commands/authenticate-gcp.yml +++ b/src/commands/authenticate-gcp.yml @@ -18,7 +18,7 @@ parameters: gcp-container-cluster: description: | The name of the Google Cloud container cluster to use. - If not provided, the command will look for the environment variable $CLOUDSDK_CONTAINER_CLUSTER + If not provided, the command will look for the environment variable $CLOUDSDK_CONTAINER_CLUSTER. To obtain the name of your clusters, use the Google Cloud Platform Console (Command: gcloud container clusters list) @@ -50,6 +50,9 @@ steps: exit 1 fi + echo ${CREDENTIALS} > ${HOME}/account-auth.json + gcloud auth activate-service-account --key-file ${HOME}/account-auth.json + CLUSTER="<< parameters.gcp-container-cluster >>" if [[ -n "${CLUSTER}" ]]; then echo "Using cluster provided in parameters." @@ -57,10 +60,9 @@ steps: echo "Using cluster from environment." CLUSTER="${CLOUDSDK_CONTAINER_CLUSTER}" else - echo "No cluster were found. Looked in parameters and environment." - exit 1 + echo "No cluster were found. Looked in parameters and environment. Skipping authenticating to cluster." fi - echo ${CREDENTIALS} > ${HOME}/account-auth.json - gcloud auth activate-service-account --key-file ${HOME}/account-auth.json - gcloud --quiet container clusters get-credentials ${CLUSTER} + if [[ -n "${CLUSTER}" ]]; then + gcloud --quiet container clusters get-credentials ${CLUSTER} + fi diff --git a/src/commands/push-helm-chart-to-gcs.yml b/src/commands/push-helm-chart-to-gcs.yml index 3672c57..87cebb3 100644 --- a/src/commands/push-helm-chart-to-gcs.yml +++ b/src/commands/push-helm-chart-to-gcs.yml @@ -19,11 +19,21 @@ parameters: Specify a chart reference (e.g. helm/mychart), or a path to an unpacked chart directory (e.g. ./helm) type: string - packed-chart-name: + app-version: # TODO: Not implemented description: | - Specify the name of the packed chart. - The command will pack the specified chart to a compressed .tgz file. + Set the appVersion on the chart to this version. type: string + default: "" + version: # TODO: Not implemented + description: | + Set the version on the chart to this semver version + type: string + default: "" + dependency-update: # TODO: Not implemented + description: | + Update dependencies from "requirements.yaml" before packaging + type: boolean + default: false #| ---- Helm GCS Plugin ---- |# gcs-plugin-version: @@ -74,13 +84,13 @@ steps: name: Package Helm chart command: | CHART_LOCATION="<< parameters.chart >>" - PACKED_CHART_NAME="<< parameters.packed-chart-name >>" - echo "Packing chart from ${CHART_LOCATION} to ${PACKED_CHART_NAME}.tgz" - helm package ${CHART_LOCATION} + mkdir -p build/helm + echo "Packing chart from ${CHART_LOCATION} to build/helm." + helm package ${CHART_LOCATION} --destination build/helm - run: name: Push Helm chart to GCS bucket command: | BUCKET_NAME="<< parameters.gcs-bucket-name >>" - PACKED_CHART_NAME="<< parameters.packed-chart-name >>" + PACKED_CHART_NAME=$(basename build/helm/*) echo "Preparing to push ${PACKED_CHART_NAME}.tgz to ${BUCKET_NAME}." helm gcs push ${PACKED_CHART_NAME}.tgz ${BUCKET_NAME}