Beispiel #1
0
    def set_content(self, kwargs, content=None):
        """
        Method to initialize the compose content

        :param dict kwargs:
        :param dict content:
        :return:
        """
        if content is None and len(kwargs[self.input_file_arg]) == 1:
            self.compose_content = load_composex_file(kwargs[self.input_file_arg][0])
        elif content is None and len(kwargs[self.input_file_arg]) > 1:
            files_list = kwargs[self.input_file_arg]
            self.compose_content = load_composex_file(files_list[0])
            files_list.pop(0)
            for file in files_list:
                merge_config_file(self.compose_content, load_composex_file(file))
                LOG.debug(yaml.dump(self.compose_content))

        elif content and isinstance(content, dict):
            self.compose_content = content
        if keyisset("services", self.compose_content):
            render_services_ports(self.compose_content["services"])
        LOG.debug(yaml.dump(self.compose_content))
        interpolate_env_vars(self.compose_content)
        parse_secrets(self)
Beispiel #2
0
def test_rds_resource_type(here):
    """
    Function to test resource type
    """
    cluster_file_path = f"{here}/../../use-cases/rds/resource_sorting/cluster.yml"
    instance_file_path = f"{here}/../../use-cases/rds/resource_sorting/instance.yml"

    cluster_props = load_composex_file(cluster_file_path)["Properties"]
    instance_props = load_composex_file(instance_file_path)["Properties"]

    c_type = determine_resource_type("dummy", cluster_props)
    i_type = determine_resource_type("dummy", instance_props)
    assert c_type is DBCluster
    assert i_type is DBInstance
Beispiel #3
0
def main():
    parser = main_parser()
    args = parser.parse_args()

    kwargs = vars(args)
    content = load_composex_file(kwargs[XFILE_DEST])
    validate_vpc_input(vars(args))
    validate_cluster_input(vars(args))

    print("Arguments: " + str(args._))
    templates_and_params = generate_full_template(content, **kwargs)

    render_final_template(templates_and_params[0])
    cfn_config = build_config_template_file(config={},
                                            parameters=templates_and_params[1])
    if keyisset("CfnConfigFile", vars(args)):
        config_file_name = args.CfnConfigFile
    else:
        config_file_name = f"{args.output_file.split('.')[0]}.config.json"
    config_file = FileArtifact(config_file_name,
                               content=cfn_config,
                               **vars(args))
    params_file = FileArtifact(
        f"{args.output_file.split('.')[0]}.params.json",
        content=templates_and_params[1],
        **vars(args),
    )
    template_file = FileArtifact(args.output_file,
                                 template=templates_and_params[0],
                                 **vars(args))
    template_file.create()
    params_file.create()
    config_file.create()
Beispiel #4
0
def get_secrets_content():
    here = path.abspath(path.dirname(__file__))
    content = load_composex_file(f"{here}/../../use-cases/blog.features.yml")
    return deepcopy(content)
Beispiel #5
0
def content():
    here = path.abspath(path.dirname(__file__))
    return load_composex_file(f"{here}/../use-cases/blog.yml")