コード例 #1
0
def create_wrapper_config_obj(config_dir, wrapper_file=None):
    """
    Given a config dir containing a tf_wrapper.
    Parses the tf_wrapper for dependencies and makes a a wrapper config object.
    :param config_dir: A tf directory containing a tf_wrapper.
    :param wrapper_file: A wrapper file passed in if known
    :return: wrapper_config_obj: a wrapper config object
    """
    if not wrapper_file:
        for file in os.listdir(config_dir):
            if file.endswith(".tf_wrapper"):
                wrapper_file = os.path.join(config_dir, file)

    wrapper_config_obj: WrapperConfig = parse_wrapper_configs([wrapper_file])
    if wrapper_config_obj.depends_on:
        depends_on = []
        for dependency in wrapper_config_obj.depends_on:
            abs_dependency = get_absolute_path(dependency)
            if not os.path.isdir(abs_dependency):
                abs_dependency = get_absolute_path(dependency, config_dir)
            depends_on.append(abs_dependency)
        wrapper_config_obj.depends_on = depends_on
    if not is_config_directory(config_dir):
        wrapper_config_obj.config = False
    return wrapper_config_obj
コード例 #2
0
 def __init__(self, path: str, variables: List[str]):
     """
     :param path: The path to the Terraform configuration files to execute.
     :param variables: Any additional variables to set alongside the Terraform command.
     """
     self.path = get_absolute_path(path=path)
     wrapper_config_files = find_wrapper_config_files(self.path)
     wrapper_config = parse_wrapper_configs(wrapper_config_files)
     self.envvars = resolve_envvars(wrapper_config.envvars)
     self.variables = variables