mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-31 23:58:03 +08:00
bake: add wildcard to fs entitlements to allow any paths
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@@ -326,7 +326,14 @@ func isParentOrEqualPath(p, parent string) bool {
|
||||
}
|
||||
|
||||
func findMissingPaths(set []string, paths map[string]struct{}) ([]string, error) {
|
||||
paths, err := evaluateToExistingPaths(paths)
|
||||
set, allowAny, err := evaluatePaths(set)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if allowAny {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
paths, err = evaluateToExistingPaths(paths)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -335,11 +342,6 @@ func findMissingPaths(set []string, paths map[string]struct{}) ([]string, error)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
set, err = evaluatePaths(set)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out := make([]string, 0, len(paths))
|
||||
loop0:
|
||||
for p := range paths {
|
||||
@@ -441,6 +443,27 @@ func removeCommonPaths(in, common []string) []string {
|
||||
return filtered
|
||||
}
|
||||
|
||||
func evaluatePaths(in []string) ([]string, bool, error) {
|
||||
out := make([]string, 0, len(in))
|
||||
allowAny := false
|
||||
for _, p := range in {
|
||||
if p == "*" {
|
||||
allowAny = true
|
||||
continue
|
||||
}
|
||||
v, err := filepath.Abs(p)
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrapf(err, "failed to evaluate path %q", p)
|
||||
}
|
||||
v, err = filepath.EvalSymlinks(v)
|
||||
if err != nil {
|
||||
return nil, false, errors.Wrapf(err, "failed to evaluate path %q", p)
|
||||
}
|
||||
out = append(out, v)
|
||||
}
|
||||
return out, allowAny, nil
|
||||
}
|
||||
|
||||
func evaluateToExistingPaths(in map[string]struct{}) (map[string]struct{}, error) {
|
||||
m := make(map[string]struct{}, len(in))
|
||||
for p := range in {
|
||||
|
Reference in New Issue
Block a user