remove generateID duplicates

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2017-10-03 16:13:35 -07:00
parent f419a8cd93
commit f706b13a3f
2 changed files with 4 additions and 22 deletions

View File

@ -2,8 +2,6 @@ package client
import (
"context"
"crypto/rand"
"encoding/hex"
"io"
"os"
"path/filepath"
@ -12,6 +10,7 @@ import (
controlapi "github.com/moby/buildkit/api/services/control"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/identity"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/filesync"
"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
}
ref := generateID()
ref := identity.NewID()
eg, ctx := errgroup.WithContext(ctx)
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()
}
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) {
for _, d := range localDirs {
fi, err := os.Stat(d)

View File

@ -1,8 +1,6 @@
package runcworker
import (
"crypto/rand"
"encoding/hex"
"encoding/json"
"io"
"os"
@ -14,6 +12,7 @@ import (
runc "github.com/containerd/go-runc"
"github.com/docker/docker/pkg/symlink"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/identity"
"github.com/moby/buildkit/worker"
"github.com/moby/buildkit/worker/oci"
"github.com/pkg/errors"
@ -62,7 +61,7 @@ func (w *runcworker) Exec(ctx context.Context, meta worker.Meta, root cache.Moun
return err
}
id := generateID()
id := identity.NewID()
bundle := filepath.Join(w.root, id)
if err := os.Mkdir(bundle, 0700); err != nil {
@ -148,11 +147,3 @@ func (s *forwardIO) Stdout() io.ReadCloser {
func (s *forwardIO) Stderr() io.ReadCloser {
return nil
}
func generateID() string {
b := make([]byte, 32)
if _, err := rand.Read(b); err != nil {
panic(err)
}
return hex.EncodeToString(b)
}