From e925b2d421b46adb5b2df4d98a78193974ad3358 Mon Sep 17 00:00:00 2001 From: Oliver Kurz Date: Tue, 23 Jul 2024 14:58:38 +0200 Subject: [PATCH] trigger-openqa_in_openqa: Allow to import for testability and extendability --- trigger-openqa_in_openqa | 55 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/trigger-openqa_in_openqa b/trigger-openqa_in_openqa index 027a93d..7c22ec7 100755 --- a/trigger-openqa_in_openqa +++ b/trigger-openqa_in_openqa @@ -19,7 +19,33 @@ client_prefix=${client_prefix:-} full_run=${FULL:-} group_id="${group_id:-"openQA"}" +usage() { + cat << EOF +Usage: $0 [OPTIONS] + +Triggers tests on an openQA instance testing openQA itself. + +Can be configured additionally with environment variables. + +Options: + -h, --help display this help +EOF + exit "$1" +} + main() { + opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1 + eval set -- "$opts" + while true; do + case "$1" in + -h | --help) usage 0 ;; + --) + shift + break + ;; + *) break ;; + esac + done [ "$dry_run" = "1" ] && client_prefix="echo" local qcow build download_scenario @@ -66,31 +92,4 @@ trigger() { | tee job_post_response } -usage() { - cat << EOF -Usage: $0 [OPTIONS] - -Triggers tests on an openQA instance testing openQA itself. - -Can be configured additionally with environment variables. - -Options: - -h, --help display this help -EOF - exit "$1" -} - -opts=$(getopt -o h -l help -n "$0" -- "$@") || usage 1 -eval set -- "$opts" -while true; do - case "$1" in - -h | --help) usage 0 ;; - --) - shift - break - ;; - *) break ;; - esac -done - -main +caller 0 > /dev/null || main "$@"