예제 #1
0
// Marshal takes a sops tree branch and marshals it into a yaml document
func (store Store) Marshal(tree sops.TreeBranch) ([]byte, error) {
	yamlMap := store.treeBranchToYamlMap(tree)
	out, err := yaml.Marshal(yamlMap)
	if err != nil {
		return nil, fmt.Errorf("Error marshaling to yaml: %s", err)
	}
	return out, nil
}
예제 #2
0
// MarshalWithMetadata takes a sops tree branch and metadata and marshals them into a yaml document
func (store Store) MarshalWithMetadata(tree sops.TreeBranch, metadata sops.Metadata) ([]byte, error) {
	yamlMap := store.treeBranchToYamlMap(tree)
	yamlMap = append(yamlMap, yaml.MapItem{Key: "sops", Value: metadata.ToMap()})
	out, err := yaml.Marshal(yamlMap)
	if err != nil {
		return nil, fmt.Errorf("Error marshaling to yaml: %s", err)
	}
	return out, nil
}