Skip to content

Commit

Permalink
listener options merge what translator generates
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenctl committed Jan 21, 2025
1 parent 4f8afe2 commit 554a788
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
lisquery "github.com/solo-io/gloo/projects/gateway2/translator/plugins/listeneroptions/query"
v1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"

"google.golang.org/protobuf/proto"

"sigs.k8s.io/controller-runtime/pkg/client"
)

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

return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/solo-io/gloo/projects/gateway2/translator/testutils"
"github.com/solo-io/gloo/projects/gateway2/wellknown"
v1 "github.com/solo-io/gloo/projects/gloo/pkg/api/v1"
"github.com/solo-io/gloo/projects/gloo/pkg/api/v1/options/proxy_protocol"
corev1 "github.com/solo-io/skv2/pkg/api/core.skv2.solo.io/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -48,12 +49,17 @@ var _ = Describe("ListenerOptions Plugin", func() {
},
}

outputListener = &v1.Listener{}
outputListener = &v1.Listener{
Options: &v1.ListenerOptions{
ProxyProtocol: &proxy_protocol.ProxyProtocol{},
},
}

expectedOptions = &v1.ListenerOptions{
PerConnectionBufferLimitBytes: &wrapperspb.UInt32Value{
Value: uint32(419),
},
ProxyProtocol: &proxy_protocol.ProxyProtocol{},
}
})
JustBeforeEach(func() {
Expand Down Expand Up @@ -118,7 +124,6 @@ var _ = Describe("ListenerOptions Plugin", func() {
})
})
})

})

func attachedListenerOption() *solokubev1.ListenerOption {
Expand All @@ -144,6 +149,7 @@ func attachedListenerOption() *solokubev1.ListenerOption {
},
}
}

func attachedListenerOptionWithSectionName() *solokubev1.ListenerOption {
listOpt := attachedListenerOption()
listOpt.Spec.TargetRefs[0].SectionName = &wrapperspb.StringValue{
Expand Down

0 comments on commit 554a788

Please sign in to comment.