diff --git a/apis/appmesh/v1beta2/virtualrouter_types.go b/apis/appmesh/v1beta2/virtualrouter_types.go index 9e19ba44..8a12a5d0 100644 --- a/apis/appmesh/v1beta2/virtualrouter_types.go +++ b/apis/appmesh/v1beta2/virtualrouter_types.go @@ -150,7 +150,7 @@ type TCPRouteAction struct { // TCPRoute refers to https://docs.aws.amazon.com/app-mesh/latest/APIReference/API_TcpRoute.html type TCPRoute struct { // An object that represents the criteria for determining a request match. - Match TCPRouteMatch `json:"match"` + Match *TCPRouteMatch `json:"match,omitempty"` // The action to take if a match is determined. Action TCPRouteAction `json:"action"` // An object that represents a tcp timeout. diff --git a/apis/appmesh/v1beta2/zz_generated.deepcopy.go b/apis/appmesh/v1beta2/zz_generated.deepcopy.go index 2273bbe7..368b359b 100644 --- a/apis/appmesh/v1beta2/zz_generated.deepcopy.go +++ b/apis/appmesh/v1beta2/zz_generated.deepcopy.go @@ -2193,7 +2193,11 @@ func (in *TCPConnectionPool) DeepCopy() *TCPConnectionPool { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TCPRoute) DeepCopyInto(out *TCPRoute) { *out = *in - in.Match.DeepCopyInto(&out.Match) + if in.Match != nil { + in, out := &in.Match, &out.Match + *out = new(TCPRouteMatch) + (*in).DeepCopyInto(*out) + } in.Action.DeepCopyInto(&out.Action) if in.Timeout != nil { in, out := &in.Timeout, &out.Timeout diff --git a/config/crd/bases/appmesh.k8s.aws_virtualrouters.yaml b/config/crd/bases/appmesh.k8s.aws_virtualrouters.yaml index ab656bb6..c8e7b05b 100644 --- a/config/crd/bases/appmesh.k8s.aws_virtualrouters.yaml +++ b/config/crd/bases/appmesh.k8s.aws_virtualrouters.yaml @@ -1044,7 +1044,6 @@ spec: type: object required: - action - - match type: object required: - name diff --git a/config/helm/appmesh-controller/crds/crds.yaml b/config/helm/appmesh-controller/crds/crds.yaml index b169180c..90537e32 100644 --- a/config/helm/appmesh-controller/crds/crds.yaml +++ b/config/helm/appmesh-controller/crds/crds.yaml @@ -3914,7 +3914,6 @@ spec: type: object required: - action - - match type: object required: - name diff --git a/pkg/conversions/virtualrouter_types_conversion.go b/pkg/conversions/virtualrouter_types_conversion.go index 2d05d2c2..247bbaa9 100644 --- a/pkg/conversions/virtualrouter_types_conversion.go +++ b/pkg/conversions/virtualrouter_types_conversion.go @@ -255,11 +255,14 @@ func Convert_CRD_TCPRouteMatch_To_SDK_TCPRouteMatch(crdObj *appmesh.TCPRouteMatc func Convert_CRD_TCPRoute_To_SDK_TcpRoute(crdObj *appmesh.TCPRoute, sdkObj *appmeshsdk.TcpRoute, scope conversion.Scope) error { - sdkObj.Match = &appmeshsdk.TcpRouteMatch{} - if err := Convert_CRD_TCPRouteMatch_To_SDK_TCPRouteMatch(&crdObj.Match, sdkObj.Match, scope); err != nil { - return err + if crdObj.Match != nil { + sdkObj.Match = &appmeshsdk.TcpRouteMatch{} + if err := Convert_CRD_TCPRouteMatch_To_SDK_TCPRouteMatch(crdObj.Match, sdkObj.Match, scope); err != nil { + return err + } + } else { + sdkObj.Match = nil } - sdkObj.Action = &appmeshsdk.TcpRouteAction{} if err := Convert_CRD_TCPRouteAction_To_SDK_TcpRouteAction(&crdObj.Action, sdkObj.Action, scope); err != nil { return err diff --git a/pkg/conversions/virtualrouter_types_conversion_test.go b/pkg/conversions/virtualrouter_types_conversion_test.go index aa3821f4..d6437fdc 100644 --- a/pkg/conversions/virtualrouter_types_conversion_test.go +++ b/pkg/conversions/virtualrouter_types_conversion_test.go @@ -1139,7 +1139,7 @@ func TestConvert_CRD_TCPRoute_To_SDK_TcpRoute(t *testing.T) { name: "normal case", args: args{ crdObj: &appmesh.TCPRoute{ - Match: appmesh.TCPRouteMatch{ + Match: &appmesh.TCPRouteMatch{ Port: aws.Int64(8080), }, Action: appmesh.TCPRouteAction{ @@ -2471,7 +2471,7 @@ func TestConvert_CRD_Route_To_SDK_RouteSpec(t *testing.T) { }, }, }, - Match: appmesh.TCPRouteMatch{ + Match: &appmesh.TCPRouteMatch{ Port: aws.Int64(8080), }, }, @@ -2976,7 +2976,6 @@ func TestConvert_CRD_Route_To_SDK_RouteSpec(t *testing.T) { }, }, }, - Match: &appmeshsdk.TcpRouteMatch{}, }, Priority: nil, }, @@ -3276,7 +3275,6 @@ func TestConvert_CRD_Route_To_SDK_RouteSpec(t *testing.T) { }, }, }, - Match: &appmeshsdk.TcpRouteMatch{}, }, Priority: aws.Int64(400), }, diff --git a/pkg/virtualrouter/routes_manager_test.go b/pkg/virtualrouter/routes_manager_test.go index f7ff63ca..b221c4ba 100644 --- a/pkg/virtualrouter/routes_manager_test.go +++ b/pkg/virtualrouter/routes_manager_test.go @@ -691,7 +691,6 @@ func Test_BuildSDKRouteSpec(t *testing.T) { }, }, }, - Match: &appmeshsdk.TcpRouteMatch{}, }, }, },