commit
a069e4037e
|
@ -2,8 +2,6 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
|
||||||
"encoding/hex"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -12,6 +10,7 @@ import (
|
||||||
|
|
||||||
controlapi "github.com/moby/buildkit/api/services/control"
|
controlapi "github.com/moby/buildkit/api/services/control"
|
||||||
"github.com/moby/buildkit/client/llb"
|
"github.com/moby/buildkit/client/llb"
|
||||||
|
"github.com/moby/buildkit/identity"
|
||||||
"github.com/moby/buildkit/session"
|
"github.com/moby/buildkit/session"
|
||||||
"github.com/moby/buildkit/session/filesync"
|
"github.com/moby/buildkit/session/filesync"
|
||||||
"github.com/moby/buildkit/session/grpchijack"
|
"github.com/moby/buildkit/session/grpchijack"
|
||||||
|
@ -52,7 +51,7 @@ func (c *Client) Solve(ctx context.Context, def *llb.Definition, opt SolveOpt, s
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ref := generateID()
|
ref := identity.NewID()
|
||||||
eg, ctx := errgroup.WithContext(ctx)
|
eg, ctx := errgroup.WithContext(ctx)
|
||||||
|
|
||||||
statusContext, cancelStatus := context.WithCancel(context.Background())
|
statusContext, cancelStatus := context.WithCancel(context.Background())
|
||||||
|
@ -159,14 +158,6 @@ func (c *Client) Solve(ctx context.Context, def *llb.Definition, opt SolveOpt, s
|
||||||
return eg.Wait()
|
return eg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateID() string {
|
|
||||||
b := make([]byte, 32)
|
|
||||||
if _, err := rand.Read(b); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return hex.EncodeToString(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareSyncedDirs(defs [][]byte, localDirs map[string]string) ([]filesync.SyncedDir, error) {
|
func prepareSyncedDirs(defs [][]byte, localDirs map[string]string) ([]filesync.SyncedDir, error) {
|
||||||
for _, d := range localDirs {
|
for _, d := range localDirs {
|
||||||
fi, err := os.Stat(d)
|
fi, err := os.Stat(d)
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package runcworker
|
package runcworker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -14,6 +12,7 @@ import (
|
||||||
runc "github.com/containerd/go-runc"
|
runc "github.com/containerd/go-runc"
|
||||||
"github.com/docker/docker/pkg/symlink"
|
"github.com/docker/docker/pkg/symlink"
|
||||||
"github.com/moby/buildkit/cache"
|
"github.com/moby/buildkit/cache"
|
||||||
|
"github.com/moby/buildkit/identity"
|
||||||
"github.com/moby/buildkit/worker"
|
"github.com/moby/buildkit/worker"
|
||||||
"github.com/moby/buildkit/worker/oci"
|
"github.com/moby/buildkit/worker/oci"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
@ -62,7 +61,7 @@ func (w *runcworker) Exec(ctx context.Context, meta worker.Meta, root cache.Moun
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
id := generateID()
|
id := identity.NewID()
|
||||||
bundle := filepath.Join(w.root, id)
|
bundle := filepath.Join(w.root, id)
|
||||||
|
|
||||||
if err := os.Mkdir(bundle, 0700); err != nil {
|
if err := os.Mkdir(bundle, 0700); err != nil {
|
||||||
|
@ -148,11 +147,3 @@ func (s *forwardIO) Stdout() io.ReadCloser {
|
||||||
func (s *forwardIO) Stderr() io.ReadCloser {
|
func (s *forwardIO) Stderr() io.ReadCloser {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateID() string {
|
|
||||||
b := make([]byte, 32)
|
|
||||||
if _, err := rand.Read(b); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
return hex.EncodeToString(b)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue