Step: ocm-ci-image-mirror-periodic

This workflow mirrors an image from the CI Registry to a given image ref to be used in a perodic Prow job.

Container image used for this step: open-cluster-management/builder:go1.16-linux

open-cluster-management/builder:go1.16-linux resolves to an image imported from the specified imagestream tag on the build farm (documentation).

Environment

In addition to the default environment, the step exposes the following:

Variable Name Type Variable Content
SOURCE_IMAGE_REF Dependency[?] Pull specification for src image
SECRETS_PATH Parameter[?] The directory where credentials will be mounted. (default: /secrets)
REGISTRY_SECRET Parameter[?] The name of the kube secret that contains the registry token file. (default: acm-cicd-quay-push)
REGISTRY_SECRET_FILE Parameter[?] The name of the file in REGSITRY_SECRET with the contents of the .docker/config.json file encoded in base64. (default: token)
REGISTRY_HOST Parameter[?] The hostname (and port) of the destination registry. (default: quay.io)
REGISTRY_ORG Parameter[?] The organization of the destination image reference. (default: open-cluster-management)
IMAGE_REPO Parameter[?] The repository name of the destination image reference. Must be provided.
IMAGE_TAG Parameter[?] The tag for the destination image reference. (default: latest)

Source Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash

export HOME=/tmp/home
mkdir -p "$HOME/.docker"
cd "$HOME" || exit 1

# log function
log_file="${ARTIFACT_DIR}/mirror.log"
log() {
    local ts
    ts=$(date --iso-8601=seconds)
    echo "$ts" "$@" | tee -a "$log_file"
}

# Setup registry credentials
REGISTRY_TOKEN_FILE="$SECRETS_PATH/$REGISTRY_SECRET/$REGISTRY_SECRET_FILE"

if [[ ! -r "$REGISTRY_TOKEN_FILE" ]]; then
    log "ERROR Registry secret file not found: $REGISTRY_TOKEN_FILE"
    log "      SECRETS_PATH        : $SECRETS_PATH"
    log "      REGISTRY_SECRET     : $REGISTRY_SECRET"
    log "      REGISTRY_SECRET_FILE: $REGISTRY_SECRET_FILE"
    exit 1
fi

if [[ -z "$IMAGE_REPO" ]]; then
    log "ERROR IMAGE_REPO is empty"
    exit 1
fi

config_file="$HOME/.docker/config.json"
base64 -d < "$REGISTRY_TOKEN_FILE" > "$config_file" || {
    log "ERROR Could not base64 decode registry secret file"
    log "      From: $REGISTRY_TOKEN_FILE"
    log "      To  : $config_file"
    exit 1
}

# Build destination image reference
DESTINATION_IMAGE_REF="$REGISTRY_HOST/$REGISTRY_ORG/$IMAGE_REPO:$IMAGE_TAG"

log "INFO Mirroring Image"
log "     From: $SOURCE_IMAGE_REF"
log "     To  : $DESTINATION_IMAGE_REF"
oc image mirror "$SOURCE_IMAGE_REF" "$DESTINATION_IMAGE_REF" || {
    log "ERROR Unable to mirror image"
    exit 1
}

log "INFO Mirroring complete."

Properties

Property Value Description
Resource requests (cpu) 100m Used in .resources.requests of the pod running this step.
Resource requests (memory) 100Mi Used in .resources.requests of the pod running this step.

GitHub Link:

https://github.com/openshift/release/blob/master/ci-operator/step-registry/ocm/ci/image-mirror-periodic/ocm-ci-image-mirror-periodic-ref.yaml

Owners:

Approvers:

Source code for this page located on GitHub