Skip to content

Commit

Permalink
WIP: Conditional image IDs
Browse files Browse the repository at this point in the history
Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Oct 31, 2024
1 parent f55d208 commit 85bf387
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ var (
ALPINELISTTAG = "quay.io/libpod/alpine:3.10.2"
ALPINELISTDIGEST = "quay.io/libpod/alpine@" + digestOrCachedTop("quay.io/libpod/alpine", "sha256:fa93b01658e3a5a1686dc3ae55f170d8de487006fb53a28efcd12ab0710a2e5f")
ALPINEAMD64DIGEST = "quay.io/libpod/alpine@" + digestOrCachedArch("quay.io/libpod/alpine", "amd64", "sha256:634a8f35b5f16dcf4aaa0822adc0b1964bb786fca12f6831de8ddc45e5986a00")
ALPINEAMD64ID = "961769676411f082461f9ef46626dd7a2d1e2b2a38e6a44364bcbecf51e66dd4"
ALPINEAMD64ID = idOrCached(ALPINEAMD64DIGEST, "961769676411f082461f9ef46626dd7a2d1e2b2a38e6a44364bcbecf51e66dd4")
ALPINEARM64DIGEST = "quay.io/libpod/alpine@" + digestOrCachedArch("quay.io/libpod/alpine", "arm64", "sha256:f270dcd11e64b85919c3bab66886e59d677cf657528ac0e4805d3c71e458e525")
ALPINEARM64ID = "915beeae46751fc564998c79e73a1026542e945ca4f73dc841d09ccc6c2c0672"
ALPINEARM64ID = idOrCached(ALPINEARM64DIGEST, "915beeae46751fc564998c79e73a1026542e945ca4f73dc841d09ccc6c2c0672")
BUSYBOXARMDIGEST = "quay.io/libpod/busybox@" + digestOrCachedArch("quay.io/libpod/busybox", "arm", "sha256:6655df04a3df853b029a5fac8836035ac4fab117800c9a6c4b69341bb5306c3d")
INFRA_IMAGE = "quay.io/libpod/k8s-pause:3.5" //nolint:revive,stylecheck
BB = "quay.io/libpod/busybox:latest"
Expand Down Expand Up @@ -65,3 +65,20 @@ func digestOrCachedArch(image string, arch string, standardDigest string) string
GinkgoWriter.Printf("Digest of %q arch %s = %q", image, arch, string(out))
return strings.TrimSpace(string(out))
}

func idOrCached(image string, standardID string) string {
if !UsingCacheRegistry() {
return standardID
}
cwd, _ := os.Getwd()
cmd := exec.Command("sh", "-c", `skopeo inspect --raw docker://`+image+` | jq -r '.config.digest'`)
cmd.Env = append(os.Environ(), "CONTAINERS_REGISTRIES_CONF="+filepath.Join(cwd, "..", "registries-cached.conf"))
out, err := cmd.Output()
if err != nil {
panic(fmt.Sprintf("Running %q: %s", cmd.String(), err.Error()))
}
GinkgoWriter.Printf("Config digest of %q = %q", image, string(out))
digest := strings.TrimSpace(string(out))
_, id, _ := strings.Cut(digest, ":") // A lazy hack, replace
return id
}

0 comments on commit 85bf387

Please sign in to comment.