Removes more Wild Cloud cruft.
This commit is contained in:
@@ -84,14 +84,6 @@ type GenerateOpts struct {
|
||||
CertsDir string // directory containing per-domain PEM files for L7 TLS
|
||||
}
|
||||
|
||||
// Generate creates a complete HAProxy configuration from instance routes, custom routes,
|
||||
// and optional config. Uses L4 TCP mode with SNI inspection for HTTPS —
|
||||
// TLS terminates at each k8s cluster's traefik. HTTP routes add an L7 frontend
|
||||
// where Central terminates TLS with a wildcard cert and reverse-proxies by Host header.
|
||||
func (m *Manager) Generate(instances []L4Route, custom []CustomRoute, centralDomain ...string) string {
|
||||
return m.GenerateWithOpts(instances, custom, GenerateOpts{})
|
||||
}
|
||||
|
||||
// GenerateWithOpts creates a complete HAProxy configuration with full options.
|
||||
func (m *Manager) GenerateWithOpts(instances []L4Route, custom []CustomRoute, opts GenerateOpts) string {
|
||||
var sb strings.Builder
|
||||
|
||||
@@ -68,7 +68,7 @@ func TestGetListenPorts_IncludesCustom(t *testing.T) {
|
||||
|
||||
func TestGenerate_AlwaysIncludesBoilerplate(t *testing.T) {
|
||||
m := NewManager("")
|
||||
out := m.Generate(nil, nil)
|
||||
out := m.GenerateWithOpts(nil, nil, GenerateOpts{})
|
||||
|
||||
for _, want := range []string{
|
||||
"global\n",
|
||||
@@ -86,7 +86,7 @@ func TestGenerate_AlwaysIncludesBoilerplate(t *testing.T) {
|
||||
|
||||
func TestGenerate_NoInstances_NoHTTPSFrontend(t *testing.T) {
|
||||
m := NewManager("")
|
||||
out := m.Generate(nil, nil)
|
||||
out := m.GenerateWithOpts(nil, nil, GenerateOpts{})
|
||||
if strings.Contains(out, "frontend https_in") {
|
||||
t.Errorf("https_in frontend should be absent when no instances configured")
|
||||
}
|
||||
@@ -97,7 +97,7 @@ func TestGenerate_WithInstance_SNIACLs(t *testing.T) {
|
||||
instances := []L4Route{
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.20", Subdomains: true},
|
||||
}
|
||||
out := m.Generate(instances, nil)
|
||||
out := m.GenerateWithOpts(instances, nil, GenerateOpts{})
|
||||
|
||||
// With subdomains:true, both ACL lines for OR-matching
|
||||
if !strings.Contains(out, "req_ssl_sni -m end .cloud.payne.io") {
|
||||
@@ -116,7 +116,7 @@ func TestGenerate_WithInstance_Backend(t *testing.T) {
|
||||
instances := []L4Route{
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.20"},
|
||||
}
|
||||
out := m.Generate(instances, nil)
|
||||
out := m.GenerateWithOpts(instances, nil, GenerateOpts{})
|
||||
|
||||
if !strings.Contains(out, "backend be_https_payne_cloud") {
|
||||
t.Errorf("expected backend block, got:\n%s", out)
|
||||
@@ -132,7 +132,7 @@ func TestGenerate_MultipleInstances(t *testing.T) {
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.20"},
|
||||
{Name: "test-cloud", Domain: "cloud2.payne.io", BackendIP: "192.168.8.30"},
|
||||
}
|
||||
out := m.Generate(instances, nil)
|
||||
out := m.GenerateWithOpts(instances, nil, GenerateOpts{})
|
||||
|
||||
if !strings.Contains(out, "be_https_payne_cloud") {
|
||||
t.Errorf("expected payne-cloud backend, got:\n%s", out)
|
||||
@@ -154,7 +154,7 @@ func TestGenerate_WithSubdomains(t *testing.T) {
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.20", Subdomains: true},
|
||||
{Name: "payne-io", Domain: "payne.io", BackendIP: "192.168.8.20", Subdomains: false},
|
||||
}
|
||||
out := m.Generate(instances, nil)
|
||||
out := m.GenerateWithOpts(instances, nil, GenerateOpts{})
|
||||
|
||||
// cloud.payne.io with subdomains:true should have wildcard ACL
|
||||
if !strings.Contains(out, "req_ssl_sni -m end .cloud.payne.io") {
|
||||
@@ -207,7 +207,7 @@ func TestGenerate_CustomRoute(t *testing.T) {
|
||||
custom := []CustomRoute{
|
||||
{Name: "civil_ssh", Port: 2222, Backend: "192.168.8.10:22"},
|
||||
}
|
||||
out := m.Generate(nil, custom)
|
||||
out := m.GenerateWithOpts(nil, custom, GenerateOpts{})
|
||||
|
||||
if !strings.Contains(out, "frontend fe_civil_ssh") {
|
||||
t.Errorf("expected custom frontend, got:\n%s", out)
|
||||
@@ -417,7 +417,7 @@ func TestGenerateWithOpts_BackwardCompatible(t *testing.T) {
|
||||
}
|
||||
|
||||
// Using old Generate function should still work
|
||||
out := m.Generate(instances, nil)
|
||||
out := m.GenerateWithOpts(instances, nil, GenerateOpts{})
|
||||
if !strings.Contains(out, "be_https_test") {
|
||||
t.Errorf("backward compat: expected instance backend, got:\n%s", out)
|
||||
}
|
||||
@@ -538,7 +538,7 @@ func TestGenerate_CustomRoutePorts(t *testing.T) {
|
||||
{Name: "mqtt", Port: 1883, Backend: "192.168.1.20:1883"},
|
||||
}
|
||||
|
||||
out := m.Generate(nil, custom)
|
||||
out := m.GenerateWithOpts(nil, custom, GenerateOpts{})
|
||||
|
||||
if !strings.Contains(out, "bind *:2222") {
|
||||
t.Errorf("expected bind on port 2222, got:\n%s", out)
|
||||
|
||||
Reference in New Issue
Block a user