NAME

File::SOPS::Format::YAML - YAML format handler for SOPS

VERSION

version 0.001

SYNOPSIS

use File::SOPS::Format::YAML;

# Parse YAML with SOPS metadata
my ($data, $metadata) = File::SOPS::Format::YAML->parse($yaml_content);

# Serialize data with SOPS metadata
my $yaml = File::SOPS::Format::YAML->serialize(
    data     => $encrypted_data,
    metadata => $metadata_obj,
);

# Check if filename is YAML
if (File::SOPS::Format::YAML->detect('secrets.yaml')) {
    # It's a YAML file
}

DESCRIPTION

YAML format handler for File::SOPS. Handles parsing and serialization of SOPS-encrypted YAML files.

Uses YAML::XS for fast, spec-compliant YAML processing. Boolean values are represented using JSON::PP for consistency.

parse

my ($data, $metadata) = File::SOPS::Format::YAML->parse($yaml_string);

Class method to parse a YAML string.

Returns a two-element list:

1. $data - HashRef of the data (without the sops section)
2. $metadata - File::SOPS::Metadata object, or undef if no sops section

Dies if the YAML is invalid or doesn't parse to a HashRef.

serialize

my $yaml = File::SOPS::Format::YAML->serialize(
    data     => \%data,
    metadata => $metadata_obj,
);

Class method to serialize data and metadata to YAML.

The data parameter must be a HashRef. The metadata parameter must be a File::SOPS::Metadata object.

Returns a YAML string with the sops section appended.

format_name

Returns 'yaml'.

file_extensions

Returns a list of file extensions: ('yaml', 'yml').

detect

if (File::SOPS::Format::YAML->detect($filename)) {
    # File is YAML based on extension
}

Class method to detect if a filename is YAML based on extension.

Returns true if filename ends with .yaml or .yml (case-insensitive).

SEE ALSO

SUPPORT

IRC

You can reach Getty on irc.perl.org for questions and support.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.