示例#1
0
 def _build_config_files_list(self):
     self.config_files = [
         # Stakkr default config
         get_file('static', 'config_default.yml'),
         '{}/services/*/config_default.yml'.format(self.project_dir)]
     # Stakkr main config file finally with user's values
     self.config_files += [self.config_file]
示例#2
0
def _recipe_get_config(recipe: str):
    """Get recipe"""
    if recipe is None:
        return ''

    recipe_config = file_utils.get_file('static/recipes', '{}.yml'.format(recipe))
    if os.path.isfile(recipe_config) is False:
        click.secho('"{}" recipe does not exist'.format(recipe), fg='red')
        sys.exit(1)

    return recipe_config
示例#3
0
文件: setup.py 项目: swipswaps/stakkr
def _recipe_get_config(recipe: str):
    """Get recipe"""
    if recipe is None:
        return ''

    recipe_config = file_utils.get_file('static/recipes',
                                        '{}.yml'.format(recipe))
    if os.path.isfile(recipe_config) is False:
        click.secho('"{}" recipe does not exist'.format(recipe), fg='red')
        sys.exit(1)

    return recipe_config
示例#4
0
文件: setup.py 项目: swipswaps/stakkr
def _copy_file(project_dir: str, source_file: str, force: bool):
    """Copy a file from a template to project dir"""
    full_path = file_utils.get_file('tpls', source_file)
    dest_file = project_dir + '/' + source_file
    if os.path.isfile(dest_file) and force is False:
        click.secho('  - {} exists, do not overwrite'.format(source_file))
        return

    click.secho('  - {} written'.format(source_file))
    try:
        shutil.copy(full_path, dest_file)
    except Exception:
        msg = "Error trying to copy {} .. check that the file is there ..."
        print(msg.format(full_path), file=sys.stderr)
示例#5
0
def _copy_file(project_dir: str, source_file: str, force: bool):
    """Copy a file from a template to project dir"""
    full_path = file_utils.get_file('tpls', source_file)
    dest_file = project_dir + '/' + source_file
    if os.path.isfile(dest_file) and force is False:
        click.secho('  - {} exists, do not overwrite'.format(source_file))
        return

    click.secho('  - {} written'.format(source_file))
    try:
        shutil.copy(full_path, dest_file)
    except Exception:
        msg = "Error trying to copy {} .. check that the file is there ...".format(full_path)
        print(msg, file=sys.stderr)
示例#6
0
def _get_base_command(config: dict):
    """Build the docker-compose file to be run as a command."""
    main_file = 'docker-compose.yml'
    # Set the network subnet ?
    if config['subnet'] != '':
        main_file = 'docker-compose.subnet.yml'
    cmd = ['docker-compose', '-f', file_utils.get_file('static', main_file)]

    # What to load
    activated_services = _get_enabled_services_files(
        config['project_dir'],
        [svc for svc, opts in config['services'].items() if opts['enabled'] is True])
    # Create the command
    services = []
    for service in activated_services:
        services.append('-f')
        services.append(service)

    return cmd + services + ['-p', config['project_name']]
示例#7
0
def _get_base_command(config: dict):
    """Build the docker-compose file to be run as a command."""
    main_file = 'docker-compose.yml'
    # Set the network subnet ?
    if config['subnet'] != '':
        main_file = 'docker-compose.subnet.yml'
    cmd = ['docker-compose', '-f', file_utils.get_file('static', main_file)]

    # What to load
    activated_services = _get_enabled_services_files(config['project_dir'], [
        svc
        for svc, opts in config['services'].items() if opts['enabled'] is True
    ])
    # Create the command
    services = []
    for service in activated_services:
        services.append('-f')
        services.append(service)

    return cmd + services + ['-p', config['project_name']]
示例#8
0
 def _build_config_schemas_list(self):
     self.spec_files = [
         # Stakkr config validation
         get_file('static', 'config_schema.yml'),
         '{}/services/*/config_schema.yml'.format(self.project_dir)]