How to use the colin.utils.cont.ImageName function in colin

To help you get started, we’ve selected a few colin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github user-cont / colin / tests / unit / test_image_name.py View on Github external
def test_image_class_name_tag(string_input, name_result, tag_result):
    image_name = ImageName.parse(string_input)
    assert image_name.name == name_result
    assert image_name.tag == tag_result
github user-cont / colin / tests / unit / test_image_name.py View on Github external
def test_image_class(string_input, image_result):
    image_name = ImageName.parse(string_input)
    registry, namespace, repository, tag, digest = image_result
    assert image_name.registry == registry
    assert image_name.namespace == namespace
    assert image_name.repository == repository
    assert image_name.tag == tag
    assert image_name.digest == digest
github user-cont / colin / colin / utils / cont.py View on Github external
#        moved to conu; I just wanted to prototype it over here and once proven working
        #        figure out how to move it to conu
        skopeo_extra_args = []
        if self.iz_dockertar:
            skopeo_source = "docker-archive:" + self.image_name
            self.ref_image_name = os.path.splitext(os.path.basename(self.image_name))[0]
        elif self.iz_ostree:
            skopeo_source = None
            if self.image_name.startswith("ostree:"):
                self.image_name = self.image_name[7:]
            try:
                self.ref_image_name, self._ostree_path = self.image_name.split("@", 1)
            except ValueError:
                raise RuntimeError("Invalid ostree target: should be 'image@path'.")
        else:
            image_name = ImageName.parse(self.image_name)
            # atomic is confused when the image lives in multiple storages, or what
            self.ref_image_name = 'colin-' + image_name.repository
            if self.pull:
                skopeo_source = "docker://" + image_name.name
                if self.insecure:
                    skopeo_extra_args.append("--src-tls-verify=false")
            else:
                skopeo_source = "docker-daemon:" + image_name.name

        skopeo_target = "ostree:%s@%s" % (self.ref_image_name, self.ostree_path)
        if skopeo_source:
            cmd = ["skopeo", "copy"] + skopeo_extra_args + [skopeo_source, skopeo_target]
            run_and_log(cmd, None,
                        "Failed to pull selected container image. Does it exist?")

        cmd = ["skopeo", "inspect", skopeo_target]
github user-cont / colin / colin / checks / dockerfile.py View on Github external
def check(self, target):
        if not target.instance.parent_images:
            raise ColinException("Cannot find FROM instruction.")

        im = ImageName.parse(target.instance.baseimage)
        passed = im.tag and im.tag != "latest"
        return CheckResult(ok=passed,
                           description=self.description,
                           message=self.message,
                           reference_url=self.reference_url,
                           check_name=self.name,
                           logs=[])
github user-cont / colin / colin / core / target.py View on Github external
def __init__(self, target, pull, parent_target=None, insecure=False, **_):
        super().__init__()
        logger.debug("Target is an image.")
        self.pull = pull
        self.insecure = insecure
        self.image_name_obj = ImageName.parse(target)
        self.target_name = self.image_name_obj.name
        self.parent_target = parent_target

        self._config_metadata = None
        self._mount_point = None
        self._mounted_container_id = None
        self.image_id = None

        self._try_image()