Load

The load operators allows you to load in content from another file.

Note that you can use string operators like + and sub to modify the value in the yaml file to a path that exists in your system.

You can load files of the following supported types:

Format
Load Operator

Yaml

load

XML

load_xml

Properties

load_props

Plain String

load_str

Base64

load_base64

Note that load_base64 only works for base64 encoded utf-8 strings.

Samples files for tests:

yaml

../../examples/thing.yml:

a: apple is included
b: cool

xml

small.xml:

properties

small.properties:

base64

base64.txt:

Disabling file operators

If required, you can use the --security-disable-file-ops to disable file operations.

Simple example

Given a sample.yml file of:

then

will output

Replace node with referenced file

Note that you can modify the filename in the load operator if needed.

Given a sample.yml file of:

then

will output

Replace all nodes with referenced file

Recursively match all the nodes (..) and then filter the ones that have a 'file' attribute.

Given a sample.yml file of:

then

will output

Replace node with referenced file as string

This will work for any text based file

Given a sample.yml file of:

then

will output

Load from XML

Given a sample.yml file of:

then

will output

Load from Properties

Given a sample.yml file of:

then

will output

Merge from properties

This can be used as a convenient way to update a yaml document

Given a sample.yml file of:

then

will output

Load from base64 encoded file

Given a sample.yml file of:

then

will output

load() operation fails when security is enabled

Use --security-disable-file-ops to disable file operations for security.

Running

will output

load_str() operation fails when security is enabled

Use --security-disable-file-ops to disable file operations for security.

Running

will output

load_xml() operation fails when security is enabled

Use --security-disable-file-ops to disable file operations for security.

Running

will output

load_props() operation fails when security is enabled

Use --security-disable-file-ops to disable file operations for security.

Running

will output

load_base64() operation fails when security is enabled

Use --security-disable-file-ops to disable file operations for security.

Running

will output

Last updated

Was this helpful?