mirror of
https://github.com/containers/skopeo.git
synced 2025-05-02 05:04:17 +00:00
Use check.C.MkDir() instead of manual ioutil.TempDir() calls
This saves us at least 2 lines (error check, and cleanup) on every instance, or in some cases adds cleanup that we forgot. This is inspired by, but not directly related to, Go 1.15's addition of Testing.T.TempDir. NOTE: This might significantly increase the tests' disk space requirements; AFAICS the temporary directories are only cleaned up when a whole "suite finishes running. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
f79cc8aeda
commit
2019b79c7f
@ -64,9 +64,7 @@ func (s *CopySuite) SetUpSuite(c *check.C) {
|
|||||||
s.registry = setupRegistryV2At(c, v2DockerRegistryURL, false, false)
|
s.registry = setupRegistryV2At(c, v2DockerRegistryURL, false, false)
|
||||||
s.s1Registry = setupRegistryV2At(c, v2s1DockerRegistryURL, false, true)
|
s.s1Registry = setupRegistryV2At(c, v2s1DockerRegistryURL, false, true)
|
||||||
|
|
||||||
gpgHome, err := ioutil.TempDir("", "skopeo-gpg")
|
s.gpgHome = c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
s.gpgHome = gpgHome
|
|
||||||
os.Setenv("GNUPGHOME", s.gpgHome)
|
os.Setenv("GNUPGHOME", s.gpgHome)
|
||||||
|
|
||||||
for _, key := range []string{"personal", "official"} {
|
for _, key := range []string{"personal", "official"} {
|
||||||
@ -82,9 +80,6 @@ func (s *CopySuite) SetUpSuite(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TearDownSuite(c *check.C) {
|
func (s *CopySuite) TearDownSuite(c *check.C) {
|
||||||
if s.gpgHome != "" {
|
|
||||||
os.RemoveAll(s.gpgHome)
|
|
||||||
}
|
|
||||||
if s.registry != nil {
|
if s.registry != nil {
|
||||||
s.registry.tearDown(c)
|
s.registry.tearDown(c)
|
||||||
}
|
}
|
||||||
@ -97,32 +92,20 @@ func (s *CopySuite) TearDownSuite(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestList(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestList(c *check.C) {
|
||||||
dir, err := ioutil.TempDir("", "copy-manifest-list")
|
dir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
assertSkopeoSucceeds(c, "", "copy", knownListImage, "dir:"+dir)
|
assertSkopeoSucceeds(c, "", "copy", knownListImage, "dir:"+dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyAllWithManifestList(c *check.C) {
|
func (s *CopySuite) TestCopyAllWithManifestList(c *check.C) {
|
||||||
dir, err := ioutil.TempDir("", "copy-all-manifest-list")
|
dir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--all", knownListImage, "dir:"+dir)
|
assertSkopeoSucceeds(c, "", "copy", "--all", knownListImage, "dir:"+dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyAllWithManifestListRoundTrip(c *check.C) {
|
func (s *CopySuite) TestCopyAllWithManifestListRoundTrip(c *check.C) {
|
||||||
oci1, err := ioutil.TempDir("", "copy-all-manifest-list-oci")
|
oci1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
oci2 := c.MkDir()
|
||||||
defer os.RemoveAll(oci1)
|
dir1 := c.MkDir()
|
||||||
oci2, err := ioutil.TempDir("", "copy-all-manifest-list-oci")
|
dir2 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(oci2)
|
|
||||||
dir1, err := ioutil.TempDir("", "copy-all-manifest-list-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-all-manifest-list-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", knownListImage, "oci:"+oci1)
|
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", knownListImage, "oci:"+oci1)
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "oci:"+oci1, "dir:"+dir1)
|
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "oci:"+oci1, "dir:"+dir1)
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "dir:"+dir1, "oci:"+oci2)
|
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "dir:"+dir1, "oci:"+oci2)
|
||||||
@ -133,18 +116,10 @@ func (s *CopySuite) TestCopyAllWithManifestListRoundTrip(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyAllWithManifestListConverge(c *check.C) {
|
func (s *CopySuite) TestCopyAllWithManifestListConverge(c *check.C) {
|
||||||
oci1, err := ioutil.TempDir("", "copy-all-manifest-list-oci")
|
oci1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
oci2 := c.MkDir()
|
||||||
defer os.RemoveAll(oci1)
|
dir1 := c.MkDir()
|
||||||
oci2, err := ioutil.TempDir("", "copy-all-manifest-list-oci")
|
dir2 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(oci2)
|
|
||||||
dir1, err := ioutil.TempDir("", "copy-all-manifest-list-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-all-manifest-list-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", knownListImage, "oci:"+oci1)
|
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", knownListImage, "oci:"+oci1)
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "oci:"+oci1, "dir:"+dir1)
|
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "oci:"+oci1, "dir:"+dir1)
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "--format", "oci", knownListImage, "dir:"+dir2)
|
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "--format", "oci", knownListImage, "dir:"+dir2)
|
||||||
@ -155,9 +130,7 @@ func (s *CopySuite) TestCopyAllWithManifestListConverge(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyNoneWithManifestList(c *check.C) {
|
func (s *CopySuite) TestCopyNoneWithManifestList(c *check.C) {
|
||||||
dir1, err := ioutil.TempDir("", "copy-all-manifest-list-dir")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=index-only", knownListImage, "dir:"+dir1)
|
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=index-only", knownListImage, "dir:"+dir1)
|
||||||
|
|
||||||
manifestPath := filepath.Join(dir1, "manifest.json")
|
manifestPath := filepath.Join(dir1, "manifest.json")
|
||||||
@ -170,18 +143,10 @@ func (s *CopySuite) TestCopyNoneWithManifestList(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListConverge(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListConverge(c *check.C) {
|
||||||
oci1, err := ioutil.TempDir("", "copy-all-manifest-list-oci")
|
oci1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
oci2 := c.MkDir()
|
||||||
defer os.RemoveAll(oci1)
|
dir1 := c.MkDir()
|
||||||
oci2, err := ioutil.TempDir("", "copy-all-manifest-list-oci")
|
dir2 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(oci2)
|
|
||||||
dir1, err := ioutil.TempDir("", "copy-all-manifest-list-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-all-manifest-list-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
assertSkopeoSucceeds(c, "", "copy", knownListImage, "oci:"+oci1)
|
assertSkopeoSucceeds(c, "", "copy", knownListImage, "oci:"+oci1)
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "oci:"+oci1, "dir:"+dir1)
|
assertSkopeoSucceeds(c, "", "copy", "--multi-arch=all", "oci:"+oci1, "dir:"+dir1)
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--format", "oci", knownListImage, "dir:"+dir2)
|
assertSkopeoSucceeds(c, "", "copy", "--format", "oci", knownListImage, "dir:"+dir2)
|
||||||
@ -192,24 +157,16 @@ func (s *CopySuite) TestCopyWithManifestListConverge(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyAllWithManifestListStorageFails(c *check.C) {
|
func (s *CopySuite) TestCopyAllWithManifestListStorageFails(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-storage")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
assertSkopeoFails(c, `.*destination transport .* does not support copying multiple images as a group.*`, "copy", "--multi-arch=all", knownListImage, "containers-storage:"+storage+"test")
|
assertSkopeoFails(c, `.*destination transport .* does not support copying multiple images as a group.*`, "copy", "--multi-arch=all", knownListImage, "containers-storage:"+storage+"test")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorage(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorage(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
dir1, err := ioutil.TempDir("", "copy-manifest-list-storage-dir")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir2 := c.MkDir()
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-manifest-list-storage-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
assertSkopeoSucceeds(c, "", "copy", knownListImage, "containers-storage:"+storage+"test")
|
assertSkopeoSucceeds(c, "", "copy", knownListImage, "containers-storage:"+storage+"test")
|
||||||
assertSkopeoSucceeds(c, "", "copy", knownListImage, "dir:"+dir1)
|
assertSkopeoSucceeds(c, "", "copy", knownListImage, "dir:"+dir1)
|
||||||
assertSkopeoSucceeds(c, "", "copy", "containers-storage:"+storage+"test", "dir:"+dir2)
|
assertSkopeoSucceeds(c, "", "copy", "containers-storage:"+storage+"test", "dir:"+dir2)
|
||||||
@ -218,16 +175,10 @@ func (s *CopySuite) TestCopyWithManifestListStorage(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorageMultiple(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorageMultiple(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage-multiple")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
dir1, err := ioutil.TempDir("", "copy-manifest-list-storage-multiple-dir")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir2 := c.MkDir()
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-manifest-list-storage-multiple-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
assertSkopeoSucceeds(c, "", "--override-arch", "amd64", "copy", knownListImage, "containers-storage:"+storage+"test")
|
assertSkopeoSucceeds(c, "", "--override-arch", "amd64", "copy", knownListImage, "containers-storage:"+storage+"test")
|
||||||
assertSkopeoSucceeds(c, "", "--override-arch", "arm64", "copy", knownListImage, "containers-storage:"+storage+"test")
|
assertSkopeoSucceeds(c, "", "--override-arch", "arm64", "copy", knownListImage, "containers-storage:"+storage+"test")
|
||||||
assertSkopeoSucceeds(c, "", "--override-arch", "arm64", "copy", knownListImage, "dir:"+dir1)
|
assertSkopeoSucceeds(c, "", "--override-arch", "arm64", "copy", knownListImage, "dir:"+dir1)
|
||||||
@ -237,18 +188,10 @@ func (s *CopySuite) TestCopyWithManifestListStorageMultiple(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListDigest(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListDigest(c *check.C) {
|
||||||
dir1, err := ioutil.TempDir("", "copy-manifest-list-digest-dir")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir2 := c.MkDir()
|
||||||
defer os.RemoveAll(dir1)
|
oci1 := c.MkDir()
|
||||||
dir2, err := ioutil.TempDir("", "copy-manifest-list-digest-dir")
|
oci2 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
oci1, err := ioutil.TempDir("", "copy-manifest-list-digest-oci")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(oci1)
|
|
||||||
oci2, err := ioutil.TempDir("", "copy-manifest-list-digest-oci")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(oci2)
|
|
||||||
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
||||||
manifestDigest, err := manifest.Digest([]byte(m))
|
manifestDigest, err := manifest.Digest([]byte(m))
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -262,12 +205,8 @@ func (s *CopySuite) TestCopyWithManifestListDigest(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithDigestfileOutput(c *check.C) {
|
func (s *CopySuite) TestCopyWithDigestfileOutput(c *check.C) {
|
||||||
tempdir, err := ioutil.TempDir("", "tempdir")
|
tempdir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir1 := c.MkDir()
|
||||||
defer os.RemoveAll(tempdir)
|
|
||||||
dir1, err := ioutil.TempDir("", "copy-manifest-list-digest-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
digestOutPath := filepath.Join(tempdir, "digest.txt")
|
digestOutPath := filepath.Join(tempdir, "digest.txt")
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--digestfile="+digestOutPath, knownListImage, "dir:"+dir1)
|
assertSkopeoSucceeds(c, "", "copy", "--digestfile="+digestOutPath, knownListImage, "dir:"+dir1)
|
||||||
readDigest, err := ioutil.ReadFile(digestOutPath)
|
readDigest, err := ioutil.ReadFile(digestOutPath)
|
||||||
@ -277,16 +216,10 @@ func (s *CopySuite) TestCopyWithDigestfileOutput(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorageDigest(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorageDigest(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage-digest")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
dir1, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-dir")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir2 := c.MkDir()
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
||||||
manifestDigest, err := manifest.Digest([]byte(m))
|
manifestDigest, err := manifest.Digest([]byte(m))
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -299,16 +232,10 @@ func (s *CopySuite) TestCopyWithManifestListStorageDigest(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArches(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArches(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage-digest")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
dir1, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-dir")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir2 := c.MkDir()
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-dir")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
||||||
manifestDigest, err := manifest.Digest([]byte(m))
|
manifestDigest, err := manifest.Digest([]byte(m))
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -321,9 +248,7 @@ func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArches(c *check
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesBothUseListDigest(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesBothUseListDigest(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-multiple-arches-both")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
||||||
manifestDigest, err := manifest.Digest([]byte(m))
|
manifestDigest, err := manifest.Digest([]byte(m))
|
||||||
@ -343,9 +268,7 @@ func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesBothUseLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesFirstUsesListDigest(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesFirstUsesListDigest(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-multiple-arches-first")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
||||||
manifestDigest, err := manifest.Digest([]byte(m))
|
manifestDigest, err := manifest.Digest([]byte(m))
|
||||||
@ -379,9 +302,7 @@ func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesFirstUses
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesSecondUsesListDigest(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesSecondUsesListDigest(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-multiple-arches-second")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
||||||
manifestDigest, err := manifest.Digest([]byte(m))
|
manifestDigest, err := manifest.Digest([]byte(m))
|
||||||
@ -415,9 +336,7 @@ func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesSecondUse
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesThirdUsesListDigest(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesThirdUsesListDigest(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-multiple-arches-third")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
||||||
manifestDigest, err := manifest.Digest([]byte(m))
|
manifestDigest, err := manifest.Digest([]byte(m))
|
||||||
@ -451,9 +370,7 @@ func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesThirdUses
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesTagAndDigest(c *check.C) {
|
func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesTagAndDigest(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-manifest-list-storage-digest-multiple-arches-tag-digest")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
m := combinedOutputOfCommand(c, skopeoBinary, "inspect", "--raw", knownListImage)
|
||||||
manifestDigest, err := manifest.Digest([]byte(m))
|
manifestDigest, err := manifest.Digest([]byte(m))
|
||||||
@ -496,28 +413,20 @@ func (s *CopySuite) TestCopyWithManifestListStorageDigestMultipleArchesTagAndDig
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyFailsWhenImageOSDoesNotMatchRuntimeOS(c *check.C) {
|
func (s *CopySuite) TestCopyFailsWhenImageOSDoesNotMatchRuntimeOS(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-fails-image-does-not-match-runtime")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
assertSkopeoFails(c, `.*no image found in manifest list for architecture .*, variant .*, OS .*`, "copy", knownWindowsOnlyImage, "containers-storage:"+storage+"test")
|
assertSkopeoFails(c, `.*no image found in manifest list for architecture .*, variant .*, OS .*`, "copy", knownWindowsOnlyImage, "containers-storage:"+storage+"test")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopySucceedsWhenImageDoesNotMatchRuntimeButWeOverride(c *check.C) {
|
func (s *CopySuite) TestCopySucceedsWhenImageDoesNotMatchRuntimeButWeOverride(c *check.C) {
|
||||||
storage, err := ioutil.TempDir("", "copy-succeeds-image-does-not-match-runtime-but-override")
|
storage := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(storage)
|
|
||||||
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage)
|
||||||
assertSkopeoSucceeds(c, "", "--override-os=windows", "--override-arch=amd64", "copy", knownWindowsOnlyImage, "containers-storage:"+storage+"test")
|
assertSkopeoSucceeds(c, "", "--override-os=windows", "--override-arch=amd64", "copy", knownWindowsOnlyImage, "containers-storage:"+storage+"test")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopySimpleAtomicRegistry(c *check.C) {
|
func (s *CopySuite) TestCopySimpleAtomicRegistry(c *check.C) {
|
||||||
dir1, err := ioutil.TempDir("", "copy-1")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir2 := c.MkDir()
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-2")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
// "pull": docker: → dir:
|
// "pull": docker: → dir:
|
||||||
@ -533,12 +442,8 @@ func (s *CopySuite) TestCopySimpleAtomicRegistry(c *check.C) {
|
|||||||
func (s *CopySuite) TestCopySimple(c *check.C) {
|
func (s *CopySuite) TestCopySimple(c *check.C) {
|
||||||
const ourRegistry = "docker://" + v2DockerRegistryURL + "/"
|
const ourRegistry = "docker://" + v2DockerRegistryURL + "/"
|
||||||
|
|
||||||
dir1, err := ioutil.TempDir("", "copy-1")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir2 := c.MkDir()
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "copy-2")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
// "pull": docker: → dir:
|
// "pull": docker: → dir:
|
||||||
@ -557,7 +462,7 @@ func (s *CopySuite) TestCopySimple(c *check.C) {
|
|||||||
ociImgName := "pause"
|
ociImgName := "pause"
|
||||||
defer os.RemoveAll(ociDest)
|
defer os.RemoveAll(ociDest)
|
||||||
assertSkopeoSucceeds(c, "", "copy", "docker://k8s.gcr.io/pause:latest", "oci:"+ociDest+":"+ociImgName)
|
assertSkopeoSucceeds(c, "", "copy", "docker://k8s.gcr.io/pause:latest", "oci:"+ociDest+":"+ociImgName)
|
||||||
_, err = os.Stat(ociDest)
|
_, err := os.Stat(ociDest)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
// docker v2s2 -> OCI image layout without image name
|
// docker v2s2 -> OCI image layout without image name
|
||||||
@ -569,31 +474,14 @@ func (s *CopySuite) TestCopySimple(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyEncryption(c *check.C) {
|
func (s *CopySuite) TestCopyEncryption(c *check.C) {
|
||||||
|
originalImageDir := c.MkDir()
|
||||||
originalImageDir, err := ioutil.TempDir("", "copy-1")
|
encryptedImgDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
decryptedImgDir := c.MkDir()
|
||||||
defer os.RemoveAll(originalImageDir)
|
keysDir := c.MkDir()
|
||||||
encryptedImgDir, err := ioutil.TempDir("", "copy-2")
|
undecryptedImgDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
multiLayerImageDir := c.MkDir()
|
||||||
defer os.RemoveAll(encryptedImgDir)
|
partiallyEncryptedImgDir := c.MkDir()
|
||||||
decryptedImgDir, err := ioutil.TempDir("", "copy-3")
|
partiallyDecryptedImgDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(decryptedImgDir)
|
|
||||||
keysDir, err := ioutil.TempDir("", "copy-4")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(keysDir)
|
|
||||||
undecryptedImgDir, err := ioutil.TempDir("", "copy-5")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(undecryptedImgDir)
|
|
||||||
multiLayerImageDir, err := ioutil.TempDir("", "copy-6")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(multiLayerImageDir)
|
|
||||||
partiallyEncryptedImgDir, err := ioutil.TempDir("", "copy-7")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(partiallyEncryptedImgDir)
|
|
||||||
partiallyDecryptedImgDir, err := ioutil.TempDir("", "copy-8")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(partiallyDecryptedImgDir)
|
|
||||||
|
|
||||||
// Create RSA key pair
|
// Create RSA key pair
|
||||||
privateKey, err := rsa.GenerateKey(rand.Reader, 4096)
|
privateKey, err := rsa.GenerateKey(rand.Reader, 4096)
|
||||||
@ -745,12 +633,8 @@ func assertSchema1DirImagesAreEqualExceptNames(c *check.C, dir1, ref1, dir2, ref
|
|||||||
|
|
||||||
// Streaming (skopeo copy)
|
// Streaming (skopeo copy)
|
||||||
func (s *CopySuite) TestCopyStreaming(c *check.C) {
|
func (s *CopySuite) TestCopyStreaming(c *check.C) {
|
||||||
dir1, err := ioutil.TempDir("", "streaming-1")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
dir2 := c.MkDir()
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
dir2, err := ioutil.TempDir("", "streaming-2")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir2)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
// streaming: docker: → atomic:
|
// streaming: docker: → atomic:
|
||||||
@ -770,12 +654,8 @@ func (s *CopySuite) TestCopyStreaming(c *check.C) {
|
|||||||
func (s *CopySuite) TestCopyOCIRoundTrip(c *check.C) {
|
func (s *CopySuite) TestCopyOCIRoundTrip(c *check.C) {
|
||||||
const ourRegistry = "docker://" + v2DockerRegistryURL + "/"
|
const ourRegistry = "docker://" + v2DockerRegistryURL + "/"
|
||||||
|
|
||||||
oci1, err := ioutil.TempDir("", "oci-1")
|
oci1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
oci2 := c.MkDir()
|
||||||
defer os.RemoveAll(oci1)
|
|
||||||
oci2, err := ioutil.TempDir("", "oci-2")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(oci2)
|
|
||||||
|
|
||||||
// Docker -> OCI
|
// Docker -> OCI
|
||||||
assertSkopeoSucceeds(c, "", "--tls-verify=false", "--debug", "copy", testFQIN, "oci:"+oci1+":latest")
|
assertSkopeoSucceeds(c, "", "--tls-verify=false", "--debug", "copy", testFQIN, "oci:"+oci1+":latest")
|
||||||
@ -798,7 +678,7 @@ func (s *CopySuite) TestCopyOCIRoundTrip(c *check.C) {
|
|||||||
// Verify using the upstream OCI image validator, this should catch most
|
// Verify using the upstream OCI image validator, this should catch most
|
||||||
// non-compliance errors. DO NOT REMOVE THIS TEST UNLESS IT'S ABSOLUTELY
|
// non-compliance errors. DO NOT REMOVE THIS TEST UNLESS IT'S ABSOLUTELY
|
||||||
// NECESSARY.
|
// NECESSARY.
|
||||||
err = image.ValidateLayout(oci1, nil, logger)
|
err := image.ValidateLayout(oci1, nil, logger)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
err = image.ValidateLayout(oci2, nil, logger)
|
err = image.ValidateLayout(oci2, nil, logger)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -820,9 +700,7 @@ func (s *CopySuite) TestCopySignatures(c *check.C) {
|
|||||||
c.Skip(fmt.Sprintf("Signing not supported: %v", err))
|
c.Skip(fmt.Sprintf("Signing not supported: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, err := ioutil.TempDir("", "signatures-dest")
|
dir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir)
|
|
||||||
dirDest := "dir:" + dir
|
dirDest := "dir:" + dir
|
||||||
|
|
||||||
policy := fileFromFixture(c, "fixtures/policy.json", map[string]string{"@keydir@": s.gpgHome})
|
policy := fileFromFixture(c, "fixtures/policy.json", map[string]string{"@keydir@": s.gpgHome})
|
||||||
@ -876,9 +754,7 @@ func (s *CopySuite) TestCopyDirSignatures(c *check.C) {
|
|||||||
c.Skip(fmt.Sprintf("Signing not supported: %v", err))
|
c.Skip(fmt.Sprintf("Signing not supported: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
topDir, err := ioutil.TempDir("", "dir-signatures-top")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
topDirDest := "dir:" + topDir
|
topDirDest := "dir:" + topDir
|
||||||
|
|
||||||
for _, suffix := range []string{"/dir1", "/dir2", "/restricted/personal", "/restricted/official", "/restricted/badidentity", "/dest"} {
|
for _, suffix := range []string{"/dir1", "/dir2", "/restricted/personal", "/restricted/official", "/restricted/badidentity", "/dest"} {
|
||||||
@ -921,9 +797,7 @@ func (s *CopySuite) TestCopyDirSignatures(c *check.C) {
|
|||||||
func (s *CopySuite) TestCopyCompression(c *check.C) {
|
func (s *CopySuite) TestCopyCompression(c *check.C) {
|
||||||
const uncompresssedLayerFile = "160d823fdc48e62f97ba62df31e55424f8f5eb6b679c865eec6e59adfe304710"
|
const uncompresssedLayerFile = "160d823fdc48e62f97ba62df31e55424f8f5eb6b679c865eec6e59adfe304710"
|
||||||
|
|
||||||
topDir, err := ioutil.TempDir("", "compression-top")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
|
|
||||||
for i, t := range []struct{ fixture, remote string }{
|
for i, t := range []struct{ fixture, remote string }{
|
||||||
{"uncompressed-image-s1", "docker://" + v2DockerRegistryURL + "/compression/compression:s1"},
|
{"uncompressed-image-s1", "docker://" + v2DockerRegistryURL + "/compression/compression:s1"},
|
||||||
@ -982,9 +856,7 @@ func (s *CopySuite) TestCopyDockerSigstore(c *check.C) {
|
|||||||
|
|
||||||
const ourRegistry = "docker://" + v2DockerRegistryURL + "/"
|
const ourRegistry = "docker://" + v2DockerRegistryURL + "/"
|
||||||
|
|
||||||
tmpDir, err := ioutil.TempDir("", "signatures-sigstore")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
copyDest := filepath.Join(tmpDir, "dest")
|
copyDest := filepath.Join(tmpDir, "dest")
|
||||||
err = os.Mkdir(copyDest, 0755)
|
err = os.Mkdir(copyDest, 0755)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -1050,9 +922,7 @@ func (s *CopySuite) TestCopyAtomicExtension(c *check.C) {
|
|||||||
c.Skip(fmt.Sprintf("Signing not supported: %v", err))
|
c.Skip(fmt.Sprintf("Signing not supported: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
topDir, err := ioutil.TempDir("", "atomic-extension")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
for _, subdir := range []string{"dirAA", "dirAD", "dirDA", "dirDD", "registries.d"} {
|
for _, subdir := range []string{"dirAA", "dirAD", "dirDA", "dirDD", "registries.d"} {
|
||||||
err := os.MkdirAll(filepath.Join(topDir, subdir), 0755)
|
err := os.MkdirAll(filepath.Join(topDir, subdir), 0755)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -1102,9 +972,7 @@ func (s *CopySuite) TestCopyAtomicExtension(c *check.C) {
|
|||||||
// copyWithSignedIdentity creates a copy of an unsigned image, adding a signature for an unrelated identity
|
// copyWithSignedIdentity creates a copy of an unsigned image, adding a signature for an unrelated identity
|
||||||
// This should be easier than using standalone-sign.
|
// This should be easier than using standalone-sign.
|
||||||
func copyWithSignedIdentity(c *check.C, src, dest, signedIdentity, signBy, registriesDir string) {
|
func copyWithSignedIdentity(c *check.C, src, dest, signedIdentity, signBy, registriesDir string) {
|
||||||
topDir, err := ioutil.TempDir("", "copyWithSignedIdentity")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
|
|
||||||
signingDir := filepath.Join(topDir, "signing-temp")
|
signingDir := filepath.Join(topDir, "signing-temp")
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--src-tls-verify=false", src, "dir:"+signingDir)
|
assertSkopeoSucceeds(c, "", "copy", "--src-tls-verify=false", src, "dir:"+signingDir)
|
||||||
@ -1126,9 +994,7 @@ func (s *CopySuite) TestCopyVerifyingMirroredSignatures(c *check.C) {
|
|||||||
c.Skip(fmt.Sprintf("Signing not supported: %v", err))
|
c.Skip(fmt.Sprintf("Signing not supported: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
topDir, err := ioutil.TempDir("", "mirrored-signatures")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
registriesDir := filepath.Join(topDir, "registries.d") // An empty directory to disable sigstore use
|
registriesDir := filepath.Join(topDir, "registries.d") // An empty directory to disable sigstore use
|
||||||
dirDest := "dir:" + filepath.Join(topDir, "unused-dest")
|
dirDest := "dir:" + filepath.Join(topDir, "unused-dest")
|
||||||
|
|
||||||
@ -1189,9 +1055,7 @@ func (s *CopySuite) TestCopyVerifyingMirroredSignatures(c *check.C) {
|
|||||||
|
|
||||||
func (s *SkopeoSuite) TestCopySrcWithAuth(c *check.C) {
|
func (s *SkopeoSuite) TestCopySrcWithAuth(c *check.C) {
|
||||||
assertSkopeoSucceeds(c, "", "--tls-verify=false", "copy", "--dest-creds=testuser:testpassword", testFQIN, fmt.Sprintf("docker://%s/busybox:latest", s.regV2WithAuth.url))
|
assertSkopeoSucceeds(c, "", "--tls-verify=false", "copy", "--dest-creds=testuser:testpassword", testFQIN, fmt.Sprintf("docker://%s/busybox:latest", s.regV2WithAuth.url))
|
||||||
dir1, err := ioutil.TempDir("", "copy-1")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(dir1)
|
|
||||||
assertSkopeoSucceeds(c, "", "--tls-verify=false", "copy", "--src-creds=testuser:testpassword", fmt.Sprintf("docker://%s/busybox:latest", s.regV2WithAuth.url), "dir:"+dir1)
|
assertSkopeoSucceeds(c, "", "--tls-verify=false", "copy", "--src-creds=testuser:testpassword", fmt.Sprintf("docker://%s/busybox:latest", s.regV2WithAuth.url), "dir:"+dir1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1205,9 +1069,7 @@ func (s *SkopeoSuite) TestCopySrcAndDestWithAuth(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyNoPanicOnHTTPResponseWithoutTLSVerifyFalse(c *check.C) {
|
func (s *CopySuite) TestCopyNoPanicOnHTTPResponseWithoutTLSVerifyFalse(c *check.C) {
|
||||||
topDir, err := ioutil.TempDir("", "no-panic-on-https-response-without-tls-verify-false")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
|
|
||||||
const ourRegistry = "docker://" + v2DockerRegistryURL + "/"
|
const ourRegistry = "docker://" + v2DockerRegistryURL + "/"
|
||||||
|
|
||||||
@ -1223,9 +1085,7 @@ func (s *CopySuite) TestCopySchemaConversion(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyManifestConversion(c *check.C) {
|
func (s *CopySuite) TestCopyManifestConversion(c *check.C) {
|
||||||
topDir, err := ioutil.TempDir("", "manifest-conversion")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
srcDir := filepath.Join(topDir, "source")
|
srcDir := filepath.Join(topDir, "source")
|
||||||
destDir1 := filepath.Join(topDir, "dest1")
|
destDir1 := filepath.Join(topDir, "dest1")
|
||||||
destDir2 := filepath.Join(topDir, "dest2")
|
destDir2 := filepath.Join(topDir, "dest2")
|
||||||
@ -1249,18 +1109,14 @@ func (s *CopySuite) TestCopyManifestConversion(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) TestCopyPreserveDigests(c *check.C) {
|
func (s *CopySuite) TestCopyPreserveDigests(c *check.C) {
|
||||||
topDir, err := ioutil.TempDir("", "preserve-digests")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
|
|
||||||
assertSkopeoSucceeds(c, "", "copy", knownListImage, "--multi-arch=all", "--preserve-digests", "dir:"+topDir)
|
assertSkopeoSucceeds(c, "", "copy", knownListImage, "--multi-arch=all", "--preserve-digests", "dir:"+topDir)
|
||||||
assertSkopeoFails(c, ".*Instructed to preserve digests.*", "copy", knownListImage, "--multi-arch=all", "--preserve-digests", "--format=oci", "dir:"+topDir)
|
assertSkopeoFails(c, ".*Instructed to preserve digests.*", "copy", knownListImage, "--multi-arch=all", "--preserve-digests", "--format=oci", "dir:"+topDir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CopySuite) testCopySchemaConversionRegistries(c *check.C, schema1Registry, schema2Registry string) {
|
func (s *CopySuite) testCopySchemaConversionRegistries(c *check.C, schema1Registry, schema2Registry string) {
|
||||||
topDir, err := ioutil.TempDir("", "schema-conversion")
|
topDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(topDir)
|
|
||||||
for _, subdir := range []string{"input1", "input2", "dest2"} {
|
for _, subdir := range []string{"input1", "input2", "dest2"} {
|
||||||
err := os.MkdirAll(filepath.Join(topDir, subdir), 0755)
|
err := os.MkdirAll(filepath.Join(topDir, subdir), 0755)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -1294,16 +1150,14 @@ func (s *CopySuite) testCopySchemaConversionRegistries(c *check.C, schema1Regist
|
|||||||
const regConfFixture = "./fixtures/registries.conf"
|
const regConfFixture = "./fixtures/registries.conf"
|
||||||
|
|
||||||
func (s *SkopeoSuite) TestSuccessCopySrcWithMirror(c *check.C) {
|
func (s *SkopeoSuite) TestSuccessCopySrcWithMirror(c *check.C) {
|
||||||
dir, err := ioutil.TempDir("", "copy-mirror")
|
dir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
assertSkopeoSucceeds(c, "", "--registries-conf="+regConfFixture, "copy",
|
assertSkopeoSucceeds(c, "", "--registries-conf="+regConfFixture, "copy",
|
||||||
"docker://mirror.invalid/busybox", "dir:"+dir)
|
"docker://mirror.invalid/busybox", "dir:"+dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SkopeoSuite) TestFailureCopySrcWithMirrorsUnavailable(c *check.C) {
|
func (s *SkopeoSuite) TestFailureCopySrcWithMirrorsUnavailable(c *check.C) {
|
||||||
dir, err := ioutil.TempDir("", "copy-mirror")
|
dir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
// .invalid domains are, per RFC 6761, supposed to result in NXDOMAIN.
|
// .invalid domains are, per RFC 6761, supposed to result in NXDOMAIN.
|
||||||
// With systemd-resolved (used only via NSS?), we instead seem to get “Temporary failure in name resolution”
|
// With systemd-resolved (used only via NSS?), we instead seem to get “Temporary failure in name resolution”
|
||||||
@ -1312,16 +1166,14 @@ func (s *SkopeoSuite) TestFailureCopySrcWithMirrorsUnavailable(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SkopeoSuite) TestSuccessCopySrcWithMirrorAndPrefix(c *check.C) {
|
func (s *SkopeoSuite) TestSuccessCopySrcWithMirrorAndPrefix(c *check.C) {
|
||||||
dir, err := ioutil.TempDir("", "copy-mirror")
|
dir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
assertSkopeoSucceeds(c, "", "--registries-conf="+regConfFixture, "copy",
|
assertSkopeoSucceeds(c, "", "--registries-conf="+regConfFixture, "copy",
|
||||||
"docker://gcr.invalid/foo/bar/busybox", "dir:"+dir)
|
"docker://gcr.invalid/foo/bar/busybox", "dir:"+dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SkopeoSuite) TestFailureCopySrcWithMirrorAndPrefixUnavailable(c *check.C) {
|
func (s *SkopeoSuite) TestFailureCopySrcWithMirrorAndPrefixUnavailable(c *check.C) {
|
||||||
dir, err := ioutil.TempDir("", "copy-mirror")
|
dir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
// .invalid domains are, per RFC 6761, supposed to result in NXDOMAIN.
|
// .invalid domains are, per RFC 6761, supposed to result in NXDOMAIN.
|
||||||
// With systemd-resolved (used only via NSS?), we instead seem to get “Temporary failure in name resolution”
|
// With systemd-resolved (used only via NSS?), we instead seem to get “Temporary failure in name resolution”
|
||||||
|
@ -33,10 +33,7 @@ type openshiftCluster struct {
|
|||||||
// in isolated test environment.
|
// in isolated test environment.
|
||||||
func startOpenshiftCluster(c *check.C) *openshiftCluster {
|
func startOpenshiftCluster(c *check.C) *openshiftCluster {
|
||||||
cluster := &openshiftCluster{}
|
cluster := &openshiftCluster{}
|
||||||
|
cluster.workingDir = c.MkDir()
|
||||||
dir, err := ioutil.TempDir("", "openshift-cluster")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
cluster.workingDir = dir
|
|
||||||
|
|
||||||
cluster.startMaster(c)
|
cluster.startMaster(c)
|
||||||
cluster.prepareRegistryConfig(c)
|
cluster.prepareRegistryConfig(c)
|
||||||
@ -262,10 +259,6 @@ func (cluster *openshiftCluster) tearDown(c *check.C) {
|
|||||||
// so we couldn’t check just for that. This is running in a container anyway…
|
// so we couldn’t check just for that. This is running in a container anyway…
|
||||||
_ = cluster.processes[i].Process.Kill()
|
_ = cluster.processes[i].Process.Kill()
|
||||||
}
|
}
|
||||||
if cluster.workingDir != "" {
|
|
||||||
err := os.RemoveAll(cluster.workingDir)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
}
|
|
||||||
if cluster.dockerDir != "" {
|
if cluster.dockerDir != "" {
|
||||||
err := os.RemoveAll(cluster.dockerDir)
|
err := os.RemoveAll(cluster.dockerDir)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
@ -20,7 +20,6 @@ const (
|
|||||||
type testRegistryV2 struct {
|
type testRegistryV2 struct {
|
||||||
cmd *exec.Cmd
|
cmd *exec.Cmd
|
||||||
url string
|
url string
|
||||||
dir string
|
|
||||||
username string
|
username string
|
||||||
password string
|
password string
|
||||||
email string
|
email string
|
||||||
@ -45,10 +44,7 @@ func setupRegistryV2At(c *check.C, url string, auth, schema1 bool) *testRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newTestRegistryV2At(c *check.C, url string, auth, schema1 bool) (*testRegistryV2, error) {
|
func newTestRegistryV2At(c *check.C, url string, auth, schema1 bool) (*testRegistryV2, error) {
|
||||||
tmp, err := ioutil.TempDir("", "registry-test-")
|
tmp := c.MkDir()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
template := `version: 0.1
|
template := `version: 0.1
|
||||||
loglevel: debug
|
loglevel: debug
|
||||||
storage:
|
storage:
|
||||||
@ -86,7 +82,6 @@ http:
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if _, err := fmt.Fprintf(config, template, tmp, url, htpasswd); err != nil {
|
if _, err := fmt.Fprintf(config, template, tmp, url, htpasswd); err != nil {
|
||||||
os.RemoveAll(tmp)
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +93,6 @@ http:
|
|||||||
cmd := exec.Command(binary, confPath)
|
cmd := exec.Command(binary, confPath)
|
||||||
consumeAndLogOutputs(c, fmt.Sprintf("registry-%s", url), cmd)
|
consumeAndLogOutputs(c, fmt.Sprintf("registry-%s", url), cmd)
|
||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
os.RemoveAll(tmp)
|
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
c.Skip(err.Error())
|
c.Skip(err.Error())
|
||||||
}
|
}
|
||||||
@ -107,7 +101,6 @@ http:
|
|||||||
return &testRegistryV2{
|
return &testRegistryV2{
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
url: url,
|
url: url,
|
||||||
dir: tmp,
|
|
||||||
username: username,
|
username: username,
|
||||||
password: password,
|
password: password,
|
||||||
email: email,
|
email: email,
|
||||||
@ -130,6 +123,4 @@ func (t *testRegistryV2) tearDown(c *check.C) {
|
|||||||
// It’s undocumented what Kill() returns if the process has terminated,
|
// It’s undocumented what Kill() returns if the process has terminated,
|
||||||
// so we couldn’t check just for that. This is running in a container anyway…
|
// so we couldn’t check just for that. This is running in a container anyway…
|
||||||
_ = t.cmd.Process.Kill()
|
_ = t.cmd.Process.Kill()
|
||||||
err := os.RemoveAll(t.dir)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SigningSuite struct {
|
type SigningSuite struct {
|
||||||
gpgHome string
|
|
||||||
fingerprint string
|
fingerprint string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,25 +39,18 @@ func (s *SigningSuite) SetUpSuite(c *check.C) {
|
|||||||
_, err := exec.LookPath(skopeoBinary)
|
_, err := exec.LookPath(skopeoBinary)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
s.gpgHome, err = ioutil.TempDir("", "skopeo-gpg")
|
gpgHome := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
os.Setenv("GNUPGHOME", gpgHome)
|
||||||
os.Setenv("GNUPGHOME", s.gpgHome)
|
|
||||||
|
|
||||||
runCommandWithInput(c, "Key-Type: RSA\nName-Real: Testing user\n%no-protection\n%commit\n", gpgBinary, "--homedir", s.gpgHome, "--batch", "--gen-key")
|
runCommandWithInput(c, "Key-Type: RSA\nName-Real: Testing user\n%no-protection\n%commit\n", gpgBinary, "--homedir", gpgHome, "--batch", "--gen-key")
|
||||||
|
|
||||||
lines, err := exec.Command(gpgBinary, "--homedir", s.gpgHome, "--with-colons", "--no-permission-warning", "--fingerprint").Output()
|
lines, err := exec.Command(gpgBinary, "--homedir", gpgHome, "--with-colons", "--no-permission-warning", "--fingerprint").Output()
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
s.fingerprint, err = findFingerprint(lines)
|
s.fingerprint, err = findFingerprint(lines)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SigningSuite) TearDownSuite(c *check.C) {
|
func (s *SigningSuite) TearDownSuite(c *check.C) {
|
||||||
if s.gpgHome != "" {
|
|
||||||
err := os.RemoveAll(s.gpgHome)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
}
|
|
||||||
s.gpgHome = ""
|
|
||||||
|
|
||||||
os.Unsetenv("GNUPGHOME")
|
os.Unsetenv("GNUPGHOME")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ func init() {
|
|||||||
type SyncSuite struct {
|
type SyncSuite struct {
|
||||||
cluster *openshiftCluster
|
cluster *openshiftCluster
|
||||||
registry *testRegistryV2
|
registry *testRegistryV2
|
||||||
gpgHome string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) SetUpSuite(c *check.C) {
|
func (s *SyncSuite) SetUpSuite(c *check.C) {
|
||||||
@ -74,10 +73,8 @@ func (s *SyncSuite) SetUpSuite(c *check.C) {
|
|||||||
// FIXME: Set up TLS for the docker registry port instead of using "--tls-verify=false" all over the place.
|
// FIXME: Set up TLS for the docker registry port instead of using "--tls-verify=false" all over the place.
|
||||||
s.registry = setupRegistryV2At(c, v2DockerRegistryURL, registryAuth, registrySchema1)
|
s.registry = setupRegistryV2At(c, v2DockerRegistryURL, registryAuth, registrySchema1)
|
||||||
|
|
||||||
gpgHome, err := ioutil.TempDir("", "skopeo-gpg")
|
gpgHome := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
os.Setenv("GNUPGHOME", gpgHome)
|
||||||
s.gpgHome = gpgHome
|
|
||||||
os.Setenv("GNUPGHOME", s.gpgHome)
|
|
||||||
|
|
||||||
for _, key := range []string{"personal", "official"} {
|
for _, key := range []string{"personal", "official"} {
|
||||||
batchInput := fmt.Sprintf("Key-Type: RSA\nName-Real: Test key - %s\nName-email: %s@example.com\n%%no-protection\n%%commit\n",
|
batchInput := fmt.Sprintf("Key-Type: RSA\nName-Real: Test key - %s\nName-email: %s@example.com\n%%no-protection\n%%commit\n",
|
||||||
@ -85,7 +82,7 @@ func (s *SyncSuite) SetUpSuite(c *check.C) {
|
|||||||
runCommandWithInput(c, batchInput, gpgBinary, "--batch", "--gen-key")
|
runCommandWithInput(c, batchInput, gpgBinary, "--batch", "--gen-key")
|
||||||
|
|
||||||
out := combinedOutputOfCommand(c, gpgBinary, "--armor", "--export", fmt.Sprintf("%s@example.com", key))
|
out := combinedOutputOfCommand(c, gpgBinary, "--armor", "--export", fmt.Sprintf("%s@example.com", key))
|
||||||
err := ioutil.WriteFile(filepath.Join(s.gpgHome, fmt.Sprintf("%s-pubkey.gpg", key)),
|
err := ioutil.WriteFile(filepath.Join(gpgHome, fmt.Sprintf("%s-pubkey.gpg", key)),
|
||||||
[]byte(out), 0600)
|
[]byte(out), 0600)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
}
|
}
|
||||||
@ -96,9 +93,6 @@ func (s *SyncSuite) TearDownSuite(c *check.C) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.gpgHome != "" {
|
|
||||||
os.RemoveAll(s.gpgHome)
|
|
||||||
}
|
|
||||||
if s.registry != nil {
|
if s.registry != nil {
|
||||||
s.registry.tearDown(c)
|
s.registry.tearDown(c)
|
||||||
}
|
}
|
||||||
@ -108,9 +102,7 @@ func (s *SyncSuite) TearDownSuite(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestDocker2DirTagged(c *check.C) {
|
func (s *SyncSuite) TestDocker2DirTagged(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
image := pullableTaggedImage
|
image := pullableTaggedImage
|
||||||
@ -136,9 +128,7 @@ func (s *SyncSuite) TestDocker2DirTagged(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestDocker2DirTaggedAll(c *check.C) {
|
func (s *SyncSuite) TestDocker2DirTaggedAll(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
image := pullableTaggedManifestList
|
image := pullableTaggedManifestList
|
||||||
@ -164,16 +154,14 @@ func (s *SyncSuite) TestDocker2DirTaggedAll(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestPreserveDigests(c *check.C) {
|
func (s *SyncSuite) TestPreserveDigests(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
image := pullableTaggedManifestList
|
image := pullableTaggedManifestList
|
||||||
|
|
||||||
// copy docker => dir
|
// copy docker => dir
|
||||||
assertSkopeoSucceeds(c, "", "copy", "--all", "--preserve-digests", "docker://"+image, "dir:"+tmpDir)
|
assertSkopeoSucceeds(c, "", "copy", "--all", "--preserve-digests", "docker://"+image, "dir:"+tmpDir)
|
||||||
_, err = os.Stat(path.Join(tmpDir, "manifest.json"))
|
_, err := os.Stat(path.Join(tmpDir, "manifest.json"))
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
assertSkopeoFails(c, ".*Instructed to preserve digests.*", "copy", "--all", "--preserve-digests", "--format=oci", "docker://"+image, "dir:"+tmpDir)
|
assertSkopeoFails(c, ".*Instructed to preserve digests.*", "copy", "--all", "--preserve-digests", "--format=oci", "docker://"+image, "dir:"+tmpDir)
|
||||||
@ -186,8 +174,7 @@ func (s *SyncSuite) TestScoped(c *check.C) {
|
|||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
imagePath := imageRef.DockerReference().String()
|
imagePath := imageRef.DockerReference().String()
|
||||||
|
|
||||||
dir1, err := ioutil.TempDir("", "skopeo-sync-test")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
assertSkopeoSucceeds(c, "", "sync", "--src", "docker", "--dest", "dir", image, dir1)
|
assertSkopeoSucceeds(c, "", "sync", "--src", "docker", "--dest", "dir", image, dir1)
|
||||||
_, err = os.Stat(path.Join(dir1, path.Base(imagePath), "manifest.json"))
|
_, err = os.Stat(path.Join(dir1, path.Base(imagePath), "manifest.json"))
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -195,8 +182,6 @@ func (s *SyncSuite) TestScoped(c *check.C) {
|
|||||||
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src", "docker", "--dest", "dir", image, dir1)
|
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src", "docker", "--dest", "dir", image, dir1)
|
||||||
_, err = os.Stat(path.Join(dir1, imagePath, "manifest.json"))
|
_, err = os.Stat(path.Join(dir1, imagePath, "manifest.json"))
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
os.RemoveAll(dir1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestDirIsNotOverwritten(c *check.C) {
|
func (s *SyncSuite) TestDirIsNotOverwritten(c *check.C) {
|
||||||
@ -210,8 +195,7 @@ func (s *SyncSuite) TestDirIsNotOverwritten(c *check.C) {
|
|||||||
assertSkopeoSucceeds(c, "", "copy", "--dest-tls-verify=false", "docker://"+image, "docker://"+path.Join(v2DockerRegistryURL, reference.Path(imageRef.DockerReference())))
|
assertSkopeoSucceeds(c, "", "copy", "--dest-tls-verify=false", "docker://"+image, "docker://"+path.Join(v2DockerRegistryURL, reference.Path(imageRef.DockerReference())))
|
||||||
|
|
||||||
//sync upstream image to dir, not scoped
|
//sync upstream image to dir, not scoped
|
||||||
dir1, err := ioutil.TempDir("", "skopeo-sync-test")
|
dir1 := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
assertSkopeoSucceeds(c, "", "sync", "--src", "docker", "--dest", "dir", image, dir1)
|
assertSkopeoSucceeds(c, "", "sync", "--src", "docker", "--dest", "dir", image, dir1)
|
||||||
_, err = os.Stat(path.Join(dir1, path.Base(imagePath), "manifest.json"))
|
_, err = os.Stat(path.Join(dir1, path.Base(imagePath), "manifest.json"))
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
@ -226,14 +210,10 @@ func (s *SyncSuite) TestDirIsNotOverwritten(c *check.C) {
|
|||||||
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src-tls-verify=false", "--src", "docker", "--dest", "dir", path.Join(v2DockerRegistryURL, reference.Path(imageRef.DockerReference())), dir1)
|
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src-tls-verify=false", "--src", "docker", "--dest", "dir", path.Join(v2DockerRegistryURL, reference.Path(imageRef.DockerReference())), dir1)
|
||||||
_, err = os.Stat(path.Join(dir1, imagePath, "manifest.json"))
|
_, err = os.Stat(path.Join(dir1, imagePath, "manifest.json"))
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
os.RemoveAll(dir1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestDocker2DirUntagged(c *check.C) {
|
func (s *SyncSuite) TestDocker2DirUntagged(c *check.C) {
|
||||||
|
tmpDir := c.MkDir()
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
image := pullableRepo
|
image := pullableRepo
|
||||||
@ -255,9 +235,7 @@ func (s *SyncSuite) TestDocker2DirUntagged(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestYamlUntagged(c *check.C) {
|
func (s *SyncSuite) TestYamlUntagged(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
dir1 := path.Join(tmpDir, "dir1")
|
dir1 := path.Join(tmpDir, "dir1")
|
||||||
|
|
||||||
image := pullableRepo
|
image := pullableRepo
|
||||||
@ -321,9 +299,7 @@ func (s *SyncSuite) TestYamlUntagged(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestYamlRegex2Dir(c *check.C) {
|
func (s *SyncSuite) TestYamlRegex2Dir(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
dir1 := path.Join(tmpDir, "dir1")
|
dir1 := path.Join(tmpDir, "dir1")
|
||||||
|
|
||||||
yamlConfig := `
|
yamlConfig := `
|
||||||
@ -336,7 +312,7 @@ k8s.gcr.io:
|
|||||||
c.Assert(nTags, check.Not(check.Equals), 0)
|
c.Assert(nTags, check.Not(check.Equals), 0)
|
||||||
|
|
||||||
yamlFile := path.Join(tmpDir, "registries.yaml")
|
yamlFile := path.Join(tmpDir, "registries.yaml")
|
||||||
err = ioutil.WriteFile(yamlFile, []byte(yamlConfig), 0644)
|
err := ioutil.WriteFile(yamlFile, []byte(yamlConfig), 0644)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src", "yaml", "--dest", "dir", yamlFile, dir1)
|
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src", "yaml", "--dest", "dir", yamlFile, dir1)
|
||||||
|
|
||||||
@ -356,9 +332,7 @@ k8s.gcr.io:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestYamlDigest2Dir(c *check.C) {
|
func (s *SyncSuite) TestYamlDigest2Dir(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
dir1 := path.Join(tmpDir, "dir1")
|
dir1 := path.Join(tmpDir, "dir1")
|
||||||
|
|
||||||
yamlConfig := `
|
yamlConfig := `
|
||||||
@ -368,7 +342,7 @@ k8s.gcr.io:
|
|||||||
- sha256:59eec8837a4d942cc19a52b8c09ea75121acc38114a2c68b98983ce9356b8610
|
- sha256:59eec8837a4d942cc19a52b8c09ea75121acc38114a2c68b98983ce9356b8610
|
||||||
`
|
`
|
||||||
yamlFile := path.Join(tmpDir, "registries.yaml")
|
yamlFile := path.Join(tmpDir, "registries.yaml")
|
||||||
err = ioutil.WriteFile(yamlFile, []byte(yamlConfig), 0644)
|
err := ioutil.WriteFile(yamlFile, []byte(yamlConfig), 0644)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src", "yaml", "--dest", "dir", yamlFile, dir1)
|
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src", "yaml", "--dest", "dir", yamlFile, dir1)
|
||||||
|
|
||||||
@ -388,9 +362,7 @@ k8s.gcr.io:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestYaml2Dir(c *check.C) {
|
func (s *SyncSuite) TestYaml2Dir(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
dir1 := path.Join(tmpDir, "dir1")
|
dir1 := path.Join(tmpDir, "dir1")
|
||||||
|
|
||||||
yamlConfig := `
|
yamlConfig := `
|
||||||
@ -421,7 +393,7 @@ quay.io:
|
|||||||
c.Assert(nTags, check.Not(check.Equals), 0)
|
c.Assert(nTags, check.Not(check.Equals), 0)
|
||||||
|
|
||||||
yamlFile := path.Join(tmpDir, "registries.yaml")
|
yamlFile := path.Join(tmpDir, "registries.yaml")
|
||||||
err = ioutil.WriteFile(yamlFile, []byte(yamlConfig), 0644)
|
err := ioutil.WriteFile(yamlFile, []byte(yamlConfig), 0644)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src", "yaml", "--dest", "dir", yamlFile, dir1)
|
assertSkopeoSucceeds(c, "", "sync", "--scoped", "--src", "yaml", "--dest", "dir", yamlFile, dir1)
|
||||||
|
|
||||||
@ -442,9 +414,7 @@ quay.io:
|
|||||||
|
|
||||||
func (s *SyncSuite) TestYamlTLSVerify(c *check.C) {
|
func (s *SyncSuite) TestYamlTLSVerify(c *check.C) {
|
||||||
const localRegURL = "docker://" + v2DockerRegistryURL + "/"
|
const localRegURL = "docker://" + v2DockerRegistryURL + "/"
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
dir1 := path.Join(tmpDir, "dir1")
|
dir1 := path.Join(tmpDir, "dir1")
|
||||||
image := pullableRepoWithLatestTag
|
image := pullableRepoWithLatestTag
|
||||||
tag := "latest"
|
tag := "latest"
|
||||||
@ -486,7 +456,7 @@ func (s *SyncSuite) TestYamlTLSVerify(c *check.C) {
|
|||||||
for _, cfg := range testCfg {
|
for _, cfg := range testCfg {
|
||||||
yamlConfig := fmt.Sprintf(yamlTemplate, v2DockerRegistryURL, cfg.tlsVerify, image, tag)
|
yamlConfig := fmt.Sprintf(yamlTemplate, v2DockerRegistryURL, cfg.tlsVerify, image, tag)
|
||||||
yamlFile := path.Join(tmpDir, "registries.yaml")
|
yamlFile := path.Join(tmpDir, "registries.yaml")
|
||||||
err = ioutil.WriteFile(yamlFile, []byte(yamlConfig), 0644)
|
err := ioutil.WriteFile(yamlFile, []byte(yamlConfig), 0644)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
cfg.checker(c, cfg.msg, "sync", "--scoped", "--src", "yaml", "--dest", "dir", yamlFile, dir1)
|
cfg.checker(c, cfg.msg, "sync", "--scoped", "--src", "yaml", "--dest", "dir", yamlFile, dir1)
|
||||||
@ -497,9 +467,7 @@ func (s *SyncSuite) TestYamlTLSVerify(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestSyncManifestOutput(c *check.C) {
|
func (s *SyncSuite) TestSyncManifestOutput(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "sync-manifest-output")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
destDir1 := filepath.Join(tmpDir, "dest1")
|
destDir1 := filepath.Join(tmpDir, "dest1")
|
||||||
destDir2 := filepath.Join(tmpDir, "dest2")
|
destDir2 := filepath.Join(tmpDir, "dest2")
|
||||||
@ -519,9 +487,7 @@ func (s *SyncSuite) TestSyncManifestOutput(c *check.C) {
|
|||||||
func (s *SyncSuite) TestDocker2DockerTagged(c *check.C) {
|
func (s *SyncSuite) TestDocker2DockerTagged(c *check.C) {
|
||||||
const localRegURL = "docker://" + v2DockerRegistryURL + "/"
|
const localRegURL = "docker://" + v2DockerRegistryURL + "/"
|
||||||
|
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
image := pullableTaggedImage
|
image := pullableTaggedImage
|
||||||
@ -552,15 +518,13 @@ func (s *SyncSuite) TestDocker2DockerTagged(c *check.C) {
|
|||||||
func (s *SyncSuite) TestDir2DockerTagged(c *check.C) {
|
func (s *SyncSuite) TestDir2DockerTagged(c *check.C) {
|
||||||
const localRegURL = "docker://" + v2DockerRegistryURL + "/"
|
const localRegURL = "docker://" + v2DockerRegistryURL + "/"
|
||||||
|
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
// FIXME: It would be nice to use one of the local Docker registries instead of needing an Internet connection.
|
||||||
image := pullableRepoWithLatestTag
|
image := pullableRepoWithLatestTag
|
||||||
|
|
||||||
dir1 := path.Join(tmpDir, "dir1")
|
dir1 := path.Join(tmpDir, "dir1")
|
||||||
err = os.Mkdir(dir1, 0755)
|
err := os.Mkdir(dir1, 0755)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
dir2 := path.Join(tmpDir, "dir2")
|
dir2 := path.Join(tmpDir, "dir2")
|
||||||
err = os.Mkdir(dir2, 0755)
|
err = os.Mkdir(dir2, 0755)
|
||||||
@ -592,9 +556,7 @@ func (s *SyncSuite) TestDir2DockerTagged(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestFailsWithDir2Dir(c *check.C) {
|
func (s *SyncSuite) TestFailsWithDir2Dir(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
dir1 := path.Join(tmpDir, "dir1")
|
dir1 := path.Join(tmpDir, "dir1")
|
||||||
dir2 := path.Join(tmpDir, "dir2")
|
dir2 := path.Join(tmpDir, "dir2")
|
||||||
@ -604,9 +566,7 @@ func (s *SyncSuite) TestFailsWithDir2Dir(c *check.C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SyncSuite) TestFailsNoSourceImages(c *check.C) {
|
func (s *SyncSuite) TestFailsNoSourceImages(c *check.C) {
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
assertSkopeoFails(c, ".*No images to sync found in .*",
|
assertSkopeoFails(c, ".*No images to sync found in .*",
|
||||||
"sync", "--scoped", "--dest-tls-verify=false", "--src", "dir", "--dest", "docker", tmpDir, v2DockerRegistryURL)
|
"sync", "--scoped", "--dest-tls-verify=false", "--src", "dir", "--dest", "docker", tmpDir, v2DockerRegistryURL)
|
||||||
@ -618,9 +578,7 @@ func (s *SyncSuite) TestFailsNoSourceImages(c *check.C) {
|
|||||||
func (s *SyncSuite) TestFailsWithDockerSourceNoRegistry(c *check.C) {
|
func (s *SyncSuite) TestFailsWithDockerSourceNoRegistry(c *check.C) {
|
||||||
const regURL = "google.com/namespace/imagename"
|
const regURL = "google.com/namespace/imagename"
|
||||||
|
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
//untagged
|
//untagged
|
||||||
assertSkopeoFails(c, ".*invalid status code from registry 404.*",
|
assertSkopeoFails(c, ".*invalid status code from registry 404.*",
|
||||||
@ -633,9 +591,7 @@ func (s *SyncSuite) TestFailsWithDockerSourceNoRegistry(c *check.C) {
|
|||||||
|
|
||||||
func (s *SyncSuite) TestFailsWithDockerSourceUnauthorized(c *check.C) {
|
func (s *SyncSuite) TestFailsWithDockerSourceUnauthorized(c *check.C) {
|
||||||
const repo = "privateimagenamethatshouldnotbepublic"
|
const repo = "privateimagenamethatshouldnotbepublic"
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
//untagged
|
//untagged
|
||||||
assertSkopeoFails(c, ".*Registry disallows tag list retrieval.*",
|
assertSkopeoFails(c, ".*Registry disallows tag list retrieval.*",
|
||||||
@ -648,9 +604,7 @@ func (s *SyncSuite) TestFailsWithDockerSourceUnauthorized(c *check.C) {
|
|||||||
|
|
||||||
func (s *SyncSuite) TestFailsWithDockerSourceNotExisting(c *check.C) {
|
func (s *SyncSuite) TestFailsWithDockerSourceNotExisting(c *check.C) {
|
||||||
repo := path.Join(v2DockerRegistryURL, "imagedoesnotexist")
|
repo := path.Join(v2DockerRegistryURL, "imagedoesnotexist")
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
defer os.RemoveAll(tmpDir)
|
|
||||||
|
|
||||||
//untagged
|
//untagged
|
||||||
assertSkopeoFails(c, ".*invalid status code from registry 404.*",
|
assertSkopeoFails(c, ".*invalid status code from registry 404.*",
|
||||||
@ -663,9 +617,9 @@ func (s *SyncSuite) TestFailsWithDockerSourceNotExisting(c *check.C) {
|
|||||||
|
|
||||||
func (s *SyncSuite) TestFailsWithDirSourceNotExisting(c *check.C) {
|
func (s *SyncSuite) TestFailsWithDirSourceNotExisting(c *check.C) {
|
||||||
// Make sure the dir does not exist!
|
// Make sure the dir does not exist!
|
||||||
tmpDir, err := ioutil.TempDir("", "skopeo-sync-test")
|
tmpDir := c.MkDir()
|
||||||
c.Assert(err, check.IsNil)
|
tmpDir = filepath.Join(tmpDir, "this-does-not-exist")
|
||||||
err = os.RemoveAll(tmpDir)
|
err := os.RemoveAll(tmpDir)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
_, err = os.Stat(path.Join(tmpDir))
|
_, err = os.Stat(path.Join(tmpDir))
|
||||||
c.Check(os.IsNotExist(err), check.Equals, true)
|
c.Check(os.IsNotExist(err), check.Equals, true)
|
||||||
|
Loading…
Reference in New Issue
Block a user