зеркало из https://github.com/getsops/sops.git
support ordered YAML maps
This commit is contained in:
Родитель
69f767776b
Коммит
cce9602d5e
7
main.go
7
main.go
|
@ -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)
|
||||
}
|
||||
|
|
10
sops/data.go
10
sops/data.go
|
@ -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
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче