@@ -52,34 +52,85 @@ func ResolveContext(_ context.Context, meta schema.ClientMeta, r *schema.Resourc
5252 return r .Set (c .Name , client .Context )
5353}
5454
55- // In k8s, IP Addresses may sometimes be empty-strings - but postgresql doesn't like that.
56- // So, the resolver for ip-addresses should recognize that case and not set null instead.
55+ // In k8s, IP Addresses may sometimes be empty-strings or `None` - but postgresql doesn't like that.
56+ // So, the resolver for ip-addresses should recognize that case and set null instead.
5757func StringToInetPathResolver (path string ) schema.ColumnResolver {
5858 return func (_ context.Context , meta schema.ClientMeta , r * schema.Resource , c schema.Column ) error {
5959 value := funk .Get (r .Item , path , funk .WithAllowZero ())
6060
6161 stringValue , ok := value .(string )
62- if ok && stringValue != "" {
62+ if ok && stringValue != "" && stringValue != "None" {
6363 return r .Set (c .Name , value )
6464 }
65+
6566 return r .Set (c .Name , nil )
6667 }
6768}
6869
69- // In k8s, IP Addresses may sometimes be empty-strings - but postgresql doesn't like that.
70- // So, the resolver for ip-addresses should recognize that case and not set null instead.
70+ // In k8s, IP Addresses may sometimes be empty-strings or `None` - but postgresql doesn't like that.
71+ // So, the resolver for ip-addresses should recognize that case and set null instead.
72+ func StringToInetArrayPathResolver (path string ) schema.ColumnResolver {
73+ return func (_ context.Context , meta schema.ClientMeta , r * schema.Resource , c schema.Column ) error {
74+ value := funk .Get (r .Item , path , funk .WithAllowZero ())
75+
76+ stringArrayValue , ok := value .([]string )
77+ if ! ok {
78+ return r .Set (c .Name , nil )
79+ }
80+
81+ sanitized := []* string {}
82+
83+ for i := range stringArrayValue {
84+ if stringArrayValue [i ] != "" && stringArrayValue [i ] != "None" {
85+ sanitized = append (sanitized , & stringArrayValue [i ])
86+ } else {
87+ sanitized = append (sanitized , nil )
88+ }
89+ }
90+
91+ return r .Set (c .Name , sanitized )
92+ }
93+ }
94+
95+ // In k8s, IP Addresses may sometimes be empty-strings or `None` - but postgresql doesn't like that.
96+ // So, the resolver for ip-addresses should recognize that case and set null instead.
7197func StringToCidrPathResolver (path string ) schema.ColumnResolver {
7298 return func (_ context.Context , meta schema.ClientMeta , r * schema.Resource , c schema.Column ) error {
7399 value := funk .Get (r .Item , path , funk .WithAllowZero ())
74100
75101 stringValue , ok := value .(string )
76- if ok && stringValue != "" {
102+ if ok && stringValue != "" && stringValue != "None" {
77103 return r .Set (c .Name , value )
78104 }
79105 return r .Set (c .Name , nil )
80106 }
81107}
82108
109+ // In k8s, IP Addresses may sometimes be empty-strings or `None` - but postgresql doesn't like that.
110+ // So, the resolver for ip-addresses should recognize that case and set null instead.
111+ func StringToCidrArrayPathResolver (path string ) schema.ColumnResolver {
112+ return func (_ context.Context , meta schema.ClientMeta , r * schema.Resource , c schema.Column ) error {
113+ value := funk .Get (r .Item , path , funk .WithAllowZero ())
114+
115+ stringArrayValue , ok := value .([]string )
116+ if ! ok {
117+ return r .Set (c .Name , nil )
118+ }
119+
120+ sanitized := []* string {}
121+
122+ for i := range stringArrayValue {
123+ if stringArrayValue [i ] != "" && stringArrayValue [i ] != "None" {
124+ sanitized = append (sanitized , & stringArrayValue [i ])
125+ } else {
126+ sanitized = append (sanitized , nil )
127+ }
128+ }
129+
130+ return r .Set (c .Name , sanitized )
131+ }
132+ }
133+
83134// isK8sTimeStruct returns true if the given type is a metav1.Time struct or a pointer to it.
84135func isK8sTimeStruct (fieldType reflect.Type ) bool {
85136 fieldKind := fieldType .Kind ()
0 commit comments