1
1
package config
2
2
3
3
import (
4
+ "encoding/json"
4
5
"fmt"
5
6
"regexp"
6
7
"strings"
@@ -14,38 +15,38 @@ import (
14
15
15
16
type (
16
17
Config struct {
17
- Pools []PoolConfig `yaml :"pools"`
18
+ Pools []PoolConfig `json :"pools"`
18
19
}
19
20
20
21
PoolConfig struct {
21
- Name string `yaml :"pool"`
22
- Continue bool `yaml :"continue"`
23
- Selector []PoolConfigSelector `yaml :"selector"`
24
- Node PoolConfigNode `yaml :"node"`
22
+ Name string `json :"pool"`
23
+ Continue bool `json :"continue"`
24
+ Selector []PoolConfigSelector `json :"selector"`
25
+ Node PoolConfigNode `json :"node"`
25
26
}
26
27
27
28
PoolConfigSelector struct {
28
- Path string `yaml :"path"`
29
+ Path string `json :"path"`
29
30
jsonPath * jsonpath.JSONPath
30
- Match * string `yaml :"match"`
31
- Regexp * string `yaml :"regexp"`
31
+ Match * string `json :"match"`
32
+ Regexp * string `json :"regexp"`
32
33
regexp * regexp.Regexp
33
34
}
34
35
35
36
PoolConfigNode struct {
36
- Roles PoolConfigNodeValueMap `yaml :"roles"`
37
- JsonPatches []k8s.JsonPatchObject `yaml :"jsonPatches"`
38
- ConfigSource * PoolConfigNodeConfigSource `yaml :"configSource"`
39
- Labels PoolConfigNodeValueMap `yaml :"labels"`
40
- Annotations PoolConfigNodeValueMap `yaml :"annotations"`
37
+ Roles PoolConfigNodeValueMap `json :"roles"`
38
+ JsonPatches []k8s.JsonPatchObject `json :"jsonPatches"`
39
+ ConfigSource * PoolConfigNodeConfigSource `json :"configSource"`
40
+ Labels PoolConfigNodeValueMap `json :"labels"`
41
+ Annotations PoolConfigNodeValueMap `json :"annotations"`
41
42
}
42
43
43
44
PoolConfigNodeConfigSource struct {
44
45
ConfigMap struct {
45
- Name string `yaml:"name" json:"name"`
46
- Namespace string `yaml:"namespace" json:"namespace"`
47
- KubeletConfigKey string `yaml:"kubeletConfigKey" json:"kubeletConfigKey"`
48
- } `yaml:"configMap" json:"configMap"`
46
+ Name string `json:"name"`
47
+ Namespace string `json:"namespace"`
48
+ KubeletConfigKey string `json:"kubeletConfigKey"`
49
+ } `json:"configMap"`
49
50
}
50
51
51
52
PoolConfigNodeValueMap struct {
@@ -63,12 +64,12 @@ func (valueMap *PoolConfigNodeValueMap) Entries() map[string]*string {
63
64
return mapList
64
65
}
65
66
66
- func (valueMap * PoolConfigNodeValueMap ) UnmarshalYAML ( unmarshal func ( interface {}) error ) error {
67
+ func (valueMap * PoolConfigNodeValueMap ) UnmarshalJSON ( b [] byte ) error {
67
68
mapList := map [string ]* string {}
68
- err := unmarshal ( & mapList )
69
+ err := json . Unmarshal ( b , & mapList )
69
70
if err != nil {
70
71
var stringList []string
71
- err := unmarshal ( & stringList )
72
+ err := json . Unmarshal ( b , & stringList )
72
73
if err != nil {
73
74
return err
74
75
}
0 commit comments