copy: support for include/exclude
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
parent
acc593f388
commit
57770d347f
@ -76,6 +76,10 @@ import "dagger.io/dagger"
|
|||||||
source: string | *"/"
|
source: string | *"/"
|
||||||
// Destination path (optional)
|
// Destination path (optional)
|
||||||
dest: string | *"/"
|
dest: string | *"/"
|
||||||
|
// Optionally exclude certain files
|
||||||
|
include: [...string]
|
||||||
|
// Optionally include certain files
|
||||||
|
exclude: [...string]
|
||||||
// Output of the operation
|
// Output of the operation
|
||||||
output: dagger.#FS
|
output: dagger.#FS
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,10 @@ import (
|
|||||||
contents: dagger.#FS
|
contents: dagger.#FS
|
||||||
source: string | *"/"
|
source: string | *"/"
|
||||||
dest: string | *"/"
|
dest: string | *"/"
|
||||||
|
// Optionally exclude certain files
|
||||||
|
include: [...string]
|
||||||
|
// Optionally include certain files
|
||||||
|
exclude: [...string]
|
||||||
|
|
||||||
// Execute copy operation
|
// Execute copy operation
|
||||||
_copy: core.#Copy & {
|
_copy: core.#Copy & {
|
||||||
@ -52,6 +56,8 @@ import (
|
|||||||
"contents": contents
|
"contents": contents
|
||||||
"source": source
|
"source": source
|
||||||
"dest": dest
|
"dest": dest
|
||||||
|
"include": include
|
||||||
|
"exclude": exclude
|
||||||
}
|
}
|
||||||
|
|
||||||
output: #Image & {
|
output: #Image & {
|
||||||
|
@ -49,18 +49,31 @@ func (t *copyTask) Run(ctx context.Context, pctx *plancontext.Context, s *solver
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var filters struct {
|
||||||
|
Include []string
|
||||||
|
Exclude []string
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := v.Decode(&filters); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: allow more configurable llb options
|
||||||
|
// For now we define the following convenience presets.
|
||||||
|
opts := &llb.CopyInfo{
|
||||||
|
CopyDirContentsOnly: true,
|
||||||
|
CreateDestPath: true,
|
||||||
|
AllowWildcard: true,
|
||||||
|
IncludePatterns: filters.Include,
|
||||||
|
ExcludePatterns: filters.Exclude,
|
||||||
|
}
|
||||||
|
|
||||||
outputState := inputState.File(
|
outputState := inputState.File(
|
||||||
llb.Copy(
|
llb.Copy(
|
||||||
contentsState,
|
contentsState,
|
||||||
sourcePath,
|
sourcePath,
|
||||||
destPath,
|
destPath,
|
||||||
// FIXME: allow more configurable llb options
|
opts,
|
||||||
// For now we define the following convenience presets:
|
|
||||||
&llb.CopyInfo{
|
|
||||||
CopyDirContentsOnly: true,
|
|
||||||
CreateDestPath: true,
|
|
||||||
AllowWildcard: true,
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
withCustomName(v, "Copy %s %s", sourcePath, destPath),
|
withCustomName(v, "Copy %s %s", sourcePath, destPath),
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user