From f6d83c97bb8b9688359d98ccf8b269894a78f555 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 19 Dec 2020 04:18:51 +0100 Subject: [PATCH] Allow secrets with env Signed-off-by: CrazyMax --- build/secrets.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/build/secrets.go b/build/secrets.go index 3ad806e0..ea4a71a1 100644 --- a/build/secrets.go +++ b/build/secrets.go @@ -34,6 +34,7 @@ func parseSecret(value string) (*secretsprovider.Source, error) { fs := secretsprovider.Source{} + var typ string for _, field := range fields { parts := strings.SplitN(field, "=", 2) key := strings.ToLower(parts[0]) @@ -45,16 +46,23 @@ func parseSecret(value string) (*secretsprovider.Source, error) { value := parts[1] switch key { case "type": - if value != "file" { + if value != "file" && value != "env" { return nil, errors.Errorf("unsupported secret type %q", value) } + typ = value case "id": fs.ID = value case "source", "src": fs.FilePath = value + case "env": + fs.Env = value default: return nil, errors.Errorf("unexpected key '%s' in '%s'", key, field) } } + if typ == "env" && fs.Env == "" { + fs.Env = fs.FilePath + fs.FilePath = "" + } return &fs, nil }