Skip to content

Commit

Permalink
Add upgrade command (#6)
Browse files Browse the repository at this point in the history
* Add `upgrade` command to upgrade a release to a new version of the chart from GitHub
  • Loading branch information
aknysh authored and darend committed Mar 16, 2018
1 parent 76cfc5e commit 945aa21
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 34 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
repos
.idea
helm-github.iml

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [2017] [Gladly Software, Inc.]
Copyright 2017-2018 Gladly Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -198,4 +198,4 @@
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.
limitations under the License.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
# helm-github

This is a helm plugin that installs raw helm charts from github.
A Helm plugin that installs or upgrades raw Helm charts from GitHub

* https://docs.helm.sh/helm/#helm-install
* https://docs.helm.sh/helm/#helm-upgrade


# Installation
* `helm plugin install --version master https://github.com/sagansystems/helm-github.git`
* `helm github --help`

![image](https://user-images.githubusercontent.com/52489/33590100-fa79e052-d931-11e7-9879-b0fd7db7d09a.png)

# Updates

# `helm-github` plugin updates

### Automatically
* `helm github --update`

### Manually
* `cd $HELM_HOME/plugins/`
* `git pull`



# Usage
* `helm github install --repo git@github.com:kubernetes/charts.git --path stable/external-dns/`

### Install a chart from a GitHub repo

* `helm github install --repo git@github.com:kubernetes/charts.git --path stable/external-dns`
* `helm github install --repo git@github.com:coreos/alb-ingress-controller.git --ref 6d64984 --path alb-ingress-controller-helm`
* `helm github install --repo git@github.com:coreos/alb-ingress-controller.git --ref master --path alb-ingress-controller-helm --namespace kube-system --name alb-ingress-ctlr-1 -f alb-ingress-controller/values.yml --version 0.0.6`

### Upgrade the `happy-panda` release to a new version of the chart from a GitHub repo

* `helm github upgrade happy-panda --repo git@github.com:kubernetes/charts.git --path stable/external-dns`
* `helm github upgrade happy-panda --repo git@github.com:coreos/alb-ingress-controller.git --ref 6d64984 --path alb-ingress-controller-helm`
* `helm github upgrade happy-panda --repo git@github.com:coreos/alb-ingress-controller.git --ref master --path alb-ingress-controller-helm -f alb-ingress-controller/values.yml --version 0.0.6`
67 changes: 43 additions & 24 deletions github-install.sh → github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,35 @@ set -e

usage() {
cat << EOF
Install Helm charts from Github
This is a helm plugin that installs raw helm charts from github.
Example Usage:
helm github install --repo git@github.com:coreos/alb-ingress-controller.git --ref master --path alb-ingress-controller-helm
Install or upgrade Helm charts from Github
https://docs.helm.sh/helm/#helm-install
https://docs.helm.sh/helm/#helm-upgrade
Available Commands:
helm github install Install a Helm chart from Github
helm github install Install a Helm chart from Github
helm github upgrade <release> Upgrades the release to a new version of the Helm chart from Github
Available Flags:
--repo, -r (Required) Specify the repo to install
--ref, -b (Optional) Specify the branch, commit, or reference to checkout before installing
--path, -p (Optional) Specify a path within repo where helm chart is stored. Must be relative to base of repo.
--path, -p (Optional) Specify a path within repo where helm chart is stored. Must be relative to base of repo
--debug (Optional) Verbosity intensifies... ...
--help (Optional) This text.
--update, -u (Optional) Update this plugin to latest master.
--update, -u (Optional) Update this plugin to the latest version from the master branch
Example Usage:
helm github install --repo git@github.com:coreos/alb-ingress-controller.git --ref master --path alb-ingress-controller-helm
helm github upgrade happy-panda --repo git@github.com:kubernetes/charts.git --path stable/external-dns
EOF
}

# Lets create the passthru array
# Create the passthru array
PASSTHRU=()
while [[ $# -gt 0 ]]
do
key="$1"

# Arg Parse
# Parse arguments
case $key in
-r|--repo)
REPO="$2"
Expand Down Expand Up @@ -69,22 +72,22 @@ set -- "${PASSTHRU[@]}"

# Show help if flagged
if [ "$HELP" == "TRUE" ]; then
usage
exit 1
usage
exit 0
fi

# Update plugin
# Update this Helm plugin
if [ "$UPDATE" == "TRUE" ]; then
cd "$HELM_HOME/plugins/helm-github"
git pull
PLUGIN_VERSION=$(git log --pretty=format:'%h' -n 1)
cd -
echo "Success! Updated this plugin to: $PLUGIN_VERSION"
exit 1
cd "$HELM_HOME/plugins/helm-github"
git pull
PLUGIN_VERSION=$(git log --pretty=format:'%h' -n 1)
cd -
echo "Success! Updated this plugin to: $PLUGIN_VERSION"
exit 0
fi

if [ -z "$REPO" ]; then
echo "Error: No Repo provided. Please provide --repo flag."
echo "Error: No Repo provided. Please provide --repo flag"
usage
exit 1
fi
Expand Down Expand Up @@ -118,7 +121,7 @@ fi
if [ -d "${REPO_LOCATION}" ]; then
cd $REPO_LOCATION
git checkout master;
git pull;
git pull;
else
git clone $REPO $REPO_LOCATION;
cd $REPO_LOCATION;
Expand All @@ -130,6 +133,22 @@ git checkout $BRANCH
# Exit the repo
cd -

# Install it!
# Take out the first variable in passthru (install) so that helm install works
helm install $REPO_LOCATION/$CHARTPATH "${PASSTHRU[@]:1}"
# COMMAND must be either 'install' or 'upgrade'
COMMAND=${PASSTHRU[0]}

if [ "$COMMAND" == "install" ]; then
echo "Installing the Helm chart from the GitHub repo"
# Take out the first variable in passthru (install) so that helm install works
helm install "${PASSTHRU[@]:1}" $REPO_LOCATION/$CHARTPATH
exit 0
elif [ "$COMMAND" == "upgrade" ]; then
RELEASE=${PASSTHRU[1]}
echo "Upgrading ${RELEASE} release to a new version of the chart from the GitHub repo"
# Take out the first two variables in passthru (install <release>) so that helm upgrade works
helm upgrade "${PASSTHRU[@]:2}" $RELEASE $REPO_LOCATION/$CHARTPATH
exit 0
else
echo "Error: Invalid command, must be one of 'install' or 'upgrade'"
usage
exit 1
fi
8 changes: 4 additions & 4 deletions plugin.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "github"
version: "0.1.0"
usage: "Install helm charts from github repos"
version: "0.2.0"
usage: "Install or upgrade Helm charts from GitHub repos"
description: |-
This plugin installs raw Helm charts from Github.
command: "$HELM_PLUGIN_DIR/github-install.sh"
This plugin installs or upgrades raw Helm charts from Github
command: "$HELM_PLUGIN_DIR/github.sh"

0 comments on commit 945aa21

Please sign in to comment.