Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove filename restrictions #120

Merged
merged 13 commits into from
Nov 13, 2020
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This fits multiple use cases:
- Need to keep charts private
- Doesn't want to package charts before installing
- Charts in a sub-path, or with another ref than `master`
- Pull values files directly from (private) Git repository

## Install

Expand Down Expand Up @@ -57,6 +58,10 @@ Fetching also works:
$ helm fetch cert-manager/cert-manager --version "0.6.6"
$ helm fetch git+https://github.com/jetstack/cert-manager@deploy/charts/cert-manager-v0.6.2.tgz?ref=v0.6.2

Pulling value files (Helm 3 only):

$ helm install . -f git+https://github.com/aslafy-z/helm-git@tests/fixtures/example-chart/values.yaml

### Environment

**name**|**description**|**default**
Expand Down
17 changes: 10 additions & 7 deletions helm-git-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,6 @@ main() {
readonly helm_repo_uri="git+$git_repo@$git_path?ref=$git_ref&sparse=$git_sparse"
debug "helm_repo_uri: $helm_repo_uri"

case "$helm_file" in
index.yaml) ;;
*.tgz) ;;
*) error "Target file name has to be either 'index.yaml' or a tgz release" ;;
esac


# Setup cleanup trap
cleanup() {
rm -rf "$git_root_path" \
Expand All @@ -223,6 +216,16 @@ main() {
readonly git_sub_path=$(path_join "$git_root_path" "$git_path")
git_checkout "$git_sparse" "$git_root_path" "$git_repo" "$git_ref" "$git_path" ||
error "Error while git_sparse_checkout"

case "$helm_file" in
index.yaml) ;;
*.tgz) ;;
*)
# value files
cat "$git_path/$helm_file"
return
;;
esac

readonly helm_target_path="$(mktemp -d "$TMPDIR/helm-git.XXXXXX")"
readonly helm_target_file="$(path_join "$helm_target_path" "$helm_file")"
Expand Down
9 changes: 9 additions & 0 deletions tests/03-cli.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ load 'test-helper'
run stat "$HELM_GIT_OUTPUT/cert-manager-v0.5.2.tgz"
[ $status = 0 ]
}

@test "fetch tests/fixtures/example-chart/values.yaml" {
run helm_init "$HELM_HOME"
url="git+https://github.com/aslafy-z/helm-git@tests/fixtures/example-chart/values.yaml?ref=master"
$HELM_GIT_DIRNAME/helm-git "" "" "" "$url" 2>/dev/null > "$HELM_GIT_OUTPUT/values.yaml"
[ $? = 0 ]
run stat "$HELM_GIT_OUTPUT/values.yaml"
[ $status = 0 ]
}