Skip to content

Commit

Permalink
fix: args parsing issues with pattern like '--x=y'
Browse files Browse the repository at this point in the history
  • Loading branch information
jBouyoud committed Feb 10, 2022
1 parent ba4e9d6 commit 205d68b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 35 deletions.
43 changes: 9 additions & 34 deletions scripts/lib/file_uri_substitution.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,20 @@ _get_subst_args_value() {

_is_helm_flag() {
case "${1:-}" in
-g | --generate-name)
log_error " Unable to proceed repeatable configuration with a generated name"
return 2
;;
--name-template)
log_error " name-template flag is not supported"
return 2
;;
# Global Flags :: Key, Value
--repository-config | --repository-cache | --registry-config | -n | --namespace | \
--kubeconfig | --kube-token | --kube-context | --kube-as-user | --kube-as-group | \
--kube-apiserver)
echo 2
;;
# Global Flags :: Key
-h | --help | --debug)
echo 1
;;
# Value Options Flags https://github.com/helm/helm/blob/master/cmd/helm/flags.go#L41
-f | --values | --set | --set-string | --set-file)
echo 2
Expand All @@ -130,53 +134,24 @@ _is_helm_flag() {
--version | --keyring | --repo | --username | --password | --cert-file | --key-file | --ca-file)
echo 2
;;
--verify | --insecure-skip-tls-verify)
echo 1
;;
# https://github.com/helm/helm/blob/master/cmd/helm/flags.go#L63
-o | --output | --post-renderer)
echo 2
;;
# Lint flags
--strict | --with-subcharts)
echo 1
;;
# Install Flags
--create-namespace | --dry-run | --no-hooks | --replace | --wait | --devel | \
--dependency-update | --disable-openapi-validation | --atomic | --skip-crds | \
--render-subchart-notes)
echo 1
;;
--timeout | --description)
echo 2
;;
-g | --generate-name)
log_error " Unable to proceed repeatable configuration with a generated name"
return 2
;;
--name-template)
log_error " name-template flag is not supported"
return 2
;;
# Template Flags
-s | --show-only | --output-dir | --api-versions | --release-name)
echo 2
;;
--validate | --include-crds | --is-upgrade)
echo 1
;;
# Upgrade Flags
--history-max)
# Already existing
# --timeout | --description
echo 2
;;
-i | --install | --recreate-pods | --force | --reset-values | \
--reuse-values | --cleanup-on-fail)
# Already existing
# --create-namespace | --devel | --dry-run | --no-hooks |
# --disable-openapi-validation | --skip-crds |
# --wait | --atomic | --render-subchart-notes
-*)
echo 1
;;
*)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/downloader.bats
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ YAML
"git+https://github.com/jBouyoud/helm-config-scheme@tests/assets/git.yaml?ref=main" \
"git+https://github.com/jBouyoud/helm-config-scheme@tests/assets/{{namespace}}/git.yaml?ref=main"

run helm config-scheme downloader unused unused unused config://test -n namespace 2>&1
run helm config-scheme downloader unused unused unused config://test --namespace=namespace 2>&1
assert_success
assert-downloader-output "namespace" "CHART-NAME" "RELEASE-NAME" "test"
assert_output --partial "[config-scheme][downloader] Loading values for 'git+https://github.com/jBouyoud/helm-config-scheme@CHART-NAME.yaml?ref=master' skipped."
Expand Down
32 changes: 32 additions & 0 deletions tests/unit/template.bats
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,38 @@ YAML
)"
}

@test "template: . reversed args" {
if is_windows; then
skip
fi
if is_coverage; then
skip
fi

create_chart
create_config_scheme test

cd "${TEST_TEMP_DIR}/chart";
run helm template --kube-token bob --values=config://test --wait-for-jobs --namespace=namespace my-release . 2>&1
cd -
assert_success
assert-downloader-output "namespace" "chart" "my-release" "test"

assert_output --partial "kind: Ingress"
assert_output --partial "$(cat <<-YAML
annotations:
default/chart.yaml: "true"
default/my-release.yaml: "true"
default/test.yaml: "true"
default/values.yaml: "true"
ns/chart.yaml: "true"
ns/my-release.yaml: "true"
ns/test.yaml: "true"
ns/values.yaml: "true"
YAML
)"
}

@test "template: . without release" {
if is_windows; then
skip
Expand Down

0 comments on commit 205d68b

Please sign in to comment.