Skip to content

Commit f49f6b9

Browse files
authored
Update script to use OCI (#85)
1 parent b99d3cb commit f49f6b9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

hack/get_image_info.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ kube_image_version=v0.8.0
88

99
token="$(curl 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:'${image}':pull' 2>/dev/null | jq -r '.token')"
1010

11-
image_digest=$(curl -sSfL -I -H "Authorization: Bearer ${token}" -H "Accept: application/vnd.docker.distribution.manifest.list.v2+json" "https://index.docker.io/v2/${image}/manifests/${version}" | awk 'BEGIN {FS=": "}/^docker-content-digest/{gsub(/"/, "", $2); print $2}')
11+
response=$(curl -sSfL -w '%{header_json}' -H "Authorization: Bearer ${token}" -H "Accept: application/vnd.oci.image.index.v1+json" "https://index.docker.io/v2/${image}/manifests/${version}" | jq -s)
1212

13-
digest="$(curl -sSfL -H "Authorization: Bearer ${token}" -H "Accept: application/vnd.docker.distribution.manifest.v2+json" "https://index.docker.io/v2/${image}/manifests/${version}" | jq -r '.config.digest')"
13+
image_digest=$(jq -r '.[1]."docker-content-digest"[]' <<<$response)
14+
manifest_digest=$(jq -r '.[0].manifests[0].digest' <<<$response)
1415

15-
created=$(curl -sSfL -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer ${token}" "https://index.docker.io/v2/${image}/blobs/${digest}" | jq -r '.config.Labels."org.opencontainers.image.created"')
16+
digest="$(curl -sSfL -H "Authorization: Bearer ${token}" -H "Accept: application/vnd.oci.image.manifest.v1+json" "https://index.docker.io/v2/${image}/manifests/${manifest_digest}" | jq -r '.config.digest')"
17+
18+
created=$(curl -sSfL -H "Accept: application/vnd.oci.image.config.v1+json" -H "Authorization: Bearer ${token}" "https://index.docker.io/v2/${image}/blobs/${digest}" | jq -r '.config.Labels."org.opencontainers.image.created"')
1619

1720
proxy="./config/default/manager_auth_proxy_patch.yaml"
1821
kube_proxy=$(yq e '.spec.template.spec.containers.[0].image' $proxy)

0 commit comments

Comments
 (0)