Skip to content

Commit

Permalink
fix: config-backend annotation also for TCP-Backends
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Jul 2, 2023
1 parent 6a9a266 commit 04ae7e5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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

0 comments on commit 04ae7e5

Please sign in to comment.