Example #1
0
    def __init__(self, user_config_fname=DEFAULT_USER_CONFIG_FNAME, project_config_fname=DEFAULT_PROJ_CONFIG_FNAME):
        self.config = DEFAULT_CONFIG

        out.print_header('Reading config')

        self.config.update(self.load_config_file(user_config_fname))
        self.config.update(self.load_config_file(project_config_fname))
Example #2
0
    def push(self, image_version):
        image_repo = self.__get_docker_image_uri()

        if image_version is None:
            image_version = self.__generate_version_tag()

        out.print_header('Pushing the updated docker image')

        full_image = image_repo + ':' + image_version

        self.cmd.docker(['tag', self.cfg.get('docker_image_name'), full_image])
        self.cmd.docker(['push', full_image])
Example #3
0
    def apply(self, image_version):
        out.print_header('Applying kubernetes provisioning')

        if image_version:
            k8s_config = '\n---\n'.join(map(lambda fname: self.__read_file(fname), self.cfg.get('kubernetes_configs')))
            k8s_config = self.__update_k8s_config(k8s_config, image_version)

            self.cmd.kubectl(['apply', '-f', '-'], input_data=k8s_config)
        else:
            args = ['apply']

            for conf in self.cfg.get('kubernetes_configs'):
                args.extend(['-f', conf])

            self.cmd.kubectl(args)
Example #4
0
    def build(self):
        if self.cfg.has('pre_build_commands'):
            out.print_header('Executing pre build steps')

            for command in self.cfg.get('pre_build_commands'):
                self.cmd.execute(command, shell=True)

        out.print_header('Building the docker image')

        args = ['build', '--pull', '-t', self.cfg.get('docker_image_name'), self.cfg.get('docker_build_dir')]

        if self.cfg.has('docker_build_args'):
            for k, v in self.cfg.get('docker_build_args').iteritems():
                args.extend(['--build-arg', '%s=%s' % (k, v)])

        self.cmd.docker(args)
Example #5
0
 def config(self):
     out.print_header('Computed configuration')
     print('  ' + '  '.join(self.cfg.dump().splitlines(True)))
Example #6
0
    def run(self):
        out.print_header('Running the docker image')

        self.cmd.docker(['run', '-i', '-t', self.cfg.get('docker_image_name')])