diff --git a/client/llb/fileop.go b/client/llb/fileop.go index 77127d1518d2a..565dab80d43d2 100644 --- a/client/llb/fileop.go +++ b/client/llb/fileop.go @@ -56,6 +56,10 @@ type subAction interface { toProtoAction(context.Context, string, pb.InputIndex) (pb.IsFileAction, error) } +type capAdder interface { + addCaps(*FileOp) +} + type FileAction struct { state *State prev *FileAction @@ -500,6 +504,15 @@ func (a *fileActionCopy) sourcePath(ctx context.Context) (string, error) { return p, nil } +func (a *fileActionCopy) addCaps(f *FileOp) { + if len(a.info.IncludePatterns) != 0 { + addCap(&f.constraints, pb.CapFileCopyIncludePatterns) + } + if len(a.info.ExcludePatterns) != 0 { + addCap(&f.constraints, pb.CapFileCopyExcludePatterns) + } +} + type CreatedTime time.Time func WithCreatedTime(t time.Time) CreatedTime { @@ -686,6 +699,10 @@ func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, [] pop.Inputs = state.inputs for i, st := range state.actions { + if adder, isCapAdder := st.action.(capAdder); isCapAdder { + adder.addCaps(f) + } + output := pb.OutputIndex(-1) if i+1 == len(state.actions) { output = 0 diff --git a/solver/pb/caps.go b/solver/pb/caps.go index 5f9bc51808ce0..9784a0a3c0de0 100644 --- a/solver/pb/caps.go +++ b/solver/pb/caps.go @@ -50,8 +50,10 @@ const ( CapExecMetaSecurityDeviceWhitelistV1 apicaps.CapID = "exec.meta.security.devices.v1" - CapFileBase apicaps.CapID = "file.base" - CapFileRmWildcard apicaps.CapID = "file.rm.wildcard" + CapFileBase apicaps.CapID = "file.base" + CapFileRmWildcard apicaps.CapID = "file.rm.wildcard" + CapFileCopyIncludePatterns apicaps.CapID = "file.copy.includepatterns" + CapFileCopyExcludePatterns apicaps.CapID = "file.copy.excludepatterns" CapConstraints apicaps.CapID = "constraints" CapPlatform apicaps.CapID = "platform" @@ -288,6 +290,18 @@ func init() { Status: apicaps.CapStatusExperimental, }) + Caps.Init(apicaps.Cap{ + ID: CapFileCopyIncludePatterns, + Enabled: true, + Status: apicaps.CapStatusExperimental, + }) + + Caps.Init(apicaps.Cap{ + ID: CapFileCopyExcludePatterns, + Enabled: true, + Status: apicaps.CapStatusExperimental, + }) + Caps.Init(apicaps.Cap{ ID: CapConstraints, Enabled: true,