Mohammed Naser | 298f027 | 2024-07-29 18:43:25 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | {{/* |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */}} |
| 16 | |
| 17 | set -ex |
| 18 | |
| 19 | {{ $source_base := .Values.bootstrap.image.source_base | default "" }} |
| 20 | {{ range $name, $opts := .Values.bootstrap.image.structured }} |
| 21 | {{ $source := empty $source_base | ternary $opts.source (printf "%s/%s" $source_base $opts.source) }} |
| 22 | openstack image show {{ $name | quote }} -fvalue -cid || ( |
| 23 | IMAGE_LOC=$(mktemp) |
| 24 | curl --fail -sSL {{ $source }} -o ${IMAGE_LOC} |
| 25 | openstack image create {{ $name | quote }} \ |
| 26 | --disk-format {{ $opts.disk_format }} \ |
| 27 | --container-format {{ $opts.container_format }} \ |
| 28 | --file ${IMAGE_LOC} \ |
| 29 | {{ if $opts.properties -}} {{ range $k, $v := $opts.properties }}--property {{$k}}={{$v}} {{ end }}{{ end -}} \ |
| 30 | --{{ $opts.visibility | default "public" }} |
| 31 | rm -f ${IMAGE_LOC} |
| 32 | ) |
| 33 | {{ else }} |
| 34 | {{ .Values.bootstrap.image.script | default "echo 'Not Enabled'" }} |
| 35 | {{ end }} |