-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyaml.go
53 lines (41 loc) · 978 Bytes
/
yaml.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package keycloak
import (
"io/ioutil"
k8syaml "sigs.k8s.io/yaml"
)
func newYAMLStore(bites []byte) (*yamlStore, error) {
jsonBites, err := k8syaml.YAMLToJSONStrict(bites)
if err != nil {
return nil, err
}
js, err := newJSONStore(jsonBites)
if err != nil {
return nil, err
}
return &yamlStore{
js: js,
}, nil
}
type yamlStore struct {
js *jsonStore
}
func (s *yamlStore) EncryptSubtree(recipient string, path ...string) error {
return s.js.EncryptSubtree(recipient, path...)
}
func (s *yamlStore) DecryptSubtree(identity string, path ...string) error {
return s.js.DecryptSubtree(identity, path...)
}
func (s *yamlStore) Subtree(path ...string) (map[string]interface{}, error) {
return s.js.Subtree(path...)
}
func (s *yamlStore) ToFile(path string) error {
bites, err := s.js.bytes()
if err != nil {
return err
}
yamlBites, err := k8syaml.JSONToYAML(bites)
if err != nil {
return err
}
return ioutil.WriteFile(path, yamlBites, 0600)
}