-
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.
Signed-off-by: Julien Bouyoud <jBouyoud@users.noreply.github.com>
- Loading branch information
Showing
8 changed files
with
213 additions
and
6 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/tests/.tmp/ | ||
/tests/coverage/ | ||
/node_modules/ | ||
/repository/ |
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 sh | ||
|
||
set -eu | ||
|
||
add_usage() { | ||
cat <<EOF | ||
helm config-scheme add NAME FILE-URI... | ||
Create a new configuration scheme NAME with all specified FILE-URI | ||
$(file_uri_substitution_help) | ||
EOF | ||
} | ||
|
||
add() { | ||
if [ $# -lt 2 ]; then | ||
add_usage | ||
exit 1 | ||
fi | ||
scheme_name="${1}" | ||
shift | ||
|
||
if repository_scheme_exists "${scheme_name}"; then | ||
log_error "[add] Scheme '${scheme_name}' already exists" | ||
exit 2 | ||
fi | ||
|
||
repository_create_scheme "${scheme_name}" | ||
|
||
for file_uri in "$@"; do | ||
repository_scheme_append_file_uri "${scheme_name}" "${file_uri}" | ||
done | ||
} |
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,38 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
file_uri_substitution_help() { | ||
cat <<EOF | ||
FILE-URI specify values in a YAML file or a URL | ||
File uri support some substitutions: | ||
| variable | substituted by | default value | | ||
| ------------- | ---------------------------------------------------- | ------------- | | ||
| {{namespace}} | Helm command namespace | unknown | | ||
| {{release}} | Helm release name | RELEASE-NAME | | ||
| {{chart}} | Helm chart name | CHART_NAME | | ||
| {{env}} | Replaced by the environment variable value for "env" | unknown | | ||
Example: | ||
- local/file.yaml | ||
- https://my.repo.com/config/{{namespace}}/file.yaml | ||
- git+https://github.com/user/repo/{{chart}}.yaml?ref=master | ||
- secrets://local/{{release}}.yaml | ||
- local/{{my_env}}.yaml | ||
EOF | ||
} | ||
|
||
file_uri_subst() { | ||
file_uri="${1}" | ||
|
||
if [ -z "${file_uri}" ]; then | ||
log_error "No file uri specified" | ||
exit 1 | ||
fi | ||
|
||
echo "${file_uri}" | sed 's/{{/${/g' | sed 's/}}/}/g' | ||
} |
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,35 @@ | ||
#!/usr/bin/env sh | ||
|
||
set -eu | ||
|
||
# Configuration directly for all scheme | ||
CONFIG_REPOSITORY="${HELM_CONFIG_SCHEME_REPOSITORY:-${HELM_PLUGIN_DIR}/repository}" | ||
|
||
# Make sure that directory exists | ||
mkdir -p "${CONFIG_REPOSITORY}" | ||
|
||
_repository_scheme_file() { | ||
echo "${CONFIG_REPOSITORY}/${1}" | ||
} | ||
|
||
repository_scheme_exists() { | ||
test -f "$(_repository_scheme_file "${1}")" | ||
} | ||
|
||
repository_create_scheme() { | ||
scheme_name="${1}" | ||
|
||
log_info "[registry] Creating '${scheme_name}'" | ||
printf '' >"$(_repository_scheme_file "${scheme_name}")" | ||
} | ||
|
||
repository_scheme_append_file_uri() { | ||
scheme_name="${1}" | ||
file_uri="${2}" | ||
|
||
log_info "[registry] Add file uri '${file_uri}' to scheme '${scheme_name}'" | ||
file_uri_scheme="$(file_uri_subst "${file_uri}")" | ||
scheme_file="$(_repository_scheme_file "${scheme_name}")" | ||
|
||
echo "${file_uri_scheme}" >>"${scheme_file}" | ||
} |
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
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,7 @@ | ||
|
||
assert_config_repository_scheme() { | ||
file="${HELM_CONFIG_SCHEME_REPOSITORY}/${1}" | ||
|
||
assert_file_exist "${file}" | ||
assert_equal "$(cat "${file}")" "${2}" | ||
} |
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
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