From 5ca5a700d95b17f109b4e7304b7aea9d224cd246 Mon Sep 17 00:00:00 2001 From: Travis Raines Date: Fri, 5 Feb 2021 16:32:44 -0800 Subject: [PATCH] feat: use json.Number instead of float64s Convert the Upstream health threshold and Target createdat values from float64 to json.Number Use of float64 prevents controller-gen from automatically generating maifests from these types: https://github.com/kubernetes-sigs/controller-tools/issues/245 --- kong/types.go | 30 +++++++++++++++--------------- kong/zz_generated.deepcopy.go | 10 +++++++--- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/kong/types.go b/kong/types.go index 8e393a24c..14b3acd5e 100644 --- a/kong/types.go +++ b/kong/types.go @@ -157,7 +157,7 @@ type PassiveHealthcheck struct { type Healthcheck struct { Active *ActiveHealthcheck `json:"active,omitempty" yaml:"active,omitempty"` Passive *PassiveHealthcheck `json:"passive,omitempty" yaml:"passive,omitempty"` - Threshold *float64 `json:"threshold,omitempty" yaml:"threshold,omitempty"` + Threshold *json.Number `json:"threshold,omitempty" yaml:"threshold,omitempty"` } // HealthDataAddress represents the health data address of a target @@ -191,14 +191,14 @@ type HealthData struct { // UpstreamNodeHealth represents the node health of a upstream // +k8s:deepcopy-gen=true type UpstreamNodeHealth struct { - ID *string `json:"id,omitempty" yaml:"id,omitempty"` - CreatedAt *float64 `json:"created_at,omitempty" yaml:"created_at,omitempty"` - Data *HealthData `json:"data,omitempty" yaml:"data,omitempty"` - Health *string `json:"health,omitempty" yaml:"data,omitempty"` - Target *string `json:"target,omitempty" yaml:"target,omitempty"` - Upstream *Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"` - Weight *int `json:"weight,omitempty" yaml:"weight,omitempty"` - Tags []*string `json:"tags,omitempty" yaml:"tags,omitempty"` + ID *string `json:"id,omitempty" yaml:"id,omitempty"` + CreatedAt *json.Number `json:"created_at,omitempty" yaml:"created_at,omitempty"` + Data *HealthData `json:"data,omitempty" yaml:"data,omitempty"` + Health *string `json:"health,omitempty" yaml:"data,omitempty"` + Target *string `json:"target,omitempty" yaml:"target,omitempty"` + Upstream *Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"` + Weight *int `json:"weight,omitempty" yaml:"weight,omitempty"` + Tags []*string `json:"tags,omitempty" yaml:"tags,omitempty"` } // Upstream represents an Upstream in Kong. @@ -224,12 +224,12 @@ type Upstream struct { // Target represents a Target in Kong. // +k8s:deepcopy-gen=true type Target struct { - CreatedAt *float64 `json:"created_at,omitempty" yaml:"created_at,omitempty"` - ID *string `json:"id,omitempty" yaml:"id,omitempty"` - Target *string `json:"target,omitempty" yaml:"target,omitempty"` - Upstream *Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"` - Weight *int `json:"weight,omitempty" yaml:"weight,omitempty"` - Tags []*string `json:"tags,omitempty" yaml:"tags,omitempty"` + CreatedAt *json.Number `json:"created_at,omitempty" yaml:"created_at,omitempty"` + ID *string `json:"id,omitempty" yaml:"id,omitempty"` + Target *string `json:"target,omitempty" yaml:"target,omitempty"` + Upstream *Upstream `json:"upstream,omitempty" yaml:"upstream,omitempty"` + Weight *int `json:"weight,omitempty" yaml:"weight,omitempty"` + Tags []*string `json:"tags,omitempty" yaml:"tags,omitempty"` } // Configuration represents a config of a plugin in Kong. diff --git a/kong/zz_generated.deepcopy.go b/kong/zz_generated.deepcopy.go index f35133c90..dc4a338c1 100644 --- a/kong/zz_generated.deepcopy.go +++ b/kong/zz_generated.deepcopy.go @@ -20,6 +20,10 @@ limitations under the License. package kong +import ( + json "encoding/json" +) + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ACLGroup) DeepCopyInto(out *ACLGroup) { *out = *in @@ -595,7 +599,7 @@ func (in *Healthcheck) DeepCopyInto(out *Healthcheck) { } if in.Threshold != nil { in, out := &in.Threshold, &out.Threshold - *out = new(float64) + *out = new(json.Number) **out = **in } return @@ -1536,7 +1540,7 @@ func (in *Target) DeepCopyInto(out *Target) { *out = *in if in.CreatedAt != nil { in, out := &in.CreatedAt, &out.CreatedAt - *out = new(float64) + *out = new(json.Number) **out = **in } if in.ID != nil { @@ -1731,7 +1735,7 @@ func (in *UpstreamNodeHealth) DeepCopyInto(out *UpstreamNodeHealth) { } if in.CreatedAt != nil { in, out := &in.CreatedAt, &out.CreatedAt - *out = new(float64) + *out = new(json.Number) **out = **in } if in.Data != nil {