|
7 | 7 |
|
8 | 8 | #### Variable #### |
9 | 9 |
|
| 10 | +NAMESPACE= |
10 | 11 | DOCKER_TIMEOUT=20 |
11 | 12 | DOCKER_PID=-1 |
12 | 13 | DOCKER_HUB= |
@@ -118,6 +119,8 @@ Options: |
118 | 119 | Use same tag as cache tag instead latest. |
119 | 120 | --cache-tag <TAG> |
120 | 121 | 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. |
121 | 124 | -d, --docker-hub <DOCKER_REPOSITORY> |
122 | 125 | Set or overwrite the docker repository. |
123 | 126 | --docker-hub-check |
@@ -446,6 +449,9 @@ function build_base() { |
446 | 449 | args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")" |
447 | 450 | labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")" |
448 | 451 | 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 |
449 | 455 | shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")" |
450 | 456 |
|
451 | 457 | # Set defaults build things |
@@ -556,6 +562,9 @@ function build_addon() { |
556 | 562 | description="$(jq --raw-output '.description // empty' "/tmp/build_config/config.json" | sed "s/'//g")" |
557 | 563 | url="$(jq --raw-output '.url // empty' "/tmp/build_config/config.json")" |
558 | 564 | 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 |
559 | 568 | mapfile -t supported_arch < <(jq --raw-output '.arch // empty' "/tmp/build_config/config.json") |
560 | 569 |
|
561 | 570 | # Read version from config.json when VERSION is not set |
@@ -614,6 +623,9 @@ function build_generic() { |
614 | 623 | args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")" |
615 | 624 | labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")" |
616 | 625 | 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 |
617 | 629 | shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")" |
618 | 630 |
|
619 | 631 | # Set defaults build things |
@@ -675,6 +687,9 @@ function build_machine() { |
675 | 687 | args="$(jq --raw-output '.args // empty | keys[]' "/tmp/build_config/build.json")" |
676 | 688 | labels="$(jq --raw-output '.labels // empty | keys[]' "/tmp/build_config/build.json")" |
677 | 689 | 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 |
678 | 693 | shadow_repository="$(jq --raw-output '.shadow_repository // empty' "/tmp/build_config/build.json")" |
679 | 694 |
|
680 | 695 | # Modify build_from |
@@ -906,6 +921,10 @@ while [[ $# -gt 0 ]]; do |
906 | 921 | VERSION_FROM=$2 |
907 | 922 | shift |
908 | 923 | ;; |
| 924 | + -n|--namespace) |
| 925 | + NAMESPACE=$2 |
| 926 | + shift |
| 927 | + ;; |
909 | 928 | --docker-hub-check) |
910 | 929 | DOCKER_HUB_CHECK=true |
911 | 930 | ;; |
|
0 commit comments