From 44f445e2d4b99b32615cdc623e436e6e5f6b5da7 Mon Sep 17 00:00:00 2001 From: Adrian Utrilla Date: Mon, 21 Aug 2017 15:55:33 -0700 Subject: [PATCH] Fix YAML comments in lists --- yaml/store.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/yaml/store.go b/yaml/store.go index 4eb6e2edb..36102efe5 100644 --- a/yaml/store.go +++ b/yaml/store.go @@ -82,6 +82,8 @@ func (store Store) treeValueToYamlValue(in interface{}) interface{} { switch in := in.(type) { case sops.TreeBranch: return store.treeBranchToYamlMap(in) + case sops.Comment: + return yaml.Comment{in.Value} case []interface{}: var out []interface{} for _, v := range in { @@ -98,7 +100,7 @@ func (store Store) treeBranchToYamlMap(in sops.TreeBranch) yaml.MapSlice { for _, item := range in { if comment, ok := item.Key.(sops.Comment); ok { branch = append(branch, yaml.MapItem{ - Key: yaml.Comment{Value: comment.Value}, + Key: store.treeValueToYamlValue(comment), Value: nil, }) } else { @@ -138,7 +140,6 @@ func (store Store) MarshalValue(v interface{}) ([]byte, error) { return (&yaml.YAMLMarshaler{Indent: 4}).Marshal(v) } - // UnmarshalMetadata takes a yaml document as a string and extracts sops' metadata from it func (store *Store) UnmarshalMetadata(in []byte) (sops.Metadata, error) { var ok bool @@ -157,4 +158,4 @@ func (store *Store) UnmarshalMetadata(in []byte) (sops.Metadata, error) { metadataBranch[key] = v } return sops.MapToMetadata(metadataBranch) -} \ No newline at end of file +}