mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-23 04:07:45 +08:00
Merge pull request #488 from crazy-max/secrets-env
Allow secrets with env
This commit is contained in:
commit
ea5d32ddff
@ -34,6 +34,7 @@ func parseSecret(value string) (*secretsprovider.Source, error) {
|
|||||||
|
|
||||||
fs := secretsprovider.Source{}
|
fs := secretsprovider.Source{}
|
||||||
|
|
||||||
|
var typ string
|
||||||
for _, field := range fields {
|
for _, field := range fields {
|
||||||
parts := strings.SplitN(field, "=", 2)
|
parts := strings.SplitN(field, "=", 2)
|
||||||
key := strings.ToLower(parts[0])
|
key := strings.ToLower(parts[0])
|
||||||
@ -45,16 +46,23 @@ func parseSecret(value string) (*secretsprovider.Source, error) {
|
|||||||
value := parts[1]
|
value := parts[1]
|
||||||
switch key {
|
switch key {
|
||||||
case "type":
|
case "type":
|
||||||
if value != "file" {
|
if value != "file" && value != "env" {
|
||||||
return nil, errors.Errorf("unsupported secret type %q", value)
|
return nil, errors.Errorf("unsupported secret type %q", value)
|
||||||
}
|
}
|
||||||
|
typ = value
|
||||||
case "id":
|
case "id":
|
||||||
fs.ID = value
|
fs.ID = value
|
||||||
case "source", "src":
|
case "source", "src":
|
||||||
fs.FilePath = value
|
fs.FilePath = value
|
||||||
|
case "env":
|
||||||
|
fs.Env = value
|
||||||
default:
|
default:
|
||||||
return nil, errors.Errorf("unexpected key '%s' in '%s'", key, field)
|
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
|
return &fs, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user