diff --git a/core/src/epicli/cli/engine/PatchEngine.py b/core/src/epicli/cli/engine/PatchEngine.py index e1b893bb8f..de1583548b 100644 --- a/core/src/epicli/cli/engine/PatchEngine.py +++ b/core/src/epicli/cli/engine/PatchEngine.py @@ -23,13 +23,13 @@ class PatchEngine(Step): def __init__(self, input_data): super().__init__(__name__) self.file = input_data.file + self.build_directory = input_data.build_directory # can be None self.parsed_components = None if input_data.components is None else set(input_data.components) self.component_dict = dict() self.input_docs = list() self.cluster_model = None self.backup_doc = None self.recovery_doc = None - self.build_directory = None self.ansible_command = AnsibleCommand() def __enter__(self): @@ -67,11 +67,16 @@ def _process_input_docs(self): # Get recovery config document self.recovery_doc = select_single(self.input_docs, lambda x: x.kind == 'configuration/recovery') - # Derive the build directory path - self.build_directory = get_build_path(self.cluster_model.specification.name) + if self.build_directory is None: + # Derive the build directory path (if not provided) + self.build_directory = get_build_path(self.cluster_model.specification.name) + + if not os.path.exists(self.build_directory): + raise Exception('Provided build directory path does not exist') def _process_component_config(self, document): if self.parsed_components is not None: + # Overwrite enable/disable settings from yaml config available_components = set(document.specification.components.keys()) self.component_dict = components_to_dict(self.parsed_components, available_components) diff --git a/core/src/epicli/cli/epicli.py b/core/src/epicli/cli/epicli.py index 8918ba44d3..52084d72fb 100644 --- a/core/src/epicli/cli/epicli.py +++ b/core/src/epicli/cli/epicli.py @@ -268,8 +268,11 @@ def backup_parser(subparsers): sub_parser = subparsers.add_parser('backup', description='Create backup of cluster components.') - sub_parser.add_argument('-f', '--file', dest='file', type=str, + sub_parser.add_argument('-f', '--file', dest='file', type=str, required=True, help='File with infrastructure/configuration definitions to use.') + sub_parser.add_argument('-b', '--build', dest='build_directory', type=str, required=False, + help='Absolute path to directory with build artifacts.', + default=None) available_components = {'kubernetes', 'load_balancer', 'logging', 'monitoring', 'postgresql', 'rabbitmq'} @@ -290,8 +293,11 @@ def recovery_parser(subparsers): sub_parser = subparsers.add_parser('recovery', description='Recover from existing backup.') - sub_parser.add_argument('-f', '--file', dest='file', type=str, + sub_parser.add_argument('-f', '--file', dest='file', type=str, required=True, help='File with infrastructure/configuration definitions to use.') + sub_parser.add_argument('-b', '--build', dest='build_directory', type=str, required=False, + help='Absolute path to directory with build artifacts.', + default=None) available_components = {'kubernetes', 'load_balancer', 'logging', 'monitoring', 'postgresql', 'rabbitmq'}