This commit is contained in:
Jeremiah Orem 2016-05-27 11:50:52 -07:00
Родитель 69f767776b
Коммит cce9602d5e
2 изменённых файлов: 14 добавлений и 3 удалений

Просмотреть файл

@ -29,7 +29,6 @@ func main() {
}
encYamlMap := make(map[interface{}]interface{})
decYamlMap := make(map[interface{}]interface{})
err = yaml.Unmarshal(fileBytes, encYamlMap)
if err != nil {
log.Fatal(err)
@ -45,9 +44,11 @@ func main() {
log.Fatal(err)
}
decYamlMap = sopsData.DecryptMap(encYamlMap, "")
orderedMap := make(yaml.MapSlice, 0)
err = yaml.Unmarshal(fileBytes, &orderedMap)
out, err := yaml.Marshal(decYamlMap)
decOrderedMap := sopsData.DecryptMapSlice(orderedMap, "")
out, err := yaml.Marshal(decOrderedMap)
if err != nil {
log.Fatal(err)
}

Просмотреть файл

@ -182,6 +182,8 @@ func (s *Data) DecryptValue(in, key interface{}, accKey string) interface{} {
return s.DecryptString(in, accKey)
case map[interface{}]interface{}:
return s.DecryptMap(in, accKey)
case yaml.MapSlice:
return s.DecryptMapSlice(in, accKey)
case []interface{}:
return s.DecryptSlice(in, accKey)
default:
@ -208,3 +210,11 @@ func (s *Data) DecryptSlice(in []interface{}, accKey string) []interface{} {
}
return list
}
func (s *Data) DecryptMapSlice(in yaml.MapSlice, accKey string) yaml.MapSlice {
out := make(yaml.MapSlice, len(in))
for i, v := range in {
out[i] = yaml.MapItem{v.Key, s.DecryptValue(v.Value, v.Key, accKey)}
}
return out
}