forked from toolshed/abra
refactor!: do not set default timeout
See toolshed/abra#596 Quite some `i18n.G` additions along the way!
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
@ -87,13 +88,21 @@ func GetLabel(compose *composetypes.Config, stackName string, label string) stri
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetTimeoutFromLabel reads the timeout value from docker label "coop-cloud.${STACK_NAME}.TIMEOUT" and returns 50 as default value
|
||||
// GetTimeoutFromLabel reads the timeout value from docker label
|
||||
// `coop-cloud.${STACK_NAME}.timeout=...` if present. A value is present if the
|
||||
// operator uses a `TIMEOUT=...` in their app env.
|
||||
func GetTimeoutFromLabel(compose *composetypes.Config, stackName string) (int, error) {
|
||||
timeout := 50 // Default Timeout
|
||||
var err error = nil
|
||||
var timeout int
|
||||
|
||||
if timeoutLabel := GetLabel(compose, stackName, "timeout"); timeoutLabel != "" {
|
||||
log.Debug(i18n.G("timeout label: %s", timeoutLabel))
|
||||
|
||||
var err error
|
||||
timeout, err = strconv.Atoi(timeoutLabel)
|
||||
if err != nil {
|
||||
return timeout, errors.New(i18n.G("unable to convert timeout label %s to int: %s", timeoutLabel, err))
|
||||
}
|
||||
}
|
||||
return timeout, err
|
||||
|
||||
return timeout, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user