mirror of
https://github.com/hassio-addons/bashio.git
synced 2025-05-06 12:01:25 +00:00
✨ Adds support for fetching ports and port descriptions (#5)
This commit is contained in:
parent
8b9d173b0e
commit
22661a8e29
1 changed files with 62 additions and 0 deletions
|
@ -448,6 +448,68 @@ function bashio::addon.network() {
|
|||
bashio::addons "${slug}" "addons.${slug}.network" '.network'
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns a list of ports and their descriptions for this add-on.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Add-on slug (optional, default: self)
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::addon.network_description() {
|
||||
local slug=${1:-'self'}
|
||||
bashio::log.trace "${FUNCNAME[0]}" "$@"
|
||||
bashio::addons "${slug}" \
|
||||
"addons.${slug}.network_description" \
|
||||
'.network_description'
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns a user configured port number for a original port number.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Original port number
|
||||
# $2 Add-on slug (optional, default: self)
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::addon.port() {
|
||||
local port=${1:-}
|
||||
local slug=${2:-'self'}
|
||||
|
||||
bashio::log.trace "${FUNCNAME[0]}" "$@"
|
||||
|
||||
# Default to TCP if not specified.
|
||||
if [[ "${port}" != *"/"* ]]; then
|
||||
port="${port}/tcp"
|
||||
fi
|
||||
|
||||
bashio::addons \
|
||||
"${slug}" \
|
||||
"addons.${slug}.network.${port//\//-}" \
|
||||
".network[\"${port}\"]"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns a description for port number for this add-on.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Original port number
|
||||
# $2 Add-on slug (optional, default: self)
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::addon.port_description() {
|
||||
local port=${1:-}
|
||||
local slug=${2:-'self'}
|
||||
|
||||
bashio::log.trace "${FUNCNAME[0]}" "$@"
|
||||
|
||||
# Default to TCP if not specified.
|
||||
if [[ "${port}" != *"/"* ]]; then
|
||||
port="${port}/tcp"
|
||||
fi
|
||||
|
||||
bashio::addons \
|
||||
"${slug}" \
|
||||
"addons.${slug}.network_description.${port//\//-}" \
|
||||
".network_description[\"${port}\"]"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns whether or not this add-on runs on the host network.
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue