mirror of
https://github.com/containous/traefik.git
synced 2025-01-26 10:03:48 +03:00
feat(ecs): add HealthCheck port label.
This commit is contained in:
parent
f195ef27f3
commit
722ea28e3a
@ -30,6 +30,7 @@ func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types
|
||||
"getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||
"hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath),
|
||||
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
|
||||
"getHealthCheckPort": getFuncFirstIntValue(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
|
||||
"getHealthCheckInterval": getFuncFirstStringValue(label.TraefikBackendHealthCheckInterval, ""),
|
||||
}
|
||||
return p.GetConfiguration("templates/ecs.tmpl", ecsFuncMap, struct {
|
||||
@ -102,6 +103,15 @@ func getFuncFirstStringValue(labelName string, defaultValue string) func(instanc
|
||||
}
|
||||
}
|
||||
|
||||
func getFuncFirstIntValue(labelName string, defaultValue int) func(instances []ecsInstance) int {
|
||||
return func(instances []ecsInstance) int {
|
||||
if len(instances) < 0 {
|
||||
return defaultValue
|
||||
}
|
||||
return getIntValue(instances[0], labelName, defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
func getFuncFirstBoolValue(labelName string, defaultValue bool) func(instances []ecsInstance) bool {
|
||||
return func(instances []ecsInstance) bool {
|
||||
if len(instances) < 0 {
|
||||
@ -137,6 +147,19 @@ func getBoolValue(i ecsInstance, labelName string, defaultValue bool) bool {
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func getIntValue(i ecsInstance, labelName string, defaultValue int) int {
|
||||
rawValue, ok := i.containerDefinition.DockerLabels[labelName]
|
||||
if ok {
|
||||
if rawValue != nil {
|
||||
v, err := strconv.Atoi(*rawValue)
|
||||
if err == nil {
|
||||
return v
|
||||
}
|
||||
}
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func getSliceString(i ecsInstance, labelName string) []string {
|
||||
if value, ok := i.containerDefinition.DockerLabels[labelName]; ok {
|
||||
if value == nil {
|
||||
|
@ -12,6 +12,7 @@
|
||||
{{ if hasHealthCheckLabels $instances }}
|
||||
[backends.backend-{{ $serviceName }}.healthCheck]
|
||||
path = "{{getHealthCheckPath $instances }}"
|
||||
port = {{getHealthCheckPort $instances}}
|
||||
interval = "{{getHealthCheckInterval $instances }}"
|
||||
{{end}}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user