def get_stack_or_stack_group(ctx, path): """ Parses the path to generate relevant Stack Group and Stack object. :param ctx: Cli context. :type ctx: click.Context :param path: Path to either stack config or stack_group folder. :type path: str """ stack = None stack_group = None config_reader = ConfigReader(ctx.obj["sceptre_dir"], ctx.obj["user_variables"]) if os.path.splitext(path)[1]: stack = config_reader.construct_stack(path) else: # <<<<<<< HEAD # # env = config_reader.construct_environment(path) # ======= # stack_group = config_reader.construct_stack_group(path) # >>>>>>> cfb45a0c7c9e4567f765d4ee4c7dbfe05ebfa0b9 stack_group = config_reader.construct_stack_group(path) return (stack, stack_group)
def test_construct_stack_group_with_valid_config(self, filepaths, targets, results): with self.runner.isolated_filesystem(): sceptre_dir = os.path.abspath('./example') config_dir = os.path.join(sceptre_dir, "config") os.makedirs(config_dir) for rel_path in filepaths: abs_path = os.path.join(config_dir, rel_path) dir_path = abs_path if abs_path.endswith(".yaml"): dir_path = os.path.split(abs_path)[0] if not os.path.exists(dir_path): try: os.makedirs(dir_path) except OSError as exc: if exc.errno != errno.EEXIST: raise config = { "region": "region", "project_code": "project_code", "template_path": rel_path } with open(abs_path, 'w') as config_file: yaml.safe_dump(config, stream=config_file, default_flow_style=False) config_reader = ConfigReader(sceptre_dir) def check_stack_group(stack_group, details): assert sorted(details["stacks"]) == sorted( [stack.name for stack in stack_group.stacks]) for sub_group in stack_group.sub_stack_groups: sub_group_details =\ details["stack_groups"][sub_group.path] check_stack_group(sub_group, sub_group_details) for i, target in enumerate(targets): stack_group =\ config_reader.construct_stack_group(target) expected = results[i] check_stack_group(stack_group, expected[stack_group.path])
def get_stack_or_stack_group(ctx, path): """ Parses the path to generate relevant Stack Group and Stack object. :param ctx: Cli context. :type ctx: click.Context :param path: Path to either stack config or stack_group folder. :type path: str """ stack = None stack_group = None config_reader = ConfigReader(ctx.obj["sceptre_dir"], ctx.obj["user_variables"]) if os.path.splitext(path)[1]: stack = config_reader.construct_stack(path) else: stack_group = config_reader.construct_stack_group(path) return (stack, stack_group)