class HierarchicalConfigGenerator(object): def __init__(self): self.config_processor = ConfigProcessor() def generate_config(self, config_path, filters=(), exclude_keys=(), enclosing_key=None, output_format="yaml", print_data=False, output_file=None): cmd = self.get_sh_command(config_path, filters, exclude_keys, enclosing_key, output_format, print_data, output_file) display(cmd, color="yellow") return self.config_processor.process(path=config_path, filters=filters, exclude_keys=exclude_keys, enclosing_key=enclosing_key, output_format=output_format, output_file=output_file, print_data=print_data) @staticmethod def get_sh_command(config_path, filters=(), exclude_keys=(), enclosing_key=None, output_format="yaml", print_data=False, output_file=None): command = "ops {} config --format {}".format( config_path, output_format) for filter in filters: command += " --filter {}".format(filter) for exclude in exclude_keys: command += " --exclude {}".format(exclude) if enclosing_key: command += " --enclosing-key {}".format(enclosing_key) if output_file: command += " --output-file {}".format(output_file) if print_data: command += " --print-data" return command
def __init__(self): self.config_processor = ConfigProcessor()
class HierarchicalConfigGenerator(): def __init__(self): self.config_processor = ConfigProcessor() def generate_config( self, config_path, filters=(), exclude_keys=(), enclosing_key=None, remove_enclosing_key=None, output_format="yaml", print_data=False, output_file=None, skip_interpolation_resolving=False, skip_interpolation_validation=False, skip_secrets=False ): cmd = self.get_sh_command( config_path, filters, exclude_keys, enclosing_key, remove_enclosing_key, output_format, print_data, output_file, skip_interpolation_resolving, skip_interpolation_validation, skip_secrets ) display(cmd, color="yellow") return self.config_processor.process( path=config_path, filters=filters, exclude_keys=exclude_keys, enclosing_key=enclosing_key, remove_enclosing_key=remove_enclosing_key, output_format=output_format, output_file=output_file, print_data=print_data, skip_interpolations=skip_interpolation_resolving, skip_interpolation_validation=skip_interpolation_validation, skip_secrets=skip_secrets ) @staticmethod def get_sh_command( config_path, filters=(), exclude_keys=(), enclosing_key=None, remove_enclosing_key=None, output_format="yaml", print_data=False, output_file=None, skip_interpolation_resolving=False, skip_interpolation_validation=False, skip_secrets=False ): command = "kompos {} config --format {}".format( config_path, output_format) for filter in filters: command += " --filter {}".format(filter) for exclude in exclude_keys: command += " --exclude {}".format(exclude) if enclosing_key: command += " --enclosing-key {}".format(enclosing_key) if remove_enclosing_key: command += " --remove-enclosing-key {}".format(remove_enclosing_key) if output_file: command += " --output-file {}".format(output_file) if print_data: command += " --print-data" if skip_interpolation_resolving: command += " --skip-interpolation-resolving" if skip_interpolation_validation: command += " --skip-interpolation-validation" if skip_secrets: command += " --skip-secrets" return command