Ejemplo n.º 1
0
// MarshalWithMetadata takes a sops tree branch and sops metadata and marshals them to json.
func (store Store) MarshalWithMetadata(tree sops.TreeBranch, metadata sops.Metadata) ([]byte, error) {
	tree = append(tree, sops.TreeItem{Key: "sops", Value: metadata.ToMap()})
	out, err := store.jsonFromTreeBranch(tree)
	if err != nil {
		return nil, fmt.Errorf("Error marshaling to json: %s", err)
	}
	return out, nil
}
Ejemplo n.º 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.YAMLMarshaler{Indent: 4}).Marshal(yamlMap)
	if err != nil {
		return nil, fmt.Errorf("Error marshaling to yaml: %s", err)
	}
	return out, nil
}