Skip to content

Commit

Permalink
Merge pull request #239 from aaronlehmann/copy-include-exclude
Browse files Browse the repository at this point in the history
Add includePatterns and excludePatterns support for copy
  • Loading branch information
aaronlehmann authored Jun 2, 2021
2 parents 53c7d05 + 948a21a commit 0bca4d2
Show file tree
Hide file tree
Showing 9 changed files with 274 additions and 844 deletions.
2 changes: 2 additions & 0 deletions builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ var (
"chown": codegen.UtilChown{},
"chmod": codegen.UtilChmod{},
"createdTime": codegen.UtilCreatedTime{},
"includePatterns": codegen.CopyIncludePatterns{},
"excludePatterns": codegen.CopyExcludePatterns{},
},
"option::localRun": map[string]parser.Callable{
"ignoreError": codegen.IgnoreError{},
Expand Down
26 changes: 26 additions & 0 deletions builtin/lookup.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions codegen/builtin_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,28 @@ func (sep SecretExcludePatterns) Call(ctx context.Context, cln *client.Client, r
return ret.Set(append(retOpts, &SecretExcludePatterns{patterns}))
}

type CopyIncludePatterns struct{}

func (iip CopyIncludePatterns) Call(ctx context.Context, cln *client.Client, ret Register, opts Option, patterns ...string) error {
retOpts, err := ret.Option()
if err != nil {
return err
}

return ret.Set(append(retOpts, llbutil.WithIncludePatterns(patterns)))
}

type CopyExcludePatterns struct{}

func (sep CopyExcludePatterns) Call(ctx context.Context, cln *client.Client, ret Register, opts Option, patterns ...string) error {
retOpts, err := ret.Option()
if err != nil {
return err
}

return ret.Set(append(retOpts, llbutil.WithExcludePatterns(patterns)))
}

type Readonly struct{}

func (r Readonly) Call(ctx context.Context, cln *client.Client, ret Register, opts Option) error {
Expand Down
19 changes: 19 additions & 0 deletions codegen/codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,25 @@ func TestCodeGen(t *testing.T) {
llb.IncludePatterns([]string{"codegen_test.go"}),
))
},
}, {
"copy file with patterns",
[]string{"default"},
`
fs default() {
copy scratch "/" "/foo" with option {
includePatterns "pat*"
excludePatterns "*pat"
}
}
`, "",
func(ctx context.Context, t *testing.T) solver.Request {
return Expect(t, llb.Scratch().File(
llb.Copy(llb.Scratch(), "/", "/foo", &llb.CopyInfo{
IncludePatterns: []string{"pat*"},
ExcludePatterns: []string{"*pat"},
}),
))
},
}, {
"local env",
[]string{"default"},
Expand Down
16 changes: 16 additions & 0 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
contentsOnly
createDestPath
createdTime "created"
excludePatterns "pattern"
followSymlinks
includePatterns "pattern"
unpack
}
}
Expand Down Expand Up @@ -81,11 +83,25 @@



#### <span class='hlb-type'>option::copy</span> <span class='hlb-name'>excludePatterns</span>(<span class='hlb-type'>string</span> <span class='hlb-variable'>pattern</span>)

!!! info "<span class='hlb-type'>string</span> <span class='hlb-variable'>pattern</span>"




#### <span class='hlb-type'>option::copy</span> <span class='hlb-name'>followSymlinks</span>()




#### <span class='hlb-type'>option::copy</span> <span class='hlb-name'>includePatterns</span>(<span class='hlb-type'>string</span> <span class='hlb-variable'>pattern</span>)

!!! info "<span class='hlb-type'>string</span> <span class='hlb-variable'>pattern</span>"




#### <span class='hlb-type'>option::copy</span> <span class='hlb-name'>unpack</span>()


Expand Down
25 changes: 15 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,38 @@ module github.com/openllb/hlb
go 1.12

require (
github.com/Microsoft/hcsshim/test v0.0.0-20210428000155-bf20b75af1b9 // indirect
github.com/alecthomas/participle v1.0.0-alpha2
github.com/containerd/containerd v1.4.1-0.20201117152358-0edc412565dc
github.com/containerd/containerd v1.5.0
github.com/containerd/fifo v1.0.0 // indirect
github.com/creachadair/jrpc2 v0.8.1
github.com/docker/buildx v0.3.2-0.20200410204309-f4ac640252b8
github.com/docker/cli v20.10.0-beta1.0.20201029214301-1d20b15adc38+incompatible
github.com/docker/cli v20.10.5+incompatible
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/go-metrics v0.0.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51
github.com/lithammer/dedent v1.1.0
github.com/logrusorgru/aurora v0.0.0-20191116043053-66b7ad493a23
github.com/mattn/go-isatty v0.0.12
github.com/mitchellh/go-homedir v1.1.0
github.com/moby/buildkit v0.8.0
github.com/moby/buildkit v0.8.2-0.20210601194713-8df5671844e0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.1
github.com/openllb/doxygen-parser v0.0.0-20201031162929-e0b5cceb2d0c
github.com/pkg/errors v0.9.1
github.com/sourcegraph/go-lsp v0.0.0-20200117082640-b19bb38222e2
github.com/stretchr/testify v1.5.1
github.com/tonistiigi/fsutil v0.0.0-20201103201449-0834f99b7b85
github.com/stretchr/testify v1.7.0
github.com/tonistiigi/fsutil v0.0.0-20210525040343-5dfbf5db66b9
github.com/urfave/cli/v2 v2.1.1
github.com/xlab/treeprint v1.0.0
golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
google.golang.org/grpc v1.29.1
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
google.golang.org/grpc v1.35.0
)

// includes the changes in github.com/slushie/fsutil v0.0.0-20200508061958-7d16a3dcbd1d
replace github.com/tonistiigi/fsutil => github.com/aaronlehmann/fsutil v0.0.0-20210601195957-d9292d6d3583

replace github.com/hashicorp/go-immutable-radix => github.com/tonistiigi/go-immutable-radix v0.0.0-20170803185627-826af9ccf0fe

replace github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305
Expand All @@ -47,4 +52,4 @@ replace k8s.io/client-go => k8s.io/client-go v0.0.0-20180806134042-1f13a808da65
// necessary for langserver with vscode
replace github.com/sourcegraph/go-lsp => github.com/radeksimko/go-lsp v0.0.0-20200223162147-9f2c54f29c9f

replace github.com/tonistiigi/fsutil => github.com/slushie/fsutil v0.0.0-20200508061958-7d16a3dcbd1d
//replace github.com/tonistiigi/fsutil => github.com/slushie/fsutil v0.0.0-20200508061958-7d16a3dcbd1d
Loading

0 comments on commit 0bca4d2

Please sign in to comment.