Exemplo n.º 1
0
    def pull_image(self, image, remote_image_obj, **kwargs):
        assert (isinstance(remote_image_obj, Image))
        debug = kwargs.get('debug', False)
        if image.startswith("dockertar:"):
            path = image.replace("dockertar:", "", 1)
            with open(path, 'rb') as f:
                self.d.load_image(data=f)
            return 0
        fq_name = remote_image_obj.fq_name
        local_image = self.has_image(image)
        if local_image is not None:
            if self.already_has_image(local_image, remote_image_obj):
                raise ValueError(
                    "Latest version of {} already present.".format(image))
        registry, _, _, tag, _ = util.Decompose(fq_name).all
        image = "docker-daemon:{}".format(fq_name)
        if not image.endswith(tag):
            image += ":{}".format(tag)
        if '@sha256:' in image:
            image = image.replace("@sha256:", ":")

        insecure = True if util.is_insecure_registry(
            self.d.info()['RegistryConfig'],
            util.strip_port(registry)) else False
        trust = Trust()
        trust.discover_sigstore(fq_name)
        util.write_out("Pulling {} ...".format(fq_name))
        util.skopeo_copy("docker://{}".format(fq_name),
                         image,
                         debug=debug,
                         insecure=insecure,
                         policy_filename=trust.policy_filename)
        return 0
Exemplo n.º 2
0
 def pull_image(self, image, **kwargs):
     debug = kwargs.get("debug", False)
     if image.startswith("dockertar:"):
         path = image.replace("dockertar:", "", 1)
         with open(path, "rb") as f:
             self.d.load_image(data=f)
         return 0
     remote_image = self.make_remote_image(image)
     fq_name = remote_image.fq_name
     local_image = self.has_image(image)
     if local_image is not None:
         if self.already_has_image(local_image, remote_image):
             raise ValueError("Latest version of {} already present.".format(image))
     registry, _, _, tag, _ = util.Decompose(fq_name).all
     image = "docker-daemon:{}".format(image)
     if not image.endswith(tag):
         image += ":{}".format(tag)
     insecure = (
         True if util.is_insecure_registry(self.d.info()["RegistryConfig"], util.strip_port(registry)) else False
     )
     trust = Trust()
     trust.discover_sigstore(fq_name)
     util.write_out("Pulling {} ...".format(fq_name))
     util.skopeo_copy(
         "docker://{}".format(fq_name), image, debug=debug, insecure=insecure, policy_filename=trust.policy_filename
     )
     return 0
Exemplo n.º 3
0
 def update(self, name, force=False):
     img_obj = self.inspect_image(name)
     if force:
         self.delete_containers_by_image(img_obj)
     registry = util.Decompose(img_obj.fq_name).registry
     return util.skopeo_copy(
         "docker://{}".format(name),
         "docker-daemon:{}".format(img_obj.fq_name),
         util.is_insecure_registry(self.d.info()['RegistryConfig'],
                                   util.strip_port(registry)))
Exemplo n.º 4
0
    def pull_image(self, image, pull_args):
        # Add this when atomic registry is incorporated.
        # if self.args.reg_type == "atomic":
        #     pull_uri = 'atomic:'
        # else:
        #     pull_uri = 'docker://'
        img_obj = self._make_remote_image(image)
        fq_name = img_obj.fq_name
        insecure = True if util.is_insecure_registry(
            self.d.info()['RegistryConfig'], util.strip_port(
                img_obj.registry)) else False

        # This needs to be re-enabled with Aaron's help
        trust = Trust()
        trust.set_args(pull_args)
        trust.discover_sigstore(fq_name)

        util.write_out("Pulling {} ...".format(fq_name))
        util.skopeo_copy("docker://{}".format(fq_name),
                         "docker-daemon:{}".format(image),
                         debug=pull_args.debug,
                         insecure=insecure,
                         policy_filename=pull_args.policy_filename)
Exemplo n.º 5
0
 def update(self, name, force=False):
     img_obj = self.inspect_image(name)
     if force:
         self.delete_containers_by_image(img_obj)
     registry = util.Decompose(img_obj.fq_name).registry
     return util.skopeo_copy("docker://{}".format(name),
                             "docker-daemon:{}".format(img_obj.fq_name),
                             util.is_insecure_registry(self.d.info()['RegistryConfig'], util.strip_port(registry)))
Exemplo n.º 6
0
    def pull_image(self, image, pull_args):
        # Add this when atomic registry is incorporated.
        # if self.args.reg_type == "atomic":
        #     pull_uri = 'atomic:'
        # else:
        #     pull_uri = 'docker://'
        img_obj = self._make_remote_image(image)
        fq_name = img_obj.fq_name
        insecure = True if util.is_insecure_registry(self.d.info()['RegistryConfig'], util.strip_port(img_obj.registry)) else False

        # This needs to be re-enabled with Aaron's help
        trust = Trust()
        trust.set_args(pull_args)
        trust.discover_sigstore(fq_name)

        util.write_out("Pulling {} ...".format(fq_name))
        util.skopeo_copy("docker://{}".format(fq_name),
                         "docker-daemon:{}".format(image),
                         debug=pull_args.debug, insecure=insecure,
                         policy_filename=pull_args.policy_filename)