From 1afeb7c5fae16b789ace04ce64473aec542c1ec6 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Mon, 7 Oct 2024 18:18:11 +0200 Subject: [PATCH] Update version to 2.0.2 and improve repository token handling Bump the program version from 2.0.1 to 2.0.2. Enhance the repository token and API handling by allowing repository-specific [.api] and [.token] values to override global settings, with a fallback mechanism for global values. Added more comprehensive comments to clarify the override logic. --- src/octopower | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/octopower b/src/octopower index dbaff60..0711515 100755 --- a/src/octopower +++ b/src/octopower @@ -3,7 +3,7 @@ # Program name PROGRAM_NAME="OctoPower" PROGRAM_CODE="octopower" -PROGRAM_VERSION="2.0.1" +PROGRAM_VERSION="2.0.2" PROGRAM_V="2.0" PROGRAM_URL="https://git.vdm.dev/octoleo/${PROGRAM_CODE}" @@ -710,12 +710,19 @@ command -v sed >/dev/null 2>&1 || { setValueFromJson 'VDM_BRANCH' '.branch' "${repository}" || VDM_BRANCH="default" setValueFromJson 'VDM_API_NAME' '.api_name' "${repository}" || VDM_API_NAME="VDM_GLOBAL_API" setValueFromJson 'VDM_TOKEN_NAME' '.token_name' "${repository}" || VDM_TOKEN_NAME="VDM_GLOBAL_TOKEN" - # set the package (api/toke) - tmp_api=${!VDM_API_NAME} - tmp_token=${!VDM_TOKEN_NAME} - # allow direct overriding (api/toke) - getConfigValue 'VDM_API' '.repository.api' false || VDM_API="${tmp_api}" - getConfigValue 'VDM_TOKEN' '.repository.token' false || VDM_TOKEN="${tmp_token}" + # Now check if the repository has its own `.api` and `.token` values + # If present, override the global values + if setValueFromJson 'VDM_API' '.api' "${repository}"; then + setValueFromJson 'VDM_TOKEN' '.token' "${repository}" || VDM_TOKEN='' + else + # set the package (api/toke) + tmp_api=${!VDM_API_NAME} + tmp_token=${!VDM_TOKEN_NAME} + # allow direct overriding (api) + getConfigValue 'VDM_API' '.repository.api' false || VDM_API="${tmp_api}" + # allow direct overriding (toke) + getConfigValue 'VDM_TOKEN' '.repository.token' false || VDM_TOKEN="${tmp_token}" + fi # check if we have some errors already if $has_error; then clearFileEnv