MCPcopy Create free account
hub / github.com/conforma/cli / WithTestImageConfig

Function WithTestImageConfig

internal/utils/oci/fake/client.go:38–78  ·  view source on GitHub ↗
(ctx context.Context, url string)

Source from the content-addressed store, hash-verified

36)
37
38func WithTestImageConfig(ctx context.Context, url string) context.Context {
39 ref, err := name.NewDigest(url)
40 if err != nil {
41 panic(err)
42 }
43
44 // Setup parent/base image mock
45 parentURL := utils.WithDigest("registry.local/base-image")
46 parentRef, err := name.ParseReference(parentURL)
47 if err != nil {
48 panic(err)
49 }
50 parentImage, err := mutate.Config(empty.Image, v1.Config{
51 Labels: map[string]string{
52 "io.k8s.display-name": "Base Image",
53 },
54 })
55 if err != nil {
56 panic(err)
57 }
58
59 // Setup child image mock
60 image := mutate.Annotations(empty.Image, map[string]string{
61 oci.BaseImageNameAnnotation: parentURL,
62 }).(v1.Image)
63 image, err = mutate.Config(image, v1.Config{
64 Labels: map[string]string{
65 "io.k8s.display-name": "Test Image",
66 },
67 })
68 if err != nil {
69 panic(err)
70 }
71
72 // Setup client
73 client := &FakeClient{}
74 client.On("Image", ref, mock.Anything).Return(image, nil)
75 client.On("Image", parentRef, mock.Anything).Return(parentImage, nil)
76
77 return oci.WithClient(ctx, client)
78}
79
80var _ oci.Client = &FakeClient{}
81

Callers 3

withImageConfigFunction · 0.92
TestFetchImageConfigFunction · 0.92

Calls 3

WithDigestFunction · 0.92
WithClientFunction · 0.92
AnnotationsMethod · 0.45

Tested by 3

withImageConfigFunction · 0.74
TestFetchImageConfigFunction · 0.74