From 562ae19e8c4fec9105963e306cebaf9fda10d347 Mon Sep 17 00:00:00 2001 From: Vic Iglesias Date: Wed, 25 Oct 2017 14:23:22 -0700 Subject: [PATCH] First pass at init and push --- bin/gcs-helper.sh | 35 +++++++++++++++++++++++++++++++++++ bin/gcs-repo.sh | 4 ++++ bin/gcs.sh | 5 ----- etc/index.yaml | 1 + plugin.yaml | 8 ++++---- 5 files changed, 44 insertions(+), 9 deletions(-) create mode 100755 bin/gcs-helper.sh create mode 100755 bin/gcs-repo.sh delete mode 100755 bin/gcs.sh create mode 100644 etc/index.yaml diff --git a/bin/gcs-helper.sh b/bin/gcs-helper.sh new file mode 100755 index 0000000..d2d69cc --- /dev/null +++ b/bin/gcs-helper.sh @@ -0,0 +1,35 @@ +#!/bin/bash -e +COMMAND=$1 + +case $COMMAND in +init) + BUCKET=$2 + if [[ -z "$2" ]];then + echo "Please provide a bucket URL in the format gs://BUCKET" + exit 1 + else + gsutil cp -n $HELM_PLUGIN_DIR/etc/index.yaml $BUCKET + echo "Repository initialized..." + exit 0 + fi + ;; +push) + CHART_PATH=$2 + BUCKET=$3 + TMP_DIR=$(mktemp -d) + TMP_REPO=$TMP_DIR/repo + OLD_INDEX=$TMP_DIR/old-index.yaml + + gsutil cat $BUCKET/index.yaml > $OLD_INDEX + mkdir $TMP_REPO + cp $CHART_PATH $TMP_REPO + helm repo index --merge $OLD_INDEX --url $BUCKET $TMP_REPO + gsutil cp $TMP_REPO/index.yaml $BUCKET + gsutil cp $TMP_REPO/$(basename $CHART_PATH) $BUCKET + echo "Repository initialized..." + ;; +*) + # TODO turn this into usage() + echo "Please provide a command." + ;; +esac \ No newline at end of file diff --git a/bin/gcs-repo.sh b/bin/gcs-repo.sh new file mode 100755 index 0000000..ed00bb7 --- /dev/null +++ b/bin/gcs-repo.sh @@ -0,0 +1,4 @@ +#!/bin/bash +REPO=$4 +gsutil cat $REPO +exit 0 \ No newline at end of file diff --git a/bin/gcs.sh b/bin/gcs.sh deleted file mode 100755 index 9377d00..0000000 --- a/bin/gcs.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -CHART=$4 -gsutil cat $CHART -exit 0 \ No newline at end of file diff --git a/etc/index.yaml b/etc/index.yaml new file mode 100644 index 0000000..9cde8e8 --- /dev/null +++ b/etc/index.yaml @@ -0,0 +1 @@ +apiVersion: v1 diff --git a/plugin.yaml b/plugin.yaml index aaa8306..7131ee8 100644 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,11 +1,11 @@ name: "gcs" version: "0.1.0" -usage: "The plugin allows to use gcs protocol to upload, fetch charts and to work with repositories." +usage: "This plugin allows to use gcs protocol to upload, fetch charts and to work with repositories." description: |- Provides Google Cloud Storage protocol support. https://github.com/viglesiasce/helm-gcs -command: "$HELM_PLUGIN_DIR/bin/gcs.sh" +command: "$HELM_PLUGIN_DIR/bin/gcs-helper.sh" downloaders: -- command: "bin/gcs.sh" +- command: "bin/gcs-repo.sh" protocols: - - "gcs" + - "gs"