
add focal dockerfile update zuul jobs for focal update tox for tox4 changes update all requirements to latest and match deckhand update cfssl from R1.2 to v1.6.3 fixed local gates for focal updated examples promenade manifests to run on focal Change-Id: I2af4043784766d36588c6f738053ad66e7b89a90
80 lines
2.5 KiB
Bash
80 lines
2.5 KiB
Bash
registry_down() {
|
|
REGISTRY_ID=$(docker ps -qa -f name=registry)
|
|
if [[ -n ${REGISTRY_ID} ]]; then
|
|
log Removing docker registry
|
|
docker rm -fv "${REGISTRY_ID}" &>> "${LOG_FILE}"
|
|
fi
|
|
}
|
|
|
|
registry_list_images() {
|
|
FILES=("$(config_configuration | xargs -I dirname find dirname -type f -name '*.yaml' | grep -v PKICatalog)")
|
|
|
|
HOSTNAME_REGEX='[a-zA-Z0-9][a-zA-Z0-9_-]{0,62}'
|
|
DOMAIN_NAME_REGEX="${HOSTNAME_REGEX}(\.${HOSTNAME_REGEX})*"
|
|
PORT_REGEX='[0-9]+'
|
|
NETLOC_REGEX="${DOMAIN_NAME_REGEX}(:${PORT_REGEX})?"
|
|
|
|
REPO_COMPONENT_REGEX='[a-zA-Z0-9][a-zA-Z0-9_-]{0,62}'
|
|
REPO_REGEX="${REPO_COMPONENT_REGEX}(/${REPO_COMPONENT_REGEX})*"
|
|
|
|
TAG_REGEX='[a-zA-Z0-9][a-zA-Z0-9.-]{0,127}'
|
|
|
|
cat "${FILES[@]}" \
|
|
| tr ' \t' '\n' | tr -s '\n' \
|
|
| grep -E "^(${NETLOC_REGEX}/)?${REPO_REGEX}:${TAG_REGEX}$" \
|
|
| sort -u \
|
|
| grep -v 'registry:5000'
|
|
}
|
|
|
|
registry_populate() {
|
|
log Validating local registry is populated
|
|
for image in $(registry_list_images); do
|
|
if [[ ${image} =~ promenade ]]; then
|
|
continue
|
|
fi
|
|
|
|
if [[ ${image} =~ .*:(latest|master) ]] || ! docker pull "localhost:5000/${image}" &> /dev/null; then
|
|
log Loading image "${image}" into local registry
|
|
{
|
|
docker pull "${image}"
|
|
docker tag "${image}" "localhost:5000/${image}"
|
|
docker push "localhost:5000/${image}"
|
|
} &>> "${LOG_FILE}"
|
|
fi
|
|
done
|
|
}
|
|
|
|
registry_replace_references() {
|
|
FILES=("${@}")
|
|
for image in $(registry_list_images); do
|
|
sed -i "s;${image}\$;registry:5000/${image};g" "${FILES[@]}"
|
|
done
|
|
}
|
|
|
|
registry_up() {
|
|
log Validating local registry is up
|
|
REGISTRY_ID=$(docker ps -qa -f name=registry)
|
|
RUNNING_REGISTRY_ID=$(docker ps -q -f name=registry)
|
|
if [[ -z ${RUNNING_REGISTRY_ID} && -n ${REGISTRY_ID} ]]; then
|
|
log Removing stopped docker registry
|
|
docker rm -fv "${REGISTRY_ID}" &>> "${LOG_FILE}"
|
|
fi
|
|
|
|
cur=$(grep registry /etc/hosts | cut -f1 -d:)
|
|
if [ -n "$cur" ]; then
|
|
sudo sed -i "s/.*registry/127.0.0.1 registry/g" /etc/hosts
|
|
else
|
|
echo "127.0.0.1 registry" | sudo tee -a /etc/hosts
|
|
fi
|
|
if [[ -z ${RUNNING_REGISTRY_ID} ]]; then
|
|
log Starting docker registry
|
|
docker run -d \
|
|
-p 5000:5000 \
|
|
-e REGISTRY_HTTP_ADDR=0.0.0.0:5000 \
|
|
--restart=always \
|
|
--name registry \
|
|
-v "${REGISTRY_DATA_DIR}:/var/lib/registry" \
|
|
registry:2 &>> "${LOG_FILE}"
|
|
fi
|
|
}
|