From b9785b6295472bd636ee77bd70ae2ab3ba04f204 Mon Sep 17 00:00:00 2001 From: lyn Date: Tue, 24 Mar 2026 19:18:20 +0000 Subject: [PATCH] use ego-mgr for username/email instead of CLI flags --- .../scripts/git/create-git-account | 32 +++++++------------ .../scripts/git/repo-add-collaborators | 9 ++++++ git-hangman-lab/scripts/git/repo-config | 19 ++++++----- .../scripts/keycloak/create-keycloak-account | 32 +++++++------------ .../scripts/keycloak/set-name | 25 +++------------ 5 files changed, 48 insertions(+), 69 deletions(-) diff --git a/git-hangman-lab/scripts/git/create-git-account b/git-hangman-lab/scripts/git/create-git-account index adbe2cc..f2a8aae 100755 --- a/git-hangman-lab/scripts/git/create-git-account +++ b/git-hangman-lab/scripts/git/create-git-account @@ -3,27 +3,19 @@ # Get the directory where this script is located SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -# Parse arguments -while [[ $# -gt 0 ]]; do - case $1 in - --username) - username="$2" - shift 2 - ;; - --email) - email="$2" - shift 2 - ;; - *) - echo "Unknown option: $1" - exit 1 - ;; - esac -done +# Get username and email from ego-mgr +username=$(ego-mgr get default-username) +email=$(ego-mgr get email) -# Check if username and email are provided -if [[ -z "$username" || -z "$email" ]]; then - echo "Usage: $0 --username --email " +# Check if username is provided +if [[ -z "$username" ]]; then + echo "Error: default-username not set in ego-mgr, please contact ard" + exit 1 +fi + +# Check if email is provided +if [[ -z "$email" ]]; then + echo "Error: email not set in ego-mgr, please contact ard" exit 1 fi diff --git a/git-hangman-lab/scripts/git/repo-add-collaborators b/git-hangman-lab/scripts/git/repo-add-collaborators index de22e40..3a3104e 100755 --- a/git-hangman-lab/scripts/git/repo-add-collaborators +++ b/git-hangman-lab/scripts/git/repo-add-collaborators @@ -3,6 +3,15 @@ # Get the directory where this script is located SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +# Get username from ego-mgr +username=$(ego-mgr get default-username) + +# Check if username is provided +if [[ -z "$username" ]]; then + echo "Error: default-username not set in ego-mgr, please contact ard" + exit 1 +fi + roster=false # Parse arguments diff --git a/git-hangman-lab/scripts/git/repo-config b/git-hangman-lab/scripts/git/repo-config index ea8f816..0d84492 100755 --- a/git-hangman-lab/scripts/git/repo-config +++ b/git-hangman-lab/scripts/git/repo-config @@ -2,15 +2,13 @@ set -euo pipefail usage() { - echo "Usage: $0 --repo-path --email [--recursive]" + echo "Usage: $0 --repo-path [--recursive]" echo " --repo-path: Path to the git repository" - echo " --email: Email address to configure" echo " --recursive: Also configure all submodules (recursive)" exit 2 } REPO_PATH="" -EMAIL="" RECURSIVE=false while [[ $# -gt 0 ]]; do @@ -19,10 +17,6 @@ while [[ $# -gt 0 ]]; do REPO_PATH="${2:-}" shift 2 ;; - --email) - EMAIL="${2:-}" - shift 2 - ;; --recursive) RECURSIVE=true shift @@ -33,10 +27,19 @@ while [[ $# -gt 0 ]]; do esac done -if [[ -z "$REPO_PATH" || -z "$EMAIL" ]]; then +if [[ -z "$REPO_PATH" ]]; then usage fi +# Get email from ego-mgr +EMAIL=$(ego-mgr get email) + +# Check if email is provided +if [[ -z "$EMAIL" ]]; then + echo "Error: email not set in ego-mgr, please contact ard" + exit 1 +fi + # Check if it's a git repo (either .git is a directory or a file with gitdir: reference) is_git_repo() { local repo="$1" diff --git a/keycloak-hangman-lab/scripts/keycloak/create-keycloak-account b/keycloak-hangman-lab/scripts/keycloak/create-keycloak-account index c5a23cf..698ff1b 100755 --- a/keycloak-hangman-lab/scripts/keycloak/create-keycloak-account +++ b/keycloak-hangman-lab/scripts/keycloak/create-keycloak-account @@ -3,27 +3,19 @@ # Get the directory where this script is located SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -# Parse arguments -while [[ $# -gt 0 ]]; do - case $1 in - --username) - username="$2" - shift 2 - ;; - --email) - email="$2" - shift 2 - ;; - *) - echo "Unknown option: $1" - exit 1 - ;; - esac -done +# Get username and email from ego-mgr +username=$(ego-mgr get default-username) +email=$(ego-mgr get email) -# Check if username and email are provided -if [[ -z "$username" || -z "$email" ]]; then - echo "Usage: $0 --username --email " +# Check if username is provided +if [[ -z "$username" ]]; then + echo "Error: default-username not set in ego-mgr, please contact ard" + exit 1 +fi + +# Check if email is provided +if [[ -z "$email" ]]; then + echo "Error: email not set in ego-mgr, please contact ard" exit 1 fi diff --git a/keycloak-hangman-lab/scripts/keycloak/set-name b/keycloak-hangman-lab/scripts/keycloak/set-name index 479f07e..ab72943 100755 --- a/keycloak-hangman-lab/scripts/keycloak/set-name +++ b/keycloak-hangman-lab/scripts/keycloak/set-name @@ -3,29 +3,12 @@ # Get the directory where this script is located SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" -# Optional explicit username -username="" -while [[ $# -gt 0 ]]; do - case $1 in - --username) - username="$2" - shift 2 - ;; - *) - echo "Unknown option: $1" - echo "Usage: $0 [--username ]" - exit 1 - ;; - esac -done +# Get username from ego-mgr +username=$(ego-mgr get default-username) -# Default to secret-mgr if not provided +# Check if username is provided if [[ -z "$username" ]]; then - username=$(secret-mgr get-username --key keycloak) -fi - -if [[ -z "$username" ]]; then - echo "Error: No keycloak username found in secret-mgr" + echo "Error: default-username not set in ego-mgr, please contact ard" exit 1 fi