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 authored and knative-prow-robot committed Jul 24, 2024
1 parent d5104e5 commit ccddafb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 4 additions & 6 deletions pkg/reconciler/ingress/resources/virtual_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +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 = map[string]*istiov1beta1.StringMatch{
k: {
MatchType: &istiov1beta1.StringMatch_Exact{
Exact: v.Exact,
},
match.Headers[k] = &istiov1beta1.StringMatch{
MatchType: &istiov1beta1.StringMatch_Exact{
Exact: v.Exact,
},
}
}

return match
}

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 ccddafb

Please sign in to comment.