Merge pull request #1904 from thaJeztah/cleanup_ParseEntitlements
utils/buildflags: ParseEntitlements(): use BuildKit's parsingpull/1894/head
commit
4f5a56aadb
@ -1,21 +1,15 @@
|
|||||||
package buildflags
|
package buildflags
|
||||||
|
|
||||||
import (
|
import "github.com/moby/buildkit/util/entitlements"
|
||||||
"github.com/moby/buildkit/util/entitlements"
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ParseEntitlements(in []string) ([]entitlements.Entitlement, error) {
|
func ParseEntitlements(in []string) ([]entitlements.Entitlement, error) {
|
||||||
out := make([]entitlements.Entitlement, 0, len(in))
|
out := make([]entitlements.Entitlement, 0, len(in))
|
||||||
for _, v := range in {
|
for _, v := range in {
|
||||||
switch v {
|
e, err := entitlements.Parse(v)
|
||||||
case "security.insecure":
|
if err != nil {
|
||||||
out = append(out, entitlements.EntitlementSecurityInsecure)
|
return nil, err
|
||||||
case "network.host":
|
|
||||||
out = append(out, entitlements.EntitlementNetworkHost)
|
|
||||||
default:
|
|
||||||
return nil, errors.Errorf("invalid entitlement: %v", v)
|
|
||||||
}
|
}
|
||||||
|
out = append(out, e)
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue