Skip to content

Add method to load multi-yaml document #331

@joaocc

Description

@joaocc

Describe the Feature

When processing k8s yaml files, it's very common that these have multi-document yaml files.
At the moment there are not many general and well supported ways of getting these files into HCL-land.
Since the deep_merge method is also one of the only ways to do a common yaml operation in HCL, I would like to kindly suggest that a method to parse multi-document YAMLs into a list of individual YAMLs (ie, into list(str)).

Expected Behavior

parsing a YAML file (str) into a list of YAMLs (list(str))
if file is already single document, a list with only 1 string will be returned.

Use Case

Processing of k8s manifest files (and flux2 files, and ...)

Describe Ideal Solution

parsing a YAML file (str) into a list of YAMLs (list(str))
if file is already single document, a list with only 1 string will be returned.

Alternatives Considered

There is currently something similar in alekc/kubectl (from gavinbunney/kubectl) in the form of kubectl_file_documents and kubectl_path_documents, but this is not generic YAML.
A discussion on adding similar capabilities to terraform here hashicorp/terraform#29729

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions