[proxy] Add --hostname-from-label
This allows registering container hostnames based on a label provided when creating the container.
This commit is contained in:
1 parent
32a82f2d0e
commit
ce5dd847e9
6 files changed
+92
-29
No files matched your search
@@ -59,8 +59,13 @@ func (i *createContainerInterceptor) InterceptRequest(r *http.Request) error {
|
||||
if err := i.setWeaveWaitEntrypoint(container.Config); err != nil {
|
||||
return err
|
||||
}
|
||||
containerName := r.URL.Query().Get("name")
|
||||
hostname := i.proxy.hostnameMatchRegexp.ReplaceAllString(containerName, i.proxy.HostnameReplacement)
|
||||
hostname := r.URL.Query().Get("name")
|
||||
if i.proxy.Config.HostnameFromLabel != "" {
|
||||
if labelValue, ok := container.Labels[i.proxy.Config.HostnameFromLabel]; ok {
|
||||
hostname = labelValue
|
||||
}
|
||||
}
|
||||
hostname = i.proxy.hostnameMatchRegexp.ReplaceAllString(hostname, i.proxy.HostnameReplacement)
|
||||
if err := i.setWeaveDNS(&container, hostname); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ func dockerAPIEndpoint(endpoint string) *regexp.Regexp {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
HostnameFromLabel string
|
||||
HostnameMatch string
|
||||
HostnameReplacement string
|
||||
ListenAddrs []string
|
||||
|
||||
Reference in new issue
Block a user