Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 37 additions & 11 deletions test/extended/images/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package images

import (
"context"
"strings"

"github.com/MakeNowJust/heredoc"
g "github.com/onsi/ginkgo/v2"
o "github.com/onsi/gomega"

e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
admissionapi "k8s.io/pod-security-admission/api"

exutil "github.com/openshift/origin/test/extended/util"
Expand All @@ -28,16 +28,42 @@ var _ = g.Describe("[sig-imageregistry][Feature:ImageInfo] Image info", func() {

g.It("should display information about images [apigroup:image.openshift.io]", func() {
ns = oc.Namespace()
cli := e2epod.PodClientNS(oc.KubeFramework(), ns)
pod := cli.Create(context.TODO(), cliPodWithPullSecret(oc, heredoc.Docf(`
set -x
payloadImage, err := oc.AsAdmin().Run("get").Args("clusterversion", "version", "-o", "jsonpath={.status.desired.image}").Output()
o.Expect(err).NotTo(o.HaveOccurred(), "Failed to get current payload image from clusterversion")
payloadImage = strings.TrimSpace(payloadImage)
o.Expect(payloadImage).NotTo(o.BeEmpty())

# display info about an image on quay.io
oc image info quay.io/openshift-release-dev/ocp-release:4.18.3-x86_64
var out string
cleanup, regArgs, prepErr := exutil.PrepareImagePullSecretAndCABundle(oc)
if cleanup != nil {
defer cleanup()
}

# display info about an image in json format
oc image info quay.io/openshift-release-dev/ocp-release:4.18.3-x86_64 -o json
`)))
cli.WaitForSuccess(context.TODO(), pod.Name, podStartupTimeout)
if prepErr == nil {
args := append([]string{"info", payloadImage}, regArgs...)
out, err = oc.AsAdmin().Run("image").Args(args...).Output()
} else {
err = prepErr
}
if err != nil {
ctx := context.Background()
isHyperShift, hsErr := exutil.IsHypershift(ctx, oc.AdminConfigClient())
o.Expect(hsErr).NotTo(o.HaveOccurred())
if isHyperShift {
g.Skip("Skipping on HyperShift: runner requires external outbound access to registry")
}
o.Expect(err).NotTo(o.HaveOccurred(), "oc image info failed on a standard cluster")
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
o.Expect(out).To(o.ContainSubstring("Digest:"))
o.Expect(out).To(o.MatchRegexp(`Name:\s+.*`))

//Test the json output
if prepErr == nil {
Comment thread
YamunadeviShanmugam marked this conversation as resolved.
Outdated
argsJson := append([]string{"info", payloadImage, "-o", "json"}, regArgs...)
outJson, errJson := oc.AsAdmin().Run("image").Args(argsJson...).Output()
o.Expect(errJson).NotTo(o.HaveOccurred())
o.Expect(outJson).To(o.ContainSubstring(`"digest":`))
o.Expect(outJson).To(o.MatchRegexp(`"name":\s+.*`))
}
})
})