mirror of
https://github.com/flatcar/scripts.git
synced 2026-04-23 06:21:57 +02:00
ci-automation: Add URL template handling
This commit is contained in:
parent
5f1cdb7e49
commit
3b09e5da75
@ -17,6 +17,8 @@ CONTAINER_REGISTRY="ghcr.io/flatcar-linux"
|
||||
|
||||
GC_BUCKET="flatcar-linux"
|
||||
|
||||
DEFAULT_HTTP_IMAGE_URL_TEMPLATE="@PROTO@://${BUILDCACHE_SERVER}/images/@ARCH@/@VERNUM@"
|
||||
|
||||
if ! command -v pigz > /dev/null; then
|
||||
# No PIGZ on Flatcar
|
||||
PIGZ="docker run --rm -i ghcr.io/flatcar-linux/pigz --fast"
|
||||
@ -85,9 +87,9 @@ GCE_PARALLEL="${PARALLEL_TESTS:-4}"
|
||||
|
||||
# -- Digital Ocean --
|
||||
|
||||
# Use the "@ARCH@", "@CHANNEL@" and "@VERNUM@" placeholders. They will
|
||||
# Use the "@PROTO@" "@ARCH@", "@CHANNEL@" and "@VERNUM@" placeholders. They will
|
||||
# be replaced.
|
||||
DO_IMAGE_URL="https://${BUILDCACHE_SERVER}/images/@ARCH@/@VERNUM@/flatcar_production_digitalocean_image.bin.bz2"
|
||||
DO_IMAGE_URL="${DEFAULT_HTTP_IMAGE_URL_TEMPLATE}/flatcar_production_digitalocean_image.bin.bz2"
|
||||
DO_CONFIG_FILE='do-token.json'
|
||||
DO_REGION='sfo3'
|
||||
DO_MACHINE_SIZE='s-2vcpu-2gb'
|
||||
|
||||
@ -224,3 +224,24 @@ function docker_image_from_registry_or_buildcache() {
|
||||
docker_image_from_buildcache "${image}" "${version}"
|
||||
}
|
||||
# --
|
||||
|
||||
# Substitutes fields in the passed template and prints the
|
||||
# result. Followed by the template, the parameters used for
|
||||
# replacement are in alphabetical order: arch, channel, proto and
|
||||
# vernum.
|
||||
function url_from_template() {
|
||||
local template="${1}"; shift
|
||||
local arch="${1}"; shift
|
||||
local channel="${1}"; shift
|
||||
local proto="${1}"; shift
|
||||
local vernum="${1}"; shift
|
||||
local url="${template}"
|
||||
|
||||
url="${url//@ARCH@/${arch}}"
|
||||
url="${url//@CHANNEL@/${channel}}"
|
||||
url="${url//@PROTO@/${proto}}"
|
||||
url="${url//@VERNUM@/${vernum}}"
|
||||
|
||||
echo "${url}"
|
||||
}
|
||||
# --
|
||||
|
||||
@ -38,9 +38,7 @@ if [[ "${channel}" = 'developer' ]]; then
|
||||
fi
|
||||
image_name="ci-${vernum//+/-}"
|
||||
testscript="$(basename "$0")"
|
||||
image_url="${DO_IMAGE_URL//@ARCH@/${arch}}"
|
||||
image_url="${image_url//@CHANNEL@/${channel}}"
|
||||
image_url="${image_url//@VERNUM@/${vernum}}"
|
||||
image_url="$(url_from_template "${DO_IMAGE_URL}" "${arch}" "${channel}" 'https' "${vernum}")"
|
||||
|
||||
ore do create-image \
|
||||
--config-file="${DO_CONFIG_FILE}" \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user