Skip to content

Commit

Permalink
Update version to 2.0.2 and improve repository token handling
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Llewellynvdm committed Oct 7, 2024
1 parent cac27ad commit 1afeb7c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/octopower
Original file line number Diff line number Diff line change
Expand Up @@ -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}"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1afeb7c

Please sign in to comment.