Skip to content

Commit 9a60c19

Browse files
committed
write missing policy.json file
1 parent d7da39e commit 9a60c19

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/e2e-ocl/imagepruner_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"flag"
88
"fmt"
9+
"log"
910
"os"
1011
"os/exec"
1112
"path/filepath"
@@ -792,9 +793,22 @@ func createAndPushScratchImage(ctx context.Context, t *testing.T, pullspec, secr
792793
return err
793794
}
794795

795-
cmd := exec.Command("skopeo", "copy", "--dest-authfile", secretPath, "tarball://"+srcImage, "docker://"+pullspec)
796+
policyPath := filepath.Join(t.TempDir(), "policy.json")
797+
// Taken from /etc/containers/policy.json and compacted.
798+
policyJSONBytes := []byte(`{"default":[{"type":"insecureAcceptAnything"}],"transports":{"docker-daemon":{"":[{"type":"insecureAcceptAnything"}]}}}`)
799+
if err := os.WriteFile(policyPath, policyJSONBytes, 0o755); err != nil {
800+
return err
801+
}
802+
803+
defer func() {
804+
if err := os.RemoveAll(tmpDir); err != nil {
805+
log.Fatalln(err)
806+
}
807+
}()
808+
809+
cmd := exec.Command("skopeo", "--policy", policyPath, "copy", "--dest-authfile", secretPath, "tarball://"+srcImage, "docker://"+pullspec)
796810
if certsDir != "" {
797-
cmd = exec.Command("skopeo", "copy", "--dest-cert-dir", certsDir, "--dest-authfile", secretPath, "tarball://"+srcImage, "docker://"+pullspec)
811+
cmd = exec.Command("skopeo", "--policy", policyPath, "copy", "--dest-cert-dir", certsDir, "--dest-authfile", secretPath, "tarball://"+srcImage, "docker://"+pullspec)
798812
}
799813

800814
t.Logf("Copying %s to %s using skopeo", srcImage, pullspec)

0 commit comments

Comments
 (0)