Allow configuring server URLs with label providers
This commit is contained in:
parent
b0a72960bc
commit
95dd17e020
18 changed files with 924 additions and 48 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue