Removes Wild Cloud cruft.
This commit is contained in:
@@ -15,12 +15,13 @@ import (
|
||||
"github.com/wild-cloud/wild-central/internal/domains"
|
||||
)
|
||||
|
||||
// InstanceRoute represents a Wild Cloud instance's ingress routing configuration
|
||||
// InstanceRoute represents an L4 TCP passthrough route (k8s instance).
|
||||
type InstanceRoute struct {
|
||||
// L4Route represents an L4 TCP passthrough route.
|
||||
// HAProxy inspects the SNI header and forwards the entire TCP connection
|
||||
// to the backend, which handles its own TLS.
|
||||
type L4Route struct {
|
||||
Name string `json:"name"` // identifier for backend naming
|
||||
Domain string `json:"domain"` // e.g. "cloud.payne.io"
|
||||
BackendIP string `json:"backendIP"` // k8s load balancer IP
|
||||
BackendIP string `json:"backendIP"` // backend server IP
|
||||
Subdomains bool `json:"subdomains"` // if true, also match *.domain
|
||||
}
|
||||
|
||||
@@ -87,12 +88,12 @@ type GenerateOpts struct {
|
||||
// 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 []InstanceRoute, custom []CustomRoute, centralDomain ...string) string {
|
||||
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 []InstanceRoute, custom []CustomRoute, opts GenerateOpts) string {
|
||||
func (m *Manager) GenerateWithOpts(instances []L4Route, custom []CustomRoute, opts GenerateOpts) string {
|
||||
var sb strings.Builder
|
||||
|
||||
sb.WriteString(`# Wild Cloud HAProxy Configuration
|
||||
@@ -433,7 +434,7 @@ func sanitizeName(name string) string {
|
||||
|
||||
// GetListenPorts returns all TCP/HTTP ports HAProxy is configured to listen on.
|
||||
// Used to keep nftables rules in sync.
|
||||
func (m *Manager) GetListenPorts(instances []InstanceRoute, custom []CustomRoute) []int {
|
||||
func (m *Manager) GetListenPorts(custom []CustomRoute) []int {
|
||||
ports := []int{80, 443, 8404}
|
||||
for _, route := range custom {
|
||||
ports = append(ports, route.Port)
|
||||
|
||||
@@ -41,7 +41,7 @@ func TestSanitizeName(t *testing.T) {
|
||||
|
||||
func TestGetListenPorts_BasePorts(t *testing.T) {
|
||||
m := NewManager("")
|
||||
ports := m.GetListenPorts(nil, nil)
|
||||
ports := m.GetListenPorts(nil)
|
||||
want := map[int]bool{80: true, 443: true, 8404: true}
|
||||
for _, p := range ports {
|
||||
delete(want, p)
|
||||
@@ -54,7 +54,7 @@ func TestGetListenPorts_BasePorts(t *testing.T) {
|
||||
func TestGetListenPorts_IncludesCustom(t *testing.T) {
|
||||
m := NewManager("")
|
||||
custom := []CustomRoute{{Name: "ssh", Port: 2222, Backend: "192.168.1.10:22"}}
|
||||
ports := m.GetListenPorts(nil, custom)
|
||||
ports := m.GetListenPorts(custom)
|
||||
found := false
|
||||
for _, p := range ports {
|
||||
if p == 2222 {
|
||||
@@ -94,7 +94,7 @@ func TestGenerate_NoInstances_NoHTTPSFrontend(t *testing.T) {
|
||||
|
||||
func TestGenerate_WithInstance_SNIACLs(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.20", Subdomains: true},
|
||||
}
|
||||
out := m.Generate(instances, nil)
|
||||
@@ -113,7 +113,7 @@ func TestGenerate_WithInstance_SNIACLs(t *testing.T) {
|
||||
|
||||
func TestGenerate_WithInstance_Backend(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.20"},
|
||||
}
|
||||
out := m.Generate(instances, nil)
|
||||
@@ -128,7 +128,7 @@ func TestGenerate_WithInstance_Backend(t *testing.T) {
|
||||
|
||||
func TestGenerate_MultipleInstances(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.20"},
|
||||
{Name: "test-cloud", Domain: "cloud2.payne.io", BackendIP: "192.168.8.30"},
|
||||
}
|
||||
@@ -150,7 +150,7 @@ func TestGenerate_MultipleInstances(t *testing.T) {
|
||||
|
||||
func TestGenerate_WithSubdomains(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{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},
|
||||
}
|
||||
@@ -172,7 +172,7 @@ func TestGenerate_WithSubdomains(t *testing.T) {
|
||||
|
||||
func TestGenerate_ACLOrdering(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.240", Subdomains: true},
|
||||
}
|
||||
httpRoutes := []HTTPRoute{
|
||||
@@ -275,7 +275,7 @@ func TestGenerateWithOpts_HTTPRoutes_L7Frontend(t *testing.T) {
|
||||
|
||||
func TestGenerateWithOpts_MixedL4AndL7(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "payne-cloud", Domain: "cloud.payne.io", BackendIP: "192.168.8.100"},
|
||||
}
|
||||
httpRoutes := []HTTPRoute{
|
||||
@@ -309,7 +309,7 @@ func TestGenerateWithOpts_ACLOrdering_L7BeforeL4Wildcard(t *testing.T) {
|
||||
// wild-cloud.payne.io is an L7 HTTP service. The L7 exact match MUST
|
||||
// appear before the L4 wildcard, otherwise HAProxy matches
|
||||
// wild-cloud.payne.io against *.payne.io and sends it to the wrong backend.
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "payne-io", Domain: "payne.io", BackendIP: "192.168.8.240", Subdomains: true},
|
||||
}
|
||||
httpRoutes := []HTTPRoute{
|
||||
@@ -352,7 +352,7 @@ func TestGenerateWithOpts_ACLOrdering_L7BeforeL4Wildcard(t *testing.T) {
|
||||
|
||||
func TestGenerateWithOpts_SubdomainsFalse_ExactOnly(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "payne-io", Domain: "payne.io", BackendIP: "192.168.8.20", Subdomains: false},
|
||||
}
|
||||
out := m.GenerateWithOpts(instances, nil, GenerateOpts{})
|
||||
@@ -368,7 +368,7 @@ func TestGenerateWithOpts_SubdomainsFalse_ExactOnly(t *testing.T) {
|
||||
|
||||
func TestGenerateWithOpts_SubdomainsTrue_WildcardAndExact(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "cloud-payne", Domain: "cloud.payne.io", BackendIP: "192.168.8.20", Subdomains: true},
|
||||
}
|
||||
out := m.GenerateWithOpts(instances, nil, GenerateOpts{})
|
||||
@@ -390,7 +390,7 @@ func TestGenerateWithOpts_SubdomainsTrue_WildcardAndExact(t *testing.T) {
|
||||
func TestGenerateWithOpts_ACLOrdering_L4ExactBeforeL4Wildcard(t *testing.T) {
|
||||
m := NewManager("")
|
||||
// payne.io exact (subdomains:false) must appear before cloud.payne.io wildcard (subdomains:true)
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "cloud-payne", Domain: "cloud.payne.io", BackendIP: "192.168.8.20", Subdomains: true},
|
||||
{Name: "payne-io", Domain: "payne.io", BackendIP: "192.168.8.20", Subdomains: false},
|
||||
}
|
||||
@@ -412,7 +412,7 @@ func TestGenerateWithOpts_ACLOrdering_L4ExactBeforeL4Wildcard(t *testing.T) {
|
||||
|
||||
func TestGenerateWithOpts_BackwardCompatible(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "test", Domain: "test.example.com", BackendIP: "10.0.0.1"},
|
||||
}
|
||||
|
||||
@@ -471,7 +471,7 @@ func TestGenerateWithOpts_OnlyHTTPRoutes(t *testing.T) {
|
||||
func TestGenerateWithOpts_OnlyL4Routes(t *testing.T) {
|
||||
m := NewManager("")
|
||||
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "cloud", Domain: "cloud.example.com", BackendIP: "10.0.0.1", Subdomains: true},
|
||||
}
|
||||
|
||||
@@ -731,7 +731,7 @@ func TestGenerateWithOpts_NoL7Fields_BackwardCompat(t *testing.T) {
|
||||
|
||||
func TestGenerateWithOpts_ServiceMarkers(t *testing.T) {
|
||||
m := NewManager("")
|
||||
instances := []InstanceRoute{
|
||||
instances := []L4Route{
|
||||
{Name: "cloud", Domain: "cloud.example.com", BackendIP: "10.0.0.1", Subdomains: true},
|
||||
}
|
||||
httpRoutes := []HTTPRoute{
|
||||
|
||||
Reference in New Issue
Block a user