Skip to content

Commit e755f87

Browse files
eshattowE Shattow
authored andcommitted
Introduce namespace option in builder.sh
Added namespace option to builder.sh script overrides namespace of image tag in build.yaml
1 parent d5e797f commit e755f87

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

builder.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set +u
77

88
#### Variable ####
99

10+
NAMESPACE=
1011
DOCKER_TIMEOUT=20
1112
DOCKER_PID=-1
1213
DOCKER_HUB=
@@ -104,6 +105,8 @@ Options:
104105
Use same tag as cache tag instead latest.
105106
--cache-tag <TAG>
106107
Use a custom tag for the build cache.
108+
-n, --namespace <NAMESPACE>
109+
Set or overwrite name of personal account or organization to build from.
107110
-d, --docker-hub <DOCKER_REPOSITORY>
108111
Set or overwrite the docker repository.
109112
--docker-hub-check
@@ -440,6 +443,8 @@ function build_base() {
440443
if ! bashio::var.has_value "${raw_image}"; then
441444
bashio::log.error "Can't find the image tag on build.json"
442445
return 1
446+
elif bashio::var.has_value "${NAMESPACE}"; then
447+
raw_image="${raw_image%%/*}/${NAMESPACE}/${raw_image##*/}"
443448
fi
444449
repository="${raw_image%/*}"
445450
image="${raw_image##*/}"
@@ -545,6 +550,9 @@ function build_addon() {
545550

546551
# Read data from image
547552
if [ -n "$raw_image" ]; then
553+
if bashio::var.has_value "${NAMESPACE}"; then
554+
raw_image="${raw_image%%/*}/${NAMESPACE}/${raw_image##*/}"
555+
fi
548556
repository="${raw_image%/*}"
549557
image="${raw_image##*/}"
550558
fi
@@ -598,6 +606,8 @@ function build_generic() {
598606
if ! bashio::var.has_value "$raw_image"; then
599607
bashio::log.error "Can't find the image tag on build.json"
600608
return 1
609+
elif bashio::var.has_value "${NAMESPACE}"; then
610+
raw_image="${raw_image%%/*}/${NAMESPACE}/${raw_image##*/}"
601611
fi
602612
repository="${raw_image%/*}"
603613
image="${raw_image##*/}"
@@ -660,6 +670,11 @@ function build_machine() {
660670
docker_cli+=("--file" "${TARGET}/${build_machine}")
661671
fi
662672

673+
if bashio::var.has_value "${raw_image}"; then
674+
if bashio::var.has_value "${NAMESPACE}"; then
675+
raw_image="${raw_image%%/*}/${NAMESPACE}/${raw_image##*/}"
676+
fi
677+
fi
663678
repository="${raw_image%/*}"
664679
image="${raw_image##*/}"
665680

@@ -878,6 +893,10 @@ while [[ $# -gt 0 ]]; do
878893
VERSION_FROM=$2
879894
shift
880895
;;
896+
-n|--namespace)
897+
NAMESPACE=$2
898+
shift
899+
;;
881900
--docker-hub-check)
882901
DOCKER_HUB_CHECK=true
883902
;;

0 commit comments

Comments
 (0)