refactor!: do not set default timeout

See toolshed/abra#596

Quite some `i18n.G` additions along the way!
This commit is contained in:
2025-08-25 11:38:07 +02:00
parent 44a7d288af
commit 6a52575ae0
10 changed files with 99 additions and 79 deletions

View File

@ -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
}