Shim bare numbers into duration strings [#39]
Helm2's --timeout took a number of seconds, rather than the ParseDuration-compatible string that helm3 uses. For backward- compatibility, update a bare number into a duration string.
This commit is contained in:
@@ -4,8 +4,11 @@ import (
|
||||
"fmt"
|
||||
"github.com/kelseyhightower/envconfig"
|
||||
"io"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var justNumbers = regexp.MustCompile(`^\d+$`)
|
||||
|
||||
// The Config struct captures the `settings` and `environment` blocks in the application's drone
|
||||
// config. Configuration in drone's `settings` block arrives as uppercase env vars matching the
|
||||
// config key, prefixed with `PLUGIN_`. Config from the `environment` block is uppercased, but does
|
||||
@@ -62,6 +65,10 @@ func NewConfig(stdout, stderr io.Writer) (*Config, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if justNumbers.MatchString(cfg.Timeout) {
|
||||
cfg.Timeout = fmt.Sprintf("%ss", cfg.Timeout)
|
||||
}
|
||||
|
||||
if cfg.Debug && cfg.Stderr != nil {
|
||||
cfg.logDebug()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user