...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package krmtotf
16
17 import (
18 "strings"
19
20 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/k8s"
21 "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/text"
22 )
23
24 func MutableButUnreadableFieldsAnnotationFor(r *Resource) (string, error) {
25 paths := getMutableButUnreadablePaths(r)
26 return k8s.GenerateMutableButUnreadableFieldsAnnotation(&r.Resource, paths)
27 }
28
29
30
31
32 func getMutableButUnreadablePaths(r *Resource) [][]string {
33 tfFields := r.ResourceConfig.MutableButUnreadableFields
34 lowerCamelCasePaths := make([][]string, 0)
35 for _, tfField := range tfFields {
36 tfPath := strings.Split(tfField, ".")
37 lowerCamelCasePaths = append(lowerCamelCasePaths, text.SnakeCaseStrsToLowerCamelCaseStrs(tfPath))
38 }
39 return lowerCamelCasePaths
40 }
41
42 func getMutableButUnreadableFieldsFromAnnotations(r *Resource) (map[string]interface{}, error) {
43 paths := getMutableButUnreadablePaths(r)
44 return k8s.GetMutableButUnreadableFieldsFromAnnotations(&r.Resource, paths)
45 }
46
View as plain text