Skip to content

Commit 1113dfc

Browse files
UPSTREAM: <carry>: [DefaultCatalogTests]: Moving parse of ENVVAR to the caller (follow-up 345)
1 parent f009adb commit 1113dfc

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

openshift/default-catalog-consistency/pkg/extract/extract.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (r *ExtractedImage) Cleanup() {
3939
}
4040

4141
// UnpackImage pulls the image, extracts it to disk, and opens it as an OCI store.
42-
func UnpackImage(ctx context.Context, imageRef, name string) (res *ExtractedImage, err error) {
42+
func UnpackImage(ctx context.Context, imageRef, name, authPath string) (res *ExtractedImage, err error) {
4343
tmpDir, err := os.MkdirTemp("", fmt.Sprintf("oci-%s-", name))
4444
if err != nil {
4545
return nil, fmt.Errorf("create temp dir: %w", err)
@@ -65,13 +65,13 @@ func UnpackImage(ctx context.Context, imageRef, name string) (res *ExtractedImag
6565
//
6666
// TODO: Update this to support checking all architectures.
6767
// See: https://issues.redhat.com/browse/OPRUN-3793
68-
sysCtx := &types.SystemContext{
69-
OSChoice: "linux",
70-
}
71-
72-
if authPath := os.Getenv("REGISTRY_AUTH_FILE"); authPath != "" {
68+
if authPath == "" {
7369
fmt.Println("Using registry auth file:", authPath)
74-
sysCtx.AuthFilePath = authPath
70+
authPath = os.Getenv("REGISTRY_AUTH_FILE")
71+
}
72+
sysCtx := &types.SystemContext{
73+
OSChoice: "linux",
74+
AuthFilePath: authPath,
7575
}
7676

7777
policyCtx, err := loadPolicyContext(sysCtx, imageRef)

openshift/default-catalog-consistency/test/validate/suite_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package validate
33
import (
44
"context"
55
"fmt"
6+
"os"
67
"testing"
78

89
. "github.com/onsi/ginkgo/v2"
@@ -23,6 +24,7 @@ var _ = Describe("Check Catalog Consistency", func() {
2324
images, err := utils.ParseImageRefsFromCatalog(catalogsPath)
2425
Expect(err).ToNot(HaveOccurred())
2526
Expect(images).ToNot(BeEmpty(), "no images found")
27+
authPath := os.Getenv("REGISTRY_AUTH_FILE")
2628

2729
for _, url := range images {
2830
name := utils.ImageNameFromRef(url)
@@ -31,7 +33,7 @@ var _ = Describe("Check Catalog Consistency", func() {
3133
ctx := context.Background()
3234
By(fmt.Sprintf("Validating image: %s", url))
3335

34-
extractedImage, err := extract.UnpackImage(ctx, url, name)
36+
extractedImage, err := extract.UnpackImage(ctx, url, name, authPath)
3537
Expect(err).ToNot(HaveOccurred())
3638
Expect(check.Check(ctx, extractedImage, check.AllChecks())).To(Succeed())
3739
extractedImage.Cleanup()

0 commit comments

Comments
 (0)