Skip to content

Commit c474920

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 8cfef9e commit c474920

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=
@@ -118,6 +119,8 @@ Options:
118119
Use same tag as cache tag instead latest.
119120
--cache-tag <TAG>
120121
Use a custom tag for the build cache.
122+
-n, --namespace <NAMESPACE>
123+
Set or overwrite name of personal account or organization to build from.
121124
-d, --docker-hub <DOCKER_REPOSITORY>
122125
Set or overwrite the docker repository.
123126
--docker-hub-check
@@ -446,6 +449,9 @@ function build_base() {
446449
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
447450
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
448451
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
452+
if bashio::var.has_value "${NAMESPACE}"; then
453+
raw_image="${raw_image%%/*}/${NAMESPACE}/${build_from##*/}"
454+
fi
449455
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"
450456

451457
# Set defaults build things
@@ -556,6 +562,9 @@ function build_addon() {
556562
description="$(jq --raw-output '.description // empty' "/tmp/build_config/config.json" | sed "s/'//g")"
557563
url="$(jq --raw-output '.url // empty' "/tmp/build_config/config.json")"
558564
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/config.json")"
565+
if bashio::var.has_value "${NAMESPACE}"; then
566+
raw_image="${raw_image%%/*}/${NAMESPACE}/${build_from##*/}"
567+
fi
559568
mapfile -t supported_arch < <(jq --raw-output '.arch // empty' "/tmp/build_config/config.json")
560569

561570
# Read version from config.json when VERSION is not set
@@ -614,6 +623,9 @@ function build_generic() {
614623
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
615624
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
616625
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
626+
if bashio::var.has_value "${NAMESPACE}"; then
627+
raw_image="${raw_image%%/*}/${NAMESPACE}/${build_from##*/}"
628+
fi
617629
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"
618630

619631
# Set defaults build things
@@ -675,6 +687,9 @@ function build_machine() {
675687
args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")"
676688
labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")"
677689
raw_image="$(jq --raw-output '.image // empty' "/tmp/build_config/build.json")"
690+
if bashio::var.has_value "${NAMESPACE}"; then
691+
raw_image="${raw_image%%/*}/${NAMESPACE}/${build_from##*/}"
692+
fi
678693
shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")"
679694

680695
# Modify build_from
@@ -906,6 +921,10 @@ while [[ $# -gt 0 ]]; do
906921
VERSION_FROM=$2
907922
shift
908923
;;
924+
-n|--namespace)
925+
NAMESPACE=$2
926+
shift
927+
;;
909928
--docker-hub-check)
910929
DOCKER_HUB_CHECK=true
911930
;;

0 commit comments

Comments
 (0)