diff --git a/builder.sh b/builder.sh index 0d2defb..a053102 100755 --- a/builder.sh +++ b/builder.sh @@ -7,6 +7,7 @@ set +u #### Variable #### +NAMESPACE= DOCKER_TIMEOUT=20 DOCKER_PID=-1 DOCKER_HUB= @@ -104,6 +105,8 @@ Options: Use same tag as cache tag instead latest. --cache-tag Use a custom tag for the build cache. + -n, --namespace + Set or overwrite name of personal account or organization to build from. -d, --docker-hub Set or overwrite the docker repository. --docker-hub-check @@ -440,6 +443,8 @@ function build_base() { if ! bashio::var.has_value "${raw_image}"; then bashio::log.error "Can't find the image tag on build.json" return 1 + elif bashio::var.has_value "${NAMESPACE}"; then + raw_image="${raw_image%%/*}/${NAMESPACE}/${raw_image##*/}" fi repository="${raw_image%/*}" image="${raw_image##*/}" @@ -545,6 +550,9 @@ function build_addon() { # Read data from image if [ -n "$raw_image" ]; then + if bashio::var.has_value "${NAMESPACE}"; then + raw_image="${raw_image%%/*}/${NAMESPACE}/${raw_image##*/}" + fi repository="${raw_image%/*}" image="${raw_image##*/}" fi @@ -598,6 +606,8 @@ function build_generic() { if ! bashio::var.has_value "$raw_image"; then bashio::log.error "Can't find the image tag on build.json" return 1 + elif bashio::var.has_value "${NAMESPACE}"; then + raw_image="${raw_image%%/*}/${NAMESPACE}/${raw_image##*/}" fi repository="${raw_image%/*}" image="${raw_image##*/}" @@ -660,6 +670,11 @@ function build_machine() { docker_cli+=("--file" "${TARGET}/${build_machine}") fi + if bashio::var.has_value "${raw_image}"; then + if bashio::var.has_value "${NAMESPACE}"; then + raw_image="${raw_image%%/*}/${NAMESPACE}/${raw_image##*/}" + fi + fi repository="${raw_image%/*}" image="${raw_image##*/}" @@ -878,6 +893,10 @@ while [[ $# -gt 0 ]]; do VERSION_FROM=$2 shift ;; + -n|--namespace) + NAMESPACE=$2 + shift + ;; --docker-hub-check) DOCKER_HUB_CHECK=true ;;