Allow configuring server URLs with label providers

This commit is contained in:
Taylor Yelverton 2025-01-09 10:20:06 -06:00 committed by GitHub
parent b0a72960bc
commit 95dd17e020
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 924 additions and 48 deletions

View file

@ -262,10 +262,14 @@ func (p *DynConfBuilder) addServer(ctx context.Context, container dockerData, lo
}
if len(loadBalancer.Servers) == 0 {
server := dynamic.Server{}
server.SetDefaults()
loadBalancer.Servers = []dynamic.Server{{}}
}
loadBalancer.Servers = []dynamic.Server{server}
if loadBalancer.Servers[0].URL != "" {
if loadBalancer.Servers[0].Scheme != "" || loadBalancer.Servers[0].Port != "" {
return errors.New("defining scheme or port is not allowed when URL is defined")
}
return nil
}
serverPort := loadBalancer.Servers[0].Port
@ -280,8 +284,13 @@ func (p *DynConfBuilder) addServer(ctx context.Context, container dockerData, lo
return errors.New("port is missing")
}
loadBalancer.Servers[0].URL = fmt.Sprintf("%s://%s", loadBalancer.Servers[0].Scheme, net.JoinHostPort(ip, port))
scheme := loadBalancer.Servers[0].Scheme
loadBalancer.Servers[0].Scheme = ""
if scheme == "" {
scheme = "http"
}
loadBalancer.Servers[0].URL = fmt.Sprintf("%s://%s", scheme, net.JoinHostPort(ip, port))
return nil
}