Skip to content

Commit

Permalink
fxing TCP Route Match (#719)
Browse files Browse the repository at this point in the history
* fxing TCP Route Match

* fixing unit tests for TCP Route Match
  • Loading branch information
dileepng authored Aug 7, 2023
1 parent fa6121f commit 3197898
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apis/appmesh/v1beta2/virtualrouter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion apis/appmesh/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion config/crd/bases/appmesh.k8s.aws_virtualrouters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,6 @@ spec:
type: object
required:
- action
- match
type: object
required:
- name
Expand Down
1 change: 0 additions & 1 deletion config/helm/appmesh-controller/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3914,7 +3914,6 @@ spec:
type: object
required:
- action
- match
type: object
required:
- name
Expand Down
11 changes: 7 additions & 4 deletions pkg/conversions/virtualrouter_types_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions pkg/conversions/virtualrouter_types_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -2471,7 +2471,7 @@ func TestConvert_CRD_Route_To_SDK_RouteSpec(t *testing.T) {
},
},
},
Match: appmesh.TCPRouteMatch{
Match: &appmesh.TCPRouteMatch{
Port: aws.Int64(8080),
},
},
Expand Down Expand Up @@ -2976,7 +2976,6 @@ func TestConvert_CRD_Route_To_SDK_RouteSpec(t *testing.T) {
},
},
},
Match: &appmeshsdk.TcpRouteMatch{},
},
Priority: nil,
},
Expand Down Expand Up @@ -3276,7 +3275,6 @@ func TestConvert_CRD_Route_To_SDK_RouteSpec(t *testing.T) {
},
},
},
Match: &appmeshsdk.TcpRouteMatch{},
},
Priority: aws.Int64(400),
},
Expand Down
1 change: 0 additions & 1 deletion pkg/virtualrouter/routes_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ func Test_BuildSDKRouteSpec(t *testing.T) {
},
},
},
Match: &appmeshsdk.TcpRouteMatch{},
},
},
},
Expand Down

0 comments on commit 3197898

Please sign in to comment.