From f3365f4949a4b0763073fe282710ea906ce4e177 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Sun, 7 Jul 2024 20:19:08 +0200 Subject: [PATCH 1/8] fix: allow use without @ if file path is empty --- helm-git-plugin.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/helm-git-plugin.sh b/helm-git-plugin.sh index 9918241d..1fd2e9da 100755 --- a/helm-git-plugin.sh +++ b/helm-git-plugin.sh @@ -293,10 +293,13 @@ main() { error "$error_invalid_protocol" git_repo_path=$(echo "${_uri_path}" | cut -d'@' -f 1) + git_file_path=$(echo "${_uri_path}" | cut -d'@' -f 2) + if [ -z "$git_file_path" ]; then + git_file_path=$(basename "$git_repo_path") + git_repo_path=$(dirname "$git_repo_path") + fi readonly git_repo_path trace "git_repo_path: $git_repo_path" - - git_file_path=$(echo "${_uri_path}" | cut -d'@' -f 2) readonly git_file_path trace "git_file_path: $git_file_path" From 0f54f3cb6e94f2e27e7cf7d669427fb7a632ae51 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Sun, 7 Jul 2024 20:22:52 +0200 Subject: [PATCH 2/8] Update helm-git-plugin.sh --- helm-git-plugin.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helm-git-plugin.sh b/helm-git-plugin.sh index 1fd2e9da..f0d9c3e5 100755 --- a/helm-git-plugin.sh +++ b/helm-git-plugin.sh @@ -292,8 +292,8 @@ main() { string_contains "$allowed_protocols" "$git_scheme" || error "$error_invalid_protocol" - git_repo_path=$(echo "${_uri_path}" | cut -d'@' -f 1) - git_file_path=$(echo "${_uri_path}" | cut -d'@' -f 2) + git_repo_path=$(echo "${_uri_path}" | awk -F'@' '{print $1}') + git_file_path=$(echo "${_uri_path}" | awk -F'@' '{print $2}') if [ -z "$git_file_path" ]; then git_file_path=$(basename "$git_repo_path") git_repo_path=$(dirname "$git_repo_path") From 49810256c549890cc76da2047342a15af69cd5d6 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Sun, 7 Jul 2024 20:28:55 +0200 Subject: [PATCH 3/8] Update 04-uri-parsing.bats --- tests/04-uri-parsing.bats | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/04-uri-parsing.bats b/tests/04-uri-parsing.bats index b096b8c8..6119ea92 100644 --- a/tests/04-uri-parsing.bats +++ b/tests/04-uri-parsing.bats @@ -86,3 +86,10 @@ load 'test-helper' [ $helm_dir = "charts/gitlab" ] [ $git_ref = "master" ] } + +@test "should discover path without path separator" { + parse_uri "git+https://github.com/jetstack/cert-manager" + [ $git_repo = "https://github.com/jetstack/cert-manager" ] + [ -z $helm_dir ] + [ $helm_file = "index.yaml" ] +} From 75596b06e1ec11a305e08975300f41f5f2235758 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Sun, 7 Jul 2024 20:29:42 +0200 Subject: [PATCH 4/8] Update 04-uri-parsing.bats --- tests/04-uri-parsing.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/04-uri-parsing.bats b/tests/04-uri-parsing.bats index 6119ea92..5a483283 100644 --- a/tests/04-uri-parsing.bats +++ b/tests/04-uri-parsing.bats @@ -88,7 +88,7 @@ load 'test-helper' } @test "should discover path without path separator" { - parse_uri "git+https://github.com/jetstack/cert-manager" + parse_uri "git+https://github.com/jetstack/cert-manager/index.yaml" [ $git_repo = "https://github.com/jetstack/cert-manager" ] [ -z $helm_dir ] [ $helm_file = "index.yaml" ] From 7af337eee0ca26f3a614fb11f01eebb0114267d5 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Sun, 7 Jul 2024 20:31:19 +0200 Subject: [PATCH 5/8] Update helm-git-plugin.sh --- helm-git-plugin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm-git-plugin.sh b/helm-git-plugin.sh index 3826f962..97078422 100755 --- a/helm-git-plugin.sh +++ b/helm-git-plugin.sh @@ -276,7 +276,7 @@ parse_uri() { _git_file_path=$(echo "${_uri_path}" | awk -F'@' '{print $2}') if [ -z "$_git_file_path" ]; then _git_file_path=$(basename "$_git_path") - _git_path=$(dirname "$_git_file_path") + _git_path=$(dirname "$_git_path") fi trace "_git_path: $_git_path" trace "_git_file_path: $_git_file_path" From 2f6ca724ba8e65976c096a3810aad30d1ab15691 Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Tue, 9 Jul 2024 18:48:55 +0200 Subject: [PATCH 6/8] Update 04-uri-validation.bats --- tests/04-uri-validation.bats | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/04-uri-validation.bats b/tests/04-uri-validation.bats index b61138db..4dfd067e 100644 --- a/tests/04-uri-validation.bats +++ b/tests/04-uri-validation.bats @@ -73,3 +73,8 @@ load 'test-helper' _run_helm_git "git+https://github.com/hashicorp/vault-helm@/index.yaml?ref=v0.5.0" [ $status = 0 ] } + +@test "should success with empty inline git_file_path" { + _run_helm_git "git+https://gitlab.com/one-touch-pipeline/weskit/helm-deployment/index.yaml?ref=ee259f65191cef10855438321ce99e37873918b6" + [ $status = 0 ] +} From 6be4228f8cc33d67c28da279a3b52fcfbb2ed6da Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Tue, 9 Jul 2024 18:51:08 +0200 Subject: [PATCH 7/8] Update README.md --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0309e52a..e34421cb 100644 --- a/README.md +++ b/README.md @@ -33,15 +33,16 @@ to the plugin, please see [these instructions](.github/CONTRIBUTING.md). Here's the Git urls format, followed by examples: - git+https://[provider.com]/[user]/[repo]@[path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]] - git+ssh://git@[provider.com]/[user]/[repo]@[path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]] - git+file://[path/to/repo]@[path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]] + git+https://[provider.com]/[user]/[repo][@path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]] + git+ssh://git@[provider.com]/[user]/[repo][@path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]] + git+file://[path/to/repo][@path/to/charts][?[ref=git-ref][&sparse=0][&depupdate=0][&package=0]] git+https://github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2&sparse=0 git+ssh://git@github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2&sparse=1 git+ssh://git@github.com/jetstack/cert-manager@deploy/charts?ref=v0.6.2 git+https://github.com/istio/istio@install/kubernetes/helm?ref=1.5.4&sparse=0&depupdate=0 git+https://github.com/bitnami/charts@bitnami/wordpress?ref=master&sparse=0&depupdate=0&package=0 + git+https://gitlab.com/one-touch-pipeline/weskit/helm-deployment?ref=ee259f65191cef10855438321ce99e37873918b6 Add your repository: From d51806afc8a74b3106ca8dc1d20f5d185a29e1db Mon Sep 17 00:00:00 2001 From: Zadkiel AHARONIAN Date: Tue, 9 Jul 2024 18:52:52 +0200 Subject: [PATCH 8/8] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e34421cb..1780c606 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,8 @@ You can enable debug output by setting `HELM_GIT_DEBUG` environment variable to In order to debug in a more efficient maneer, I advise you use `helm fetch` instead of `helm repo add`. +You can enable more advanced output by setting `HELM_GIT_TRACE` environment variable to `1`. + ## Contributing Contributions are welcome! Please see [these instructions](.github/CONTRIBUTING.md) that will help you to develop the plugin.