...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package label
16
17 import (
18 "strings"
19 )
20
21 func NewGcpFromK8sLabels(labels map[string]string) map[string]string {
22 res := RemoveLabelsWithKRMPrefix(labels)
23 res[CnrmManagedKey] = "true"
24 return res
25 }
26
27 func RemoveLabelsWithKRMPrefix(labels map[string]string) map[string]string {
28 res := make(map[string]string)
29 for k, v := range labels {
30 if len(strings.Split(k, "/")) == 2 {
31
32
33
34 continue
35 }
36 res[k] = v
37 }
38 return res
39 }
40
41 func NewGCPLabelsFromK8SLabels(labelMaps ...map[string]string) map[string]interface{} {
42 res := make(map[string]interface{})
43 for _, labels := range labelMaps {
44 if labels != nil {
45 for k, v := range labels {
46 if len(strings.Split(k, "/")) == 2 {
47
48
49
50 continue
51 }
52 res[k] = v
53 }
54 }
55 }
56 return res
57 }
58
59 func GetDefaultLabels() map[string]string {
60 return map[string]string{
61 CnrmManagedKey: "true",
62 }
63 }
64
View as plain text