Use different endpoint for add-on options (#88)

This commit is contained in:
Pascal Vizeli 2021-11-09 09:26:33 +01:00 committed by GitHub
parent ee555d9afb
commit 8aa75b069b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -544,6 +544,30 @@ function bashio::addon.option() {
bashio::cache.flush_all
}
# ------------------------------------------------------------------------------
# Returns a JSON object with add-on specific config for the addon itself.
#
# This can be only used by self.
# ------------------------------------------------------------------------------
function bashio::addon.config() {
local cache_key="addons.self.options.config"
local response
bashio::log.trace "${FUNCNAME[0]}" "$@"
if bashio::cache.exists "${cache_key}"; then
bashio::cache.get "${cache_key}"
return "${__BASHIO_EXIT_OK}"
fi
response=$(bashio::api.supervisor GET "/addons/self/options/config" false)
bashio::cache.set "${cache_key}" "${response}"
printf "%s" "${response}"
return "${__BASHIO_EXIT_OK}"
}
# ------------------------------------------------------------------------------
# Returns a list of ports which are exposed on the host network for this add-on.
#

View file

@ -45,7 +45,7 @@ function bashio::config() {
end
QUERY
options=$(bashio::addon.options)
options=$(bashio::addon.config)
result=$(bashio::jq "${options}" "${query}")
if [[ "${result}" == "null" ]] && bashio::var.has_value "${default_value}";