From d488a87dd45d91e330a378a2c6de06bd53c47ad5 Mon Sep 17 00:00:00 2001 From: Pallav Vasa Date: Sat, 17 May 2025 14:42:06 +0000 Subject: [PATCH] feat: upgrade gitops ability to fetch files from different repos --- gitops_router.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/gitops_router.sh b/gitops_router.sh index 4702198..9343346 100644 --- a/gitops_router.sh +++ b/gitops_router.sh @@ -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 [] +# update [] 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 ;;