feat: upgrade gitops ability to fetch files from different repos
This commit is contained in:
parent
3e361cd03c
commit
d488a87dd4
@ -4,7 +4,7 @@ set -euo pipefail
|
||||
PERSON="${1:?Missing PERSON argument}"
|
||||
HOST="alps:3222"
|
||||
PROTOCOL="http"
|
||||
REPO="babbarc/workspaces"
|
||||
REPO=("babbarc/workspaces" "babbarc/workspaces-sec-alps-infilytics")
|
||||
BRANCH="master"
|
||||
LOG_FILE="/tmp/.gitops-router-${PERSON}.log"
|
||||
|
||||
@ -39,9 +39,9 @@ log() {
|
||||
# ─────────────────────────────────────────────
|
||||
# Build the raw URL for fetching files
|
||||
geturl() {
|
||||
local type="$1" file="$2"
|
||||
local repo="$1" type="$2" file="$3"
|
||||
printf '%s://%s/%s/%s/branch/%s/%s\n' \
|
||||
"$PROTOCOL" "$HOST" "$REPO" "$type" "$BRANCH" "$file"
|
||||
"$PROTOCOL" "$HOST" "${REPO[$repo]}" "$type" "$BRANCH" "$file"
|
||||
}
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
@ -53,13 +53,13 @@ run() {
|
||||
|
||||
# ─────────────────────────────────────────────
|
||||
# Download & install an artifact
|
||||
# update <file> <target-dir> <mode> [<type>]
|
||||
# update <repo> <file> <target-dir> <mode> [<type>]
|
||||
update() {
|
||||
local file="$1" dir="$2" mode="$3" type="${4:-raw}"
|
||||
local repo="$1" file="$2" dir="$3" mode="$4" type="${5:-raw}"
|
||||
local url out
|
||||
|
||||
out="$HOME/$dir/$(basename "$file")"
|
||||
url="$(geturl "$type" "$file")"
|
||||
url="$(geturl "$repo" "$type" "$file")"
|
||||
|
||||
[[ -f "$out" ]] && chmod 700 "$out"
|
||||
|
||||
@ -157,12 +157,13 @@ build)
|
||||
;;
|
||||
update)
|
||||
case "${args[0]}" in
|
||||
containerfile) update Containerfile . 500 ;;
|
||||
access) update access.yml . 400 ;;
|
||||
ssh_router) update ssh_router.sh .local/bin 500 ;;
|
||||
gitops_router) update gitops_router.sh .local/bin 500 ;;
|
||||
home_tar) update home.tar.gz . 500 media ;;
|
||||
gitconfig) update gitconfig.template . 500 ;;
|
||||
containerfile) update 0 Containerfile . 500 ;;
|
||||
access) update 1 access.yml . 400 ;;
|
||||
ssh_router) update 0 ssh_router.sh .local/bin 500 ;;
|
||||
gitops_router) update 0 gitops_router.sh .local/bin 500 ;;
|
||||
validate_command) update 1 validate_command_access.sh .local/bin 500 ;;
|
||||
home_tar) update 0 home.tar.gz . 500 media ;;
|
||||
gitconfig) update 1 gitconfig.template . 500 ;;
|
||||
*) log ERROR "update: invalid arg '${args[0]}'" ;;
|
||||
esac
|
||||
;;
|
||||
|
Loading…
x
Reference in New Issue
Block a user