11package kusto
22
33import (
4+ "encoding/json"
45 "errors"
56 "fmt"
67 "os"
78 "regexp"
89 "strings"
910
10- yaml "gopkg.in /yaml.v3 "
11+ "sigs.k8s.io /yaml"
1112)
1213
1314const (
@@ -28,50 +29,50 @@ const (
2829
2930type (
3031 Config struct {
31- Queries []ConfigQuery `yaml :"queries"`
32+ Queries []ConfigQuery `json :"queries"`
3233 }
3334
3435 ConfigQuery struct {
35- MetricConfig ConfigQueryMetric `yaml:",inline"`
36- QueryMode string `yaml :"queryMode"`
37- Workspaces * []string `yaml :"workspaces"`
38- Metric string `yaml :"metric"`
39- Module string `yaml :"module"`
40- Query string `yaml :"query"`
41- Timespan * string `yaml :"timespan"`
42- Subscriptions * []string `yaml :"subscriptions"`
36+ * ConfigQueryMetric
37+ QueryMode string `json :"queryMode"`
38+ Workspaces * []string `json :"workspaces"`
39+ Metric string `json :"metric"`
40+ Module string `json :"module"`
41+ Query string `json :"query"`
42+ Timespan * string `json :"timespan"`
43+ Subscriptions * []string `json :"subscriptions"`
4344 }
4445
4546 ConfigQueryMetric struct {
46- Value * float64 `yaml :"value"`
47- Fields []ConfigQueryMetricField `yaml :"fields"`
48- Labels map [string ]string `yaml :"labels"`
49- DefaultField ConfigQueryMetricField `yaml :"defaultField"`
50- Publish * bool `yaml :"publish"`
47+ Value * float64 `json :"value"`
48+ Fields []ConfigQueryMetricField `json :"fields"`
49+ Labels map [string ]string `json :"labels"`
50+ DefaultField ConfigQueryMetricField `json :"defaultField"`
51+ Publish * bool `json :"publish"`
5152 }
5253
5354 ConfigQueryMetricField struct {
54- Name string `yaml :"name"`
55- Metric string `yaml :"metric"`
56- Source string `yaml :"source"`
57- Target string `yaml :"target"`
58- Type string `yaml :"type"`
59- Labels map [string ]string `yaml :"labels"`
60- Filters []ConfigQueryMetricFieldFilter `yaml :"filters"`
61- Expand * ConfigQueryMetric `yaml :"expand"`
55+ Name string `json :"name"`
56+ Metric string `json :"metric"`
57+ Source string `json :"source"`
58+ Target string `json :"target"`
59+ Type string `json :"type"`
60+ Labels map [string ]string `json :"labels"`
61+ Filters []ConfigQueryMetricFieldFilter `json :"filters"`
62+ Expand * ConfigQueryMetric `json :"expand"`
6263 }
6364
6465 ConfigQueryMetricFieldFilter struct {
65- Type string `yaml :"type"`
66- RegExp string `yaml :"regexp"`
67- Replacement string `yaml :"replacement"`
66+ Type string `json :"type"`
67+ RegExp string `json :"regexp"`
68+ Replacement string `json :"replacement"`
6869 parsedRegexp * regexp.Regexp
6970 }
7071
7172 ConfigQueryMetricFieldFilterParser struct {
72- Type string `yaml :"type"`
73- RegExp string `yaml :"regexp"`
74- Replacement string `yaml :"replacement"`
73+ Type string `json :"type"`
74+ RegExp string `json :"regexp"`
75+ Replacement string `json :"replacement"`
7576 }
7677)
7778
@@ -90,7 +91,7 @@ func (c *Config) Validate() error {
9091}
9192
9293func (c * ConfigQuery ) Validate () error {
93- if err := c .MetricConfig .Validate (); err != nil {
94+ if err := c .ConfigQueryMetric .Validate (); err != nil {
9495 return err
9596 }
9697
@@ -297,12 +298,12 @@ func (f *ConfigQueryMetricField) TransformBool(value bool) (ret string) {
297298 return
298299}
299300
300- func (f * ConfigQueryMetricFieldFilter ) UnmarshalYAML ( unmarshal func ( interface {}) error ) error {
301+ func (f * ConfigQueryMetricFieldFilter ) UnmarshalJSON ( c [] byte ) error {
301302 var multi ConfigQueryMetricFieldFilterParser
302- err := unmarshal ( & multi )
303+ err := json . Unmarshal ( c , & multi )
303304 if err != nil {
304305 var single string
305- err := unmarshal ( & single )
306+ err := json . Unmarshal ( c , & single )
306307 if err != nil {
307308 return err
308309 }
0 commit comments