From d307586b8a0f1271ac57b2e769b56d6e45281a61 Mon Sep 17 00:00:00 2001 From: Martin Maruskin Date: Tue, 19 Oct 2021 14:03:22 +0200 Subject: [PATCH 1/2] WEEK2CHALLENGE changes: - formatting - quotes for variables - curly brackets - unused variable removal --- topics/Week2_Best_Practices/challenge/btpguid | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 topics/Week2_Best_Practices/challenge/btpguid diff --git a/topics/Week2_Best_Practices/challenge/btpguid b/topics/Week2_Best_Practices/challenge/btpguid new file mode 100644 index 000000000..76c951e0f --- /dev/null +++ b/topics/Week2_Best_Practices/challenge/btpguid @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# btpguid - return BTP subaccount/directory GUIDs + +# Usage: btpguid [-t|--target] displayname + +# Returns the GUID for the given subaccount or directory, which is +# specified by name. If the option -t or --target is specified, it +# will also set that subaccount or directory as the target. + + # Requires the btp CLI. Will direct you to log in first if you're + # not already logged in. + + # It uses the detail from the output of this command: + # btp get accounts/global-account --show-hierarchy + +# Uses the "${2:-$1}" technique seen in fff - see +# https://qmacro.org/autodidactics/2021/09/03/exploring-fff-part-1-main/ +# for details. + +gethier () { + btp get accounts/global-account --show-hierarchy 2> /dev/null +} + +main() { + + local hierarchy subtype guid displayname rc=0 + + displayname="${2:-$1}" + + [[ -z displayname ]] && { + echo "No display name specified" + exit 1 + } + + hierarchy="$(gethier)" || { btp login && hierarchy="$(gethier)"; } + read -r subtype guid <<< "$(grep -P -o "^(subaccount|directory)\s+(\S+)(?=\s+$displayname)" <<< "$hierarchy")" + + # Set the subtype as target if requested + [[ $1 == -t ]] || [[ $1 == --target ]] && { + btp target "--${subtype}" "$guid" &> /dev/null + rc=$? + } + + echo "$guid" + return $rc + +} + +main "$@" \ No newline at end of file From 086b117a107cc1bfb43a11386544b825cf037c9c Mon Sep 17 00:00:00 2001 From: Martin Maruskin Date: Fri, 12 Nov 2021 00:28:15 +0100 Subject: [PATCH 2/2] entry added --- contest/entry.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contest/entry.csv b/contest/entry.csv index 2c8c22b29..087198812 100644 --- a/contest/entry.csv +++ b/contest/entry.csv @@ -57,4 +57,4 @@ https://github.com/seVladimirs/dotfiles,vladimirs.semikins https://github.com/ag3silaus/saptutorials,ag3silaus https://github.com/lvhengel/cap-azuread-luigi-ui5,leo.vanhengel https://github.com/MartinStenzig/teched-2021,martin.stenzig3 - +https://github.com/softy12/ABAP-DTP_TO_BE_PUSHED2HANA,martin.maruskin2