log_option_helpers.go 769 B

1234567891011121314151617181920212223242526
  1. package loggerutils
  2. import (
  3. "fmt"
  4. "strconv"
  5. "github.com/docker/docker/daemon/logger"
  6. )
  7. const (
  8. defaultFailOnStartupError = true // So that we do not break existing behaviour
  9. )
  10. // ParseFailOnStartupErrorFlag parses a log driver flag that determines if
  11. // the driver should ignore possible connection errors during startup
  12. func ParseFailOnStartupErrorFlag(ctx logger.Context) (bool, error) {
  13. failOnStartupError := ctx.Config["fail-on-startup-error"]
  14. if failOnStartupError == "" {
  15. return defaultFailOnStartupError, nil
  16. }
  17. failOnStartupErrorFlag, err := strconv.ParseBool(failOnStartupError)
  18. if err != nil {
  19. return defaultFailOnStartupError, fmt.Errorf("invalid connect error flag %s: %s", failOnStartupError, err)
  20. }
  21. return failOnStartupErrorFlag, nil
  22. }