Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: config-backend annotation also for TCP-Backends #1009

Merged
merged 1 commit into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkg/haproxy/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,14 @@ frontend _front_https
"_back_d1_app_8080_idpathdef__prefix_02.map": "<default>#/app1 path02",
},
},
{
doconfig: func(c *config, h *hatypes.Host, b *hatypes.Backend) {
b.ModeTCP = true
b.CustomConfig = []string{"## custom for TCP backend"}
},
expected: `
## custom for TCP backend`,
},
}
for _, test := range testCases {
c := setup(t)
Expand Down Expand Up @@ -3635,6 +3643,14 @@ func TestInstanceCustomProxy(t *testing.T) {
h.AddPath(b, "/", hatypes.MatchBegin)
h.SetSSLPassthrough(true)

var h2 *hatypes.Host
var b2 = c.config.Backends().AcquireBackend("d2", "app", "8080")
b2.Endpoints = []*hatypes.Endpoint{endpointS21}
b2.ModeTCP = true
h2 = c.config.Hosts().AcquireHost("d2.local")
h2.AddPath(b, "/", hatypes.MatchBegin)
h2.SetSSLPassthrough(true)

auth := &c.config.Frontend().AuthProxy
auth.Name = "_front__auth"
auth.RangeStart = 4001
Expand All @@ -3653,6 +3669,7 @@ func TestInstanceCustomProxy(t *testing.T) {
"_tcp_default_pgsql_5432": {"## custom for _tcp_default_pgsql_5432"},
"_auth_backend001_5000": {"## custom for _auth_backend001_5000"},
"d1_app_8080": {"## custom for d1_app_8080"},
"d2_app_8080": {"## custom for d2_app_8080"},
"_redirect_https": {"## custom for _redirect_https"},
"_error404": {"## custom for _error404", "## line 2"},
"_auth_4001": {"## custom for _auth_4001"},
Expand Down Expand Up @@ -3682,6 +3699,10 @@ backend d1_app_8080
mode http
## custom for d1_app_8080
server s1 172.17.0.11:8080 weight 100
backend d2_app_8080
mode tcp
## custom for d2_app_8080
server s21 172.17.0.121:8080 weight 100
backend _redirect_https
mode http
## custom for _redirect_https
Expand Down
8 changes: 8 additions & 0 deletions rootfs/etc/templates/haproxy/haproxy.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,14 @@ backend {{ $backend.ID }}
{{- end }}
{{- end }}

{{- /*------------------------------------*/}}
{{- range $snippet := $backend.CustomConfig }}
{{ $snippet }}
{{- end }}
{{- range $snippet := index $global.CustomProxy $backend.ID }}
{{ $snippet }}
{{- end }}

{{- /*------------------------------------*/}}
{{- /* MODE HTTP */}}
{{- /*------------------------------------*/}}
Expand Down