mirror of
https://github.com/projectatomic/atomic.git
synced 2026-02-06 03:45:28 +01:00
Adding the ability to decompose an input image "name" that
includes a digest. For example:
docker.io/library/fedora@sha256:64a02df6aac27d1200c2572fe4b9949f1970d05f74d367ce4af994ba5dc3669e
Also, reword the decompose method in a Decompose class. This simplifies the use of
decomposition and allows for growth.
Example usage:
registry, repo, image, tag, digest = Decompose("docker.io/library/busybox:latest").all
repo = Decompose("docker.io/library/busybox:latest").repo
digest = Decompose("docker.io/fedora@sha256:64a02df6aac27d1200c2...67ce4af994ba5dc3669e").digest
Closes: #701
Approved by: rhatdan
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
import unittest
|
|
from Atomic import util
|
|
from Atomic import discovery
|
|
|
|
|
|
class TestAtomicUtil(unittest.TestCase):
|
|
IMAGE = 'docker.io/library/busybox:latest'
|
|
I_REGISTRY, I_REPO, I_IMAGE, I_TAG, _ = util.Decompose(IMAGE).all
|
|
|
|
def test_ping(self):
|
|
ri = discovery.RegistryInspect(registry=self.I_REGISTRY,
|
|
repo=self.I_REPO,
|
|
image=self.I_IMAGE,
|
|
tag=self.I_TAG)
|
|
# No exceptions should be raised
|
|
ri.ping()
|
|
|
|
|
|
def test_find_image_on_registry(self):
|
|
fq = 'docker.io/library/busybox:latest'
|
|
for img in ['docker.io/library/busybox:latest', 'docker.io/library/busybox', 'docker.io/busybox', 'busybox']:
|
|
registry, repo, image, tag, _ = util.Decompose(img).all
|
|
ri = discovery.RegistryInspect(registry=registry, repo=repo, image=image, tag=tag)
|
|
self.assertEqual(ri.find_image_on_registry(), fq)
|
|
|
|
def test_inspect(self):
|
|
ri = discovery.RegistryInspect(registry=self.I_REGISTRY,
|
|
repo=self.I_REPO,
|
|
image=self.I_IMAGE,
|
|
tag=self.I_TAG)
|
|
inspect_info = ri.inspect()
|
|
self.assertEqual(inspect_info['Name'], "{}/{}/{}".format(self.I_REGISTRY, self.I_REPO, self.I_IMAGE))
|
|
self.assertEqual(inspect_info['Tag'], self.I_TAG)
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|