-
Notifications
You must be signed in to change notification settings - Fork 807
/
service_variable.go
679 lines (583 loc) · 19.5 KB
/
service_variable.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
/*
Copyright 2023 The KodeRover Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package types
import (
"bytes"
"fmt"
"gopkg.in/yaml.v3"
"k8s.io/apimachinery/pkg/util/sets"
)
type ServiceVariableKVType string
const (
ServiceVariableKVTypeBoolean ServiceVariableKVType = "bool"
ServiceVariableKVTypeString ServiceVariableKVType = "string"
ServiceVariableKVTypeEnum ServiceVariableKVType = "enum"
ServiceVariableKVTypeYaml ServiceVariableKVType = "yaml"
)
// This kv will aggregate complicated struct to the first layer of key
type ServiceVariableKV struct {
Key string `bson:"key" yaml:"key" json:"key"`
Value interface{} `bson:"value" yaml:"value" json:"value"`
Type ServiceVariableKVType `bson:"type" yaml:"type" json:"type"`
Options []string `bson:"options" yaml:"options" json:"options"`
Desc string `bson:"desc" yaml:"desc" json:"desc"`
}
type RenderVariableKV struct {
ServiceVariableKV `bson:",inline" yaml:",inline" json:",inline"`
UseGlobalVariable bool `bson:"use_global_variable" yaml:"use_global_variable" json:"use_global_variable"`
}
type GlobalVariableKV struct {
ServiceVariableKV `bson:",inline" yaml:",inline" json:",inline"`
RelatedServices []string `bson:"related_services" yaml:"related_services" json:"related_services"`
}
// yaml spec document: https://yaml.org/spec/1.2.2/
func convertValueToNode(data interface{}) *yaml.Node {
node := &yaml.Node{}
if dataMap, ok := data.(map[string]interface{}); ok {
node.Kind = yaml.MappingNode
for key, value := range dataMap {
childKey := &yaml.Node{
Kind: yaml.ScalarNode,
Value: key,
}
node.Content = append(node.Content, childKey)
childValue := convertValueToNode(value)
node.Content = append(node.Content, childValue)
}
} else if dataSlice, ok := data.([]interface{}); ok {
node.Kind = yaml.SequenceNode
for _, value := range dataSlice {
child := convertValueToNode(value)
node.Content = append(node.Content, child)
}
} else {
node.Kind = yaml.ScalarNode
node.Value = fmt.Sprintf("%v", data)
}
return node
}
func addValueToNode(key string, data interface{}, node *yaml.Node) *yaml.Node {
keyNode := &yaml.Node{
Kind: yaml.ScalarNode,
Value: key,
}
node.Content = append(node.Content, keyNode)
switch data.(type) {
case *yaml.Node:
valueNode := data.(*yaml.Node)
if valueNode.Kind == yaml.DocumentNode {
node.Content = append(node.Content, valueNode.Content...)
} else {
if valueNode.Kind != yaml.DocumentNode &&
valueNode.Kind != yaml.SequenceNode &&
valueNode.Kind != yaml.MappingNode &&
valueNode.Kind != yaml.ScalarNode &&
valueNode.Kind != yaml.AliasNode {
valueNode.Kind = yaml.ScalarNode
}
node.Content = append(node.Content, valueNode)
}
default:
valueChild := convertValueToNode(data)
node.Content = append(node.Content, valueChild)
}
return node
}
// inorder to preserve the order of the yaml, we need to use yaml.node to marshal and unmarshal yaml
func marshalYamlNode(node *yaml.Node) (string, error) {
buf := bytes.Buffer{}
enc := yaml.NewEncoder(&buf)
enc.SetIndent(2)
err := enc.Encode(node)
if err != nil {
return "", fmt.Errorf("failed to marshal node yaml, err: %w", err)
}
return buf.String(), nil
}
// not suitable for flatten kv
// ServiceVariableKV is a kv which aggregate complicated struct to the first layer
func ServiceVariableKVToYaml(kvs []*ServiceVariableKV) (string, error) {
node := &yaml.Node{
Kind: yaml.MappingNode,
}
for _, kv := range kvs {
if kv == nil {
continue
}
switch kv.Type {
case ServiceVariableKVTypeYaml:
value, ok := kv.Value.(string)
if !ok {
return "", fmt.Errorf("failed to convert value to yaml, key: %v, value: %v", kv.Key, kv.Value)
}
valueNode := &yaml.Node{}
err := yaml.Unmarshal([]byte(value), valueNode)
if err != nil {
return "", fmt.Errorf("failed to unmarshal yaml, key: %v, err: %w", kv.Key, err)
}
node = addValueToNode(kv.Key, valueNode, node)
case ServiceVariableKVTypeBoolean:
v, ok := kv.Value.(bool)
if ok {
node = addValueToNode(kv.Key, v, node)
} else if kv.Value == "true" {
node = addValueToNode(kv.Key, true, node)
} else if kv.Value == "false" {
node = addValueToNode(kv.Key, false, node)
} else {
return "", fmt.Errorf("invaild value for boolean, key: %v, value: %v", kv.Key, kv.Value)
}
case ServiceVariableKVTypeEnum:
v := fmt.Sprintf("%v", kv.Value)
if !sets.NewString(kv.Options...).Has(v) {
return "", fmt.Errorf("invaild value for enum, key: %v, value: %v, options: %v", kv.Key, kv.Value, kv.Options)
}
node = addValueToNode(kv.Key, kv.Value, node)
default:
node = addValueToNode(kv.Key, kv.Value, node)
}
}
return marshalYamlNode(node)
}
// not suitable for flatten kv
// ServiceVariableKV is a kv which aggregate complicated struct to the first layer
func YamlToServiceVariableKV(yamlStr string, origKVs []*ServiceVariableKV) ([]*ServiceVariableKV, error) {
if yamlStr == "null" || yamlStr == "null\n" {
return nil, nil
}
node := &yaml.Node{}
err := yaml.Unmarshal([]byte(yamlStr), node)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal yaml, err: %w", err)
}
origKVMap := make(map[string]*ServiceVariableKV, 0)
for _, kv := range origKVs {
origKVMap[kv.Key] = kv
}
ret := make([]*ServiceVariableKV, 0)
if node != nil && node.Content != nil {
if node.Kind != yaml.DocumentNode {
return nil, fmt.Errorf("root node is not docment node")
}
for _, root := range node.Content {
if root.Kind == yaml.MappingNode {
for i := 0; i < len(root.Content); i += 2 {
key := root.Content[i].Value
value := root.Content[i+1]
kv, err := snippetToKV(key, value, origKVMap[key])
if err != nil {
return nil, fmt.Errorf("failed to convert snippet to kv, err: %w", err)
}
ret = append(ret, kv)
}
} else {
return nil, fmt.Errorf("root node is not mapping node")
}
}
}
return ret, nil
}
// FIXME: ServiceVariableKVType not equal with golang runtime type
func snippetToKV(key string, snippet *yaml.Node, origKV *ServiceVariableKV) (*ServiceVariableKV, error) {
var retKV *ServiceVariableKV
if origKV == nil {
// origKV is nil, create a new kv
retKV = &ServiceVariableKV{
Key: key,
}
switch snippet.Kind {
case yaml.ScalarNode:
retKV.Type = ServiceVariableKVTypeString
retKV.Value = snippet.Value
case yaml.MappingNode:
retKV.Type = ServiceVariableKVTypeYaml
snippetYaml, err := marshalYamlNode(snippet)
if err != nil {
return nil, fmt.Errorf("key %s: failed to marshal snippet, err: %w", retKV.Key, err)
}
retKV.Type = ServiceVariableKVTypeYaml
retKV.Value = snippetYaml
case yaml.SequenceNode:
retKV.Type = ServiceVariableKVTypeYaml
snippetYaml, err := marshalYamlNode(snippet)
if err != nil {
return nil, fmt.Errorf("key %s: failed to marshal snippet, err: %w", retKV.Key, err)
}
retKV.Type = ServiceVariableKVTypeYaml
retKV.Value = snippetYaml
default:
if snippet.Value == "true" || snippet.Value == "false" {
retKV.Type = ServiceVariableKVTypeBoolean
} else {
retKV.Type = ServiceVariableKVTypeString
}
retKV.Value = snippet.Value
}
} else {
// origKV is not nil, inherit type, options, and desc from it
retKV = &ServiceVariableKV{
Key: origKV.Key,
Value: origKV.Value,
Type: origKV.Type,
Options: origKV.Options,
Desc: origKV.Desc,
}
// validate key
if key != retKV.Key {
return nil, fmt.Errorf("key not match, key: %s, orig key: %s", key, origKV.Key)
}
// validate value match type
switch retKV.Type {
case ServiceVariableKVTypeBoolean:
// check if value valid for boolean
value := snippet.Value
if value != "true" && value != "false" {
return nil, fmt.Errorf("key %s: invalid value: %s for boolean", retKV.Key, snippet.Value)
}
case ServiceVariableKVTypeEnum:
// check if value exist in options
optionSet := sets.NewString(origKV.Options...)
if !optionSet.Has(snippet.Value) {
return nil, fmt.Errorf("key %s: invalid value: %v, valid options: %v", retKV.Key, snippet.Value, origKV.Options)
}
}
// convert snippet to value
if retKV.Type == ServiceVariableKVTypeYaml {
snippetYaml, err := marshalYamlNode(snippet)
if err != nil {
return nil, fmt.Errorf("key %s: failed to marshal snippet, err: %w", retKV.Key, err)
}
retKV.Value = snippetYaml
} else {
switch snippet.Kind {
case yaml.MappingNode, yaml.SequenceNode:
snippetYaml, err := marshalYamlNode(snippet)
if err != nil {
return nil, fmt.Errorf("key %s: failed to marshal snippet, err: %w", retKV.Key, err)
}
retKV.Value = snippetYaml
default:
retKV.Value = snippet.Value
}
}
}
return retKV, nil
}
func transferServiceVariable(render, template *ServiceVariableKV) *ServiceVariableKV {
if render == nil {
return template
}
if template == nil {
return render
}
ret := &ServiceVariableKV{}
if render.Type != template.Type {
ret = template
} else {
ret = template
ret.Value = render.Value
}
return ret
}
func MergeServiceVariableKVsIfNotExist(kvsList ...[]*ServiceVariableKV) (string, []*ServiceVariableKV, error) {
kvSet := sets.NewString()
ret := make([]*ServiceVariableKV, 0)
for _, kvs := range kvsList {
for _, kv := range kvs {
if !kvSet.Has(kv.Key) {
kvSet.Insert(kv.Key)
ret = append(ret, kv)
}
}
}
yaml, err := ServiceVariableKVToYaml(ret)
if err != nil {
return "", nil, fmt.Errorf("failed to convert service variable kv to yaml, err: %w", err)
}
return yaml, ret, nil
}
func MergeServiceVariableKVs(kvsList ...[]*ServiceVariableKV) (string, []*ServiceVariableKV, error) {
kvMap := map[string]*ServiceVariableKV{}
for _, kvs := range kvsList {
for _, kv := range kvs {
kvMap[kv.Key] = kv
}
}
ret := []*ServiceVariableKV{}
for _, kv := range kvMap {
ret = append(ret, kv)
}
yaml, err := ServiceVariableKVToYaml(ret)
if err != nil {
return "", nil, fmt.Errorf("failed to convert service variable kv to yaml, err: %w", err)
}
return yaml, ret, nil
}
func MergeRenderVariableKVs(kvsList ...[]*RenderVariableKV) (string, []*RenderVariableKV, error) {
kvMap := map[string]*RenderVariableKV{}
for _, kvs := range kvsList {
for _, kv := range kvs {
kvMap[kv.Key] = kv
}
}
ret := []*RenderVariableKV{}
for _, kv := range kvMap {
ret = append(ret, kv)
}
yaml, err := RenderVariableKVToYaml(ret)
if err != nil {
return "", nil, fmt.Errorf("failed to convert render variable kv to yaml, err: %w", err)
}
return yaml, ret, nil
}
// merge render variables base on service template variables
// render variables has higher value priority, service template variables has higher type priority
// normally used to get latest variables for a service
func MergeRenderAndServiceTemplateVariableKVs(render []*RenderVariableKV, serivceTemplate []*ServiceVariableKV) (string, []*RenderVariableKV, error) {
renderMap := map[string]*RenderVariableKV{}
for _, kv := range render {
renderMap[kv.Key] = kv
}
ret := []*RenderVariableKV{}
for _, kv := range serivceTemplate {
if renderKV, ok := renderMap[kv.Key]; !ok {
ret = append(ret, &RenderVariableKV{
ServiceVariableKV: *kv,
UseGlobalVariable: false,
})
} else {
if renderKV.UseGlobalVariable {
ret = append(ret, renderKV)
} else {
newKV := transferServiceVariable(&renderKV.ServiceVariableKV, kv)
transferedKV := &RenderVariableKV{
ServiceVariableKV: *newKV,
UseGlobalVariable: false,
}
ret = append(ret, transferedKV)
}
}
}
yaml, err := RenderVariableKVToYaml(ret)
if err != nil {
return "", nil, fmt.Errorf("failed to convert render variable kv to yaml, err: %w", err)
}
return yaml, ret, nil
}
// RenderVariableKVToYaml
func RenderVariableKVToYaml(kvs []*RenderVariableKV) (string, error) {
serviceVariableKVs := make([]*ServiceVariableKV, 0)
for _, kv := range kvs {
serviceVariableKVs = append(serviceVariableKVs, &kv.ServiceVariableKV)
}
return ServiceVariableKVToYaml(serviceVariableKVs)
}
func GlobalVariableKVToYaml(kvs []*GlobalVariableKV) (string, error) {
serviceVariableKVs := make([]*ServiceVariableKV, 0)
for _, kv := range kvs {
serviceVariableKVs = append(serviceVariableKVs, &kv.ServiceVariableKV)
}
return ServiceVariableKVToYaml(serviceVariableKVs)
}
// validate global variables base on global variables define
func ValidateGlobalVariables(globalVariablesDefine []*ServiceVariableKV, globalVariables []*GlobalVariableKV) bool {
globalVariableMap := map[string]*ServiceVariableKV{}
for _, kv := range globalVariablesDefine {
globalVariableMap[kv.Key] = kv
}
for _, kv := range globalVariables {
if _, ok := globalVariableMap[kv.Key]; !ok {
return false
}
}
return true
}
func ValidateRenderVariables(globalVariables []*GlobalVariableKV, renderVariables []*RenderVariableKV) error {
globalVariableMap := map[string]*GlobalVariableKV{}
for _, kv := range globalVariables {
globalVariableMap[kv.Key] = kv
}
for _, kv := range renderVariables {
if kv.UseGlobalVariable {
globalVariable, ok := globalVariableMap[kv.Key]
if !ok {
return fmt.Errorf("referenced global variable not exist, key: %s", kv.Key)
}
kv.Value = globalVariable.Value
kv.Type = globalVariable.Type
kv.Options = globalVariable.Options
kv.Desc = globalVariable.Desc
}
}
return nil
}
func ServiceToRenderVariableKVs(ServiceVariables []*ServiceVariableKV) []*RenderVariableKV {
ret := []*RenderVariableKV{}
for _, kv := range ServiceVariables {
ret = append(ret, &RenderVariableKV{
ServiceVariableKV: *kv,
UseGlobalVariable: false,
})
}
return ret
}
func RemoveGlobalVariableRelatedService(globalVariableKVs []*GlobalVariableKV, serviceNames ...string) []*GlobalVariableKV {
for _, kv := range globalVariableKVs {
relatedServiceSet := sets.NewString(kv.RelatedServices...)
relatedServiceSet = relatedServiceSet.Delete(serviceNames...)
kv.RelatedServices = relatedServiceSet.List()
}
return globalVariableKVs
}
// update global variable's related serivces and render variables value base on useGlobalVariable flag
func UpdateGlobalVariableKVs(serviceName string, globalVariables []*GlobalVariableKV, argVariables, currentVariables []*RenderVariableKV) ([]*GlobalVariableKV, []*RenderVariableKV, error) {
globalVariableMap := map[string]*GlobalVariableKV{}
for _, kv := range globalVariables {
globalVariableMap[kv.Key] = kv
}
argVariableMap := map[string]*RenderVariableKV{}
for _, kv := range argVariables {
argVariableMap[kv.Key] = kv
}
renderVariableMap := map[string]*RenderVariableKV{}
for _, kv := range currentVariables {
renderVariableMap[kv.Key] = kv
}
addRelatedServices := func(globalVariableKV *GlobalVariableKV, serviceName string) {
relatedSvcSet := sets.NewString(globalVariableKV.RelatedServices...)
relatedSvcSet.Insert(serviceName)
globalVariableKV.RelatedServices = relatedSvcSet.List()
}
delRelatedServices := func(globalVariableKV *GlobalVariableKV, serviceName string) {
relatedSvcSet := sets.NewString(globalVariableKV.RelatedServices...)
relatedSvcSet.Delete(serviceName)
globalVariableKV.RelatedServices = relatedSvcSet.List()
}
updateRenderVariable := func(globalVariableKV *GlobalVariableKV, renderVariableKV *RenderVariableKV) {
renderVariableKV.Value = globalVariableKV.Value
renderVariableKV.Type = globalVariableKV.Type
renderVariableKV.Options = globalVariableKV.Options
renderVariableKV.Desc = globalVariableKV.Desc
}
// check render vairaible diff
for _, argKV := range argVariableMap {
globalVariableKV, ok := globalVariableMap[argKV.Key]
if !ok && argKV.UseGlobalVariable {
// global variable not exist, but arg use global variable
return nil, nil, fmt.Errorf("global variable not exist, but used by serviceName: %s, key: %s", serviceName, argKV.Key)
}
renderKV, ok := renderVariableMap[argKV.Key]
if !ok {
// render variable not exist, newly added variable
if argKV.UseGlobalVariable {
// arg use global variable
addRelatedServices(globalVariableKV, serviceName)
updateRenderVariable(globalVariableKV, argKV)
}
} else {
// render variable exist
if argKV.UseGlobalVariable && !renderKV.UseGlobalVariable {
addRelatedServices(globalVariableKV, serviceName)
updateRenderVariable(globalVariableKV, argKV)
} else if !argKV.UseGlobalVariable && renderKV.UseGlobalVariable {
delRelatedServices(globalVariableKV, serviceName)
}
// delete from render when this kv is checked
delete(renderVariableMap, argKV.Key)
}
}
// deleted variable
for _, renderKV := range renderVariableMap {
globalVariableKV, ok := globalVariableMap[renderKV.Key]
if !ok && renderKV.UseGlobalVariable {
// global variable not exist, but render use global variable
return nil, nil, fmt.Errorf("global variable not exist, but used by serviceName: %s, key: %s", serviceName, renderKV.Key)
}
if renderKV.UseGlobalVariable {
delRelatedServices(globalVariableKV, serviceName)
}
}
retGlobalVariables := []*GlobalVariableKV{}
for _, kv := range globalVariableMap {
retGlobalVariables = append(retGlobalVariables, kv)
}
return retGlobalVariables, argVariables, nil
}
// update render variables base on global variables and useGlobalVariable flag
func UpdateRenderVariable(global []*GlobalVariableKV, render []*RenderVariableKV) []*RenderVariableKV {
globalMap := map[string]*GlobalVariableKV{}
for _, kv := range global {
globalMap[kv.Key] = kv
}
ret := []*RenderVariableKV{}
for _, kv := range render {
if globalKV, ok := globalMap[kv.Key]; ok {
if kv.UseGlobalVariable {
retKV := &RenderVariableKV{
ServiceVariableKV: ServiceVariableKV{
Key: globalKV.Key,
Value: globalKV.Value,
Type: globalKV.Type,
Options: globalKV.Options,
Desc: globalKV.Desc,
},
UseGlobalVariable: true,
}
ret = append(ret, retKV)
} else {
ret = append(ret, kv)
}
} else {
ret = append(ret, kv)
}
}
return ret
}
func ClipRenderVariableKVs(template []*ServiceVariableKV, render []*RenderVariableKV) (yaml string, kvs []*RenderVariableKV, err error) {
templateSet := sets.NewString()
for _, kv := range template {
templateSet.Insert(kv.Key)
}
ret := []*RenderVariableKV{}
for _, kv := range render {
if templateSet.Has(kv.Key) {
ret = append(ret, kv)
}
}
yaml, err = RenderVariableKVToYaml(ret)
if err != nil {
return "", nil, fmt.Errorf("failed to convert render variable kv to yaml, err: %w", err)
}
return yaml, ret, nil
}
func ClipServiceVariableKVs(clipRange []*ServiceVariableKV, kvs []*ServiceVariableKV) (string, []*ServiceVariableKV, error) {
clipRangeSet := sets.NewString()
for _, kv := range clipRange {
clipRangeSet.Insert(kv.Key)
}
ret := []*ServiceVariableKV{}
for _, kv := range kvs {
if clipRangeSet.Has(kv.Key) {
ret = append(ret, kv)
}
}
yaml, err := ServiceVariableKVToYaml(ret)
if err != nil {
return "", nil, fmt.Errorf("failed to convert service variable kv to yaml, err: %w", err)
}
return yaml, ret, nil
}
type GlobalVariables struct {
Variables []*ServiceVariableKV `json:"variables"`
ProductionVariables []*ServiceVariableKV `json:"production_variables"`
}