-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- logging helper - is_help Signed-off-by: Julien Bouyoud <jBouyoud@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
is_help() { | ||
case "$1" in | ||
-h | --help | help) | ||
return 0 | ||
;; | ||
*) | ||
return 1 | ||
;; | ||
esac | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
# Output infos | ||
QUIET="${HELM_CONFIG_SCHEME_QUIET:-false}" | ||
|
||
log_info() { | ||
if [ "${QUIET}" = "false" ]; then | ||
printf "[config-scheme]%s\n" "$@" >&2 | ||
fi | ||
} | ||
|
||
log_error() { | ||
echo | ||
printf "[config-scheme]%s\n" "$@" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env bats | ||
|
||
load '../lib/helper' | ||
load '../bats/extensions/bats-support/load' | ||
load '../bats/extensions/bats-assert/load' | ||
load '../bats/extensions/bats-file/load' | ||
|
||
@test "quiet: default" { | ||
run helm config-scheme add scheme1 test.yaml | ||
assert_success | ||
assert_output --partial "[config-scheme][registry] Creating 'scheme1'" | ||
assert_output --partial "[config-scheme][registry] Add file uri 'test.yaml' to scheme 'scheme1'" | ||
} | ||
|
||
@test "quiet: -q" { | ||
run helm config-scheme -q add scheme1 test.yaml | ||
assert_success | ||
refute_output --partial "[config-scheme][registry] Creating 'scheme1'" | ||
refute_output --partial "[config-scheme][registry] Add file uri 'test.yaml' to scheme 'scheme1'" | ||
} | ||
|
||
@test "quiet: --quiet" { | ||
run helm config-scheme --quiet add scheme1 test.yaml | ||
assert_success | ||
refute_output --partial "[config-scheme][registry] Creating 'scheme1'" | ||
refute_output --partial "[config-scheme][registry] Add file uri 'test.yaml' to scheme 'scheme1'" | ||
} | ||
|
||
@test "quiet: env var" { | ||
HELM_CONFIG_SCHEME_QUIET=true run helm config-scheme -q add scheme1 test.yaml | ||
assert_success | ||
refute_output --partial "[config-scheme][registry] Creating 'scheme1'" | ||
refute_output --partial "[config-scheme][registry] Add file uri 'test.yaml' to scheme 'scheme1'" | ||
} |