Skip to content

Commit

Permalink
preserve appropriate header matching when creating the virtualservice
Browse files Browse the repository at this point in the history
  • Loading branch information
dprotaso committed Jul 23, 2024
1 parent a8bc624 commit 6661caa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/reconciler/ingress/resources/virtual_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ func makeMatch(host, path string, headers map[string]v1alpha1.HeaderMatch, gatew
}
}

// match.Headers = make(map[string]*istiov1beta1.StringMatch, len(headers))
// for k, v := range headers {
// match.Headers[k] = &istiov1beta1.StringMatch{
// MatchType: &istiov1beta1.StringMatch_Exact{
// Exact: v.Exact,
// },
// }
// }
for k, v := range headers {
match.Headers = map[string]*istiov1beta1.StringMatch{
k: {
Expand Down
14 changes: 13 additions & 1 deletion pkg/reconciler/ingress/resources/virtual_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ func TestMakeVirtualServices_CorrectMetadata(t *testing.T) {
}

func TestMakeVirtualServicesSpec_CorrectGateways(t *testing.T) {

tests := []struct {
name string
ingress *v1alpha1.Ingress
Expand Down Expand Up @@ -640,6 +639,9 @@ func TestMakeVirtualServiceRoute_Vanilla(t *testing.T) {
"my-header": {
Exact: "my-header-value",
},
"my-second-header": {
Exact: "my-second-header-value",
},
},
Splits: []v1alpha1.IngressBackendSplit{{
IngressBackend: v1alpha1.IngressBackend{
Expand All @@ -664,6 +666,11 @@ func TestMakeVirtualServiceRoute_Vanilla(t *testing.T) {
Exact: "my-header-value",
},
},
"my-second-header": {
MatchType: &istiov1beta1.StringMatch_Exact{
Exact: "my-second-header-value",
},
},
},
}, {
Gateways: []string{"gateway-1"},
Expand All @@ -676,6 +683,11 @@ func TestMakeVirtualServiceRoute_Vanilla(t *testing.T) {
Exact: "my-header-value",
},
},
"my-second-header": {
MatchType: &istiov1beta1.StringMatch_Exact{
Exact: "my-second-header-value",
},
},
},
}},
Route: []*istiov1beta1.HTTPRouteDestination{{
Expand Down

0 comments on commit 6661caa

Please sign in to comment.