Skip to content

Commit

Permalink
Merge pull request #1904 from thaJeztah/cleanup_ParseEntitlements
Browse files Browse the repository at this point in the history
utils/buildflags: ParseEntitlements(): use BuildKit's parsing
  • Loading branch information
crazy-max authored Jun 23, 2023
2 parents bd672ea + 399beb5 commit 4f5a56a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions util/buildflags/entitlements.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package buildflags

import (
"github.com/moby/buildkit/util/entitlements"
"github.com/pkg/errors"
)
import "github.com/moby/buildkit/util/entitlements"

func ParseEntitlements(in []string) ([]entitlements.Entitlement, error) {
out := make([]entitlements.Entitlement, 0, len(in))
for _, v := range in {
switch v {
case "security.insecure":
out = append(out, entitlements.EntitlementSecurityInsecure)
case "network.host":
out = append(out, entitlements.EntitlementNetworkHost)
default:
return nil, errors.Errorf("invalid entitlement: %v", v)
e, err := entitlements.Parse(v)
if err != nil {
return nil, err
}
out = append(out, e)
}
return out, nil
}

0 comments on commit 4f5a56a

Please sign in to comment.