-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.go
More file actions
47 lines (38 loc) · 840 Bytes
/
run.go
File metadata and controls
47 lines (38 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package mkfile
import (
"context"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/frontend/gateway/client"
"github.com/pkg/errors"
)
var (
CopyOptions = &llb.CopyInfo{
FollowSymlinks: true,
CopyDirContentsOnly: true,
AttemptUnpack: false,
CreateDestPath: true,
AllowWildcard: true,
AllowEmptyWildcard: true,
}
)
func Run(ctx context.Context, c client.Client) (*client.Result, error) {
var dt []byte
content, ok := c.BuildOpts().Opts["content"]
if ok {
dt = []byte(content)
}
st := llb.Scratch().File(
llb.Mkfile("/out", 0600, dt),
)
def, err := st.Marshal()
if err != nil {
return nil, err
}
res, err := c.Solve(ctx, client.SolveRequest{
Definition: def.ToPB(),
})
if err != nil {
return nil, errors.Wrapf(err, "failed to solve")
}
return res, nil
}