feat(ecs): add HealthCheck port label.
This commit is contained in:
parent
f195ef27f3
commit
722ea28e3a
2 changed files with 24 additions and 0 deletions
|
@ -30,6 +30,7 @@ func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types
|
||||||
"getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints),
|
"getEntryPoints": getFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||||
"hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath),
|
"hasHealthCheckLabels": hasFuncFirst(label.TraefikBackendHealthCheckPath),
|
||||||
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
|
"getHealthCheckPath": getFuncFirstStringValue(label.TraefikBackendHealthCheckPath, ""),
|
||||||
|
"getHealthCheckPort": getFuncFirstIntValue(label.TraefikBackendHealthCheckPort, label.DefaultBackendHealthCheckPort),
|
||||||
"getHealthCheckInterval": getFuncFirstStringValue(label.TraefikBackendHealthCheckInterval, ""),
|
"getHealthCheckInterval": getFuncFirstStringValue(label.TraefikBackendHealthCheckInterval, ""),
|
||||||
}
|
}
|
||||||
return p.GetConfiguration("templates/ecs.tmpl", ecsFuncMap, struct {
|
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 {
|
func getFuncFirstBoolValue(labelName string, defaultValue bool) func(instances []ecsInstance) bool {
|
||||||
return func(instances []ecsInstance) bool {
|
return func(instances []ecsInstance) bool {
|
||||||
if len(instances) < 0 {
|
if len(instances) < 0 {
|
||||||
|
@ -137,6 +147,19 @@ func getBoolValue(i ecsInstance, labelName string, defaultValue bool) bool {
|
||||||
return defaultValue
|
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 {
|
func getSliceString(i ecsInstance, labelName string) []string {
|
||||||
if value, ok := i.containerDefinition.DockerLabels[labelName]; ok {
|
if value, ok := i.containerDefinition.DockerLabels[labelName]; ok {
|
||||||
if value == nil {
|
if value == nil {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
{{ if hasHealthCheckLabels $instances }}
|
{{ if hasHealthCheckLabels $instances }}
|
||||||
[backends.backend-{{ $serviceName }}.healthCheck]
|
[backends.backend-{{ $serviceName }}.healthCheck]
|
||||||
path = "{{getHealthCheckPath $instances }}"
|
path = "{{getHealthCheckPath $instances }}"
|
||||||
|
port = {{getHealthCheckPort $instances}}
|
||||||
interval = "{{getHealthCheckInterval $instances }}"
|
interval = "{{getHealthCheckInterval $instances }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue