Documentation
¶
Overview ¶
Package stores acts as a layer between the internal representation of encrypted files and the encrypted files themselves.
Subpackages implement serialization and deserialization to multiple formats.
This package defines the structure SOPS files should have and conversions to and from the internal representation. Part of the purpose of this package is to make it easy to change the SOPS file format while remaining backwards-compatible.
Index ¶
- Constants
- Variables
- func ExtractMetadata(branches sops.TreeBranches, opts MetadataOpts) (sops.TreeBranches, sops.Metadata, error)
- func HasSopsTopLevelKey(branch sops.TreeBranch) bool
- func IsComplexValue(v interface{}) bool
- func SerializeMetadata(data sops.Tree, opts MetadataOpts) (sops.TreeBranches, error)
- func ValToString(v interface{}) string
- type MetadataFlatten
- type MetadataOpts
Constants ¶
const (
// SopsMetadataKey is the key used to store SOPS metadata at in SOPS encrypted files.
SopsMetadataKey = "sops"
)
const SopsPrefix = SopsMetadataKey + "_"
SopsPrefix is the prefix for all metadata entry keys.
Variables ¶
var ExampleComplexTree = sops.Tree{ Branches: sops.TreeBranches{ sops.TreeBranch{ sops.TreeItem{ Key: "hello", Value: `Welcome to SOPS! Edit this file as you please!`, }, sops.TreeItem{ Key: "example_key", Value: "example_value", }, sops.TreeItem{ Key: sops.Comment{Value: " Example comment"}, Value: nil, }, sops.TreeItem{ Key: "example_array", Value: []interface{}{ "example_value1", "example_value2", }, }, sops.TreeItem{ Key: "example_number", Value: 1234.56789, }, sops.TreeItem{ Key: "example_booleans", Value: []interface{}{true, false}, }, }, }, }
ExampleComplexTree is an example sops.Tree object exhibiting complex relationships
var ExampleFlatTree = sops.Tree{ Branches: sops.TreeBranches{ sops.TreeBranch{ sops.TreeItem{ Key: sops.Comment{Value: " This is an example file."}, Value: nil, }, sops.TreeItem{ Key: "hello", Value: "Welcome to SOPS! Edit this file as you please!", }, sops.TreeItem{ Key: "example_key", Value: "example_value", }, sops.TreeItem{ Key: "example_multiline", Value: "foo\nbar\nbaz", }, }, }, }
ExampleFlatTree is an example sops.Tree object exhibiting only simple relationships with no nested branches and only simple string values
var ExampleSimpleTree = sops.Tree{ Branches: sops.TreeBranches{ sops.TreeBranch{ sops.TreeItem{ Key: "Welcome!", Value: sops.TreeBranch{ sops.TreeItem{ Key: sops.Comment{Value: " This is an example file."}, Value: nil, }, sops.TreeItem{ Key: "hello", Value: "Welcome to SOPS! Edit this file as you please!", }, sops.TreeItem{ Key: "example_key", Value: "example_value", }, }, }, }, }, }
ExampleSimpleTree is an example sops.Tree object exhibiting only simple relationships with only one nested branch and only simple string values
Functions ¶
func ExtractMetadata ¶ added in v3.13.0
func ExtractMetadata(branches sops.TreeBranches, opts MetadataOpts) (sops.TreeBranches, sops.Metadata, error)
ExtractMetadata extracts SOPS metadata from the supplied tree branches.
func HasSopsTopLevelKey ¶ added in v3.9.0
func HasSopsTopLevelKey(branch sops.TreeBranch) bool
HasSopsTopLevelKey returns true if the given branch has a top-level key called "sops".
func IsComplexValue ¶ added in v3.11.0
func IsComplexValue(v interface{}) bool
IsComplexValue returns true if the given value is an array or dictionary/hash.
func SerializeMetadata ¶ added in v3.13.0
func SerializeMetadata(data sops.Tree, opts MetadataOpts) (sops.TreeBranches, error)
SerializeMetadata embeds the metadata of `data` into its tree branches.
func ValToString ¶ added in v3.11.0
func ValToString(v interface{}) string
ValToString converts a simple value to a string. It does not handle complex values (arrays and mappings).
Types ¶
type MetadataFlatten ¶ added in v3.13.0
type MetadataFlatten int
MetadataFlatten is an enum type
const ( // MetadataFlattenNone keeps the metadata under a single nested `sops` // key in the first tree branch. MetadataFlattenNone MetadataFlatten = iota // MetadataFlattenBelowTop keeps the metadata under a top-level `sops` // key in the first tree branch, with its values flattened beneath it. MetadataFlattenBelowTop // MetadataFlattenFull flattens the metadata fully into the first tree // branch, prefixing each key with `SopsPrefix`. MetadataFlattenFull )
type MetadataOpts ¶ added in v3.13.0
type MetadataOpts struct {
Flatten MetadataFlatten
}