Skip to content

Commit 9f025a3

Browse files
authored
feat: allow empty file path (#284)
1 parent 7640834 commit 9f025a3

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ to the plugin, please see [these instructions](.github/CONTRIBUTING.md).
3333

3434
Here's the Git urls format, followed by examples:
3535

36-
git+https://[provider.com]/[user]/[repo]@[path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]]
37-
git+ssh://git@[provider.com]/[user]/[repo]@[path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]]
38-
git+file://[path/to/repo]@[path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]]
36+
git+https://[provider.com]/[user]/[repo][@path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]]
37+
git+ssh://git@[provider.com]/[user]/[repo][@path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]]
38+
git+file://[path/to/repo][@path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]]
3939

4040
git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2&sparse=0
4141
git+ssh://[email protected]/jetstack/cert-manager@deploy/charts?ref=v0.6.2&sparse=1
4242
git+ssh://[email protected]/jetstack/cert-manager@deploy/charts?ref=v0.6.2
4343
git+https://github.com/istio/istio@install/kubernetes/helm?ref=1.5.4&sparse=0&depupdate=0
4444
git+https://github.com/bitnami/charts@bitnami/wordpress?ref=master&sparse=0&depupdate=0&package=0
45+
git+https://gitlab.com/one-touch-pipeline/weskit/helm-deployment?ref=ee259f65191cef10855438321ce99e37873918b6
4546

4647
Add your repository:
4748

@@ -103,6 +104,8 @@ You can enable debug output by setting `HELM_GIT_DEBUG` environment variable to
103104

104105
In order to debug in a more efficient maneer, I advise you use `helm fetch` instead of `helm repo add`.
105106

107+
You can enable more advanced output by setting `HELM_GIT_TRACE` environment variable to `1`.
108+
106109
## Contributing
107110

108111
Contributions are welcome! Please see [these instructions](.github/CONTRIBUTING.md) that will help you to develop the plugin.

helm-git-plugin.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,13 @@ parse_uri() {
294294
string_contains "$allowed_protocols" "$_git_scheme" ||
295295
error "$error_invalid_protocol"
296296

297-
_git_path=$(echo "${_uri_path}" | cut -d'@' -f 1)
297+
_git_path=$(echo "${_uri_path}" | awk -F'@' '{print $1}')
298+
_git_file_path=$(echo "${_uri_path}" | awk -F'@' '{print $2}')
299+
if [ -z "$_git_file_path" ]; then
300+
_git_file_path=$(basename "$_git_path")
301+
_git_path=$(dirname "$_git_path")
302+
fi
298303
trace "_git_path: $_git_path"
299-
300-
_git_file_path=$(echo "${_uri_path}" | cut -d'@' -f 2)
301304
trace "_git_file_path: $_git_file_path"
302305

303306
helm_dir=$(dirname "${_git_file_path}" | sed -r '/^[\.|/]$/d')

tests/04-uri-parsing.bats

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,10 @@ load 'test-helper'
8686
[ $helm_dir = "charts/gitlab" ]
8787
[ $git_ref = "master" ]
8888
}
89+
90+
@test "should discover path without path separator" {
91+
parse_uri "git+https://github.com/jetstack/cert-manager/index.yaml"
92+
[ $git_repo = "https://github.com/jetstack/cert-manager" ]
93+
[ -z $helm_dir ]
94+
[ $helm_file = "index.yaml" ]
95+
}

tests/04-uri-validation.bats

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,8 @@ load 'test-helper'
7373
_run_helm_git "git+https://github.com/hashicorp/vault-helm@/index.yaml?ref=v0.5.0"
7474
[ $status = 0 ]
7575
}
76+
77+
@test "should success with empty inline git_file_path" {
78+
_run_helm_git "git+https://gitlab.com/one-touch-pipeline/weskit/helm-deployment/index.yaml?ref=ee259f65191cef10855438321ce99e37873918b6"
79+
[ $status = 0 ]
80+
}

0 commit comments

Comments
 (0)