Skip to content

Commit 554a788

Browse files
committed
listener options merge what translator generates
1 parent 4f8afe2 commit 554a788

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

projects/gateway2/translator/plugins/listeneroptions/listener_options_plugin.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
lisquery "github.com/solo-io/gloo/projects/gateway2/translator/plugins/listeneroptions/query"
99
v1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
1010

11+
"google.golang.org/protobuf/proto"
12+
1113
"sigs.k8s.io/controller-runtime/pkg/client"
1214
)
1315

@@ -47,7 +49,11 @@ func (p *plugin) ApplyListenerPlugin(
4749
// use the first option (highest in priority)
4850
// see for more context: https://github.com/solo-io/solo-projects/issues/6313
4951
optToUse := attachedOptions[0]
50-
outListener.Options = optToUse.Spec.GetOptions()
52+
if outListener.GetOptions() != nil {
53+
proto.Merge(outListener.GetOptions(), optToUse.Spec.GetOptions())
54+
} else {
55+
outListener.Options = optToUse.Spec.GetOptions()
56+
}
5157

5258
return nil
5359
}

projects/gateway2/translator/plugins/listeneroptions/listener_options_plugin_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/solo-io/gloo/projects/gateway2/translator/testutils"
1717
"github.com/solo-io/gloo/projects/gateway2/wellknown"
1818
v1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
19+
"github.com/solo-io/gloo/projects/gloo/pkg/api/v1/options/proxy_protocol"
1920
corev1 "github.com/solo-io/skv2/pkg/api/core.skv2.solo.io/v1"
2021
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -48,12 +49,17 @@ var _ = Describe("ListenerOptions Plugin", func() {
4849
},
4950
}
5051

51-
outputListener = &v1.Listener{}
52+
outputListener = &v1.Listener{
53+
Options: &v1.ListenerOptions{
54+
ProxyProtocol: &proxy_protocol.ProxyProtocol{},
55+
},
56+
}
5257

5358
expectedOptions = &v1.ListenerOptions{
5459
PerConnectionBufferLimitBytes: &wrapperspb.UInt32Value{
5560
Value: uint32(419),
5661
},
62+
ProxyProtocol: &proxy_protocol.ProxyProtocol{},
5763
}
5864
})
5965
JustBeforeEach(func() {
@@ -118,7 +124,6 @@ var _ = Describe("ListenerOptions Plugin", func() {
118124
})
119125
})
120126
})
121-
122127
})
123128

124129
func attachedListenerOption() *solokubev1.ListenerOption {
@@ -144,6 +149,7 @@ func attachedListenerOption() *solokubev1.ListenerOption {
144149
},
145150
}
146151
}
152+
147153
func attachedListenerOptionWithSectionName() *solokubev1.ListenerOption {
148154
listOpt := attachedListenerOption()
149155
listOpt.Spec.TargetRefs[0].SectionName = &wrapperspb.StringValue{

0 commit comments

Comments
 (0)