mirror of
https://github.com/traefik/traefik.git
synced 2025-11-29 22:51:37 +01:00
Auto-negotiate Docker API version
This commit is contained in:
parent
effca0a603
commit
058b194604
@ -33,14 +33,6 @@ import (
|
|||||||
"github.com/traefik/traefik/v2/pkg/version"
|
"github.com/traefik/traefik/v2/pkg/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// DockerAPIVersion is a constant holding the version of the Provider API traefik will use.
|
|
||||||
DockerAPIVersion = "1.24"
|
|
||||||
|
|
||||||
// SwarmAPIVersion is a constant holding the version of the Provider API traefik will use.
|
|
||||||
SwarmAPIVersion = "1.24"
|
|
||||||
)
|
|
||||||
|
|
||||||
// DefaultTemplateRule The default template for the default rule.
|
// DefaultTemplateRule The default template for the default rule.
|
||||||
const DefaultTemplateRule = "Host(`{{ normalize .Name }}`)"
|
const DefaultTemplateRule = "Host(`{{ normalize .Name }}`)"
|
||||||
|
|
||||||
@ -121,13 +113,10 @@ func (p *Provider) createClient() (client.APIClient, error) {
|
|||||||
httpHeaders := map[string]string{
|
httpHeaders := map[string]string{
|
||||||
"User-Agent": "Traefik " + version.Version,
|
"User-Agent": "Traefik " + version.Version,
|
||||||
}
|
}
|
||||||
opts = append(opts, client.WithHTTPHeaders(httpHeaders))
|
opts = append(opts,
|
||||||
|
client.FromEnv,
|
||||||
apiVersion := DockerAPIVersion
|
client.WithAPIVersionNegotiation(),
|
||||||
if p.SwarmMode {
|
client.WithHTTPHeaders(httpHeaders))
|
||||||
apiVersion = SwarmAPIVersion
|
|
||||||
}
|
|
||||||
opts = append(opts, client.WithVersion(apiVersion))
|
|
||||||
|
|
||||||
return client.NewClientWithOpts(opts...)
|
return client.NewClientWithOpts(opts...)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user