Skip to content

Commit

Permalink
Merge branch 'master' of github.com:teracyhq/helm-charts into task/te…
Browse files Browse the repository at this point in the history
…racyhq#2-create-test-helm-chart
  • Loading branch information
hieptranquoc committed Oct 29, 2018
2 parents ad4ed9c + 1b8d9d9 commit 7758391
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 6 deletions.
54 changes: 54 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
language: python
sudo: false
env:
global:
- HELM_URL=https://storage.googleapis.com/kubernetes-helm
- HELM_TARBALL=helm-v2.9.1-linux-amd64.tar.gz
- STABLE_REPO_URL=https://teracyhq.storage.googleapis.com/
- INCUBATOR_REPO_URL=https://teracyhq-incubator.storage.googleapis.com/
- GCS_BUCKET_STABLE=gs://teracyhq
- GCS_BUCKET_INCUBATOR=gs://teracyhq-incubator
- ALLOW_OVERWRITE_INDEX_FILE=true
before_install:
- git submodule update --init --recursive
#Please replace the following line with your credential command
- openssl aes-256-cbc -K $encrypted_cbce4ac2ef86_key -iv $encrypted_cbce4ac2ef86_iv
-in credential.json.enc -out credential.json -d
install:
- wget -q ${HELM_URL}/${HELM_TARBALL}
- tar xzfv ${HELM_TARBALL}
- PATH=`pwd`/linux-amd64/:$PATH
- helm init --client-only
- if [ ! -d ${HOME}/google-cloud-sdk ]; then export CLOUDSDK_CORE_DISABLE_PROMPTS=1;
curl https://sdk.cloud.google.com | bash; fi
- source /home/travis/google-cloud-sdk/path.bash.inc
before_script:
- git config --global user.name "<Replace your name here>"
- git config --global user.email "<Replace your email here>"
- chmod ugo+x ./.travis/sync-repo.sh
script:
- |
# Check format helm stable
for dir in `find stable/ -mindepth 1 -maxdepth 1 -type d`; do
helm lint $dir
if [ $? != 0 ]; then
travis_terminate 1
fi
done
# Check format helm incubator
for dir in `find incubator/ -mindepth 1 -maxdepth 1 -type d`; do
helm lint $dir
if [ $? != 0 ]; then
travis_terminate 1
fi
done
after_success:
- |
if [ $TRAVIS_BRANCH == 'master' ] && [ $TRAVIS_PULL_REQUEST == 'false' ]; then
./.travis/sync-repo.sh
fi
notifications:
slack:
rooms:
secure: "<replace your slack channel's secure key here>"
on_success: always
88 changes: 88 additions & 0 deletions .travis/sync-repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash

# Copyright 2018 The Kubernetes Authors. All rights reserved.
#
# 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.

set -o errexit
set -o nounset
set -o pipefail

main() {
authenticate

if ! sync_repo stable "$GCS_BUCKET_STABLE" "$STABLE_REPO_URL"; then
log_error "Not all stable charts could be packaged and synced!"
fi
if ! sync_repo incubator "$GCS_BUCKET_INCUBATOR" "$INCUBATOR_REPO_URL"; then
log_error "Not all incubator charts could be packaged and synced!"
fi
}

authenticate() {
echo "Authenticating with Google Cloud..."
#gcloud auth activate-service-account --key-file <(base64 --decode <<< "$SYNC_CREDS")
gcloud auth activate-service-account --key-file credential.json
}

sync_repo() {
local repo_dir="${1?Specify repo dir}"
local bucket="${2?Specify repo bucket}"
local repo_url="${3?Specify repo url}"
local sync_dir="${repo_dir}-sync"
local index_dir="${repo_dir}-index"

echo "Syncing repo '$repo_dir'..."

mkdir -p "$sync_dir"
mkdir -p "$index_dir"
# echo "$ALLOW_OVERWRITE_INDEX_FILE"
if ([ ! `gsutil cp "$bucket/index.yaml" "$index_dir/index.yaml"` ]) && ([ ! $ALLOW_OVERWRITE_INDEX_FILE ]); then
log_error "Exiting because unable to copy index locally. Not safe to proceed."
exit 1
fi

local exit_code=0

for dir in `find ${repo_dir}/ -mindepth 1 -maxdepth 1 -type d`; do
if helm dependency build "$dir"; then
helm package --destination "$sync_dir" "$dir"
else
log_error "Problem building dependencies. Skipping packaging of '$dir'."
exit_code=1
fi
done

if helm repo index --url "$repo_url" --merge "$index_dir/index.yaml" "$sync_dir"; then
# Move updated index.yaml to sync folder so we don't push the old one again
mv -f "$sync_dir/index.yaml" "$index_dir/index.yaml"

gsutil -m rsync "$sync_dir" "$bucket"

# Make sure index.yaml is synced last
gsutil cp "$index_dir/index.yaml" "$bucket"
else
log_error "Exiting because unable to update index. Not safe to push update."
exit 1
fi

ls -l "$sync_dir"

return "$exit_code"
}

log_error() {
printf '\e[31mERROR: %s\n\e[39m' "$1" >&2
}

main
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ Use this repository to submit official Helm Charts for Teracy Helm Chart's repo.

Just do the following:
```
$ git clone https://github.com/teracyhq/helm-charts.git
$ cd helm-charts
$ helm install stable/<chart-name>
$ helm repo add teracyhq https://teracyhq.storage.googleapis.com/
$ helm install teracyhq/<chart-name>
```

For more information on using Helm, refer to the [Helm's documentation](https://github.com/kubernetes/helm#docs).
Expand All @@ -18,9 +17,8 @@ For more information on using Helm, refer to the [Helm's documentation](https://

Just do the following:
```
$ git clone https://github.com/teracyhq/helm-charts.git
$ cd helm-charts
$ helm install incubator/<chart-name>
$ helm repo add teracyhq-incubator https://teracyhq-incubator.storage.googleapis.com/
$ helm install teracyhq-incubator/<chart-name>
```

## Chart Format
Expand Down
Binary file added credential.json.enc
Binary file not shown.

0 comments on commit 7758391

Please sign in to comment.