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]
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
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)
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)
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']]
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']]
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)]