summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-12-15 05:23:22 +0100
committertv <tv@krebsco.de>2017-12-15 05:23:22 +0100
commita058a8d1f7cf77e4990e9c6c06c4a2681efbc47c (patch)
tree6c31581e31eeb6feff0735d5ad4ed4d0a2ee7bd7 /bin
parent399c2e25188104387bc8e9723f991955fe76806d (diff)
populate_*: unify argumentsv2.1.1
Diffstat (limited to 'bin')
-rwxr-xr-xbin/populate45
1 files changed, 11 insertions, 34 deletions
diff --git a/bin/populate b/bin/populate
index 8163ccd..7f43cf3 100755
--- a/bin/populate
+++ b/bin/populate
@@ -78,29 +78,8 @@ main() {(
while read -r source; do
key=$(echo "$source" | jq -r .key)
type=$(echo "$source" | jq -r .value.type)
- case $type in
- file)
- file_path=$(echo "$source" | jq -r .value.file.path)
- populate_file "$key" "$file_path"
- ;;
- git)
- git_url=$(echo "$source" | jq -r .value.git.url)
- git_ref=$(echo "$source" | jq -r .value.git.ref)
- populate_git "$key" "$git_url" "$git_ref"
- ;;
- pass)
- pass_dir=$(echo "$source" | jq -r .value.pass.dir)
- pass_name_root=$(echo "$source" | jq -r .value.pass.name)
- populate_pass "$key" "$pass_dir" "$pass_name_root"
- ;;
- symlink)
- symlink_target=$(echo "$source" | jq -r .value.symlink.target)
- populate_symlink "$key" "$symlink_target"
- ;;
- *)
- echo "Warning: ignoring $source" >&2
- ;;
- esac
+ conf=$(echo "$source" | jq -r .value.${type})
+ populate_"$type" "$key" "$conf"
done
)}
@@ -140,7 +119,7 @@ populate_file() {(
print_info populate_file "$@"
file_name=$1
- file_path=$2
+ file_path=$(echo "$2" | jq -r .path)
if is_local_target; then
file_target=$target_path/$file_name
@@ -160,15 +139,14 @@ populate_git() {(
print_info populate_git "$@"
git_name=$1
- git_url=$2
- git_ref=$3
+ git_url=$(echo "$2" | jq -r .url)
+ git_ref=$(echo "$2" | jq -r .ref)
git_work_tree=$target_path/$git_name
{
echo set -efu
- echo git_name=$(quote "$git_name")
echo git_url=$(quote "$git_url")
echo git_ref=$(quote "$git_ref")
@@ -208,8 +186,8 @@ populate_pass() {(
print_info populate_pass "$@"
pass_target_name=$1
- pass_dir=$2
- pass_name_root=$3
+ pass_dir=$(echo "$2" | jq -r .dir)
+ pass_name_root=$(echo "$2" | jq -r .name)
if is_local_target; then
pass_target=$target_path/$pass_target_name
@@ -253,20 +231,19 @@ populate_symlink() {(
print_info populate_symlink "$@"
symlink_name=$1
- symlink_source=$2
-
- symlink_target=$target_path/$symlink_name
+ symlink_target=$(echo "$2" | jq -r .target)
+ link_name=$target_path/$symlink_name
{
# TODO rm -fR instead of ln -f?
- echo ln -fns $(quote "$symlink_source" "$symlink_target")
+ echo ln -fns $(quote "$symlink_target" "$link_name")
} \
|
target_shell
)}
print_info() {
- printf '\e[1;33m* %s\e[m\n' "$*" >&2
+ printf '\e[1;33m%s\e[m\n' "$*" >&2
}
quote() {