Пример #1
0
    def _is_build(self, image):
        try:
            if is_str_set(image.data.fields.build, "context") or is_str_set(image.data.fields.build, "remote"):
                return True
        except (KeyError, AttributeError):
            pass

        return False
Пример #2
0
    def _is_build(self, image):
        try:
            if is_str_set(image.data.fields.build, 'context') or \
                    is_str_set(image.data.fields.build, 'remote'):
                return True
        except (KeyError, AttributeError):
            pass

        return False
Пример #3
0
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ['context', 'remote']:
                if key in opts:
                    del opts[key]
            opts['stream'] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status['stream'])
                except:
                    pass

        if is_str_set(opts, 'context'):
            with closing(requests.get(opts['context'], stream=True)) as r:
                if r.status_code != 200:
                    raise Exception('Bad response {} from {}'
                                    .format(r.status_code,
                                            opts['context']))
                del opts['context']
                opts['fileobj'] = ResponseWrapper(r)
                opts['custom_context'] = True
                do_build()
        else:
            remote = opts['remote']
            if remote.startswith('[email protected]:'):
                remote = remote.replace('[email protected]:', 'git://github.com/')
            del opts['remote']
            opts['path'] = remote
            do_build()
Пример #4
0
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ['context', 'remote']:
                if key in opts:
                    del opts[key]
            opts['stream'] = True
            opts['rm'] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status['stream'])
                except:
                    pass

        if is_str_set(opts, 'context'):
            with closing(requests.get(opts['context'], stream=True)) as r:
                if r.status_code != 200:
                    raise Exception('Bad response {} from {}'.format(
                        r.status_code, opts['context']))
                del opts['context']
                opts['fileobj'] = ResponseWrapper(r)
                opts['custom_context'] = True
                do_build()
        else:
            remote = opts['remote']
            if remote.startswith('[email protected]:'):
                remote = remote.replace('[email protected]:', 'git://github.com/')
            del opts['remote']
            opts['path'] = remote
            do_build()
Пример #5
0
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ["context", "remote"]:
                if key in opts:
                    del opts[key]
            opts["stream"] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status["stream"])
                except:
                    pass

        if is_str_set(opts, "context"):
            with closing(requests.get(opts["context"], stream=True)) as r:
                if r.status_code != 200:
                    raise Exception("Bad response {} from {}".format(r.status_code, opts["context"]))
                del opts["context"]
                opts["fileobj"] = ResponseWrapper(r)
                opts["custom_context"] = True
                do_build()
        else:
            remote = opts["remote"]
            if remote.startswith("[email protected]:"):
                remote = remote.replace("[email protected]:", "git://github.com/")
            del opts["remote"]
            opts["path"] = remote
            do_build()
Пример #6
0
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ['context', 'remote']:
                if key in opts:
                    del opts[key]
            opts['stream'] = True
            opts['rm'] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status['stream'])
                except:
                    pass

        if is_str_set(opts, 'context'):
            downloaded = None
            try:
                downloaded = download_file(opts['context'], Config.builds())
                with open(downloaded) as f:
                    del opts['context']
                    opts['fileobj'] = f
                    opts['custom_context'] = True
                    do_build()
            finally:
                if downloaded is not None:
                    os.remove(downloaded)
        else:
            remote = opts['remote']
            if remote.startswith('[email protected]:'):
                remote = remote.replace('[email protected]:', 'git://github.com/')
            del opts['remote']
            opts['path'] = remote
            do_build()
Пример #7
0
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ['context', 'remote']:
                if key in opts:
                    del opts[key]
            opts['stream'] = True
            opts['rm'] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status['stream'])
                except:
                    pass

        if is_str_set(opts, 'context'):
            downloaded = None
            try:
                downloaded = download_file(opts['context'], Config.builds())
                with open(downloaded) as f:
                    del opts['context']
                    opts['fileobj'] = f
                    opts['custom_context'] = True
                    do_build()
            finally:
                if downloaded is not None:
                    os.remove(downloaded)
        else:
            remote = opts['remote']
            if remote.startswith('[email protected]:'):
                remote = remote.replace('[email protected]:', 'git://github.com/')
            del opts['remote']
            opts['path'] = remote
            do_build()