Use our fork of envconfig with custom lookup

This commit is contained in:
MaxJa4
2023-08-28 21:48:30 +02:00
parent 4a47f7ab69
commit c6f74f2c54
3 changed files with 16 additions and 4 deletions

View File

@@ -35,8 +35,8 @@ import (
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/client"
"github.com/kelseyhightower/envconfig"
"github.com/leekchan/timeutil"
"github.com/offen/envconfig"
"github.com/otiai10/copy"
"golang.org/x/sync/errgroup"
)
@@ -89,6 +89,18 @@ func newScript() (*script, error) {
return nil
})
envconfig.Lookup = func(key string) (string, bool) {
location, ok := os.LookupEnv(key + "_FILE")
if ok {
contents, err := os.ReadFile(location)
if err != nil {
s.logger.Warn(fmt.Sprintf("Failed to read %s! Falling back to %s", location, key))
return os.LookupEnv(key)
}
return string(contents), true
}
return os.LookupEnv(key)
}
if err := envconfig.Process("", s.c); err != nil {
return nil, fmt.Errorf("newScript: failed to process configuration values: %w", err)
}