1 Commits

Author SHA1 Message Date
1afeb7c5fa 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.
2024-10-07 18:18:11 +02:00

View File

@ -3,7 +3,7 @@
# Program name # Program name
PROGRAM_NAME="OctoPower" PROGRAM_NAME="OctoPower"
PROGRAM_CODE="octopower" PROGRAM_CODE="octopower"
PROGRAM_VERSION="2.0.1" PROGRAM_VERSION="2.0.2"
PROGRAM_V="2.0" PROGRAM_V="2.0"
PROGRAM_URL="https://git.vdm.dev/octoleo/${PROGRAM_CODE}" 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_BRANCH' '.branch' "${repository}" || VDM_BRANCH="default"
setValueFromJson 'VDM_API_NAME' '.api_name' "${repository}" || VDM_API_NAME="VDM_GLOBAL_API" 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" setValueFromJson 'VDM_TOKEN_NAME' '.token_name' "${repository}" || VDM_TOKEN_NAME="VDM_GLOBAL_TOKEN"
# set the package (api/toke) # Now check if the repository has its own `.api` and `.token` values
tmp_api=${!VDM_API_NAME} # If present, override the global values
tmp_token=${!VDM_TOKEN_NAME} if setValueFromJson 'VDM_API' '.api' "${repository}"; then
# allow direct overriding (api/toke) setValueFromJson 'VDM_TOKEN' '.token' "${repository}" || VDM_TOKEN=''
getConfigValue 'VDM_API' '.repository.api' false || VDM_API="${tmp_api}" else
getConfigValue 'VDM_TOKEN' '.repository.token' false || VDM_TOKEN="${tmp_token}" # 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 # check if we have some errors already
if $has_error; then if $has_error; then
clearFileEnv clearFileEnv