From 16e98bf09036f61e0baf4a9a56ab238c895e5326 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 17 Sep 2019 17:00:51 +0200 Subject: [PATCH] :fire: Removes secrets support, now natively supported by Hassio (#14) --- lib/bashio.sh | 3 --- lib/config.sh | 4 ---- lib/const.sh | 1 - lib/secrets.sh | 61 -------------------------------------------------- 4 files changed, 69 deletions(-) delete mode 100644 lib/secrets.sh diff --git a/lib/bashio.sh b/lib/bashio.sh index 7b16b0e..a33af4f 100644 --- a/lib/bashio.sh +++ b/lib/bashio.sh @@ -33,7 +33,6 @@ declare __BASHIO_LOG_FORMAT=${LOG_FORMAT:-${__BASHIO_DEFAULT_LOG_FORMAT}} declare __BASHIO_LOG_TIMESTAMP=${LOG_TIMESTAMP:-${__BASHIO_DEFAULT_LOG_TIMESTAMP}} declare __BASHIO_HIBP_ENDPOINT=${HIBP_ENDPOINT:-${__BASHIO_DEFAULT_HIBP_ENDPOINT}} declare __BASHIO_CACHE_DIR=${CACHE_DIR:-${__BASHIO_DEFAULT_CACHE_DIR}} -declare __BASHIO_HA_SECRETS=${HA_SECRETS:-${__BASHIO_DEFAULT_SECRETS}} # ============================================================================== # MODULES @@ -80,8 +79,6 @@ source "${__BASHIO_LIB_DIR}/net.sh" source "${__BASHIO_LIB_DIR}/pwned.sh" # shellcheck source=lib/repositories.sh source "${__BASHIO_LIB_DIR}/repositories.sh" -# shellcheck source=lib/secrets.sh -source "${__BASHIO_LIB_DIR}/secrets.sh" # shellcheck source=lib/services.sh source "${__BASHIO_LIB_DIR}/services.sh" # shellcheck source=lib/string.sh diff --git a/lib/config.sh b/lib/config.sh index ce4302c..651092a 100644 --- a/lib/config.sh +++ b/lib/config.sh @@ -46,10 +46,6 @@ QUERY result=$(bashio::jq "${__BASHIO_ADDON_CONFIG}" "${query}") - if [[ "${result}" == '!secret '* ]]; then - result=$(bashio::secret "${result}") - fi - printf "%s" "${result}" return "${__BASHIO_EXIT_OK}" } diff --git a/lib/const.sh b/lib/const.sh index b5ef982..0a32b6f 100644 --- a/lib/const.sh +++ b/lib/const.sh @@ -16,7 +16,6 @@ readonly __BASHIO_DEFAULT_HASSIO_TOKEN="" readonly __BASHIO_DEFAULT_ADDON_CONFIG="/data/options.json" readonly __BASHIO_DEFAULT_HIBP_ENDPOINT="https://api.pwnedpasswords.com/range" readonly __BASHIO_DEFAULT_CACHE_DIR="/dev/shm/bashio" -readonly __BASHIO_DEFAULT_SECRETS="/config/secrets.yaml" # Exit codes readonly __BASHIO_EXIT_OK=0 # Successful termination diff --git a/lib/secrets.sh b/lib/secrets.sh deleted file mode 100644 index 2f44710..0000000 --- a/lib/secrets.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env bash -# ============================================================================== -# Community Hass.io Add-ons: Bashio -# Bashio is an bash function library for use with Hass.io add-ons. -# -# It contains a set of commonly used operations and can be used -# to be included in add-on scripts to reduce code duplication across add-ons. -# ============================================================================== - -# ------------------------------------------------------------------------------ -# Gets a secret value by key from secrets.yaml. -# -# Arguments: -# $1 Secret key -# ------------------------------------------------------------------------------ -bashio::secret() { - local key=${1} - local secret - local value - - bashio::log.trace "${FUNCNAME[0]}:" "$@" - - if ! bashio::fs.directory_exists "$(dirname "${__BASHIO_HA_SECRETS}")"; then - bashio::log.error "This add-on does not support secrets!" - return "${__BASHIO_EXIT_NOK}" - fi - - if ! bashio::fs.file_exists "${__BASHIO_HA_SECRETS}"; then - bashio::log.error \ - "A secret was requested, but could not find a secrets.yaml" - return "${__BASHIO_EXIT_NOK}" - fi - - secret="${key#'!secret '}" - value=$(yq read "${__BASHIO_HA_SECRETS}" "${secret}" ) - - if [[ "${value}" = "null" ]]; then - bashio::log.error "Secret ${secret} not found in secrets.yaml file." - return "${__BASHIO_EXIT_NOK}" - fi - - printf "%s" "${value}" - return "${__BASHIO_EXIT_OK}" -} - -# ------------------------------------------------------------------------------ -# Tells whether or not a string might be a secret. -# -# Arguments: -# $1 String to check for a secret -# ------------------------------------------------------------------------------ -bashio::is_secret() { - local string="${1}" - - bashio::log.trace "${FUNCNAME[0]}:" "$@" - - if [[ "${string}" != '!secret '* ]]; then - return "${__BASHIO_EXIT_NOK}" - fi - return "${__BASHIO_EXIT_OK}" -}