Merge pull request #41607 from cpuguy83/use_head_for_manifest_by_tag
cache manifests on pull
diff --git a/Jenkinsfile b/Jenkinsfile
index c2b17b1..ec5c651 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -214,14 +214,6 @@
'''
}
}
- stage("Build e2e image") {
- steps {
- sh '''
- echo "Building e2e image"
- docker build --build-arg DOCKER_GITCOMMIT=${GIT_COMMIT} -t moby-e2e-test -f Dockerfile.e2e .
- '''
- }
- }
}
post {
diff --git a/api/types/mount/mount.go b/api/types/mount/mount.go
index ab4446b..443b8d0 100644
--- a/api/types/mount/mount.go
+++ b/api/types/mount/mount.go
@@ -113,7 +113,7 @@
// TODO(stevvooe): There are several more tmpfs flags, specified in the
// daemon, that are accepted. Only the most basic are added for now.
//
- // From docker/docker/pkg/mount/flags.go:
+ // From https://github.com/moby/sys/blob/mount/v0.1.1/mount/flags.go#L47-L56
//
// var validFlags = map[string]bool{
// "": true,
diff --git a/builder/builder-next/adapters/containerimage/pull.go b/builder/builder-next/adapters/containerimage/pull.go
index 65ee7a3..733a337 100644
--- a/builder/builder-next/adapters/containerimage/pull.go
+++ b/builder/builder-next/adapters/containerimage/pull.go
@@ -9,7 +9,6 @@
"path"
"runtime"
"sync"
- "sync/atomic"
"time"
"github.com/containerd/containerd/content"
@@ -31,6 +30,7 @@
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/solver"
"github.com/moby/buildkit/source"
"github.com/moby/buildkit/util/flightcontrol"
"github.com/moby/buildkit/util/imageutil"
@@ -59,18 +59,12 @@
// Source is the source implementation for accessing container images
type Source struct {
SourceOpt
- g flightcontrol.Group
- resolverCache *resolverCache
+ g flightcontrol.Group
}
// NewSource creates a new image source
func NewSource(opt SourceOpt) (*Source, error) {
- is := &Source{
- SourceOpt: opt,
- resolverCache: newResolverCache(),
- }
-
- return is, nil
+ return &Source{SourceOpt: opt}, nil
}
// ID returns image scheme identifier
@@ -78,16 +72,6 @@
return source.DockerImageScheme
}
-func (is *Source) getResolver(hosts docker.RegistryHosts, ref string, sm *session.Manager, g session.Group) remotes.Resolver {
- if res := is.resolverCache.Get(ref, g); res != nil {
- return res
- }
- auth := resolver.NewSessionAuthenticator(sm, g)
- r := resolver.New(hosts, auth)
- r = is.resolverCache.Add(ref, auth, r, g)
- return r
-}
-
func (is *Source) resolveLocal(refStr string) (*image.Image, error) {
ref, err := distreference.ParseNormalizedNamed(refStr)
if err != nil {
@@ -109,8 +93,15 @@
dgst digest.Digest
dt []byte
}
- res, err := is.g.Do(ctx, ref, func(ctx context.Context) (interface{}, error) {
- dgst, dt, err := imageutil.Config(ctx, ref, is.getResolver(is.RegistryHosts, ref, sm, g), is.ContentStore, nil, platform)
+ p := platforms.DefaultSpec()
+ if platform != nil {
+ p = *platform
+ }
+ // key is used to synchronize resolutions that can happen in parallel when doing multi-stage.
+ key := "getconfig::" + ref + "::" + platforms.Format(p)
+ res, err := is.g.Do(ctx, key, func(ctx context.Context) (interface{}, error) {
+ res := resolver.DefaultPool.GetResolver(is.RegistryHosts, ref, "pull", sm, g)
+ dgst, dt, err := imageutil.Config(ctx, ref, res, is.ContentStore, nil, platform)
if err != nil {
return nil, err
}
@@ -168,7 +159,7 @@
}
// Resolve returns access to pulling for an identifier
-func (is *Source) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager) (source.SourceInstance, error) {
+func (is *Source) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager, vtx solver.Vertex) (source.SourceInstance, error) {
imageIdentifier, ok := id.(*source.ImageIdentifier)
if !ok {
return nil, errors.Errorf("invalid image identifier %v", id)
@@ -191,29 +182,20 @@
type puller struct {
is *Source
- resolveOnce sync.Once
resolveLocalOnce sync.Once
src *source.ImageIdentifier
desc ocispec.Descriptor
ref string
- resolveErr error
- resolverInstance remotes.Resolver
- resolverOnce sync.Once
config []byte
platform ocispec.Platform
sm *session.Manager
}
func (p *puller) resolver(g session.Group) remotes.Resolver {
- p.resolverOnce.Do(func() {
- if p.resolverInstance == nil {
- p.resolverInstance = p.is.getResolver(p.is.RegistryHosts, p.src.Reference.String(), p.sm, g)
- }
- })
- return p.resolverInstance
+ return resolver.DefaultPool.GetResolver(p.is.RegistryHosts, p.src.Reference.String(), "pull", p.sm, g)
}
-func (p *puller) mainManifestKey(dgst digest.Digest, platform ocispec.Platform) (digest.Digest, error) {
+func (p *puller) mainManifestKey(platform ocispec.Platform) (digest.Digest, error) {
dt, err := json.Marshal(struct {
Digest digest.Digest
OS string
@@ -271,22 +253,23 @@
}
func (p *puller) resolve(ctx context.Context, g session.Group) error {
- p.resolveOnce.Do(func() {
+ // key is used to synchronize resolutions that can happen in parallel when doing multi-stage.
+ key := "resolve::" + p.ref + "::" + platforms.Format(p.platform)
+ _, err := p.is.g.Do(ctx, key, func(ctx context.Context) (_ interface{}, err error) {
resolveProgressDone := oneOffProgress(ctx, "resolve "+p.src.Reference.String())
+ defer func() {
+ resolveProgressDone(err)
+ }()
ref, err := distreference.ParseNormalizedNamed(p.src.Reference.String())
if err != nil {
- p.resolveErr = err
- _ = resolveProgressDone(err)
- return
+ return nil, err
}
if p.desc.Digest == "" && p.config == nil {
origRef, desc, err := p.resolver(g).Resolve(ctx, ref.String())
if err != nil {
- p.resolveErr = err
- _ = resolveProgressDone(err)
- return
+ return nil, err
}
p.desc = desc
@@ -301,65 +284,61 @@
if p.config == nil && p.desc.MediaType != images.MediaTypeDockerSchema1Manifest {
ref, err := distreference.WithDigest(ref, p.desc.Digest)
if err != nil {
- p.resolveErr = err
- _ = resolveProgressDone(err)
- return
+ return nil, err
}
_, dt, err := p.is.ResolveImageConfig(ctx, ref.String(), llb.ResolveImageConfigOpt{Platform: &p.platform, ResolveMode: resolveModeToString(p.src.ResolveMode)}, p.sm, g)
if err != nil {
- p.resolveErr = err
- _ = resolveProgressDone(err)
- return
+ return nil, err
}
p.config = dt
}
- _ = resolveProgressDone(nil)
+ return nil, nil
})
- return p.resolveErr
+ return err
}
-func (p *puller) CacheKey(ctx context.Context, g session.Group, index int) (string, bool, error) {
+func (p *puller) CacheKey(ctx context.Context, g session.Group, index int) (string, solver.CacheOpts, bool, error) {
p.resolveLocal()
if p.desc.Digest != "" && index == 0 {
- dgst, err := p.mainManifestKey(p.desc.Digest, p.platform)
+ dgst, err := p.mainManifestKey(p.platform)
if err != nil {
- return "", false, err
+ return "", nil, false, err
}
- return dgst.String(), false, nil
+ return dgst.String(), nil, false, nil
}
if p.config != nil {
k := cacheKeyFromConfig(p.config).String()
if k == "" {
- return digest.FromBytes(p.config).String(), true, nil
+ return digest.FromBytes(p.config).String(), nil, true, nil
}
- return k, true, nil
+ return k, nil, true, nil
}
if err := p.resolve(ctx, g); err != nil {
- return "", false, err
+ return "", nil, false, err
}
if p.desc.Digest != "" && index == 0 {
- dgst, err := p.mainManifestKey(p.desc.Digest, p.platform)
+ dgst, err := p.mainManifestKey(p.platform)
if err != nil {
- return "", false, err
+ return "", nil, false, err
}
- return dgst.String(), false, nil
+ return dgst.String(), nil, false, nil
}
k := cacheKeyFromConfig(p.config).String()
if k == "" {
- dgst, err := p.mainManifestKey(p.desc.Digest, p.platform)
+ dgst, err := p.mainManifestKey(p.platform)
if err != nil {
- return "", false, err
+ return "", nil, false, err
}
- return dgst.String(), true, nil
+ return dgst.String(), nil, true, nil
}
- return k, true, nil
+ return k, nil, true, nil
}
func (p *puller) getRef(ctx context.Context, diffIDs []layer.DiffID, opts ...cache.RefOption) (cache.ImmutableRef, error) {
@@ -426,10 +405,6 @@
}
platform := platforms.Only(p.platform)
- // workaround for GCR bug that requires a request to manifest endpoint for authentication to work.
- // if current resolver has not used manifests do a dummy request.
- // in most cases resolver should be cached and extra request is not needed.
- ensureManifestRequested(ctx, p.resolver(g), p.ref)
var (
schema1Converter *schema1.Converter
@@ -845,97 +820,6 @@
return ""
}
-type resolverCache struct {
- mu sync.Mutex
- m map[string]cachedResolver
-}
-
-type cachedResolver struct {
- counter int64 // needs to be 64bit aligned for 32bit systems
- timeout time.Time
- remotes.Resolver
- auth *resolver.SessionAuthenticator
-}
-
-func (cr *cachedResolver) Resolve(ctx context.Context, ref string) (name string, desc ocispec.Descriptor, err error) {
- atomic.AddInt64(&cr.counter, 1)
- return cr.Resolver.Resolve(ctx, ref)
-}
-
-func (r *resolverCache) Add(ref string, auth *resolver.SessionAuthenticator, resolver remotes.Resolver, g session.Group) *cachedResolver {
- r.mu.Lock()
- defer r.mu.Unlock()
-
- ref = r.repo(ref)
-
- cr, ok := r.m[ref]
- cr.timeout = time.Now().Add(time.Minute)
- if ok {
- cr.auth.AddSession(g)
- return &cr
- }
-
- cr.Resolver = resolver
- cr.auth = auth
- r.m[ref] = cr
- return &cr
-}
-
-func (r *resolverCache) repo(refStr string) string {
- ref, err := distreference.ParseNormalizedNamed(refStr)
- if err != nil {
- return refStr
- }
- return ref.Name()
-}
-
-func (r *resolverCache) Get(ref string, g session.Group) *cachedResolver {
- r.mu.Lock()
- defer r.mu.Unlock()
-
- ref = r.repo(ref)
-
- cr, ok := r.m[ref]
- if ok {
- cr.auth.AddSession(g)
- return &cr
- }
- return nil
-}
-
-func (r *resolverCache) clean(now time.Time) {
- r.mu.Lock()
- for k, cr := range r.m {
- if now.After(cr.timeout) {
- delete(r.m, k)
- }
- }
- r.mu.Unlock()
-}
-
-func newResolverCache() *resolverCache {
- rc := &resolverCache{
- m: map[string]cachedResolver{},
- }
- t := time.NewTicker(time.Minute)
- go func() {
- for {
- rc.clean(<-t.C)
- }
- }()
- return rc
-}
-
-func ensureManifestRequested(ctx context.Context, res remotes.Resolver, ref string) {
- cr, ok := res.(*cachedResolver)
- if !ok {
- return
- }
- if atomic.LoadInt64(&cr.counter) == 0 {
- res.Resolve(ctx, ref)
- }
-}
-
func platformMatches(img *image.Image, p *ocispec.Platform) bool {
if img.Architecture != p.Architecture {
return false
diff --git a/builder/builder-next/controller.go b/builder/builder-next/controller.go
index 5decff8..5aac0cb 100644
--- a/builder/builder-next/controller.go
+++ b/builder/builder-next/controller.go
@@ -34,7 +34,7 @@
"github.com/moby/buildkit/frontend/gateway/forwarder"
containerdsnapshot "github.com/moby/buildkit/snapshot/containerd"
"github.com/moby/buildkit/solver/bboltcachestorage"
- "github.com/moby/buildkit/util/binfmt_misc"
+ "github.com/moby/buildkit/util/archutil"
"github.com/moby/buildkit/util/entitlements"
"github.com/moby/buildkit/util/leaseutil"
"github.com/moby/buildkit/worker"
@@ -166,7 +166,7 @@
return nil, errors.Errorf("snapshotter doesn't support differ")
}
- p, err := parsePlatforms(binfmt_misc.SupportedPlatforms(true))
+ p, err := parsePlatforms(archutil.SupportedPlatforms(true))
if err != nil {
return nil, err
}
diff --git a/builder/builder-next/executor_unix.go b/builder/builder-next/executor_unix.go
index d684b9f..c052ec7 100644
--- a/builder/builder-next/executor_unix.go
+++ b/builder/builder-next/executor_unix.go
@@ -95,11 +95,11 @@
iface.ep = ep
}
-func (iface *lnInterface) Set(s *specs.Spec) {
+func (iface *lnInterface) Set(s *specs.Spec) error {
<-iface.ready
if iface.err != nil {
logrus.WithError(iface.err).Error("failed to set networking spec")
- return
+ return iface.err
}
shortNetCtlrID := stringid.TruncateID(iface.provider.NetworkController.ID())
// attach netns to bridge within the container namespace, using reexec in a prestart hook
@@ -109,6 +109,7 @@
Args: []string{"libnetwork-setkey", "-exec-root=" + iface.provider.Config().Daemon.ExecRoot, iface.sbx.ContainerID(), shortNetCtlrID},
}},
}
+ return nil
}
func (iface *lnInterface) Close() error {
diff --git a/builder/builder-next/executor_windows.go b/builder/builder-next/executor_windows.go
index 5f33bcb..f63d8ab 100644
--- a/builder/builder-next/executor_windows.go
+++ b/builder/builder-next/executor_windows.go
@@ -7,7 +7,6 @@
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/libnetwork"
- "github.com/moby/buildkit/cache"
"github.com/moby/buildkit/executor"
"github.com/moby/buildkit/executor/oci"
)
@@ -19,7 +18,7 @@
type winExecutor struct {
}
-func (w *winExecutor) Run(ctx context.Context, id string, root cache.Mountable, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
+func (w *winExecutor) Run(ctx context.Context, id string, root executor.Mount, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
return errors.New("buildkit executor not implemented for windows")
}
diff --git a/builder/builder-next/exporter/writer.go b/builder/builder-next/exporter/writer.go
index 64d260f..53305ca 100644
--- a/builder/builder-next/exporter/writer.go
+++ b/builder/builder-next/exporter/writer.go
@@ -26,7 +26,7 @@
}
img.RootFS.Type = "layers"
img.Config.WorkingDir = "/"
- img.Config.Env = []string{"PATH=" + system.DefaultPathEnv}
+ img.Config.Env = []string{"PATH=" + system.DefaultPathEnvUnix}
dt, err := json.Marshal(img)
return dt, errors.Wrap(err, "failed to create empty image config")
}
diff --git a/builder/builder-next/worker/worker.go b/builder/builder-next/worker/worker.go
index f8c3ef9..76a4470 100644
--- a/builder/builder-next/worker/worker.go
+++ b/builder/builder-next/worker/worker.go
@@ -33,13 +33,15 @@
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/solver/llbsolver/mounts"
"github.com/moby/buildkit/solver/llbsolver/ops"
"github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/source"
"github.com/moby/buildkit/source/git"
"github.com/moby/buildkit/source/http"
"github.com/moby/buildkit/source/local"
- "github.com/moby/buildkit/util/binfmt_misc"
+ "github.com/moby/buildkit/util/archutil"
+ "github.com/moby/buildkit/util/compression"
"github.com/moby/buildkit/util/contentutil"
"github.com/moby/buildkit/util/progress"
digest "github.com/opencontainers/go-digest"
@@ -147,7 +149,7 @@
for _, p := range w.Opt.Platforms {
pm[platforms.Format(p)] = struct{}{}
}
- for _, p := range binfmt_misc.SupportedPlatforms(noCache) {
+ for _, p := range archutil.SupportedPlatforms(noCache) {
if _, ok := pm[p]; !ok {
pp, _ := platforms.Parse(p)
w.Opt.Platforms = append(w.Opt.Platforms, pp)
@@ -170,13 +172,18 @@
return w.Opt.ContentStore
}
+// MetadataStore returns the metadata store
+func (w *Worker) MetadataStore() *metadata.Store {
+ return w.Opt.MetadataStore
+}
+
// LoadRef loads a reference by ID
-func (w *Worker) LoadRef(id string, hidden bool) (cache.ImmutableRef, error) {
+func (w *Worker) LoadRef(ctx context.Context, id string, hidden bool) (cache.ImmutableRef, error) {
var opts []cache.RefOption
if hidden {
opts = append(opts, cache.NoUpdateLastUsed)
}
- return w.CacheManager().Get(context.TODO(), id, opts...)
+ return w.CacheManager().Get(ctx, id, opts...)
}
// ResolveOp converts a LLB vertex into a LLB operation
@@ -186,9 +193,9 @@
case *pb.Op_Source:
return ops.NewSourceOp(v, op, baseOp.Platform, w.SourceManager, sm, w)
case *pb.Op_Exec:
- return ops.NewExecOp(v, op, baseOp.Platform, w.CacheManager(), sm, w.MetadataStore, w.Executor(), w)
+ return ops.NewExecOp(v, op, baseOp.Platform, w.CacheManager(), sm, w.Opt.MetadataStore, w.Executor(), w)
case *pb.Op_File:
- return ops.NewFileOp(v, op, w.CacheManager(), w.MetadataStore, w)
+ return ops.NewFileOp(v, op, w.CacheManager(), w.Opt.MetadataStore, w)
case *pb.Op_Build:
return ops.NewBuildOp(v, op, s, w)
}
@@ -230,7 +237,7 @@
}
// GetRemote returns a remote snapshot reference for a local one
-func (w *Worker) GetRemote(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool) (*solver.Remote, error) {
+func (w *Worker) GetRemote(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool, _ compression.Type, _ session.Group) (*solver.Remote, error) {
var diffIDs []layer.DiffID
var err error
if !createIfNeeded {
@@ -265,13 +272,13 @@
// PruneCacheMounts removes the current cache snapshots for specified IDs
func (w *Worker) PruneCacheMounts(ctx context.Context, ids []string) error {
- mu := ops.CacheMountsLocker()
+ mu := mounts.CacheMountsLocker()
mu.Lock()
defer mu.Unlock()
for _, id := range ids {
id = "cache-dir:" + id
- sis, err := w.MetadataStore.Search(id)
+ sis, err := w.Opt.MetadataStore.Search(id)
if err != nil {
return err
}
@@ -300,7 +307,7 @@
}
}
- ops.ClearActiveCacheMounts()
+ mounts.ClearActiveCacheMounts()
return nil
}
diff --git a/builder/dockerfile/builder.go b/builder/dockerfile/builder.go
index c7784e2..a0bfb28 100644
--- a/builder/dockerfile/builder.go
+++ b/builder/dockerfile/builder.go
@@ -85,10 +85,6 @@
ctx, cancel := context.WithCancel(ctx)
defer cancel()
- if config.Options.SessionID != "" {
- return nil, errors.New("experimental session with v1 builder is no longer supported, use builder version v2 (BuildKit) instead")
- }
-
builderOptions := builderOptions{
Options: config.Options,
ProgressWriter: config.ProgressWriter,
@@ -239,8 +235,10 @@
}); err != nil {
return err
}
- args.AddArg(meta.Key, meta.Value)
- args.AddMetaArg(meta.Key, meta.Value)
+ for _, arg := range meta.Args {
+ args.AddArg(arg.Key, arg.Value)
+ args.AddMetaArg(arg.Key, arg.Value)
+ }
return nil
}
diff --git a/builder/dockerfile/dispatchers.go b/builder/dockerfile/dispatchers.go
index bf28a66..36335df 100644
--- a/builder/dockerfile/dispatchers.go
+++ b/builder/dockerfile/dispatchers.go
@@ -587,14 +587,21 @@
// to builder using the --build-arg flag for expansion/substitution or passing to 'run'.
// Dockerfile author may optionally set a default value of this variable.
func dispatchArg(d dispatchRequest, c *instructions.ArgCommand) error {
-
- commitStr := "ARG " + c.Key
- if c.Value != nil {
- commitStr += "=" + *c.Value
+ var commitStr strings.Builder
+ commitStr.WriteString("ARG ")
+ for i, arg := range c.Args {
+ if i > 0 {
+ commitStr.WriteString(" ")
+ }
+ commitStr.WriteString(arg.Key)
+ if arg.Value != nil {
+ commitStr.WriteString("=")
+ commitStr.WriteString(*arg.Value)
+ }
+ d.state.buildArgs.AddArg(arg.Key, arg.Value)
}
- d.state.buildArgs.AddArg(c.Key, c.Value)
- return d.builder.commit(d.state, commitStr)
+ return d.builder.commit(d.state, commitStr.String())
}
// SHELL powershell -command
diff --git a/builder/dockerfile/dispatchers_test.go b/builder/dockerfile/dispatchers_test.go
index 03e0245..d5f6bb9 100644
--- a/builder/dockerfile/dispatchers_test.go
+++ b/builder/dockerfile/dispatchers_test.go
@@ -139,10 +139,10 @@
args := NewBuildArgs(make(map[string]*string))
val := "sometag"
- metaArg := instructions.ArgCommand{KeyValuePairOptional: instructions.KeyValuePairOptional{
+ metaArg := instructions.ArgCommand{Args: []instructions.KeyValuePairOptional{{
Key: "THETAG",
Value: &val,
- }}
+ }}}
cmd := &instructions.Stage{
BaseName: "alpine:${THETAG}",
}
@@ -395,7 +395,7 @@
argName := "foo"
argVal := "bar"
- cmd := &instructions.ArgCommand{KeyValuePairOptional: instructions.KeyValuePairOptional{Key: argName, Value: &argVal}}
+ cmd := &instructions.ArgCommand{Args: []instructions.KeyValuePairOptional{{Key: argName, Value: &argVal}}}
err := dispatch(sb, cmd)
assert.NilError(t, err)
diff --git a/builder/dockerfile/internals_linux.go b/builder/dockerfile/internals_linux.go
index 5dbd86f..269f722 100644
--- a/builder/dockerfile/internals_linux.go
+++ b/builder/dockerfile/internals_linux.go
@@ -6,7 +6,7 @@
"strings"
"github.com/docker/docker/pkg/idtools"
- "github.com/docker/docker/pkg/symlink"
+ "github.com/moby/sys/symlink"
lcUser "github.com/opencontainers/runc/libcontainer/user"
"github.com/pkg/errors"
)
diff --git a/builder/dockerignore/deprecated.go b/builder/dockerignore/deprecated.go
new file mode 100644
index 0000000..e387cc8
--- /dev/null
+++ b/builder/dockerignore/deprecated.go
@@ -0,0 +1,17 @@
+// Package dockerignore is deprecated. Use github.com/moby/buildkit/frontend/dockerfile/dockerignore instead.
+package dockerignore
+
+import (
+ "io"
+
+ "github.com/moby/buildkit/frontend/dockerfile/dockerignore"
+)
+
+// ReadAll reads a .dockerignore file and returns the list of file patterns
+// to ignore. Note this will trim whitespace from each line as well
+// as use GO's "clean" func to get the shortest/cleanest path for each.
+//
+// Deprecated: use github.com/moby/buildkit/frontend/dockerfile/dockerignore.ReadAll instead.
+func ReadAll(reader io.Reader) ([]string, error) {
+ return dockerignore.ReadAll(reader)
+}
diff --git a/builder/dockerignore/dockerignore_test.go b/builder/dockerignore/dockerignore_test.go
deleted file mode 100644
index 655bd6f..0000000
--- a/builder/dockerignore/dockerignore_test.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package dockerignore // import "github.com/docker/docker/builder/dockerignore"
-
-import (
- "fmt"
- "io/ioutil"
- "os"
- "path/filepath"
- "testing"
-)
-
-func TestReadAll(t *testing.T) {
- tmpDir, err := ioutil.TempDir("", "dockerignore-test")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpDir)
-
- di, err := ReadAll(nil)
- if err != nil {
- t.Fatalf("Expected not to have error, got %v", err)
- }
-
- if diLen := len(di); diLen != 0 {
- t.Fatalf("Expected to have zero dockerignore entry, got %d", diLen)
- }
-
- diName := filepath.Join(tmpDir, ".dockerignore")
- content := fmt.Sprintf("test1\n/test2\n/a/file/here\n\nlastfile\n# this is a comment\n! /inverted/abs/path\n!\n! \n")
- err = ioutil.WriteFile(diName, []byte(content), 0777)
- if err != nil {
- t.Fatal(err)
- }
-
- diFd, err := os.Open(diName)
- if err != nil {
- t.Fatal(err)
- }
- defer diFd.Close()
-
- di, err = ReadAll(diFd)
- if err != nil {
- t.Fatal(err)
- }
-
- if len(di) != 7 {
- t.Fatalf("Expected 7 entries, got %v", len(di))
- }
- if di[0] != "test1" {
- t.Fatal("First element is not test1")
- }
- if di[1] != "test2" { // according to https://docs.docker.com/engine/reference/builder/#dockerignore-file, /foo/bar should be treated as foo/bar
- t.Fatal("Second element is not test2")
- }
- if di[2] != "a/file/here" { // according to https://docs.docker.com/engine/reference/builder/#dockerignore-file, /foo/bar should be treated as foo/bar
- t.Fatal("Third element is not a/file/here")
- }
- if di[3] != "lastfile" {
- t.Fatal("Fourth element is not lastfile")
- }
- if di[4] != "!inverted/abs/path" {
- t.Fatal("Fifth element is not !inverted/abs/path")
- }
- if di[5] != "!" {
- t.Fatalf("Sixth element is not !, but %s", di[5])
- }
- if di[6] != "!" {
- t.Fatalf("Seventh element is not !, but %s", di[6])
- }
-}
diff --git a/builder/remotecontext/detect.go b/builder/remotecontext/detect.go
index a1953dd..9b126ef 100644
--- a/builder/remotecontext/detect.go
+++ b/builder/remotecontext/detect.go
@@ -11,10 +11,10 @@
"github.com/containerd/continuity/driver"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/builder"
- "github.com/docker/docker/builder/dockerignore"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/fileutils"
"github.com/docker/docker/pkg/urlutil"
+ "github.com/moby/buildkit/frontend/dockerfile/dockerignore"
"github.com/moby/buildkit/frontend/dockerfile/parser"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -33,12 +33,7 @@
case remoteURL == "":
remote, dockerfile, err = newArchiveRemote(config.Source, dockerfilePath)
case remoteURL == ClientSessionRemote:
- res, err := parser.Parse(config.Source)
- if err != nil {
- return nil, nil, errdefs.InvalidParameter(err)
- }
-
- return nil, res, nil
+ return nil, nil, errdefs.InvalidParameter(errors.New("experimental session with v1 builder is no longer supported, use builder version v2 (BuildKit) instead"))
case urlutil.IsGitURL(remoteURL):
remote, dockerfile, err = newGitRemote(remoteURL, dockerfilePath)
case urlutil.IsURL(remoteURL):
diff --git a/builder/remotecontext/git/gitutils.go b/builder/remotecontext/git/gitutils.go
index ffd5123..b3aba7f 100644
--- a/builder/remotecontext/git/gitutils.go
+++ b/builder/remotecontext/git/gitutils.go
@@ -9,7 +9,7 @@
"path/filepath"
"strings"
- "github.com/docker/docker/pkg/symlink"
+ "github.com/moby/sys/symlink"
"github.com/pkg/errors"
)
diff --git a/cmd/dockerd/config.go b/cmd/dockerd/config.go
index 8dfe8a3..73d5b81 100644
--- a/cmd/dockerd/config.go
+++ b/cmd/dockerd/config.go
@@ -97,11 +97,9 @@
conf.MaxDownloadAttempts = &maxDownloadAttempts
flags.StringVar(&conf.ContainerdNamespace, "containerd-namespace", daemon.ContainersNamespace, "Containerd namespace to use")
- if err := flags.MarkHidden("containerd-namespace"); err != nil {
- return err
- }
flags.StringVar(&conf.ContainerdPluginNamespace, "containerd-plugins-namespace", containerd.PluginNamespace, "Containerd namespace to use for plugins")
- return flags.MarkHidden("containerd-plugins-namespace")
+
+ return nil
}
func installRegistryServiceFlags(options *registry.ServiceOptions, flags *pflag.FlagSet) {
diff --git a/cmd/dockerd/config_unix.go b/cmd/dockerd/config_unix.go
index ec41714..2daad6e 100644
--- a/cmd/dockerd/config_unix.go
+++ b/cmd/dockerd/config_unix.go
@@ -5,11 +5,11 @@
import (
"os/exec"
+ "github.com/containerd/cgroups"
"github.com/docker/docker/daemon/config"
"github.com/docker/docker/opts"
"github.com/docker/docker/rootless"
units "github.com/docker/go-units"
- "github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/pkg/errors"
"github.com/spf13/pflag"
)
@@ -66,7 +66,7 @@
// Note that defaultUserlandProxyPath and honorXDG are configured according to the value of rootless.RunningWithRootlessKit, not the value of --rootless.
flags.BoolVar(&conf.Rootless, "rootless", rootless.RunningWithRootlessKit(), "Enable rootless mode; typically used with RootlessKit")
defaultCgroupNamespaceMode := "host"
- if cgroups.IsCgroup2UnifiedMode() {
+ if cgroups.Mode() == cgroups.Unified {
defaultCgroupNamespaceMode = "private"
}
flags.StringVar(&conf.CgroupNamespaceMode, "default-cgroupns-mode", defaultCgroupNamespaceMode, `Default mode for containers cgroup namespace ("host" | "private")`)
diff --git a/container/container.go b/container/container.go
index 5610c9b..df90a4e 100644
--- a/container/container.go
+++ b/container/container.go
@@ -32,13 +32,13 @@
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/signal"
- "github.com/docker/docker/pkg/symlink"
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/restartmanager"
"github.com/docker/docker/volume"
volumemounts "github.com/docker/docker/volume/mounts"
units "github.com/docker/go-units"
agentexec "github.com/docker/swarmkit/agent/exec"
+ "github.com/moby/sys/symlink"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
diff --git a/daemon/container_operations.go b/daemon/container_operations.go
index 4b63401..af69e04 100644
--- a/daemon/container_operations.go
+++ b/daemon/container_operations.go
@@ -118,7 +118,7 @@
// If the IP Address is a string called "host-gateway", replace this
// value with the IP address stored in the daemon level HostGatewayIP
// config variable
- if parts[1] == network.HostGatewayName {
+ if parts[1] == opts.HostGatewayName {
gateway := daemon.configStore.HostGatewayIP.String()
if gateway == "" {
return nil, fmt.Errorf("unable to derive the IP value for host-gateway")
diff --git a/daemon/daemon_unix.go b/daemon/daemon_unix.go
index efe8796..f483c7e 100644
--- a/daemon/daemon_unix.go
+++ b/daemon/daemon_unix.go
@@ -16,6 +16,7 @@
"strings"
"time"
+ "github.com/containerd/cgroups"
statsV1 "github.com/containerd/cgroups/stats/v1"
statsV2 "github.com/containerd/cgroups/v2/stats"
"github.com/containerd/containerd/sys"
@@ -43,7 +44,6 @@
"github.com/docker/libnetwork/options"
lntypes "github.com/docker/libnetwork/types"
"github.com/moby/sys/mount"
- "github.com/opencontainers/runc/libcontainer/cgroups"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/pkg/errors"
@@ -362,11 +362,11 @@
if hostConfig.CgroupnsMode.IsEmpty() {
// for cgroup v2: unshare cgroupns even for privileged containers
// https://github.com/containers/libpod/pull/4374#issuecomment-549776387
- if hostConfig.Privileged && !cgroups.IsCgroup2UnifiedMode() {
+ if hostConfig.Privileged && cgroups.Mode() != cgroups.Unified {
hostConfig.CgroupnsMode = containertypes.CgroupnsMode("host")
} else {
m := "host"
- if cgroups.IsCgroup2UnifiedMode() {
+ if cgroups.Mode() == cgroups.Unified {
m = "private"
}
if daemon.configStore != nil {
@@ -637,7 +637,7 @@
return true
}
// On cgroup v2 hosts, default to systemd driver
- if getCD(config) == "" && cgroups.IsCgroup2UnifiedMode() && IsRunningSystemd() {
+ if getCD(config) == "" && cgroups.Mode() == cgroups.Unified && IsRunningSystemd() {
return true
}
return false
@@ -758,7 +758,7 @@
}
}
- if conf.Rootless && UsingSystemd(conf) && !cgroups.IsCgroup2UnifiedMode() {
+ if conf.Rootless && UsingSystemd(conf) && cgroups.Mode() != cgroups.Unified {
return fmt.Errorf("exec-opt native.cgroupdriver=systemd requires cgroup v2 for rootless mode")
}
@@ -1711,3 +1711,7 @@
}
return sysinfo.New(quiet, opts...)
}
+
+func recursiveUnmount(target string) error {
+ return mount.RecursiveUnmount(target)
+}
diff --git a/daemon/daemon_windows.go b/daemon/daemon_windows.go
index aee48d3..38c2ab8 100644
--- a/daemon/daemon_windows.go
+++ b/daemon/daemon_windows.go
@@ -467,6 +467,10 @@
return nil
}
+func recursiveUnmount(_ string) error {
+ return nil
+}
+
func setupRemappedRoot(config *config.Config) (*idtools.IdentityMapping, error) {
return &idtools.IdentityMapping{}, nil
}
diff --git a/daemon/graphdriver/copy/copy_test.go b/daemon/graphdriver/copy/copy_test.go
index 491bf78..5fac6fc 100644
--- a/daemon/graphdriver/copy/copy_test.go
+++ b/daemon/graphdriver/copy/copy_test.go
@@ -53,7 +53,6 @@
}
dstPath := filepath.Join(dstDir, relPath)
- assert.NilError(t, err)
// If we add non-regular dirs and files to the test
// then we need to add more checks here.
diff --git a/daemon/graphdriver/zfs/zfs.go b/daemon/graphdriver/zfs/zfs.go
index 0c0daaf..21c271e 100644
--- a/daemon/graphdriver/zfs/zfs.go
+++ b/daemon/graphdriver/zfs/zfs.go
@@ -159,7 +159,7 @@
continue // may fail on fuse file systems
}
- if stat.Dev == wantedDev && m.Fstype == "zfs" {
+ if stat.Dev == wantedDev && m.FSType == "zfs" {
return m.Source, nil
}
}
diff --git a/daemon/logger/loggerutils/file_unix.go b/daemon/logger/loggerutils/file_unix.go
index eb39d4b..e7b6095 100644
--- a/daemon/logger/loggerutils/file_unix.go
+++ b/daemon/logger/loggerutils/file_unix.go
@@ -7,3 +7,7 @@
func openFile(name string, flag int, perm os.FileMode) (*os.File, error) {
return os.OpenFile(name, flag, perm)
}
+
+func open(name string) (*os.File, error) {
+ return os.Open(name)
+}
diff --git a/daemon/logger/loggerutils/file_windows.go b/daemon/logger/loggerutils/file_windows.go
index 507da68..b16bf01 100644
--- a/daemon/logger/loggerutils/file_windows.go
+++ b/daemon/logger/loggerutils/file_windows.go
@@ -4,17 +4,19 @@
"os"
"syscall"
"unsafe"
-
- "github.com/pkg/errors"
)
+func open(name string) (*os.File, error) {
+ return openFile(name, os.O_RDONLY, 0)
+}
+
func openFile(name string, flag int, perm os.FileMode) (*os.File, error) {
if name == "" {
return nil, &os.PathError{Op: "open", Path: name, Err: syscall.ENOENT}
}
h, err := syscallOpen(fixLongPath(name), flag|syscall.O_CLOEXEC, syscallMode(perm))
if err != nil {
- return nil, errors.Wrap(err, "error opening file")
+ return nil, &os.PathError{Op: "open", Path: name, Err: err}
}
return os.NewFile(uintptr(h), name), nil
}
diff --git a/daemon/logger/loggerutils/logfile.go b/daemon/logger/loggerutils/logfile.go
index 2b01192..6b42d9d 100644
--- a/daemon/logger/loggerutils/logfile.go
+++ b/daemon/logger/loggerutils/logfile.go
@@ -68,7 +68,7 @@
if rc.counter[fileName] <= 0 {
delete(rc.counter, fileName)
err := os.Remove(fileName)
- if err != nil {
+ if err != nil && !os.IsNotExist(err) {
return err
}
}
@@ -87,7 +87,7 @@
compress bool // whether old versions of log files are compressed
lastTimestamp time.Time // timestamp of the last log
filesRefCounter refCounter // keep reference-counted of decompressed files
- notifyRotate *pubsub.Publisher
+ notifyReaders *pubsub.Publisher
marshal logger.MarshalFunc
createDecoder MakeDecoderFn
getTailReader GetTailReaderFunc
@@ -141,7 +141,7 @@
maxFiles: maxFiles,
compress: compress,
filesRefCounter: refCounter{counter: make(map[string]int)},
- notifyRotate: pubsub.NewPublisher(0, 1),
+ notifyReaders: pubsub.NewPublisher(0, 1),
marshal: marshaller,
createDecoder: decodeFunc,
perms: perms,
@@ -167,7 +167,7 @@
if err := w.checkCapacityAndRotate(); err != nil {
w.mu.Unlock()
- return err
+ return errors.Wrap(err, "error rotating log file")
}
n, err := w.f.Write(b)
@@ -175,49 +175,77 @@
w.currentSize += int64(n)
w.lastTimestamp = msg.Timestamp
}
+
w.mu.Unlock()
- return err
+ return errors.Wrap(err, "error writing log entry")
}
-func (w *LogFile) checkCapacityAndRotate() error {
+func (w *LogFile) checkCapacityAndRotate() (retErr error) {
if w.capacity == -1 {
return nil
}
-
- if w.currentSize >= w.capacity {
- w.rotateMu.Lock()
- fname := w.f.Name()
- if err := w.f.Close(); err != nil {
- // if there was an error during a prior rotate, the file could already be closed
- if !errors.Is(err, os.ErrClosed) {
- w.rotateMu.Unlock()
- return errors.Wrap(err, "error closing file")
- }
- }
- if err := rotate(fname, w.maxFiles, w.compress); err != nil {
- w.rotateMu.Unlock()
- return err
- }
- file, err := openFile(fname, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, w.perms)
- if err != nil {
- w.rotateMu.Unlock()
- return err
- }
- w.f = file
- w.currentSize = 0
- w.notifyRotate.Publish(struct{}{})
-
- if w.maxFiles <= 1 || !w.compress {
- w.rotateMu.Unlock()
- return nil
- }
-
- go func() {
- compressFile(fname+".1", w.lastTimestamp)
- w.rotateMu.Unlock()
- }()
+ if w.currentSize < w.capacity {
+ return nil
}
+ w.rotateMu.Lock()
+ noCompress := w.maxFiles <= 1 || !w.compress
+ defer func() {
+ // If we aren't going to run the goroutine to compress the log file, then we need to unlock in this function.
+ // Otherwise the lock will be released in the goroutine that handles compression.
+ if retErr != nil || noCompress {
+ w.rotateMu.Unlock()
+ }
+ }()
+
+ fname := w.f.Name()
+ if err := w.f.Close(); err != nil {
+ // if there was an error during a prior rotate, the file could already be closed
+ if !errors.Is(err, os.ErrClosed) {
+ return errors.Wrap(err, "error closing file")
+ }
+ }
+
+ if err := rotate(fname, w.maxFiles, w.compress); err != nil {
+ logrus.WithError(err).Warn("Error rotating log file, log data may have been lost")
+ } else {
+ var renameErr error
+ for i := 0; i < 10; i++ {
+ if renameErr = os.Rename(fname, fname+".1"); renameErr != nil && !os.IsNotExist(renameErr) {
+ logrus.WithError(renameErr).WithField("file", fname).Debug("Error rotating current container log file, evicting readers and retrying")
+ w.notifyReaders.Publish(renameErr)
+ time.Sleep(100 * time.Millisecond)
+ continue
+ }
+ break
+ }
+ if renameErr != nil {
+ logrus.WithError(renameErr).Error("Error renaming current log file")
+ }
+ }
+
+ file, err := openFile(fname, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, w.perms)
+ if err != nil {
+ return err
+ }
+ w.f = file
+ w.currentSize = 0
+
+ w.notifyReaders.Publish(struct{}{})
+
+ if noCompress {
+ return nil
+ }
+
+ ts := w.lastTimestamp
+
+ go func() {
+ if err := compressFile(fname+".1", ts); err != nil {
+ logrus.WithError(err).Error("Error compressing log file after rotation")
+ }
+ w.rotateMu.Unlock()
+ }()
+
return nil
}
@@ -240,41 +268,44 @@
for i := maxFiles - 1; i > 1; i-- {
toPath := name + "." + strconv.Itoa(i) + extension
fromPath := name + "." + strconv.Itoa(i-1) + extension
+ logrus.WithField("source", fromPath).WithField("target", toPath).Trace("Rotating log file")
if err := os.Rename(fromPath, toPath); err != nil && !os.IsNotExist(err) {
return err
}
}
- if err := os.Rename(name, name+".1"); err != nil && !os.IsNotExist(err) {
- return err
- }
-
return nil
}
-func compressFile(fileName string, lastTimestamp time.Time) {
- file, err := os.Open(fileName)
+func compressFile(fileName string, lastTimestamp time.Time) (retErr error) {
+ file, err := open(fileName)
if err != nil {
- logrus.Errorf("Failed to open log file: %v", err)
- return
+ if os.IsNotExist(err) {
+ logrus.WithField("file", fileName).WithError(err).Debug("Could not open log file to compress")
+ return nil
+ }
+ return errors.Wrap(err, "failed to open log file")
}
defer func() {
file.Close()
- err := os.Remove(fileName)
- if err != nil {
- logrus.Errorf("Failed to remove source log file: %v", err)
+ if retErr == nil {
+ err := os.Remove(fileName)
+ if err != nil && !os.IsNotExist(err) {
+ retErr = errors.Wrap(err, "failed to remove source log file")
+ }
}
}()
outFile, err := openFile(fileName+".gz", os.O_CREATE|os.O_TRUNC|os.O_RDWR, 0640)
if err != nil {
- logrus.Errorf("Failed to open or create gzip log file: %v", err)
- return
+ return errors.Wrap(err, "failed to open or create gzip log file")
}
defer func() {
outFile.Close()
- if err != nil {
- os.Remove(fileName + ".gz")
+ if retErr != nil {
+ if err := os.Remove(fileName + ".gz"); err != nil && !os.IsExist(err) {
+ logrus.WithError(err).Error("Error cleaning up after failed log compression")
+ }
}
}()
@@ -292,9 +323,10 @@
_, err = pools.Copy(compressWriter, file)
if err != nil {
- logrus.WithError(err).WithField("module", "container.logs").WithField("file", fileName).Error("Error compressing log file")
- return
+ return errors.Wrapf(err, "error compressing log file %s", fileName)
}
+
+ return nil
}
// MaxFiles return maximum number of files
@@ -309,7 +341,7 @@
if w.closed {
return nil
}
- if err := w.f.Close(); err != nil {
+ if err := w.f.Close(); err != nil && !errors.Is(err, os.ErrClosed) {
return err
}
w.closed = true
@@ -322,7 +354,7 @@
// TODO: Consider a different implementation which can effectively follow logs under frequent rotations.
func (w *LogFile) ReadLogs(config logger.ReadConfig, watcher *logger.LogWatcher) {
w.mu.RLock()
- currentFile, err := os.Open(w.f.Name())
+ currentFile, err := open(w.f.Name())
if err != nil {
w.mu.RUnlock()
watcher.Err <- err
@@ -340,6 +372,12 @@
return
}
+ notifyEvict := w.notifyReaders.SubscribeTopicWithBuffer(func(i interface{}) bool {
+ _, ok := i.(error)
+ return ok
+ }, 1)
+ defer w.notifyReaders.Evict(notifyEvict)
+
if config.Tail != 0 {
// TODO(@cpuguy83): Instead of opening every file, only get the files which
// are needed to tail.
@@ -358,7 +396,7 @@
if strings.HasSuffix(fileName, tmpLogfileSuffix) {
err := w.filesRefCounter.Dereference(fileName)
if err != nil {
- logrus.Errorf("Failed to dereference the log file %q: %v", fileName, err)
+ logrus.WithError(err).WithField("file", fileName).Error("Failed to dereference the log file")
}
}
}
@@ -378,9 +416,11 @@
readers = append(readers, currentChunk)
}
- tailFiles(readers, watcher, dec, w.getTailReader, config)
+ ok := tailFiles(readers, watcher, dec, w.getTailReader, config, notifyEvict)
closeFiles()
-
+ if !ok {
+ return
+ }
w.mu.RLock()
}
@@ -390,9 +430,13 @@
}
w.mu.RUnlock()
- notifyRotate := w.notifyRotate.Subscribe()
- defer w.notifyRotate.Evict(notifyRotate)
- followLogs(currentFile, watcher, notifyRotate, dec, config.Since, config.Until)
+ notifyRotate := w.notifyReaders.SubscribeTopic(func(i interface{}) bool {
+ _, ok := i.(struct{})
+ return ok
+ })
+ defer w.notifyReaders.Evict(notifyRotate)
+
+ followLogs(currentFile, watcher, notifyRotate, notifyEvict, dec, config.Since, config.Until)
}
func (w *LogFile) openRotatedFiles(config logger.ReadConfig) (files []*os.File, err error) {
@@ -415,7 +459,7 @@
}()
for i := w.maxFiles; i > 1; i-- {
- f, err := os.Open(fmt.Sprintf("%s.%d", w.f.Name(), i-1))
+ f, err := open(fmt.Sprintf("%s.%d", w.f.Name(), i-1))
if err != nil {
if !os.IsNotExist(err) {
return nil, errors.Wrap(err, "error opening rotated log file")
@@ -425,7 +469,7 @@
decompressedFileName := fileName + tmpLogfileSuffix
tmpFile, err := w.filesRefCounter.GetReference(decompressedFileName, func(refFileName string, exists bool) (*os.File, error) {
if exists {
- return os.Open(refFileName)
+ return open(refFileName)
}
return decompressfile(fileName, refFileName, config.Since)
})
@@ -451,7 +495,7 @@
}
func decompressfile(fileName, destFileName string, since time.Time) (*os.File, error) {
- cf, err := os.Open(fileName)
+ cf, err := open(fileName)
if err != nil {
return nil, errors.Wrap(err, "error opening file for decompression")
}
@@ -498,16 +542,25 @@
return io.NewSectionReader(f, 0, size), nil
}
-func tailFiles(files []SizeReaderAt, watcher *logger.LogWatcher, dec Decoder, getTailReader GetTailReaderFunc, config logger.ReadConfig) {
+func tailFiles(files []SizeReaderAt, watcher *logger.LogWatcher, dec Decoder, getTailReader GetTailReaderFunc, config logger.ReadConfig, notifyEvict <-chan interface{}) (cont bool) {
nLines := config.Tail
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
+
+ cont = true
// TODO(@cpuguy83): we should plumb a context through instead of dealing with `WatchClose()` here.
go func() {
select {
+ case err := <-notifyEvict:
+ if err != nil {
+ watcher.Err <- err.(error)
+ cont = false
+ cancel()
+ }
case <-ctx.Done():
case <-watcher.WatchConsumerGone():
+ cont = false
cancel()
}
}()
@@ -555,7 +608,7 @@
}
}
-func followLogs(f *os.File, logWatcher *logger.LogWatcher, notifyRotate chan interface{}, dec Decoder, since, until time.Time) {
+func followLogs(f *os.File, logWatcher *logger.LogWatcher, notifyRotate, notifyEvict chan interface{}, dec Decoder, since, until time.Time) {
dec.Reset(f)
name := f.Name()
@@ -566,6 +619,7 @@
}
defer func() {
f.Close()
+ dec.Close()
fileWatcher.Close()
}()
@@ -576,7 +630,7 @@
// retry when the file doesn't exist
for retries := 0; retries <= 5; retries++ {
- f, err = os.Open(name)
+ f, err = open(name)
if err == nil || !os.IsNotExist(err) {
break
}
@@ -593,8 +647,22 @@
errRetry := errors.New("retry")
errDone := errors.New("done")
+
+ handleMustClose := func(evictErr error) {
+ f.Close()
+ dec.Close()
+ logWatcher.Err <- errors.Wrap(err, "log reader evicted due to errors")
+ logrus.WithField("file", f.Name()).Error("Log reader notified that it must re-open log file, some log data may not be streamed to the client.")
+ }
+
waitRead := func() error {
select {
+ case e := <-notifyEvict:
+ if e != nil {
+ err := e.(error)
+ handleMustClose(err)
+ }
+ return errDone
case e := <-fileWatcher.Events():
switch e.Op {
case fsnotify.Write:
@@ -668,6 +736,14 @@
// main loop
for {
+ select {
+ case err := <-notifyEvict:
+ if err != nil {
+ handleMustClose(err.(error))
+ }
+ return
+ default:
+ }
msg, err := dec.Decode()
if err != nil {
if err := handleDecodeErr(err); err != nil {
@@ -691,6 +767,13 @@
}
// send the message, unless the consumer is gone
select {
+ case e := <-notifyEvict:
+ if e != nil {
+ err := e.(error)
+ logrus.WithError(err).Debug("Reader evicted while sending log message")
+ logWatcher.Err <- err
+ }
+ return
case logWatcher.Msg <- msg:
case <-logWatcher.WatchConsumerGone():
return
diff --git a/daemon/logger/loggerutils/logfile_test.go b/daemon/logger/loggerutils/logfile_test.go
index ab4a542..af951c7 100644
--- a/daemon/logger/loggerutils/logfile_test.go
+++ b/daemon/logger/loggerutils/logfile_test.go
@@ -1,14 +1,18 @@
-package loggerutils
+package loggerutils // import "github.com/docker/docker/daemon/logger/loggerutils"
import (
"bufio"
+ "bytes"
"context"
+ "fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
+ "sync/atomic"
"testing"
+ "text/tabwriter"
"time"
"github.com/docker/docker/daemon/logger"
@@ -51,6 +55,7 @@
files := []SizeReaderAt{s1, s2, s3}
watcher := logger.NewLogWatcher()
+ defer watcher.ConsumerGone()
tailReader := func(ctx context.Context, r SizeReaderAt, lines int) (io.Reader, int, error) {
return tailfile.NewTailReader(ctx, r, lines)
@@ -62,7 +67,7 @@
started := make(chan struct{})
go func() {
close(started)
- tailFiles(files, watcher, dec, tailReader, config)
+ tailFiles(files, watcher, dec, tailReader, config, make(chan interface{}))
}()
<-started
})
@@ -72,7 +77,7 @@
started := make(chan struct{})
go func() {
close(started)
- tailFiles(files, watcher, dec, tailReader, config)
+ tailFiles(files, watcher, dec, tailReader, config, make(chan interface{}))
}()
<-started
@@ -121,7 +126,7 @@
followLogsDone := make(chan struct{})
var since, until time.Time
go func() {
- followLogs(f, lw, make(chan interface{}), dec, since, until)
+ followLogs(f, lw, make(chan interface{}), make(chan interface{}), dec, since, until)
close(followLogsDone)
}()
@@ -157,19 +162,20 @@
func TestFollowLogsProducerGone(t *testing.T) {
lw := logger.NewLogWatcher()
+ defer lw.ConsumerGone()
f, err := ioutil.TempFile("", t.Name())
assert.NilError(t, err)
defer os.Remove(f.Name())
- var sent, received, closed int
+ var sent, received, closed int32
dec := &dummyWrapper{fn: func() error {
- switch closed {
+ switch atomic.LoadInt32(&closed) {
case 0:
- sent++
+ atomic.AddInt32(&sent, 1)
return nil
case 1:
- closed++
+ atomic.AddInt32(&closed, 1)
t.Logf("logDecode() closed after sending %d messages\n", sent)
return io.EOF
default:
@@ -181,7 +187,7 @@
followLogsDone := make(chan struct{})
go func() {
- followLogs(f, lw, make(chan interface{}), dec, since, until)
+ followLogs(f, lw, make(chan interface{}), make(chan interface{}), dec, since, until)
close(followLogsDone)
}()
@@ -198,7 +204,7 @@
}
// "stop" the "container"
- closed = 1
+ atomic.StoreInt32(&closed, 1)
lw.ProducerGone()
// should receive all the messages sent
@@ -209,7 +215,7 @@
select {
case <-lw.Msg:
received++
- if received == sent {
+ if received == atomic.LoadInt32(&sent) {
return
}
case err := <-lw.Err:
@@ -223,7 +229,7 @@
t.Fatalf("timeout waiting for log messages to be read (sent: %d, received: %d", sent, received)
}
- t.Logf("messages sent: %d, received: %d", sent, received)
+ t.Logf("messages sent: %d, received: %d", atomic.LoadInt32(&sent), received)
// followLogs() should be done by now
select {
@@ -248,21 +254,30 @@
assert.NilError(t, err)
l := &LogFile{
- f: f,
- capacity: 5,
- maxFiles: 3,
- compress: true,
- notifyRotate: pubsub.NewPublisher(0, 1),
- perms: 0600,
+ f: f,
+ capacity: 5,
+ maxFiles: 3,
+ compress: true,
+ notifyReaders: pubsub.NewPublisher(0, 1),
+ perms: 0600,
+ filesRefCounter: refCounter{counter: make(map[string]int)},
+ getTailReader: func(ctx context.Context, r SizeReaderAt, lines int) (io.Reader, int, error) {
+ return tailfile.NewTailReader(ctx, r, lines)
+ },
+ createDecoder: func(io.Reader) Decoder {
+ return dummyDecoder{}
+ },
marshal: func(msg *logger.Message) ([]byte, error) {
return msg.Line, nil
},
}
defer l.Close()
+ ls := dirStringer{dir}
+
assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world!")}))
_, err = os.Stat(f.Name() + ".1")
- assert.Assert(t, os.IsNotExist(err), dirStringer{dir})
+ assert.Assert(t, os.IsNotExist(err), ls)
assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world!")}))
poll.WaitOn(t, checkFileExists(f.Name()+".1.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second))
@@ -271,11 +286,48 @@
poll.WaitOn(t, checkFileExists(f.Name()+".1.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second))
poll.WaitOn(t, checkFileExists(f.Name()+".2.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second))
- // Now let's simulate a failed rotation where the file was able to be closed but something else happened elsewhere
- // down the line.
- // We want to make sure that we can recover in the case that `l.f` was closed while attempting a rotation.
- l.f.Close()
- assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world!")}))
+ t.Run("closed log file", func(t *testing.T) {
+ // Now let's simulate a failed rotation where the file was able to be closed but something else happened elsewhere
+ // down the line.
+ // We want to make sure that we can recover in the case that `l.f` was closed while attempting a rotation.
+ l.f.Close()
+ assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world!")}))
+ assert.NilError(t, os.Remove(f.Name()+".2.gz"))
+ })
+
+ t.Run("with log reader", func(t *testing.T) {
+ // Make sure rotate works with an active reader
+ lw := logger.NewLogWatcher()
+ defer lw.ConsumerGone()
+ go l.ReadLogs(logger.ReadConfig{Follow: true, Tail: 1000}, lw)
+
+ assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world 0!")}), ls)
+ // make sure the log reader is primed
+ waitForMsg(t, lw, 30*time.Second)
+
+ assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world 1!")}), ls)
+ assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world 2!")}), ls)
+ assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world 3!")}), ls)
+ assert.NilError(t, l.WriteLogEntry(&logger.Message{Line: []byte("hello world 4!")}), ls)
+ poll.WaitOn(t, checkFileExists(f.Name()+".2.gz"), poll.WithDelay(time.Millisecond), poll.WithTimeout(30*time.Second))
+ })
+}
+
+func waitForMsg(t *testing.T, lw *logger.LogWatcher, timeout time.Duration) {
+ t.Helper()
+
+ timer := time.NewTimer(timeout)
+ defer timer.Stop()
+
+ select {
+ case <-lw.Msg:
+ case <-lw.WatchProducerGone():
+ t.Fatal("log producer gone before log message arrived")
+ case err := <-lw.Err:
+ assert.NilError(t, err)
+ case <-timer.C:
+ t.Fatal("timeout waiting for log message")
+ }
}
type dirStringer struct {
@@ -287,13 +339,18 @@
if err != nil {
return ""
}
- var s strings.Builder
- s.WriteString("\n")
+ buf := bytes.NewBuffer(nil)
+ tw := tabwriter.NewWriter(buf, 1, 8, 1, '\t', 0)
+ buf.WriteString("\n")
+
+ btw := bufio.NewWriter(tw)
for _, fi := range ls {
- s.WriteString(fi.Name() + "\n")
+ btw.WriteString(fmt.Sprintf("%s\t%s\t%dB\t%s\n", fi.Name(), fi.Mode(), fi.Size(), fi.ModTime()))
}
- return s.String()
+ btw.Flush()
+ tw.Flush()
+ return buf.String()
}
func checkFileExists(name string) poll.Check {
@@ -305,7 +362,7 @@
case os.IsNotExist(err):
return poll.Continue("waiting for %s to exist", name)
default:
- t.Logf("%s", dirStringer{filepath.Dir(name)})
+ t.Logf("waiting for %s: %v: %s", name, err, dirStringer{filepath.Dir(name)})
return poll.Error(err)
}
}
diff --git a/daemon/network/constants.go b/daemon/network/constants.go
deleted file mode 100644
index e7d9701..0000000
--- a/daemon/network/constants.go
+++ /dev/null
@@ -1,8 +0,0 @@
-package network
-
-const (
- // HostGatewayName is the string value that can be passed
- // to the IPAddr section in --add-host that is replaced by
- // the value of HostGatewayIP daemon config value
- HostGatewayName = "host-gateway"
-)
diff --git a/daemon/oci_linux.go b/daemon/oci_linux.go
index 4cc6c9b..3ef7c90 100644
--- a/daemon/oci_linux.go
+++ b/daemon/oci_linux.go
@@ -11,6 +11,7 @@
"strconv"
"strings"
+ cdcgroups "github.com/containerd/cgroups"
"github.com/containerd/containerd/containers"
coci "github.com/containerd/containerd/oci"
"github.com/containerd/containerd/sys"
@@ -89,7 +90,7 @@
return func(_ context.Context, _ coci.Client, _ *containers.Container, s *coci.Spec) error {
var v2Controllers []string
if daemon.getCgroupDriver() == cgroupSystemdDriver {
- if !cgroups.IsCgroup2UnifiedMode() {
+ if cdcgroups.Mode() != cdcgroups.Unified {
return errors.New("rootless systemd driver doesn't support cgroup v1")
}
rootlesskitParentEUID := os.Getenv("ROOTLESSKIT_PARENT_EUID")
@@ -814,7 +815,7 @@
return nil
}
- if cgroups.IsCgroup2UnifiedMode() {
+ if cdcgroups.Mode() == cdcgroups.Unified {
return errors.New("daemon-scoped cpu-rt-period and cpu-rt-runtime are not implemented for cgroup v2")
}
diff --git a/daemon/start.go b/daemon/start.go
index 6126efa..d9bc082 100644
--- a/daemon/start.go
+++ b/daemon/start.go
@@ -5,14 +5,10 @@
"runtime"
"time"
- "github.com/containerd/containerd"
- "github.com/containerd/containerd/containers"
- "github.com/docker/distribution/reference"
"github.com/docker/docker/api/types"
containertypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/container"
"github.com/docker/docker/errdefs"
- "github.com/moby/sys/mount"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -182,12 +178,7 @@
ctx := context.TODO()
- imageRef, err := reference.ParseNormalizedNamed(container.Config.Image)
- if err != nil {
- return err
- }
-
- err = daemon.containerd.Create(ctx, container.ID, spec, shim, createOptions, withImageName(imageRef.String()))
+ err = daemon.containerd.Create(ctx, container.ID, spec, shim, createOptions)
if err != nil {
if errdefs.IsConflict(err) {
logrus.WithError(err).WithField("container", container.ID).Error("Container not cleaned up from containerd from previous run")
@@ -196,7 +187,7 @@
if err := daemon.containerd.Delete(ctx, container.ID); err != nil && !errdefs.IsNotFound(err) {
logrus.WithError(err).WithField("container", container.ID).Error("Error cleaning up stale containerd container object")
}
- err = daemon.containerd.Create(ctx, container.ID, spec, shim, createOptions, withImageName(imageRef.String()))
+ err = daemon.containerd.Create(ctx, container.ID, spec, shim, createOptions)
}
if err != nil {
return translateContainerdStartErr(container.Path, container.SetExitCode, err)
@@ -253,7 +244,7 @@
logrus.Warnf("%s cleanup: failed to unmount secrets: %s", container.ID, err)
}
- if err := mount.RecursiveUnmount(container.Root); err != nil {
+ if err := recursiveUnmount(container.Root); err != nil {
logrus.WithError(err).WithField("container", container.ID).Warn("Error while cleaning up container resource mounts.")
}
@@ -273,10 +264,3 @@
logrus.Errorf("%s cleanup: failed to delete container from containerd: %v", container.ID, err)
}
}
-
-func withImageName(n string) containerd.NewContainerOpts {
- return func(ctx context.Context, _ *containerd.Client, c *containers.Container) error {
- c.Image = n
- return nil
- }
-}
diff --git a/daemon/start_unix.go b/daemon/start_unix.go
index b2908fb..7b70451 100644
--- a/daemon/start_unix.go
+++ b/daemon/start_unix.go
@@ -3,9 +3,9 @@
package daemon // import "github.com/docker/docker/daemon"
import (
+ "github.com/containerd/cgroups"
"github.com/docker/docker/container"
"github.com/docker/docker/errdefs"
- "github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -27,7 +27,7 @@
rt.Shim = defaultV2ShimConfig(daemon.configStore, p)
}
if rt.Shim.Binary == linuxShimV1 {
- if cgroups.IsCgroup2UnifiedMode() {
+ if cgroups.Mode() == cgroups.Unified {
return "", nil, errdefs.InvalidParameter(errors.Errorf("runtime %q is not supported while cgroups v2 (unified hierarchy) is being used", container.HostConfig.Runtime))
}
logrus.Warnf("Configured runtime %q is deprecated and will be removed in the next release", container.HostConfig.Runtime)
diff --git a/hack/ci/windows.ps1 b/hack/ci/windows.ps1
index ebb4030..fe166e9 100644
--- a/hack/ci/windows.ps1
+++ b/hack/ci/windows.ps1
@@ -1012,9 +1012,6 @@
Throw $_
}
Finally {
- # Preserve the LastExitCode of the tests
- $tmpLastExitCode = $LastExitCode
-
$ErrorActionPreference="SilentlyContinue"
$global:ProgressPreference=$origProgressPreference
Write-Host -ForegroundColor Green "INFO: Tidying up at end of run"
@@ -1053,6 +1050,4 @@
$Dur=New-TimeSpan -Start $StartTime -End $(Get-Date)
Write-Host -ForegroundColor $FinallyColour "`nINFO: executeCI.ps1 exiting at $(date). Duration $dur`n"
-
- exit $tmpLastExitCode
}
diff --git a/hack/dockerfile/install/proxy.installer b/hack/dockerfile/install/proxy.installer
index 751357e..d8caa0c 100755
--- a/hack/dockerfile/install/proxy.installer
+++ b/hack/dockerfile/install/proxy.installer
@@ -3,7 +3,7 @@
# LIBNETWORK_COMMIT is used to build the docker-userland-proxy binary. When
# updating the binary version, consider updating github.com/docker/libnetwork
# in vendor.conf accordingly
-: "${LIBNETWORK_COMMIT:=d0951081b35fa4216fc4f0064bf065beeb55a74b}"
+: "${LIBNETWORK_COMMIT:=d511c60c5c23e6753631244f271a1ec6097254a5}"
install_proxy() {
case "$1" in
diff --git a/hack/dockerfile/install/rootlesskit.installer b/hack/dockerfile/install/rootlesskit.installer
index 8841dd8..43b84d3 100755
--- a/hack/dockerfile/install/rootlesskit.installer
+++ b/hack/dockerfile/install/rootlesskit.installer
@@ -1,7 +1,7 @@
#!/bin/sh
-# v0.10.0
-: ${ROOTLESSKIT_COMMIT:=f766387c3b360bc6dc6c2f353e9e630cf2c6ee86}
+# v0.11.0
+: ${ROOTLESSKIT_COMMIT:=2886253e467c5444a4d2ac7084e53aa3cc50055d}
install_rootlesskit() {
case "$1" in
diff --git a/image/tarexport/load.go b/image/tarexport/load.go
index cc22127..bbbb238 100644
--- a/image/tarexport/load.go
+++ b/image/tarexport/load.go
@@ -22,8 +22,8 @@
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
"github.com/docker/docker/pkg/stringid"
- "github.com/docker/docker/pkg/symlink"
"github.com/docker/docker/pkg/system"
+ "github.com/moby/sys/symlink"
digest "github.com/opencontainers/go-digest"
"github.com/sirupsen/logrus"
)
diff --git a/integration-cli/docker_api_containers_test.go b/integration-cli/docker_api_containers_test.go
index 720a909..76ce061 100644
--- a/integration-cli/docker_api_containers_test.go
+++ b/integration-cli/docker_api_containers_test.go
@@ -30,7 +30,6 @@
"github.com/docker/docker/testutil/request"
"github.com/docker/docker/volume"
"github.com/docker/go-connections/nat"
- "github.com/moby/sys/mount"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/poll"
@@ -2056,7 +2055,7 @@
assert.NilError(c, err)
defer os.RemoveAll(tmpDir3)
- assert.Assert(c, mount.Mount(tmpDir3, tmpDir3, "none", "bind,shared") == nil)
+ assert.Assert(c, mountWrapper(tmpDir3, tmpDir3, "none", "bind,shared") == nil)
cases = append(cases, []testCase{
{
diff --git a/integration-cli/docker_api_containers_unix_test.go b/integration-cli/docker_api_containers_unix_test.go
new file mode 100644
index 0000000..05c667f
--- /dev/null
+++ b/integration-cli/docker_api_containers_unix_test.go
@@ -0,0 +1,9 @@
+// +build !windows
+
+package main
+
+import "github.com/moby/sys/mount"
+
+func mountWrapper(device, target, mType, options string) error {
+ return mount.Mount(device, target, mType, options)
+}
diff --git a/integration-cli/docker_api_containers_windows_test.go b/integration-cli/docker_api_containers_windows_test.go
index 0423d18..1038506 100644
--- a/integration-cli/docker_api_containers_windows_test.go
+++ b/integration-cli/docker_api_containers_windows_test.go
@@ -15,6 +15,7 @@
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
+ "github.com/pkg/errors"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -75,3 +76,8 @@
assert.NilError(c, err)
assert.Check(c, is.Equal(text, strings.TrimSpace(string(b))))
}
+
+func mountWrapper(device, target, mType, options string) error {
+ // This should never be called.
+ return errors.Errorf("there is no implementation of Mount on this platform")
+}
diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go
index 1acc491..c7dc934 100644
--- a/integration-cli/docker_cli_build_test.go
+++ b/integration-cli/docker_cli_build_test.go
@@ -5608,30 +5608,6 @@
}
-func (s *DockerSuite) TestBuildContChar(c *testing.T) {
- name := "testbuildcontchar"
-
- buildImage(name, build.WithDockerfile(`FROM busybox\`)).Assert(c, icmd.Expected{
- Out: "Step 1/1 : FROM busybox",
- })
-
- result := buildImage(name, build.WithDockerfile(`FROM busybox
- RUN echo hi \`))
- result.Assert(c, icmd.Success)
- assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
- assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi\n"))
- result = buildImage(name, build.WithDockerfile(`FROM busybox
- RUN echo hi \\`))
- result.Assert(c, icmd.Success)
- assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
- assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi \\\n"))
- result = buildImage(name, build.WithDockerfile(`FROM busybox
- RUN echo hi \\\`))
- result.Assert(c, icmd.Success)
- assert.Assert(c, strings.Contains(result.Combined(), "Step 1/2 : FROM busybox"))
- assert.Assert(c, strings.Contains(result.Combined(), "Step 2/2 : RUN echo hi \\\\\n"))
-}
-
func (s *DockerSuite) TestBuildMultiStageCopyFromSyntax(c *testing.T) {
dockerfile := `
FROM busybox AS first
diff --git a/integration-cli/docker_cli_daemon_test.go b/integration-cli/docker_cli_daemon_test.go
index d5fa41c..81bc7e6 100644
--- a/integration-cli/docker_cli_daemon_test.go
+++ b/integration-cli/docker_cli_daemon_test.go
@@ -945,12 +945,13 @@
sourceRule := []string{"-i", bridgeName, "-o", bridgeName, "-p", "tcp", "-s", childIP, "--sport", "80", "-d", parentIP, "-j", "ACCEPT"}
destinationRule := []string{"-i", bridgeName, "-o", bridgeName, "-p", "tcp", "-s", parentIP, "--dport", "80", "-d", childIP, "-j", "ACCEPT"}
- if !iptables.Exists("filter", "DOCKER", sourceRule...) || !iptables.Exists("filter", "DOCKER", destinationRule...) {
+ iptable := iptables.GetIptable(iptables.IPv4)
+ if !iptable.Exists("filter", "DOCKER", sourceRule...) || !iptable.Exists("filter", "DOCKER", destinationRule...) {
c.Fatal("Iptables rules not found")
}
s.d.Cmd("rm", "--link", "parent/http")
- if iptables.Exists("filter", "DOCKER", sourceRule...) || iptables.Exists("filter", "DOCKER", destinationRule...) {
+ if iptable.Exists("filter", "DOCKER", sourceRule...) || iptable.Exists("filter", "DOCKER", destinationRule...) {
c.Fatal("Iptables rules should be removed when unlink")
}
diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go
index 7c22cfc..e0c1bbe 100644
--- a/integration-cli/docker_cli_run_test.go
+++ b/integration-cli/docker_cli_run_test.go
@@ -34,7 +34,6 @@
"github.com/docker/go-connections/nat"
"github.com/docker/libnetwork/resolvconf"
"github.com/docker/libnetwork/types"
- "github.com/moby/sys/mount"
"github.com/moby/sys/mountinfo"
"gotest.tools/v3/assert"
"gotest.tools/v3/icmd"
@@ -3764,86 +3763,6 @@
}
}
-func (s *DockerSuite) TestRunVolumesMountedAsShared(c *testing.T) {
- // Volume propagation is linux only. Also it creates directories for
- // bind mounting, so needs to be same host.
- testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace)
-
- // Prepare a source directory to bind mount
- tmpDir, err := ioutil.TempDir("", "volume-source")
- if err != nil {
- c.Fatal(err)
- }
- defer os.RemoveAll(tmpDir)
-
- if err := os.Mkdir(path.Join(tmpDir, "mnt1"), 0755); err != nil {
- c.Fatal(err)
- }
-
- // Convert this directory into a shared mount point so that we do
- // not rely on propagation properties of parent mount.
- icmd.RunCommand("mount", "--bind", tmpDir, tmpDir).Assert(c, icmd.Success)
- icmd.RunCommand("mount", "--make-private", "--make-shared", tmpDir).Assert(c, icmd.Success)
-
- dockerCmd(c, "run", "--privileged", "-v", fmt.Sprintf("%s:/volume-dest:shared", tmpDir), "busybox", "mount", "--bind", "/volume-dest/mnt1", "/volume-dest/mnt1")
-
- // Make sure a bind mount under a shared volume propagated to host.
- if mounted, _ := mountinfo.Mounted(path.Join(tmpDir, "mnt1")); !mounted {
- c.Fatalf("Bind mount under shared volume did not propagate to host")
- }
-
- mount.Unmount(path.Join(tmpDir, "mnt1"))
-}
-
-func (s *DockerSuite) TestRunVolumesMountedAsSlave(c *testing.T) {
- // Volume propagation is linux only. Also it creates directories for
- // bind mounting, so needs to be same host.
- testRequires(c, DaemonIsLinux, testEnv.IsLocalDaemon, NotUserNamespace)
-
- // Prepare a source directory to bind mount
- tmpDir, err := ioutil.TempDir("", "volume-source")
- if err != nil {
- c.Fatal(err)
- }
- defer os.RemoveAll(tmpDir)
-
- if err := os.Mkdir(path.Join(tmpDir, "mnt1"), 0755); err != nil {
- c.Fatal(err)
- }
-
- // Prepare a source directory with file in it. We will bind mount this
- // directory and see if file shows up.
- tmpDir2, err := ioutil.TempDir("", "volume-source2")
- if err != nil {
- c.Fatal(err)
- }
- defer os.RemoveAll(tmpDir2)
-
- if err := ioutil.WriteFile(path.Join(tmpDir2, "slave-testfile"), []byte("Test"), 0644); err != nil {
- c.Fatal(err)
- }
-
- // Convert this directory into a shared mount point so that we do
- // not rely on propagation properties of parent mount.
- icmd.RunCommand("mount", "--bind", tmpDir, tmpDir).Assert(c, icmd.Success)
- icmd.RunCommand("mount", "--make-private", "--make-shared", tmpDir).Assert(c, icmd.Success)
-
- dockerCmd(c, "run", "-i", "-d", "--name", "parent", "-v", fmt.Sprintf("%s:/volume-dest:slave", tmpDir), "busybox", "top")
-
- // Bind mount tmpDir2/ onto tmpDir/mnt1. If mount propagates inside
- // container then contents of tmpDir2/slave-testfile should become
- // visible at "/volume-dest/mnt1/slave-testfile"
- icmd.RunCommand("mount", "--bind", tmpDir2, path.Join(tmpDir, "mnt1")).Assert(c, icmd.Success)
-
- out, _ := dockerCmd(c, "exec", "parent", "cat", "/volume-dest/mnt1/slave-testfile")
-
- mount.Unmount(path.Join(tmpDir, "mnt1"))
-
- if out != "Test" {
- c.Fatalf("Bind mount under slave volume did not propagate to container")
- }
-}
-
func (s *DockerSuite) TestRunNamedVolumesMountedAsShared(c *testing.T) {
testRequires(c, DaemonIsLinux, NotUserNamespace)
out, exitCode, _ := dockerCmdWithError("run", "-v", "foo:/test:shared", "busybox", "touch", "/test/somefile")
diff --git a/integration/container/mounts_linux_test.go b/integration/container/mounts_linux_test.go
index 1ebdb32..d65bc99 100644
--- a/integration/container/mounts_linux_test.go
+++ b/integration/container/mounts_linux_test.go
@@ -16,6 +16,7 @@
"github.com/docker/docker/integration/internal/container"
"github.com/docker/docker/pkg/system"
"github.com/moby/sys/mount"
+ "github.com/moby/sys/mountinfo"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/fs"
@@ -266,3 +267,127 @@
poll.WaitOn(t, container.IsSuccessful(ctx, client, c), poll.WithDelay(100*time.Millisecond))
}
}
+
+func TestContainerVolumesMountedAsShared(t *testing.T) {
+ // Volume propagation is linux only. Also it creates directories for
+ // bind mounting, so needs to be same host.
+ skip.If(t, testEnv.IsRemoteDaemon)
+ skip.If(t, testEnv.IsUserNamespace)
+ skip.If(t, testEnv.IsRootless, "cannot be tested because RootlessKit executes the daemon in private mount namespace (https://github.com/rootless-containers/rootlesskit/issues/97)")
+
+ defer setupTest(t)()
+
+ // Prepare a source directory to bind mount
+ tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0755),
+ fs.WithDir("mnt1", fs.WithMode(0755)))
+ defer tmpDir1.Remove()
+ tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
+
+ // Convert this directory into a shared mount point so that we do
+ // not rely on propagation properties of parent mount.
+ if err := mount.Mount(tmpDir1.Path(), tmpDir1.Path(), "none", "bind,private"); err != nil {
+ t.Fatal(err)
+ }
+ defer func() {
+ if err := mount.Unmount(tmpDir1.Path()); err != nil {
+ t.Fatal(err)
+ }
+ }()
+ if err := mount.Mount("none", tmpDir1.Path(), "none", "shared"); err != nil {
+ t.Fatal(err)
+ }
+
+ sharedMount := mounttypes.Mount{
+ Type: mounttypes.TypeBind,
+ Source: tmpDir1.Path(),
+ Target: "/volume-dest",
+ BindOptions: &mounttypes.BindOptions{
+ Propagation: mounttypes.PropagationShared,
+ },
+ }
+
+ bindMountCmd := []string{"mount", "--bind", "/volume-dest/mnt1", "/volume-dest/mnt1"}
+
+ ctx := context.Background()
+ client := testEnv.APIClient()
+ containerID := container.Run(ctx, t, client, container.WithPrivileged(true), container.WithMount(sharedMount), container.WithCmd(bindMountCmd...))
+ poll.WaitOn(t, container.IsSuccessful(ctx, client, containerID), poll.WithDelay(100*time.Millisecond))
+
+ // Make sure a bind mount under a shared volume propagated to host.
+ if mounted, _ := mountinfo.Mounted(tmpDir1Mnt); !mounted {
+ t.Fatalf("Bind mount under shared volume did not propagate to host")
+ }
+
+ mount.Unmount(tmpDir1Mnt)
+}
+
+func TestContainerVolumesMountedAsSlave(t *testing.T) {
+ // Volume propagation is linux only. Also it creates directories for
+ // bind mounting, so needs to be same host.
+ skip.If(t, testEnv.IsRemoteDaemon)
+ skip.If(t, testEnv.IsUserNamespace)
+ skip.If(t, testEnv.IsRootless, "cannot be tested because RootlessKit executes the daemon in private mount namespace (https://github.com/rootless-containers/rootlesskit/issues/97)")
+
+ // Prepare a source directory to bind mount
+ tmpDir1 := fs.NewDir(t, "volume-source", fs.WithMode(0755),
+ fs.WithDir("mnt1", fs.WithMode(0755)))
+ defer tmpDir1.Remove()
+ tmpDir1Mnt := filepath.Join(tmpDir1.Path(), "mnt1")
+
+ // Prepare a source directory with file in it. We will bind mount this
+ // directory and see if file shows up.
+ tmpDir2 := fs.NewDir(t, "volume-source2", fs.WithMode(0755),
+ fs.WithFile("slave-testfile", "Test", fs.WithMode(0644)))
+ defer tmpDir2.Remove()
+
+ // Convert this directory into a shared mount point so that we do
+ // not rely on propagation properties of parent mount.
+ if err := mount.Mount(tmpDir1.Path(), tmpDir1.Path(), "none", "bind,private"); err != nil {
+ t.Fatal(err)
+ }
+ defer func() {
+ if err := mount.Unmount(tmpDir1.Path()); err != nil {
+ t.Fatal(err)
+ }
+ }()
+ if err := mount.Mount("none", tmpDir1.Path(), "none", "shared"); err != nil {
+ t.Fatal(err)
+ }
+
+ slaveMount := mounttypes.Mount{
+ Type: mounttypes.TypeBind,
+ Source: tmpDir1.Path(),
+ Target: "/volume-dest",
+ BindOptions: &mounttypes.BindOptions{
+ Propagation: mounttypes.PropagationSlave,
+ },
+ }
+
+ topCmd := []string{"top"}
+
+ ctx := context.Background()
+ client := testEnv.APIClient()
+ containerID := container.Run(ctx, t, client, container.WithTty(true), container.WithMount(slaveMount), container.WithCmd(topCmd...))
+
+ // Bind mount tmpDir2/ onto tmpDir1/mnt1. If mount propagates inside
+ // container then contents of tmpDir2/slave-testfile should become
+ // visible at "/volume-dest/mnt1/slave-testfile"
+ if err := mount.Mount(tmpDir2.Path(), tmpDir1Mnt, "none", "bind"); err != nil {
+ t.Fatal(err)
+ }
+ defer func() {
+ if err := mount.Unmount(tmpDir1Mnt); err != nil {
+ t.Fatal(err)
+ }
+ }()
+
+ mountCmd := []string{"cat", "/volume-dest/mnt1/slave-testfile"}
+
+ if result, err := container.Exec(ctx, client, containerID, mountCmd); err == nil {
+ if result.Stdout() != "Test" {
+ t.Fatalf("Bind mount under slave volume did not propagate to container")
+ }
+ } else {
+ t.Fatal(err)
+ }
+}
diff --git a/libcontainerd/remote/client.go b/libcontainerd/remote/client.go
index 1e58768..43f549f 100644
--- a/libcontainerd/remote/client.go
+++ b/libcontainerd/remote/client.go
@@ -862,6 +862,13 @@
ei = libcontainerdtypes.EventInfo{
ContainerID: t.ContainerID,
}
+ case *apievents.TaskDelete:
+ c.logger.WithFields(logrus.Fields{
+ "topic": ev.Topic,
+ "type": reflect.TypeOf(t),
+ "container": t.ContainerID},
+ ).Info("ignoring event")
+ continue
default:
c.logger.WithFields(logrus.Fields{
"topic": ev.Topic,
diff --git a/opts/hosts.go b/opts/hosts.go
index 41caae3..a3123ad 100644
--- a/opts/hosts.go
+++ b/opts/hosts.go
@@ -8,11 +8,10 @@
"strconv"
"strings"
- "github.com/docker/docker/daemon/network"
"github.com/docker/docker/pkg/homedir"
)
-var (
+const (
// DefaultHTTPPort Default HTTP Port used if only the protocol is provided to -H flag e.g. dockerd -H tcp://
// These are the IANA registered port numbers for use with Docker
// see http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml?search=docker
@@ -23,11 +22,15 @@
// Docker daemon by default always listens on the default unix socket
DefaultUnixSocket = "/var/run/docker.sock"
// DefaultTCPHost constant defines the default host string used by docker on Windows
- DefaultTCPHost = fmt.Sprintf("tcp://%s:%d", DefaultHTTPHost, DefaultHTTPPort)
+ DefaultTCPHost = "tcp://" + DefaultHTTPHost + ":2375"
// DefaultTLSHost constant defines the default host string used by docker for TLS sockets
- DefaultTLSHost = fmt.Sprintf("tcp://%s:%d", DefaultHTTPHost, DefaultTLSHTTPPort)
+ DefaultTLSHost = "tcp://" + DefaultHTTPHost + ":2376"
// DefaultNamedPipe defines the default named pipe used by docker on Windows
DefaultNamedPipe = `//./pipe/docker_engine`
+ // HostGatewayName is the string value that can be passed
+ // to the IPAddr section in --add-host that is replaced by
+ // the value of HostGatewayIP daemon config value
+ HostGatewayName = "host-gateway"
)
// ValidateHost validates that the specified string is a valid host and returns it.
@@ -171,7 +174,7 @@
return "", fmt.Errorf("bad format for add-host: %q", val)
}
// Skip IPaddr validation for special "host-gateway" string
- if arr[1] != network.HostGatewayName {
+ if arr[1] != HostGatewayName {
if _, err := ValidateIPAddress(arr[1]); err != nil {
return "", fmt.Errorf("invalid IP address in add-host: %q", arr[1])
}
diff --git a/opts/hosts_unix.go b/opts/hosts_unix.go
index 9d5bb64..2986419 100644
--- a/opts/hosts_unix.go
+++ b/opts/hosts_unix.go
@@ -2,7 +2,10 @@
package opts // import "github.com/docker/docker/opts"
-import "fmt"
+const (
+ // DefaultHTTPHost Default HTTP Host used if only port is provided to -H flag e.g. dockerd -H tcp://:8080
+ DefaultHTTPHost = "localhost"
-// DefaultHost constant defines the default host string used by docker on other hosts than Windows
-var DefaultHost = fmt.Sprintf("unix://%s", DefaultUnixSocket)
+ // DefaultHost constant defines the default host string used by docker on other hosts than Windows
+ DefaultHost = "unix://" + DefaultUnixSocket
+)
diff --git a/opts/hosts_windows.go b/opts/hosts_windows.go
index 906eba5..576236b 100644
--- a/opts/hosts_windows.go
+++ b/opts/hosts_windows.go
@@ -1,4 +1,60 @@
package opts // import "github.com/docker/docker/opts"
-// DefaultHost constant defines the default host string used by docker on Windows
-var DefaultHost = "npipe://" + DefaultNamedPipe
+const (
+ // TODO Windows. Identify bug in GOLang 1.5.1+ and/or Windows Server 2016 TP5.
+ //
+ // On Windows, this mitigates a problem with the default options of running
+ // a docker client against a local docker daemon on TP5.
+ //
+ // What was found that if the default host is "localhost", even if the client
+ // (and daemon as this is local) is not physically on a network, and the DNS
+ // cache is flushed (ipconfig /flushdns), then the client will pause for
+ // exactly one second when connecting to the daemon for calls. For example
+ // using docker run windowsservercore cmd, the CLI will send a create followed
+ // by an attach. You see the delay between the attach finishing and the attach
+ // being seen by the daemon.
+ //
+ // Here's some daemon debug logs with additional debug spew put in. The
+ // AfterWriteJSON log is the very last thing the daemon does as part of the
+ // create call. The POST /attach is the second CLI call. Notice the second
+ // time gap.
+ //
+ // time="2015-11-06T13:38:37.259627400-08:00" level=debug msg="After createRootfs"
+ // time="2015-11-06T13:38:37.263626300-08:00" level=debug msg="After setHostConfig"
+ // time="2015-11-06T13:38:37.267631200-08:00" level=debug msg="before createContainerPl...."
+ // time="2015-11-06T13:38:37.271629500-08:00" level=debug msg=ToDiskLocking....
+ // time="2015-11-06T13:38:37.275643200-08:00" level=debug msg="loggin event...."
+ // time="2015-11-06T13:38:37.277627600-08:00" level=debug msg="logged event...."
+ // time="2015-11-06T13:38:37.279631800-08:00" level=debug msg="In defer func"
+ // time="2015-11-06T13:38:37.282628100-08:00" level=debug msg="After daemon.create"
+ // time="2015-11-06T13:38:37.286651700-08:00" level=debug msg="return 2"
+ // time="2015-11-06T13:38:37.289629500-08:00" level=debug msg="Returned from daemon.ContainerCreate"
+ // time="2015-11-06T13:38:37.311629100-08:00" level=debug msg="After WriteJSON"
+ // ... 1 second gap here....
+ // time="2015-11-06T13:38:38.317866200-08:00" level=debug msg="Calling POST /v1.22/containers/984758282b842f779e805664b2c95d563adc9a979c8a3973e68c807843ee4757/attach"
+ // time="2015-11-06T13:38:38.326882500-08:00" level=info msg="POST /v1.22/containers/984758282b842f779e805664b2c95d563adc9a979c8a3973e68c807843ee4757/attach?stderr=1&stdin=1&stdout=1&stream=1"
+ //
+ // We suspect this is either a bug introduced in GOLang 1.5.1, or that a change
+ // in GOLang 1.5.1 (from 1.4.3) is exposing a bug in Windows. In theory,
+ // the Windows networking stack is supposed to resolve "localhost" internally,
+ // without hitting DNS, or even reading the hosts file (which is why localhost
+ // is commented out in the hosts file on Windows).
+ //
+ // We have validated that working around this using the actual IPv4 localhost
+ // address does not cause the delay.
+ //
+ // This does not occur with the docker client built with 1.4.3 on the same
+ // Windows build, regardless of whether the daemon is built using 1.5.1
+ // or 1.4.3. It does not occur on Linux. We also verified we see the same thing
+ // on a cross-compiled Windows binary (from Linux).
+ //
+ // Final note: This is a mitigation, not a 'real' fix. It is still susceptible
+ // to the delay if a user were to do 'docker run -H=tcp://localhost:2375...'
+ // explicitly.
+
+ // DefaultHTTPHost Default HTTP Host used if only port is provided to -H flag e.g. dockerd -H tcp://:8080
+ DefaultHTTPHost = "127.0.0.1"
+
+ // DefaultHost constant defines the default host string used by docker on Windows
+ DefaultHost = "npipe://" + DefaultNamedPipe
+)
diff --git a/opts/opts_unix.go b/opts/opts_unix.go
deleted file mode 100644
index 0c32367..0000000
--- a/opts/opts_unix.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// +build !windows
-
-package opts // import "github.com/docker/docker/opts"
-
-// DefaultHTTPHost Default HTTP Host used if only port is provided to -H flag e.g. dockerd -H tcp://:8080
-const DefaultHTTPHost = "localhost"
diff --git a/opts/opts_windows.go b/opts/opts_windows.go
deleted file mode 100644
index 4455c9d..0000000
--- a/opts/opts_windows.go
+++ /dev/null
@@ -1,55 +0,0 @@
-package opts // import "github.com/docker/docker/opts"
-
-// TODO Windows. Identify bug in GOLang 1.5.1+ and/or Windows Server 2016 TP5.
-//
-// On Windows, this mitigates a problem with the default options of running
-// a docker client against a local docker daemon on TP5.
-//
-// What was found that if the default host is "localhost", even if the client
-// (and daemon as this is local) is not physically on a network, and the DNS
-// cache is flushed (ipconfig /flushdns), then the client will pause for
-// exactly one second when connecting to the daemon for calls. For example
-// using docker run windowsservercore cmd, the CLI will send a create followed
-// by an attach. You see the delay between the attach finishing and the attach
-// being seen by the daemon.
-//
-// Here's some daemon debug logs with additional debug spew put in. The
-// AfterWriteJSON log is the very last thing the daemon does as part of the
-// create call. The POST /attach is the second CLI call. Notice the second
-// time gap.
-//
-// time="2015-11-06T13:38:37.259627400-08:00" level=debug msg="After createRootfs"
-// time="2015-11-06T13:38:37.263626300-08:00" level=debug msg="After setHostConfig"
-// time="2015-11-06T13:38:37.267631200-08:00" level=debug msg="before createContainerPl...."
-// time="2015-11-06T13:38:37.271629500-08:00" level=debug msg=ToDiskLocking....
-// time="2015-11-06T13:38:37.275643200-08:00" level=debug msg="loggin event...."
-// time="2015-11-06T13:38:37.277627600-08:00" level=debug msg="logged event...."
-// time="2015-11-06T13:38:37.279631800-08:00" level=debug msg="In defer func"
-// time="2015-11-06T13:38:37.282628100-08:00" level=debug msg="After daemon.create"
-// time="2015-11-06T13:38:37.286651700-08:00" level=debug msg="return 2"
-// time="2015-11-06T13:38:37.289629500-08:00" level=debug msg="Returned from daemon.ContainerCreate"
-// time="2015-11-06T13:38:37.311629100-08:00" level=debug msg="After WriteJSON"
-// ... 1 second gap here....
-// time="2015-11-06T13:38:38.317866200-08:00" level=debug msg="Calling POST /v1.22/containers/984758282b842f779e805664b2c95d563adc9a979c8a3973e68c807843ee4757/attach"
-// time="2015-11-06T13:38:38.326882500-08:00" level=info msg="POST /v1.22/containers/984758282b842f779e805664b2c95d563adc9a979c8a3973e68c807843ee4757/attach?stderr=1&stdin=1&stdout=1&stream=1"
-//
-// We suspect this is either a bug introduced in GOLang 1.5.1, or that a change
-// in GOLang 1.5.1 (from 1.4.3) is exposing a bug in Windows. In theory,
-// the Windows networking stack is supposed to resolve "localhost" internally,
-// without hitting DNS, or even reading the hosts file (which is why localhost
-// is commented out in the hosts file on Windows).
-//
-// We have validated that working around this using the actual IPv4 localhost
-// address does not cause the delay.
-//
-// This does not occur with the docker client built with 1.4.3 on the same
-// Windows build, regardless of whether the daemon is built using 1.5.1
-// or 1.4.3. It does not occur on Linux. We also verified we see the same thing
-// on a cross-compiled Windows binary (from Linux).
-//
-// Final note: This is a mitigation, not a 'real' fix. It is still susceptible
-// to the delay if a user were to do 'docker run -H=tcp://localhost:2375...'
-// explicitly.
-
-// DefaultHTTPHost Default HTTP Host used if only port is provided to -H flag e.g. dockerd -H tcp://:8080
-const DefaultHTTPHost = "127.0.0.1"
diff --git a/pkg/containerfs/containerfs.go b/pkg/containerfs/containerfs.go
index 7bb1d8c..d25826d 100644
--- a/pkg/containerfs/containerfs.go
+++ b/pkg/containerfs/containerfs.go
@@ -6,7 +6,7 @@
"github.com/containerd/continuity/driver"
"github.com/containerd/continuity/pathdriver"
- "github.com/docker/docker/pkg/symlink"
+ "github.com/moby/sys/symlink"
)
// ContainerFS is that represents a root file system
diff --git a/pkg/devicemapper/devmapper_wrapper.go b/pkg/devicemapper/devmapper_wrapper.go
index 56facd4..d518657 100644
--- a/pkg/devicemapper/devmapper_wrapper.go
+++ b/pkg/devicemapper/devmapper_wrapper.go
@@ -150,12 +150,11 @@
}
// golang issue: https://github.com/golang/go/issues/11925
- hdr := reflect.SliceHeader{
- Data: uintptr(unsafe.Pointer(uintptr(unsafe.Pointer(Cdeps)) + unsafe.Sizeof(*Cdeps))),
- Len: int(Cdeps.count),
- Cap: int(Cdeps.count),
- }
- devices := *(*[]C.uint64_t)(unsafe.Pointer(&hdr))
+ var devices []C.uint64_t
+ devicesHdr := (*reflect.SliceHeader)(unsafe.Pointer(&devices))
+ devicesHdr.Data = uintptr(unsafe.Pointer(uintptr(unsafe.Pointer(Cdeps)) + unsafe.Sizeof(*Cdeps)))
+ devicesHdr.Len = int(Cdeps.count)
+ devicesHdr.Cap = int(Cdeps.count)
deps := &Deps{
Count: uint32(Cdeps.count),
diff --git a/pkg/mount/deprecated.go b/pkg/mount/deprecated.go
index 86ef303..16c8e59 100644
--- a/pkg/mount/deprecated.go
+++ b/pkg/mount/deprecated.go
@@ -4,70 +4,64 @@
// Use github.com/moby/sys/mount and github.com/moby/sys/mountinfo instead.
import (
- sysmount "github.com/moby/sys/mount"
"github.com/moby/sys/mountinfo"
)
-// Deprecated: use github.com/moby/sys/mount instead.
-//nolint:golint
-var (
- Mount = sysmount.Mount
- ForceMount = sysmount.Mount // a deprecated synonym
- Unmount = sysmount.Unmount
- RecursiveUnmount = sysmount.RecursiveUnmount
-)
-
-// Deprecated: use github.com/moby/sys/mount instead.
-//nolint:golint
-const (
- RDONLY = sysmount.RDONLY
- NOSUID = sysmount.NOSUID
- NOEXEC = sysmount.NOEXEC
- SYNCHRONOUS = sysmount.SYNCHRONOUS
- NOATIME = sysmount.NOATIME
- BIND = sysmount.BIND
- DIRSYNC = sysmount.DIRSYNC
- MANDLOCK = sysmount.MANDLOCK
- NODEV = sysmount.NODEV
- NODIRATIME = sysmount.NODIRATIME
- UNBINDABLE = sysmount.UNBINDABLE
- RUNBINDABLE = sysmount.RUNBINDABLE
- PRIVATE = sysmount.PRIVATE
- RPRIVATE = sysmount.RPRIVATE
- SHARED = sysmount.SHARED
- RSHARED = sysmount.RSHARED
- SLAVE = sysmount.SLAVE
- RSLAVE = sysmount.RSLAVE
- RBIND = sysmount.RBIND
- RELATIME = sysmount.RELATIME
- REMOUNT = sysmount.REMOUNT
- STRICTATIME = sysmount.STRICTATIME
-)
-
-// Deprecated: use github.com/moby/sys/mount instead.
-//nolint:golint
-var (
- MergeTmpfsOptions = sysmount.MergeTmpfsOptions
-)
-
//nolint:golint
type (
// FilterFunc is a type.
// Deprecated: use github.com/moby/sys/mountinfo instead.
- FilterFunc = mountinfo.FilterFunc
- // Info is a type.
+ FilterFunc = func(*Info) (skip, stop bool)
+
+ // Info is a type
// Deprecated: use github.com/moby/sys/mountinfo instead.
- Info = mountinfo.Info // Info is deprecated
+ Info struct {
+ ID, Parent, Major, Minor int
+ Root, Mountpoint, Opts, Optional, Fstype, Source, VfsOpts string
+ }
)
// Deprecated: use github.com/moby/sys/mountinfo instead.
//nolint:golint
var (
- Mounted = mountinfo.Mounted
- GetMounts = mountinfo.GetMounts
-
+ Mounted = mountinfo.Mounted
PrefixFilter = mountinfo.PrefixFilter
SingleEntryFilter = mountinfo.SingleEntryFilter
ParentsFilter = mountinfo.ParentsFilter
- FstypeFilter = mountinfo.FstypeFilter
+ FstypeFilter = mountinfo.FSTypeFilter
)
+
+// GetMounts is a function.
+//
+// Deprecated: use github.com/moby/sys/mountinfo.GetMounts() instead.
+//nolint:golint
+func GetMounts(f FilterFunc) ([]*Info, error) {
+ fi := func(i *mountinfo.Info) (skip, stop bool) {
+ return f(toLegacyInfo(i))
+ }
+
+ mounts, err := mountinfo.GetMounts(fi)
+ if err != nil {
+ return nil, err
+ }
+ mi := make([]*Info, len(mounts))
+ for i, m := range mounts {
+ mi[i] = toLegacyInfo(m)
+ }
+ return mi, nil
+}
+
+func toLegacyInfo(m *mountinfo.Info) *Info {
+ return &Info{
+ ID: m.ID,
+ Parent: m.Parent,
+ Major: m.Major,
+ Minor: m.Minor,
+ Root: m.Root,
+ Mountpoint: m.Mountpoint,
+ Opts: m.Options,
+ Fstype: m.FSType,
+ Source: m.Source,
+ VfsOpts: m.VFSOptions,
+ }
+}
diff --git a/pkg/mount/deprecated_unix.go b/pkg/mount/deprecated_unix.go
new file mode 100644
index 0000000..1787f20
--- /dev/null
+++ b/pkg/mount/deprecated_unix.go
@@ -0,0 +1,52 @@
+// +build !darwin,!windows
+
+package mount // import "github.com/docker/docker/pkg/mount"
+
+// Deprecated: this package is not maintained and will be removed.
+// Use github.com/moby/sys/mount and github.com/moby/sys/mountinfo instead.
+
+import (
+ sysmount "github.com/moby/sys/mount"
+)
+
+// Deprecated: use github.com/moby/sys/mount instead.
+//nolint:golint
+var (
+ Mount = sysmount.Mount
+ ForceMount = sysmount.Mount // a deprecated synonym
+ Unmount = sysmount.Unmount
+ RecursiveUnmount = sysmount.RecursiveUnmount
+)
+
+// Deprecated: use github.com/moby/sys/mount instead.
+//nolint:golint
+const (
+ RDONLY = sysmount.RDONLY
+ NOSUID = sysmount.NOSUID
+ NOEXEC = sysmount.NOEXEC
+ SYNCHRONOUS = sysmount.SYNCHRONOUS
+ NOATIME = sysmount.NOATIME
+ BIND = sysmount.BIND
+ DIRSYNC = sysmount.DIRSYNC
+ MANDLOCK = sysmount.MANDLOCK
+ NODEV = sysmount.NODEV
+ NODIRATIME = sysmount.NODIRATIME
+ UNBINDABLE = sysmount.UNBINDABLE
+ RUNBINDABLE = sysmount.RUNBINDABLE
+ PRIVATE = sysmount.PRIVATE
+ RPRIVATE = sysmount.RPRIVATE
+ SHARED = sysmount.SHARED
+ RSHARED = sysmount.RSHARED
+ SLAVE = sysmount.SLAVE
+ RSLAVE = sysmount.RSLAVE
+ RBIND = sysmount.RBIND
+ RELATIME = sysmount.RELATIME
+ REMOUNT = sysmount.REMOUNT
+ STRICTATIME = sysmount.STRICTATIME
+)
+
+// Deprecated: use github.com/moby/sys/mount instead.
+//nolint:golint
+var (
+ MergeTmpfsOptions = sysmount.MergeTmpfsOptions
+)
diff --git a/pkg/symlink/deprecated.go b/pkg/symlink/deprecated.go
new file mode 100644
index 0000000..c4f12ef
--- /dev/null
+++ b/pkg/symlink/deprecated.go
@@ -0,0 +1,12 @@
+package symlink // import "github.com/docker/docker/pkg/symlink"
+
+import "github.com/moby/sys/symlink"
+
+var (
+ // EvalSymlinks is deprecated and moved to github.com/moby/sys/symlink
+ // Deprecated: use github.com/moby/sys/symlink.EvalSymlinks instead
+ EvalSymlinks = symlink.EvalSymlinks
+ // FollowSymlinkInScope is deprecated and moved to github.com/moby/sys/symlink
+ // Deprecated: use github.com/moby/sys/symlink.FollowSymlinkInScope instead
+ FollowSymlinkInScope = symlink.FollowSymlinkInScope
+)
diff --git a/pkg/symlink/fs_unix_test.go b/pkg/symlink/fs_unix_test.go
deleted file mode 100644
index 9ed1dd7..0000000
--- a/pkg/symlink/fs_unix_test.go
+++ /dev/null
@@ -1,407 +0,0 @@
-// +build !windows
-
-// Licensed under the Apache License, Version 2.0; See LICENSE.APACHE
-
-package symlink // import "github.com/docker/docker/pkg/symlink"
-
-import (
- "fmt"
- "io/ioutil"
- "os"
- "path/filepath"
- "testing"
-)
-
-// TODO Windows: This needs some serious work to port to Windows. For now,
-// turning off testing in this package.
-
-type dirOrLink struct {
- path string
- target string
-}
-
-func makeFs(tmpdir string, fs []dirOrLink) error {
- for _, s := range fs {
- s.path = filepath.Join(tmpdir, s.path)
- if s.target == "" {
- os.MkdirAll(s.path, 0755)
- continue
- }
- if err := os.MkdirAll(filepath.Dir(s.path), 0755); err != nil {
- return err
- }
- if err := os.Symlink(s.target, s.path); err != nil && !os.IsExist(err) {
- return err
- }
- }
- return nil
-}
-
-func testSymlink(tmpdir, path, expected, scope string) error {
- rewrite, err := FollowSymlinkInScope(filepath.Join(tmpdir, path), filepath.Join(tmpdir, scope))
- if err != nil {
- return err
- }
- expected, err = filepath.Abs(filepath.Join(tmpdir, expected))
- if err != nil {
- return err
- }
- if expected != rewrite {
- return fmt.Errorf("Expected %q got %q", expected, rewrite)
- }
- return nil
-}
-
-func TestFollowSymlinkAbsolute(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkAbsolute")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
- if err := makeFs(tmpdir, []dirOrLink{{path: "testdata/fs/a/d", target: "/b"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "testdata/fs/a/d/c/data", "testdata/b/c/data", "testdata"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkRelativePath(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkRelativePath")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
- if err := makeFs(tmpdir, []dirOrLink{{path: "testdata/fs/i", target: "a"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "testdata/fs/i", "testdata/fs/a", "testdata"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkSkipSymlinksOutsideScope(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkSkipSymlinksOutsideScope")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
- if err := makeFs(tmpdir, []dirOrLink{
- {path: "linkdir", target: "realdir"},
- {path: "linkdir/foo/bar"},
- }); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "linkdir/foo/bar", "linkdir/foo/bar", "linkdir/foo"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkInvalidScopePathPair(t *testing.T) {
- if _, err := FollowSymlinkInScope("toto", "testdata"); err == nil {
- t.Fatal("expected an error")
- }
-}
-
-func TestFollowSymlinkLastLink(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkLastLink")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
- if err := makeFs(tmpdir, []dirOrLink{{path: "testdata/fs/a/d", target: "/b"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "testdata/fs/a/d", "testdata/b", "testdata"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkRelativeLinkChangeScope(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkRelativeLinkChangeScope")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
- if err := makeFs(tmpdir, []dirOrLink{{path: "testdata/fs/a/e", target: "../b"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "testdata/fs/a/e/c/data", "testdata/fs/b/c/data", "testdata"); err != nil {
- t.Fatal(err)
- }
- // avoid letting allowing symlink e lead us to ../b
- // normalize to the "testdata/fs/a"
- if err := testSymlink(tmpdir, "testdata/fs/a/e", "testdata/fs/a/b", "testdata/fs/a"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkDeepRelativeLinkChangeScope(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkDeepRelativeLinkChangeScope")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- if err := makeFs(tmpdir, []dirOrLink{{path: "testdata/fs/a/f", target: "../../../../test"}}); err != nil {
- t.Fatal(err)
- }
- // avoid letting symlink f lead us out of the "testdata" scope
- // we don't normalize because symlink f is in scope and there is no
- // information leak
- if err := testSymlink(tmpdir, "testdata/fs/a/f", "testdata/test", "testdata"); err != nil {
- t.Fatal(err)
- }
- // avoid letting symlink f lead us out of the "testdata/fs" scope
- // we don't normalize because symlink f is in scope and there is no
- // information leak
- if err := testSymlink(tmpdir, "testdata/fs/a/f", "testdata/fs/test", "testdata/fs"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkRelativeLinkChain(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkRelativeLinkChain")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- // avoid letting symlink g (pointed at by symlink h) take out of scope
- // TODO: we should probably normalize to scope here because ../[....]/root
- // is out of scope and we leak information
- if err := makeFs(tmpdir, []dirOrLink{
- {path: "testdata/fs/b/h", target: "../g"},
- {path: "testdata/fs/g", target: "../../../../../../../../../../../../root"},
- }); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "testdata/fs/b/h", "testdata/root", "testdata"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkBreakoutPath(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkBreakoutPath")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- // avoid letting symlink -> ../directory/file escape from scope
- // normalize to "testdata/fs/j"
- if err := makeFs(tmpdir, []dirOrLink{{path: "testdata/fs/j/k", target: "../i/a"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "testdata/fs/j/k", "testdata/fs/j/i/a", "testdata/fs/j"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkToRoot(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkToRoot")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- // make sure we don't allow escaping to /
- // normalize to dir
- if err := makeFs(tmpdir, []dirOrLink{{path: "foo", target: "/"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "foo", "", ""); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkSlashDotdot(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkSlashDotdot")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
- tmpdir = filepath.Join(tmpdir, "dir", "subdir")
-
- // make sure we don't allow escaping to /
- // normalize to dir
- if err := makeFs(tmpdir, []dirOrLink{{path: "foo", target: "/../../"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "foo", "", ""); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkDotdot(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkDotdot")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
- tmpdir = filepath.Join(tmpdir, "dir", "subdir")
-
- // make sure we stay in scope without leaking information
- // this also checks for escaping to /
- // normalize to dir
- if err := makeFs(tmpdir, []dirOrLink{{path: "foo", target: "../../"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "foo", "", ""); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkRelativePath2(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkRelativePath2")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- if err := makeFs(tmpdir, []dirOrLink{{path: "bar/foo", target: "baz/target"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "bar/foo", "bar/baz/target", ""); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkScopeLink(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkScopeLink")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- if err := makeFs(tmpdir, []dirOrLink{
- {path: "root2"},
- {path: "root", target: "root2"},
- {path: "root2/foo", target: "../bar"},
- }); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "root/foo", "root/bar", "root"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkRootScope(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkRootScope")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- expected, err := filepath.EvalSymlinks(tmpdir)
- if err != nil {
- t.Fatal(err)
- }
- rewrite, err := FollowSymlinkInScope(tmpdir, "/")
- if err != nil {
- t.Fatal(err)
- }
- if rewrite != expected {
- t.Fatalf("expected %q got %q", expected, rewrite)
- }
-}
-
-func TestFollowSymlinkEmpty(t *testing.T) {
- res, err := FollowSymlinkInScope("", "")
- if err != nil {
- t.Fatal(err)
- }
- wd, err := os.Getwd()
- if err != nil {
- t.Fatal(err)
- }
- if res != wd {
- t.Fatalf("expected %q got %q", wd, res)
- }
-}
-
-func TestFollowSymlinkCircular(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkCircular")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- if err := makeFs(tmpdir, []dirOrLink{{path: "root/foo", target: "foo"}}); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "root/foo", "", "root"); err == nil {
- t.Fatal("expected an error for foo -> foo")
- }
-
- if err := makeFs(tmpdir, []dirOrLink{
- {path: "root/bar", target: "baz"},
- {path: "root/baz", target: "../bak"},
- {path: "root/bak", target: "/bar"},
- }); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "root/foo", "", "root"); err == nil {
- t.Fatal("expected an error for bar -> baz -> bak -> bar")
- }
-}
-
-func TestFollowSymlinkComplexChainWithTargetPathsContainingLinks(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkComplexChainWithTargetPathsContainingLinks")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- if err := makeFs(tmpdir, []dirOrLink{
- {path: "root2"},
- {path: "root", target: "root2"},
- {path: "root/a", target: "r/s"},
- {path: "root/r", target: "../root/t"},
- {path: "root/root/t/s/b", target: "/../u"},
- {path: "root/u/c", target: "."},
- {path: "root/u/x/y", target: "../v"},
- {path: "root/u/v", target: "/../w"},
- }); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "root/a/b/c/x/y/z", "root/w/z", "root"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkBreakoutNonExistent(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkBreakoutNonExistent")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- if err := makeFs(tmpdir, []dirOrLink{
- {path: "root/slash", target: "/"},
- {path: "root/sym", target: "/idontexist/../slash"},
- }); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "root/sym/file", "root/file", "root"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestFollowSymlinkNoLexicalCleaning(t *testing.T) {
- tmpdir, err := ioutil.TempDir("", "TestFollowSymlinkNoLexicalCleaning")
- if err != nil {
- t.Fatal(err)
- }
- defer os.RemoveAll(tmpdir)
-
- if err := makeFs(tmpdir, []dirOrLink{
- {path: "root/sym", target: "/foo/bar"},
- {path: "root/hello", target: "/sym/../baz"},
- }); err != nil {
- t.Fatal(err)
- }
- if err := testSymlink(tmpdir, "root/hello", "root/foo/baz", "root"); err != nil {
- t.Fatal(err)
- }
-}
diff --git a/pkg/sysinfo/sysinfo_linux.go b/pkg/sysinfo/sysinfo_linux.go
index cabae5e..42709a4 100644
--- a/pkg/sysinfo/sysinfo_linux.go
+++ b/pkg/sysinfo/sysinfo_linux.go
@@ -8,6 +8,7 @@
"strings"
"sync"
+ cdcgroups "github.com/containerd/cgroups"
"github.com/opencontainers/runc/libcontainer/cgroups"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
@@ -56,7 +57,7 @@
for _, o := range options {
o(&opts)
}
- if cgroups.IsCgroup2UnifiedMode() {
+ if cdcgroups.Mode() == cdcgroups.Unified {
return newV2(quiet, &opts)
}
diff --git a/pkg/system/chtimes_unix_test.go b/pkg/system/chtimes_linux_test.go
similarity index 98%
rename from pkg/system/chtimes_unix_test.go
rename to pkg/system/chtimes_linux_test.go
index 779ed4b..273fc0a 100644
--- a/pkg/system/chtimes_unix_test.go
+++ b/pkg/system/chtimes_linux_test.go
@@ -1,5 +1,3 @@
-// +build !windows
-
package system // import "github.com/docker/docker/pkg/system"
import (
diff --git a/pkg/system/chtimes_unix.go b/pkg/system/chtimes_nowindows.go
similarity index 100%
rename from pkg/system/chtimes_unix.go
rename to pkg/system/chtimes_nowindows.go
diff --git a/pkg/system/rm_unix.go b/pkg/system/rm.go
similarity index 98%
rename from pkg/system/rm_unix.go
rename to pkg/system/rm.go
index 6ba3fb3..c5d80eb 100644
--- a/pkg/system/rm_unix.go
+++ b/pkg/system/rm.go
@@ -1,4 +1,4 @@
-// +build !windows
+// +build !darwin,!windows
package system // import "github.com/docker/docker/pkg/system"
diff --git a/pkg/system/rm_nodarwin_test.go b/pkg/system/rm_nodarwin_test.go
new file mode 100644
index 0000000..f3db37e
--- /dev/null
+++ b/pkg/system/rm_nodarwin_test.go
@@ -0,0 +1,36 @@
+// +build !darwin
+
+package system // import "github.com/docker/docker/pkg/system"
+
+import (
+ "io/ioutil"
+ "testing"
+)
+
+func TestEnsureRemoveAllNotExist(t *testing.T) {
+ // should never return an error for a non-existent path
+ if err := EnsureRemoveAll("/non/existent/path"); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestEnsureRemoveAllWithDir(t *testing.T) {
+ dir, err := ioutil.TempDir("", "test-ensure-removeall-with-dir")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := EnsureRemoveAll(dir); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestEnsureRemoveAllWithFile(t *testing.T) {
+ tmp, err := ioutil.TempFile("", "test-ensure-removeall-with-dir")
+ if err != nil {
+ t.Fatal(err)
+ }
+ tmp.Close()
+ if err := EnsureRemoveAll(tmp.Name()); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/pkg/system/rm_test.go b/pkg/system/rm_test.go
index 4ba2c8f..245edb2 100644
--- a/pkg/system/rm_test.go
+++ b/pkg/system/rm_test.go
@@ -1,10 +1,11 @@
+// +build !darwin,!windows
+
package system // import "github.com/docker/docker/pkg/system"
import (
"io/ioutil"
"os"
"path/filepath"
- "runtime"
"testing"
"time"
@@ -12,36 +13,7 @@
"gotest.tools/v3/skip"
)
-func TestEnsureRemoveAllNotExist(t *testing.T) {
- // should never return an error for a non-existent path
- if err := EnsureRemoveAll("/non/existent/path"); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestEnsureRemoveAllWithDir(t *testing.T) {
- dir, err := ioutil.TempDir("", "test-ensure-removeall-with-dir")
- if err != nil {
- t.Fatal(err)
- }
- if err := EnsureRemoveAll(dir); err != nil {
- t.Fatal(err)
- }
-}
-
-func TestEnsureRemoveAllWithFile(t *testing.T) {
- tmp, err := ioutil.TempFile("", "test-ensure-removeall-with-dir")
- if err != nil {
- t.Fatal(err)
- }
- tmp.Close()
- if err := EnsureRemoveAll(tmp.Name()); err != nil {
- t.Fatal(err)
- }
-}
-
func TestEnsureRemoveAllWithMount(t *testing.T) {
- skip.If(t, runtime.GOOS == "windows", "mount not supported on Windows")
skip.If(t, os.Getuid() != 0, "skipping test that requires root")
dir1, err := ioutil.TempDir("", "test-ensure-removeall-with-dir1")
diff --git a/plugin/manager.go b/plugin/manager.go
index db38fca..c237378 100644
--- a/plugin/manager.go
+++ b/plugin/manager.go
@@ -23,7 +23,6 @@
"github.com/docker/docker/pkg/system"
v2 "github.com/docker/docker/plugin/v2"
"github.com/docker/docker/registry"
- "github.com/moby/sys/mount"
digest "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
@@ -159,10 +158,8 @@
if restart {
pm.enable(p, c, true)
- } else {
- if err := mount.RecursiveUnmount(filepath.Join(pm.config.Root, id)); err != nil {
- return errors.Wrap(err, "error cleaning up plugin mounts")
- }
+ } else if err := recursiveUnmount(filepath.Join(pm.config.Root, id)); err != nil {
+ return errors.Wrap(err, "error cleaning up plugin mounts")
}
return nil
}
diff --git a/plugin/manager_linux.go b/plugin/manager_linux.go
index a147df6..d224514 100644
--- a/plugin/manager_linux.go
+++ b/plugin/manager_linux.go
@@ -346,3 +346,7 @@
return p, nil
}
+
+func recursiveUnmount(target string) error {
+ return mount.RecursiveUnmount(target)
+}
diff --git a/plugin/manager_windows.go b/plugin/manager_windows.go
index 89595df..003b221 100644
--- a/plugin/manager_windows.go
+++ b/plugin/manager_windows.go
@@ -26,3 +26,7 @@
// Shutdown plugins
func (pm *Manager) Shutdown() {
}
+
+func recursiveUnmount(_ string) error {
+ return nil
+}
diff --git a/profiles/seccomp/default.json b/profiles/seccomp/default.json
index edf8ee2..3ae143c 100644
--- a/profiles/seccomp/default.json
+++ b/profiles/seccomp/default.json
@@ -232,6 +232,8 @@
"openat",
"openat2",
"pause",
+ "pidfd_open",
+ "pidfd_send_signal",
"pipe",
"pipe2",
"poll",
@@ -721,6 +723,7 @@
{
"names": [
"kcmp",
+ "pidfd_getfd",
"process_vm_readv",
"process_vm_writev",
"ptrace"
diff --git a/profiles/seccomp/default_linux.go b/profiles/seccomp/default_linux.go
index 18b5cb0..232a414 100644
--- a/profiles/seccomp/default_linux.go
+++ b/profiles/seccomp/default_linux.go
@@ -225,6 +225,8 @@
"openat",
"openat2",
"pause",
+ "pidfd_open",
+ "pidfd_send_signal",
"pipe",
"pipe2",
"poll",
@@ -622,6 +624,7 @@
{
Names: []string{
"kcmp",
+ "pidfd_getfd",
"process_vm_readv",
"process_vm_writev",
"ptrace",
diff --git a/registry/auth.go b/registry/auth.go
index 0b2f66c..2d0ecde 100644
--- a/registry/auth.go
+++ b/registry/auth.go
@@ -77,22 +77,21 @@
// endpoint will be pinged to get authorization challenges. These challenges
// will be used to authenticate against the registry to validate credentials.
func loginV2(authConfig *types.AuthConfig, endpoint APIEndpoint, userAgent string) (string, string, error) {
- logrus.Debugf("attempting v2 login to registry endpoint %s", strings.TrimRight(endpoint.URL.String(), "/")+"/v2/")
+ var (
+ endpointStr = strings.TrimRight(endpoint.URL.String(), "/") + "/v2/"
+ modifiers = Headers(userAgent, nil)
+ authTransport = transport.NewTransport(NewTransport(endpoint.TLSConfig), modifiers...)
+ credentialAuthConfig = *authConfig
+ creds = loginCredentialStore{authConfig: &credentialAuthConfig}
+ )
- modifiers := Headers(userAgent, nil)
- authTransport := transport.NewTransport(NewTransport(endpoint.TLSConfig), modifiers...)
-
- credentialAuthConfig := *authConfig
- creds := loginCredentialStore{
- authConfig: &credentialAuthConfig,
- }
+ logrus.Debugf("attempting v2 login to registry endpoint %s", endpointStr)
loginClient, foundV2, err := v2AuthHTTPClient(endpoint.URL, authTransport, modifiers, creds, nil)
if err != nil {
return "", "", err
}
- endpointStr := strings.TrimRight(endpoint.URL.String(), "/") + "/v2/"
req, err := http.NewRequest(http.MethodGet, endpointStr, nil)
if err != nil {
if !foundV2 {
diff --git a/testutil/daemon/daemon.go b/testutil/daemon/daemon.go
index 3b9f039..1b29654 100644
--- a/testutil/daemon/daemon.go
+++ b/testutil/daemon/daemon.go
@@ -24,7 +24,6 @@
"github.com/docker/docker/testutil/request"
"github.com/docker/go-connections/sockets"
"github.com/docker/go-connections/tlsconfig"
- "github.com/moby/sys/mount"
"github.com/pkg/errors"
"gotest.tools/v3/assert"
)
@@ -812,15 +811,6 @@
return info
}
-// cleanupMount unmounts the daemon root directory, or logs a message if
-// unmounting failed.
-func cleanupMount(t testing.TB, d *Daemon) {
- t.Helper()
- if err := mount.Unmount(d.Root); err != nil {
- d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
- }
-}
-
// cleanupRaftDir removes swarmkit wal files if present
func cleanupRaftDir(t testing.TB, d *Daemon) {
t.Helper()
diff --git a/testutil/daemon/daemon_unix.go b/testutil/daemon/daemon_unix.go
index fac5297..788f420 100644
--- a/testutil/daemon/daemon_unix.go
+++ b/testutil/daemon/daemon_unix.go
@@ -11,10 +11,20 @@
"syscall"
"testing"
+ "github.com/moby/sys/mount"
"golang.org/x/sys/unix"
"gotest.tools/v3/assert"
)
+// cleanupMount unmounts the daemon root directory, or logs a message if
+// unmounting failed.
+func cleanupMount(t testing.TB, d *Daemon) {
+ t.Helper()
+ if err := mount.Unmount(d.Root); err != nil {
+ d.log.Logf("[%s] unable to unmount daemon root (%s): %v", d.id, d.Root, err)
+ }
+}
+
func cleanupNetworkNamespace(t testing.TB, d *Daemon) {
t.Helper()
// Cleanup network namespaces in the exec root of this
diff --git a/testutil/daemon/daemon_windows.go b/testutil/daemon/daemon_windows.go
index 601f60a..be94b52 100644
--- a/testutil/daemon/daemon_windows.go
+++ b/testutil/daemon/daemon_windows.go
@@ -24,6 +24,8 @@
return fmt.Errorf("daemon reload not supported")
}
+func cleanupMount(_ testing.TB, _ *Daemon) {}
+
func cleanupNetworkNamespace(_ testing.TB, _ *Daemon) {}
// CgroupNamespace returns the cgroup namespace the daemon is running in
diff --git a/vendor.conf b/vendor.conf
index 96ba6ad..f389f5e 100644
--- a/vendor.conf
+++ b/vendor.conf
@@ -9,14 +9,20 @@
github.com/moby/locker 281af2d563954745bea9d1487c965f24d30742fe # v1.0.1
github.com/moby/term 7f0af18e79f2784809e9cef63d0df5aa2c79d76e
-github.com/creack/pty 3a6a957789163cacdfe0e291617a1c8e80612c11 # v1.1.9
+# Note that this dependency uses submodules, providing the github.com/moby/sys/mount,
+# github.com/moby/sys/mountinfo, and github.com/moby/sys/symlink modules. Our vendoring
+# tool (vndr) currently does not support submodules / vendoring sub-paths, so we vendor
+# the top-level moby/sys repository (which contains both) and pick the most recent tag,
+# which could be either `mountinfo/vX.Y.Z`, `mount/vX.Y.Z`, or `symlink/vX.Y.Z`.
+github.com/moby/sys 1bc8673b57550ddf85262eb0fed0aac651a37dab # symlink/v0.1.0
+
+github.com/creack/pty 2a38352e8b4d7ab6c336eef107e42a55e72e7fbc # v1.1.11
github.com/sirupsen/logrus 6699a89a232f3db797f2e280639854bbc4b89725 # v1.7.0
github.com/tchap/go-patricia a7f0089c6f496e8e70402f61733606daa326cac5 # v2.3.0
golang.org/x/net ab34263943818b32f575efc978a3d24e80b04bd7
-golang.org/x/sys aee5d888a86055dc6ab0342f9cdc7b53aaeaec62
+golang.org/x/sys eeed37f84f13f52d35e095e8023ba65671ff86a1
github.com/docker/go-units 519db1ee28dcc9fd2474ae59fca29a810482bfb1 # v0.4.0
github.com/docker/go-connections 7395e3f8aa162843a74ed6d48e79627d9792ac55 # v0.4.0
-github.com/moby/sys 6154f11e6840c0d6b0dbb23f4125a6134b3013c9 # mountinfo/v0.1.3
golang.org/x/text 23ae387dee1f90d29a23c0e87ee0b46038fbed0e # v0.3.3
gotest.tools/v3 bb0d8a963040ea5048dcef1a14d8f8b58a33d4b3 # v3.0.2
github.com/google/go-cmp 3af367b6b30c263d47e8895973edcca9a49cf029 # v0.2.0
@@ -27,20 +33,21 @@
golang.org/x/sync cd5d95a43a6e21273425c7ae415d3df9ea832eeb
# buildkit
-github.com/moby/buildkit 4d1f260e8490ec438ab66e08bb105577aca0ce06
-github.com/tonistiigi/fsutil ae3a8d753069d0f76fbee396457e8b6cfd7cb8c3
+github.com/moby/buildkit 6861f17f15364de0fe1fd1e6e8da07598a485123
+github.com/tonistiigi/fsutil c3ed55f3b48161fd3dc42c17ba09e12ac52d57dc
+github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2
github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746
-github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7
+github.com/opentracing/opentracing-go d34af3eaa63c4d08ab54863a4bdd0daa45212e12 # v1.2.0
github.com/google/shlex e7afc7fbc51079733e9468cdfd1efcd7d196cd1d
-github.com/opentracing-contrib/go-stdlib b1a47cfbdd7543e70e9ef3e73d0802ad306cc1cc
-github.com/mitchellh/hashstructure 2bca23e0e452137f789efbc8610126fd8b94f73b
+github.com/opentracing-contrib/go-stdlib 8a6ff1ad1691a29e4f7b5d46604f97634997c8c4 # v1.0.0
+github.com/mitchellh/hashstructure a38c50148365edc8df43c1580c48fb2b3a1e9cd7 # v1.0.0
github.com/gofrs/flock 6caa7350c26b838538005fae7dbee4e69d9398db # v0.7.3
github.com/grpc-ecosystem/go-grpc-middleware 3c51f7f332123e8be5a157c0802a228ac85bf9db # v1.2.0
# libnetwork
# When updating, also update LIBNETWORK_COMMIT in hack/dockerfile/install/proxy.installer accordingly
-github.com/docker/libnetwork d0951081b35fa4216fc4f0064bf065beeb55a74b
+github.com/docker/libnetwork d511c60c5c23e6753631244f271a1ec6097254a5
github.com/docker/go-events e31b211e4f1cd09aa76fe4ac244571fab96ae47f
github.com/armon/go-radix e39d623f12e8e41c7b5529e9a9dd67a1e2261f80
github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
@@ -123,12 +130,12 @@
google.golang.org/genproto 3f1135a288c9a07e340ae8ba4cc6c7065a3160e8
# containerd
-github.com/containerd/containerd c623d1b36f09f8ef6536a057bd658b3aa8632828 # v1.4.1
+github.com/containerd/containerd d4e78200d6da62480c85bf6f26b7221ea938f396
github.com/containerd/fifo f15a3290365b9d2627d189e619ab4008e0069caf
github.com/containerd/continuity efbc4488d8fe1bdc16bde3b2d2990d9b3a899165
github.com/containerd/cgroups 318312a373405e5e91134d8063d04d59768a1bff
github.com/containerd/console 5d7e1412f07b502a01029ea20e20e0d2be31fa7c # v1.0.1
-github.com/containerd/go-runc 7016d3ce2328dd2cb1192b2076ebd565c4e8df0c
+github.com/containerd/go-runc 16b287bc67d069a60fa48db15f330b790b74365b
github.com/containerd/typeurl cd3ce7159eae562a4f60ceff37dada11a939d247 # v1.0.1
github.com/containerd/ttrpc 72bb1b21c5b0a4a107f59dd85f6ab58e564b68d6 # v1.0.1
github.com/gogo/googleapis 01e0f9cca9b92166042241267ee2a5cdf5cff46c # v1.3.2
@@ -161,7 +168,7 @@
github.com/cespare/xxhash/v2 d7df74196a9e781ede915320c11c378c1b2f3a1f # v2.1.1
# cli
-github.com/spf13/cobra a684a6d7f5e37385d954dd3b5a14fc6912c6ab9d # v1.0.0
+github.com/spf13/cobra 86f8bfd7fef868a174e1b606783bd7f5c82ddf8f # v1.1.1
github.com/spf13/pflag 2e9d26c8c37aae03e3f9d4e90b7116f5accb7cab # v1.0.5
github.com/inconshreveable/mousetrap 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75 # v1.0.0
github.com/morikuni/aec 39771216ff4c63d11f5e604076f9c45e8be1067b # v1.0.0
diff --git a/vendor/github.com/containerd/containerd/README.md b/vendor/github.com/containerd/containerd/README.md
index a973d51..320c112 100644
--- a/vendor/github.com/containerd/containerd/README.md
+++ b/vendor/github.com/containerd/containerd/README.md
@@ -10,10 +10,24 @@
containerd is an industry-standard container runtime with an emphasis on simplicity, robustness and portability. It is available as a daemon for Linux and Windows, which can manage the complete container lifecycle of its host system: image transfer and storage, container execution and supervision, low-level storage and network attachments, etc.
+containerd is a member of CNCF with ['graduated'](https://landscape.cncf.io/selected=containerd) status.
+
containerd is designed to be embedded into a larger system, rather than being used directly by developers or end-users.
![architecture](design/architecture.png)
+## Now Recruiting
+
+We are a large inclusive OSS project that is welcoming help of any kind shape or form:
+* Documentation help is needed to make the product easier to consume and extend.
+* We need OSS community outreach / organizing help to get the word out; manage
+and create messaging and educational content; and to help with social media, community forums/groups, and google groups.
+* We are actively inviting new [security advisors](https://github.com/containerd/project/blob/master/GOVERNANCE.md#security-advisors) to join the team.
+* New sub-projects are being created, core and non-core that could use additional development help.
+* Each of the [containerd projects](https://github.com/containerd) has a list of issues currently being worked on or that need help resolving.
+ - If the issue has not already been assigned to someone, or has not made recent progress and you are interested, please inquire.
+ - If you are interested in starting with a smaller / beginner level issue, look for issues with an `exp/beginner` tag, for example [containerd/containerd beginner issues.](https://github.com/containerd/containerd/issues?q=is%3Aissue+is%3Aopen+label%3Aexp%2Fbeginner)
+
## Getting Started
See our documentation on [containerd.io](https://containerd.io):
@@ -250,10 +264,7 @@
For async communication and long running discussions please use issues and pull requests on the github repo.
This will be the best place to discuss design and implementation.
-For sync communication we have a community slack with a #containerd channel that everyone is welcome to join and chat about development.
-
-**Slack:** Catch us in the #containerd and #containerd-dev channels on dockercommunity.slack.com.
-[Click here for an invite to docker community slack.](https://dockr.ly/slack)
+For sync communication catch us in the `#containerd` and `#containerd-dev` slack channels on Cloud Native Computing Foundation's (CNCF) slack - `cloud-native.slack.com`. Everyone is welcome to join and chat. [Get Invite to CNCF slack.](https://slack.cncf.io)
### Security audit
diff --git a/vendor/github.com/containerd/containerd/remotes/docker/auth/fetch.go b/vendor/github.com/containerd/containerd/remotes/docker/auth/fetch.go
new file mode 100644
index 0000000..7a05e39
--- /dev/null
+++ b/vendor/github.com/containerd/containerd/remotes/docker/auth/fetch.go
@@ -0,0 +1,206 @@
+/*
+ Copyright The containerd Authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package auth
+
+import (
+ "context"
+ "encoding/json"
+ "net/http"
+ "net/url"
+ "strings"
+ "time"
+
+ "github.com/containerd/containerd/log"
+ remoteserrors "github.com/containerd/containerd/remotes/errors"
+ "github.com/pkg/errors"
+ "golang.org/x/net/context/ctxhttp"
+)
+
+var (
+ // ErrNoToken is returned if a request is successful but the body does not
+ // contain an authorization token.
+ ErrNoToken = errors.New("authorization server did not include a token in the response")
+)
+
+// GenerateTokenOptions generates options for fetching a token based on a challenge
+func GenerateTokenOptions(ctx context.Context, host, username, secret string, c Challenge) (TokenOptions, error) {
+ realm, ok := c.Parameters["realm"]
+ if !ok {
+ return TokenOptions{}, errors.New("no realm specified for token auth challenge")
+ }
+
+ realmURL, err := url.Parse(realm)
+ if err != nil {
+ return TokenOptions{}, errors.Wrap(err, "invalid token auth challenge realm")
+ }
+
+ to := TokenOptions{
+ Realm: realmURL.String(),
+ Service: c.Parameters["service"],
+ Username: username,
+ Secret: secret,
+ }
+
+ scope, ok := c.Parameters["scope"]
+ if ok {
+ to.Scopes = append(to.Scopes, scope)
+ } else {
+ log.G(ctx).WithField("host", host).Debug("no scope specified for token auth challenge")
+ }
+
+ return to, nil
+}
+
+// TokenOptions are optios for requesting a token
+type TokenOptions struct {
+ Realm string
+ Service string
+ Scopes []string
+ Username string
+ Secret string
+}
+
+// OAuthTokenResponse is response from fetching token with a OAuth POST request
+type OAuthTokenResponse struct {
+ AccessToken string `json:"access_token"`
+ RefreshToken string `json:"refresh_token"`
+ ExpiresIn int `json:"expires_in"`
+ IssuedAt time.Time `json:"issued_at"`
+ Scope string `json:"scope"`
+}
+
+// FetchTokenWithOAuth fetches a token using a POST request
+func FetchTokenWithOAuth(ctx context.Context, client *http.Client, headers http.Header, clientID string, to TokenOptions) (*OAuthTokenResponse, error) {
+ form := url.Values{}
+ if len(to.Scopes) > 0 {
+ form.Set("scope", strings.Join(to.Scopes, " "))
+ }
+ form.Set("service", to.Service)
+ form.Set("client_id", clientID)
+
+ if to.Username == "" {
+ form.Set("grant_type", "refresh_token")
+ form.Set("refresh_token", to.Secret)
+ } else {
+ form.Set("grant_type", "password")
+ form.Set("username", to.Username)
+ form.Set("password", to.Secret)
+ }
+
+ req, err := http.NewRequest("POST", to.Realm, strings.NewReader(form.Encode()))
+ if err != nil {
+ return nil, err
+ }
+ req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
+ if headers != nil {
+ for k, v := range headers {
+ req.Header[k] = append(req.Header[k], v...)
+ }
+ }
+
+ resp, err := ctxhttp.Do(ctx, client, req)
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode < 200 || resp.StatusCode >= 400 {
+ return nil, errors.WithStack(remoteserrors.NewUnexpectedStatusErr(resp))
+ }
+
+ decoder := json.NewDecoder(resp.Body)
+
+ var tr OAuthTokenResponse
+ if err = decoder.Decode(&tr); err != nil {
+ return nil, errors.Wrap(err, "unable to decode token response")
+ }
+
+ if tr.AccessToken == "" {
+ return nil, errors.WithStack(ErrNoToken)
+ }
+
+ return &tr, nil
+}
+
+// FetchTokenResponse is response from fetching token with GET request
+type FetchTokenResponse struct {
+ Token string `json:"token"`
+ AccessToken string `json:"access_token"`
+ ExpiresIn int `json:"expires_in"`
+ IssuedAt time.Time `json:"issued_at"`
+ RefreshToken string `json:"refresh_token"`
+}
+
+// FetchToken fetches a token using a GET request
+func FetchToken(ctx context.Context, client *http.Client, headers http.Header, to TokenOptions) (*FetchTokenResponse, error) {
+ req, err := http.NewRequest("GET", to.Realm, nil)
+ if err != nil {
+ return nil, err
+ }
+
+ if headers != nil {
+ for k, v := range headers {
+ req.Header[k] = append(req.Header[k], v...)
+ }
+ }
+
+ reqParams := req.URL.Query()
+
+ if to.Service != "" {
+ reqParams.Add("service", to.Service)
+ }
+
+ for _, scope := range to.Scopes {
+ reqParams.Add("scope", scope)
+ }
+
+ if to.Secret != "" {
+ req.SetBasicAuth(to.Username, to.Secret)
+ }
+
+ req.URL.RawQuery = reqParams.Encode()
+
+ resp, err := ctxhttp.Do(ctx, client, req)
+ if err != nil {
+ return nil, err
+ }
+ defer resp.Body.Close()
+
+ if resp.StatusCode < 200 || resp.StatusCode >= 400 {
+ return nil, errors.WithStack(remoteserrors.NewUnexpectedStatusErr(resp))
+ }
+
+ decoder := json.NewDecoder(resp.Body)
+
+ var tr FetchTokenResponse
+ if err = decoder.Decode(&tr); err != nil {
+ return nil, errors.Wrap(err, "unable to decode token response")
+ }
+
+ // `access_token` is equivalent to `token` and if both are specified
+ // the choice is undefined. Canonicalize `access_token` by sticking
+ // things in `token`.
+ if tr.AccessToken != "" {
+ tr.Token = tr.AccessToken
+ }
+
+ if tr.Token == "" {
+ return nil, errors.WithStack(ErrNoToken)
+ }
+
+ return &tr, nil
+}
diff --git a/vendor/github.com/containerd/containerd/remotes/docker/auth.go b/vendor/github.com/containerd/containerd/remotes/docker/auth/parse.go
similarity index 80%
rename from vendor/github.com/containerd/containerd/remotes/docker/auth.go
rename to vendor/github.com/containerd/containerd/remotes/docker/auth/parse.go
index 70cfdea..223fa2d 100644
--- a/vendor/github.com/containerd/containerd/remotes/docker/auth.go
+++ b/vendor/github.com/containerd/containerd/remotes/docker/auth/parse.go
@@ -14,7 +14,7 @@
limitations under the License.
*/
-package docker
+package auth
import (
"net/http"
@@ -22,31 +22,35 @@
"strings"
)
-type authenticationScheme byte
+// AuthenticationScheme defines scheme of the authentication method
+type AuthenticationScheme byte
const (
- basicAuth authenticationScheme = 1 << iota // Defined in RFC 7617
- digestAuth // Defined in RFC 7616
- bearerAuth // Defined in RFC 6750
+ // BasicAuth is scheme for Basic HTTP Authentication RFC 7617
+ BasicAuth AuthenticationScheme = 1 << iota
+ // DigestAuth is scheme for HTTP Digest Access Authentication RFC 7616
+ DigestAuth
+ // BearerAuth is scheme for OAuth 2.0 Bearer Tokens RFC 6750
+ BearerAuth
)
-// challenge carries information from a WWW-Authenticate response header.
+// Challenge carries information from a WWW-Authenticate response header.
// See RFC 2617.
-type challenge struct {
+type Challenge struct {
// scheme is the auth-scheme according to RFC 2617
- scheme authenticationScheme
+ Scheme AuthenticationScheme
// parameters are the auth-params according to RFC 2617
- parameters map[string]string
+ Parameters map[string]string
}
-type byScheme []challenge
+type byScheme []Challenge
func (bs byScheme) Len() int { return len(bs) }
func (bs byScheme) Swap(i, j int) { bs[i], bs[j] = bs[j], bs[i] }
// Sort in priority order: token > digest > basic
-func (bs byScheme) Less(i, j int) bool { return bs[i].scheme > bs[j].scheme }
+func (bs byScheme) Less(i, j int) bool { return bs[i].Scheme > bs[j].Scheme }
// Octet types from RFC 2616.
type octetType byte
@@ -90,22 +94,23 @@
}
}
-func parseAuthHeader(header http.Header) []challenge {
- challenges := []challenge{}
+// ParseAuthHeader parses challenges from WWW-Authenticate header
+func ParseAuthHeader(header http.Header) []Challenge {
+ challenges := []Challenge{}
for _, h := range header[http.CanonicalHeaderKey("WWW-Authenticate")] {
v, p := parseValueAndParams(h)
- var s authenticationScheme
+ var s AuthenticationScheme
switch v {
case "basic":
- s = basicAuth
+ s = BasicAuth
case "digest":
- s = digestAuth
+ s = DigestAuth
case "bearer":
- s = bearerAuth
+ s = BearerAuth
default:
continue
}
- challenges = append(challenges, challenge{scheme: s, parameters: p})
+ challenges = append(challenges, Challenge{Scheme: s, Parameters: p})
}
sort.Stable(byScheme(challenges))
return challenges
diff --git a/vendor/github.com/containerd/containerd/remotes/docker/authorizer.go b/vendor/github.com/containerd/containerd/remotes/docker/authorizer.go
index 001423a..67e4aea 100644
--- a/vendor/github.com/containerd/containerd/remotes/docker/authorizer.go
+++ b/vendor/github.com/containerd/containerd/remotes/docker/authorizer.go
@@ -19,21 +19,17 @@
import (
"context"
"encoding/base64"
- "encoding/json"
"fmt"
- "io"
- "io/ioutil"
"net/http"
- "net/url"
"strings"
"sync"
- "time"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
+ "github.com/containerd/containerd/remotes/docker/auth"
+ remoteerrors "github.com/containerd/containerd/remotes/errors"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- "golang.org/x/net/context/ctxhttp"
)
type dockerAuthorizer struct {
@@ -135,8 +131,8 @@
a.mu.Lock()
defer a.mu.Unlock()
- for _, c := range parseAuthHeader(last.Header) {
- if c.scheme == bearerAuth {
+ for _, c := range auth.ParseAuthHeader(last.Header) {
+ if c.Scheme == auth.BearerAuth {
if err := invalidAuthorization(c, responses); err != nil {
delete(a.handlers, host)
return err
@@ -152,26 +148,35 @@
return nil
}
- common, err := a.generateTokenOptions(ctx, host, c)
+ var username, secret string
+ if a.credentials != nil {
+ var err error
+ username, secret, err = a.credentials(host)
+ if err != nil {
+ return err
+ }
+ }
+
+ common, err := auth.GenerateTokenOptions(ctx, host, username, secret, c)
if err != nil {
return err
}
- a.handlers[host] = newAuthHandler(a.client, a.header, c.scheme, common)
+ a.handlers[host] = newAuthHandler(a.client, a.header, c.Scheme, common)
return nil
- } else if c.scheme == basicAuth && a.credentials != nil {
+ } else if c.Scheme == auth.BasicAuth && a.credentials != nil {
username, secret, err := a.credentials(host)
if err != nil {
return err
}
if username != "" && secret != "" {
- common := tokenOptions{
- username: username,
- secret: secret,
+ common := auth.TokenOptions{
+ Username: username,
+ Secret: secret,
}
- a.handlers[host] = newAuthHandler(a.client, a.header, c.scheme, common)
+ a.handlers[host] = newAuthHandler(a.client, a.header, c.Scheme, common)
return nil
}
}
@@ -179,38 +184,6 @@
return errors.Wrap(errdefs.ErrNotImplemented, "failed to find supported auth scheme")
}
-func (a *dockerAuthorizer) generateTokenOptions(ctx context.Context, host string, c challenge) (tokenOptions, error) {
- realm, ok := c.parameters["realm"]
- if !ok {
- return tokenOptions{}, errors.New("no realm specified for token auth challenge")
- }
-
- realmURL, err := url.Parse(realm)
- if err != nil {
- return tokenOptions{}, errors.Wrap(err, "invalid token auth challenge realm")
- }
-
- to := tokenOptions{
- realm: realmURL.String(),
- service: c.parameters["service"],
- }
-
- scope, ok := c.parameters["scope"]
- if ok {
- to.scopes = append(to.scopes, scope)
- } else {
- log.G(ctx).WithField("host", host).Debug("no scope specified for token auth challenge")
- }
-
- if a.credentials != nil {
- to.username, to.secret, err = a.credentials(host)
- if err != nil {
- return tokenOptions{}, err
- }
- }
- return to, nil
-}
-
// authResult is used to control limit rate.
type authResult struct {
sync.WaitGroup
@@ -227,17 +200,17 @@
client *http.Client
// only support basic and bearer schemes
- scheme authenticationScheme
+ scheme auth.AuthenticationScheme
// common contains common challenge answer
- common tokenOptions
+ common auth.TokenOptions
// scopedTokens caches token indexed by scopes, which used in
// bearer auth case
scopedTokens map[string]*authResult
}
-func newAuthHandler(client *http.Client, hdr http.Header, scheme authenticationScheme, opts tokenOptions) *authHandler {
+func newAuthHandler(client *http.Client, hdr http.Header, scheme auth.AuthenticationScheme, opts auth.TokenOptions) *authHandler {
return &authHandler{
header: hdr,
client: client,
@@ -249,17 +222,17 @@
func (ah *authHandler) authorize(ctx context.Context) (string, error) {
switch ah.scheme {
- case basicAuth:
+ case auth.BasicAuth:
return ah.doBasicAuth(ctx)
- case bearerAuth:
+ case auth.BearerAuth:
return ah.doBearerAuth(ctx)
default:
- return "", errors.Wrap(errdefs.ErrNotImplemented, "failed to find supported auth scheme")
+ return "", errors.Wrapf(errdefs.ErrNotImplemented, "failed to find supported auth scheme: %s", string(ah.scheme))
}
}
func (ah *authHandler) doBasicAuth(ctx context.Context) (string, error) {
- username, secret := ah.common.username, ah.common.secret
+ username, secret := ah.common.Username, ah.common.Secret
if username == "" || secret == "" {
return "", fmt.Errorf("failed to handle basic auth because missing username or secret")
@@ -269,14 +242,14 @@
return fmt.Sprintf("Basic %s", auth), nil
}
-func (ah *authHandler) doBearerAuth(ctx context.Context) (string, error) {
+func (ah *authHandler) doBearerAuth(ctx context.Context) (token string, err error) {
// copy common tokenOptions
to := ah.common
- to.scopes = GetTokenScopes(ctx, to.scopes)
+ to.Scopes = GetTokenScopes(ctx, to.Scopes)
// Docs: https://docs.docker.com/registry/spec/auth/scope
- scoped := strings.Join(to.scopes, " ")
+ scoped := strings.Join(to.Scopes, " ")
ah.Lock()
if r, exist := ah.scopedTokens[scoped]; exist {
@@ -291,174 +264,52 @@
ah.scopedTokens[scoped] = r
ah.Unlock()
+ defer func() {
+ token = fmt.Sprintf("Bearer %s", token)
+ r.token, r.err = token, err
+ r.Done()
+ }()
+
// fetch token for the resource scope
- var (
- token string
- err error
- )
- if to.secret != "" {
+ if to.Secret != "" {
+ defer func() {
+ err = errors.Wrap(err, "failed to fetch oauth token")
+ }()
// credential information is provided, use oauth POST endpoint
- token, err = ah.fetchTokenWithOAuth(ctx, to)
- err = errors.Wrap(err, "failed to fetch oauth token")
- } else {
- // do request anonymously
- token, err = ah.fetchToken(ctx, to)
- err = errors.Wrap(err, "failed to fetch anonymous token")
- }
- token = fmt.Sprintf("Bearer %s", token)
-
- r.token, r.err = token, err
- r.Done()
- return r.token, r.err
-}
-
-type tokenOptions struct {
- realm string
- service string
- scopes []string
- username string
- secret string
-}
-
-type postTokenResponse struct {
- AccessToken string `json:"access_token"`
- RefreshToken string `json:"refresh_token"`
- ExpiresIn int `json:"expires_in"`
- IssuedAt time.Time `json:"issued_at"`
- Scope string `json:"scope"`
-}
-
-func (ah *authHandler) fetchTokenWithOAuth(ctx context.Context, to tokenOptions) (string, error) {
- form := url.Values{}
- if len(to.scopes) > 0 {
- form.Set("scope", strings.Join(to.scopes, " "))
- }
- form.Set("service", to.service)
- // TODO: Allow setting client_id
- form.Set("client_id", "containerd-client")
-
- if to.username == "" {
- form.Set("grant_type", "refresh_token")
- form.Set("refresh_token", to.secret)
- } else {
- form.Set("grant_type", "password")
- form.Set("username", to.username)
- form.Set("password", to.secret)
- }
-
- req, err := http.NewRequest("POST", to.realm, strings.NewReader(form.Encode()))
- if err != nil {
- return "", err
- }
- req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8")
- if ah.header != nil {
- for k, v := range ah.header {
- req.Header[k] = append(req.Header[k], v...)
+ // TODO: Allow setting client_id
+ resp, err := auth.FetchTokenWithOAuth(ctx, ah.client, ah.header, "containerd-client", to)
+ if err != nil {
+ var errStatus remoteerrors.ErrUnexpectedStatus
+ if errors.As(err, &errStatus) {
+ // Registries without support for POST may return 404 for POST /v2/token.
+ // As of September 2017, GCR is known to return 404.
+ // As of February 2018, JFrog Artifactory is known to return 401.
+ if (errStatus.StatusCode == 405 && to.Username != "") || errStatus.StatusCode == 404 || errStatus.StatusCode == 401 {
+ resp, err := auth.FetchToken(ctx, ah.client, ah.header, to)
+ if err != nil {
+ return "", err
+ }
+ return resp.Token, nil
+ }
+ log.G(ctx).WithFields(logrus.Fields{
+ "status": errStatus.Status,
+ "body": string(errStatus.Body),
+ }).Debugf("token request failed")
+ }
+ return "", err
}
+ return resp.AccessToken, nil
}
-
- resp, err := ctxhttp.Do(ctx, ah.client, req)
+ // do request anonymously
+ resp, err := auth.FetchToken(ctx, ah.client, ah.header, to)
if err != nil {
- return "", err
+ return "", errors.Wrap(err, "failed to fetch anonymous token")
}
- defer resp.Body.Close()
-
- // Registries without support for POST may return 404 for POST /v2/token.
- // As of September 2017, GCR is known to return 404.
- // As of February 2018, JFrog Artifactory is known to return 401.
- if (resp.StatusCode == 405 && to.username != "") || resp.StatusCode == 404 || resp.StatusCode == 401 {
- return ah.fetchToken(ctx, to)
- } else if resp.StatusCode < 200 || resp.StatusCode >= 400 {
- b, _ := ioutil.ReadAll(io.LimitReader(resp.Body, 64000)) // 64KB
- log.G(ctx).WithFields(logrus.Fields{
- "status": resp.Status,
- "body": string(b),
- }).Debugf("token request failed")
- // TODO: handle error body and write debug output
- return "", errors.Errorf("unexpected status: %s", resp.Status)
- }
-
- decoder := json.NewDecoder(resp.Body)
-
- var tr postTokenResponse
- if err = decoder.Decode(&tr); err != nil {
- return "", fmt.Errorf("unable to decode token response: %s", err)
- }
-
- return tr.AccessToken, nil
+ return resp.Token, nil
}
-type getTokenResponse struct {
- Token string `json:"token"`
- AccessToken string `json:"access_token"`
- ExpiresIn int `json:"expires_in"`
- IssuedAt time.Time `json:"issued_at"`
- RefreshToken string `json:"refresh_token"`
-}
-
-// fetchToken fetches a token using a GET request
-func (ah *authHandler) fetchToken(ctx context.Context, to tokenOptions) (string, error) {
- req, err := http.NewRequest("GET", to.realm, nil)
- if err != nil {
- return "", err
- }
-
- if ah.header != nil {
- for k, v := range ah.header {
- req.Header[k] = append(req.Header[k], v...)
- }
- }
-
- reqParams := req.URL.Query()
-
- if to.service != "" {
- reqParams.Add("service", to.service)
- }
-
- for _, scope := range to.scopes {
- reqParams.Add("scope", scope)
- }
-
- if to.secret != "" {
- req.SetBasicAuth(to.username, to.secret)
- }
-
- req.URL.RawQuery = reqParams.Encode()
-
- resp, err := ctxhttp.Do(ctx, ah.client, req)
- if err != nil {
- return "", err
- }
- defer resp.Body.Close()
-
- if resp.StatusCode < 200 || resp.StatusCode >= 400 {
- // TODO: handle error body and write debug output
- return "", errors.Errorf("unexpected status: %s", resp.Status)
- }
-
- decoder := json.NewDecoder(resp.Body)
-
- var tr getTokenResponse
- if err = decoder.Decode(&tr); err != nil {
- return "", fmt.Errorf("unable to decode token response: %s", err)
- }
-
- // `access_token` is equivalent to `token` and if both are specified
- // the choice is undefined. Canonicalize `access_token` by sticking
- // things in `token`.
- if tr.AccessToken != "" {
- tr.Token = tr.AccessToken
- }
-
- if tr.Token == "" {
- return "", ErrNoToken
- }
-
- return tr.Token, nil
-}
-
-func invalidAuthorization(c challenge, responses []*http.Response) error {
- errStr := c.parameters["error"]
+func invalidAuthorization(c auth.Challenge, responses []*http.Response) error {
+ errStr := c.Parameters["error"]
if errStr == "" {
return nil
}
diff --git a/vendor/github.com/containerd/containerd/remotes/docker/pusher.go b/vendor/github.com/containerd/containerd/remotes/docker/pusher.go
index 98ea515..13fc136 100644
--- a/vendor/github.com/containerd/containerd/remotes/docker/pusher.go
+++ b/vendor/github.com/containerd/containerd/remotes/docker/pusher.go
@@ -30,6 +30,7 @@
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/remotes"
+ remoteserrors "github.com/containerd/containerd/remotes/errors"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
@@ -112,8 +113,9 @@
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest)
}
} else if resp.StatusCode != http.StatusNotFound {
- // TODO: log error
- return nil, errors.Errorf("unexpected response: %s", resp.Status)
+ err := remoteserrors.NewUnexpectedStatusErr(resp)
+ log.G(ctx).WithField("resp", resp).WithField("body", string(err.(remoteserrors.ErrUnexpectedStatus).Body)).Debug("unexpected response")
+ return nil, err
}
}
@@ -166,8 +168,9 @@
})
return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest)
default:
- // TODO: log error
- return nil, errors.Errorf("unexpected response: %s", resp.Status)
+ err := remoteserrors.NewUnexpectedStatusErr(resp)
+ log.G(ctx).WithField("resp", resp).WithField("body", string(err.(remoteserrors.ErrUnexpectedStatus).Body)).Debug("unexpected response")
+ return nil, err
}
var (
@@ -244,8 +247,9 @@
switch resp.StatusCode {
case http.StatusOK, http.StatusCreated, http.StatusNoContent:
default:
- // TODO: log error
- pr.CloseWithError(errors.Errorf("unexpected response: %s", resp.Status))
+ err := remoteserrors.NewUnexpectedStatusErr(resp)
+ log.G(ctx).WithField("resp", resp).WithField("body", string(err.(remoteserrors.ErrUnexpectedStatus).Body)).Debug("unexpected response")
+ pr.CloseWithError(err)
}
respC <- resp
}()
diff --git a/vendor/github.com/containerd/containerd/remotes/docker/resolver.go b/vendor/github.com/containerd/containerd/remotes/docker/resolver.go
index 53e42ec..07640f2 100644
--- a/vendor/github.com/containerd/containerd/remotes/docker/resolver.go
+++ b/vendor/github.com/containerd/containerd/remotes/docker/resolver.go
@@ -41,10 +41,6 @@
)
var (
- // ErrNoToken is returned if a request is successful but the body does not
- // contain an authorization token.
- ErrNoToken = errors.New("authorization server did not include a token in the response")
-
// ErrInvalidAuthorization is used when credentials are passed to a server but
// those credentials are rejected.
ErrInvalidAuthorization = errors.New("authorization failed")
diff --git a/vendor/github.com/containerd/containerd/remotes/errors/errors.go b/vendor/github.com/containerd/containerd/remotes/errors/errors.go
new file mode 100644
index 0000000..e58e4af
--- /dev/null
+++ b/vendor/github.com/containerd/containerd/remotes/errors/errors.go
@@ -0,0 +1,46 @@
+/*
+ Copyright The containerd Authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package errors
+
+import (
+ "fmt"
+ "io"
+ "io/ioutil"
+ "net/http"
+)
+
+var _ error = ErrUnexpectedStatus{}
+
+// ErrUnexpectedStatus is returned if a registry API request returned with unexpected HTTP status
+type ErrUnexpectedStatus struct {
+ Status string
+ StatusCode int
+ Body []byte
+}
+
+func (e ErrUnexpectedStatus) Error() string {
+ return fmt.Sprintf("unexpected status: %s", e.Status)
+}
+
+// NewUnexpectedStatusErr creates an ErrUnexpectedStatus from HTTP response
+func NewUnexpectedStatusErr(resp *http.Response) error {
+ var b []byte
+ if resp.Body != nil {
+ b, _ = ioutil.ReadAll(io.LimitReader(resp.Body, 64000)) // 64KB
+ }
+ return ErrUnexpectedStatus{Status: resp.Status, StatusCode: resp.StatusCode, Body: b}
+}
diff --git a/vendor/github.com/containerd/containerd/runtime/v1/shim/client/client.go b/vendor/github.com/containerd/containerd/runtime/v1/shim/client/client.go
index 9653454..562ee6c 100644
--- a/vendor/github.com/containerd/containerd/runtime/v1/shim/client/client.go
+++ b/vendor/github.com/containerd/containerd/runtime/v1/shim/client/client.go
@@ -22,7 +22,6 @@
"context"
"fmt"
"io"
- "io/ioutil"
"net"
"os"
"os/exec"
@@ -68,24 +67,22 @@
}
defer f.Close()
- stdoutCopy := ioutil.Discard
- stderrCopy := ioutil.Discard
- stdoutLog, err := v1.OpenShimStdoutLog(ctx, config.WorkDir)
- if err != nil {
- return nil, nil, errors.Wrapf(err, "failed to create stdout log")
- }
-
- stderrLog, err := v1.OpenShimStderrLog(ctx, config.WorkDir)
- if err != nil {
- return nil, nil, errors.Wrapf(err, "failed to create stderr log")
- }
+ var stdoutLog io.ReadWriteCloser
+ var stderrLog io.ReadWriteCloser
if debug {
- stdoutCopy = os.Stdout
- stderrCopy = os.Stderr
- }
+ stdoutLog, err = v1.OpenShimStdoutLog(ctx, config.WorkDir)
+ if err != nil {
+ return nil, nil, errors.Wrapf(err, "failed to create stdout log")
+ }
- go io.Copy(stdoutCopy, stdoutLog)
- go io.Copy(stderrCopy, stderrLog)
+ stderrLog, err = v1.OpenShimStderrLog(ctx, config.WorkDir)
+ if err != nil {
+ return nil, nil, errors.Wrapf(err, "failed to create stderr log")
+ }
+
+ go io.Copy(os.Stdout, stdoutLog)
+ go io.Copy(os.Stderr, stderrLog)
+ }
cmd, err := newCommand(binary, daemonAddress, debug, config, f, stdoutLog, stderrLog)
if err != nil {
diff --git a/vendor/github.com/containerd/containerd/vendor.conf b/vendor/github.com/containerd/containerd/vendor.conf
index 59ec791..ad72fb6 100644
--- a/vendor/github.com/containerd/containerd/vendor.conf
+++ b/vendor/github.com/containerd/containerd/vendor.conf
@@ -7,6 +7,7 @@
github.com/containerd/continuity efbc4488d8fe1bdc16bde3b2d2990d9b3a899165
github.com/containerd/fifo f15a3290365b9d2627d189e619ab4008e0069caf
github.com/containerd/go-runc 7016d3ce2328dd2cb1192b2076ebd565c4e8df0c
+github.com/containerd/nri 0afc7f031eaf9c7d9c1a381b7ab5462e89c998fc
github.com/containerd/ttrpc v1.0.1
github.com/containerd/typeurl v1.0.1
github.com/coreos/go-systemd/v22 v22.1.0
@@ -57,7 +58,7 @@
github.com/cilium/ebpf 1c8d4c9ef7759622653a1d319284a44652333b28
# cri dependencies
-github.com/containerd/cri 4e6644c8cf7fb825f62e0007421b7d83dfeab5a1 # master
+github.com/containerd/cri 35e623e6bf7512e8c82b8ac6052cb1d720189f28 # master
github.com/davecgh/go-spew v1.1.1
github.com/docker/docker 4634ce647cf2ce2c6031129ccd109e557244986f
github.com/docker/spdystream 449fdfce4d962303d702fec724ef0ad181c92528
diff --git a/vendor/github.com/containerd/containerd/version/version.go b/vendor/github.com/containerd/containerd/version/version.go
index 9a23540..3eb8c90 100644
--- a/vendor/github.com/containerd/containerd/version/version.go
+++ b/vendor/github.com/containerd/containerd/version/version.go
@@ -23,7 +23,7 @@
Package = "github.com/containerd/containerd"
// Version holds the complete version number. Filled in at linking time.
- Version = "1.4.1+unknown"
+ Version = "1.4.0+unknown"
// Revision is filled with the VCS (e.g. git) revision being used to build
// the program at linking time.
diff --git a/vendor/github.com/containerd/go-runc/go.mod b/vendor/github.com/containerd/go-runc/go.mod
index d833ee1..f69c26f 100644
--- a/vendor/github.com/containerd/go-runc/go.mod
+++ b/vendor/github.com/containerd/go-runc/go.mod
@@ -3,8 +3,9 @@
go 1.13
require (
- github.com/containerd/console v0.0.0-20191206165004-02ecf6a7291e
- github.com/opencontainers/runtime-spec v1.0.1
- github.com/pkg/errors v0.8.1
- golang.org/x/sys v0.0.0-20191210023423-ac6580df4449
+ github.com/containerd/console v1.0.1
+ github.com/opencontainers/runtime-spec v1.0.2
+ github.com/pkg/errors v0.9.1
+ github.com/sirupsen/logrus v1.7.0
+ golang.org/x/sys v0.0.0-20200916030750-2334cc1a136f
)
diff --git a/vendor/github.com/containerd/go-runc/io_unix.go b/vendor/github.com/containerd/go-runc/io_unix.go
index 567cd07..ccf1dd4 100644
--- a/vendor/github.com/containerd/go-runc/io_unix.go
+++ b/vendor/github.com/containerd/go-runc/io_unix.go
@@ -20,7 +20,9 @@
import (
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
+ "runtime"
)
// NewPipeIO creates pipe pairs to be used with runc
@@ -47,7 +49,13 @@
}
pipes = append(pipes, stdin)
if err = unix.Fchown(int(stdin.r.Fd()), uid, gid); err != nil {
- return nil, errors.Wrap(err, "failed to chown stdin")
+ // TODO: revert with proper darwin solution, skipping for now
+ // as darwin chown is returning EINVAL on anonymous pipe
+ if runtime.GOOS == "darwin" {
+ logrus.WithError(err).Debug("failed to chown stdin, ignored")
+ } else {
+ return nil, errors.Wrap(err, "failed to chown stdin")
+ }
}
}
if option.OpenStdout {
@@ -56,7 +64,13 @@
}
pipes = append(pipes, stdout)
if err = unix.Fchown(int(stdout.w.Fd()), uid, gid); err != nil {
- return nil, errors.Wrap(err, "failed to chown stdout")
+ // TODO: revert with proper darwin solution, skipping for now
+ // as darwin chown is returning EINVAL on anonymous pipe
+ if runtime.GOOS == "darwin" {
+ logrus.WithError(err).Debug("failed to chown stdout, ignored")
+ } else {
+ return nil, errors.Wrap(err, "failed to chown stdout")
+ }
}
}
if option.OpenStderr {
@@ -65,7 +79,13 @@
}
pipes = append(pipes, stderr)
if err = unix.Fchown(int(stderr.w.Fd()), uid, gid); err != nil {
- return nil, errors.Wrap(err, "failed to chown stderr")
+ // TODO: revert with proper darwin solution, skipping for now
+ // as darwin chown is returning EINVAL on anonymous pipe
+ if runtime.GOOS == "darwin" {
+ logrus.WithError(err).Debug("failed to chown stderr, ignored")
+ } else {
+ return nil, errors.Wrap(err, "failed to chown stderr")
+ }
}
}
return &pipeIO{
diff --git a/vendor/github.com/containerd/go-runc/runc.go b/vendor/github.com/containerd/go-runc/runc.go
index c3a95af..f5f03ae 100644
--- a/vendor/github.com/containerd/go-runc/runc.go
+++ b/vendor/github.com/containerd/go-runc/runc.go
@@ -29,7 +29,6 @@
"path/filepath"
"strconv"
"strings"
- "syscall"
"time"
specs "github.com/opencontainers/runtime-spec/specs-go"
@@ -55,24 +54,9 @@
DefaultCommand = "runc"
)
-// Runc is the client to the runc cli
-type Runc struct {
- //If command is empty, DefaultCommand is used
- Command string
- Root string
- Debug bool
- Log string
- LogFormat Format
- PdeathSignal syscall.Signal
- Setpgid bool
- Criu string
- SystemdCgroup bool
- Rootless *bool // nil stands for "auto"
-}
-
// List returns all containers created inside the provided runc root directory
func (r *Runc) List(context context.Context) ([]*Container, error) {
- data, err := cmdOutput(r.command(context, "list", "--format=json"), false)
+ data, err := cmdOutput(r.command(context, "list", "--format=json"), false, nil)
defer putBuf(data)
if err != nil {
return nil, err
@@ -86,7 +70,7 @@
// State returns the state for the container provided by id
func (r *Runc) State(context context.Context, id string) (*Container, error) {
- data, err := cmdOutput(r.command(context, "state", id), true)
+ data, err := cmdOutput(r.command(context, "state", id), true, nil)
defer putBuf(data)
if err != nil {
return nil, fmt.Errorf("%s: %s", err, data.String())
@@ -111,6 +95,7 @@
NoPivot bool
NoNewKeyring bool
ExtraFiles []*os.File
+ Started chan<- int
}
func (o *CreateOpts) args() (out []string, err error) {
@@ -156,7 +141,7 @@
cmd.ExtraFiles = opts.ExtraFiles
if cmd.Stdout == nil && cmd.Stderr == nil {
- data, err := cmdOutput(cmd, true)
+ data, err := cmdOutput(cmd, true, nil)
defer putBuf(data)
if err != nil {
return fmt.Errorf("%s: %s", err, data.String())
@@ -176,7 +161,7 @@
}
status, err := Monitor.Wait(cmd, ec)
if err == nil && status != 0 {
- err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
+ err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
}
return err
}
@@ -191,6 +176,7 @@
PidFile string
ConsoleSocket ConsoleSocket
Detach bool
+ Started chan<- int
}
func (o *ExecOpts) args() (out []string, err error) {
@@ -210,9 +196,12 @@
return out, nil
}
-// Exec executres and additional process inside the container based on a full
+// Exec executes an additional process inside the container based on a full
// OCI Process specification
func (r *Runc) Exec(context context.Context, id string, spec specs.Process, opts *ExecOpts) error {
+ if opts.Started != nil {
+ defer close(opts.Started)
+ }
f, err := ioutil.TempFile(os.Getenv("XDG_RUNTIME_DIR"), "runc-process")
if err != nil {
return err
@@ -236,10 +225,10 @@
opts.Set(cmd)
}
if cmd.Stdout == nil && cmd.Stderr == nil {
- data, err := cmdOutput(cmd, true)
+ data, err := cmdOutput(cmd, true, opts.Started)
defer putBuf(data)
if err != nil {
- return fmt.Errorf("%s: %s", err, data.String())
+ return fmt.Errorf("%w: %s", err, data.String())
}
return nil
}
@@ -247,6 +236,9 @@
if err != nil {
return err
}
+ if opts.Started != nil {
+ opts.Started <- cmd.Process.Pid
+ }
if opts != nil && opts.IO != nil {
if c, ok := opts.IO.(StartCloser); ok {
if err := c.CloseAfterStart(); err != nil {
@@ -256,7 +248,7 @@
}
status, err := Monitor.Wait(cmd, ec)
if err == nil && status != 0 {
- err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
+ err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
}
return err
}
@@ -264,6 +256,9 @@
// Run runs the create, start, delete lifecycle of the container
// and returns its exit status after it has exited
func (r *Runc) Run(context context.Context, id, bundle string, opts *CreateOpts) (int, error) {
+ if opts.Started != nil {
+ defer close(opts.Started)
+ }
args := []string{"run", "--bundle", bundle}
if opts != nil {
oargs, err := opts.args()
@@ -280,9 +275,12 @@
if err != nil {
return -1, err
}
+ if opts.Started != nil {
+ opts.Started <- cmd.Process.Pid
+ }
status, err := Monitor.Wait(cmd, ec)
if err == nil && status != 0 {
- err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
+ err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
}
return status, err
}
@@ -403,7 +401,7 @@
// Ps lists all the processes inside the container returning their pids
func (r *Runc) Ps(context context.Context, id string) ([]int, error) {
- data, err := cmdOutput(r.command(context, "ps", "--format", "json", id), true)
+ data, err := cmdOutput(r.command(context, "ps", "--format", "json", id), true, nil)
defer putBuf(data)
if err != nil {
return nil, fmt.Errorf("%s: %s", err, data.String())
@@ -417,7 +415,7 @@
// Top lists all the processes inside the container returning the full ps data
func (r *Runc) Top(context context.Context, id string, psOptions string) (*TopResults, error) {
- data, err := cmdOutput(r.command(context, "ps", "--format", "table", id, psOptions), true)
+ data, err := cmdOutput(r.command(context, "ps", "--format", "table", id, psOptions), true, nil)
defer putBuf(data)
if err != nil {
return nil, fmt.Errorf("%s: %s", err, data.String())
@@ -452,6 +450,10 @@
// EmptyNamespaces creates a namespace for the container but does not save its properties
// Provide the namespaces you wish to be checkpointed without their settings on restore
EmptyNamespaces []string
+ // LazyPages uses userfaultfd to lazily restore memory pages
+ LazyPages bool
+ // StatusFile is the file criu writes \0 to once lazy-pages is ready
+ StatusFile *os.File
}
type CgroupMode string
@@ -493,6 +495,9 @@
for _, ns := range o.EmptyNamespaces {
out = append(out, "--empty-ns", ns)
}
+ if o.LazyPages {
+ out = append(out, "--lazy-pages")
+ }
return out
}
@@ -511,13 +516,23 @@
// Checkpoint allows you to checkpoint a container using criu
func (r *Runc) Checkpoint(context context.Context, id string, opts *CheckpointOpts, actions ...CheckpointAction) error {
args := []string{"checkpoint"}
+ extraFiles := []*os.File{}
if opts != nil {
args = append(args, opts.args()...)
+ if opts.StatusFile != nil {
+ // pass the status file to the child process
+ extraFiles = []*os.File{opts.StatusFile}
+ // set status-fd to 3 as this will be the file descriptor
+ // of the first file passed with cmd.ExtraFiles
+ args = append(args, "--status-fd", "3")
+ }
}
for _, a := range actions {
args = a(args)
}
- return r.runOrError(r.command(context, append(args, id)...))
+ cmd := r.command(context, append(args, id)...)
+ cmd.ExtraFiles = extraFiles
+ return r.runOrError(cmd)
}
type RestoreOpts struct {
@@ -583,7 +598,7 @@
}
status, err := Monitor.Wait(cmd, ec)
if err == nil && status != 0 {
- err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
+ err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
}
return status, err
}
@@ -612,7 +627,7 @@
// Version returns the runc and runtime-spec versions
func (r *Runc) Version(context context.Context) (Version, error) {
- data, err := cmdOutput(r.command(context, "--version"), false)
+ data, err := cmdOutput(r.command(context, "--version"), false, nil)
defer putBuf(data)
if err != nil {
return Version{}, err
@@ -680,11 +695,11 @@
}
status, err := Monitor.Wait(cmd, ec)
if err == nil && status != 0 {
- err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
+ err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
}
return err
}
- data, err := cmdOutput(cmd, true)
+ data, err := cmdOutput(cmd, true, nil)
defer putBuf(data)
if err != nil {
return fmt.Errorf("%s: %s", err, data.String())
@@ -694,7 +709,7 @@
// callers of cmdOutput are expected to call putBuf on the returned Buffer
// to ensure it is released back to the shared pool after use.
-func cmdOutput(cmd *exec.Cmd, combined bool) (*bytes.Buffer, error) {
+func cmdOutput(cmd *exec.Cmd, combined bool, started chan<- int) (*bytes.Buffer, error) {
b := getBuf()
cmd.Stdout = b
@@ -705,11 +720,22 @@
if err != nil {
return nil, err
}
+ if started != nil {
+ started <- cmd.Process.Pid
+ }
status, err := Monitor.Wait(cmd, ec)
if err == nil && status != 0 {
- err = fmt.Errorf("%s did not terminate successfully", cmd.Args[0])
+ err = fmt.Errorf("%s did not terminate successfully: %w", cmd.Args[0], &ExitError{status})
}
return b, err
}
+
+type ExitError struct {
+ Status int
+}
+
+func (e *ExitError) Error() string {
+ return fmt.Sprintf("exit status %d", e.Status)
+}
diff --git a/vendor/github.com/containerd/go-runc/runc_unix.go b/vendor/github.com/containerd/go-runc/runc_unix.go
new file mode 100644
index 0000000..548ffd6
--- /dev/null
+++ b/vendor/github.com/containerd/go-runc/runc_unix.go
@@ -0,0 +1,38 @@
+//+build !windows
+
+/*
+ Copyright The containerd Authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package runc
+
+import (
+ "golang.org/x/sys/unix"
+)
+
+// Runc is the client to the runc cli
+type Runc struct {
+ //If command is empty, DefaultCommand is used
+ Command string
+ Root string
+ Debug bool
+ Log string
+ LogFormat Format
+ PdeathSignal unix.Signal
+ Setpgid bool
+ Criu string
+ SystemdCgroup bool
+ Rootless *bool // nil stands for "auto"
+}
diff --git a/vendor/github.com/containerd/go-runc/runc_windows.go b/vendor/github.com/containerd/go-runc/runc_windows.go
new file mode 100644
index 0000000..c5873de
--- /dev/null
+++ b/vendor/github.com/containerd/go-runc/runc_windows.go
@@ -0,0 +1,31 @@
+/*
+ Copyright The containerd Authors.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+package runc
+
+// Runc is the client to the runc cli
+type Runc struct {
+ //If command is empty, DefaultCommand is used
+ Command string
+ Root string
+ Debug bool
+ Log string
+ LogFormat Format
+ Setpgid bool
+ Criu string
+ SystemdCgroup bool
+ Rootless *bool // nil stands for "auto"
+}
diff --git a/vendor/github.com/creack/pty/run.go b/vendor/github.com/creack/pty/run.go
index 959be26..b079425 100644
--- a/vendor/github.com/creack/pty/run.go
+++ b/vendor/github.com/creack/pty/run.go
@@ -11,6 +11,8 @@
// Start assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout,
// and c.Stderr, calls c.Start, and returns the File of the tty's
// corresponding pty.
+//
+// Starts the process in a new session and sets the controlling terminal.
func Start(c *exec.Cmd) (pty *os.File, err error) {
return StartWithSize(c, nil)
}
@@ -19,16 +21,35 @@
// and c.Stderr, calls c.Start, and returns the File of the tty's
// corresponding pty.
//
-// This will resize the pty to the specified size before starting the command
+// This will resize the pty to the specified size before starting the command.
+// Starts the process in a new session and sets the controlling terminal.
func StartWithSize(c *exec.Cmd, sz *Winsize) (pty *os.File, err error) {
+ if c.SysProcAttr == nil {
+ c.SysProcAttr = &syscall.SysProcAttr{}
+ }
+ c.SysProcAttr.Setsid = true
+ c.SysProcAttr.Setctty = true
+ return StartWithAttrs(c, sz, c.SysProcAttr)
+}
+
+// StartWithAttrs assigns a pseudo-terminal tty os.File to c.Stdin, c.Stdout,
+// and c.Stderr, calls c.Start, and returns the File of the tty's
+// corresponding pty.
+//
+// This will resize the pty to the specified size before starting the command if a size is provided.
+// The `attrs` parameter overrides the one set in c.SysProcAttr.
+//
+// This should generally not be needed. Used in some edge cases where it is needed to create a pty
+// without a controlling terminal.
+func StartWithAttrs(c *exec.Cmd, sz *Winsize, attrs *syscall.SysProcAttr) (pty *os.File, err error) {
pty, tty, err := Open()
if err != nil {
return nil, err
}
defer tty.Close()
+
if sz != nil {
- err = Setsize(pty, sz)
- if err != nil {
+ if err := Setsize(pty, sz); err != nil {
pty.Close()
return nil, err
}
@@ -42,15 +63,11 @@
if c.Stdin == nil {
c.Stdin = tty
}
- if c.SysProcAttr == nil {
- c.SysProcAttr = &syscall.SysProcAttr{}
- }
- c.SysProcAttr.Setctty = true
- c.SysProcAttr.Setsid = true
- c.SysProcAttr.Ctty = int(tty.Fd())
- err = c.Start()
- if err != nil {
- pty.Close()
+
+ c.SysProcAttr = attrs
+
+ if err := c.Start(); err != nil {
+ _ = pty.Close()
return nil, err
}
return pty, err
diff --git a/vendor/github.com/creack/pty/ztypes_freebsd_arm64.go b/vendor/github.com/creack/pty/ztypes_freebsd_arm64.go
new file mode 100644
index 0000000..4418139
--- /dev/null
+++ b/vendor/github.com/creack/pty/ztypes_freebsd_arm64.go
@@ -0,0 +1,13 @@
+// Code generated by cmd/cgo -godefs; DO NOT EDIT.
+// cgo -godefs types_freebsd.go
+
+package pty
+
+const (
+ _C_SPECNAMELEN = 0xff
+)
+
+type fiodgnameArg struct {
+ Len int32
+ Buf *byte
+}
diff --git a/vendor/github.com/creack/pty/ztypes_openbsd_386.go b/vendor/github.com/creack/pty/ztypes_openbsd_32bit_int.go
similarity index 61%
rename from vendor/github.com/creack/pty/ztypes_openbsd_386.go
rename to vendor/github.com/creack/pty/ztypes_openbsd_32bit_int.go
index ccb3aab..d7cab4a 100644
--- a/vendor/github.com/creack/pty/ztypes_openbsd_386.go
+++ b/vendor/github.com/creack/pty/ztypes_openbsd_32bit_int.go
@@ -1,5 +1,5 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_openbsd.go
+// +build openbsd
+// +build 386 amd64 arm arm64
package pty
diff --git a/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go b/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go
deleted file mode 100644
index e670516..0000000
--- a/vendor/github.com/creack/pty/ztypes_openbsd_amd64.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_openbsd.go
-
-package pty
-
-type ptmget struct {
- Cfd int32
- Sfd int32
- Cn [16]int8
- Sn [16]int8
-}
-
-var ioctl_PTMGET = 0x40287401
diff --git a/vendor/github.com/docker/libnetwork/drivers/bridge/bridge.go b/vendor/github.com/docker/libnetwork/drivers/bridge/bridge.go
index 88fbafa..f8e751b 100644
--- a/vendor/github.com/docker/libnetwork/drivers/bridge/bridge.go
+++ b/vendor/github.com/docker/libnetwork/drivers/bridge/bridge.go
@@ -57,6 +57,7 @@
type configuration struct {
EnableIPForwarding bool
EnableIPTables bool
+ EnableIP6Tables bool
EnableUserlandProxy bool
UserlandProxyPath string
}
@@ -133,22 +134,27 @@
config *networkConfiguration
endpoints map[string]*bridgeEndpoint // key: endpoint id
portMapper *portmapper.PortMapper
+ portMapperV6 *portmapper.PortMapper
driver *driver // The network's driver
iptCleanFuncs iptablesCleanFuncs
sync.Mutex
}
type driver struct {
- config *configuration
- network *bridgeNetwork
- natChain *iptables.ChainInfo
- filterChain *iptables.ChainInfo
- isolationChain1 *iptables.ChainInfo
- isolationChain2 *iptables.ChainInfo
- networks map[string]*bridgeNetwork
- store datastore.DataStore
- nlh *netlink.Handle
- configNetwork sync.Mutex
+ config *configuration
+ network *bridgeNetwork
+ natChain *iptables.ChainInfo
+ filterChain *iptables.ChainInfo
+ isolationChain1 *iptables.ChainInfo
+ isolationChain2 *iptables.ChainInfo
+ natChainV6 *iptables.ChainInfo
+ filterChainV6 *iptables.ChainInfo
+ isolationChain1V6 *iptables.ChainInfo
+ isolationChain2V6 *iptables.ChainInfo
+ networks map[string]*bridgeNetwork
+ store datastore.DataStore
+ nlh *netlink.Handle
+ configNetwork sync.Mutex
sync.Mutex
}
@@ -277,7 +283,7 @@
n.iptCleanFuncs = append(n.iptCleanFuncs, clean)
}
-func (n *bridgeNetwork) getDriverChains() (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
+func (n *bridgeNetwork) getDriverChains(version iptables.IPVersion) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
n.Lock()
defer n.Unlock()
@@ -285,6 +291,10 @@
return nil, nil, nil, nil, types.BadRequestErrorf("no driver found")
}
+ if version == iptables.IPv6 {
+ return n.driver.natChainV6, n.driver.filterChainV6, n.driver.isolationChain1V6, n.driver.isolationChain2V6, nil
+ }
+
return n.driver.natChain, n.driver.filterChain, n.driver.isolationChain1, n.driver.isolationChain2, nil
}
@@ -323,17 +333,31 @@
}
// Install the rules to isolate this network against each of the other networks
- return setINC(thisConfig.BridgeName, enable)
+ if n.driver.config.EnableIP6Tables {
+ err := setINC(iptables.IPv6, thisConfig.BridgeName, enable)
+ if err != nil {
+ return err
+ }
+ }
+
+ if n.driver.config.EnableIPTables {
+ return setINC(iptables.IPv4, thisConfig.BridgeName, enable)
+ }
+ return nil
}
func (d *driver) configure(option map[string]interface{}) error {
var (
- config *configuration
- err error
- natChain *iptables.ChainInfo
- filterChain *iptables.ChainInfo
- isolationChain1 *iptables.ChainInfo
- isolationChain2 *iptables.ChainInfo
+ config *configuration
+ err error
+ natChain *iptables.ChainInfo
+ filterChain *iptables.ChainInfo
+ isolationChain1 *iptables.ChainInfo
+ isolationChain2 *iptables.ChainInfo
+ natChainV6 *iptables.ChainInfo
+ filterChainV6 *iptables.ChainInfo
+ isolationChain1V6 *iptables.ChainInfo
+ isolationChain2V6 *iptables.ChainInfo
)
genericData, ok := option[netlabel.GenericData]
@@ -354,23 +378,46 @@
return &ErrInvalidDriverConfig{}
}
- if config.EnableIPTables {
+ if config.EnableIPTables || config.EnableIP6Tables {
if _, err := os.Stat("/proc/sys/net/bridge"); err != nil {
if out, err := exec.Command("modprobe", "-va", "bridge", "br_netfilter").CombinedOutput(); err != nil {
logrus.Warnf("Running modprobe bridge br_netfilter failed with message: %s, error: %v", out, err)
}
}
- removeIPChains()
- natChain, filterChain, isolationChain1, isolationChain2, err = setupIPChains(config)
+ }
+
+ if config.EnableIPTables {
+ removeIPChains(iptables.IPv4)
+
+ natChain, filterChain, isolationChain1, isolationChain2, err = setupIPChains(config, iptables.IPv4)
if err != nil {
return err
}
+
// Make sure on firewall reload, first thing being re-played is chains creation
- iptables.OnReloaded(func() { logrus.Debugf("Recreating iptables chains on firewall reload"); setupIPChains(config) })
+ iptables.OnReloaded(func() {
+ logrus.Debugf("Recreating iptables chains on firewall reload")
+ setupIPChains(config, iptables.IPv4)
+ })
+ }
+
+ if config.EnableIP6Tables {
+ removeIPChains(iptables.IPv6)
+
+ natChainV6, filterChainV6, isolationChain1V6, isolationChain2V6, err = setupIPChains(config, iptables.IPv6)
+ if err != nil {
+ return err
+ }
+
+ // Make sure on firewall reload, first thing being re-played is chains creation
+ iptables.OnReloaded(func() {
+ logrus.Debugf("Recreating ip6tables chains on firewall reload")
+ setupIPChains(config, iptables.IPv6)
+ })
}
if config.EnableIPForwarding {
- err = setupIPForwarding(config.EnableIPTables)
+ err = setupIPForwarding(config.EnableIPTables, config.EnableIP6Tables)
if err != nil {
logrus.Warn(err)
return err
@@ -382,6 +429,10 @@
d.filterChain = filterChain
d.isolationChain1 = isolationChain1
d.isolationChain2 = isolationChain2
+ d.natChainV6 = natChainV6
+ d.filterChainV6 = filterChainV6
+ d.isolationChain1V6 = isolationChain1V6
+ d.isolationChain2V6 = isolationChain2V6
d.config = config
d.Unlock()
@@ -644,12 +695,13 @@
// Create and set network handler in driver
network := &bridgeNetwork{
- id: config.ID,
- endpoints: make(map[string]*bridgeEndpoint),
- config: config,
- portMapper: portmapper.New(d.config.UserlandProxyPath),
- bridge: bridgeIface,
- driver: d,
+ id: config.ID,
+ endpoints: make(map[string]*bridgeEndpoint),
+ config: config,
+ portMapper: portmapper.New(d.config.UserlandProxyPath),
+ portMapperV6: portmapper.New(d.config.UserlandProxyPath),
+ bridge: bridgeIface,
+ driver: d,
}
d.Lock()
@@ -724,11 +776,16 @@
{!d.config.EnableUserlandProxy, setupLoopbackAddressesRouting},
// Setup IPTables.
- {d.config.EnableIPTables, network.setupIPTables},
+ {d.config.EnableIPTables, network.setupIP4Tables},
+
+ // Setup IP6Tables.
+ {d.config.EnableIP6Tables, network.setupIP6Tables},
//We want to track firewalld configuration so that
//if it is started/reloaded, the rules can be applied correctly
{d.config.EnableIPTables, network.setupFirewalld},
+ // same for IPv6
+ {d.config.EnableIP6Tables, network.setupFirewalld6},
// Setup DefaultGatewayIPv4
{config.DefaultGatewayIPv4 != nil, setupGatewayIPv4},
diff --git a/vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go b/vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go
index 853129f..75b17d6 100644
--- a/vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go
+++ b/vendor/github.com/docker/libnetwork/drivers/bridge/port_mapping.go
@@ -12,7 +12,8 @@
)
var (
- defaultBindingIP = net.IPv4(0, 0, 0, 0)
+ defaultBindingIP = net.IPv4(0, 0, 0, 0)
+ defaultBindingIPV6 = net.ParseIP("::")
)
func (n *bridgeNetwork) allocatePorts(ep *bridgeEndpoint, reqDefBindIP net.IP, ulPxyEnabled bool) ([]types.PortBinding, error) {
@@ -25,7 +26,25 @@
defHostIP = reqDefBindIP
}
- return n.allocatePortsInternal(ep.extConnConfig.PortBindings, ep.addr.IP, defHostIP, ulPxyEnabled)
+ // IPv4 port binding including user land proxy
+ pb, err := n.allocatePortsInternal(ep.extConnConfig.PortBindings, ep.addr.IP, defHostIP, ulPxyEnabled)
+ if err != nil {
+ return nil, err
+ }
+
+ // IPv6 port binding excluding user land proxy
+ if n.driver.config.EnableIP6Tables && ep.addrv6 != nil {
+ // TODO IPv6 custom default binding IP
+ pbv6, err := n.allocatePortsInternal(ep.extConnConfig.PortBindings, ep.addrv6.IP, defaultBindingIPV6, false)
+ if err != nil {
+ // ensure we clear the previous allocated IPv4 ports
+ n.releasePortsInternal(pb)
+ return nil, err
+ }
+
+ pb = append(pb, pbv6...)
+ }
+ return pb, nil
}
func (n *bridgeNetwork) allocatePortsInternal(bindings []types.PortBinding, containerIP, defHostIP net.IP, ulPxyEnabled bool) ([]types.PortBinding, error) {
@@ -69,9 +88,15 @@
return err
}
+ portmapper := n.portMapper
+
+ if containerIP.To4() == nil {
+ portmapper = n.portMapperV6
+ }
+
// Try up to maxAllocatePortAttempts times to get a port that's not already allocated.
for i := 0; i < maxAllocatePortAttempts; i++ {
- if host, err = n.portMapper.MapRange(container, bnd.HostIP, int(bnd.HostPort), int(bnd.HostPortEnd), ulPxyEnabled); err == nil {
+ if host, err = portmapper.MapRange(container, bnd.HostIP, int(bnd.HostPort), int(bnd.HostPortEnd), ulPxyEnabled); err == nil {
break
}
// There is no point in immediately retrying to map an explicitly chosen port.
@@ -128,5 +153,12 @@
if err != nil {
return err
}
- return n.portMapper.Unmap(host)
+
+ portmapper := n.portMapper
+
+ if bnd.HostIP.To4() == nil {
+ portmapper = n.portMapperV6
+ }
+
+ return portmapper.Unmap(host)
}
diff --git a/vendor/github.com/docker/libnetwork/drivers/bridge/setup_firewalld.go b/vendor/github.com/docker/libnetwork/drivers/bridge/setup_firewalld.go
index 50cbdb1..82ed712 100644
--- a/vendor/github.com/docker/libnetwork/drivers/bridge/setup_firewalld.go
+++ b/vendor/github.com/docker/libnetwork/drivers/bridge/setup_firewalld.go
@@ -13,8 +13,23 @@
return IPTableCfgError(config.BridgeName)
}
- iptables.OnReloaded(func() { n.setupIPTables(config, i) })
+ iptables.OnReloaded(func() { n.setupIP4Tables(config, i) })
iptables.OnReloaded(n.portMapper.ReMapAll)
+ return nil
+}
+func (n *bridgeNetwork) setupFirewalld6(config *networkConfiguration, i *bridgeInterface) error {
+ d := n.driver
+ d.Lock()
+ driverConfig := d.config
+ d.Unlock()
+
+ // Sanity check.
+ if !driverConfig.EnableIP6Tables {
+ return IPTableCfgError(config.BridgeName)
+ }
+
+ iptables.OnReloaded(func() { n.setupIP6Tables(config, i) })
+ iptables.OnReloaded(n.portMapperV6.ReMapAll)
return nil
}
diff --git a/vendor/github.com/docker/libnetwork/drivers/bridge/setup_ip_forwarding.go b/vendor/github.com/docker/libnetwork/drivers/bridge/setup_ip_forwarding.go
index 10f61a1..2c6e080 100644
--- a/vendor/github.com/docker/libnetwork/drivers/bridge/setup_ip_forwarding.go
+++ b/vendor/github.com/docker/libnetwork/drivers/bridge/setup_ip_forwarding.go
@@ -21,7 +21,7 @@
return ioutil.WriteFile(ipv4ForwardConf, []byte{val, '\n'}, ipv4ForwardConfPerm)
}
-func setupIPForwarding(enableIPTables bool) error {
+func setupIPForwarding(enableIPTables bool, enableIP6Tables bool) error {
// Get current IPv4 forward setup
ipv4ForwardData, err := ioutil.ReadFile(ipv4ForwardConf)
if err != nil {
@@ -36,21 +36,36 @@
}
// When enabling ip_forward set the default policy on forward chain to
// drop only if the daemon option iptables is not set to false.
- if !enableIPTables {
- return nil
- }
- if err := iptables.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
- if err := configureIPForwarding(false); err != nil {
- logrus.Errorf("Disabling IP forwarding failed, %v", err)
+ if enableIPTables {
+ iptable := iptables.GetIptable(iptables.IPv4)
+ if err := iptable.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
+ if err := configureIPForwarding(false); err != nil {
+ logrus.Errorf("Disabling IP forwarding failed, %v", err)
+ }
+ return err
}
- return err
+ iptables.OnReloaded(func() {
+ logrus.Debug("Setting the default DROP policy on firewall reload")
+ if err := iptable.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
+ logrus.Warnf("Setting the default DROP policy on firewall reload failed, %v", err)
+ }
+ })
+ }
+ }
+
+ // add only iptables rules - forwarding is handled by setupIPv6Forwarding in setup_ipv6
+ if enableIP6Tables {
+ iptable := iptables.GetIptable(iptables.IPv6)
+ if err := iptable.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
+ logrus.Warnf("Setting the default DROP policy on firewall reload failed, %v", err)
}
iptables.OnReloaded(func() {
logrus.Debug("Setting the default DROP policy on firewall reload")
- if err := iptables.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
+ if err := iptable.SetDefaultPolicy(iptables.Filter, "FORWARD", iptables.Drop); err != nil {
logrus.Warnf("Setting the default DROP policy on firewall reload failed, %v", err)
}
})
}
+
return nil
}
diff --git a/vendor/github.com/docker/libnetwork/drivers/bridge/setup_ip_tables.go b/vendor/github.com/docker/libnetwork/drivers/bridge/setup_ip_tables.go
index e59b9ca..c483dda 100644
--- a/vendor/github.com/docker/libnetwork/drivers/bridge/setup_ip_tables.go
+++ b/vendor/github.com/docker/libnetwork/drivers/bridge/setup_ip_tables.go
@@ -26,7 +26,7 @@
IsolationChain2 = "DOCKER-ISOLATION-STAGE-2"
)
-func setupIPChains(config *configuration) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
+func setupIPChains(config *configuration, version iptables.IPVersion) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
// Sanity check.
if config.EnableIPTables == false {
return nil, nil, nil, nil, errors.New("cannot create new chains, EnableIPTable is disabled")
@@ -34,66 +34,105 @@
hairpinMode := !config.EnableUserlandProxy
- natChain, err := iptables.NewChain(DockerChain, iptables.Nat, hairpinMode)
+ iptable := iptables.GetIptable(version)
+
+ natChain, err := iptable.NewChain(DockerChain, iptables.Nat, hairpinMode)
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("failed to create NAT chain %s: %v", DockerChain, err)
}
defer func() {
if err != nil {
- if err := iptables.RemoveExistingChain(DockerChain, iptables.Nat); err != nil {
+ if err := iptable.RemoveExistingChain(DockerChain, iptables.Nat); err != nil {
logrus.Warnf("failed on removing iptables NAT chain %s on cleanup: %v", DockerChain, err)
}
}
}()
- filterChain, err := iptables.NewChain(DockerChain, iptables.Filter, false)
+ filterChain, err := iptable.NewChain(DockerChain, iptables.Filter, false)
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("failed to create FILTER chain %s: %v", DockerChain, err)
}
defer func() {
if err != nil {
- if err := iptables.RemoveExistingChain(DockerChain, iptables.Filter); err != nil {
+ if err := iptable.RemoveExistingChain(DockerChain, iptables.Filter); err != nil {
logrus.Warnf("failed on removing iptables FILTER chain %s on cleanup: %v", DockerChain, err)
}
}
}()
- isolationChain1, err := iptables.NewChain(IsolationChain1, iptables.Filter, false)
+ isolationChain1, err := iptable.NewChain(IsolationChain1, iptables.Filter, false)
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("failed to create FILTER isolation chain: %v", err)
}
defer func() {
if err != nil {
- if err := iptables.RemoveExistingChain(IsolationChain1, iptables.Filter); err != nil {
+ if err := iptable.RemoveExistingChain(IsolationChain1, iptables.Filter); err != nil {
logrus.Warnf("failed on removing iptables FILTER chain %s on cleanup: %v", IsolationChain1, err)
}
}
}()
- isolationChain2, err := iptables.NewChain(IsolationChain2, iptables.Filter, false)
+ isolationChain2, err := iptable.NewChain(IsolationChain2, iptables.Filter, false)
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("failed to create FILTER isolation chain: %v", err)
}
defer func() {
if err != nil {
- if err := iptables.RemoveExistingChain(IsolationChain2, iptables.Filter); err != nil {
+ if err := iptable.RemoveExistingChain(IsolationChain2, iptables.Filter); err != nil {
logrus.Warnf("failed on removing iptables FILTER chain %s on cleanup: %v", IsolationChain2, err)
}
}
}()
- if err := iptables.AddReturnRule(IsolationChain1); err != nil {
+ if err := iptable.AddReturnRule(IsolationChain1); err != nil {
return nil, nil, nil, nil, err
}
- if err := iptables.AddReturnRule(IsolationChain2); err != nil {
+ if err := iptable.AddReturnRule(IsolationChain2); err != nil {
return nil, nil, nil, nil, err
}
return natChain, filterChain, isolationChain1, isolationChain2, nil
}
-func (n *bridgeNetwork) setupIPTables(config *networkConfiguration, i *bridgeInterface) error {
+func (n *bridgeNetwork) setupIP4Tables(config *networkConfiguration, i *bridgeInterface) error {
+ d := n.driver
+ d.Lock()
+ driverConfig := d.config
+ d.Unlock()
+
+ // Sanity check.
+ if !driverConfig.EnableIPTables {
+ return errors.New("Cannot program chains, EnableIPTable is disabled")
+ }
+
+ maskedAddrv4 := &net.IPNet{
+ IP: i.bridgeIPv4.IP.Mask(i.bridgeIPv4.Mask),
+ Mask: i.bridgeIPv4.Mask,
+ }
+ return n.setupIPTables(iptables.IPv4, maskedAddrv4, config, i)
+}
+
+func (n *bridgeNetwork) setupIP6Tables(config *networkConfiguration, i *bridgeInterface) error {
+ d := n.driver
+ d.Lock()
+ driverConfig := d.config
+ d.Unlock()
+
+ // Sanity check.
+ if !driverConfig.EnableIP6Tables {
+ return errors.New("Cannot program chains, EnableIP6Tables is disabled")
+ }
+
+ maskedAddrv6 := &net.IPNet{
+ IP: i.bridgeIPv6.IP.Mask(i.bridgeIPv6.Mask),
+ Mask: i.bridgeIPv6.Mask,
+ }
+
+ return n.setupIPTables(iptables.IPv6, maskedAddrv6, config, i)
+}
+
+func (n *bridgeNetwork) setupIPTables(ipVersion iptables.IPVersion, maskedAddr *net.IPNet, config *networkConfiguration, i *bridgeInterface) error {
var err error
d := n.driver
@@ -101,62 +140,51 @@
driverConfig := d.config
d.Unlock()
- // Sanity check.
- if driverConfig.EnableIPTables == false {
- return errors.New("Cannot program chains, EnableIPTable is disabled")
- }
-
// Pickup this configuration option from driver
hairpinMode := !driverConfig.EnableUserlandProxy
- maskedAddrv4 := &net.IPNet{
- IP: i.bridgeIPv4.IP.Mask(i.bridgeIPv4.Mask),
- Mask: i.bridgeIPv4.Mask,
- }
+ iptable := iptables.GetIptable(ipVersion)
+
if config.Internal {
- if err = setupInternalNetworkRules(config.BridgeName, maskedAddrv4, config.EnableICC, true); err != nil {
+ if err = setupInternalNetworkRules(config.BridgeName, maskedAddr, config.EnableICC, true); err != nil {
return fmt.Errorf("Failed to Setup IP tables: %s", err.Error())
}
n.registerIptCleanFunc(func() error {
- return setupInternalNetworkRules(config.BridgeName, maskedAddrv4, config.EnableICC, false)
+ return setupInternalNetworkRules(config.BridgeName, maskedAddr, config.EnableICC, false)
})
} else {
- if err = setupIPTablesInternal(config.HostIP, config.BridgeName, maskedAddrv4, config.EnableICC, config.EnableIPMasquerade, hairpinMode, true); err != nil {
+ if err = setupIPTablesInternal(config.HostIP, config.BridgeName, maskedAddr, config.EnableICC, config.EnableIPMasquerade, hairpinMode, true); err != nil {
return fmt.Errorf("Failed to Setup IP tables: %s", err.Error())
}
n.registerIptCleanFunc(func() error {
- return setupIPTablesInternal(config.HostIP, config.BridgeName, maskedAddrv4, config.EnableICC, config.EnableIPMasquerade, hairpinMode, false)
+ return setupIPTablesInternal(config.HostIP, config.BridgeName, maskedAddr, config.EnableICC, config.EnableIPMasquerade, hairpinMode, false)
})
- natChain, filterChain, _, _, err := n.getDriverChains()
+ natChain, filterChain, _, _, err := n.getDriverChains(ipVersion)
if err != nil {
return fmt.Errorf("Failed to setup IP tables, cannot acquire chain info %s", err.Error())
}
- err = iptables.ProgramChain(natChain, config.BridgeName, hairpinMode, true)
+ err = iptable.ProgramChain(natChain, config.BridgeName, hairpinMode, true)
if err != nil {
return fmt.Errorf("Failed to program NAT chain: %s", err.Error())
}
- err = iptables.ProgramChain(filterChain, config.BridgeName, hairpinMode, true)
+ err = iptable.ProgramChain(filterChain, config.BridgeName, hairpinMode, true)
if err != nil {
return fmt.Errorf("Failed to program FILTER chain: %s", err.Error())
}
n.registerIptCleanFunc(func() error {
- return iptables.ProgramChain(filterChain, config.BridgeName, hairpinMode, false)
+ return iptable.ProgramChain(filterChain, config.BridgeName, hairpinMode, false)
})
n.portMapper.SetIptablesChain(natChain, n.getNetworkBridgeName())
}
d.Lock()
- err = iptables.EnsureJumpRule("FORWARD", IsolationChain1)
+ err = iptable.EnsureJumpRule("FORWARD", IsolationChain1)
d.Unlock()
- if err != nil {
- return err
- }
-
- return nil
+ return err
}
type iptRule struct {
@@ -166,7 +194,7 @@
args []string
}
-func setupIPTablesInternal(hostIP net.IP, bridgeIface string, addr net.Addr, icc, ipmasq, hairpin, enable bool) error {
+func setupIPTablesInternal(hostIP net.IP, bridgeIface string, addr *net.IPNet, icc, ipmasq, hairpin, enable bool) error {
var (
address = addr.String()
@@ -189,41 +217,50 @@
natRule := iptRule{table: iptables.Nat, chain: "POSTROUTING", preArgs: []string{"-t", "nat"}, args: natArgs}
hpNatRule := iptRule{table: iptables.Nat, chain: "POSTROUTING", preArgs: []string{"-t", "nat"}, args: hpNatArgs}
+ ipVersion := iptables.IPv4
+
+ if addr.IP.To4() == nil {
+ ipVersion = iptables.IPv6
+ }
+
// Set NAT.
if ipmasq {
- if err := programChainRule(natRule, "NAT", enable); err != nil {
+ if err := programChainRule(ipVersion, natRule, "NAT", enable); err != nil {
return err
}
}
if ipmasq && !hairpin {
- if err := programChainRule(skipDNAT, "SKIP DNAT", enable); err != nil {
+ if err := programChainRule(ipVersion, skipDNAT, "SKIP DNAT", enable); err != nil {
return err
}
}
// In hairpin mode, masquerade traffic from localhost
if hairpin {
- if err := programChainRule(hpNatRule, "MASQ LOCAL HOST", enable); err != nil {
+ if err := programChainRule(ipVersion, hpNatRule, "MASQ LOCAL HOST", enable); err != nil {
return err
}
}
// Set Inter Container Communication.
- if err := setIcc(bridgeIface, icc, enable); err != nil {
+ if err := setIcc(ipVersion, bridgeIface, icc, enable); err != nil {
return err
}
// Set Accept on all non-intercontainer outgoing packets.
- return programChainRule(outRule, "ACCEPT NON_ICC OUTGOING", enable)
+ return programChainRule(ipVersion, outRule, "ACCEPT NON_ICC OUTGOING", enable)
}
-func programChainRule(rule iptRule, ruleDescr string, insert bool) error {
+func programChainRule(version iptables.IPVersion, rule iptRule, ruleDescr string, insert bool) error {
+
+ iptable := iptables.GetIptable(version)
+
var (
prefix []string
operation string
condition bool
- doesExist = iptables.Exists(rule.table, rule.chain, rule.args...)
+ doesExist = iptable.Exists(rule.table, rule.chain, rule.args...)
)
if insert {
@@ -240,7 +277,7 @@
}
if condition {
- if err := iptables.RawCombinedOutput(append(prefix, rule.args...)...); err != nil {
+ if err := iptable.RawCombinedOutput(append(prefix, rule.args...)...); err != nil {
return fmt.Errorf("Unable to %s %s rule: %s", operation, ruleDescr, err.Error())
}
}
@@ -248,7 +285,8 @@
return nil
}
-func setIcc(bridgeIface string, iccEnable, insert bool) error {
+func setIcc(version iptables.IPVersion, bridgeIface string, iccEnable, insert bool) error {
+ iptable := iptables.GetIptable(version)
var (
table = iptables.Filter
chain = "FORWARD"
@@ -259,18 +297,18 @@
if insert {
if !iccEnable {
- iptables.Raw(append([]string{"-D", chain}, acceptArgs...)...)
+ iptable.Raw(append([]string{"-D", chain}, acceptArgs...)...)
- if !iptables.Exists(table, chain, dropArgs...) {
- if err := iptables.RawCombinedOutput(append([]string{"-A", chain}, dropArgs...)...); err != nil {
+ if !iptable.Exists(table, chain, dropArgs...) {
+ if err := iptable.RawCombinedOutput(append([]string{"-A", chain}, dropArgs...)...); err != nil {
return fmt.Errorf("Unable to prevent intercontainer communication: %s", err.Error())
}
}
} else {
- iptables.Raw(append([]string{"-D", chain}, dropArgs...)...)
+ iptable.Raw(append([]string{"-D", chain}, dropArgs...)...)
- if !iptables.Exists(table, chain, acceptArgs...) {
- if err := iptables.RawCombinedOutput(append([]string{"-I", chain}, acceptArgs...)...); err != nil {
+ if !iptable.Exists(table, chain, acceptArgs...) {
+ if err := iptable.RawCombinedOutput(append([]string{"-I", chain}, acceptArgs...)...); err != nil {
return fmt.Errorf("Unable to allow intercontainer communication: %s", err.Error())
}
}
@@ -278,12 +316,12 @@
} else {
// Remove any ICC rule.
if !iccEnable {
- if iptables.Exists(table, chain, dropArgs...) {
- iptables.Raw(append([]string{"-D", chain}, dropArgs...)...)
+ if iptable.Exists(table, chain, dropArgs...) {
+ iptable.Raw(append([]string{"-D", chain}, dropArgs...)...)
}
} else {
- if iptables.Exists(table, chain, acceptArgs...) {
- iptables.Raw(append([]string{"-D", chain}, acceptArgs...)...)
+ if iptable.Exists(table, chain, acceptArgs...) {
+ iptable.Raw(append([]string{"-D", chain}, acceptArgs...)...)
}
}
}
@@ -292,7 +330,8 @@
}
// Control Inter Network Communication. Install[Remove] only if it is [not] present.
-func setINC(iface string, enable bool) error {
+func setINC(version iptables.IPVersion, iface string, enable bool) error {
+ iptable := iptables.GetIptable(version)
var (
action = iptables.Insert
actionMsg = "add"
@@ -309,12 +348,12 @@
}
for i, chain := range chains {
- if err := iptables.ProgramRule(iptables.Filter, chain, action, rules[i]); err != nil {
+ if err := iptable.ProgramRule(iptables.Filter, chain, action, rules[i]); err != nil {
msg := fmt.Sprintf("unable to %s inter-network communication rule: %v", actionMsg, err)
if enable {
if i == 1 {
// Rollback the rule installed on first chain
- if err2 := iptables.ProgramRule(iptables.Filter, chains[0], iptables.Delete, rules[0]); err2 != nil {
+ if err2 := iptable.ProgramRule(iptables.Filter, chains[0], iptables.Delete, rules[0]); err2 != nil {
logrus.Warnf("Failed to rollback iptables rule after failure (%v): %v", err, err2)
}
}
@@ -330,37 +369,47 @@
// Obsolete chain from previous docker versions
const oldIsolationChain = "DOCKER-ISOLATION"
-func removeIPChains() {
+func removeIPChains(version iptables.IPVersion) {
+ ipt := iptables.IPTable{Version: version}
+
// Remove obsolete rules from default chains
- iptables.ProgramRule(iptables.Filter, "FORWARD", iptables.Delete, []string{"-j", oldIsolationChain})
+ ipt.ProgramRule(iptables.Filter, "FORWARD", iptables.Delete, []string{"-j", oldIsolationChain})
// Remove chains
for _, chainInfo := range []iptables.ChainInfo{
- {Name: DockerChain, Table: iptables.Nat},
- {Name: DockerChain, Table: iptables.Filter},
- {Name: IsolationChain1, Table: iptables.Filter},
- {Name: IsolationChain2, Table: iptables.Filter},
- {Name: oldIsolationChain, Table: iptables.Filter},
+ {Name: DockerChain, Table: iptables.Nat, IPTable: ipt},
+ {Name: DockerChain, Table: iptables.Filter, IPTable: ipt},
+ {Name: IsolationChain1, Table: iptables.Filter, IPTable: ipt},
+ {Name: IsolationChain2, Table: iptables.Filter, IPTable: ipt},
+ {Name: oldIsolationChain, Table: iptables.Filter, IPTable: ipt},
} {
+
if err := chainInfo.Remove(); err != nil {
logrus.Warnf("Failed to remove existing iptables entries in table %s chain %s : %v", chainInfo.Table, chainInfo.Name, err)
}
}
}
-func setupInternalNetworkRules(bridgeIface string, addr net.Addr, icc, insert bool) error {
+func setupInternalNetworkRules(bridgeIface string, addr *net.IPNet, icc, insert bool) error {
var (
inDropRule = iptRule{table: iptables.Filter, chain: IsolationChain1, args: []string{"-i", bridgeIface, "!", "-d", addr.String(), "-j", "DROP"}}
outDropRule = iptRule{table: iptables.Filter, chain: IsolationChain1, args: []string{"-o", bridgeIface, "!", "-s", addr.String(), "-j", "DROP"}}
)
- if err := programChainRule(inDropRule, "DROP INCOMING", insert); err != nil {
+
+ version := iptables.IPv4
+
+ if addr.IP.To4() == nil {
+ version = iptables.IPv6
+ }
+
+ if err := programChainRule(version, inDropRule, "DROP INCOMING", insert); err != nil {
return err
}
- if err := programChainRule(outDropRule, "DROP OUTGOING", insert); err != nil {
+ if err := programChainRule(version, outDropRule, "DROP OUTGOING", insert); err != nil {
return err
}
// Set Inter Container Communication.
- return setIcc(bridgeIface, icc, insert)
+ return setIcc(version, bridgeIface, icc, insert)
}
func clearEndpointConnections(nlh *netlink.Handle, ep *bridgeEndpoint) {
diff --git a/vendor/github.com/docker/libnetwork/drivers/overlay/encryption.go b/vendor/github.com/docker/libnetwork/drivers/overlay/encryption.go
index d71f81b..aafd9c0 100644
--- a/vendor/github.com/docker/libnetwork/drivers/overlay/encryption.go
+++ b/vendor/github.com/docker/libnetwork/drivers/overlay/encryption.go
@@ -210,7 +210,10 @@
action = "install"
)
- if add == iptables.Exists(iptables.Mangle, chain, rule...) {
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
+
+ if add == iptable.Exists(iptables.Mangle, chain, rule...) {
return
}
@@ -219,7 +222,7 @@
action = "remove"
}
- if err = iptables.RawCombinedOutput(append([]string{"-t", string(iptables.Mangle), a, chain}, rule...)...); err != nil {
+ if err = iptable.RawCombinedOutput(append([]string{"-t", string(iptables.Mangle), a, chain}, rule...)...); err != nil {
logrus.Warnf("could not %s mangle rule: %v", action, err)
}
@@ -239,16 +242,19 @@
msg = "add"
)
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
+
if !add {
action = iptables.Delete
msg = "remove"
}
- if err := iptables.ProgramRule(iptables.Filter, chain, action, accept); err != nil {
+ if err := iptable.ProgramRule(iptables.Filter, chain, action, accept); err != nil {
logrus.Errorf("could not %s input rule: %v. Please do it manually.", msg, err)
}
- if err := iptables.ProgramRule(iptables.Filter, chain, action, block); err != nil {
+ if err := iptable.ProgramRule(iptables.Filter, chain, action, block); err != nil {
logrus.Errorf("could not %s input rule: %v. Please do it manually.", msg, err)
}
diff --git a/vendor/github.com/docker/libnetwork/drivers/overlay/filter.go b/vendor/github.com/docker/libnetwork/drivers/overlay/filter.go
index 1601803..853afc6 100644
--- a/vendor/github.com/docker/libnetwork/drivers/overlay/filter.go
+++ b/vendor/github.com/docker/libnetwork/drivers/overlay/filter.go
@@ -20,7 +20,9 @@
}
func chainExists(cname string) bool {
- if _, err := iptables.Raw("-L", cname); err != nil {
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
+ if _, err := iptable.Raw("-L", cname); err != nil {
return false
}
@@ -28,22 +30,26 @@
}
func setupGlobalChain() {
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
// Because of an ungraceful shutdown, chain could already be present
if !chainExists(globalChain) {
- if err := iptables.RawCombinedOutput("-N", globalChain); err != nil {
+ if err := iptable.RawCombinedOutput("-N", globalChain); err != nil {
logrus.Errorf("could not create global overlay chain: %v", err)
return
}
}
- if !iptables.Exists(iptables.Filter, globalChain, "-j", "RETURN") {
- if err := iptables.RawCombinedOutput("-A", globalChain, "-j", "RETURN"); err != nil {
+ if !iptable.Exists(iptables.Filter, globalChain, "-j", "RETURN") {
+ if err := iptable.RawCombinedOutput("-A", globalChain, "-j", "RETURN"); err != nil {
logrus.Errorf("could not install default return chain in the overlay global chain: %v", err)
}
}
}
func setNetworkChain(cname string, remove bool) error {
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
// Initialize the onetime global overlay chain
filterOnce.Do(setupGlobalChain)
@@ -52,21 +58,21 @@
opt := "-N"
// In case of remove, make sure to flush the rules in the chain
if remove && exists {
- if err := iptables.RawCombinedOutput("-F", cname); err != nil {
+ if err := iptable.RawCombinedOutput("-F", cname); err != nil {
return fmt.Errorf("failed to flush overlay network chain %s rules: %v", cname, err)
}
opt = "-X"
}
if (!remove && !exists) || (remove && exists) {
- if err := iptables.RawCombinedOutput(opt, cname); err != nil {
+ if err := iptable.RawCombinedOutput(opt, cname); err != nil {
return fmt.Errorf("failed network chain operation %q for chain %s: %v", opt, cname, err)
}
}
if !remove {
- if !iptables.Exists(iptables.Filter, cname, "-j", "DROP") {
- if err := iptables.RawCombinedOutput("-A", cname, "-j", "DROP"); err != nil {
+ if !iptable.Exists(iptables.Filter, cname, "-j", "DROP") {
+ if err := iptable.RawCombinedOutput("-A", cname, "-j", "DROP"); err != nil {
return fmt.Errorf("failed adding default drop rule to overlay network chain %s: %v", cname, err)
}
}
@@ -92,37 +98,39 @@
if remove {
opt = "-D"
}
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
// Every time we set filters for a new subnet make sure to move the global overlay hook to the top of the both the OUTPUT and forward chains
if !remove {
for _, chain := range []string{"OUTPUT", "FORWARD"} {
- exists := iptables.Exists(iptables.Filter, chain, "-j", globalChain)
+ exists := iptable.Exists(iptables.Filter, chain, "-j", globalChain)
if exists {
- if err := iptables.RawCombinedOutput("-D", chain, "-j", globalChain); err != nil {
+ if err := iptable.RawCombinedOutput("-D", chain, "-j", globalChain); err != nil {
return fmt.Errorf("failed to delete overlay hook in chain %s while moving the hook: %v", chain, err)
}
}
- if err := iptables.RawCombinedOutput("-I", chain, "-j", globalChain); err != nil {
+ if err := iptable.RawCombinedOutput("-I", chain, "-j", globalChain); err != nil {
return fmt.Errorf("failed to insert overlay hook in chain %s: %v", chain, err)
}
}
}
// Insert/Delete the rule to jump to per-bridge chain
- exists := iptables.Exists(iptables.Filter, globalChain, "-o", brName, "-j", cname)
+ exists := iptable.Exists(iptables.Filter, globalChain, "-o", brName, "-j", cname)
if (!remove && !exists) || (remove && exists) {
- if err := iptables.RawCombinedOutput(opt, globalChain, "-o", brName, "-j", cname); err != nil {
+ if err := iptable.RawCombinedOutput(opt, globalChain, "-o", brName, "-j", cname); err != nil {
return fmt.Errorf("failed to add per-bridge filter rule for bridge %s, network chain %s: %v", brName, cname, err)
}
}
- exists = iptables.Exists(iptables.Filter, cname, "-i", brName, "-j", "ACCEPT")
+ exists = iptable.Exists(iptables.Filter, cname, "-i", brName, "-j", "ACCEPT")
if (!remove && exists) || (remove && !exists) {
return nil
}
- if err := iptables.RawCombinedOutput(opt, cname, "-i", brName, "-j", "ACCEPT"); err != nil {
+ if err := iptable.RawCombinedOutput(opt, cname, "-i", brName, "-j", "ACCEPT"); err != nil {
return fmt.Errorf("failed to add overlay filter rile for network chain %s, bridge %s: %v", cname, brName, err)
}
diff --git a/vendor/github.com/docker/libnetwork/firewall_linux.go b/vendor/github.com/docker/libnetwork/firewall_linux.go
index 26ee913..ead12b5 100644
--- a/vendor/github.com/docker/libnetwork/firewall_linux.go
+++ b/vendor/github.com/docker/libnetwork/firewall_linux.go
@@ -26,18 +26,20 @@
if ctrl == nil || !ctrl.iptablesEnabled() {
return
}
- _, err := iptables.NewChain(userChain, iptables.Filter, false)
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
+ _, err := iptable.NewChain(userChain, iptables.Filter, false)
if err != nil {
logrus.Warnf("Failed to create %s chain: %v", userChain, err)
return
}
- if err = iptables.AddReturnRule(userChain); err != nil {
+ if err = iptable.AddReturnRule(userChain); err != nil {
logrus.Warnf("Failed to add the RETURN rule for %s: %v", userChain, err)
return
}
- err = iptables.EnsureJumpRule("FORWARD", userChain)
+ err = iptable.EnsureJumpRule("FORWARD", userChain)
if err != nil {
logrus.Warnf("Failed to ensure the jump rule for %s: %v", userChain, err)
}
diff --git a/vendor/github.com/docker/libnetwork/iptables/iptables.go b/vendor/github.com/docker/libnetwork/iptables/iptables.go
index bd262eb..0ebda6f 100644
--- a/vendor/github.com/docker/libnetwork/iptables/iptables.go
+++ b/vendor/github.com/docker/libnetwork/iptables/iptables.go
@@ -23,6 +23,9 @@
// Table refers to Nat, Filter or Mangle.
type Table string
+// IPVersion refers to IP version, v4 or v6
+type IPVersion string
+
const (
// Append appends the rule at the end of the chain.
Append Action = "-A"
@@ -40,10 +43,15 @@
Drop Policy = "DROP"
// Accept is the default iptables ACCEPT policy
Accept Policy = "ACCEPT"
+ // IPv4 is version 4
+ IPv4 IPVersion = "IPV4"
+ // IPv6 is version 6
+ IPv6 IPVersion = "IPV6"
)
var (
iptablesPath string
+ ip6tablesPath string
supportsXlock = false
supportsCOpt = false
xLockWaitMsg = "Another app is currently holding the xtables lock"
@@ -54,11 +62,17 @@
initOnce sync.Once
)
+// IPTable defines struct with IPVersion
+type IPTable struct {
+ Version IPVersion
+}
+
// ChainInfo defines the iptables chain.
type ChainInfo struct {
Name string
Table Table
HairpinMode bool
+ IPTable IPTable
}
// ChainError is returned to represent errors during ip table operation.
@@ -80,6 +94,11 @@
if out, err := exec.Command(path, "--wait", "-t", "nat", "-L", "-n").CombinedOutput(); err != nil {
logrus.Warnf("Running iptables --wait -t nat -L -n failed with message: `%s`, error: %v", strings.TrimSpace(string(out)), err)
}
+ _, err = exec.LookPath("ip6tables")
+ if err != nil {
+ logrus.Warnf("Failed to find ip6tables: %v", err)
+ return
+ }
}
func initFirewalld() {
@@ -94,6 +113,11 @@
return
}
iptablesPath = path
+ path, err = exec.LookPath("ip6tables")
+ if err != nil {
+ return
+ }
+ ip6tablesPath = path
supportsXlock = exec.Command(iptablesPath, "--wait", "-L", "-n").Run() == nil
mj, mn, mc, err := GetVersion()
if err != nil {
@@ -118,20 +142,26 @@
return nil
}
+// GetIptable returns an instance of IPTable with specified version
+func GetIptable(version IPVersion) *IPTable {
+ return &IPTable{Version: version}
+}
+
// NewChain adds a new chain to ip table.
-func NewChain(name string, table Table, hairpinMode bool) (*ChainInfo, error) {
+func (iptable IPTable) NewChain(name string, table Table, hairpinMode bool) (*ChainInfo, error) {
c := &ChainInfo{
Name: name,
Table: table,
HairpinMode: hairpinMode,
+ IPTable: iptable,
}
if string(c.Table) == "" {
c.Table = Filter
}
// Add chain if it doesn't exist
- if _, err := Raw("-t", string(c.Table), "-n", "-L", c.Name); err != nil {
- if output, err := Raw("-t", string(c.Table), "-N", c.Name); err != nil {
+ if _, err := iptable.Raw("-t", string(c.Table), "-n", "-L", c.Name); err != nil {
+ if output, err := iptable.Raw("-t", string(c.Table), "-N", c.Name); err != nil {
return nil, err
} else if len(output) != 0 {
return nil, fmt.Errorf("Could not create %s/%s chain: %s", c.Table, c.Name, output)
@@ -140,8 +170,16 @@
return c, nil
}
+// LoopbackByVersion returns loopback address by version
+func (iptable IPTable) LoopbackByVersion() string {
+ if iptable.Version == IPv6 {
+ return "::1/128"
+ }
+ return "127.0.0.0/8"
+}
+
// ProgramChain is used to add rules to a chain
-func ProgramChain(c *ChainInfo, bridgeName string, hairpinMode, enable bool) error {
+func (iptable IPTable) ProgramChain(c *ChainInfo, bridgeName string, hairpinMode, enable bool) error {
if c.Name == "" {
return errors.New("Could not program chain, missing chain name")
}
@@ -165,11 +203,11 @@
"-m", "addrtype",
"--dst-type", "LOCAL",
"-j", c.Name}
- if !Exists(Nat, "PREROUTING", preroute...) && enable {
+ if !iptable.Exists(Nat, "PREROUTING", preroute...) && enable {
if err := c.Prerouting(Append, preroute...); err != nil {
return fmt.Errorf("Failed to inject %s in PREROUTING chain: %s", c.Name, err)
}
- } else if Exists(Nat, "PREROUTING", preroute...) && !enable {
+ } else if iptable.Exists(Nat, "PREROUTING", preroute...) && !enable {
if err := c.Prerouting(Delete, preroute...); err != nil {
return fmt.Errorf("Failed to remove %s in PREROUTING chain: %s", c.Name, err)
}
@@ -179,13 +217,13 @@
"--dst-type", "LOCAL",
"-j", c.Name}
if !hairpinMode {
- output = append(output, "!", "--dst", "127.0.0.0/8")
+ output = append(output, "!", "--dst", iptable.LoopbackByVersion())
}
- if !Exists(Nat, "OUTPUT", output...) && enable {
+ if !iptable.Exists(Nat, "OUTPUT", output...) && enable {
if err := c.Output(Append, output...); err != nil {
return fmt.Errorf("Failed to inject %s in OUTPUT chain: %s", c.Name, err)
}
- } else if Exists(Nat, "OUTPUT", output...) && !enable {
+ } else if iptable.Exists(Nat, "OUTPUT", output...) && !enable {
if err := c.Output(Delete, output...); err != nil {
return fmt.Errorf("Failed to inject %s in OUTPUT chain: %s", c.Name, err)
}
@@ -198,16 +236,16 @@
link := []string{
"-o", bridgeName,
"-j", c.Name}
- if !Exists(Filter, "FORWARD", link...) && enable {
+ if !iptable.Exists(Filter, "FORWARD", link...) && enable {
insert := append([]string{string(Insert), "FORWARD"}, link...)
- if output, err := Raw(insert...); err != nil {
+ if output, err := iptable.Raw(insert...); err != nil {
return err
} else if len(output) != 0 {
return fmt.Errorf("Could not create linking rule to %s/%s: %s", c.Table, c.Name, output)
}
- } else if Exists(Filter, "FORWARD", link...) && !enable {
+ } else if iptable.Exists(Filter, "FORWARD", link...) && !enable {
del := append([]string{string(Delete), "FORWARD"}, link...)
- if output, err := Raw(del...); err != nil {
+ if output, err := iptable.Raw(del...); err != nil {
return err
} else if len(output) != 0 {
return fmt.Errorf("Could not delete linking rule from %s/%s: %s", c.Table, c.Name, output)
@@ -219,16 +257,16 @@
"-m", "conntrack",
"--ctstate", "RELATED,ESTABLISHED",
"-j", "ACCEPT"}
- if !Exists(Filter, "FORWARD", establish...) && enable {
+ if !iptable.Exists(Filter, "FORWARD", establish...) && enable {
insert := append([]string{string(Insert), "FORWARD"}, establish...)
- if output, err := Raw(insert...); err != nil {
+ if output, err := iptable.Raw(insert...); err != nil {
return err
} else if len(output) != 0 {
return fmt.Errorf("Could not create establish rule to %s: %s", c.Table, output)
}
- } else if Exists(Filter, "FORWARD", establish...) && !enable {
+ } else if iptable.Exists(Filter, "FORWARD", establish...) && !enable {
del := append([]string{string(Delete), "FORWARD"}, establish...)
- if output, err := Raw(del...); err != nil {
+ if output, err := iptable.Raw(del...); err != nil {
return err
} else if len(output) != 0 {
return fmt.Errorf("Could not delete establish rule from %s: %s", c.Table, output)
@@ -239,10 +277,11 @@
}
// RemoveExistingChain removes existing chain from the table.
-func RemoveExistingChain(name string, table Table) error {
+func (iptable IPTable) RemoveExistingChain(name string, table Table) error {
c := &ChainInfo{
- Name: name,
- Table: table,
+ Name: name,
+ Table: table,
+ IPTable: iptable,
}
if string(c.Table) == "" {
c.Table = Filter
@@ -252,6 +291,8 @@
// Forward adds forwarding rule to 'filter' table and corresponding nat rule to 'nat' table.
func (c *ChainInfo) Forward(action Action, ip net.IP, port int, proto, destAddr string, destPort int, bridgeName string) error {
+
+ iptable := GetIptable(c.IPTable.Version)
daddr := ip.String()
if ip.IsUnspecified() {
// iptables interprets "0.0.0.0" as "0.0.0.0/32", whereas we
@@ -266,10 +307,11 @@
"--dport", strconv.Itoa(port),
"-j", "DNAT",
"--to-destination", net.JoinHostPort(destAddr, strconv.Itoa(destPort))}
+
if !c.HairpinMode {
args = append(args, "!", "-i", bridgeName)
}
- if err := ProgramRule(Nat, c.Name, action, args); err != nil {
+ if err := iptable.ProgramRule(Nat, c.Name, action, args); err != nil {
return err
}
@@ -281,7 +323,7 @@
"--dport", strconv.Itoa(destPort),
"-j", "ACCEPT",
}
- if err := ProgramRule(Filter, c.Name, action, args); err != nil {
+ if err := iptable.ProgramRule(Filter, c.Name, action, args); err != nil {
return err
}
@@ -293,7 +335,7 @@
"-j", "MASQUERADE",
}
- if err := ProgramRule(Nat, "POSTROUTING", action, args); err != nil {
+ if err := iptable.ProgramRule(Nat, "POSTROUTING", action, args); err != nil {
return err
}
@@ -311,7 +353,7 @@
"-j", "CHECKSUM",
"--checksum-fill",
}
- if err := ProgramRule(Mangle, "POSTROUTING", action, args); err != nil {
+ if err := iptable.ProgramRule(Mangle, "POSTROUTING", action, args); err != nil {
return err
}
}
@@ -322,6 +364,7 @@
// Link adds reciprocal ACCEPT rule for two supplied IP addresses.
// Traffic is allowed from ip1 to ip2 and vice-versa
func (c *ChainInfo) Link(action Action, ip1, ip2 net.IP, port int, proto string, bridgeName string) error {
+ iptable := GetIptable(c.IPTable.Version)
// forward
args := []string{
"-i", bridgeName, "-o", bridgeName,
@@ -331,32 +374,34 @@
"--dport", strconv.Itoa(port),
"-j", "ACCEPT",
}
- if err := ProgramRule(Filter, c.Name, action, args); err != nil {
+
+ if err := iptable.ProgramRule(Filter, c.Name, action, args); err != nil {
return err
}
// reverse
args[7], args[9] = args[9], args[7]
args[10] = "--sport"
- return ProgramRule(Filter, c.Name, action, args)
+ return iptable.ProgramRule(Filter, c.Name, action, args)
}
// ProgramRule adds the rule specified by args only if the
// rule is not already present in the chain. Reciprocally,
// it removes the rule only if present.
-func ProgramRule(table Table, chain string, action Action, args []string) error {
- if Exists(table, chain, args...) != (action == Delete) {
+func (iptable IPTable) ProgramRule(table Table, chain string, action Action, args []string) error {
+ if iptable.Exists(table, chain, args...) != (action == Delete) {
return nil
}
- return RawCombinedOutput(append([]string{"-t", string(table), string(action), chain}, args...)...)
+ return iptable.RawCombinedOutput(append([]string{"-t", string(table), string(action), chain}, args...)...)
}
// Prerouting adds linking rule to nat/PREROUTING chain.
func (c *ChainInfo) Prerouting(action Action, args ...string) error {
+ iptable := GetIptable(c.IPTable.Version)
a := []string{"-t", string(Nat), string(action), "PREROUTING"}
if len(args) > 0 {
a = append(a, args...)
}
- if output, err := Raw(a...); err != nil {
+ if output, err := iptable.Raw(a...); err != nil {
return err
} else if len(output) != 0 {
return ChainError{Chain: "PREROUTING", Output: output}
@@ -366,11 +411,12 @@
// Output adds linking rule to an OUTPUT chain.
func (c *ChainInfo) Output(action Action, args ...string) error {
+ iptable := GetIptable(c.IPTable.Version)
a := []string{"-t", string(c.Table), string(action), "OUTPUT"}
if len(args) > 0 {
a = append(a, args...)
}
- if output, err := Raw(a...); err != nil {
+ if output, err := iptable.Raw(a...); err != nil {
return err
} else if len(output) != 0 {
return ChainError{Chain: "OUTPUT", Output: output}
@@ -380,35 +426,36 @@
// Remove removes the chain.
func (c *ChainInfo) Remove() error {
+ iptable := GetIptable(c.IPTable.Version)
// Ignore errors - This could mean the chains were never set up
if c.Table == Nat {
c.Prerouting(Delete, "-m", "addrtype", "--dst-type", "LOCAL", "-j", c.Name)
- c.Output(Delete, "-m", "addrtype", "--dst-type", "LOCAL", "!", "--dst", "127.0.0.0/8", "-j", c.Name)
+ c.Output(Delete, "-m", "addrtype", "--dst-type", "LOCAL", "!", "--dst", iptable.LoopbackByVersion(), "-j", c.Name)
c.Output(Delete, "-m", "addrtype", "--dst-type", "LOCAL", "-j", c.Name) // Created in versions <= 0.1.6
c.Prerouting(Delete)
c.Output(Delete)
}
- Raw("-t", string(c.Table), "-F", c.Name)
- Raw("-t", string(c.Table), "-X", c.Name)
+ iptable.Raw("-t", string(c.Table), "-F", c.Name)
+ iptable.Raw("-t", string(c.Table), "-X", c.Name)
return nil
}
// Exists checks if a rule exists
-func Exists(table Table, chain string, rule ...string) bool {
- return exists(false, table, chain, rule...)
+func (iptable IPTable) Exists(table Table, chain string, rule ...string) bool {
+ return iptable.exists(false, table, chain, rule...)
}
// ExistsNative behaves as Exists with the difference it
// will always invoke `iptables` binary.
-func ExistsNative(table Table, chain string, rule ...string) bool {
- return exists(true, table, chain, rule...)
+func (iptable IPTable) ExistsNative(table Table, chain string, rule ...string) bool {
+ return iptable.exists(true, table, chain, rule...)
}
-func exists(native bool, table Table, chain string, rule ...string) bool {
- f := Raw
+func (iptable IPTable) exists(native bool, table Table, chain string, rule ...string) bool {
+ f := iptable.Raw
if native {
- f = raw
+ f = iptable.raw
}
if string(table) == "" {
@@ -429,12 +476,16 @@
// parse "iptables -S" for the rule (it checks rules in a specific chain
// in a specific table and it is very unreliable)
- return existsRaw(table, chain, rule...)
+ return iptable.existsRaw(table, chain, rule...)
}
-func existsRaw(table Table, chain string, rule ...string) bool {
+func (iptable IPTable) existsRaw(table Table, chain string, rule ...string) bool {
+ path := iptablesPath
+ if iptable.Version == IPv6 {
+ path = ip6tablesPath
+ }
ruleString := fmt.Sprintf("%s %s\n", chain, strings.Join(rule, " "))
- existingRules, _ := exec.Command(iptablesPath, "-t", string(table), "-S", chain).Output()
+ existingRules, _ := exec.Command(path, "-t", string(table), "-S", chain).Output()
return strings.Contains(string(existingRules), ruleString)
}
@@ -459,7 +510,7 @@
}
// Raw calls 'iptables' system command, passing supplied arguments.
-func Raw(args ...string) ([]byte, error) {
+func (iptable IPTable) Raw(args ...string) ([]byte, error) {
if firewalldRunning {
startTime := time.Now()
output, err := Passthrough(Iptables, args...)
@@ -467,10 +518,10 @@
return filterOutput(startTime, output, args...), err
}
}
- return raw(args...)
+ return iptable.raw(args...)
}
-func raw(args ...string) ([]byte, error) {
+func (iptable IPTable) raw(args ...string) ([]byte, error) {
if err := initCheck(); err != nil {
return nil, err
}
@@ -481,10 +532,15 @@
defer bestEffortLock.Unlock()
}
- logrus.Debugf("%s, %v", iptablesPath, args)
+ path := iptablesPath
+ if iptable.Version == IPv6 {
+ path = ip6tablesPath
+ }
+
+ logrus.Debugf("%s, %v", path, args)
startTime := time.Now()
- output, err := exec.Command(iptablesPath, args...).CombinedOutput()
+ output, err := exec.Command(path, args...).CombinedOutput()
if err != nil {
return nil, fmt.Errorf("iptables failed: iptables %v: %s (%s)", strings.Join(args, " "), output, err)
}
@@ -494,8 +550,8 @@
// RawCombinedOutput internally calls the Raw function and returns a non nil
// error if Raw returned a non nil error or a non empty output
-func RawCombinedOutput(args ...string) error {
- if output, err := Raw(args...); err != nil || len(output) != 0 {
+func (iptable IPTable) RawCombinedOutput(args ...string) error {
+ if output, err := iptable.Raw(args...); err != nil || len(output) != 0 {
return fmt.Errorf("%s (%v)", string(output), err)
}
return nil
@@ -503,16 +559,16 @@
// RawCombinedOutputNative behave as RawCombinedOutput with the difference it
// will always invoke `iptables` binary
-func RawCombinedOutputNative(args ...string) error {
- if output, err := raw(args...); err != nil || len(output) != 0 {
+func (iptable IPTable) RawCombinedOutputNative(args ...string) error {
+ if output, err := iptable.raw(args...); err != nil || len(output) != 0 {
return fmt.Errorf("%s (%v)", string(output), err)
}
return nil
}
// ExistChain checks if a chain exists
-func ExistChain(chain string, table Table) bool {
- if _, err := Raw("-t", string(table), "-nL", chain); err == nil {
+func (iptable IPTable) ExistChain(chain string, table Table) bool {
+ if _, err := iptable.Raw("-t", string(table), "-nL", chain); err == nil {
return true
}
return false
@@ -528,8 +584,8 @@
}
// SetDefaultPolicy sets the passed default policy for the table/chain
-func SetDefaultPolicy(table Table, chain string, policy Policy) error {
- if err := RawCombinedOutput("-t", string(table), "-P", chain, string(policy)); err != nil {
+func (iptable IPTable) SetDefaultPolicy(table Table, chain string, policy Policy) error {
+ if err := iptable.RawCombinedOutput("-t", string(table), "-P", chain, string(policy)); err != nil {
return fmt.Errorf("setting default policy to %v in %v chain failed: %v", policy, chain, err)
}
return nil
@@ -549,17 +605,17 @@
}
// AddReturnRule adds a return rule for the chain in the filter table
-func AddReturnRule(chain string) error {
+func (iptable IPTable) AddReturnRule(chain string) error {
var (
table = Filter
args = []string{"-j", "RETURN"}
)
- if Exists(table, chain, args...) {
+ if iptable.Exists(table, chain, args...) {
return nil
}
- err := RawCombinedOutput(append([]string{"-A", chain}, args...)...)
+ err := iptable.RawCombinedOutput(append([]string{"-A", chain}, args...)...)
if err != nil {
return fmt.Errorf("unable to add return rule in %s chain: %s", chain, err.Error())
}
@@ -568,20 +624,20 @@
}
// EnsureJumpRule ensures the jump rule is on top
-func EnsureJumpRule(fromChain, toChain string) error {
+func (iptable IPTable) EnsureJumpRule(fromChain, toChain string) error {
var (
table = Filter
args = []string{"-j", toChain}
)
- if Exists(table, fromChain, args...) {
- err := RawCombinedOutput(append([]string{"-D", fromChain}, args...)...)
+ if iptable.Exists(table, fromChain, args...) {
+ err := iptable.RawCombinedOutput(append([]string{"-D", fromChain}, args...)...)
if err != nil {
return fmt.Errorf("unable to remove jump to %s rule in %s chain: %s", toChain, fromChain, err.Error())
}
}
- err := RawCombinedOutput(append([]string{"-I", fromChain}, args...)...)
+ err := iptable.RawCombinedOutput(append([]string{"-I", fromChain}, args...)...)
if err != nil {
return fmt.Errorf("unable to insert jump to %s rule in %s chain: %s", toChain, fromChain, err.Error())
}
diff --git a/vendor/github.com/docker/libnetwork/portmapper/mapper.go b/vendor/github.com/docker/libnetwork/portmapper/mapper.go
index 47c99a9..f447f3f 100644
--- a/vendor/github.com/docker/libnetwork/portmapper/mapper.go
+++ b/vendor/github.com/docker/libnetwork/portmapper/mapper.go
@@ -151,7 +151,7 @@
}
containerIP, containerPort := getIPAndPort(m.container)
- if hostIP.To4() != nil {
+ if hostIP.To4() != nil || hostIP.To16() != nil {
if err := pm.AppendForwardingTableEntry(m.proto, hostIP, allocatedHostPort, containerIP.String(), containerPort); err != nil {
return nil, err
}
@@ -160,7 +160,7 @@
cleanup := func() error {
// need to undo the iptables rules before we return
m.userlandProxy.Stop()
- if hostIP.To4() != nil {
+ if hostIP.To4() != nil || hostIP.To16() != nil {
pm.DeleteForwardingTableEntry(m.proto, hostIP, allocatedHostPort, containerIP.String(), containerPort)
if err := pm.Allocator.ReleasePort(hostIP, m.proto, allocatedHostPort); err != nil {
return err
diff --git a/vendor/github.com/docker/libnetwork/resolver_unix.go b/vendor/github.com/docker/libnetwork/resolver_unix.go
index f4e4ad6..28b8c42 100644
--- a/vendor/github.com/docker/libnetwork/resolver_unix.go
+++ b/vendor/github.com/docker/libnetwork/resolver_unix.go
@@ -57,25 +57,28 @@
os.Exit(3)
}
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
+
// insert outputChain and postroutingchain
- err = iptables.RawCombinedOutputNative("-t", "nat", "-C", "OUTPUT", "-d", resolverIP, "-j", outputChain)
+ err = iptable.RawCombinedOutputNative("-t", "nat", "-C", "OUTPUT", "-d", resolverIP, "-j", outputChain)
if err == nil {
- iptables.RawCombinedOutputNative("-t", "nat", "-F", outputChain)
+ iptable.RawCombinedOutputNative("-t", "nat", "-F", outputChain)
} else {
- iptables.RawCombinedOutputNative("-t", "nat", "-N", outputChain)
- iptables.RawCombinedOutputNative("-t", "nat", "-I", "OUTPUT", "-d", resolverIP, "-j", outputChain)
+ iptable.RawCombinedOutputNative("-t", "nat", "-N", outputChain)
+ iptable.RawCombinedOutputNative("-t", "nat", "-I", "OUTPUT", "-d", resolverIP, "-j", outputChain)
}
- err = iptables.RawCombinedOutputNative("-t", "nat", "-C", "POSTROUTING", "-d", resolverIP, "-j", postroutingchain)
+ err = iptable.RawCombinedOutputNative("-t", "nat", "-C", "POSTROUTING", "-d", resolverIP, "-j", postroutingchain)
if err == nil {
- iptables.RawCombinedOutputNative("-t", "nat", "-F", postroutingchain)
+ iptable.RawCombinedOutputNative("-t", "nat", "-F", postroutingchain)
} else {
- iptables.RawCombinedOutputNative("-t", "nat", "-N", postroutingchain)
- iptables.RawCombinedOutputNative("-t", "nat", "-I", "POSTROUTING", "-d", resolverIP, "-j", postroutingchain)
+ iptable.RawCombinedOutputNative("-t", "nat", "-N", postroutingchain)
+ iptable.RawCombinedOutputNative("-t", "nat", "-I", "POSTROUTING", "-d", resolverIP, "-j", postroutingchain)
}
for _, rule := range rules {
- if iptables.RawCombinedOutputNative(rule...) != nil {
+ if iptable.RawCombinedOutputNative(rule...) != nil {
logrus.Errorf("set up rule failed, %v", rule)
}
}
diff --git a/vendor/github.com/docker/libnetwork/service_linux.go b/vendor/github.com/docker/libnetwork/service_linux.go
index 02ea8ff..66c8be6 100644
--- a/vendor/github.com/docker/libnetwork/service_linux.go
+++ b/vendor/github.com/docker/libnetwork/service_linux.go
@@ -302,6 +302,9 @@
}
func programIngress(gwIP net.IP, ingressPorts []*PortConfig, isDelete bool) error {
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
+
addDelOpt := "-I"
rollbackAddDelOpt := "-D"
if isDelete {
@@ -312,19 +315,19 @@
ingressMu.Lock()
defer ingressMu.Unlock()
- chainExists := iptables.ExistChain(ingressChain, iptables.Nat)
- filterChainExists := iptables.ExistChain(ingressChain, iptables.Filter)
+ chainExists := iptable.ExistChain(ingressChain, iptables.Nat)
+ filterChainExists := iptable.ExistChain(ingressChain, iptables.Filter)
ingressOnce.Do(func() {
// Flush nat table and filter table ingress chain rules during init if it
// exists. It might contain stale rules from previous life.
if chainExists {
- if err := iptables.RawCombinedOutput("-t", "nat", "-F", ingressChain); err != nil {
+ if err := iptable.RawCombinedOutput("-t", "nat", "-F", ingressChain); err != nil {
logrus.Errorf("Could not flush nat table ingress chain rules during init: %v", err)
}
}
if filterChainExists {
- if err := iptables.RawCombinedOutput("-F", ingressChain); err != nil {
+ if err := iptable.RawCombinedOutput("-F", ingressChain); err != nil {
logrus.Errorf("Could not flush filter table ingress chain rules during init: %v", err)
}
}
@@ -332,38 +335,38 @@
if !isDelete {
if !chainExists {
- if err := iptables.RawCombinedOutput("-t", "nat", "-N", ingressChain); err != nil {
+ if err := iptable.RawCombinedOutput("-t", "nat", "-N", ingressChain); err != nil {
return fmt.Errorf("failed to create ingress chain: %v", err)
}
}
if !filterChainExists {
- if err := iptables.RawCombinedOutput("-N", ingressChain); err != nil {
+ if err := iptable.RawCombinedOutput("-N", ingressChain); err != nil {
return fmt.Errorf("failed to create filter table ingress chain: %v", err)
}
}
- if !iptables.Exists(iptables.Nat, ingressChain, "-j", "RETURN") {
- if err := iptables.RawCombinedOutput("-t", "nat", "-A", ingressChain, "-j", "RETURN"); err != nil {
+ if !iptable.Exists(iptables.Nat, ingressChain, "-j", "RETURN") {
+ if err := iptable.RawCombinedOutput("-t", "nat", "-A", ingressChain, "-j", "RETURN"); err != nil {
return fmt.Errorf("failed to add return rule in nat table ingress chain: %v", err)
}
}
- if !iptables.Exists(iptables.Filter, ingressChain, "-j", "RETURN") {
- if err := iptables.RawCombinedOutput("-A", ingressChain, "-j", "RETURN"); err != nil {
+ if !iptable.Exists(iptables.Filter, ingressChain, "-j", "RETURN") {
+ if err := iptable.RawCombinedOutput("-A", ingressChain, "-j", "RETURN"); err != nil {
return fmt.Errorf("failed to add return rule to filter table ingress chain: %v", err)
}
}
for _, chain := range []string{"OUTPUT", "PREROUTING"} {
- if !iptables.Exists(iptables.Nat, chain, "-m", "addrtype", "--dst-type", "LOCAL", "-j", ingressChain) {
- if err := iptables.RawCombinedOutput("-t", "nat", "-I", chain, "-m", "addrtype", "--dst-type", "LOCAL", "-j", ingressChain); err != nil {
+ if !iptable.Exists(iptables.Nat, chain, "-m", "addrtype", "--dst-type", "LOCAL", "-j", ingressChain) {
+ if err := iptable.RawCombinedOutput("-t", "nat", "-I", chain, "-m", "addrtype", "--dst-type", "LOCAL", "-j", ingressChain); err != nil {
return fmt.Errorf("failed to add jump rule in %s to ingress chain: %v", chain, err)
}
}
}
- if !iptables.Exists(iptables.Filter, "FORWARD", "-j", ingressChain) {
- if err := iptables.RawCombinedOutput("-I", "FORWARD", "-j", ingressChain); err != nil {
+ if !iptable.Exists(iptables.Filter, "FORWARD", "-j", ingressChain) {
+ if err := iptable.RawCombinedOutput("-I", "FORWARD", "-j", ingressChain); err != nil {
return fmt.Errorf("failed to add jump rule to %s in filter table forward chain: %v", ingressChain, err)
}
arrangeUserFilterRule()
@@ -380,8 +383,8 @@
}
ruleArgs := strings.Fields(fmt.Sprintf("-m addrtype --src-type LOCAL -o %s -j MASQUERADE", oifName))
- if !iptables.Exists(iptables.Nat, "POSTROUTING", ruleArgs...) {
- if err := iptables.RawCombinedOutput(append([]string{"-t", "nat", "-I", "POSTROUTING"}, ruleArgs...)...); err != nil {
+ if !iptable.Exists(iptables.Nat, "POSTROUTING", ruleArgs...) {
+ if err := iptable.RawCombinedOutput(append([]string{"-t", "nat", "-I", "POSTROUTING"}, ruleArgs...)...); err != nil {
return fmt.Errorf("failed to add ingress localhost POSTROUTING rule for %s: %v", oifName, err)
}
}
@@ -395,7 +398,7 @@
if portErr != nil && !isDelete {
filterPortConfigs(filteredPorts, !isDelete)
for _, rule := range rollbackRules {
- if err := iptables.RawCombinedOutput(rule...); err != nil {
+ if err := iptable.RawCombinedOutput(rule...); err != nil {
logrus.Warnf("roll back rule failed, %v: %v", rule, err)
}
}
@@ -403,10 +406,10 @@
}()
for _, iPort := range filteredPorts {
- if iptables.ExistChain(ingressChain, iptables.Nat) {
+ if iptable.ExistChain(ingressChain, iptables.Nat) {
rule := strings.Fields(fmt.Sprintf("-t nat %s %s -p %s --dport %d -j DNAT --to-destination %s:%d",
addDelOpt, ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort, gwIP, iPort.PublishedPort))
- if portErr = iptables.RawCombinedOutput(rule...); portErr != nil {
+ if portErr = iptable.RawCombinedOutput(rule...); portErr != nil {
errStr := fmt.Sprintf("set up rule failed, %v: %v", rule, portErr)
if !isDelete {
return fmt.Errorf("%s", errStr)
@@ -423,7 +426,7 @@
// 2) unmanaged containers on bridge networks
rule := strings.Fields(fmt.Sprintf("%s %s -m state -p %s --sport %d --state ESTABLISHED,RELATED -j ACCEPT",
addDelOpt, ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort))
- if portErr = iptables.RawCombinedOutput(rule...); portErr != nil {
+ if portErr = iptable.RawCombinedOutput(rule...); portErr != nil {
errStr := fmt.Sprintf("set up rule failed, %v: %v", rule, portErr)
if !isDelete {
return fmt.Errorf("%s", errStr)
@@ -436,7 +439,7 @@
rule = strings.Fields(fmt.Sprintf("%s %s -p %s --dport %d -j ACCEPT",
addDelOpt, ingressChain, strings.ToLower(PortConfig_Protocol_name[int32(iPort.Protocol)]), iPort.PublishedPort))
- if portErr = iptables.RawCombinedOutput(rule...); portErr != nil {
+ if portErr = iptable.RawCombinedOutput(rule...); portErr != nil {
errStr := fmt.Sprintf("set up rule failed, %v: %v", rule, portErr)
if !isDelete {
return fmt.Errorf("%s", errStr)
@@ -461,13 +464,15 @@
// This chain has the rules to allow access to the published ports for swarm tasks
// from local bridge networks and docker_gwbridge (ie:taks on other swarm networks)
func arrangeIngressFilterRule() {
- if iptables.ExistChain(ingressChain, iptables.Filter) {
- if iptables.Exists(iptables.Filter, "FORWARD", "-j", ingressChain) {
- if err := iptables.RawCombinedOutput("-D", "FORWARD", "-j", ingressChain); err != nil {
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
+ if iptable.ExistChain(ingressChain, iptables.Filter) {
+ if iptable.Exists(iptables.Filter, "FORWARD", "-j", ingressChain) {
+ if err := iptable.RawCombinedOutput("-D", "FORWARD", "-j", ingressChain); err != nil {
logrus.Warnf("failed to delete jump rule to ingressChain in filter table: %v", err)
}
}
- if err := iptables.RawCombinedOutput("-I", "FORWARD", "-j", ingressChain); err != nil {
+ if err := iptable.RawCombinedOutput("-I", "FORWARD", "-j", ingressChain); err != nil {
logrus.Warnf("failed to add jump rule to ingressChain in filter table: %v", err)
}
}
@@ -606,6 +611,8 @@
// Firewall marker reexec function.
func fwMarker() {
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
@@ -660,7 +667,7 @@
}
ruleParams := strings.Fields(fmt.Sprintf("-m ipvs --ipvs -d %s -j SNAT --to-source %s", subnet, eIP))
- if !iptables.Exists("nat", "POSTROUTING", ruleParams...) {
+ if !iptable.Exists("nat", "POSTROUTING", ruleParams...) {
rule := append(strings.Fields("-t nat -A POSTROUTING"), ruleParams...)
rules = append(rules, rule)
@@ -676,7 +683,7 @@
rules = append(rules, rule)
for _, rule := range rules {
- if err := iptables.RawCombinedOutputNative(rule...); err != nil {
+ if err := iptable.RawCombinedOutputNative(rule...); err != nil {
logrus.Errorf("set up rule failed, %v: %v", rule, err)
os.Exit(8)
}
@@ -711,6 +718,8 @@
// Redirector reexec function.
func redirector() {
+ // TODO IPv6 support
+ iptable := iptables.GetIptable(iptables.IPv4)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
@@ -763,7 +772,7 @@
}
for _, rule := range rules {
- if err := iptables.RawCombinedOutputNative(rule...); err != nil {
+ if err := iptable.RawCombinedOutputNative(rule...); err != nil {
logrus.Errorf("set up rule failed, %v: %v", rule, err)
os.Exit(6)
}
@@ -779,15 +788,15 @@
{"-d", eIP.String(), "-p", "udp", "-j", "DROP"},
{"-d", eIP.String(), "-p", "tcp", "-j", "DROP"},
} {
- if !iptables.ExistsNative(iptables.Filter, "INPUT", rule...) {
- if err := iptables.RawCombinedOutputNative(append([]string{"-A", "INPUT"}, rule...)...); err != nil {
+ if !iptable.ExistsNative(iptables.Filter, "INPUT", rule...) {
+ if err := iptable.RawCombinedOutputNative(append([]string{"-A", "INPUT"}, rule...)...); err != nil {
logrus.Errorf("set up rule failed, %v: %v", rule, err)
os.Exit(7)
}
}
rule[0] = "-s"
- if !iptables.ExistsNative(iptables.Filter, "OUTPUT", rule...) {
- if err := iptables.RawCombinedOutputNative(append([]string{"-A", "OUTPUT"}, rule...)...); err != nil {
+ if !iptable.ExistsNative(iptables.Filter, "OUTPUT", rule...) {
+ if err := iptable.RawCombinedOutputNative(append([]string{"-A", "OUTPUT"}, rule...)...); err != nil {
logrus.Errorf("set up rule failed, %v: %v", rule, err)
os.Exit(8)
}
diff --git a/vendor/github.com/mitchellh/hashstructure/go.mod b/vendor/github.com/mitchellh/hashstructure/go.mod
new file mode 100644
index 0000000..966582a
--- /dev/null
+++ b/vendor/github.com/mitchellh/hashstructure/go.mod
@@ -0,0 +1 @@
+module github.com/mitchellh/hashstructure
diff --git a/vendor/github.com/moby/buildkit/README.md b/vendor/github.com/moby/buildkit/README.md
index 19d7325..0af9e2e 100644
--- a/vendor/github.com/moby/buildkit/README.md
+++ b/vendor/github.com/moby/buildkit/README.md
@@ -62,6 +62,7 @@
- [Expose BuildKit as a TCP service](#expose-buildkit-as-a-tcp-service)
- [Load balancing](#load-balancing)
- [Containerizing BuildKit](#containerizing-buildkit)
+ - [Podman](#podman)
- [Kubernetes](#kubernetes)
- [Daemonless](#daemonless)
- [Opentracing support](#opentracing-support)
@@ -127,11 +128,6 @@
The buildkitd daemon listens gRPC API on `/run/buildkit/buildkitd.sock` by default, but you can also use TCP sockets.
See [Expose BuildKit as a TCP service](#expose-buildkit-as-a-tcp-service).
-:information_source: Notice to Fedora 31 users:
-
-* As runc still does not work on cgroup v2 environment like Fedora 31, you need to substitute runc with crun. Run `buildkitd` with `--oci-worker-binary=crun`.
-* If you want to use runc, you need to configure the system to use cgroup v1. Run `sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"` and reboot.
-
### Exploring LLB
BuildKit builds are based on a binary intermediate format called LLB that is used for defining the dependency graph for processes running part of your build. tl;dr: LLB is to Dockerfile what LLVM IR is to C.
@@ -150,6 +146,9 @@
- [Mockerfile](https://matt-rickard.com/building-a-new-dockerfile-frontend/)
- [Gockerfile](https://github.com/po3rin/gockerfile)
- [bldr (Pkgfile)](https://github.com/talos-systems/bldr/)
+- [HLB](https://github.com/openllb/hlb)
+- [Earthfile (Earthly)](https://github.com/earthly/earthly)
+- [Cargo Wharf (Rust)](https://github.com/denzp/cargo-wharf)
- (open a PR to add your own language)
### Exploring Dockerfiles
@@ -353,6 +352,7 @@
- `mode=max`: export all the layers of all intermediate steps. Not supported for `inline` cache exporter.
- `ref=docker.io/user/image:tag`: reference for `registry` cache exporter
- `dest=path/to/output-dir`: directory for `local` cache exporter
+- `oci-mediatypes=true|false`: whether to use OCI mediatypes in exported manifests for `local` and `registry` exporter. Since BuildKit `v0.8` defaults to true.
#### `--import-cache` options
- `type`: `registry` or `local`. Use `registry` to import `inline` cache.
@@ -418,6 +418,16 @@
buildctl build --help
```
+### Podman
+To connect to a BuildKit daemon running in a Podman container, use `podman-container://` instead of `docker-container://` .
+
+```bash
+podman run -d --name buildkitd --privileged moby/buildkit:latest
+buildctl --addr=podman-container://buildkitd build --frontend dockerfile.v0 --local context=. --local dockerfile=. --output type=oci | podman load foo
+```
+
+`sudo` is not required.
+
### Kubernetes
For Kubernetes deployments, see [`examples/kubernetes`](./examples/kubernetes).
diff --git a/vendor/github.com/moby/buildkit/api/services/control/generate.go b/vendor/github.com/moby/buildkit/api/services/control/generate.go
index 1c16115..9a3b246 100644
--- a/vendor/github.com/moby/buildkit/api/services/control/generate.go
+++ b/vendor/github.com/moby/buildkit/api/services/control/generate.go
@@ -1,3 +1,3 @@
-package moby_buildkit_v1
+package moby_buildkit_v1 //nolint:golint
//go:generate protoc -I=. -I=../../../vendor/ -I=../../../../../../ --gogo_out=plugins=grpc:. control.proto
diff --git a/vendor/github.com/moby/buildkit/api/types/generate.go b/vendor/github.com/moby/buildkit/api/types/generate.go
index 84007df..984bb74 100644
--- a/vendor/github.com/moby/buildkit/api/types/generate.go
+++ b/vendor/github.com/moby/buildkit/api/types/generate.go
@@ -1,3 +1,3 @@
-package moby_buildkit_v1_types
+package moby_buildkit_v1_types //nolint:golint
//go:generate protoc -I=. -I=../../vendor/ -I=../../../../../ --gogo_out=plugins=grpc:. worker.proto
diff --git a/vendor/github.com/moby/buildkit/cache/blobs.go b/vendor/github.com/moby/buildkit/cache/blobs.go
new file mode 100644
index 0000000..d3648b1
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/cache/blobs.go
@@ -0,0 +1,236 @@
+package cache
+
+import (
+ "context"
+
+ "github.com/containerd/containerd/diff"
+ "github.com/containerd/containerd/leases"
+ "github.com/containerd/containerd/mount"
+ "github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/util/compression"
+ "github.com/moby/buildkit/util/flightcontrol"
+ "github.com/moby/buildkit/util/winlayers"
+ digest "github.com/opencontainers/go-digest"
+ imagespecidentity "github.com/opencontainers/image-spec/identity"
+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/pkg/errors"
+ "golang.org/x/sync/errgroup"
+)
+
+var g flightcontrol.Group
+
+const containerdUncompressed = "containerd.io/uncompressed"
+
+type CompareWithParent interface {
+ CompareWithParent(ctx context.Context, ref string, opts ...diff.Opt) (ocispec.Descriptor, error)
+}
+
+var ErrNoBlobs = errors.Errorf("no blobs for snapshot")
+
+// computeBlobChain ensures every ref in a parent chain has an associated blob in the content store. If
+// a blob is missing and createIfNeeded is true, then the blob will be created, otherwise ErrNoBlobs will
+// be returned. Caller must hold a lease when calling this function.
+func (sr *immutableRef) computeBlobChain(ctx context.Context, createIfNeeded bool, compressionType compression.Type, s session.Group) error {
+ if _, ok := leases.FromContext(ctx); !ok {
+ return errors.Errorf("missing lease requirement for computeBlobChain")
+ }
+
+ if err := sr.Finalize(ctx, true); err != nil {
+ return err
+ }
+
+ if isTypeWindows(sr) {
+ ctx = winlayers.UseWindowsLayerMode(ctx)
+ }
+
+ return computeBlobChain(ctx, sr, createIfNeeded, compressionType, s)
+}
+
+func computeBlobChain(ctx context.Context, sr *immutableRef, createIfNeeded bool, compressionType compression.Type, s session.Group) error {
+ baseCtx := ctx
+ eg, ctx := errgroup.WithContext(ctx)
+ var currentDescr ocispec.Descriptor
+ if sr.parent != nil {
+ eg.Go(func() error {
+ return computeBlobChain(ctx, sr.parent, createIfNeeded, compressionType, s)
+ })
+ }
+ eg.Go(func() error {
+ dp, err := g.Do(ctx, sr.ID(), func(ctx context.Context) (interface{}, error) {
+ refInfo := sr.Info()
+ if refInfo.Blob != "" {
+ return nil, nil
+ } else if !createIfNeeded {
+ return nil, errors.WithStack(ErrNoBlobs)
+ }
+
+ var mediaType string
+ switch compressionType {
+ case compression.Uncompressed:
+ mediaType = ocispec.MediaTypeImageLayer
+ case compression.Gzip:
+ mediaType = ocispec.MediaTypeImageLayerGzip
+ default:
+ return nil, errors.Errorf("unknown layer compression type: %q", compressionType)
+ }
+
+ var descr ocispec.Descriptor
+ var err error
+
+ if pc, ok := sr.cm.Differ.(CompareWithParent); ok {
+ descr, err = pc.CompareWithParent(ctx, sr.ID(), diff.WithMediaType(mediaType))
+ if err != nil {
+ return nil, err
+ }
+ }
+ if descr.Digest == "" {
+ // reference needs to be committed
+ var lower []mount.Mount
+ if sr.parent != nil {
+ m, err := sr.parent.Mount(ctx, true, s)
+ if err != nil {
+ return nil, err
+ }
+ var release func() error
+ lower, release, err = m.Mount()
+ if err != nil {
+ return nil, err
+ }
+ if release != nil {
+ defer release()
+ }
+ }
+ m, err := sr.Mount(ctx, true, s)
+ if err != nil {
+ return nil, err
+ }
+ upper, release, err := m.Mount()
+ if err != nil {
+ return nil, err
+ }
+ if release != nil {
+ defer release()
+ }
+ descr, err = sr.cm.Differ.Compare(ctx, lower, upper,
+ diff.WithMediaType(mediaType),
+ diff.WithReference(sr.ID()),
+ )
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ if descr.Annotations == nil {
+ descr.Annotations = map[string]string{}
+ }
+
+ info, err := sr.cm.ContentStore.Info(ctx, descr.Digest)
+ if err != nil {
+ return nil, err
+ }
+
+ if diffID, ok := info.Labels[containerdUncompressed]; ok {
+ descr.Annotations[containerdUncompressed] = diffID
+ } else if compressionType == compression.Uncompressed {
+ descr.Annotations[containerdUncompressed] = descr.Digest.String()
+ } else {
+ return nil, errors.Errorf("unknown layer compression type")
+ }
+
+ return descr, nil
+
+ })
+ if err != nil {
+ return err
+ }
+
+ if dp != nil {
+ currentDescr = dp.(ocispec.Descriptor)
+ }
+ return nil
+ })
+ err := eg.Wait()
+ if err != nil {
+ return err
+ }
+ if currentDescr.Digest != "" {
+ if err := sr.setBlob(baseCtx, currentDescr); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+// setBlob associates a blob with the cache record.
+// A lease must be held for the blob when calling this function
+// Caller should call Info() for knowing what current values are actually set
+func (sr *immutableRef) setBlob(ctx context.Context, desc ocispec.Descriptor) error {
+ if _, ok := leases.FromContext(ctx); !ok {
+ return errors.Errorf("missing lease requirement for setBlob")
+ }
+
+ diffID, err := diffIDFromDescriptor(desc)
+ if err != nil {
+ return err
+ }
+ if _, err := sr.cm.ContentStore.Info(ctx, desc.Digest); err != nil {
+ return err
+ }
+
+ sr.mu.Lock()
+ defer sr.mu.Unlock()
+
+ if getChainID(sr.md) != "" {
+ return nil
+ }
+
+ if err := sr.finalize(ctx, true); err != nil {
+ return err
+ }
+
+ p := sr.parent
+ var parentChainID digest.Digest
+ var parentBlobChainID digest.Digest
+ if p != nil {
+ pInfo := p.Info()
+ if pInfo.ChainID == "" || pInfo.BlobChainID == "" {
+ return errors.Errorf("failed to set blob for reference with non-addressable parent")
+ }
+ parentChainID = pInfo.ChainID
+ parentBlobChainID = pInfo.BlobChainID
+ }
+
+ if err := sr.cm.LeaseManager.AddResource(ctx, leases.Lease{ID: sr.ID()}, leases.Resource{
+ ID: desc.Digest.String(),
+ Type: "content",
+ }); err != nil {
+ return err
+ }
+
+ queueDiffID(sr.md, diffID.String())
+ queueBlob(sr.md, desc.Digest.String())
+ chainID := diffID
+ blobChainID := imagespecidentity.ChainID([]digest.Digest{desc.Digest, diffID})
+ if parentChainID != "" {
+ chainID = imagespecidentity.ChainID([]digest.Digest{parentChainID, chainID})
+ blobChainID = imagespecidentity.ChainID([]digest.Digest{parentBlobChainID, blobChainID})
+ }
+ queueChainID(sr.md, chainID.String())
+ queueBlobChainID(sr.md, blobChainID.String())
+ queueMediaType(sr.md, desc.MediaType)
+ queueBlobSize(sr.md, desc.Size)
+ if err := sr.md.Commit(); err != nil {
+ return err
+ }
+ return nil
+}
+
+func isTypeWindows(sr *immutableRef) bool {
+ if GetLayerType(sr) == "windows" {
+ return true
+ }
+ if parent := sr.parent; parent != nil {
+ return isTypeWindows(parent)
+ }
+ return false
+}
diff --git a/vendor/github.com/moby/buildkit/cache/contenthash/checksum.go b/vendor/github.com/moby/buildkit/cache/contenthash/checksum.go
index 5d42d04..a8335ea 100644
--- a/vendor/github.com/moby/buildkit/cache/contenthash/checksum.go
+++ b/vendor/github.com/moby/buildkit/cache/contenthash/checksum.go
@@ -11,12 +11,13 @@
"sync"
"github.com/docker/docker/pkg/idtools"
- "github.com/docker/docker/pkg/locker"
iradix "github.com/hashicorp/go-immutable-radix"
"github.com/hashicorp/golang-lru/simplelru"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/cache/metadata"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/snapshot"
+ "github.com/moby/locker"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil"
@@ -44,12 +45,12 @@
// header, "/dir" is for contents. For the root node "" (empty string) is the
// key for root, "/" for the root header
-func Checksum(ctx context.Context, ref cache.ImmutableRef, path string, followLinks bool) (digest.Digest, error) {
- return getDefaultManager().Checksum(ctx, ref, path, followLinks)
+func Checksum(ctx context.Context, ref cache.ImmutableRef, path string, followLinks bool, s session.Group) (digest.Digest, error) {
+ return getDefaultManager().Checksum(ctx, ref, path, followLinks, s)
}
-func ChecksumWildcard(ctx context.Context, ref cache.ImmutableRef, path string, followLinks bool) (digest.Digest, error) {
- return getDefaultManager().ChecksumWildcard(ctx, ref, path, followLinks)
+func ChecksumWildcard(ctx context.Context, ref cache.ImmutableRef, path string, followLinks bool, s session.Group) (digest.Digest, error) {
+ return getDefaultManager().ChecksumWildcard(ctx, ref, path, followLinks, s)
}
func GetCacheContext(ctx context.Context, md *metadata.StorageItem, idmap *idtools.IdentityMapping) (CacheContext, error) {
@@ -65,8 +66,8 @@
}
type CacheContext interface {
- Checksum(ctx context.Context, ref cache.Mountable, p string, followLinks bool) (digest.Digest, error)
- ChecksumWildcard(ctx context.Context, ref cache.Mountable, p string, followLinks bool) (digest.Digest, error)
+ Checksum(ctx context.Context, ref cache.Mountable, p string, followLinks bool, s session.Group) (digest.Digest, error)
+ ChecksumWildcard(ctx context.Context, ref cache.Mountable, p string, followLinks bool, s session.Group) (digest.Digest, error)
HandleChange(kind fsutil.ChangeKind, p string, fi os.FileInfo, err error) error
}
@@ -85,20 +86,20 @@
lruMu sync.Mutex
}
-func (cm *cacheManager) Checksum(ctx context.Context, ref cache.ImmutableRef, p string, followLinks bool) (digest.Digest, error) {
+func (cm *cacheManager) Checksum(ctx context.Context, ref cache.ImmutableRef, p string, followLinks bool, s session.Group) (digest.Digest, error) {
cc, err := cm.GetCacheContext(ctx, ensureOriginMetadata(ref.Metadata()), ref.IdentityMapping())
if err != nil {
return "", nil
}
- return cc.Checksum(ctx, ref, p, followLinks)
+ return cc.Checksum(ctx, ref, p, followLinks, s)
}
-func (cm *cacheManager) ChecksumWildcard(ctx context.Context, ref cache.ImmutableRef, p string, followLinks bool) (digest.Digest, error) {
+func (cm *cacheManager) ChecksumWildcard(ctx context.Context, ref cache.ImmutableRef, p string, followLinks bool, s session.Group) (digest.Digest, error) {
cc, err := cm.GetCacheContext(ctx, ensureOriginMetadata(ref.Metadata()), ref.IdentityMapping())
if err != nil {
return "", nil
}
- return cc.ChecksumWildcard(ctx, ref, p, followLinks)
+ return cc.ChecksumWildcard(ctx, ref, p, followLinks, s)
}
func (cm *cacheManager) GetCacheContext(ctx context.Context, md *metadata.StorageItem, idmap *idtools.IdentityMapping) (CacheContext, error) {
@@ -170,13 +171,14 @@
mountable cache.Mountable
mountPath string
unmount func() error
+ session session.Group
}
func (m *mount) mount(ctx context.Context) (string, error) {
if m.mountPath != "" {
return m.mountPath, nil
}
- mounts, err := m.mountable.Mount(ctx, true)
+ mounts, err := m.mountable.Mount(ctx, true, m.session)
if err != nil {
return "", err
}
@@ -380,13 +382,13 @@
return nil
}
-func (cc *cacheContext) ChecksumWildcard(ctx context.Context, mountable cache.Mountable, p string, followLinks bool) (digest.Digest, error) {
- m := &mount{mountable: mountable}
+func (cc *cacheContext) ChecksumWildcard(ctx context.Context, mountable cache.Mountable, p string, followLinks bool, s session.Group) (digest.Digest, error) {
+ m := &mount{mountable: mountable, session: s}
defer m.clean()
wildcards, err := cc.wildcards(ctx, m, p)
if err != nil {
- return "", nil
+ return "", err
}
if followLinks {
@@ -413,13 +415,12 @@
digester.Hash().Write([]byte(w.Record.Digest))
}
return digester.Digest(), nil
- } else {
- return wildcards[0].Record.Digest, nil
}
+ return wildcards[0].Record.Digest, nil
}
-func (cc *cacheContext) Checksum(ctx context.Context, mountable cache.Mountable, p string, followLinks bool) (digest.Digest, error) {
- m := &mount{mountable: mountable}
+func (cc *cacheContext) Checksum(ctx context.Context, mountable cache.Mountable, p string, followLinks bool, s session.Group) (digest.Digest, error) {
+ m := &mount{mountable: mountable, session: s}
defer m.clean()
return cc.checksumFollow(ctx, m, p, followLinks)
@@ -688,24 +689,24 @@
if p == "/" {
p = ""
}
- if v, ok := root.Get(convertPathToKey([]byte(p))); !ok {
+ v, ok := root.Get(convertPathToKey([]byte(p)))
+ if !ok {
if p == "" {
return true, nil
}
return cc.needsScanFollow(root, path.Clean(path.Dir(p)), linksWalked)
- } else {
- cr := v.(*CacheRecord)
- if cr.Type == CacheRecordTypeSymlink {
- if *linksWalked > 255 {
- return false, errTooManyLinks
- }
- *linksWalked++
- link := path.Clean(cr.Linkname)
- if !path.IsAbs(cr.Linkname) {
- link = path.Join("/", path.Dir(p), link)
- }
- return cc.needsScanFollow(root, link, linksWalked)
+ }
+ cr := v.(*CacheRecord)
+ if cr.Type == CacheRecordTypeSymlink {
+ if *linksWalked > 255 {
+ return false, errTooManyLinks
}
+ *linksWalked++
+ link := path.Clean(cr.Linkname)
+ if !path.IsAbs(cr.Linkname) {
+ link = path.Join("/", path.Dir(p), link)
+ }
+ return cc.needsScanFollow(root, link, linksWalked)
}
return false, nil
}
@@ -875,12 +876,15 @@
}
var pool32K = sync.Pool{
- New: func() interface{} { return make([]byte, 32*1024) }, // 32K
+ New: func() interface{} {
+ buf := make([]byte, 32*1024) // 32K
+ return &buf
+ },
}
func poolsCopy(dst io.Writer, src io.Reader) (written int64, err error) {
- buf := pool32K.Get().([]byte)
- written, err = io.CopyBuffer(dst, src, buf)
+ buf := pool32K.Get().(*[]byte)
+ written, err = io.CopyBuffer(dst, src, *buf)
pool32K.Put(buf)
return
}
diff --git a/vendor/github.com/moby/buildkit/cache/contenthash/filehash.go b/vendor/github.com/moby/buildkit/cache/contenthash/filehash.go
index 84018e7..0b52671 100644
--- a/vendor/github.com/moby/buildkit/cache/contenthash/filehash.go
+++ b/vendor/github.com/moby/buildkit/cache/contenthash/filehash.go
@@ -40,20 +40,22 @@
}
func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
+ // Clear the socket bit since archive/tar.FileInfoHeader does not handle it
+ stat.Mode &^= uint32(os.ModeSocket)
+
fi := &statInfo{stat}
hdr, err := tar.FileInfoHeader(fi, stat.Linkname)
if err != nil {
return nil, err
}
hdr.Name = "" // note: empty name is different from current has in docker build. Name is added on recursive directory scan instead
- hdr.Mode = int64(chmodWindowsTarEntry(os.FileMode(hdr.Mode)))
hdr.Devmajor = stat.Devmajor
hdr.Devminor = stat.Devminor
if len(stat.Xattrs) > 0 {
- hdr.Xattrs = make(map[string]string, len(stat.Xattrs))
+ hdr.PAXRecords = make(map[string]string, len(stat.Xattrs))
for k, v := range stat.Xattrs {
- hdr.Xattrs[k] = string(v)
+ hdr.PAXRecords["SCHILY.xattr."+k] = string(v)
}
}
// fmt.Printf("hdr: %#v\n", hdr)
diff --git a/vendor/github.com/moby/buildkit/cache/contenthash/filehash_unix.go b/vendor/github.com/moby/buildkit/cache/contenthash/filehash_unix.go
index 4f610d7..ccd2ebd 100644
--- a/vendor/github.com/moby/buildkit/cache/contenthash/filehash_unix.go
+++ b/vendor/github.com/moby/buildkit/cache/contenthash/filehash_unix.go
@@ -12,10 +12,6 @@
"golang.org/x/sys/unix"
)
-func chmodWindowsTarEntry(perm os.FileMode) os.FileMode {
- return perm
-}
-
func setUnixOpt(path string, fi os.FileInfo, stat *fstypes.Stat) error {
s := fi.Sys().(*syscall.Stat_t)
diff --git a/vendor/github.com/moby/buildkit/cache/contenthash/filehash_windows.go b/vendor/github.com/moby/buildkit/cache/contenthash/filehash_windows.go
index e15bf1e..c6bfce9 100644
--- a/vendor/github.com/moby/buildkit/cache/contenthash/filehash_windows.go
+++ b/vendor/github.com/moby/buildkit/cache/contenthash/filehash_windows.go
@@ -8,16 +8,6 @@
fstypes "github.com/tonistiigi/fsutil/types"
)
-// chmodWindowsTarEntry is used to adjust the file permissions used in tar
-// header based on the platform the archival is done.
-func chmodWindowsTarEntry(perm os.FileMode) os.FileMode {
- perm &= 0755
- // Add the x bit: make everything +x from windows
- perm |= 0111
-
- return perm
-}
-
func setUnixOpt(path string, fi os.FileInfo, stat *fstypes.Stat) error {
return nil
}
diff --git a/vendor/github.com/moby/buildkit/cache/contenthash/tarsum.go b/vendor/github.com/moby/buildkit/cache/contenthash/tarsum.go
index de72d6c..a7f192d 100644
--- a/vendor/github.com/moby/buildkit/cache/contenthash/tarsum.go
+++ b/vendor/github.com/moby/buildkit/cache/contenthash/tarsum.go
@@ -36,11 +36,24 @@
}
func v1TarHeaderSelect(h *tar.Header) (orderedHeaders [][2]string) {
+ pax := h.PAXRecords
+ if len(h.Xattrs) > 0 { //nolint deprecated
+ if pax == nil {
+ pax = map[string]string{}
+ for k, v := range h.Xattrs { //nolint deprecated
+ pax["SCHILY.xattr."+k] = v
+ }
+ }
+ }
+
// Get extended attributes.
- xAttrKeys := make([]string, len(h.Xattrs))
- for k := range h.Xattrs {
- if k == "security.capability" || !strings.HasPrefix(k, "security.") && !strings.HasPrefix(k, "system.") {
- xAttrKeys = append(xAttrKeys, k)
+ xAttrKeys := make([]string, len(h.PAXRecords))
+ for k := range pax {
+ if strings.HasPrefix(k, "SCHILY.xattr.") {
+ k = strings.TrimPrefix(k, "SCHILY.xattr.")
+ if k == "security.capability" || !strings.HasPrefix(k, "security.") && !strings.HasPrefix(k, "system.") {
+ xAttrKeys = append(xAttrKeys, k)
+ }
}
}
sort.Strings(xAttrKeys)
@@ -56,7 +69,7 @@
// Finally, append the sorted xattrs.
for _, k := range xAttrKeys {
- orderedHeaders = append(orderedHeaders, [2]string{k, h.Xattrs[k]})
+ orderedHeaders = append(orderedHeaders, [2]string{k, h.PAXRecords["SCHILY.xattr."+k]})
}
return
diff --git a/vendor/github.com/moby/buildkit/cache/manager.go b/vendor/github.com/moby/buildkit/cache/manager.go
index 3d1e884..0fb0103 100644
--- a/vendor/github.com/moby/buildkit/cache/manager.go
+++ b/vendor/github.com/moby/buildkit/cache/manager.go
@@ -8,6 +8,7 @@
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/diff"
+ "github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/filters"
"github.com/containerd/containerd/gc"
"github.com/containerd/containerd/leases"
@@ -15,7 +16,9 @@
"github.com/moby/buildkit/cache/metadata"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/identity"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/snapshot"
+ "github.com/moby/buildkit/util/flightcontrol"
digest "github.com/opencontainers/go-digest"
imagespecidentity "github.com/opencontainers/image-spec/identity"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -38,14 +41,15 @@
PruneRefChecker ExternalRefCheckerFunc
GarbageCollect func(ctx context.Context) (gc.Stats, error)
Applier diff.Applier
+ Differ diff.Comparer
}
type Accessor interface {
GetByBlob(ctx context.Context, desc ocispec.Descriptor, parent ImmutableRef, opts ...RefOption) (ImmutableRef, error)
Get(ctx context.Context, id string, opts ...RefOption) (ImmutableRef, error)
- New(ctx context.Context, parent ImmutableRef, opts ...RefOption) (MutableRef, error)
- GetMutable(ctx context.Context, id string) (MutableRef, error) // Rebase?
+ New(ctx context.Context, parent ImmutableRef, s session.Group, opts ...RefOption) (MutableRef, error)
+ GetMutable(ctx context.Context, id string, opts ...RefOption) (MutableRef, error) // Rebase?
IdentityMapping() *idtools.IdentityMapping
Metadata(string) *metadata.StorageItem
}
@@ -74,6 +78,7 @@
md *metadata.Store
muPrune sync.Mutex // make sure parallel prune is not allowed so there will not be inconsistent results
+ unlazyG flightcontrol.Group
}
func NewManager(opt ManagerOpt) (Manager, error) {
@@ -92,7 +97,7 @@
return cm, nil
}
-func (cm *cacheManager) GetByBlob(ctx context.Context, desc ocispec.Descriptor, parent ImmutableRef, opts ...RefOption) (ir ImmutableRef, err error) {
+func (cm *cacheManager) GetByBlob(ctx context.Context, desc ocispec.Descriptor, parent ImmutableRef, opts ...RefOption) (ir ImmutableRef, rerr error) {
diffID, err := diffIDFromDescriptor(desc)
if err != nil {
return nil, err
@@ -100,9 +105,12 @@
chainID := diffID
blobChainID := imagespecidentity.ChainID([]digest.Digest{desc.Digest, diffID})
- if desc.Digest != "" {
- if _, err := cm.ContentStore.Info(ctx, desc.Digest); err != nil {
- return nil, errors.Wrapf(err, "failed to get blob %s", desc.Digest)
+ descHandlers := descHandlersOf(opts...)
+ if desc.Digest != "" && (descHandlers == nil || descHandlers[desc.Digest] == nil) {
+ if _, err := cm.ContentStore.Info(ctx, desc.Digest); errors.Is(err, errdefs.ErrNotFound) {
+ return nil, NeedsRemoteProvidersError([]digest.Digest{desc.Digest})
+ } else if err != nil {
+ return nil, err
}
}
@@ -115,7 +123,8 @@
}
chainID = imagespecidentity.ChainID([]digest.Digest{pInfo.ChainID, chainID})
blobChainID = imagespecidentity.ChainID([]digest.Digest{pInfo.BlobChainID, blobChainID})
- p2, err := cm.Get(ctx, parent.ID(), NoUpdateLastUsed)
+
+ p2, err := cm.Get(ctx, parent.ID(), NoUpdateLastUsed, descHandlers)
if err != nil {
return nil, err
}
@@ -128,7 +137,7 @@
releaseParent := false
defer func() {
- if releaseParent || err != nil && p != nil {
+ if releaseParent || rerr != nil && p != nil {
p.Release(context.TODO())
}
}()
@@ -141,14 +150,17 @@
return nil, err
}
- for _, si := range sis {
- ref, err := cm.get(ctx, si.ID(), opts...)
+ if len(sis) > 0 {
+ ref, err := cm.get(ctx, sis[0].ID(), opts...)
if err != nil && !IsNotFound(err) {
- return nil, errors.Wrapf(err, "failed to get record %s by blobchainid", si.ID())
+ return nil, errors.Wrapf(err, "failed to get record %s by blobchainid", sis[0].ID())
}
if p != nil {
releaseParent = true
}
+ if err := setImageRefMetadata(ref, opts...); err != nil {
+ return nil, errors.Wrapf(err, "failed to append image ref metadata to ref %s", ref.ID())
+ }
return ref, nil
}
@@ -158,13 +170,12 @@
}
var link ImmutableRef
- for _, si := range sis {
- ref, err := cm.get(ctx, si.ID(), opts...)
+ if len(sis) > 0 {
+ ref, err := cm.get(ctx, sis[0].ID(), opts...)
if err != nil && !IsNotFound(err) {
- return nil, errors.Wrapf(err, "failed to get record %s by chainid", si.ID())
+ return nil, errors.Wrapf(err, "failed to get record %s by chainid", sis[0].ID())
}
link = ref
- break
}
id := identity.NewID()
@@ -188,7 +199,7 @@
}
defer func() {
- if err != nil {
+ if rerr != nil {
if err := cm.ManagerOpt.LeaseManager.Delete(context.TODO(), leases.Lease{
ID: l.ID,
}); err != nil {
@@ -227,6 +238,10 @@
return nil, err
}
+ if err := setImageRefMetadata(rec, opts...); err != nil {
+ return nil, errors.Wrapf(err, "failed to append image ref metadata to ref %s", rec.ID())
+ }
+
queueDiffID(rec.md, diffID.String())
queueBlob(rec.md, desc.Digest.String())
queueChainID(rec.md, chainID.String())
@@ -234,6 +249,7 @@
queueSnapshotID(rec.md, snapshotID)
queueBlobOnly(rec.md, blobOnly)
queueMediaType(rec.md, desc.MediaType)
+ queueBlobSize(rec.md, desc.Size)
queueCommitted(rec.md)
if err := rec.md.Commit(); err != nil {
@@ -242,7 +258,7 @@
cm.records[id] = rec
- return rec.ref(true), nil
+ return rec.ref(true, descHandlers), nil
}
// init loads all snapshots from metadata state and tries to load the records
@@ -308,25 +324,52 @@
}
}
+ descHandlers := descHandlersOf(opts...)
+
if rec.mutable {
if len(rec.refs) != 0 {
return nil, errors.Wrapf(ErrLocked, "%s is locked", id)
}
if rec.equalImmutable != nil {
- return rec.equalImmutable.ref(triggerUpdate), nil
+ return rec.equalImmutable.ref(triggerUpdate, descHandlers), nil
}
- return rec.mref(triggerUpdate).commit(ctx)
+ return rec.mref(triggerUpdate, descHandlers).commit(ctx)
}
- return rec.ref(triggerUpdate), nil
+ return rec.ref(triggerUpdate, descHandlers), nil
}
// getRecord returns record for id. Requires manager lock.
func (cm *cacheManager) getRecord(ctx context.Context, id string, opts ...RefOption) (cr *cacheRecord, retErr error) {
+ checkLazyProviders := func(rec *cacheRecord) error {
+ missing := NeedsRemoteProvidersError(nil)
+ dhs := descHandlersOf(opts...)
+ for {
+ blob := digest.Digest(getBlob(rec.md))
+ if isLazy, err := rec.isLazy(ctx); err != nil {
+ return err
+ } else if isLazy && dhs[blob] == nil {
+ missing = append(missing, blob)
+ }
+
+ if rec.parent == nil {
+ break
+ }
+ rec = rec.parent.cacheRecord
+ }
+ if len(missing) > 0 {
+ return missing
+ }
+ return nil
+ }
+
if rec, ok := cm.records[id]; ok {
if rec.isDead() {
return nil, errors.Wrapf(errNotFound, "failed to get dead record %s", id)
}
+ if err := checkLazyProviders(rec); err != nil {
+ return nil, err
+ }
return rec, nil
}
@@ -343,11 +386,17 @@
}
return nil, err
}
+
+ // parent refs are possibly lazy so keep it hold the description handlers.
+ var dhs DescHandlers
+ if mutable.parent != nil {
+ dhs = mutable.parent.descHandlers
+ }
rec := &cacheRecord{
mu: &sync.Mutex{},
cm: cm,
refs: make(map[ref]struct{}),
- parent: mutable.parentRef(false),
+ parent: mutable.parentRef(false, dhs),
md: md,
equalMutable: &mutableRef{cacheRecord: mutable},
}
@@ -393,25 +442,39 @@
return nil, err
}
+ if err := setImageRefMetadata(rec, opts...); err != nil {
+ return nil, errors.Wrapf(err, "failed to append image ref metadata to ref %s", rec.ID())
+ }
+
cm.records[id] = rec
+ if err := checkLazyProviders(rec); err != nil {
+ return nil, err
+ }
return rec, nil
}
-func (cm *cacheManager) New(ctx context.Context, s ImmutableRef, opts ...RefOption) (mr MutableRef, err error) {
+func (cm *cacheManager) New(ctx context.Context, s ImmutableRef, sess session.Group, opts ...RefOption) (mr MutableRef, err error) {
id := identity.NewID()
var parent *immutableRef
var parentID string
var parentSnapshotID string
if s != nil {
- p, err := cm.Get(ctx, s.ID(), NoUpdateLastUsed)
- if err != nil {
+ if _, ok := s.(*immutableRef); ok {
+ parent = s.Clone().(*immutableRef)
+ } else {
+ p, err := cm.Get(ctx, s.ID(), append(opts, NoUpdateLastUsed)...)
+ if err != nil {
+ return nil, err
+ }
+ parent = p.(*immutableRef)
+ }
+ if err := parent.Finalize(ctx, true); err != nil {
return nil, err
}
- if err := p.Finalize(ctx, true); err != nil {
+ if err := parent.Extract(ctx, sess); err != nil {
return nil, err
}
- parent = p.(*immutableRef)
parentSnapshotID = getSnapshotID(parent.md)
parentID = parent.ID()
}
@@ -469,18 +532,28 @@
return nil, err
}
+ if err := setImageRefMetadata(rec, opts...); err != nil {
+ return nil, errors.Wrapf(err, "failed to append image ref metadata to ref %s", rec.ID())
+ }
+
cm.mu.Lock()
defer cm.mu.Unlock()
cm.records[id] = rec // TODO: save to db
- return rec.mref(true), nil
+ // parent refs are possibly lazy so keep it hold the description handlers.
+ var dhs DescHandlers
+ if parent != nil {
+ dhs = parent.descHandlers
+ }
+ return rec.mref(true, dhs), nil
}
-func (cm *cacheManager) GetMutable(ctx context.Context, id string) (MutableRef, error) {
+
+func (cm *cacheManager) GetMutable(ctx context.Context, id string, opts ...RefOption) (MutableRef, error) {
cm.mu.Lock()
defer cm.mu.Unlock()
- rec, err := cm.getRecord(ctx, id)
+ rec, err := cm.getRecord(ctx, id, opts...)
if err != nil {
return nil, err
}
@@ -506,7 +579,7 @@
rec.equalImmutable = nil
}
- return rec.mref(true), nil
+ return rec.mref(true, descHandlersOf(opts...)), nil
}
func (cm *cacheManager) Prune(ctx context.Context, ch chan client.UsageInfo, opts ...client.PruneInfo) error {
@@ -957,6 +1030,31 @@
}
}
+// Need a separate type for imageRef because it needs to be called outside
+// initializeMetadata while still being a RefOption, so wrapping it in a
+// different type ensures initializeMetadata won't catch it too and duplicate
+// setting the metadata.
+type imageRefOption func(m withMetadata) error
+
+// WithImageRef appends the given imageRef to the cache ref's metadata
+func WithImageRef(imageRef string) RefOption {
+ return imageRefOption(func(m withMetadata) error {
+ return appendImageRef(m.Metadata(), imageRef)
+ })
+}
+
+func setImageRefMetadata(m withMetadata, opts ...RefOption) error {
+ md := m.Metadata()
+ for _, opt := range opts {
+ if fn, ok := opt.(imageRefOption); ok {
+ if err := fn(m); err != nil {
+ return err
+ }
+ }
+ }
+ return md.Commit()
+}
+
func initializeMetadata(m withMetadata, parent string, opts ...RefOption) error {
md := m.Metadata()
if tm := GetCreatedAt(md); !tm.IsZero() {
diff --git a/vendor/github.com/moby/buildkit/cache/metadata.go b/vendor/github.com/moby/buildkit/cache/metadata.go
index bf4041e..a5c7df7 100644
--- a/vendor/github.com/moby/buildkit/cache/metadata.go
+++ b/vendor/github.com/moby/buildkit/cache/metadata.go
@@ -28,6 +28,10 @@
const keySnapshot = "cache.snapshot"
const keyBlobOnly = "cache.blobonly"
const keyMediaType = "cache.mediatype"
+const keyImageRefs = "cache.imageRefs"
+
+// BlobSize is the packed blob size as specified in the oci descriptor
+const keyBlobSize = "cache.blobsize"
const keyDeleted = "cache.deleted"
@@ -307,6 +311,63 @@
return size
}
+func appendImageRef(si *metadata.StorageItem, s string) error {
+ return si.GetAndSetValue(keyImageRefs, func(v *metadata.Value) (*metadata.Value, error) {
+ var imageRefs []string
+ if v != nil {
+ if err := v.Unmarshal(&imageRefs); err != nil {
+ return nil, err
+ }
+ }
+ for _, existing := range imageRefs {
+ if existing == s {
+ return nil, metadata.ErrSkipSetValue
+ }
+ }
+ imageRefs = append(imageRefs, s)
+ v, err := metadata.NewValue(imageRefs)
+ if err != nil {
+ return nil, errors.Wrap(err, "failed to create imageRefs value")
+ }
+ return v, nil
+ })
+}
+
+func getImageRefs(si *metadata.StorageItem) []string {
+ v := si.Get(keyImageRefs)
+ if v == nil {
+ return nil
+ }
+ var refs []string
+ if err := v.Unmarshal(&refs); err != nil {
+ return nil
+ }
+ return refs
+}
+
+func queueBlobSize(si *metadata.StorageItem, s int64) error {
+ v, err := metadata.NewValue(s)
+ if err != nil {
+ return errors.Wrap(err, "failed to create blobsize value")
+ }
+ si.Queue(func(b *bolt.Bucket) error {
+ return si.SetValue(b, keyBlobSize, v)
+ })
+ return nil
+}
+
+func getBlobSize(si *metadata.StorageItem) int64 {
+ v := si.Get(keyBlobSize)
+ if v == nil {
+ return sizeUnknown
+ }
+ var size int64
+ if err := v.Unmarshal(&size); err != nil {
+ return sizeUnknown
+ }
+ return size
+}
+
func getEqualMutable(si *metadata.StorageItem) string {
v := si.Get(keyEqualMutable)
if v == nil {
diff --git a/vendor/github.com/moby/buildkit/cache/metadata/metadata.go b/vendor/github.com/moby/buildkit/cache/metadata/metadata.go
index 42e8cb4..b0b2221 100644
--- a/vendor/github.com/moby/buildkit/cache/metadata/metadata.go
+++ b/vendor/github.com/moby/buildkit/cache/metadata/metadata.go
@@ -372,6 +372,22 @@
return nil
}
+var ErrSkipSetValue = errors.New("skip setting metadata value")
+
+func (s *StorageItem) GetAndSetValue(key string, fn func(*Value) (*Value, error)) error {
+ s.mu.Lock()
+ defer s.mu.Unlock()
+ return s.Update(func(b *bolt.Bucket) error {
+ v, err := fn(s.values[key])
+ if errors.Is(err, ErrSkipSetValue) {
+ return nil
+ } else if err != nil {
+ return err
+ }
+ return s.SetValue(b, key, v)
+ })
+}
+
type Value struct {
Value json.RawMessage `json:"value,omitempty"`
Index string `json:"index,omitempty"`
diff --git a/vendor/github.com/moby/buildkit/cache/opts.go b/vendor/github.com/moby/buildkit/cache/opts.go
new file mode 100644
index 0000000..911def3
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/cache/opts.go
@@ -0,0 +1,35 @@
+package cache
+
+import (
+ "fmt"
+
+ "github.com/containerd/containerd/content"
+ "github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/util/progress"
+ digest "github.com/opencontainers/go-digest"
+)
+
+type DescHandler struct {
+ Provider func(session.Group) content.Provider
+ Progress progress.Controller
+ SnapshotLabels map[string]string
+}
+
+type DescHandlers map[digest.Digest]*DescHandler
+
+func descHandlersOf(opts ...RefOption) DescHandlers {
+ for _, opt := range opts {
+ if opt, ok := opt.(DescHandlers); ok {
+ return opt
+ }
+ }
+ return nil
+}
+
+type DescHandlerKey digest.Digest
+
+type NeedsRemoteProvidersError []digest.Digest
+
+func (m NeedsRemoteProvidersError) Error() string {
+ return fmt.Sprintf("missing descriptor handlers for lazy blobs %+v", []digest.Digest(m))
+}
diff --git a/vendor/github.com/moby/buildkit/cache/refs.go b/vendor/github.com/moby/buildkit/cache/refs.go
index d932f4e..2b25235 100644
--- a/vendor/github.com/moby/buildkit/cache/refs.go
+++ b/vendor/github.com/moby/buildkit/cache/refs.go
@@ -14,14 +14,18 @@
"github.com/docker/docker/pkg/idtools"
"github.com/moby/buildkit/cache/metadata"
"github.com/moby/buildkit/identity"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/snapshot"
+ "github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/util/compression"
"github.com/moby/buildkit/util/flightcontrol"
"github.com/moby/buildkit/util/leaseutil"
+ "github.com/moby/buildkit/util/winlayers"
digest "github.com/opencontainers/go-digest"
- imagespecidentity "github.com/opencontainers/image-spec/identity"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
+ "golang.org/x/sync/errgroup"
)
// Ref is a reference to cacheable objects.
@@ -41,8 +45,8 @@
Clone() ImmutableRef
Info() RefInfo
- SetBlob(ctx context.Context, desc ocispec.Descriptor) error
- Extract(ctx context.Context) error // +progress
+ Extract(ctx context.Context, s session.Group) error // +progress
+ GetRemote(ctx context.Context, createIfNeeded bool, compressionType compression.Type, s session.Group) (*solver.Remote, error)
}
type RefInfo struct {
@@ -61,7 +65,7 @@
}
type Mountable interface {
- Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error)
+ Mount(ctx context.Context, readonly bool, s session.Group) (snapshot.Mountable, error)
}
type ref interface {
@@ -93,15 +97,23 @@
}
// hold ref lock before calling
-func (cr *cacheRecord) ref(triggerLastUsed bool) *immutableRef {
- ref := &immutableRef{cacheRecord: cr, triggerLastUsed: triggerLastUsed}
+func (cr *cacheRecord) ref(triggerLastUsed bool, descHandlers DescHandlers) *immutableRef {
+ ref := &immutableRef{
+ cacheRecord: cr,
+ triggerLastUsed: triggerLastUsed,
+ descHandlers: descHandlers,
+ }
cr.refs[ref] = struct{}{}
return ref
}
// hold ref lock before calling
-func (cr *cacheRecord) mref(triggerLastUsed bool) *mutableRef {
- ref := &mutableRef{cacheRecord: cr, triggerLastUsed: triggerLastUsed}
+func (cr *cacheRecord) mref(triggerLastUsed bool, descHandlers DescHandlers) *mutableRef {
+ ref := &mutableRef{
+ cacheRecord: cr,
+ triggerLastUsed: triggerLastUsed,
+ descHandlers: descHandlers,
+ }
cr.refs[ref] = struct{}{}
return ref
}
@@ -131,6 +143,22 @@
return cr.dead || (cr.equalImmutable != nil && cr.equalImmutable.dead) || (cr.equalMutable != nil && cr.equalMutable.dead)
}
+func (cr *cacheRecord) isLazy(ctx context.Context) (bool, error) {
+ if !getBlobOnly(cr.md) {
+ return false, nil
+ }
+ dgst := getBlob(cr.md)
+ // special case for moby where there is no compressed blob (empty digest)
+ if dgst == "" {
+ return false, nil
+ }
+ _, err := cr.cm.ContentStore.Info(ctx, digest.Digest(dgst))
+ if errors.Is(err, errdefs.ErrNotFound) {
+ return true, nil
+ }
+ return false, err
+}
+
func (cr *cacheRecord) IdentityMapping() *idtools.IdentityMapping {
return cr.cm.IdentityMapping()
}
@@ -186,27 +214,18 @@
return s.(int64), nil
}
-func (cr *cacheRecord) Parent() ImmutableRef {
- if p := cr.parentRef(true); p != nil { // avoid returning typed nil pointer
- return p
- }
- return nil
-}
-
-func (cr *cacheRecord) parentRef(hidden bool) *immutableRef {
+func (cr *cacheRecord) parentRef(hidden bool, descHandlers DescHandlers) *immutableRef {
p := cr.parent
if p == nil {
return nil
}
p.mu.Lock()
defer p.mu.Unlock()
- return p.ref(hidden)
+ return p.ref(hidden, descHandlers)
}
-func (cr *cacheRecord) Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error) {
- cr.mu.Lock()
- defer cr.mu.Unlock()
-
+// must be called holding cacheRecord mu
+func (cr *cacheRecord) mount(ctx context.Context, readonly bool) (snapshot.Mountable, error) {
if cr.mutable {
m, err := cr.cm.Snapshotter.Mounts(ctx, getSnapshotID(cr.md))
if err != nil {
@@ -282,20 +301,29 @@
type immutableRef struct {
*cacheRecord
triggerLastUsed bool
+ descHandlers DescHandlers
}
type mutableRef struct {
*cacheRecord
triggerLastUsed bool
+ descHandlers DescHandlers
}
func (sr *immutableRef) Clone() ImmutableRef {
sr.mu.Lock()
- ref := sr.ref(false)
+ ref := sr.ref(false, sr.descHandlers)
sr.mu.Unlock()
return ref
}
+func (sr *immutableRef) Parent() ImmutableRef {
+ if p := sr.parentRef(true, sr.descHandlers); p != nil { // avoid returning typed nil pointer
+ return p
+ }
+ return nil
+}
+
func (sr *immutableRef) Info() RefInfo {
return RefInfo{
ChainID: digest.Digest(getChainID(sr.md)),
@@ -308,25 +336,181 @@
}
}
-func (sr *immutableRef) Extract(ctx context.Context) error {
- _, err := sr.sizeG.Do(ctx, sr.ID()+"-extract", func(ctx context.Context) (interface{}, error) {
+func (sr *immutableRef) ociDesc() (ocispec.Descriptor, error) {
+ desc := ocispec.Descriptor{
+ Digest: digest.Digest(getBlob(sr.md)),
+ Size: getBlobSize(sr.md),
+ MediaType: getMediaType(sr.md),
+ Annotations: make(map[string]string),
+ }
+
+ diffID := getDiffID(sr.md)
+ if diffID != "" {
+ desc.Annotations["containerd.io/uncompressed"] = diffID
+ }
+
+ createdAt := GetCreatedAt(sr.md)
+ if !createdAt.IsZero() {
+ createdAt, err := createdAt.MarshalText()
+ if err != nil {
+ return ocispec.Descriptor{}, err
+ }
+ desc.Annotations["buildkit/createdat"] = string(createdAt)
+ }
+
+ return desc, nil
+}
+
+// order is from parent->child, sr will be at end of slice
+func (sr *immutableRef) parentRefChain() []*immutableRef {
+ var count int
+ for ref := sr; ref != nil; ref = ref.parent {
+ count++
+ }
+ refs := make([]*immutableRef, count)
+ for i, ref := count-1, sr; ref != nil; i, ref = i-1, ref.parent {
+ refs[i] = ref
+ }
+ return refs
+}
+
+func (sr *immutableRef) Mount(ctx context.Context, readonly bool, s session.Group) (snapshot.Mountable, error) {
+ if err := sr.Extract(ctx, s); err != nil {
+ return nil, err
+ }
+
+ sr.mu.Lock()
+ defer sr.mu.Unlock()
+ return sr.mount(ctx, readonly)
+}
+
+func (sr *immutableRef) Extract(ctx context.Context, s session.Group) (rerr error) {
+ if !getBlobOnly(sr.md) {
+ return
+ }
+
+ ctx, done, err := leaseutil.WithLease(ctx, sr.cm.LeaseManager, leaseutil.MakeTemporary)
+ if err != nil {
+ return err
+ }
+ defer done(ctx)
+
+ if GetLayerType(sr) == "windows" {
+ ctx = winlayers.UseWindowsLayerMode(ctx)
+ }
+
+ if _, err := sr.prepareRemoteSnapshots(ctx, sr.descHandlers); err != nil {
+ return err
+ }
+
+ return sr.extract(ctx, sr.descHandlers, s)
+}
+
+func (sr *immutableRef) prepareRemoteSnapshots(ctx context.Context, dhs DescHandlers) (bool, error) {
+ ok, err := sr.sizeG.Do(ctx, sr.ID()+"-prepare-remote-snapshot", func(ctx context.Context) (_ interface{}, rerr error) {
snapshotID := getSnapshotID(sr.md)
if _, err := sr.cm.Snapshotter.Stat(ctx, snapshotID); err == nil {
- queueBlobOnly(sr.md, false)
- return nil, sr.md.Commit()
+ return true, nil
+ }
+ desc, err := sr.ociDesc()
+ if err != nil {
+ return false, err
+ }
+ dh := dhs[desc.Digest]
+ if dh == nil {
+ return false, nil
}
parentID := ""
if sr.parent != nil {
- if err := sr.parent.Extract(ctx); err != nil {
- return nil, err
+ if ok, err := sr.parent.prepareRemoteSnapshots(ctx, dhs); !ok {
+ return false, err
}
parentID = getSnapshotID(sr.parent.md)
}
- info := sr.Info()
- key := fmt.Sprintf("extract-%s %s", identity.NewID(), info.ChainID)
- err := sr.cm.Snapshotter.Prepare(ctx, key, parentID)
+ // Hint labels to the snapshotter
+ labels := dh.SnapshotLabels
+ if labels == nil {
+ labels = make(map[string]string)
+ }
+ labels["containerd.io/snapshot.ref"] = snapshotID
+ opt := snapshots.WithLabels(labels)
+
+ // Try to preapre the remote snapshot
+ key := fmt.Sprintf("tmp-%s %s", identity.NewID(), sr.Info().ChainID)
+ if err = sr.cm.Snapshotter.Prepare(ctx, key, parentID, opt); err != nil {
+ if errdefs.IsAlreadyExists(err) {
+ // Check if the targeting snapshot ID has been prepared as a remote
+ // snapshot in the snapshotter.
+ if _, err := sr.cm.Snapshotter.Stat(ctx, snapshotID); err == nil {
+ // We can use this remote snapshot without unlazying.
+ // Try the next layer as well.
+ return true, nil
+ }
+ }
+ }
+
+ // This layer cannot be prepared without unlazying.
+ return false, nil
+ })
+ return ok.(bool), err
+}
+
+func (sr *immutableRef) extract(ctx context.Context, dhs DescHandlers, s session.Group) error {
+ _, err := sr.sizeG.Do(ctx, sr.ID()+"-extract", func(ctx context.Context) (_ interface{}, rerr error) {
+ snapshotID := getSnapshotID(sr.md)
+ if _, err := sr.cm.Snapshotter.Stat(ctx, snapshotID); err == nil {
+ return nil, nil
+ }
+
+ if sr.cm.Applier == nil {
+ return nil, errors.New("extract requires an applier")
+ }
+
+ eg, egctx := errgroup.WithContext(ctx)
+
+ parentID := ""
+ if sr.parent != nil {
+ eg.Go(func() error {
+ if err := sr.parent.extract(egctx, dhs, s); err != nil {
+ return err
+ }
+ parentID = getSnapshotID(sr.parent.md)
+ return nil
+ })
+ }
+
+ desc, err := sr.ociDesc()
+ if err != nil {
+ return nil, err
+ }
+ dh := dhs[desc.Digest]
+
+ eg.Go(func() error {
+ // unlazies if needed, otherwise a no-op
+ return lazyRefProvider{
+ ref: sr,
+ desc: desc,
+ dh: dh,
+ session: s,
+ }.Unlazy(egctx)
+ })
+
+ if err := eg.Wait(); err != nil {
+ return nil, err
+ }
+
+ if dh != nil && dh.Progress != nil {
+ _, stopProgress := dh.Progress.Start(ctx)
+ defer stopProgress(rerr)
+ statusDone := dh.Progress.Status("extracting "+desc.Digest.String(), "extracting")
+ defer statusDone()
+ }
+
+ key := fmt.Sprintf("extract-%s %s", identity.NewID(), sr.Info().ChainID)
+
+ err = sr.cm.Snapshotter.Prepare(ctx, key, parentID)
if err != nil {
return nil, err
}
@@ -339,10 +523,7 @@
if err != nil {
return nil, err
}
- _, err = sr.cm.Applier.Apply(ctx, ocispec.Descriptor{
- Digest: info.Blob,
- MediaType: info.MediaType,
- }, mounts)
+ _, err = sr.cm.Applier.Apply(ctx, desc, mounts)
if err != nil {
unmount()
return nil, err
@@ -357,6 +538,7 @@
}
}
queueBlobOnly(sr.md, false)
+ setSize(sr.md, sizeUnknown)
if err := sr.md.Commit(); err != nil {
return nil, err
}
@@ -365,65 +547,6 @@
return err
}
-// SetBlob associates a blob with the cache record.
-// A lease must be held for the blob when calling this function
-// Caller should call Info() for knowing what current values are actually set
-func (sr *immutableRef) SetBlob(ctx context.Context, desc ocispec.Descriptor) error {
- diffID, err := diffIDFromDescriptor(desc)
- if err != nil {
- return err
- }
- if _, err := sr.cm.ContentStore.Info(ctx, desc.Digest); err != nil {
- return err
- }
-
- sr.mu.Lock()
- defer sr.mu.Unlock()
-
- if getChainID(sr.md) != "" {
- return nil
- }
-
- if err := sr.finalize(ctx, true); err != nil {
- return err
- }
-
- p := sr.parent
- var parentChainID digest.Digest
- var parentBlobChainID digest.Digest
- if p != nil {
- pInfo := p.Info()
- if pInfo.ChainID == "" || pInfo.BlobChainID == "" {
- return errors.Errorf("failed to set blob for reference with non-addressable parent")
- }
- parentChainID = pInfo.ChainID
- parentBlobChainID = pInfo.BlobChainID
- }
-
- if err := sr.cm.LeaseManager.AddResource(ctx, leases.Lease{ID: sr.ID()}, leases.Resource{
- ID: desc.Digest.String(),
- Type: "content",
- }); err != nil {
- return err
- }
-
- queueDiffID(sr.md, diffID.String())
- queueBlob(sr.md, desc.Digest.String())
- chainID := diffID
- blobChainID := imagespecidentity.ChainID([]digest.Digest{desc.Digest, diffID})
- if parentChainID != "" {
- chainID = imagespecidentity.ChainID([]digest.Digest{parentChainID, chainID})
- blobChainID = imagespecidentity.ChainID([]digest.Digest{parentBlobChainID, blobChainID})
- }
- queueChainID(sr.md, chainID.String())
- queueBlobChainID(sr.md, blobChainID.String())
- queueMediaType(sr.md, desc.MediaType)
- if err := sr.md.Commit(); err != nil {
- return err
- }
- return nil
-}
-
func (sr *immutableRef) Release(ctx context.Context) error {
sr.cm.mu.Lock()
defer sr.cm.mu.Unlock()
@@ -555,7 +678,7 @@
rec := &cacheRecord{
mu: sr.mu,
cm: sr.cm,
- parent: sr.parentRef(false),
+ parent: sr.parentRef(false, sr.descHandlers),
equalMutable: sr,
refs: make(map[ref]struct{}),
md: md,
@@ -588,13 +711,16 @@
return nil, err
}
- ref := rec.ref(true)
+ ref := rec.ref(true, sr.descHandlers)
sr.equalImmutable = ref
return ref, nil
}
-func (sr *mutableRef) updatesLastUsed() bool {
- return sr.triggerLastUsed
+func (sr *mutableRef) Mount(ctx context.Context, readonly bool, s session.Group) (snapshot.Mountable, error) {
+ sr.mu.Lock()
+ defer sr.mu.Unlock()
+
+ return sr.mount(ctx, readonly)
}
func (sr *mutableRef) Commit(ctx context.Context) (ImmutableRef, error) {
@@ -633,11 +759,10 @@
}
}
return sr.remove(ctx, true)
- } else {
- if sr.updateLastUsed() {
- updateLastUsed(sr.md)
- sr.triggerLastUsed = false
- }
+ }
+ if sr.updateLastUsed() {
+ updateLastUsed(sr.md)
+ sr.triggerLastUsed = false
}
return nil
}
diff --git a/vendor/github.com/moby/buildkit/cache/remote.go b/vendor/github.com/moby/buildkit/cache/remote.go
new file mode 100644
index 0000000..b74cb27
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/cache/remote.go
@@ -0,0 +1,204 @@
+package cache
+
+import (
+ "context"
+ "fmt"
+ "net/url"
+ "strings"
+
+ "github.com/containerd/containerd/content"
+ "github.com/containerd/containerd/errdefs"
+ "github.com/containerd/containerd/reference"
+ "github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/util/compression"
+ "github.com/moby/buildkit/util/contentutil"
+ "github.com/moby/buildkit/util/leaseutil"
+ "github.com/moby/buildkit/util/pull/pullprogress"
+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/pkg/errors"
+ "golang.org/x/sync/errgroup"
+)
+
+type Unlazier interface {
+ Unlazy(ctx context.Context) error
+}
+
+// GetRemote gets a *solver.Remote from content store for this ref (potentially pulling lazily).
+// Note: Use WorkerRef.GetRemote instead as moby integration requires custom GetRemote implementation.
+func (sr *immutableRef) GetRemote(ctx context.Context, createIfNeeded bool, compressionType compression.Type, s session.Group) (*solver.Remote, error) {
+ ctx, done, err := leaseutil.WithLease(ctx, sr.cm.LeaseManager, leaseutil.MakeTemporary)
+ if err != nil {
+ return nil, err
+ }
+ defer done(ctx)
+
+ err = sr.computeBlobChain(ctx, createIfNeeded, compressionType, s)
+ if err != nil {
+ return nil, err
+ }
+
+ mprovider := &lazyMultiProvider{mprovider: contentutil.NewMultiProvider(nil)}
+ remote := &solver.Remote{
+ Provider: mprovider,
+ }
+
+ for _, ref := range sr.parentRefChain() {
+ desc, err := ref.ociDesc()
+ if err != nil {
+ return nil, err
+ }
+
+ // NOTE: The media type might be missing for some migrated ones
+ // from before lease based storage. If so, we should detect
+ // the media type from blob data.
+ //
+ // Discussion: https://github.com/moby/buildkit/pull/1277#discussion_r352795429
+ if desc.MediaType == "" {
+ desc.MediaType, err = compression.DetectLayerMediaType(ctx, sr.cm.ContentStore, desc.Digest, false)
+ if err != nil {
+ return nil, err
+ }
+ }
+
+ // update distribution source annotation for lazy-refs (non-lazy refs
+ // will already have their dsl stored in the content store, which is
+ // used by the push handlers)
+ if isLazy, err := ref.isLazy(ctx); err != nil {
+ return nil, err
+ } else if isLazy {
+ imageRefs := getImageRefs(ref.md)
+ for _, imageRef := range imageRefs {
+ refspec, err := reference.Parse(imageRef)
+ if err != nil {
+ return nil, err
+ }
+
+ u, err := url.Parse("dummy://" + refspec.Locator)
+ if err != nil {
+ return nil, err
+ }
+
+ source, repo := u.Hostname(), strings.TrimPrefix(u.Path, "/")
+ if desc.Annotations == nil {
+ desc.Annotations = make(map[string]string)
+ }
+ dslKey := fmt.Sprintf("%s.%s", "containerd.io/distribution.source", source)
+
+ var existingRepos []string
+ if existings, ok := desc.Annotations[dslKey]; ok {
+ existingRepos = strings.Split(existings, ",")
+ }
+ addNewRepo := true
+ for _, existing := range existingRepos {
+ if existing == repo {
+ addNewRepo = false
+ break
+ }
+ }
+ if addNewRepo {
+ existingRepos = append(existingRepos, repo)
+ }
+ desc.Annotations[dslKey] = strings.Join(existingRepos, ",")
+ }
+ }
+
+ remote.Descriptors = append(remote.Descriptors, desc)
+ mprovider.Add(lazyRefProvider{
+ ref: ref,
+ desc: desc,
+ dh: sr.descHandlers[desc.Digest],
+ session: s,
+ })
+ }
+ return remote, nil
+}
+
+type lazyMultiProvider struct {
+ mprovider *contentutil.MultiProvider
+ plist []lazyRefProvider
+}
+
+func (mp *lazyMultiProvider) Add(p lazyRefProvider) {
+ mp.mprovider.Add(p.desc.Digest, p)
+ mp.plist = append(mp.plist, p)
+}
+
+func (mp *lazyMultiProvider) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
+ return mp.mprovider.ReaderAt(ctx, desc)
+}
+
+func (mp *lazyMultiProvider) Unlazy(ctx context.Context) error {
+ eg, egctx := errgroup.WithContext(ctx)
+ for _, p := range mp.plist {
+ p := p
+ eg.Go(func() error {
+ return p.Unlazy(egctx)
+ })
+ }
+ return eg.Wait()
+}
+
+type lazyRefProvider struct {
+ ref *immutableRef
+ desc ocispec.Descriptor
+ dh *DescHandler
+ session session.Group
+}
+
+func (p lazyRefProvider) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
+ if desc.Digest != p.desc.Digest {
+ return nil, errdefs.ErrNotFound
+ }
+ if err := p.Unlazy(ctx); err != nil {
+ return nil, err
+ }
+ return p.ref.cm.ContentStore.ReaderAt(ctx, desc)
+}
+
+func (p lazyRefProvider) Unlazy(ctx context.Context) error {
+ _, err := p.ref.cm.unlazyG.Do(ctx, string(p.desc.Digest), func(ctx context.Context) (_ interface{}, rerr error) {
+ if isLazy, err := p.ref.isLazy(ctx); err != nil {
+ return nil, err
+ } else if !isLazy {
+ return nil, nil
+ }
+
+ if p.dh == nil {
+ // shouldn't happen, if you have a lazy immutable ref it already should be validated
+ // that descriptor handlers exist for it
+ return nil, errors.New("unexpected nil descriptor handler")
+ }
+
+ if p.dh.Progress != nil {
+ var stopProgress func(error)
+ ctx, stopProgress = p.dh.Progress.Start(ctx)
+ defer stopProgress(rerr)
+ }
+
+ // For now, just pull down the whole content and then return a ReaderAt from the local content
+ // store. If efficient partial reads are desired in the future, something more like a "tee"
+ // that caches remote partial reads to a local store may need to replace this.
+ err := contentutil.Copy(ctx, p.ref.cm.ContentStore, &pullprogress.ProviderWithProgress{
+ Provider: p.dh.Provider(p.session),
+ Manager: p.ref.cm.ContentStore,
+ }, p.desc)
+ if err != nil {
+ return nil, err
+ }
+
+ if imageRefs := getImageRefs(p.ref.md); len(imageRefs) > 0 {
+ // just use the first image ref, it's arbitrary
+ imageRef := imageRefs[0]
+ if GetDescription(p.ref.md) == "" {
+ queueDescription(p.ref.md, "pulled from "+imageRef)
+ err := p.ref.md.Commit()
+ if err != nil {
+ return nil, err
+ }
+ }
+ }
+ return nil, err
+ })
+ return err
+}
diff --git a/vendor/github.com/moby/buildkit/cache/remotecache/export.go b/vendor/github.com/moby/buildkit/cache/remotecache/export.go
index d9d5bab..542aa76 100644
--- a/vendor/github.com/moby/buildkit/cache/remotecache/export.go
+++ b/vendor/github.com/moby/buildkit/cache/remotecache/export.go
@@ -12,6 +12,7 @@
v1 "github.com/moby/buildkit/cache/remotecache/v1"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/util/compression"
"github.com/moby/buildkit/util/contentutil"
"github.com/moby/buildkit/util/progress"
digest "github.com/opencontainers/go-digest"
@@ -55,20 +56,17 @@
solver.CacheExporterTarget
chains *v1.CacheChains
ingester content.Ingester
+ oci bool
}
-func NewExporter(ingester content.Ingester) Exporter {
+func NewExporter(ingester content.Ingester, oci bool) Exporter {
cc := v1.NewCacheChains()
- return &contentCacheExporter{CacheExporterTarget: cc, chains: cc, ingester: ingester}
+ return &contentCacheExporter{CacheExporterTarget: cc, chains: cc, ingester: ingester, oci: oci}
}
func (ce *contentCacheExporter) Finalize(ctx context.Context) (map[string]string, error) {
- return export(ctx, ce.ingester, ce.chains)
-}
-
-func export(ctx context.Context, ingester content.Ingester, cc *v1.CacheChains) (map[string]string, error) {
res := make(map[string]string)
- config, descs, err := cc.Marshal()
+ config, descs, err := ce.chains.Marshal()
if err != nil {
return nil, err
}
@@ -86,6 +84,9 @@
var mfst manifestList
mfst.SchemaVersion = 2
mfst.MediaType = images.MediaTypeDockerSchema2ManifestList
+ if ce.oci {
+ mfst.MediaType = ocispec.MediaTypeImageIndex
+ }
for _, l := range config.Layers {
dgstPair, ok := descs[l.Blob]
@@ -93,13 +94,15 @@
return nil, errors.Errorf("missing blob %s", l.Blob)
}
layerDone := oneOffProgress(ctx, fmt.Sprintf("writing layer %s", l.Blob))
- if err := contentutil.Copy(ctx, ingester, dgstPair.Provider, dgstPair.Descriptor); err != nil {
+ if err := contentutil.Copy(ctx, ce.ingester, dgstPair.Provider, dgstPair.Descriptor); err != nil {
return nil, layerDone(errors.Wrap(err, "error writing layer blob"))
}
layerDone(nil)
mfst.Manifests = append(mfst.Manifests, dgstPair.Descriptor)
}
+ mfst.Manifests = compression.ConvertAllLayerMediaTypes(ce.oci, mfst.Manifests...)
+
dt, err := json.Marshal(config)
if err != nil {
return nil, err
@@ -111,7 +114,7 @@
MediaType: v1.CacheConfigMediaTypeV0,
}
configDone := oneOffProgress(ctx, fmt.Sprintf("writing config %s", dgst))
- if err := content.WriteBlob(ctx, ingester, dgst.String(), bytes.NewReader(dt), desc); err != nil {
+ if err := content.WriteBlob(ctx, ce.ingester, dgst.String(), bytes.NewReader(dt), desc); err != nil {
return nil, configDone(errors.Wrap(err, "error writing config blob"))
}
configDone(nil)
@@ -130,7 +133,7 @@
MediaType: mfst.MediaType,
}
mfstDone := oneOffProgress(ctx, fmt.Sprintf("writing manifest %s", dgst))
- if err := content.WriteBlob(ctx, ingester, dgst.String(), bytes.NewReader(dt), desc); err != nil {
+ if err := content.WriteBlob(ctx, ce.ingester, dgst.String(), bytes.NewReader(dt), desc); err != nil {
return nil, mfstDone(errors.Wrap(err, "error writing manifest blob"))
}
descJSON, err := json.Marshal(desc)
diff --git a/vendor/github.com/moby/buildkit/cache/remotecache/local/local.go b/vendor/github.com/moby/buildkit/cache/remotecache/local/local.go
index dabb235..2ee194a 100644
--- a/vendor/github.com/moby/buildkit/cache/remotecache/local/local.go
+++ b/vendor/github.com/moby/buildkit/cache/remotecache/local/local.go
@@ -2,6 +2,7 @@
import (
"context"
+ "strconv"
"time"
"github.com/containerd/containerd/content"
@@ -17,6 +18,7 @@
attrDigest = "digest"
attrSrc = "src"
attrDest = "dest"
+ attrOCIMediatypes = "oci-mediatypes"
contentStoreIDPrefix = "local:"
)
@@ -27,12 +29,20 @@
if store == "" {
return nil, errors.New("local cache exporter requires dest")
}
+ ociMediatypes := true
+ if v, ok := attrs[attrOCIMediatypes]; ok {
+ b, err := strconv.ParseBool(v)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse %s", attrOCIMediatypes)
+ }
+ ociMediatypes = b
+ }
csID := contentStoreIDPrefix + store
cs, err := getContentStore(ctx, sm, g, csID)
if err != nil {
return nil, err
}
- return remotecache.NewExporter(cs), nil
+ return remotecache.NewExporter(cs, ociMediatypes), nil
}
}
@@ -76,7 +86,7 @@
timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
- caller, err := sm.Get(timeoutCtx, sessionID)
+ caller, err := sm.Get(timeoutCtx, sessionID, false)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/cache/remotecache/registry/registry.go b/vendor/github.com/moby/buildkit/cache/remotecache/registry/registry.go
index e81fcb9..281d9fa 100644
--- a/vendor/github.com/moby/buildkit/cache/remotecache/registry/registry.go
+++ b/vendor/github.com/moby/buildkit/cache/remotecache/registry/registry.go
@@ -2,6 +2,7 @@
import (
"context"
+ "strconv"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/remotes/docker"
@@ -28,7 +29,8 @@
}
const (
- attrRef = "ref"
+ attrRef = "ref"
+ attrOCIMediatypes = "oci-mediatypes"
)
func ResolveCacheExporterFunc(sm *session.Manager, hosts docker.RegistryHosts) remotecache.ResolveCacheExporterFunc {
@@ -37,12 +39,20 @@
if err != nil {
return nil, err
}
- remote := resolver.New(hosts, resolver.NewSessionAuthenticator(sm, g))
+ ociMediatypes := true
+ if v, ok := attrs[attrOCIMediatypes]; ok {
+ b, err := strconv.ParseBool(v)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to parse %s", attrOCIMediatypes)
+ }
+ ociMediatypes = b
+ }
+ remote := resolver.DefaultPool.GetResolver(hosts, ref, "push", sm, g)
pusher, err := remote.Pusher(ctx, ref)
if err != nil {
return nil, err
}
- return remotecache.NewExporter(contentutil.FromPusher(pusher)), nil
+ return remotecache.NewExporter(contentutil.FromPusher(pusher), ociMediatypes), nil
}
}
@@ -52,7 +62,7 @@
if err != nil {
return nil, specs.Descriptor{}, err
}
- remote := resolver.New(hosts, resolver.NewSessionAuthenticator(sm, g))
+ remote := resolver.DefaultPool.GetResolver(hosts, ref, "pull", sm, g)
xref, desc, err := remote.Resolve(ctx, ref)
if err != nil {
return nil, specs.Descriptor{}, err
diff --git a/vendor/github.com/moby/buildkit/cache/remotecache/v1/cachestorage.go b/vendor/github.com/moby/buildkit/cache/remotecache/v1/cachestorage.go
index 728b85a..dee02f4 100644
--- a/vendor/github.com/moby/buildkit/cache/remotecache/v1/cachestorage.go
+++ b/vendor/github.com/moby/buildkit/cache/remotecache/v1/cachestorage.go
@@ -5,6 +5,7 @@
"time"
"github.com/moby/buildkit/identity"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver"
"github.com/moby/buildkit/worker"
digest "github.com/opencontainers/go-digest"
@@ -260,7 +261,7 @@
return worker.NewWorkerRefResult(ref, cs.w), nil
}
-func (cs *cacheResultStorage) LoadRemote(ctx context.Context, res solver.CacheResult) (*solver.Remote, error) {
+func (cs *cacheResultStorage) LoadRemote(ctx context.Context, res solver.CacheResult, _ session.Group) (*solver.Remote, error) {
if r := cs.byResultID(res.ID); r != nil && r.result != nil {
return r.result, nil
}
diff --git a/vendor/github.com/moby/buildkit/cache/remotecache/v1/chains.go b/vendor/github.com/moby/buildkit/cache/remotecache/v1/chains.go
index a9b11c3..a76cc69 100644
--- a/vendor/github.com/moby/buildkit/cache/remotecache/v1/chains.go
+++ b/vendor/github.com/moby/buildkit/cache/remotecache/v1/chains.go
@@ -23,7 +23,7 @@
if strings.HasPrefix(dgst.String(), "random:") {
return &nopRecord{}
}
- it := &item{c: c, dgst: dgst}
+ it := &item{c: c, dgst: dgst, backlinks: map[*item]struct{}{}}
c.items = append(c.items, it)
return it
}
@@ -44,6 +44,17 @@
byKey: map[digest.Digest]*item{},
}
+ validated := make([]*item, 0, len(c.items))
+ for _, it := range c.items {
+ it.validate()
+ }
+ for _, it := range c.items {
+ if !it.invalid {
+ validated = append(validated, it)
+ }
+ }
+ c.items = validated
+
for _, it := range c.items {
_, err := normalizeItem(it, st)
if err != nil {
@@ -99,7 +110,9 @@
result *solver.Remote
resultTime time.Time
- links []map[link]struct{}
+ links []map[link]struct{}
+ backlinks map[*item]struct{}
+ invalid bool
}
type link struct {
@@ -126,6 +139,30 @@
}
c.links[index][link{src: src, selector: selector}] = struct{}{}
+ src.backlinks[c] = struct{}{}
+}
+
+func (c *item) validate() {
+ for _, m := range c.links {
+ if len(m) == 0 {
+ c.invalid = true
+ for bl := range c.backlinks {
+ changed := false
+ for _, m := range bl.links {
+ for l := range m {
+ if l.src == c {
+ delete(m, l)
+ changed = true
+ }
+ }
+ }
+ if changed {
+ bl.validate()
+ }
+ }
+ return
+ }
+ }
}
func (c *item) walkAllResults(fn func(i *item) error, visited map[*item]struct{}) error {
diff --git a/vendor/github.com/moby/buildkit/cache/remotecache/v1/utils.go b/vendor/github.com/moby/buildkit/cache/remotecache/v1/utils.go
index dfc7fab..fc494aa 100644
--- a/vendor/github.com/moby/buildkit/cache/remotecache/v1/utils.go
+++ b/vendor/github.com/moby/buildkit/cache/remotecache/v1/utils.go
@@ -4,10 +4,9 @@
"fmt"
"sort"
- "github.com/containerd/containerd/content"
+ "github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/solver"
digest "github.com/opencontainers/go-digest"
- ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
@@ -230,10 +229,6 @@
if len(r.Descriptors) == 0 {
return ""
}
- type Remote struct {
- Descriptors []ocispec.Descriptor
- Provider content.Provider
- }
var parentID string
if len(r.Descriptors) > 1 {
r2 := &solver.Remote{
@@ -244,6 +239,10 @@
}
desc := r.Descriptors[len(r.Descriptors)-1]
+ if desc.Digest == exptypes.EmptyGZLayer {
+ return parentID
+ }
+
state.descriptors[desc.Digest] = DescriptorProviderPair{
Descriptor: desc,
Provider: r.Provider,
diff --git a/vendor/github.com/moby/buildkit/cache/util/fsutil.go b/vendor/github.com/moby/buildkit/cache/util/fsutil.go
index 41e5465..b425a00 100644
--- a/vendor/github.com/moby/buildkit/cache/util/fsutil.go
+++ b/vendor/github.com/moby/buildkit/cache/util/fsutil.go
@@ -8,7 +8,6 @@
"path/filepath"
"github.com/containerd/continuity/fs"
- "github.com/moby/buildkit/cache"
"github.com/moby/buildkit/snapshot"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil"
@@ -25,12 +24,7 @@
Length int
}
-func withMount(ctx context.Context, ref cache.ImmutableRef, cb func(string) error) error {
- mount, err := ref.Mount(ctx, true)
- if err != nil {
- return err
- }
-
+func withMount(ctx context.Context, mount snapshot.Mountable, cb func(string) error) error {
lm := snapshot.LocalMounter(mount)
root, err := lm.Mount()
@@ -55,10 +49,10 @@
return nil
}
-func ReadFile(ctx context.Context, ref cache.ImmutableRef, req ReadRequest) ([]byte, error) {
+func ReadFile(ctx context.Context, mount snapshot.Mountable, req ReadRequest) ([]byte, error) {
var dt []byte
- err := withMount(ctx, ref, func(root string) error {
+ err := withMount(ctx, mount, func(root string) error {
fp, err := fs.RootPath(root, req.Filename)
if err != nil {
return errors.WithStack(err)
@@ -90,7 +84,7 @@
IncludePattern string
}
-func ReadDir(ctx context.Context, ref cache.ImmutableRef, req ReadDirRequest) ([]*fstypes.Stat, error) {
+func ReadDir(ctx context.Context, mount snapshot.Mountable, req ReadDirRequest) ([]*fstypes.Stat, error) {
var (
rd []*fstypes.Stat
wo fsutil.WalkOpt
@@ -98,7 +92,7 @@
if req.IncludePattern != "" {
wo.IncludePatterns = append(wo.IncludePatterns, req.IncludePattern)
}
- err := withMount(ctx, ref, func(root string) error {
+ err := withMount(ctx, mount, func(root string) error {
fp, err := fs.RootPath(root, req.Path)
if err != nil {
return errors.WithStack(err)
@@ -123,9 +117,9 @@
return rd, err
}
-func StatFile(ctx context.Context, ref cache.ImmutableRef, path string) (*fstypes.Stat, error) {
+func StatFile(ctx context.Context, mount snapshot.Mountable, path string) (*fstypes.Stat, error) {
var st *fstypes.Stat
- err := withMount(ctx, ref, func(root string) error {
+ err := withMount(ctx, mount, func(root string) error {
fp, err := fs.RootPath(root, path)
if err != nil {
return errors.WithStack(err)
diff --git a/vendor/github.com/moby/buildkit/client/build.go b/vendor/github.com/moby/buildkit/client/build.go
index 2518cd7..4cb91d7 100644
--- a/vendor/github.com/moby/buildkit/client/build.go
+++ b/vendor/github.com/moby/buildkit/client/build.go
@@ -45,11 +45,14 @@
}
cb := func(ref string, s *session.Session) error {
- g, err := grpcclient.New(ctx, feOpts, s.ID(), product, c.gatewayClientForBuild(ref), gworkers)
+ gwClient := c.gatewayClientForBuild(ref)
+ g, err := grpcclient.New(ctx, feOpts, s.ID(), product, gwClient, gworkers)
if err != nil {
return err
}
+ gwClient.caps = g.BuildOpts().Caps
+
if err := g.Run(ctx, buildFunc); err != nil {
return errors.Wrap(err, "failed to run Build function")
}
@@ -59,14 +62,18 @@
return c.solve(ctx, nil, cb, opt, statusChan)
}
-func (c *Client) gatewayClientForBuild(buildid string) gatewayapi.LLBBridgeClient {
+func (c *Client) gatewayClientForBuild(buildid string) *gatewayClientForBuild {
g := gatewayapi.NewLLBBridgeClient(c.conn)
- return &gatewayClientForBuild{g, buildid}
+ return &gatewayClientForBuild{
+ gateway: g,
+ buildID: buildid,
+ }
}
type gatewayClientForBuild struct {
gateway gatewayapi.LLBBridgeClient
buildID string
+ caps apicaps.CapSet
}
func (g *gatewayClientForBuild) ResolveImageConfig(ctx context.Context, in *gatewayapi.ResolveImageConfigRequest, opts ...grpc.CallOption) (*gatewayapi.ResolveImageConfigResponse, error) {
@@ -85,11 +92,17 @@
}
func (g *gatewayClientForBuild) ReadDir(ctx context.Context, in *gatewayapi.ReadDirRequest, opts ...grpc.CallOption) (*gatewayapi.ReadDirResponse, error) {
+ if err := g.caps.Supports(gatewayapi.CapReadDir); err != nil {
+ return nil, err
+ }
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
return g.gateway.ReadDir(ctx, in, opts...)
}
func (g *gatewayClientForBuild) StatFile(ctx context.Context, in *gatewayapi.StatFileRequest, opts ...grpc.CallOption) (*gatewayapi.StatFileResponse, error) {
+ if err := g.caps.Supports(gatewayapi.CapStatFile); err != nil {
+ return nil, err
+ }
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
return g.gateway.StatFile(ctx, in, opts...)
}
@@ -105,6 +118,33 @@
}
func (g *gatewayClientForBuild) Inputs(ctx context.Context, in *gatewayapi.InputsRequest, opts ...grpc.CallOption) (*gatewayapi.InputsResponse, error) {
+ if err := g.caps.Supports(gatewayapi.CapFrontendInputs); err != nil {
+ return nil, err
+ }
ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
return g.gateway.Inputs(ctx, in, opts...)
}
+
+func (g *gatewayClientForBuild) NewContainer(ctx context.Context, in *gatewayapi.NewContainerRequest, opts ...grpc.CallOption) (*gatewayapi.NewContainerResponse, error) {
+ if err := g.caps.Supports(gatewayapi.CapGatewayExec); err != nil {
+ return nil, err
+ }
+ ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
+ return g.gateway.NewContainer(ctx, in, opts...)
+}
+
+func (g *gatewayClientForBuild) ReleaseContainer(ctx context.Context, in *gatewayapi.ReleaseContainerRequest, opts ...grpc.CallOption) (*gatewayapi.ReleaseContainerResponse, error) {
+ if err := g.caps.Supports(gatewayapi.CapGatewayExec); err != nil {
+ return nil, err
+ }
+ ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
+ return g.gateway.ReleaseContainer(ctx, in, opts...)
+}
+
+func (g *gatewayClientForBuild) ExecProcess(ctx context.Context, opts ...grpc.CallOption) (gatewayapi.LLBBridge_ExecProcessClient, error) {
+ if err := g.caps.Supports(gatewayapi.CapGatewayExec); err != nil {
+ return nil, err
+ }
+ ctx = buildid.AppendToOutgoingContext(ctx, g.buildID)
+ return g.gateway.ExecProcess(ctx, opts...)
+}
diff --git a/vendor/github.com/moby/buildkit/client/client.go b/vendor/github.com/moby/buildkit/client/client.go
index 0546f46..38429ff 100644
--- a/vendor/github.com/moby/buildkit/client/client.go
+++ b/vendor/github.com/moby/buildkit/client/client.go
@@ -6,8 +6,9 @@
"crypto/x509"
"io/ioutil"
"net"
- "time"
+ "net/url"
+ "github.com/containerd/containerd/defaults"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
controlapi "github.com/moby/buildkit/api/services/control"
@@ -30,7 +31,10 @@
// New returns a new buildkit client. Address can be empty for the system-default address.
func New(ctx context.Context, address string, opts ...ClientOpt) (*Client, error) {
- gopts := []grpc.DialOption{}
+ gopts := []grpc.DialOption{
+ grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(defaults.DefaultMaxRecvMsgSize)),
+ grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)),
+ }
needDialer := true
needWithInsecure := true
@@ -54,7 +58,7 @@
stream = append(stream, otgrpc.OpenTracingStreamClientInterceptor(wt.tracer))
}
if wd, ok := o.(*withDialer); ok {
- gopts = append(gopts, grpc.WithDialer(wd.dialer))
+ gopts = append(gopts, grpc.WithContextDialer(wd.dialer))
needDialer = false
}
}
@@ -63,9 +67,7 @@
if err != nil {
return nil, err
}
- // TODO(AkihiroSuda): use WithContextDialer (requires grpc 1.19)
- // https://github.com/grpc/grpc-go/commit/40cb5618f475e7b9d61aa7920ae4b04ef9bbaf89
- gopts = append(gopts, grpc.WithDialer(dialFn))
+ gopts = append(gopts, grpc.WithContextDialer(dialFn))
}
if needWithInsecure {
gopts = append(gopts, grpc.WithInsecure())
@@ -74,6 +76,15 @@
address = appdefaults.Address
}
+ // grpc-go uses a slightly different naming scheme: https://github.com/grpc/grpc/blob/master/doc/naming.md
+ // This will end up setting rfc non-complient :authority header to address string (e.g. tcp://127.0.0.1:1234).
+ // So, here sets right authority header via WithAuthority DialOption.
+ addressURL, err := url.Parse(address)
+ if err != nil {
+ return nil, err
+ }
+ gopts = append(gopts, grpc.WithAuthority(addressURL.Host))
+
unary = append(unary, grpcerrors.UnaryClientInterceptor)
stream = append(stream, grpcerrors.StreamClientInterceptor)
@@ -118,10 +129,10 @@
}
type withDialer struct {
- dialer func(string, time.Duration) (net.Conn, error)
+ dialer func(context.Context, string) (net.Conn, error)
}
-func WithDialer(df func(string, time.Duration) (net.Conn, error)) ClientOpt {
+func WithContextDialer(df func(context.Context, string) (net.Conn, error)) ClientOpt {
return &withDialer{dialer: df}
}
@@ -179,17 +190,13 @@
tracer opentracing.Tracer
}
-func resolveDialer(address string) (func(string, time.Duration) (net.Conn, error), error) {
+func resolveDialer(address string) (func(context.Context, string) (net.Conn, error), error) {
ch, err := connhelper.GetConnectionHelper(address)
if err != nil {
return nil, err
}
if ch != nil {
- f := func(a string, _ time.Duration) (net.Conn, error) {
- ctx := context.Background()
- return ch.ContextDialer(ctx, a)
- }
- return f, nil
+ return ch.ContextDialer, nil
}
// basic dialer
return dialer, nil
diff --git a/vendor/github.com/moby/buildkit/client/client_unix.go b/vendor/github.com/moby/buildkit/client/client_unix.go
index 93afb95..888a817 100644
--- a/vendor/github.com/moby/buildkit/client/client_unix.go
+++ b/vendor/github.com/moby/buildkit/client/client_unix.go
@@ -3,17 +3,18 @@
package client
import (
+ "context"
"net"
"strings"
- "time"
"github.com/pkg/errors"
)
-func dialer(address string, timeout time.Duration) (net.Conn, error) {
+func dialer(ctx context.Context, address string) (net.Conn, error) {
addrParts := strings.SplitN(address, "://", 2)
if len(addrParts) != 2 {
return nil, errors.Errorf("invalid address %s", address)
}
- return net.DialTimeout(addrParts[0], addrParts[1], timeout)
+ var d net.Dialer
+ return d.DialContext(ctx, addrParts[0], addrParts[1])
}
diff --git a/vendor/github.com/moby/buildkit/client/client_windows.go b/vendor/github.com/moby/buildkit/client/client_windows.go
index d0d8a1b..a9eb87f 100644
--- a/vendor/github.com/moby/buildkit/client/client_windows.go
+++ b/vendor/github.com/moby/buildkit/client/client_windows.go
@@ -1,15 +1,15 @@
package client
import (
+ "context"
"net"
"strings"
- "time"
winio "github.com/Microsoft/go-winio"
"github.com/pkg/errors"
)
-func dialer(address string, timeout time.Duration) (net.Conn, error) {
+func dialer(ctx context.Context, address string) (net.Conn, error) {
addrParts := strings.SplitN(address, "://", 2)
if len(addrParts) != 2 {
return nil, errors.Errorf("invalid address %s", address)
@@ -17,8 +17,9 @@
switch addrParts[0] {
case "npipe":
address = strings.Replace(addrParts[1], "/", "\\", -1)
- return winio.DialPipe(address, &timeout)
+ return winio.DialPipeContext(ctx, address)
default:
- return net.DialTimeout(addrParts[0], addrParts[1], timeout)
+ var d net.Dialer
+ return d.DialContext(ctx, addrParts[0], addrParts[1])
}
}
diff --git a/vendor/github.com/moby/buildkit/client/llb/definition.go b/vendor/github.com/moby/buildkit/client/llb/definition.go
index fe9f7c1..99af7c6 100644
--- a/vendor/github.com/moby/buildkit/client/llb/definition.go
+++ b/vendor/github.com/moby/buildkit/client/llb/definition.go
@@ -16,14 +16,15 @@
// LLB state can be reconstructed from the definition.
type DefinitionOp struct {
MarshalCache
- mu sync.Mutex
- ops map[digest.Digest]*pb.Op
- defs map[digest.Digest][]byte
- metas map[digest.Digest]pb.OpMetadata
- sources map[digest.Digest][]*SourceLocation
- platforms map[digest.Digest]*specs.Platform
- dgst digest.Digest
- index pb.OutputIndex
+ mu sync.Mutex
+ ops map[digest.Digest]*pb.Op
+ defs map[digest.Digest][]byte
+ metas map[digest.Digest]pb.OpMetadata
+ sources map[digest.Digest][]*SourceLocation
+ platforms map[digest.Digest]*specs.Platform
+ dgst digest.Digest
+ index pb.OutputIndex
+ inputCache map[digest.Digest][]*DefinitionOp
}
// NewDefinitionOp returns a new operation from a marshalled definition.
@@ -89,13 +90,14 @@
}
return &DefinitionOp{
- ops: ops,
- defs: defs,
- metas: def.Metadata,
- sources: srcs,
- platforms: platforms,
- dgst: dgst,
- index: index,
+ ops: ops,
+ defs: defs,
+ metas: def.Metadata,
+ sources: srcs,
+ platforms: platforms,
+ dgst: dgst,
+ index: index,
+ inputCache: make(map[digest.Digest][]*DefinitionOp),
}, nil
}
@@ -188,14 +190,34 @@
d.mu.Unlock()
for _, input := range op.Inputs {
- vtx := &DefinitionOp{
- ops: d.ops,
- defs: d.defs,
- metas: d.metas,
- platforms: d.platforms,
- dgst: input.Digest,
- index: input.Index,
+ var vtx *DefinitionOp
+ d.mu.Lock()
+ if existingIndexes, ok := d.inputCache[input.Digest]; ok {
+ if int(input.Index) < len(existingIndexes) && existingIndexes[input.Index] != nil {
+ vtx = existingIndexes[input.Index]
+ }
}
+ if vtx == nil {
+ vtx = &DefinitionOp{
+ ops: d.ops,
+ defs: d.defs,
+ metas: d.metas,
+ platforms: d.platforms,
+ dgst: input.Digest,
+ index: input.Index,
+ inputCache: d.inputCache,
+ }
+ existingIndexes := d.inputCache[input.Digest]
+ indexDiff := int(input.Index) - len(existingIndexes)
+ if indexDiff >= 0 {
+ // make room in the slice for the new index being set
+ existingIndexes = append(existingIndexes, make([]*DefinitionOp, indexDiff+1)...)
+ }
+ existingIndexes[input.Index] = vtx
+ d.inputCache[input.Digest] = existingIndexes
+ }
+ d.mu.Unlock()
+
inputs = append(inputs, &output{vertex: vtx, platform: platform, getIndex: func() (pb.OutputIndex, error) {
return pb.OutputIndex(vtx.index), nil
}})
diff --git a/vendor/github.com/moby/buildkit/client/llb/exec.go b/vendor/github.com/moby/buildkit/client/llb/exec.go
index 9d27bbc..decc0d7 100644
--- a/vendor/github.com/moby/buildkit/client/llb/exec.go
+++ b/vendor/github.com/moby/buildkit/client/llb/exec.go
@@ -2,7 +2,7 @@
import (
"context"
- _ "crypto/sha256"
+ _ "crypto/sha256" // for opencontainers/go-digest
"fmt"
"net"
"sort"
@@ -153,7 +153,13 @@
}
if c.Caps != nil {
if err := c.Caps.Supports(pb.CapExecMetaSetsDefaultPath); err != nil {
- env = env.SetDefault("PATH", system.DefaultPathEnv)
+ os := "linux"
+ if c.Platform != nil {
+ os = c.Platform.OS
+ } else if e.constraints.Platform != nil {
+ os = e.constraints.Platform.OS
+ }
+ env = env.SetDefault("PATH", system.DefaultPathEnv(os))
} else {
addCap(&e.constraints, pb.CapExecMetaSetsDefaultPath)
}
@@ -174,11 +180,17 @@
return "", nil, nil, nil, err
}
+ hostname, err := getHostname(e.base)(ctx)
+ if err != nil {
+ return "", nil, nil, nil, err
+ }
+
meta := &pb.Meta{
- Args: args,
- Env: env.ToArray(),
- Cwd: cwd,
- User: user,
+ Args: args,
+ Env: env.ToArray(),
+ Cwd: cwd,
+ User: user,
+ Hostname: hostname,
}
extraHosts, err := getExtraHosts(e.base)(ctx)
if err != nil {
@@ -217,9 +229,9 @@
if p := e.proxyEnv; p != nil {
peo.Meta.ProxyEnv = &pb.ProxyEnv{
- HttpProxy: p.HttpProxy,
- HttpsProxy: p.HttpsProxy,
- FtpProxy: p.FtpProxy,
+ HttpProxy: p.HTTPProxy,
+ HttpsProxy: p.HTTPSProxy,
+ FtpProxy: p.FTPProxy,
NoProxy: p.NoProxy,
}
addCap(&e.constraints, pb.CapExecMetaProxy)
@@ -629,9 +641,9 @@
}
type ProxyEnv struct {
- HttpProxy string
- HttpsProxy string
- FtpProxy string
+ HTTPProxy string
+ HTTPSProxy string
+ FTPProxy string
NoProxy string
}
diff --git a/vendor/github.com/moby/buildkit/client/llb/fileop.go b/vendor/github.com/moby/buildkit/client/llb/fileop.go
index db5ed00..fdcf992 100644
--- a/vendor/github.com/moby/buildkit/client/llb/fileop.go
+++ b/vendor/github.com/moby/buildkit/client/llb/fileop.go
@@ -2,7 +2,7 @@
import (
"context"
- _ "crypto/sha256"
+ _ "crypto/sha256" // for opencontainers/go-digest
"os"
"path"
"strconv"
@@ -252,13 +252,13 @@
mi.ChownOpt = &co
}
-func (cp *ChownOpt) marshal(base pb.InputIndex) *pb.ChownOpt {
- if cp == nil {
+func (co *ChownOpt) marshal(base pb.InputIndex) *pb.ChownOpt {
+ if co == nil {
return nil
}
return &pb.ChownOpt{
- User: cp.User.marshal(base),
- Group: cp.Group.marshal(base),
+ User: co.User.marshal(base),
+ Group: co.Group.marshal(base),
}
}
@@ -476,17 +476,17 @@
}, nil
}
-func (c *fileActionCopy) sourcePath(ctx context.Context) (string, error) {
- p := path.Clean(c.src)
+func (a *fileActionCopy) sourcePath(ctx context.Context) (string, error) {
+ p := path.Clean(a.src)
if !path.IsAbs(p) {
- if c.state != nil {
- dir, err := c.state.GetDir(ctx)
+ if a.state != nil {
+ dir, err := a.state.GetDir(ctx)
if err != nil {
return "", err
}
p = path.Join("/", dir, p)
- } else if c.fas != nil {
- dir, err := c.fas.state.GetDir(ctx)
+ } else if a.fas != nil {
+ dir, err := a.fas.state.GetDir(ctx)
if err != nil {
return "", err
}
diff --git a/vendor/github.com/moby/buildkit/client/llb/imagemetaresolver/resolver.go b/vendor/github.com/moby/buildkit/client/llb/imagemetaresolver/resolver.go
index 0dbd473..97a0cba 100644
--- a/vendor/github.com/moby/buildkit/client/llb/imagemetaresolver/resolver.go
+++ b/vendor/github.com/moby/buildkit/client/llb/imagemetaresolver/resolver.go
@@ -8,10 +8,10 @@
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
- "github.com/docker/docker/pkg/locker"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/util/contentutil"
"github.com/moby/buildkit/util/imageutil"
+ "github.com/moby/locker"
digest "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
)
diff --git a/vendor/github.com/moby/buildkit/client/llb/meta.go b/vendor/github.com/moby/buildkit/client/llb/meta.go
index ab0f593..80cc18d 100644
--- a/vendor/github.com/moby/buildkit/client/llb/meta.go
+++ b/vendor/github.com/moby/buildkit/client/llb/meta.go
@@ -19,6 +19,7 @@
keyDir = contextKeyT("llb.exec.dir")
keyEnv = contextKeyT("llb.exec.env")
keyUser = contextKeyT("llb.exec.user")
+ keyHostname = contextKeyT("llb.exec.hostname")
keyExtraHost = contextKeyT("llb.exec.extrahost")
keyPlatform = contextKeyT("llb.platform")
keyNetwork = contextKeyT("llb.network")
@@ -143,6 +144,25 @@
}
}
+func Hostname(str string) StateOption {
+ return func(s State) State {
+ return s.WithValue(keyHostname, str)
+ }
+}
+
+func getHostname(s State) func(context.Context) (string, error) {
+ return func(ctx context.Context) (string, error) {
+ v, err := s.getValue(keyHostname)(ctx)
+ if err != nil {
+ return "", err
+ }
+ if v != nil {
+ return v.(string), nil
+ }
+ return "", nil
+ }
+}
+
func args(args ...string) StateOption {
return func(s State) State {
return s.WithValue(keyArgs, args)
@@ -155,7 +175,7 @@
}
return func(s State) State {
arg, err := shlex.Split(str)
- if err != nil {
+ if err != nil { //nolint
// TODO: handle error
}
return args(arg...)(s)
diff --git a/vendor/github.com/moby/buildkit/client/llb/source.go b/vendor/github.com/moby/buildkit/client/llb/source.go
index 51fdcf9..7cb9b4e 100644
--- a/vendor/github.com/moby/buildkit/client/llb/source.go
+++ b/vendor/github.com/moby/buildkit/client/llb/source.go
@@ -2,7 +2,7 @@
import (
"context"
- _ "crypto/sha256"
+ _ "crypto/sha256" // for opencontainers/go-digest
"encoding/json"
"os"
"strconv"
@@ -233,11 +233,15 @@
}
if gi.AuthTokenSecret != "" {
attrs[pb.AttrAuthTokenSecret] = gi.AuthTokenSecret
- addCap(&gi.Constraints, pb.CapSourceGitHttpAuth)
+ if gi.addAuthCap {
+ addCap(&gi.Constraints, pb.CapSourceGitHTTPAuth)
+ }
}
if gi.AuthHeaderSecret != "" {
attrs[pb.AttrAuthHeaderSecret] = gi.AuthHeaderSecret
- addCap(&gi.Constraints, pb.CapSourceGitHttpAuth)
+ if gi.addAuthCap {
+ addCap(&gi.Constraints, pb.CapSourceGitHTTPAuth)
+ }
}
addCap(&gi.Constraints, pb.CapSourceGit)
@@ -260,6 +264,7 @@
KeepGitDir bool
AuthTokenSecret string
AuthHeaderSecret string
+ addAuthCap bool
}
func KeepGitDir() GitOption {
@@ -271,12 +276,14 @@
func AuthTokenSecret(v string) GitOption {
return gitOptionFunc(func(gi *GitInfo) {
gi.AuthTokenSecret = v
+ gi.addAuthCap = true
})
}
func AuthHeaderSecret(v string) GitOption {
return gitOptionFunc(func(gi *GitInfo) {
gi.AuthHeaderSecret = v
+ gi.addAuthCap = true
})
}
diff --git a/vendor/github.com/moby/buildkit/client/llb/state.go b/vendor/github.com/moby/buildkit/client/llb/state.go
index dac9b87..eca7164 100644
--- a/vendor/github.com/moby/buildkit/client/llb/state.go
+++ b/vendor/github.com/moby/buildkit/client/llb/state.go
@@ -320,6 +320,14 @@
return User(v)(s)
}
+func (s State) Hostname(v string) State {
+ return Hostname(v)(s)
+}
+
+func (s State) GetHostname(ctx context.Context) (string, error) {
+ return getHostname(s)(ctx)
+}
+
func (s State) Platform(p specs.Platform) State {
return platform(p)(s)
}
diff --git a/vendor/github.com/moby/buildkit/client/ociindex/ociindex.go b/vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
index 13f1d50..7bc5834 100644
--- a/vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
+++ b/vendor/github.com/moby/buildkit/client/ociindex/ociindex.go
@@ -6,7 +6,7 @@
"os"
"github.com/gofrs/flock"
- "github.com/opencontainers/image-spec/specs-go/v1"
+ v1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
diff --git a/vendor/github.com/moby/buildkit/cmd/buildkitd/config/config.go b/vendor/github.com/moby/buildkit/cmd/buildkitd/config/config.go
index fc2da18..fe3e7ff 100644
--- a/vendor/github.com/moby/buildkit/cmd/buildkitd/config/config.go
+++ b/vendor/github.com/moby/buildkit/cmd/buildkitd/config/config.go
@@ -1,5 +1,7 @@
package config
+import "github.com/BurntSushi/toml"
+
// Config provides containerd configuration data for the server
type Config struct {
Debug bool `toml:"debug"`
@@ -78,7 +80,13 @@
// incomplete and the intention is to make it default without config.
UserRemapUnsupported string `toml:"userRemapUnsupported"`
// For use in storing the OCI worker binary name that will replace buildkit-runc
- Binary string `toml:"binary"`
+ Binary string `toml:"binary"`
+ ProxySnapshotterPath string `toml:"proxySnapshotterPath"`
+
+ // StargzSnapshotterConfig is configuration for stargz snapshotter.
+ // Decoding this is delayed in order to remove the dependency from this
+ // config pkg to stargz snapshotter's config pkg.
+ StargzSnapshotterConfig toml.Primitive `toml:"stargzSnapshotter"`
}
type ContainerdConfig struct {
@@ -89,6 +97,7 @@
Namespace string `toml:"namespace"`
GCConfig
NetworkConfig
+ Snapshotter string `toml:"snapshotter"`
}
type GCPolicy struct {
diff --git a/vendor/github.com/moby/buildkit/control/control.go b/vendor/github.com/moby/buildkit/control/control.go
index 0ee110e..048e696 100644
--- a/vendor/github.com/moby/buildkit/control/control.go
+++ b/vendor/github.com/moby/buildkit/control/control.go
@@ -63,7 +63,7 @@
cache: cache,
gatewayForwarder: gatewayForwarder,
}
- c.throttledGC = throttle.ThrottleAfter(time.Minute, c.gc)
+ c.throttledGC = throttle.After(time.Minute, c.gc)
defer func() {
time.AfterFunc(time.Second, c.throttledGC)
@@ -305,40 +305,56 @@
if !ok {
return nil
}
- sr := controlapi.StatusResponse{}
- for _, v := range ss.Vertexes {
- sr.Vertexes = append(sr.Vertexes, &controlapi.Vertex{
- Digest: v.Digest,
- Inputs: v.Inputs,
- Name: v.Name,
- Started: v.Started,
- Completed: v.Completed,
- Error: v.Error,
- Cached: v.Cached,
- })
- }
- for _, v := range ss.Statuses {
- sr.Statuses = append(sr.Statuses, &controlapi.VertexStatus{
- ID: v.ID,
- Vertex: v.Vertex,
- Name: v.Name,
- Current: v.Current,
- Total: v.Total,
- Timestamp: v.Timestamp,
- Started: v.Started,
- Completed: v.Completed,
- })
- }
- for _, v := range ss.Logs {
- sr.Logs = append(sr.Logs, &controlapi.VertexLog{
- Vertex: v.Vertex,
- Stream: int64(v.Stream),
- Msg: v.Data,
- Timestamp: v.Timestamp,
- })
- }
- if err := stream.SendMsg(&sr); err != nil {
- return err
+ logSize := 0
+ retry := false
+ for {
+ sr := controlapi.StatusResponse{}
+ for _, v := range ss.Vertexes {
+ sr.Vertexes = append(sr.Vertexes, &controlapi.Vertex{
+ Digest: v.Digest,
+ Inputs: v.Inputs,
+ Name: v.Name,
+ Started: v.Started,
+ Completed: v.Completed,
+ Error: v.Error,
+ Cached: v.Cached,
+ })
+ }
+ for _, v := range ss.Statuses {
+ sr.Statuses = append(sr.Statuses, &controlapi.VertexStatus{
+ ID: v.ID,
+ Vertex: v.Vertex,
+ Name: v.Name,
+ Current: v.Current,
+ Total: v.Total,
+ Timestamp: v.Timestamp,
+ Started: v.Started,
+ Completed: v.Completed,
+ })
+ }
+ for i, v := range ss.Logs {
+ sr.Logs = append(sr.Logs, &controlapi.VertexLog{
+ Vertex: v.Vertex,
+ Stream: int64(v.Stream),
+ Msg: v.Data,
+ Timestamp: v.Timestamp,
+ })
+ logSize += len(v.Data)
+ // avoid logs growing big and split apart if they do
+ if logSize > 1024*1024 {
+ ss.Vertexes = nil
+ ss.Statuses = nil
+ ss.Logs = ss.Logs[i+1:]
+ retry = true
+ break
+ }
+ }
+ if err := stream.SendMsg(&sr); err != nil {
+ return err
+ }
+ if !retry {
+ break
+ }
}
}
})
diff --git a/vendor/github.com/moby/buildkit/control/gateway/gateway.go b/vendor/github.com/moby/buildkit/control/gateway/gateway.go
index 2d4e8b3..9b91a08 100644
--- a/vendor/github.com/moby/buildkit/control/gateway/gateway.go
+++ b/vendor/github.com/moby/buildkit/control/gateway/gateway.go
@@ -152,3 +152,27 @@
}
return fwd.StatFile(ctx, req)
}
+
+func (gwf *GatewayForwarder) NewContainer(ctx context.Context, req *gwapi.NewContainerRequest) (*gwapi.NewContainerResponse, error) {
+ fwd, err := gwf.lookupForwarder(ctx)
+ if err != nil {
+ return nil, errors.Wrap(err, "forwarding NewContainer")
+ }
+ return fwd.NewContainer(ctx, req)
+}
+
+func (gwf *GatewayForwarder) ReleaseContainer(ctx context.Context, req *gwapi.ReleaseContainerRequest) (*gwapi.ReleaseContainerResponse, error) {
+ fwd, err := gwf.lookupForwarder(ctx)
+ if err != nil {
+ return nil, errors.Wrap(err, "forwarding ReleaseContainer")
+ }
+ return fwd.ReleaseContainer(ctx, req)
+}
+
+func (gwf *GatewayForwarder) ExecProcess(srv gwapi.LLBBridge_ExecProcessServer) error {
+ fwd, err := gwf.lookupForwarder(srv.Context())
+ if err != nil {
+ return errors.Wrap(err, "forwarding ExecProcess")
+ }
+ return fwd.ExecProcess(srv)
+}
diff --git a/vendor/github.com/moby/buildkit/executor/executor.go b/vendor/github.com/moby/buildkit/executor/executor.go
index 5ab4252..8fbe4a9 100644
--- a/vendor/github.com/moby/buildkit/executor/executor.go
+++ b/vendor/github.com/moby/buildkit/executor/executor.go
@@ -5,7 +5,7 @@
"io"
"net"
- "github.com/moby/buildkit/cache"
+ "github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/solver/pb"
)
@@ -14,6 +14,7 @@
Env []string
User string
Cwd string
+ Hostname string
Tty bool
ReadonlyRootFS bool
ExtraHosts []HostIP
@@ -21,24 +22,34 @@
SecurityMode pb.SecurityMode
}
+type Mountable interface {
+ Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error)
+}
+
type Mount struct {
- Src cache.Mountable
+ Src Mountable
Selector string
Dest string
Readonly bool
}
+type WinSize struct {
+ Rows uint32
+ Cols uint32
+}
+
type ProcessInfo struct {
Meta Meta
Stdin io.ReadCloser
Stdout, Stderr io.WriteCloser
+ Resize <-chan WinSize
}
type Executor interface {
// Run will start a container for the given process with rootfs, mounts.
// `id` is an optional name for the container so it can be referenced later via Exec.
// `started` is an optional channel that will be closed when the container setup completes and has started running.
- Run(ctx context.Context, id string, rootfs cache.Mountable, mounts []Mount, process ProcessInfo, started chan<- struct{}) error
+ Run(ctx context.Context, id string, rootfs Mount, mounts []Mount, process ProcessInfo, started chan<- struct{}) error
// Exec will start a process in container matching `id`. An error will be returned
// if the container failed to start (via Run) or has exited before Exec is called.
Exec(ctx context.Context, id string, process ProcessInfo) error
diff --git a/vendor/github.com/moby/buildkit/executor/oci/hosts.go b/vendor/github.com/moby/buildkit/executor/oci/hosts.go
index 552b585..d0505c2 100644
--- a/vendor/github.com/moby/buildkit/executor/oci/hosts.go
+++ b/vendor/github.com/moby/buildkit/executor/oci/hosts.go
@@ -14,28 +14,26 @@
"github.com/pkg/errors"
)
-const hostsContent = `
-127.0.0.1 localhost buildkitsandbox
-::1 localhost ip6-localhost ip6-loopback
-`
+const defaultHostname = "buildkitsandbox"
-func GetHostsFile(ctx context.Context, stateDir string, extraHosts []executor.HostIP, idmap *idtools.IdentityMapping) (string, func(), error) {
- if len(extraHosts) == 0 {
- _, err := g.Do(ctx, stateDir, func(ctx context.Context) (interface{}, error) {
- _, _, err := makeHostsFile(stateDir, nil, idmap)
- return nil, err
- })
- if err != nil {
- return "", nil, err
- }
- return filepath.Join(stateDir, "hosts"), func() {}, nil
+func GetHostsFile(ctx context.Context, stateDir string, extraHosts []executor.HostIP, idmap *idtools.IdentityMapping, hostname string) (string, func(), error) {
+ if len(extraHosts) != 0 || hostname != defaultHostname {
+ return makeHostsFile(stateDir, extraHosts, idmap, hostname)
}
- return makeHostsFile(stateDir, extraHosts, idmap)
+
+ _, err := g.Do(ctx, stateDir, func(ctx context.Context) (interface{}, error) {
+ _, _, err := makeHostsFile(stateDir, nil, idmap, hostname)
+ return nil, err
+ })
+ if err != nil {
+ return "", nil, err
+ }
+ return filepath.Join(stateDir, "hosts"), func() {}, nil
}
-func makeHostsFile(stateDir string, extraHosts []executor.HostIP, idmap *idtools.IdentityMapping) (string, func(), error) {
+func makeHostsFile(stateDir string, extraHosts []executor.HostIP, idmap *idtools.IdentityMapping, hostname string) (string, func(), error) {
p := filepath.Join(stateDir, "hosts")
- if len(extraHosts) != 0 {
+ if len(extraHosts) != 0 || hostname != defaultHostname {
p += "." + identity.NewID()
}
_, err := os.Stat(p)
@@ -47,8 +45,7 @@
}
b := &bytes.Buffer{}
-
- if _, err := b.Write([]byte(hostsContent)); err != nil {
+ if _, err := b.Write([]byte(initHostsFile(hostname))); err != nil {
return "", nil, err
}
@@ -77,3 +74,14 @@
os.RemoveAll(p)
}, nil
}
+
+func initHostsFile(hostname string) string {
+ var hosts string
+ if hostname != "" {
+ hosts = fmt.Sprintf("127.0.0.1 localhost %s", hostname)
+ } else {
+ hosts = fmt.Sprintf("127.0.0.1 localhost %s", defaultHostname)
+ }
+ hosts = fmt.Sprintf("%s\n::1 localhost ip6-localhost ip6-loopback\n", hosts)
+ return hosts
+}
diff --git a/vendor/github.com/moby/buildkit/executor/oci/mounts.go b/vendor/github.com/moby/buildkit/executor/oci/mounts.go
index 62dbd38..62360f4 100644
--- a/vendor/github.com/moby/buildkit/executor/oci/mounts.go
+++ b/vendor/github.com/moby/buildkit/executor/oci/mounts.go
@@ -5,82 +5,57 @@
"path/filepath"
"strings"
+ "github.com/containerd/containerd/containers"
+ "github.com/containerd/containerd/oci"
specs "github.com/opencontainers/runtime-spec/specs-go"
- "github.com/pkg/errors"
)
-// MountOpts sets oci spec specific info for mount points
-type MountOpts func([]specs.Mount) ([]specs.Mount, error)
-
-//GetMounts returns default required for buildkit
-// https://github.com/moby/buildkit/issues/429
-func GetMounts(ctx context.Context, mountOpts ...MountOpts) ([]specs.Mount, error) {
- mounts := []specs.Mount{
- {
- Destination: "/proc",
- Type: "proc",
- Source: "proc",
- },
- {
- Destination: "/dev",
- Type: "tmpfs",
- Source: "tmpfs",
- Options: []string{"nosuid", "strictatime", "mode=755", "size=65536k"},
- },
- {
- Destination: "/dev/pts",
- Type: "devpts",
- Source: "devpts",
- Options: []string{"nosuid", "noexec", "newinstance", "ptmxmode=0666", "mode=0620", "gid=5"},
- },
- {
- Destination: "/dev/shm",
- Type: "tmpfs",
- Source: "shm",
- Options: []string{"nosuid", "noexec", "nodev", "mode=1777", "size=65536k"},
- },
- {
- Destination: "/dev/mqueue",
- Type: "mqueue",
- Source: "mqueue",
- Options: []string{"nosuid", "noexec", "nodev"},
- },
- {
- Destination: "/sys",
- Type: "sysfs",
- Source: "sysfs",
- Options: []string{"nosuid", "noexec", "nodev", "ro"},
- },
- }
- var err error
- for _, o := range mountOpts {
- mounts, err = o(mounts)
- if err != nil {
- return nil, err
+func withRemovedMount(destination string) oci.SpecOpts {
+ return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
+ newMounts := []specs.Mount{}
+ for _, o := range s.Mounts {
+ if o.Destination != destination {
+ newMounts = append(newMounts, o)
+ }
}
+ s.Mounts = newMounts
+
+ return nil
}
- return mounts, nil
}
-func withROBind(src, dest string) func(m []specs.Mount) ([]specs.Mount, error) {
- return func(m []specs.Mount) ([]specs.Mount, error) {
- m = append(m, specs.Mount{
+func withROBind(src, dest string) oci.SpecOpts {
+ return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
+ s.Mounts = append(s.Mounts, specs.Mount{
Destination: dest,
Type: "bind",
Source: src,
Options: []string{"nosuid", "noexec", "nodev", "rbind", "ro"},
})
- return m, nil
+ return nil
}
}
+func withCGroup() oci.SpecOpts {
+ return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
+ s.Mounts = append(s.Mounts, specs.Mount{
+ Destination: "/sys/fs/cgroup",
+ Type: "cgroup",
+ Source: "cgroup",
+ Options: []string{"ro", "nosuid", "noexec", "nodev"},
+ })
+ return nil
+ }
+
+}
+
func hasPrefix(p, prefixDir string) bool {
prefixDir = filepath.Clean(prefixDir)
- if prefixDir == "/" {
+ if filepath.Base(prefixDir) == string(filepath.Separator) {
return true
}
p = filepath.Clean(p)
- return p == prefixDir || strings.HasPrefix(p, prefixDir+"/")
+ return p == prefixDir || strings.HasPrefix(p, prefixDir+string(filepath.Separator))
}
func removeMountsWithPrefix(mounts []specs.Mount, prefixDir string) []specs.Mount {
@@ -93,25 +68,35 @@
return ret
}
-func withProcessMode(processMode ProcessMode) func([]specs.Mount) ([]specs.Mount, error) {
- return func(m []specs.Mount) ([]specs.Mount, error) {
- switch processMode {
- case ProcessSandbox:
- // keep the default
- case NoProcessSandbox:
- m = removeMountsWithPrefix(m, "/proc")
- procMount := specs.Mount{
- Destination: "/proc",
- Type: "bind",
- Source: "/proc",
- // NOTE: "rbind"+"ro" does not make /proc read-only recursively.
- // So we keep maskedPath and readonlyPaths (although not mandatory for rootless mode)
- Options: []string{"rbind"},
- }
- m = append([]specs.Mount{procMount}, m...)
- default:
- return nil, errors.Errorf("unknown process mode: %v", processMode)
+func withBoundProc() oci.SpecOpts {
+ return func(_ context.Context, _ oci.Client, _ *containers.Container, s *specs.Spec) error {
+ s.Mounts = removeMountsWithPrefix(s.Mounts, "/proc")
+ procMount := specs.Mount{
+ Destination: "/proc",
+ Type: "bind",
+ Source: "/proc",
+ // NOTE: "rbind"+"ro" does not make /proc read-only recursively.
+ // So we keep maskedPath and readonlyPaths (although not mandatory for rootless mode)
+ Options: []string{"rbind"},
}
- return m, nil
+ s.Mounts = append([]specs.Mount{procMount}, s.Mounts...)
+
+ var maskedPaths []string
+ for _, s := range s.Linux.MaskedPaths {
+ if !hasPrefix(s, "/proc") {
+ maskedPaths = append(maskedPaths, s)
+ }
+ }
+ s.Linux.MaskedPaths = maskedPaths
+
+ var readonlyPaths []string
+ for _, s := range s.Linux.ReadonlyPaths {
+ if !hasPrefix(s, "/proc") {
+ readonlyPaths = append(readonlyPaths, s)
+ }
+ }
+ s.Linux.ReadonlyPaths = readonlyPaths
+
+ return nil
}
}
diff --git a/vendor/github.com/moby/buildkit/executor/oci/spec.go b/vendor/github.com/moby/buildkit/executor/oci/spec.go
index 9329fa9..44ad95e 100644
--- a/vendor/github.com/moby/buildkit/executor/oci/spec.go
+++ b/vendor/github.com/moby/buildkit/executor/oci/spec.go
@@ -1,6 +1,25 @@
package oci
-// ProcMode configures PID namespaces
+import (
+ "context"
+ "path"
+ "sync"
+
+ "github.com/containerd/containerd/containers"
+ "github.com/containerd/containerd/mount"
+ "github.com/containerd/containerd/namespaces"
+ "github.com/containerd/containerd/oci"
+ "github.com/containerd/continuity/fs"
+ "github.com/docker/docker/pkg/idtools"
+ "github.com/mitchellh/hashstructure"
+ "github.com/moby/buildkit/executor"
+ "github.com/moby/buildkit/snapshot"
+ "github.com/moby/buildkit/util/network"
+ specs "github.com/opencontainers/runtime-spec/specs-go"
+ "github.com/pkg/errors"
+)
+
+// ProcessMode configures PID namespaces
type ProcessMode int
const (
@@ -11,3 +30,203 @@
// NoProcessSandbox should be enabled only when the BuildKit is running in a container as an unprivileged user.
NoProcessSandbox
)
+
+// Ideally we don't have to import whole containerd just for the default spec
+
+// GenerateSpec generates spec using containerd functionality.
+// opts are ignored for s.Process, s.Hostname, and s.Mounts .
+func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mount, id, resolvConf, hostsFile string, namespace network.Namespace, processMode ProcessMode, idmap *idtools.IdentityMapping, opts ...oci.SpecOpts) (*specs.Spec, func(), error) {
+ c := &containers.Container{
+ ID: id,
+ }
+
+ // containerd/oci.GenerateSpec requires a namespace, which
+ // will be used to namespace specs.Linux.CgroupsPath if generated
+ if _, ok := namespaces.Namespace(ctx); !ok {
+ ctx = namespaces.WithNamespace(ctx, "buildkit")
+ }
+
+ if mountOpts, err := generateMountOpts(resolvConf, hostsFile); err == nil {
+ opts = append(opts, mountOpts...)
+ } else {
+ return nil, nil, err
+ }
+
+ if securityOpts, err := generateSecurityOpts(meta.SecurityMode); err == nil {
+ opts = append(opts, securityOpts...)
+ } else {
+ return nil, nil, err
+ }
+
+ if processModeOpts, err := generateProcessModeOpts(processMode); err == nil {
+ opts = append(opts, processModeOpts...)
+ } else {
+ return nil, nil, err
+ }
+
+ if idmapOpts, err := generateIDmapOpts(idmap); err == nil {
+ opts = append(opts, idmapOpts...)
+ } else {
+ return nil, nil, err
+ }
+
+ hostname := defaultHostname
+ if meta.Hostname != "" {
+ hostname = meta.Hostname
+ }
+
+ opts = append(opts,
+ oci.WithProcessArgs(meta.Args...),
+ oci.WithEnv(meta.Env),
+ oci.WithProcessCwd(meta.Cwd),
+ oci.WithNewPrivileges,
+ oci.WithHostname(hostname),
+ )
+
+ s, err := oci.GenerateSpec(ctx, nil, c, opts...)
+ if err != nil {
+ return nil, nil, err
+ }
+
+ // set the networking information on the spec
+ if err := namespace.Set(s); err != nil {
+ return nil, nil, err
+ }
+
+ s.Process.Rlimits = nil // reset open files limit
+
+ sm := &submounts{}
+
+ var releasers []func() error
+ releaseAll := func() {
+ sm.cleanup()
+ for _, f := range releasers {
+ f()
+ }
+ }
+
+ for _, m := range mounts {
+ if m.Src == nil {
+ return nil, nil, errors.Errorf("mount %s has no source", m.Dest)
+ }
+ mountable, err := m.Src.Mount(ctx, m.Readonly)
+ if err != nil {
+ releaseAll()
+ return nil, nil, errors.Wrapf(err, "failed to mount %s", m.Dest)
+ }
+ mounts, release, err := mountable.Mount()
+ if err != nil {
+ releaseAll()
+ return nil, nil, errors.WithStack(err)
+ }
+ releasers = append(releasers, release)
+ for _, mount := range mounts {
+ mount, err = sm.subMount(mount, m.Selector)
+ if err != nil {
+ releaseAll()
+ return nil, nil, err
+ }
+ s.Mounts = append(s.Mounts, specs.Mount{
+ Destination: m.Dest,
+ Type: mount.Type,
+ Source: mount.Source,
+ Options: mount.Options,
+ })
+ }
+ }
+
+ return s, releaseAll, nil
+}
+
+type mountRef struct {
+ mount mount.Mount
+ unmount func() error
+}
+
+type submounts struct {
+ m map[uint64]mountRef
+}
+
+func (s *submounts) subMount(m mount.Mount, subPath string) (mount.Mount, error) {
+ if path.Join("/", subPath) == "/" {
+ return m, nil
+ }
+ if s.m == nil {
+ s.m = map[uint64]mountRef{}
+ }
+ h, err := hashstructure.Hash(m, nil)
+ if err != nil {
+ return mount.Mount{}, nil
+ }
+ if mr, ok := s.m[h]; ok {
+ sm, err := sub(mr.mount, subPath)
+ if err != nil {
+ return mount.Mount{}, nil
+ }
+ return sm, nil
+ }
+
+ lm := snapshot.LocalMounterWithMounts([]mount.Mount{m})
+
+ mp, err := lm.Mount()
+ if err != nil {
+ return mount.Mount{}, err
+ }
+
+ opts := []string{"rbind"}
+ for _, opt := range m.Options {
+ if opt == "ro" {
+ opts = append(opts, opt)
+ }
+ }
+
+ s.m[h] = mountRef{
+ mount: mount.Mount{
+ Source: mp,
+ Type: "bind",
+ Options: opts,
+ },
+ unmount: lm.Unmount,
+ }
+
+ sm, err := sub(s.m[h].mount, subPath)
+ if err != nil {
+ return mount.Mount{}, err
+ }
+ return sm, nil
+}
+
+func (s *submounts) cleanup() {
+ var wg sync.WaitGroup
+ wg.Add(len(s.m))
+ for _, m := range s.m {
+ func(m mountRef) {
+ go func() {
+ m.unmount()
+ wg.Done()
+ }()
+ }(m)
+ }
+ wg.Wait()
+}
+
+func sub(m mount.Mount, subPath string) (mount.Mount, error) {
+ src, err := fs.RootPath(m.Source, subPath)
+ if err != nil {
+ return mount.Mount{}, err
+ }
+ m.Source = src
+ return m, nil
+}
+
+func specMapping(s []idtools.IDMap) []specs.LinuxIDMapping {
+ var ids []specs.LinuxIDMapping
+ for _, item := range s {
+ ids = append(ids, specs.LinuxIDMapping{
+ HostID: uint32(item.HostID),
+ ContainerID: uint32(item.ContainerID),
+ Size: uint32(item.Size),
+ })
+ }
+ return ids
+}
diff --git a/vendor/github.com/moby/buildkit/executor/oci/spec_unix.go b/vendor/github.com/moby/buildkit/executor/oci/spec_unix.go
index 8ab4fb4..de36195 100644
--- a/vendor/github.com/moby/buildkit/executor/oci/spec_unix.go
+++ b/vendor/github.com/moby/buildkit/executor/oci/spec_unix.go
@@ -3,252 +3,56 @@
package oci
import (
- "context"
- "path"
- "sync"
-
- "github.com/containerd/containerd/containers"
"github.com/containerd/containerd/contrib/seccomp"
- "github.com/containerd/containerd/mount"
- "github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
- "github.com/containerd/continuity/fs"
"github.com/docker/docker/pkg/idtools"
- "github.com/mitchellh/hashstructure"
- "github.com/moby/buildkit/executor"
- "github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/entitlements/security"
- "github.com/moby/buildkit/util/network"
"github.com/moby/buildkit/util/system"
specs "github.com/opencontainers/runtime-spec/specs-go"
- "github.com/pkg/errors"
)
-// Ideally we don't have to import whole containerd just for the default spec
-
-// GenerateSpec generates spec using containerd functionality.
-// opts are ignored for s.Process, s.Hostname, and s.Mounts .
-func GenerateSpec(ctx context.Context, meta executor.Meta, mounts []executor.Mount, id, resolvConf, hostsFile string, namespace network.Namespace, processMode ProcessMode, idmap *idtools.IdentityMapping, opts ...oci.SpecOpts) (*specs.Spec, func(), error) {
- c := &containers.Container{
- ID: id,
- }
- _, ok := namespaces.Namespace(ctx)
- if !ok {
- ctx = namespaces.WithNamespace(ctx, "buildkit")
- }
- if meta.SecurityMode == pb.SecurityMode_INSECURE {
- opts = append(opts, security.WithInsecureSpec())
- } else if system.SeccompSupported() && meta.SecurityMode == pb.SecurityMode_SANDBOX {
- opts = append(opts, seccomp.WithDefaultProfile())
- }
-
- switch processMode {
- case NoProcessSandbox:
- // Mount for /proc is replaced in GetMounts()
- opts = append(opts,
- oci.WithHostNamespace(specs.PIDNamespace))
- // TODO(AkihiroSuda): Configure seccomp to disable ptrace (and prctl?) explicitly
- }
-
- // Note that containerd.GenerateSpec is namespaced so as to make
- // specs.Linux.CgroupsPath namespaced
- s, err := oci.GenerateSpec(ctx, nil, c, opts...)
- if err != nil {
- return nil, nil, err
- }
- // set the networking information on the spec
- namespace.Set(s)
-
- s.Process.Args = meta.Args
- s.Process.Env = meta.Env
- s.Process.Cwd = meta.Cwd
- s.Process.Rlimits = nil // reset open files limit
- s.Process.NoNewPrivileges = false // reset nonewprivileges
- s.Hostname = "buildkitsandbox"
-
- s.Mounts, err = GetMounts(ctx,
- withProcessMode(processMode),
+func generateMountOpts(resolvConf, hostsFile string) ([]oci.SpecOpts, error) {
+ return []oci.SpecOpts{
+ // https://github.com/moby/buildkit/issues/429
+ withRemovedMount("/run"),
withROBind(resolvConf, "/etc/resolv.conf"),
withROBind(hostsFile, "/etc/hosts"),
- )
- if err != nil {
- return nil, nil, err
- }
-
- s.Mounts = append(s.Mounts, specs.Mount{
- Destination: "/sys/fs/cgroup",
- Type: "cgroup",
- Source: "cgroup",
- Options: []string{"ro", "nosuid", "noexec", "nodev"},
- })
-
- if processMode == NoProcessSandbox {
- var maskedPaths []string
- for _, s := range s.Linux.MaskedPaths {
- if !hasPrefix(s, "/proc") {
- maskedPaths = append(maskedPaths, s)
- }
- }
- s.Linux.MaskedPaths = maskedPaths
- var readonlyPaths []string
- for _, s := range s.Linux.ReadonlyPaths {
- if !hasPrefix(s, "/proc") {
- readonlyPaths = append(readonlyPaths, s)
- }
- }
- s.Linux.ReadonlyPaths = readonlyPaths
- }
-
- if meta.SecurityMode == pb.SecurityMode_INSECURE {
- if err = oci.WithWriteableCgroupfs(ctx, nil, c, s); err != nil {
- return nil, nil, err
- }
- if err = oci.WithWriteableSysfs(ctx, nil, c, s); err != nil {
- return nil, nil, err
- }
- }
-
- if idmap != nil {
- s.Linux.Namespaces = append(s.Linux.Namespaces, specs.LinuxNamespace{
- Type: specs.UserNamespace,
- })
- s.Linux.UIDMappings = specMapping(idmap.UIDs())
- s.Linux.GIDMappings = specMapping(idmap.GIDs())
- }
-
- sm := &submounts{}
-
- var releasers []func() error
- releaseAll := func() {
- sm.cleanup()
- for _, f := range releasers {
- f()
- }
- }
-
- for _, m := range mounts {
- if m.Src == nil {
- return nil, nil, errors.Errorf("mount %s has no source", m.Dest)
- }
- mountable, err := m.Src.Mount(ctx, m.Readonly)
- if err != nil {
- releaseAll()
- return nil, nil, errors.Wrapf(err, "failed to mount %s", m.Dest)
- }
- mounts, release, err := mountable.Mount()
- if err != nil {
- releaseAll()
- return nil, nil, errors.WithStack(err)
- }
- releasers = append(releasers, release)
- for _, mount := range mounts {
- mount, err = sm.subMount(mount, m.Selector)
- if err != nil {
- releaseAll()
- return nil, nil, err
- }
- s.Mounts = append(s.Mounts, specs.Mount{
- Destination: m.Dest,
- Type: mount.Type,
- Source: mount.Source,
- Options: mount.Options,
- })
- }
- }
-
- return s, releaseAll, nil
+ withCGroup(),
+ }, nil
}
-type mountRef struct {
- mount mount.Mount
- unmount func() error
+// generateSecurityOpts may affect mounts, so must be called after generateMountOpts
+func generateSecurityOpts(mode pb.SecurityMode) ([]oci.SpecOpts, error) {
+ if mode == pb.SecurityMode_INSECURE {
+ return []oci.SpecOpts{
+ security.WithInsecureSpec(),
+ oci.WithWriteableCgroupfs,
+ oci.WithWriteableSysfs,
+ }, nil
+ } else if system.SeccompSupported() && mode == pb.SecurityMode_SANDBOX {
+ return []oci.SpecOpts{seccomp.WithDefaultProfile()}, nil
+ }
+ return nil, nil
}
-type submounts struct {
- m map[uint64]mountRef
+// generateProcessModeOpts may affect mounts, so must be called after generateMountOpts
+func generateProcessModeOpts(mode ProcessMode) ([]oci.SpecOpts, error) {
+ if mode == NoProcessSandbox {
+ return []oci.SpecOpts{
+ oci.WithHostNamespace(specs.PIDNamespace),
+ withBoundProc(),
+ }, nil
+ // TODO(AkihiroSuda): Configure seccomp to disable ptrace (and prctl?) explicitly
+ }
+ return nil, nil
}
-func (s *submounts) subMount(m mount.Mount, subPath string) (mount.Mount, error) {
- if path.Join("/", subPath) == "/" {
- return m, nil
+func generateIDmapOpts(idmap *idtools.IdentityMapping) ([]oci.SpecOpts, error) {
+ if idmap == nil {
+ return nil, nil
}
- if s.m == nil {
- s.m = map[uint64]mountRef{}
- }
- h, err := hashstructure.Hash(m, nil)
- if err != nil {
- return mount.Mount{}, nil
- }
- if mr, ok := s.m[h]; ok {
- sm, err := sub(mr.mount, subPath)
- if err != nil {
- return mount.Mount{}, nil
- }
- return sm, nil
- }
-
- lm := snapshot.LocalMounterWithMounts([]mount.Mount{m})
-
- mp, err := lm.Mount()
- if err != nil {
- return mount.Mount{}, err
- }
-
- opts := []string{"rbind"}
- for _, opt := range m.Options {
- if opt == "ro" {
- opts = append(opts, opt)
- }
- }
-
- s.m[h] = mountRef{
- mount: mount.Mount{
- Source: mp,
- Type: "bind",
- Options: opts,
- },
- unmount: lm.Unmount,
- }
-
- sm, err := sub(s.m[h].mount, subPath)
- if err != nil {
- return mount.Mount{}, err
- }
- return sm, nil
-}
-
-func (s *submounts) cleanup() {
- var wg sync.WaitGroup
- wg.Add(len(s.m))
- for _, m := range s.m {
- func(m mountRef) {
- go func() {
- m.unmount()
- wg.Done()
- }()
- }(m)
- }
- wg.Wait()
-}
-
-func sub(m mount.Mount, subPath string) (mount.Mount, error) {
- src, err := fs.RootPath(m.Source, subPath)
- if err != nil {
- return mount.Mount{}, err
- }
- m.Source = src
- return m, nil
-}
-
-func specMapping(s []idtools.IDMap) []specs.LinuxIDMapping {
- var ids []specs.LinuxIDMapping
- for _, item := range s {
- ids = append(ids, specs.LinuxIDMapping{
- HostID: uint32(item.HostID),
- ContainerID: uint32(item.ContainerID),
- Size: uint32(item.Size),
- })
- }
- return ids
+ return []oci.SpecOpts{
+ oci.WithUserNamespace(specMapping(idmap.UIDs()), specMapping(idmap.GIDs())),
+ }, nil
}
diff --git a/vendor/github.com/moby/buildkit/executor/oci/spec_windows.go b/vendor/github.com/moby/buildkit/executor/oci/spec_windows.go
new file mode 100644
index 0000000..4589c9d
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/executor/oci/spec_windows.go
@@ -0,0 +1,42 @@
+// +build windows
+
+package oci
+
+import (
+ "github.com/containerd/containerd/contrib/seccomp"
+ "github.com/containerd/containerd/oci"
+ "github.com/docker/docker/pkg/idtools"
+ "github.com/moby/buildkit/solver/pb"
+ "github.com/moby/buildkit/util/system"
+ "github.com/pkg/errors"
+)
+
+func generateMountOpts(resolvConf, hostsFile string) ([]oci.SpecOpts, error) {
+ return nil, nil
+}
+
+// generateSecurityOpts may affect mounts, so must be called after generateMountOpts
+func generateSecurityOpts(mode pb.SecurityMode) ([]oci.SpecOpts, error) {
+ if mode == pb.SecurityMode_INSECURE {
+ return nil, errors.New("no support for running in insecure mode on Windows")
+ } else if system.SeccompSupported() && mode == pb.SecurityMode_SANDBOX {
+ // TODO: Can LCOW support seccomp? Does that even make sense?
+ return []oci.SpecOpts{seccomp.WithDefaultProfile()}, nil
+ }
+ return nil, nil
+}
+
+// generateProcessModeOpts may affect mounts, so must be called after generateMountOpts
+func generateProcessModeOpts(mode ProcessMode) ([]oci.SpecOpts, error) {
+ if mode == NoProcessSandbox {
+ return nil, errors.New("no support for NoProcessSandbox on Windows")
+ }
+ return nil, nil
+}
+
+func generateIDmapOpts(idmap *idtools.IdentityMapping) ([]oci.SpecOpts, error) {
+ if idmap == nil {
+ return nil, nil
+ }
+ return nil, errors.New("no support for IdentityMapping on Windows")
+}
diff --git a/vendor/github.com/moby/buildkit/executor/oci/user.go b/vendor/github.com/moby/buildkit/executor/oci/user.go
index 4f7cb10..e49eb8e 100644
--- a/vendor/github.com/moby/buildkit/executor/oci/user.go
+++ b/vendor/github.com/moby/buildkit/executor/oci/user.go
@@ -14,7 +14,7 @@
"github.com/pkg/errors"
)
-func GetUser(ctx context.Context, root, username string) (uint32, uint32, []uint32, error) {
+func GetUser(root, username string) (uint32, uint32, []uint32, error) {
// fast path from uid/gid
if uid, gid, err := ParseUIDGID(username); err == nil {
return uid, gid, nil, nil
diff --git a/vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go b/vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go
index 068929c..035edfd 100644
--- a/vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go
+++ b/vendor/github.com/moby/buildkit/executor/runcexecutor/executor.go
@@ -12,15 +12,16 @@
"syscall"
"time"
+ "github.com/containerd/containerd"
"github.com/containerd/containerd/mount"
containerdoci "github.com/containerd/containerd/oci"
"github.com/containerd/continuity/fs"
runc "github.com/containerd/go-runc"
"github.com/docker/docker/pkg/idtools"
- "github.com/moby/buildkit/cache"
"github.com/moby/buildkit/executor"
"github.com/moby/buildkit/executor/oci"
"github.com/moby/buildkit/identity"
+ "github.com/moby/buildkit/solver/errdefs"
"github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/network"
rootlessspecconv "github.com/moby/buildkit/util/rootless/specconv"
@@ -52,7 +53,6 @@
type runcExecutor struct {
runc *runc.Runc
root string
- cmd string
cgroupParent string
rootless bool
networkProviders map[pb.NetMode]network.Provider
@@ -103,15 +103,16 @@
os.RemoveAll(filepath.Join(root, "resolv.conf"))
runtime := &runc.Runc{
- Command: cmd,
- Log: filepath.Join(root, "runc-log.json"),
- LogFormat: runc.JSON,
- PdeathSignal: syscall.SIGKILL, // this can still leak the process
- Setpgid: true,
+ Command: cmd,
+ Log: filepath.Join(root, "runc-log.json"),
+ LogFormat: runc.JSON,
+ Setpgid: true,
// we don't execute runc with --rootless=(true|false) explicitly,
// so as to support non-runc runtimes
}
+ updateRuncFieldsForHostOS(runtime)
+
w := &runcExecutor{
runc: runtime,
root: root,
@@ -128,7 +129,7 @@
return w, nil
}
-func (w *runcExecutor) Run(ctx context.Context, id string, root cache.Mountable, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
+func (w *runcExecutor) Run(ctx context.Context, id string, root executor.Mount, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
meta := process.Meta
startedOnce := sync.Once{}
@@ -168,7 +169,7 @@
return err
}
- hostsFile, clean, err := oci.GetHostsFile(ctx, w.root, meta.ExtraHosts, w.idmap)
+ hostsFile, clean, err := oci.GetHostsFile(ctx, w.root, meta.ExtraHosts, w.idmap, meta.Hostname)
if err != nil {
return err
}
@@ -176,7 +177,7 @@
defer clean()
}
- mountable, err := root.Mount(ctx, false)
+ mountable, err := root.Src.Mount(ctx, false)
if err != nil {
return err
}
@@ -213,7 +214,9 @@
}
defer mount.Unmount(rootFSPath, 0)
- uid, gid, sgids, err := oci.GetUser(ctx, rootFSPath, meta.User)
+ defer executor.MountStubsCleaner(rootFSPath, mounts)()
+
+ uid, gid, sgids, err := oci.GetUser(rootFSPath, meta.User)
if err != nil {
return err
}
@@ -258,7 +261,7 @@
defer cleanup()
spec.Root.Path = rootFSPath
- if _, ok := root.(cache.ImmutableRef); ok { // TODO: pass in with mount, not ref type
+ if root.Readonly {
spec.Root.Readonly = true
}
@@ -323,28 +326,37 @@
close(started)
})
}
- status, err := w.runc.Run(runCtx, id, bundle, &runc.CreateOpts{
- IO: &forwardIO{stdin: process.Stdin, stdout: process.Stdout, stderr: process.Stderr},
- NoPivot: w.noPivot,
- })
- close(ended)
- if status != 0 || err != nil {
- if err == nil {
- err = errors.Errorf("exit code: %d", status)
+ err = w.run(runCtx, id, bundle, process)
+ close(ended)
+ return exitError(ctx, err)
+}
+
+func exitError(ctx context.Context, err error) error {
+ if err != nil {
+ exitErr := &errdefs.ExitError{
+ ExitCode: containerd.UnknownExitStatus,
+ Err: err,
+ }
+ var runcExitError *runc.ExitError
+ if errors.As(err, &runcExitError) {
+ exitErr = &errdefs.ExitError{
+ ExitCode: uint32(runcExitError.Status),
+ }
}
select {
case <-ctx.Done():
- return errors.Wrapf(ctx.Err(), err.Error())
+ exitErr.Err = errors.Wrapf(ctx.Err(), exitErr.Error())
+ return exitErr
default:
- return stack.Enable(err)
+ return stack.Enable(exitErr)
}
}
return nil
}
-func (w *runcExecutor) Exec(ctx context.Context, id string, process executor.ProcessInfo) error {
+func (w *runcExecutor) Exec(ctx context.Context, id string, process executor.ProcessInfo) (err error) {
// first verify the container is running, if we get an error assume the container
// is in the process of being created and check again every 100ms or until
// context is canceled.
@@ -386,7 +398,7 @@
}
if process.Meta.User != "" {
- uid, gid, sgids, err := oci.GetUser(ctx, state.Rootfs, process.Meta.User)
+ uid, gid, sgids, err := oci.GetUser(state.Rootfs, process.Meta.User)
if err != nil {
return err
}
@@ -407,9 +419,8 @@
spec.Process.Env = process.Meta.Env
}
- return w.runc.Exec(ctx, id, *spec.Process, &runc.ExecOpts{
- IO: &forwardIO{stdin: process.Stdin, stdout: process.Stdout, stderr: process.Stderr},
- })
+ err = w.exec(ctx, id, state.Bundle, spec.Process, process)
+ return exitError(ctx, err)
}
type forwardIO struct {
diff --git a/vendor/github.com/moby/buildkit/executor/runcexecutor/executor_common.go b/vendor/github.com/moby/buildkit/executor/runcexecutor/executor_common.go
new file mode 100644
index 0000000..3751b90
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/executor/runcexecutor/executor_common.go
@@ -0,0 +1,36 @@
+// +build !linux
+
+package runcexecutor
+
+import (
+ "context"
+
+ runc "github.com/containerd/go-runc"
+ "github.com/moby/buildkit/executor"
+ "github.com/opencontainers/runtime-spec/specs-go"
+ "github.com/pkg/errors"
+)
+
+var unsupportedConsoleError = errors.New("tty for runc is only supported on linux")
+
+func updateRuncFieldsForHostOS(runtime *runc.Runc) {}
+
+func (w *runcExecutor) run(ctx context.Context, id, bundle string, process executor.ProcessInfo) error {
+ if process.Meta.Tty {
+ return unsupportedConsoleError
+ }
+ _, err := w.runc.Run(ctx, id, bundle, &runc.CreateOpts{
+ IO: &forwardIO{stdin: process.Stdin, stdout: process.Stdout, stderr: process.Stderr},
+ NoPivot: w.noPivot,
+ })
+ return err
+}
+
+func (w *runcExecutor) exec(ctx context.Context, id, bundle string, specsProcess *specs.Process, process executor.ProcessInfo) error {
+ if process.Meta.Tty {
+ return unsupportedConsoleError
+ }
+ return w.runc.Exec(ctx, id, *specsProcess, &runc.ExecOpts{
+ IO: &forwardIO{stdin: process.Stdin, stdout: process.Stdout, stderr: process.Stderr},
+ })
+}
diff --git a/vendor/github.com/moby/buildkit/executor/runcexecutor/executor_linux.go b/vendor/github.com/moby/buildkit/executor/runcexecutor/executor_linux.go
new file mode 100644
index 0000000..b01040c
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/executor/runcexecutor/executor_linux.go
@@ -0,0 +1,160 @@
+package runcexecutor
+
+import (
+ "context"
+ "io"
+ "os"
+ "syscall"
+ "time"
+
+ "github.com/containerd/console"
+ runc "github.com/containerd/go-runc"
+ "github.com/docker/docker/pkg/signal"
+ "github.com/moby/buildkit/executor"
+ "github.com/opencontainers/runtime-spec/specs-go"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+ "golang.org/x/sync/errgroup"
+)
+
+func updateRuncFieldsForHostOS(runtime *runc.Runc) {
+ // PdeathSignal only supported on unix platforms
+ runtime.PdeathSignal = syscall.SIGKILL // this can still leak the process
+}
+
+func (w *runcExecutor) run(ctx context.Context, id, bundle string, process executor.ProcessInfo) error {
+ return w.callWithIO(ctx, id, bundle, process, func(ctx context.Context, started chan<- int, io runc.IO) error {
+ _, err := w.runc.Run(ctx, id, bundle, &runc.CreateOpts{
+ NoPivot: w.noPivot,
+ Started: started,
+ IO: io,
+ })
+ return err
+ })
+}
+
+func (w *runcExecutor) exec(ctx context.Context, id, bundle string, specsProcess *specs.Process, process executor.ProcessInfo) error {
+ return w.callWithIO(ctx, id, bundle, process, func(ctx context.Context, started chan<- int, io runc.IO) error {
+ return w.runc.Exec(ctx, id, *specsProcess, &runc.ExecOpts{
+ Started: started,
+ IO: io,
+ })
+ })
+}
+
+type runcCall func(ctx context.Context, started chan<- int, io runc.IO) error
+
+func (w *runcExecutor) callWithIO(ctx context.Context, id, bundle string, process executor.ProcessInfo, call runcCall) error {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+
+ if !process.Meta.Tty {
+ return call(ctx, nil, &forwardIO{stdin: process.Stdin, stdout: process.Stdout, stderr: process.Stderr})
+ }
+
+ ptm, ptsName, err := console.NewPty()
+ if err != nil {
+ return err
+ }
+
+ pts, err := os.OpenFile(ptsName, os.O_RDWR|syscall.O_NOCTTY, 0)
+ if err != nil {
+ ptm.Close()
+ return err
+ }
+
+ eg, ctx := errgroup.WithContext(ctx)
+
+ defer func() {
+ if process.Stdin != nil {
+ process.Stdin.Close()
+ }
+ pts.Close()
+ ptm.Close()
+ cancel() // this will shutdown resize loop
+ err := eg.Wait()
+ if err != nil {
+ logrus.Warningf("error while shutting down tty io: %s", err)
+ }
+ }()
+
+ if process.Stdin != nil {
+ eg.Go(func() error {
+ _, err := io.Copy(ptm, process.Stdin)
+ // stdin might be a pipe, so this is like EOF
+ if errors.Is(err, io.ErrClosedPipe) {
+ return nil
+ }
+ return err
+ })
+ }
+
+ if process.Stdout != nil {
+ eg.Go(func() error {
+ _, err := io.Copy(process.Stdout, ptm)
+ // ignore `read /dev/ptmx: input/output error` when ptm is closed
+ var ptmClosedError *os.PathError
+ if errors.As(err, &ptmClosedError) {
+ if ptmClosedError.Op == "read" &&
+ ptmClosedError.Path == "/dev/ptmx" &&
+ ptmClosedError.Err == syscall.EIO {
+ return nil
+ }
+ }
+ return err
+ })
+ }
+
+ started := make(chan int, 1)
+
+ eg.Go(func() error {
+ startedCtx, timeout := context.WithTimeout(ctx, 10*time.Second)
+ defer timeout()
+ var runcProcess *os.Process
+ select {
+ case <-startedCtx.Done():
+ return errors.New("runc started message never received")
+ case pid, ok := <-started:
+ if !ok {
+ return errors.New("runc process failed to send pid")
+ }
+ runcProcess, err = os.FindProcess(pid)
+ if err != nil {
+ return errors.Wrapf(err, "unable to find runc process for pid %d", pid)
+ }
+ defer runcProcess.Release()
+ }
+
+ for {
+ select {
+ case <-ctx.Done():
+ return nil
+ case resize := <-process.Resize:
+ err = ptm.Resize(console.WinSize{
+ Height: uint16(resize.Rows),
+ Width: uint16(resize.Cols),
+ })
+ if err != nil {
+ logrus.Errorf("failed to resize ptm: %s", err)
+ }
+ err = runcProcess.Signal(signal.SIGWINCH)
+ if err != nil {
+ logrus.Errorf("failed to send SIGWINCH to process: %s", err)
+ }
+ }
+ }
+ })
+
+ runcIO := &forwardIO{}
+ if process.Stdin != nil {
+ runcIO.stdin = pts
+ }
+ if process.Stdout != nil {
+ runcIO.stdout = pts
+ }
+ if process.Stderr != nil {
+ runcIO.stderr = pts
+ }
+
+ return call(ctx, started, runcIO)
+}
diff --git a/vendor/github.com/moby/buildkit/executor/stubs.go b/vendor/github.com/moby/buildkit/executor/stubs.go
new file mode 100644
index 0000000..2c13b13
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/executor/stubs.go
@@ -0,0 +1,49 @@
+package executor
+
+import (
+ "errors"
+ "os"
+ "path/filepath"
+ "syscall"
+
+ "github.com/containerd/continuity/fs"
+)
+
+func MountStubsCleaner(dir string, mounts []Mount) func() {
+ names := []string{"/etc/resolv.conf", "/etc/hosts"}
+
+ for _, m := range mounts {
+ names = append(names, m.Dest)
+ }
+
+ paths := make([]string, 0, len(names))
+
+ for _, p := range names {
+ p = filepath.Join("/", p)
+ if p == "/" {
+ continue
+ }
+ realPath, err := fs.RootPath(dir, p)
+ if err != nil {
+ continue
+ }
+
+ _, err = os.Lstat(realPath)
+ if errors.Is(err, os.ErrNotExist) || errors.Is(err, syscall.ENOTDIR) {
+ paths = append(paths, realPath)
+ }
+ }
+
+ return func() {
+ for _, p := range paths {
+ st, err := os.Lstat(p)
+ if err != nil {
+ continue
+ }
+ if st.Size() != 0 {
+ continue
+ }
+ os.Remove(p)
+ }
+ }
+}
diff --git a/vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go b/vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go
index 02e34eb..b428afd 100644
--- a/vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go
+++ b/vendor/github.com/moby/buildkit/exporter/containerimage/exptypes/types.go
@@ -1,11 +1,16 @@
package exptypes
-import specs "github.com/opencontainers/image-spec/specs-go/v1"
+import (
+ "github.com/opencontainers/go-digest"
+ specs "github.com/opencontainers/image-spec/specs-go/v1"
+)
const ExporterImageConfigKey = "containerimage.config"
const ExporterInlineCache = "containerimage.inlinecache"
const ExporterPlatformsKey = "refs.platforms"
+const EmptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
+
type Platforms struct {
Platforms []Platform
}
diff --git a/vendor/github.com/moby/buildkit/exporter/local/export.go b/vendor/github.com/moby/buildkit/exporter/local/export.go
index 28e3220..d772776 100644
--- a/vendor/github.com/moby/buildkit/exporter/local/export.go
+++ b/vendor/github.com/moby/buildkit/exporter/local/export.go
@@ -51,7 +51,7 @@
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
- caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID)
+ caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID, false)
if err != nil {
return nil, err
}
@@ -70,7 +70,7 @@
}
defer os.RemoveAll(src)
} else {
- mount, err := ref.Mount(ctx, true)
+ mount, err := ref.Mount(ctx, true, session.NewGroup(sessionID))
if err != nil {
return err
}
diff --git a/vendor/github.com/moby/buildkit/exporter/tar/export.go b/vendor/github.com/moby/buildkit/exporter/tar/export.go
index 0f635fc..79e98cd 100644
--- a/vendor/github.com/moby/buildkit/exporter/tar/export.go
+++ b/vendor/github.com/moby/buildkit/exporter/tar/export.go
@@ -65,7 +65,7 @@
}
defers = append(defers, func() { os.RemoveAll(src) })
} else {
- mount, err := ref.Mount(ctx, true)
+ mount, err := ref.Mount(ctx, true, session.NewGroup(sessionID))
if err != nil {
return nil, err
}
@@ -135,7 +135,7 @@
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
- caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID)
+ caller, err := e.opt.SessionManager.Get(timeoutCtx, sessionID, false)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/build.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/build.go
index 6d959d9..f182ae9 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/build.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/build.go
@@ -14,11 +14,11 @@
"strings"
"github.com/containerd/containerd/platforms"
- "github.com/docker/docker/builder/dockerignore"
controlapi "github.com/moby/buildkit/api/services/control"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb"
+ "github.com/moby/buildkit/frontend/dockerfile/dockerignore"
"github.com/moby/buildkit/frontend/dockerfile/parser"
"github.com/moby/buildkit/frontend/gateway/client"
gwpb "github.com/moby/buildkit/frontend/gateway/pb"
@@ -53,16 +53,23 @@
keyNameDockerfile = "dockerfilekey"
keyContextSubDir = "contextsubdir"
keyContextKeepGitDir = "build-arg:BUILDKIT_CONTEXT_KEEP_GIT_DIR"
+ keySyntax = "build-arg:BUILDKIT_SYNTAX"
+ keyHostname = "hostname"
)
var httpPrefix = regexp.MustCompile(`^https?://`)
-var gitUrlPathWithFragmentSuffix = regexp.MustCompile(`\.git(?:#.+)?$`)
+var gitURLPathWithFragmentSuffix = regexp.MustCompile(`\.git(?:#.+)?$`)
func Build(ctx context.Context, c client.Client) (*client.Result, error) {
opts := c.BuildOpts().Opts
caps := c.BuildOpts().LLBCaps
gwcaps := c.BuildOpts().Caps
+ allowForward, capsError := validateCaps(opts["frontend.caps"])
+ if !allowForward && capsError != nil {
+ return nil, capsError
+ }
+
marshalOpts := []llb.ConstraintsOpt{llb.WithCaps(caps)}
localNameContext := DefaultLocalNameContext
@@ -317,8 +324,14 @@
}
if _, ok := opts["cmdline"]; !ok {
- ref, cmdline, loc, ok := dockerfile2llb.DetectSyntax(bytes.NewBuffer(dtDockerfile))
- if ok {
+ if cmdline, ok := opts[keySyntax]; ok {
+ p := strings.SplitN(strings.TrimSpace(cmdline), " ", 2)
+ res, err := forwardGateway(ctx, c, p[0], cmdline)
+ if err != nil && len(errdefs.Sources(err)) == 0 {
+ return nil, errors.Wrapf(err, "failed with %s = %s", keySyntax, cmdline)
+ }
+ return res, err
+ } else if ref, cmdline, loc, ok := dockerfile2llb.DetectSyntax(bytes.NewBuffer(dtDockerfile)); ok {
res, err := forwardGateway(ctx, c, ref, cmdline)
if err != nil && len(errdefs.Sources(err)) == 0 {
return nil, wrapSource(err, sourceMap, loc)
@@ -327,6 +340,14 @@
}
}
+ if capsError != nil {
+ return nil, capsError
+ }
+
+ if res, ok, err := checkSubRequest(ctx, opts); ok {
+ return res, err
+ }
+
exportMap := len(targetPlatforms) > 1
if v := opts[keyMultiPlatform]; v != "" {
@@ -375,6 +396,7 @@
OverrideCopyImage: opts[keyOverrideCopyImage],
LLBCaps: &caps,
SourceMap: sourceMap,
+ Hostname: opts[keyHostname],
})
if err != nil {
@@ -512,7 +534,7 @@
func detectGitContext(ref, gitContext string) (*llb.State, bool) {
found := false
- if httpPrefix.MatchString(ref) && gitUrlPathWithFragmentSuffix.MatchString(ref) {
+ if httpPrefix.MatchString(ref) && gitURLPathWithFragmentSuffix.MatchString(ref) {
found = true
}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/caps.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/caps.go
new file mode 100644
index 0000000..2797011
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/caps.go
@@ -0,0 +1,34 @@
+package builder
+
+import (
+ "strings"
+
+ "github.com/moby/buildkit/solver/errdefs"
+ "github.com/moby/buildkit/util/grpcerrors"
+ "github.com/moby/buildkit/util/stack"
+ "google.golang.org/grpc/codes"
+)
+
+var enabledCaps = map[string]struct{}{
+ "moby.buildkit.frontend.inputs": {},
+ "moby.buildkit.frontend.subrequests": {},
+}
+
+func validateCaps(req string) (forward bool, err error) {
+ if req == "" {
+ return
+ }
+ caps := strings.Split(req, ",")
+ for _, c := range caps {
+ parts := strings.SplitN(c, "+", 2)
+ if _, ok := enabledCaps[parts[0]]; !ok {
+ err = stack.Enable(grpcerrors.WrapCode(errdefs.NewUnsupportedFrontendCapError(parts[0]), codes.Unimplemented))
+ if strings.Contains(c, "+forward") {
+ forward = true
+ } else {
+ return false, err
+ }
+ }
+ }
+ return
+}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/subrequests.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/subrequests.go
new file mode 100644
index 0000000..6d30b7b
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/builder/subrequests.go
@@ -0,0 +1,39 @@
+package builder
+
+import (
+ "context"
+ "encoding/json"
+
+ "github.com/moby/buildkit/frontend/gateway/client"
+ "github.com/moby/buildkit/frontend/subrequests"
+ "github.com/moby/buildkit/solver/errdefs"
+)
+
+func checkSubRequest(ctx context.Context, opts map[string]string) (*client.Result, bool, error) {
+ req, ok := opts["requestid"]
+ if !ok {
+ return nil, false, nil
+ }
+ switch req {
+ case subrequests.RequestSubrequestsDescribe:
+ res, err := describe()
+ return res, true, err
+ default:
+ return nil, true, errdefs.NewUnsupportedSubrequestError(req)
+ }
+}
+
+func describe() (*client.Result, error) {
+ all := []subrequests.Request{
+ subrequests.SubrequestsDescribeDefinition,
+ }
+ dt, err := json.MarshalIndent(all, " ", "")
+ if err != nil {
+ return nil, err
+ }
+ res := client.NewResult()
+ res.Metadata = map[string][]byte{
+ "result.json": dt,
+ }
+ return res, nil
+}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go
index 28c7efc..5b3d52a 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go
@@ -62,6 +62,7 @@
LLBCaps *apicaps.CapSet
ContextLocalName string
SourceMap *llb.SourceMap
+ Hostname string
}
func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State, *Image, error) {
@@ -94,11 +95,13 @@
shlex := shell.NewLex(dockerfile.EscapeToken)
- for _, metaArg := range metaArgs {
- if metaArg.Value != nil {
- *metaArg.Value, _ = shlex.ProcessWordWithMap(*metaArg.Value, metaArgsToMap(optMetaArgs))
+ for _, cmd := range metaArgs {
+ for _, metaArg := range cmd.Args {
+ if metaArg.Value != nil {
+ *metaArg.Value, _ = shlex.ProcessWordWithMap(*metaArg.Value, metaArgsToMap(optMetaArgs))
+ }
+ optMetaArgs = append(optMetaArgs, setKVValue(metaArg, opt.BuildArgs))
}
- optMetaArgs = append(optMetaArgs, setKVValue(metaArg.KeyValuePairOptional, opt.BuildArgs))
}
metaResolver := opt.MetaResolver
@@ -314,7 +317,11 @@
// make sure that PATH is always set
if _, ok := shell.BuildEnvs(d.image.Config.Env)["PATH"]; !ok {
- d.image.Config.Env = append(d.image.Config.Env, "PATH="+system.DefaultPathEnv)
+ var os string
+ if d.platform != nil {
+ os = d.platform.OS
+ }
+ d.image.Config.Env = append(d.image.Config.Env, "PATH="+system.DefaultPathEnv(os))
}
// initialize base metadata from image conf
@@ -322,6 +329,9 @@
k, v := parseKeyValue(env)
d.state = d.state.AddEnv(k, v)
}
+ if opt.Hostname != "" {
+ d.state = d.state.Hostname(opt.Hostname)
+ }
if d.image.Config.WorkingDir != "" {
if err = dispatchWorkdir(d, &instructions.WorkdirCommand{Path: d.image.Config.WorkingDir}, false, nil); err != nil {
return nil, nil, parser.WithLocation(err, d.stage.Location)
@@ -1072,26 +1082,30 @@
}
func dispatchArg(d *dispatchState, c *instructions.ArgCommand, metaArgs []instructions.KeyValuePairOptional, buildArgValues map[string]string) error {
- commitStr := "ARG " + c.Key
- buildArg := setKVValue(c.KeyValuePairOptional, buildArgValues)
+ commitStrs := make([]string, 0, len(c.Args))
+ for _, arg := range c.Args {
+ buildArg := setKVValue(arg, buildArgValues)
- if c.Value != nil {
- commitStr += "=" + *c.Value
- }
- if buildArg.Value == nil {
- for _, ma := range metaArgs {
- if ma.Key == buildArg.Key {
- buildArg.Value = ma.Value
+ commitStr := arg.Key
+ if arg.Value != nil {
+ commitStr += "=" + *arg.Value
+ }
+ commitStrs = append(commitStrs, commitStr)
+ if buildArg.Value == nil {
+ for _, ma := range metaArgs {
+ if ma.Key == buildArg.Key {
+ buildArg.Value = ma.Value
+ }
}
}
- }
- if buildArg.Value != nil {
- d.state = d.state.AddEnv(buildArg.Key, *buildArg.Value)
- }
+ if buildArg.Value != nil {
+ d.state = d.state.AddEnv(buildArg.Key, *buildArg.Value)
+ }
- d.buildArgs = append(d.buildArgs, buildArg)
- return commitToHistory(&d.image, commitStr, false, nil)
+ d.buildArgs = append(d.buildArgs, buildArg)
+ }
+ return commitToHistory(&d.image, "ARG "+strings.Join(commitStrs, " "), false, nil)
}
func pathRelativeToWorkingDir(s llb.State, p string) (string, error) {
@@ -1308,15 +1322,15 @@
isNil := true
for k, v := range args {
if strings.EqualFold(k, "http_proxy") {
- pe.HttpProxy = v
+ pe.HTTPProxy = v
isNil = false
}
if strings.EqualFold(k, "https_proxy") {
- pe.HttpsProxy = v
+ pe.HTTPSProxy = v
isNil = false
}
if strings.EqualFold(k, "ftp_proxy") {
- pe.FtpProxy = v
+ pe.FTPProxy = v
isNil = false
}
if strings.EqualFold(k, "no_proxy") {
@@ -1339,7 +1353,7 @@
if len(img.Config.Shell) > 0 {
shell = append([]string{}, img.Config.Shell...)
} else {
- shell = defaultShell()
+ shell = defaultShell(img.OS)
}
return append(shell, strings.Join(args, " "))
}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_norunmount.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_norunmount.go
deleted file mode 100644
index 5f0cd08..0000000
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_norunmount.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// +build !dfrunmount
-
-package dockerfile2llb
-
-import (
- "github.com/moby/buildkit/client/llb"
- "github.com/moby/buildkit/frontend/dockerfile/instructions"
-)
-
-func detectRunMount(cmd *command, allDispatchStates *dispatchStates) bool {
- return false
-}
-
-func dispatchRunMounts(d *dispatchState, c *instructions.RunCommand, sources []*dispatchState, opt dispatchOpt) ([]llb.RunOption, error) {
- return nil, nil
-}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_nosecrets.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_nosecrets.go
deleted file mode 100644
index d754702..0000000
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_nosecrets.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// +build dfrunmount,!dfsecrets
-
-package dockerfile2llb
-
-import (
- "github.com/moby/buildkit/client/llb"
- "github.com/moby/buildkit/frontend/dockerfile/instructions"
- "github.com/pkg/errors"
-)
-
-func dispatchSecret(m *instructions.Mount) (llb.RunOption, error) {
- return nil, errors.Errorf("secret mounts not allowed")
-}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_nossh.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_nossh.go
deleted file mode 100644
index 8b8afdc..0000000
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_nossh.go
+++ /dev/null
@@ -1,13 +0,0 @@
-// +build dfrunmount,!dfssh
-
-package dockerfile2llb
-
-import (
- "github.com/moby/buildkit/client/llb"
- "github.com/moby/buildkit/frontend/dockerfile/instructions"
- "github.com/pkg/errors"
-)
-
-func dispatchSSH(m *instructions.Mount) (llb.RunOption, error) {
- return nil, errors.Errorf("ssh mounts not allowed")
-}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_runmount.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_runmount.go
index 1be4849..8cd928b 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_runmount.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_runmount.go
@@ -1,5 +1,3 @@
-// +build dfrunmount
-
package dockerfile2llb
import (
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_secrets.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_secrets.go
index 59c055a..2c88a5e 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_secrets.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_secrets.go
@@ -1,5 +1,3 @@
-// +build dfsecrets
-
package dockerfile2llb
import (
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_ssh.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_ssh.go
index a29b535..b55659d 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_ssh.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert_ssh.go
@@ -1,5 +1,3 @@
-// +build dfssh
-
package dockerfile2llb
import (
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell.go
new file mode 100644
index 0000000..58b1737
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell.go
@@ -0,0 +1,8 @@
+package dockerfile2llb
+
+func defaultShell(os string) []string {
+ if os == "windows" {
+ return []string{"cmd", "/S", "/C"}
+ }
+ return []string{"/bin/sh", "-c"}
+}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell_unix.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell_unix.go
deleted file mode 100644
index b5d541d..0000000
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell_unix.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build !windows
-
-package dockerfile2llb
-
-func defaultShell() []string {
- return []string{"/bin/sh", "-c"}
-}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell_windows.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell_windows.go
deleted file mode 100644
index 7693e05..0000000
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/defaultshell_windows.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build windows
-
-package dockerfile2llb
-
-func defaultShell() []string {
- return []string{"cmd", "/S", "/C"}
-}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/image.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/image.go
index 55e9add..6eb4cf6 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/image.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/image.go
@@ -74,6 +74,6 @@
}
img.RootFS.Type = "layers"
img.Config.WorkingDir = "/"
- img.Config.Env = []string{"PATH=" + system.DefaultPathEnv}
+ img.Config.Env = []string{"PATH=" + system.DefaultPathEnv(platform.OS)}
return img
}
diff --git a/builder/dockerignore/dockerignore.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerignore/dockerignore.go
similarity index 94%
rename from builder/dockerignore/dockerignore.go
rename to vendor/github.com/moby/buildkit/frontend/dockerfile/dockerignore/dockerignore.go
index 57f224a..cc22381 100644
--- a/builder/dockerignore/dockerignore.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerignore/dockerignore.go
@@ -1,4 +1,4 @@
-package dockerignore // import "github.com/docker/docker/builder/dockerignore"
+package dockerignore
import (
"bufio"
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go
index 4a4146a..e602744 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands.go
@@ -21,8 +21,9 @@
// KeyValuePairOptional is the same as KeyValuePair but Value is optional
type KeyValuePairOptional struct {
- Key string
- Value *string
+ Key string
+ Value *string
+ Comment string
}
func (kvpo *KeyValuePairOptional) ValueString() string {
@@ -380,22 +381,25 @@
// Dockerfile author may optionally set a default value of this variable.
type ArgCommand struct {
withNameAndCode
- KeyValuePairOptional
+ Args []KeyValuePairOptional
}
// Expand variables
func (c *ArgCommand) Expand(expander SingleWordExpander) error {
- p, err := expander(c.Key)
- if err != nil {
- return err
- }
- c.Key = p
- if c.Value != nil {
- p, err = expander(*c.Value)
+ for i, v := range c.Args {
+ p, err := expander(v.Key)
if err != nil {
return err
}
- c.Value = &p
+ v.Key = p
+ if v.Value != nil {
+ p, err = expander(*v.Value)
+ if err != nil {
+ return err
+ }
+ v.Value = &p
+ }
+ c.Args[i] = v
}
return nil
}
@@ -416,6 +420,7 @@
SourceCode string
Platform string
Location []parser.Range
+ Comment string
}
// AddCommand to the stage
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_nosecrets.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_nosecrets.go
deleted file mode 100644
index 5878064..0000000
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_nosecrets.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build !dfsecrets
-
-package instructions
-
-func isSecretMountsSupported() bool {
- return false
-}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_nossh.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_nossh.go
deleted file mode 100644
index a131a27..0000000
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_nossh.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build !dfssh
-
-package instructions
-
-func isSSHMountsSupported() bool {
- return false
-}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go
index 442877d..b0b0f01 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go
@@ -1,5 +1,3 @@
-// +build dfrunmount
-
package instructions
import (
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_secrets.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_secrets.go
index 6cce119..2b4140b 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_secrets.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_secrets.go
@@ -1,5 +1,3 @@
-// +build dfsecrets
-
package instructions
func isSecretMountsSupported() bool {
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_ssh.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_ssh.go
index 0b94a56..0e4e5f3 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_ssh.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_ssh.go
@@ -1,5 +1,3 @@
-// +build dfssh
-
package instructions
func isSSHMountsSupported() bool {
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go
index 1be9d7b..83cab66 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/parse.go
@@ -22,6 +22,7 @@
flags *BFlags
original string
location []parser.Range
+ comments []string
}
var parseRunPreHooks []func(*RunCommand, parseRequest) error
@@ -50,6 +51,7 @@
original: node.Original,
flags: NewBFlagsWithArgs(node.Flags),
location: node.Location(),
+ comments: node.PrevComment,
}
}
@@ -289,6 +291,7 @@
Commands: []Command{},
Platform: flPlatform.Value,
Location: req.location,
+ Comment: getComment(req.comments, stageName),
}, nil
}
@@ -579,33 +582,38 @@
}
func parseArg(req parseRequest) (*ArgCommand, error) {
- if len(req.args) != 1 {
- return nil, errExactlyOneArgument("ARG")
+ if len(req.args) < 1 {
+ return nil, errAtLeastOneArgument("ARG")
}
- kvpo := KeyValuePairOptional{}
+ pairs := make([]KeyValuePairOptional, len(req.args))
- arg := req.args[0]
- // 'arg' can just be a name or name-value pair. Note that this is different
- // from 'env' that handles the split of name and value at the parser level.
- // The reason for doing it differently for 'arg' is that we support just
- // defining an arg and not assign it a value (while 'env' always expects a
- // name-value pair). If possible, it will be good to harmonize the two.
- if strings.Contains(arg, "=") {
- parts := strings.SplitN(arg, "=", 2)
- if len(parts[0]) == 0 {
- return nil, errBlankCommandNames("ARG")
+ for i, arg := range req.args {
+ kvpo := KeyValuePairOptional{}
+
+ // 'arg' can just be a name or name-value pair. Note that this is different
+ // from 'env' that handles the split of name and value at the parser level.
+ // The reason for doing it differently for 'arg' is that we support just
+ // defining an arg and not assign it a value (while 'env' always expects a
+ // name-value pair). If possible, it will be good to harmonize the two.
+ if strings.Contains(arg, "=") {
+ parts := strings.SplitN(arg, "=", 2)
+ if len(parts[0]) == 0 {
+ return nil, errBlankCommandNames("ARG")
+ }
+
+ kvpo.Key = parts[0]
+ kvpo.Value = &parts[1]
+ } else {
+ kvpo.Key = arg
}
-
- kvpo.Key = parts[0]
- kvpo.Value = &parts[1]
- } else {
- kvpo.Key = arg
+ kvpo.Comment = getComment(req.comments, kvpo.Key)
+ pairs[i] = kvpo
}
return &ArgCommand{
- KeyValuePairOptional: kvpo,
- withNameAndCode: newWithNameAndCode(req),
+ Args: pairs,
+ withNameAndCode: newWithNameAndCode(req),
}, nil
}
@@ -650,3 +658,15 @@
func errTooManyArguments(command string) error {
return errors.Errorf("Bad input to %s, too many arguments", command)
}
+
+func getComment(comments []string, name string) string {
+ if name == "" {
+ return ""
+ }
+ for _, line := range comments {
+ if strings.HasPrefix(line, name+" ") {
+ return strings.TrimPrefix(line, name+" ")
+ }
+ }
+ return ""
+}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go
index 441824c..c0d0a55 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/line_parsers.go
@@ -40,7 +40,7 @@
return nil, nil, nil
}
- child, err := newNodeFromLine(rest, d)
+ child, err := newNodeFromLine(rest, d, nil)
if err != nil {
return nil, nil, err
}
diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go
index dc6d178..1e30e20 100644
--- a/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go
+++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/parser/parser.go
@@ -28,14 +28,15 @@
// works a little more effectively than a "proper" parse tree for our needs.
//
type Node struct {
- Value string // actual content
- Next *Node // the next item in the current sexp
- Children []*Node // the children of this sexp
- Attributes map[string]bool // special attributes for this node
- Original string // original line used before parsing
- Flags []string // only top Node should have this set
- StartLine int // the line in the original dockerfile where the node begins
- EndLine int // the line in the original dockerfile where the node ends
+ Value string // actual content
+ Next *Node // the next item in the current sexp
+ Children []*Node // the children of this sexp
+ Attributes map[string]bool // special attributes for this node
+ Original string // original line used before parsing
+ Flags []string // only top Node should have this set
+ StartLine int // the line in the original dockerfile where the node begins
+ EndLine int // the line in the original dockerfile where the node ends
+ PrevComment []string
}
// Location return the location of node in source code
@@ -107,13 +108,25 @@
seen map[string]struct{} // Whether the escape directive has been seen
}
-// setEscapeToken sets the default token for escaping characters in a Dockerfile.
+// setEscapeToken sets the default token for escaping characters and as line-
+// continuation token in a Dockerfile. Only ` (backtick) and \ (backslash) are
+// allowed as token.
func (d *directives) setEscapeToken(s string) error {
- if s != "`" && s != "\\" {
+ if s != "`" && s != `\` {
return errors.Errorf("invalid escape token '%s' does not match ` or \\", s)
}
d.escapeToken = rune(s[0])
- d.lineContinuationRegex = regexp.MustCompile(`\` + s + `[ \t]*$`)
+ // The escape token is used both to escape characters in a line and as line
+ // continuation token. If it's the last non-whitespace token, it is used as
+ // line-continuation token, *unless* preceded by an escape-token.
+ //
+ // The second branch in the regular expression handles line-continuation
+ // tokens on their own line, which don't have any character preceding them.
+ //
+ // Due to Go lacking negative look-ahead matching, this regular expression
+ // does not currently handle a line-continuation token preceded by an *escaped*
+ // escape-token ("foo \\\").
+ d.lineContinuationRegex = regexp.MustCompile(`([^\` + s + `])\` + s + `[ \t]*$|^\` + s + `[ \t]*$`)
return nil
}
@@ -191,7 +204,7 @@
// newNodeFromLine splits the line into parts, and dispatches to a function
// based on the command and command arguments. A Node is created from the
// result of the dispatch.
-func newNodeFromLine(line string, d *directives) (*Node, error) {
+func newNodeFromLine(line string, d *directives, comments []string) (*Node, error) {
cmd, flags, args, err := splitCommand(line)
if err != nil {
return nil, err
@@ -208,11 +221,12 @@
}
return &Node{
- Value: cmd,
- Original: line,
- Flags: flags,
- Next: next,
- Attributes: attrs,
+ Value: cmd,
+ Original: line,
+ Flags: flags,
+ Next: next,
+ Attributes: attrs,
+ PrevComment: comments,
}, nil
}
@@ -239,6 +253,7 @@
root := &Node{StartLine: -1}
scanner := bufio.NewScanner(rwc)
warnings := []string{}
+ var comments []string
var err error
for scanner.Scan() {
@@ -247,6 +262,14 @@
// First line, strip the byte-order-marker if present
bytesRead = bytes.TrimPrefix(bytesRead, utf8bom)
}
+ if isComment(bytesRead) {
+ comment := strings.TrimSpace(string(bytesRead[1:]))
+ if comment == "" {
+ comments = nil
+ } else {
+ comments = append(comments, comment)
+ }
+ }
bytesRead, err = processLine(d, bytesRead, true)
if err != nil {
return nil, withLocation(err, currentLine, 0)
@@ -285,10 +308,11 @@
warnings = append(warnings, "[WARNING]: Empty continuation line found in:\n "+line)
}
- child, err := newNodeFromLine(line, d)
+ child, err := newNodeFromLine(line, d, comments)
if err != nil {
return nil, withLocation(err, startLine, currentLine)
}
+ comments = nil
root.AddChild(child, startLine, currentLine)
}
@@ -327,7 +351,7 @@
func trimContinuationCharacter(line string, d *directives) (string, bool) {
if d.lineContinuationRegex.MatchString(line) {
- line = d.lineContinuationRegex.ReplaceAllString(line, "")
+ line = d.lineContinuationRegex.ReplaceAllString(line, "$1")
return line, false
}
return line, true
diff --git a/vendor/github.com/moby/buildkit/frontend/frontend.go b/vendor/github.com/moby/buildkit/frontend/frontend.go
index e55b6af..fea8e14 100644
--- a/vendor/github.com/moby/buildkit/frontend/frontend.go
+++ b/vendor/github.com/moby/buildkit/frontend/frontend.go
@@ -7,12 +7,13 @@
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/executor"
gw "github.com/moby/buildkit/frontend/gateway/client"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver/pb"
digest "github.com/opencontainers/go-digest"
)
type Frontend interface {
- Solve(ctx context.Context, llb FrontendLLBBridge, opt map[string]string, inputs map[string]*pb.Definition, sid string) (*Result, error)
+ Solve(ctx context.Context, llb FrontendLLBBridge, opt map[string]string, inputs map[string]*pb.Definition, sid string, sm *session.Manager) (*Result, error)
}
type FrontendLLBBridge interface {
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/client/client.go b/vendor/github.com/moby/buildkit/frontend/gateway/client/client.go
index bc7f96b..9f0b7f0 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/client/client.go
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/client/client.go
@@ -2,6 +2,7 @@
import (
"context"
+ "io"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/solver/pb"
@@ -16,6 +17,63 @@
ResolveImageConfig(ctx context.Context, ref string, opt llb.ResolveImageConfigOpt) (digest.Digest, []byte, error)
BuildOpts() BuildOpts
Inputs(ctx context.Context) (map[string]llb.State, error)
+ NewContainer(ctx context.Context, req NewContainerRequest) (Container, error)
+}
+
+// NewContainerRequest encapsulates the requirements for a client to define a
+// new container, without defining the initial process.
+type NewContainerRequest struct {
+ Mounts []Mount
+ NetMode pb.NetMode
+ Platform *pb.Platform
+ Constraints *pb.WorkerConstraints
+}
+
+// Mount allows clients to specify a filesystem mount. A Reference to a
+// previously solved Result is required.
+type Mount struct {
+ Selector string
+ Dest string
+ Ref Reference
+ Readonly bool
+ MountType pb.MountType
+ CacheOpt *pb.CacheOpt
+ SecretOpt *pb.SecretOpt
+ SSHOpt *pb.SSHOpt
+}
+
+// Container is used to start new processes inside a container and release the
+// container resources when done.
+type Container interface {
+ Start(context.Context, StartRequest) (ContainerProcess, error)
+ Release(context.Context) error
+}
+
+// StartRequest encapsulates the arguments to define a process within a
+// container.
+type StartRequest struct {
+ Args []string
+ Env []string
+ User string
+ Cwd string
+ Tty bool
+ Stdin io.ReadCloser
+ Stdout, Stderr io.WriteCloser
+ SecurityMode pb.SecurityMode
+}
+
+// WinSize is same as executor.WinSize, copied here to prevent circular package
+// dependencies.
+type WinSize struct {
+ Rows uint32
+ Cols uint32
+}
+
+// ContainerProcess represents a process within a container.
+type ContainerProcess interface {
+ Wait() error
+ Resize(ctx context.Context, size WinSize) error
+ // TODO Signal(ctx context.Context, sig os.Signal)
}
type Reference interface {
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/container.go b/vendor/github.com/moby/buildkit/frontend/gateway/container.go
new file mode 100644
index 0000000..0aad15e
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/container.go
@@ -0,0 +1,373 @@
+package gateway
+
+import (
+ "context"
+ "fmt"
+ "runtime"
+ "sort"
+ "strings"
+ "sync"
+
+ "github.com/moby/buildkit/cache"
+ "github.com/moby/buildkit/executor"
+ "github.com/moby/buildkit/frontend/gateway/client"
+ "github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/snapshot"
+ "github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/solver/llbsolver/mounts"
+ opspb "github.com/moby/buildkit/solver/pb"
+ "github.com/moby/buildkit/util/stack"
+ utilsystem "github.com/moby/buildkit/util/system"
+ "github.com/moby/buildkit/worker"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+ "golang.org/x/sync/errgroup"
+)
+
+type NewContainerRequest struct {
+ ContainerID string
+ NetMode opspb.NetMode
+ Mounts []Mount
+ Platform *opspb.Platform
+ Constraints *opspb.WorkerConstraints
+}
+
+// Mount used for the gateway.Container is nearly identical to the client.Mount
+// except is has a RefProxy instead of Ref to allow for a common abstraction
+// between gateway clients.
+type Mount struct {
+ Dest string
+ Selector string
+ Readonly bool
+ MountType opspb.MountType
+ RefProxy solver.ResultProxy
+ CacheOpt *opspb.CacheOpt
+ SecretOpt *opspb.SecretOpt
+ SSHOpt *opspb.SSHOpt
+}
+
+func toProtoMount(m Mount) *opspb.Mount {
+ return &opspb.Mount{
+ Selector: m.Selector,
+ Dest: m.Dest,
+ Readonly: m.Readonly,
+ MountType: m.MountType,
+ CacheOpt: m.CacheOpt,
+ SecretOpt: m.SecretOpt,
+ SSHOpt: m.SSHOpt,
+ }
+}
+
+func NewContainer(ctx context.Context, e executor.Executor, sm *session.Manager, g session.Group, req NewContainerRequest) (client.Container, error) {
+ ctx, cancel := context.WithCancel(ctx)
+ eg, ctx := errgroup.WithContext(ctx)
+ platform := opspb.Platform{
+ OS: runtime.GOOS,
+ Architecture: runtime.GOARCH,
+ }
+ if req.Platform != nil {
+ platform = *req.Platform
+ }
+ ctr := &gatewayContainer{
+ id: req.ContainerID,
+ netMode: req.NetMode,
+ platform: platform,
+ executor: e,
+ errGroup: eg,
+ ctx: ctx,
+ cancel: cancel,
+ }
+
+ makeMutable := func(worker worker.Worker, ref cache.ImmutableRef) (cache.MutableRef, error) {
+ mRef, err := worker.CacheManager().New(ctx, ref, g)
+ if err != nil {
+ return nil, stack.Enable(err)
+ }
+ ctr.cleanup = append(ctr.cleanup, func() error {
+ return stack.Enable(mRef.Release(context.TODO()))
+ })
+ return mRef, nil
+ }
+
+ var mm *mounts.MountManager
+ mnts := req.Mounts
+
+ for i, m := range mnts {
+ if m.Dest == opspb.RootMount && m.RefProxy != nil {
+ res, err := m.RefProxy.Result(ctx)
+ if err != nil {
+ return nil, stack.Enable(err)
+ }
+ workerRef, ok := res.Sys().(*worker.WorkerRef)
+ if !ok {
+ return nil, errors.Errorf("invalid reference for exec %T", res.Sys())
+ }
+
+ name := fmt.Sprintf("container %s", req.ContainerID)
+ mm = mounts.NewMountManager(name, workerRef.Worker.CacheManager(), sm, workerRef.Worker.MetadataStore())
+
+ ctr.rootFS = mountWithSession(workerRef.ImmutableRef, g)
+ if !m.Readonly {
+ ref, err := makeMutable(workerRef.Worker, workerRef.ImmutableRef)
+ if err != nil {
+ return nil, stack.Enable(err)
+ }
+ ctr.rootFS = mountWithSession(ref, g)
+ }
+
+ // delete root mount from list, handled here
+ mnts = append(mnts[:i], mnts[i+1:]...)
+ break
+ }
+ }
+
+ if ctr.rootFS.Src == nil {
+ return nil, errors.Errorf("root mount required")
+ }
+
+ for _, m := range mnts {
+ var ref cache.ImmutableRef
+ var mountable cache.Mountable
+ if m.RefProxy != nil {
+ res, err := m.RefProxy.Result(ctx)
+ if err != nil {
+ return nil, stack.Enable(err)
+ }
+ workerRef, ok := res.Sys().(*worker.WorkerRef)
+ if !ok {
+ return nil, errors.Errorf("invalid reference for exec %T", res.Sys())
+ }
+ ref = workerRef.ImmutableRef
+ mountable = ref
+
+ if !m.Readonly {
+ mountable, err = makeMutable(workerRef.Worker, ref)
+ if err != nil {
+ return nil, stack.Enable(err)
+ }
+ }
+ }
+ switch m.MountType {
+ case opspb.MountType_BIND:
+ // nothing to do here
+ case opspb.MountType_CACHE:
+ mRef, err := mm.MountableCache(ctx, toProtoMount(m), ref, g)
+ if err != nil {
+ return nil, err
+ }
+ mountable = mRef
+ ctr.cleanup = append(ctr.cleanup, func() error {
+ return stack.Enable(mRef.Release(context.TODO()))
+ })
+ case opspb.MountType_TMPFS:
+ mountable = mm.MountableTmpFS()
+ case opspb.MountType_SECRET:
+ var err error
+ mountable, err = mm.MountableSecret(ctx, toProtoMount(m), g)
+ if err != nil {
+ return nil, err
+ }
+ if mountable == nil {
+ continue
+ }
+ case opspb.MountType_SSH:
+ var err error
+ mountable, err = mm.MountableSSH(ctx, toProtoMount(m), g)
+ if err != nil {
+ return nil, err
+ }
+ if mountable == nil {
+ continue
+ }
+ default:
+ return nil, errors.Errorf("mount type %s not implemented", m.MountType)
+ }
+
+ // validate that there is a mount
+ if mountable == nil {
+ return nil, errors.Errorf("mount %s has no input", m.Dest)
+ }
+
+ execMount := executor.Mount{
+ Src: mountableWithSession(mountable, g),
+ Selector: m.Selector,
+ Dest: m.Dest,
+ Readonly: m.Readonly,
+ }
+
+ ctr.mounts = append(ctr.mounts, execMount)
+ }
+
+ // sort mounts so parents are mounted first
+ sort.Slice(ctr.mounts, func(i, j int) bool {
+ return ctr.mounts[i].Dest < ctr.mounts[j].Dest
+ })
+
+ return ctr, nil
+}
+
+type gatewayContainer struct {
+ id string
+ netMode opspb.NetMode
+ platform opspb.Platform
+ rootFS executor.Mount
+ mounts []executor.Mount
+ executor executor.Executor
+ started bool
+ errGroup *errgroup.Group
+ mu sync.Mutex
+ cleanup []func() error
+ ctx context.Context
+ cancel func()
+}
+
+func (gwCtr *gatewayContainer) Start(ctx context.Context, req client.StartRequest) (client.ContainerProcess, error) {
+ resize := make(chan executor.WinSize)
+ procInfo := executor.ProcessInfo{
+ Meta: executor.Meta{
+ Args: req.Args,
+ Env: req.Env,
+ User: req.User,
+ Cwd: req.Cwd,
+ Tty: req.Tty,
+ NetMode: gwCtr.netMode,
+ SecurityMode: req.SecurityMode,
+ },
+ Stdin: req.Stdin,
+ Stdout: req.Stdout,
+ Stderr: req.Stderr,
+ Resize: resize,
+ }
+ if procInfo.Meta.Cwd == "" {
+ procInfo.Meta.Cwd = "/"
+ }
+ procInfo.Meta.Env = addDefaultEnvvar(procInfo.Meta.Env, "PATH", utilsystem.DefaultPathEnv(gwCtr.platform.OS))
+ if req.Tty {
+ procInfo.Meta.Env = addDefaultEnvvar(procInfo.Meta.Env, "TERM", "xterm")
+ }
+
+ // mark that we have started on the first call to execProcess for this
+ // container, so that future calls will call Exec rather than Run
+ gwCtr.mu.Lock()
+ started := gwCtr.started
+ gwCtr.started = true
+ gwCtr.mu.Unlock()
+
+ eg, ctx := errgroup.WithContext(gwCtr.ctx)
+ gwProc := &gatewayContainerProcess{
+ resize: resize,
+ errGroup: eg,
+ groupCtx: ctx,
+ }
+
+ if !started {
+ startedCh := make(chan struct{})
+ gwProc.errGroup.Go(func() error {
+ logrus.Debugf("Starting new container for %s with args: %q", gwCtr.id, procInfo.Meta.Args)
+ err := gwCtr.executor.Run(ctx, gwCtr.id, gwCtr.rootFS, gwCtr.mounts, procInfo, startedCh)
+ return stack.Enable(err)
+ })
+ select {
+ case <-ctx.Done():
+ case <-startedCh:
+ }
+ } else {
+ gwProc.errGroup.Go(func() error {
+ logrus.Debugf("Execing into container %s with args: %q", gwCtr.id, procInfo.Meta.Args)
+ err := gwCtr.executor.Exec(ctx, gwCtr.id, procInfo)
+ return stack.Enable(err)
+ })
+ }
+
+ gwCtr.errGroup.Go(gwProc.errGroup.Wait)
+
+ return gwProc, nil
+}
+
+func (gwCtr *gatewayContainer) Release(ctx context.Context) error {
+ gwCtr.cancel()
+ err1 := gwCtr.errGroup.Wait()
+
+ var err2 error
+ for i := len(gwCtr.cleanup) - 1; i >= 0; i-- { // call in LIFO order
+ err := gwCtr.cleanup[i]()
+ if err2 == nil {
+ err2 = err
+ }
+ }
+
+ if err1 != nil {
+ return stack.Enable(err1)
+ }
+ return stack.Enable(err2)
+}
+
+type gatewayContainerProcess struct {
+ errGroup *errgroup.Group
+ groupCtx context.Context
+ resize chan<- executor.WinSize
+ mu sync.Mutex
+}
+
+func (gwProc *gatewayContainerProcess) Wait() error {
+ err := stack.Enable(gwProc.errGroup.Wait())
+ gwProc.mu.Lock()
+ defer gwProc.mu.Unlock()
+ close(gwProc.resize)
+ return err
+}
+
+func (gwProc *gatewayContainerProcess) Resize(ctx context.Context, size client.WinSize) error {
+ gwProc.mu.Lock()
+ defer gwProc.mu.Unlock()
+
+ // is the container done or should we proceed with sending event?
+ select {
+ case <-gwProc.groupCtx.Done():
+ return nil
+ case <-ctx.Done():
+ return nil
+ default:
+ }
+
+ // now we select on contexts again in case p.resize blocks b/c
+ // container no longer reading from it. In that case when
+ // the errgroup finishes we want to unblock on the write
+ // and exit
+ select {
+ case <-gwProc.groupCtx.Done():
+ case <-ctx.Done():
+ case gwProc.resize <- executor.WinSize{Cols: size.Cols, Rows: size.Rows}:
+ }
+ return nil
+}
+
+func addDefaultEnvvar(env []string, k, v string) []string {
+ for _, e := range env {
+ if strings.HasPrefix(e, k+"=") {
+ return env
+ }
+ }
+ return append(env, k+"="+v)
+}
+
+func mountWithSession(m cache.Mountable, g session.Group) executor.Mount {
+ _, readonly := m.(cache.ImmutableRef)
+ return executor.Mount{
+ Src: mountableWithSession(m, g),
+ Readonly: readonly,
+ }
+}
+
+func mountableWithSession(m cache.Mountable, g session.Group) executor.Mountable {
+ return &mountable{m: m, g: g}
+}
+
+type mountable struct {
+ m cache.Mountable
+ g session.Group
+}
+
+func (m *mountable) Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error) {
+ return m.m.Mount(ctx, readonly, m.g)
+}
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/forwarder/forward.go b/vendor/github.com/moby/buildkit/frontend/gateway/forwarder/forward.go
index 241be88..368787f 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/forwarder/forward.go
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/forwarder/forward.go
@@ -4,13 +4,16 @@
"context"
"sync"
- "github.com/moby/buildkit/cache"
cacheutil "github.com/moby/buildkit/cache/util"
clienttypes "github.com/moby/buildkit/client"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/frontend"
+ "github.com/moby/buildkit/frontend/gateway"
"github.com/moby/buildkit/frontend/gateway/client"
gwpb "github.com/moby/buildkit/frontend/gateway/pb"
+ "github.com/moby/buildkit/identity"
+ "github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/solver"
opspb "github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/apicaps"
@@ -19,12 +22,13 @@
fstypes "github.com/tonistiigi/fsutil/types"
)
-func llbBridgeToGatewayClient(ctx context.Context, llbBridge frontend.FrontendLLBBridge, opts map[string]string, inputs map[string]*opspb.Definition, workerInfos []clienttypes.WorkerInfo, sid string) (*bridgeClient, error) {
+func llbBridgeToGatewayClient(ctx context.Context, llbBridge frontend.FrontendLLBBridge, opts map[string]string, inputs map[string]*opspb.Definition, workerInfos []clienttypes.WorkerInfo, sid string, sm *session.Manager) (*bridgeClient, error) {
return &bridgeClient{
opts: opts,
inputs: inputs,
FrontendLLBBridge: llbBridge,
sid: sid,
+ sm: sm,
workerInfos: workerInfos,
final: map[*ref]struct{}{},
}, nil
@@ -32,14 +36,14 @@
type bridgeClient struct {
frontend.FrontendLLBBridge
- mu sync.Mutex
- opts map[string]string
- inputs map[string]*opspb.Definition
- final map[*ref]struct{}
- sid string
- exporterAttr map[string][]byte
- refs []*ref
- workerInfos []clienttypes.WorkerInfo
+ mu sync.Mutex
+ opts map[string]string
+ inputs map[string]*opspb.Definition
+ final map[*ref]struct{}
+ sid string
+ sm *session.Manager
+ refs []*ref
+ workerInfos []clienttypes.WorkerInfo
}
func (c *bridgeClient) Solve(ctx context.Context, req client.SolveRequest) (*client.Result, error) {
@@ -57,7 +61,7 @@
cRes := &client.Result{}
c.mu.Lock()
for k, r := range res.Refs {
- rr, err := newRef(r)
+ rr, err := newRef(r, session.NewGroup(c.sid))
if err != nil {
return nil, err
}
@@ -65,7 +69,7 @@
cRes.AddRef(k, rr)
}
if r := res.Ref; r != nil {
- rr, err := newRef(r)
+ rr, err := newRef(r, session.NewGroup(c.sid))
if err != nil {
return nil, err
}
@@ -150,12 +154,48 @@
}
}
-type ref struct {
- solver.ResultProxy
+func (c *bridgeClient) NewContainer(ctx context.Context, req client.NewContainerRequest) (client.Container, error) {
+ ctrReq := gateway.NewContainerRequest{
+ ContainerID: identity.NewID(),
+ NetMode: req.NetMode,
+ }
+
+ for _, m := range req.Mounts {
+ var refProxy solver.ResultProxy
+ if m.Ref != nil {
+ var ok bool
+ refProxy, ok = m.Ref.(*ref)
+ if !ok {
+ return nil, errors.Errorf("unexpected Ref type: %T", m.Ref)
+ }
+ }
+ ctrReq.Mounts = append(ctrReq.Mounts, gateway.Mount{
+ Dest: m.Dest,
+ Selector: m.Selector,
+ Readonly: m.Readonly,
+ MountType: m.MountType,
+ RefProxy: refProxy,
+ CacheOpt: m.CacheOpt,
+ SecretOpt: m.SecretOpt,
+ SSHOpt: m.SSHOpt,
+ })
+ }
+
+ group := session.NewGroup(c.sid)
+ ctr, err := gateway.NewContainer(ctx, c, c.sm, group, ctrReq)
+ if err != nil {
+ return nil, err
+ }
+ return ctr, nil
}
-func newRef(r solver.ResultProxy) (*ref, error) {
- return &ref{ResultProxy: r}, nil
+type ref struct {
+ solver.ResultProxy
+ session session.Group
+}
+
+func newRef(r solver.ResultProxy, s session.Group) (*ref, error) {
+ return &ref{ResultProxy: r, session: s}, nil
}
func (r *ref) ToState() (st llb.State, err error) {
@@ -167,7 +207,7 @@
}
func (r *ref) ReadFile(ctx context.Context, req client.ReadRequest) ([]byte, error) {
- ref, err := r.getImmutableRef(ctx)
+ m, err := r.getMountable(ctx)
if err != nil {
return nil, err
}
@@ -180,11 +220,11 @@
Length: r.Length,
}
}
- return cacheutil.ReadFile(ctx, ref, newReq)
+ return cacheutil.ReadFile(ctx, m, newReq)
}
func (r *ref) ReadDir(ctx context.Context, req client.ReadDirRequest) ([]*fstypes.Stat, error) {
- ref, err := r.getImmutableRef(ctx)
+ m, err := r.getMountable(ctx)
if err != nil {
return nil, err
}
@@ -192,18 +232,18 @@
Path: req.Path,
IncludePattern: req.IncludePattern,
}
- return cacheutil.ReadDir(ctx, ref, newReq)
+ return cacheutil.ReadDir(ctx, m, newReq)
}
func (r *ref) StatFile(ctx context.Context, req client.StatRequest) (*fstypes.Stat, error) {
- ref, err := r.getImmutableRef(ctx)
+ m, err := r.getMountable(ctx)
if err != nil {
return nil, err
}
- return cacheutil.StatFile(ctx, ref, req.Path)
+ return cacheutil.StatFile(ctx, m, req.Path)
}
-func (r *ref) getImmutableRef(ctx context.Context) (cache.ImmutableRef, error) {
+func (r *ref) getMountable(ctx context.Context) (snapshot.Mountable, error) {
rr, err := r.ResultProxy.Result(ctx)
if err != nil {
return nil, err
@@ -212,5 +252,5 @@
if !ok {
return nil, errors.Errorf("invalid ref: %T", rr.Sys())
}
- return ref.ImmutableRef, nil
+ return ref.ImmutableRef.Mount(ctx, true, r.session)
}
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/forwarder/frontend.go b/vendor/github.com/moby/buildkit/frontend/gateway/forwarder/frontend.go
index 571aff8..9a6d602 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/forwarder/frontend.go
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/forwarder/frontend.go
@@ -5,6 +5,7 @@
"github.com/moby/buildkit/frontend"
"github.com/moby/buildkit/frontend/gateway/client"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver/pb"
)
@@ -20,8 +21,8 @@
f client.BuildFunc
}
-func (gf *GatewayForwarder) Solve(ctx context.Context, llbBridge frontend.FrontendLLBBridge, opts map[string]string, inputs map[string]*pb.Definition, sid string) (retRes *frontend.Result, retErr error) {
- c, err := llbBridgeToGatewayClient(ctx, llbBridge, opts, inputs, gf.workers.WorkerInfos(), sid)
+func (gf *GatewayForwarder) Solve(ctx context.Context, llbBridge frontend.FrontendLLBBridge, opts map[string]string, inputs map[string]*pb.Definition, sid string, sm *session.Manager) (retRes *frontend.Result, retErr error) {
+ c, err := llbBridgeToGatewayClient(ctx, llbBridge, opts, inputs, gf.workers.WorkerInfos(), sid, sm)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/gateway.go b/vendor/github.com/moby/buildkit/frontend/gateway/gateway.go
index f2305e0..55aae03 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/gateway.go
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/gateway.go
@@ -12,7 +12,9 @@
"sync"
"time"
+ "github.com/containerd/containerd"
"github.com/docker/distribution/reference"
+ "github.com/gogo/googleapis/google/rpc"
gogotypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/any"
apitypes "github.com/moby/buildkit/api/types"
@@ -23,20 +25,27 @@
"github.com/moby/buildkit/executor"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/frontend"
+ gwclient "github.com/moby/buildkit/frontend/gateway/client"
pb "github.com/moby/buildkit/frontend/gateway/pb"
"github.com/moby/buildkit/identity"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/solver/errdefs"
opspb "github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/apicaps"
"github.com/moby/buildkit/util/grpcerrors"
+ "github.com/moby/buildkit/util/stack"
"github.com/moby/buildkit/util/tracing"
"github.com/moby/buildkit/worker"
+ "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/net/http2"
+ "golang.org/x/sync/errgroup"
spb "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
"google.golang.org/grpc/health"
"google.golang.org/grpc/health/grpc_health_v1"
"google.golang.org/grpc/status"
@@ -67,7 +76,7 @@
return m
}
-func (gf *gatewayFrontend) Solve(ctx context.Context, llbBridge frontend.FrontendLLBBridge, opts map[string]string, inputs map[string]*opspb.Definition, sid string) (*frontend.Result, error) {
+func (gf *gatewayFrontend) Solve(ctx context.Context, llbBridge frontend.FrontendLLBBridge, opts map[string]string, inputs map[string]*opspb.Definition, sid string, sm *session.Manager) (*frontend.Result, error) {
source, ok := opts[keySource]
if !ok {
return nil, errors.Errorf("no source specified for gateway")
@@ -75,6 +84,7 @@
_, isDevel := opts[keyDevel]
var img specs.Image
+ var mfstDigest digest.Digest
var rootFS cache.MutableRef
var readonly bool // TODO: try to switch to read-only by default.
@@ -105,7 +115,7 @@
return nil, errors.Errorf("invalid ref: %T", res.Sys())
}
- rootFS, err = workerRef.Worker.CacheManager().New(ctx, workerRef.ImmutableRef)
+ rootFS, err = workerRef.Worker.CacheManager().New(ctx, workerRef.ImmutableRef, session.NewGroup(sid))
if err != nil {
return nil, err
}
@@ -126,6 +136,7 @@
if err != nil {
return nil, err
}
+ mfstDigest = dgst
if err := json.Unmarshal(config, &img); err != nil {
return nil, err
@@ -168,19 +179,13 @@
if !ok {
return nil, errors.Errorf("invalid ref: %T", r.Sys())
}
- rootFS, err = workerRef.Worker.CacheManager().New(ctx, workerRef.ImmutableRef)
+ rootFS, err = workerRef.Worker.CacheManager().New(ctx, workerRef.ImmutableRef, session.NewGroup(sid))
if err != nil {
return nil, err
}
defer rootFS.Release(context.TODO())
}
- lbf, ctx, err := newLLBBridgeForwarder(ctx, llbBridge, gf.workers, inputs, sid)
- defer lbf.conn.Close()
- if err != nil {
- return nil, err
- }
-
args := []string{"/run"}
env := []string{}
cwd := "/"
@@ -207,8 +212,6 @@
}
env = append(env, "BUILDKIT_WORKERS="+string(dt))
- defer lbf.Discard()
-
env = append(env, "BUILDKIT_EXPORTEDPRODUCT="+apicaps.ExportedProduct)
meta := executor.Meta{
@@ -224,7 +227,27 @@
}
}
- err = llbBridge.Run(ctx, "", rootFS, nil, executor.ProcessInfo{Meta: meta, Stdin: lbf.Stdin, Stdout: lbf.Stdout, Stderr: os.Stderr}, nil)
+ curCaps := getCaps(img.Config.Labels["moby.buildkit.frontend.caps"])
+ addCapsForKnownFrontends(curCaps, mfstDigest)
+ reqCaps := getCaps(opts["frontend.caps"])
+ if len(inputs) > 0 {
+ reqCaps["moby.buildkit.frontend.inputs"] = struct{}{}
+ }
+
+ for c := range reqCaps {
+ if _, ok := curCaps[c]; !ok {
+ return nil, stack.Enable(grpcerrors.WrapCode(errdefs.NewUnsupportedFrontendCapError(c), codes.Unimplemented))
+ }
+ }
+
+ lbf, ctx, err := serveLLBBridgeForwarder(ctx, llbBridge, gf.workers, inputs, sid, sm)
+ defer lbf.conn.Close() //nolint
+ if err != nil {
+ return nil, err
+ }
+ defer lbf.Discard()
+
+ err = llbBridge.Run(ctx, "", mountWithSession(rootFS, session.NewGroup(sid)), nil, executor.ProcessInfo{Meta: meta, Stdin: lbf.Stdin, Stdout: lbf.Stdout, Stderr: os.Stderr}, nil)
if err != nil {
if errors.Is(err, context.Canceled) && lbf.isErrServerClosed {
@@ -302,7 +325,11 @@
return lbf.result, nil
}
-func NewBridgeForwarder(ctx context.Context, llbBridge frontend.FrontendLLBBridge, workers frontend.WorkerInfos, inputs map[string]*opspb.Definition, sid string) *llbBridgeForwarder {
+func NewBridgeForwarder(ctx context.Context, llbBridge frontend.FrontendLLBBridge, workers frontend.WorkerInfos, inputs map[string]*opspb.Definition, sid string, sm *session.Manager) LLBBridgeForwarder {
+ return newBridgeForwarder(ctx, llbBridge, workers, inputs, sid, sm)
+}
+
+func newBridgeForwarder(ctx context.Context, llbBridge frontend.FrontendLLBBridge, workers frontend.WorkerInfos, inputs map[string]*opspb.Definition, sid string, sm *session.Manager) *llbBridgeForwarder {
lbf := &llbBridgeForwarder{
callCtx: ctx,
llbBridge: llbBridge,
@@ -312,13 +339,15 @@
workers: workers,
inputs: inputs,
sid: sid,
+ sm: sm,
+ ctrs: map[string]gwclient.Container{},
}
return lbf
}
-func newLLBBridgeForwarder(ctx context.Context, llbBridge frontend.FrontendLLBBridge, workers frontend.WorkerInfos, inputs map[string]*opspb.Definition, sid string) (*llbBridgeForwarder, context.Context, error) {
+func serveLLBBridgeForwarder(ctx context.Context, llbBridge frontend.FrontendLLBBridge, workers frontend.WorkerInfos, inputs map[string]*opspb.Definition, sid string, sm *session.Manager) (*llbBridgeForwarder, context.Context, error) {
ctx, cancel := context.WithCancel(ctx)
- lbf := NewBridgeForwarder(ctx, llbBridge, workers, inputs, sid)
+ lbf := newBridgeForwarder(ctx, llbBridge, workers, inputs, sid, sm)
server := grpc.NewServer(grpc.UnaryInterceptor(grpcerrors.UnaryServerInterceptor), grpc.StreamInterceptor(grpcerrors.StreamServerInterceptor))
grpc_health_v1.RegisterHealthServer(server, health.NewServer())
pb.RegisterLLBBridgeServer(server, lbf)
@@ -393,6 +422,7 @@
pb.LLBBridgeServer
Done() <-chan struct{}
Result() (*frontend.Result, error)
+ Discard()
}
type llbBridgeForwarder struct {
@@ -406,12 +436,14 @@
doneCh chan struct{} // closed when result or err become valid through a call to a Return
result *frontend.Result
err error
- exporterAttr map[string][]byte
workers frontend.WorkerInfos
inputs map[string]*opspb.Definition
isErrServerClosed bool
sid string
+ sm *session.Manager
*pipe
+ ctrs map[string]gwclient.Container
+ ctrsMu sync.Mutex
}
func (lbf *llbBridgeForwarder) ResolveImageConfig(ctx context.Context, req *pb.ResolveImageConfigRequest) (*pb.ResolveImageConfigResponse, error) {
@@ -592,7 +624,12 @@
}
}
- dt, err := cacheutil.ReadFile(ctx, workerRef.ImmutableRef, newReq)
+ m, err := workerRef.ImmutableRef.Mount(ctx, true, session.NewGroup(lbf.sid))
+ if err != nil {
+ return nil, err
+ }
+
+ dt, err := cacheutil.ReadFile(ctx, m, newReq)
if err != nil {
return nil, err
}
@@ -624,7 +661,11 @@
Path: req.DirPath,
IncludePattern: req.IncludePattern,
}
- entries, err := cacheutil.ReadDir(ctx, workerRef.ImmutableRef, newReq)
+ m, err := workerRef.ImmutableRef.Mount(ctx, true, session.NewGroup(lbf.sid))
+ if err != nil {
+ return nil, err
+ }
+ entries, err := cacheutil.ReadDir(ctx, m, newReq)
if err != nil {
return nil, err
}
@@ -651,8 +692,11 @@
if !ok {
return nil, errors.Errorf("invalid ref: %T", r.Sys())
}
-
- st, err := cacheutil.StatFile(ctx, workerRef.ImmutableRef, req.Path)
+ m, err := workerRef.ImmutableRef.Mount(ctx, true, session.NewGroup(lbf.sid))
+ if err != nil {
+ return nil, err
+ }
+ st, err := cacheutil.StatFile(ctx, m, req.Path)
if err != nil {
return nil, err
}
@@ -686,47 +730,46 @@
Message: in.Error.Message,
Details: convertGogoAny(in.Error.Details),
})))
- } else {
- r := &frontend.Result{
- Metadata: in.Result.Metadata,
- }
-
- switch res := in.Result.Result.(type) {
- case *pb.Result_RefDeprecated:
- ref, err := lbf.convertRef(res.RefDeprecated)
- if err != nil {
- return nil, err
- }
- r.Ref = ref
- case *pb.Result_RefsDeprecated:
- m := map[string]solver.ResultProxy{}
- for k, id := range res.RefsDeprecated.Refs {
- ref, err := lbf.convertRef(id)
- if err != nil {
- return nil, err
- }
- m[k] = ref
- }
- r.Refs = m
- case *pb.Result_Ref:
- ref, err := lbf.convertRef(res.Ref.Id)
- if err != nil {
- return nil, err
- }
- r.Ref = ref
- case *pb.Result_Refs:
- m := map[string]solver.ResultProxy{}
- for k, ref := range res.Refs.Refs {
- ref, err := lbf.convertRef(ref.Id)
- if err != nil {
- return nil, err
- }
- m[k] = ref
- }
- r.Refs = m
- }
- return lbf.setResult(r, nil)
}
+ r := &frontend.Result{
+ Metadata: in.Result.Metadata,
+ }
+
+ switch res := in.Result.Result.(type) {
+ case *pb.Result_RefDeprecated:
+ ref, err := lbf.convertRef(res.RefDeprecated)
+ if err != nil {
+ return nil, err
+ }
+ r.Ref = ref
+ case *pb.Result_RefsDeprecated:
+ m := map[string]solver.ResultProxy{}
+ for k, id := range res.RefsDeprecated.Refs {
+ ref, err := lbf.convertRef(id)
+ if err != nil {
+ return nil, err
+ }
+ m[k] = ref
+ }
+ r.Refs = m
+ case *pb.Result_Ref:
+ ref, err := lbf.convertRef(res.Ref.Id)
+ if err != nil {
+ return nil, err
+ }
+ r.Ref = ref
+ case *pb.Result_Refs:
+ m := map[string]solver.ResultProxy{}
+ for k, ref := range res.Refs.Refs {
+ ref, err := lbf.convertRef(ref.Id)
+ if err != nil {
+ return nil, err
+ }
+ m[k] = ref
+ }
+ r.Refs = m
+ }
+ return lbf.setResult(r, nil)
}
func (lbf *llbBridgeForwarder) Inputs(ctx context.Context, in *pb.InputsRequest) (*pb.InputsResponse, error) {
@@ -735,6 +778,417 @@
}, nil
}
+func (lbf *llbBridgeForwarder) NewContainer(ctx context.Context, in *pb.NewContainerRequest) (_ *pb.NewContainerResponse, err error) {
+ logrus.Debugf("|<--- NewContainer %s", in.ContainerID)
+ ctrReq := NewContainerRequest{
+ ContainerID: in.ContainerID,
+ NetMode: in.Network,
+ Platform: in.Platform,
+ Constraints: in.Constraints,
+ }
+
+ for _, m := range in.Mounts {
+ var refProxy solver.ResultProxy
+ if m.ResultID != "" {
+ refProxy, err = lbf.convertRef(m.ResultID)
+ if err != nil {
+ return nil, errors.Wrapf(err, "failed to find ref %s for %q mount", m.ResultID, m.Dest)
+ }
+ }
+ ctrReq.Mounts = append(ctrReq.Mounts, Mount{
+ Dest: m.Dest,
+ Selector: m.Selector,
+ Readonly: m.Readonly,
+ MountType: m.MountType,
+ RefProxy: refProxy,
+ CacheOpt: m.CacheOpt,
+ SecretOpt: m.SecretOpt,
+ SSHOpt: m.SSHOpt,
+ })
+ }
+
+ // Not using `ctx` here because it will get cancelled as soon as NewContainer returns
+ // and we want the context to live for the duration of the container.
+ group := session.NewGroup(lbf.sid)
+ ctr, err := NewContainer(context.Background(), lbf.llbBridge, lbf.sm, group, ctrReq)
+ if err != nil {
+ return nil, stack.Enable(err)
+ }
+ defer func() {
+ if err != nil {
+ ctr.Release(ctx) // ensure release on error
+ }
+ }()
+
+ lbf.ctrsMu.Lock()
+ defer lbf.ctrsMu.Unlock()
+ // ensure we are not clobbering a dup container id request
+ if _, ok := lbf.ctrs[in.ContainerID]; ok {
+ return nil, stack.Enable(status.Errorf(codes.AlreadyExists, "Container %s already exists", in.ContainerID))
+ }
+ lbf.ctrs[in.ContainerID] = ctr
+ return &pb.NewContainerResponse{}, nil
+}
+
+func (lbf *llbBridgeForwarder) ReleaseContainer(ctx context.Context, in *pb.ReleaseContainerRequest) (*pb.ReleaseContainerResponse, error) {
+ logrus.Debugf("|<--- ReleaseContainer %s", in.ContainerID)
+ lbf.ctrsMu.Lock()
+ ctr, ok := lbf.ctrs[in.ContainerID]
+ delete(lbf.ctrs, in.ContainerID)
+ lbf.ctrsMu.Unlock()
+ if !ok {
+ return nil, errors.Errorf("container details for %s not found", in.ContainerID)
+ }
+ err := ctr.Release(ctx)
+ return &pb.ReleaseContainerResponse{}, stack.Enable(err)
+}
+
+type processIO struct {
+ id string
+ mu sync.Mutex
+ resize func(context.Context, gwclient.WinSize) error
+ done chan struct{}
+ doneOnce sync.Once
+ // these track the process side of the io pipe for
+ // read (fd=0) and write (fd=1, fd=2)
+ processReaders map[uint32]io.ReadCloser
+ processWriters map[uint32]io.WriteCloser
+ // these track the server side of the io pipe, so
+ // when we receive an EOF over grpc, we will close
+ // this end
+ serverWriters map[uint32]io.WriteCloser
+ serverReaders map[uint32]io.ReadCloser
+}
+
+func newProcessIO(id string, openFds []uint32) *processIO {
+ pio := &processIO{
+ id: id,
+ processReaders: map[uint32]io.ReadCloser{},
+ processWriters: map[uint32]io.WriteCloser{},
+ serverReaders: map[uint32]io.ReadCloser{},
+ serverWriters: map[uint32]io.WriteCloser{},
+ done: make(chan struct{}),
+ }
+
+ for _, fd := range openFds {
+ // TODO do we know which way to pipe each fd? For now assume fd0 is for
+ // reading, and the rest are for writing
+ r, w := io.Pipe()
+ if fd == 0 {
+ pio.processReaders[fd] = r
+ pio.serverWriters[fd] = w
+ } else {
+ pio.processWriters[fd] = w
+ pio.serverReaders[fd] = r
+ }
+ }
+
+ return pio
+}
+
+func (pio *processIO) Close() (err error) {
+ pio.mu.Lock()
+ defer pio.mu.Unlock()
+ for fd, r := range pio.processReaders {
+ delete(pio.processReaders, fd)
+ err1 := r.Close()
+ if err1 != nil && err == nil {
+ err = stack.Enable(err1)
+ }
+ }
+ for fd, w := range pio.serverReaders {
+ delete(pio.serverReaders, fd)
+ err1 := w.Close()
+ if err1 != nil && err == nil {
+ err = stack.Enable(err1)
+ }
+ }
+ pio.Done()
+ return err
+}
+
+func (pio *processIO) Done() {
+ stillOpen := len(pio.processReaders) + len(pio.processWriters) + len(pio.serverReaders) + len(pio.serverWriters)
+ if stillOpen == 0 {
+ pio.doneOnce.Do(func() {
+ close(pio.done)
+ })
+ }
+}
+
+func (pio *processIO) Write(f *pb.FdMessage) (err error) {
+ pio.mu.Lock()
+ writer := pio.serverWriters[f.Fd]
+ pio.mu.Unlock()
+ if writer == nil {
+ return status.Errorf(codes.OutOfRange, "fd %d unavailable to write", f.Fd)
+ }
+ defer func() {
+ if err != nil || f.EOF {
+ writer.Close()
+ pio.mu.Lock()
+ defer pio.mu.Unlock()
+ delete(pio.serverWriters, f.Fd)
+ pio.Done()
+ }
+ }()
+ if len(f.Data) > 0 {
+ _, err = writer.Write(f.Data)
+ return stack.Enable(err)
+ }
+ return nil
+}
+
+type outputWriter struct {
+ stream pb.LLBBridge_ExecProcessServer
+ fd uint32
+ processID string
+}
+
+func (w *outputWriter) Write(msg []byte) (int, error) {
+ logrus.Debugf("|---> File Message %s, fd=%d, %d bytes", w.processID, w.fd, len(msg))
+ err := w.stream.Send(&pb.ExecMessage{
+ ProcessID: w.processID,
+ Input: &pb.ExecMessage_File{
+ File: &pb.FdMessage{
+ Fd: w.fd,
+ Data: msg,
+ },
+ },
+ })
+ return len(msg), stack.Enable(err)
+}
+
+func (lbf *llbBridgeForwarder) ExecProcess(srv pb.LLBBridge_ExecProcessServer) error {
+ eg, ctx := errgroup.WithContext(srv.Context())
+
+ msgs := make(chan *pb.ExecMessage)
+
+ eg.Go(func() error {
+ defer close(msgs)
+ for {
+ execMsg, err := srv.Recv()
+ if err != nil {
+ if errors.Is(err, io.EOF) {
+ return nil
+ }
+ return stack.Enable(err)
+ }
+ switch m := execMsg.GetInput().(type) {
+ case *pb.ExecMessage_Init:
+ logrus.Debugf("|<--- Init Message %s", execMsg.ProcessID)
+ case *pb.ExecMessage_File:
+ if m.File.EOF {
+ logrus.Debugf("|<--- File Message %s, fd=%d, EOF", execMsg.ProcessID, m.File.Fd)
+ } else {
+ logrus.Debugf("|<--- File Message %s, fd=%d, %d bytes", execMsg.ProcessID, m.File.Fd, len(m.File.Data))
+ }
+ case *pb.ExecMessage_Resize:
+ logrus.Debugf("|<--- Resize Message %s", execMsg.ProcessID)
+ }
+ select {
+ case <-ctx.Done():
+ case msgs <- execMsg:
+ }
+ }
+ })
+
+ eg.Go(func() error {
+ pios := make(map[string]*processIO)
+ // close any stray pios on exit to make sure
+ // all the associated resources get cleaned up
+ defer func() {
+ for _, pio := range pios {
+ pio.Close()
+ }
+ }()
+
+ for {
+ var execMsg *pb.ExecMessage
+ select {
+ case <-ctx.Done():
+ return nil
+ case execMsg = <-msgs:
+ }
+ if execMsg == nil {
+ return nil
+ }
+
+ pid := execMsg.ProcessID
+ if pid == "" {
+ return stack.Enable(status.Errorf(codes.InvalidArgument, "ProcessID required"))
+ }
+
+ pio, pioFound := pios[pid]
+
+ if data := execMsg.GetFile(); data != nil {
+ if !pioFound {
+ return stack.Enable(status.Errorf(codes.NotFound, "IO for process %q not found", pid))
+ }
+ err := pio.Write(data)
+ if err != nil {
+ return stack.Enable(err)
+ }
+ } else if resize := execMsg.GetResize(); resize != nil {
+ if !pioFound {
+ return stack.Enable(status.Errorf(codes.NotFound, "IO for process %q not found", pid))
+ }
+ pio.resize(ctx, gwclient.WinSize{
+ Cols: resize.Cols,
+ Rows: resize.Rows,
+ })
+ } else if init := execMsg.GetInit(); init != nil {
+ if pioFound {
+ return stack.Enable(status.Errorf(codes.AlreadyExists, "Process %s already exists", pid))
+ }
+ id := init.ContainerID
+ lbf.ctrsMu.Lock()
+ ctr, ok := lbf.ctrs[id]
+ lbf.ctrsMu.Unlock()
+ if !ok {
+ return stack.Enable(status.Errorf(codes.NotFound, "container %q previously released or not created", id))
+ }
+
+ initCtx, initCancel := context.WithCancel(context.Background())
+ defer initCancel()
+
+ pio := newProcessIO(pid, init.Fds)
+ pios[pid] = pio
+
+ proc, err := ctr.Start(initCtx, gwclient.StartRequest{
+ Args: init.Meta.Args,
+ Env: init.Meta.Env,
+ User: init.Meta.User,
+ Cwd: init.Meta.Cwd,
+ Tty: init.Tty,
+ Stdin: pio.processReaders[0],
+ Stdout: pio.processWriters[1],
+ Stderr: pio.processWriters[2],
+ })
+ if err != nil {
+ return stack.Enable(err)
+ }
+ pio.resize = proc.Resize
+
+ eg.Go(func() error {
+ <-pio.done
+ logrus.Debugf("|---> Done Message %s", pid)
+ err := srv.Send(&pb.ExecMessage{
+ ProcessID: pid,
+ Input: &pb.ExecMessage_Done{
+ Done: &pb.DoneMessage{},
+ },
+ })
+ return stack.Enable(err)
+ })
+
+ eg.Go(func() error {
+ defer func() {
+ pio.Close()
+ }()
+ err := proc.Wait()
+
+ var statusCode uint32
+ var exitError *errdefs.ExitError
+ var statusError *rpc.Status
+ if err != nil {
+ statusCode = containerd.UnknownExitStatus
+ st, _ := status.FromError(grpcerrors.ToGRPC(err))
+ stp := st.Proto()
+ statusError = &rpc.Status{
+ Code: stp.Code,
+ Message: stp.Message,
+ Details: convertToGogoAny(stp.Details),
+ }
+ }
+ if errors.As(err, &exitError) {
+ statusCode = exitError.ExitCode
+ }
+ logrus.Debugf("|---> Exit Message %s, code=%d, error=%s", pid, statusCode, err)
+ sendErr := srv.Send(&pb.ExecMessage{
+ ProcessID: pid,
+ Input: &pb.ExecMessage_Exit{
+ Exit: &pb.ExitMessage{
+ Code: statusCode,
+ Error: statusError,
+ },
+ },
+ })
+
+ if sendErr != nil && err != nil {
+ return errors.Wrap(sendErr, err.Error())
+ } else if sendErr != nil {
+ return stack.Enable(sendErr)
+ }
+
+ if err != nil && statusCode != 0 {
+ // this was a container exit error which is "normal" so
+ // don't return this error from the errgroup
+ return nil
+ }
+ return stack.Enable(err)
+ })
+
+ logrus.Debugf("|---> Started Message %s", pid)
+ err = srv.Send(&pb.ExecMessage{
+ ProcessID: pid,
+ Input: &pb.ExecMessage_Started{
+ Started: &pb.StartedMessage{},
+ },
+ })
+ if err != nil {
+ return stack.Enable(err)
+ }
+
+ // start sending Fd output back to client, this is done after
+ // StartedMessage so that Fd output will not potentially arrive
+ // to the client before "Started" as the container starts up.
+ for fd, file := range pio.serverReaders {
+ fd, file := fd, file
+ eg.Go(func() error {
+ defer func() {
+ file.Close()
+ pio.mu.Lock()
+ defer pio.mu.Unlock()
+ w := pio.processWriters[fd]
+ if w != nil {
+ w.Close()
+ }
+ delete(pio.processWriters, fd)
+ pio.Done()
+ }()
+ dest := &outputWriter{
+ stream: srv,
+ fd: uint32(fd),
+ processID: pid,
+ }
+ _, err := io.Copy(dest, file)
+ // ignore ErrClosedPipe, it is EOF for our usage.
+ if err != nil && !errors.Is(err, io.ErrClosedPipe) {
+ return stack.Enable(err)
+ }
+ // no error so must be EOF
+ logrus.Debugf("|---> File Message %s, fd=%d, EOF", pid, fd)
+ err = srv.Send(&pb.ExecMessage{
+ ProcessID: pid,
+ Input: &pb.ExecMessage_File{
+ File: &pb.FdMessage{
+ Fd: uint32(fd),
+ EOF: true,
+ },
+ },
+ })
+ return stack.Enable(err)
+ })
+ }
+ }
+ }
+ })
+
+ err := eg.Wait()
+ return stack.Enable(err)
+}
+
func (lbf *llbBridgeForwarder) convertRef(id string) (solver.ResultProxy, error) {
if id == "" {
return nil, nil
@@ -773,3 +1227,39 @@
}
return out
}
+
+func convertToGogoAny(in []*any.Any) []*gogotypes.Any {
+ out := make([]*gogotypes.Any, len(in))
+ for i := range in {
+ out[i] = &gogotypes.Any{TypeUrl: in[i].TypeUrl, Value: in[i].Value}
+ }
+ return out
+}
+
+func getCaps(label string) map[string]struct{} {
+ if label == "" {
+ return make(map[string]struct{})
+ }
+ caps := strings.Split(label, ",")
+ out := make(map[string]struct{}, len(caps))
+ for _, c := range caps {
+ name := strings.SplitN(c, "+", 2)
+ if name[0] != "" {
+ out[name[0]] = struct{}{}
+ }
+ }
+ return out
+}
+
+func addCapsForKnownFrontends(caps map[string]struct{}, dgst digest.Digest) {
+ // these frontends were built without caps detection but do support inputs
+ defaults := map[digest.Digest]struct{}{
+ "sha256:9ac1c43a60e31dca741a6fe8314130a9cd4c4db0311fbbc636ff992ef60ae76d": {}, // docker/dockerfile:1.1.6
+ "sha256:080bd74d8778f83e7b670de193362d8c593c8b14f5c8fb919d28ee8feda0d069": {}, // docker/dockerfile:1.1.7
+ "sha256:60543a9d92b92af5088fb2938fb09b2072684af8384399e153e137fe081f8ab4": {}, // docker/dockerfile:1.1.6-experimental
+ "sha256:de85b2f3a3e8a2f7fe48e8e84a65f6fdd5cd5183afa6412fff9caa6871649c44": {}, // docker/dockerfile:1.1.7-experimental
+ }
+ if _, ok := defaults[dgst]; ok {
+ caps["moby.buildkit.frontend.inputs"] = struct{}{}
+ }
+}
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go b/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go
index 5fe33a1..13f6d5f 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go
@@ -3,38 +3,48 @@
import (
"context"
"encoding/json"
+ "fmt"
"io"
"net"
"os"
"strings"
+ "sync"
"time"
+ "github.com/containerd/containerd"
"github.com/gogo/googleapis/google/rpc"
gogotypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/ptypes/any"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/frontend/gateway/client"
pb "github.com/moby/buildkit/frontend/gateway/pb"
+ "github.com/moby/buildkit/identity"
+ "github.com/moby/buildkit/solver/errdefs"
opspb "github.com/moby/buildkit/solver/pb"
"github.com/moby/buildkit/util/apicaps"
"github.com/moby/buildkit/util/grpcerrors"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
fstypes "github.com/tonistiigi/fsutil/types"
+ "golang.org/x/sync/errgroup"
+ spb "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
const frontendPrefix = "BUILDKIT_FRONTEND_OPT_"
type GrpcClient interface {
+ client.Client
Run(context.Context, client.BuildFunc) error
}
func New(ctx context.Context, opts map[string]string, session, product string, c pb.LLBBridgeClient, w []client.WorkerInfo) (GrpcClient, error) {
- ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
- defer cancel()
- resp, err := c.Ping(ctx, &pb.PingRequest{})
+ pingCtx, pingCancel := context.WithTimeout(ctx, 15*time.Second)
+ defer pingCancel()
+ resp, err := c.Ping(pingCtx, &pb.PingRequest{})
if err != nil {
return nil, err
}
@@ -56,6 +66,7 @@
caps: pb.Caps.CapSet(resp.FrontendAPICaps),
llbCaps: opspb.Caps.CapSet(resp.LLBCaps),
requests: map[string]*pb.SolveRequest{},
+ execMsgs: newMessageForwarder(ctx, c),
}, nil
}
@@ -167,10 +178,21 @@
}()
}
+ defer func() {
+ err = c.execMsgs.Release()
+ if err != nil && retError != nil {
+ retError = err
+ }
+ }()
+
if res, err = f(ctx, c); err != nil {
return err
}
+ if res == nil {
+ return nil
+ }
+
if err := c.caps.Supports(pb.CapReturnMap); len(res.Refs) > 1 && err != nil {
return err
}
@@ -253,6 +275,7 @@
caps apicaps.CapSet
llbCaps apicaps.CapSet
requests map[string]*pb.SolveRequest
+ execMsgs *messageForwarder
}
func (c *grpcClient) requestForRef(ref client.Reference) (*pb.SolveRequest, error) {
@@ -423,14 +446,460 @@
inputs[key] = llb.NewState(op)
}
return inputs, nil
+}
+// procMessageForwarder is created per container process to act as the
+// communication channel between the process and the ExecProcess message
+// stream.
+type procMessageForwarder struct {
+ done chan struct{}
+ closeOnce sync.Once
+ msgs chan *pb.ExecMessage
+}
+
+func newProcMessageForwarder() *procMessageForwarder {
+ return &procMessageForwarder{
+ done: make(chan struct{}),
+ msgs: make(chan *pb.ExecMessage),
+ }
+}
+
+func (b *procMessageForwarder) Send(ctx context.Context, m *pb.ExecMessage) {
+ select {
+ case <-ctx.Done():
+ case <-b.done:
+ b.closeOnce.Do(func() {
+ close(b.msgs)
+ })
+ case b.msgs <- m:
+ }
+}
+
+func (b *procMessageForwarder) Recv(ctx context.Context) (m *pb.ExecMessage, ok bool) {
+ select {
+ case <-ctx.Done():
+ return nil, true
+ case <-b.done:
+ return nil, false
+ case m = <-b.msgs:
+ return m, true
+ }
+}
+
+func (b *procMessageForwarder) Close() {
+ close(b.done)
+ b.Recv(context.Background()) // flush any messages in queue
+ b.Send(context.Background(), nil) // ensure channel is closed
+}
+
+// messageForwarder manages a single grpc stream for ExecProcess to facilitate
+// a pub/sub message channel for each new process started from the client
+// connection.
+type messageForwarder struct {
+ client pb.LLBBridgeClient
+ ctx context.Context
+ cancel func()
+ eg *errgroup.Group
+ mu sync.Mutex
+ pids map[string]*procMessageForwarder
+ stream pb.LLBBridge_ExecProcessClient
+ // startOnce used to only start the exec message forwarder once,
+ // so we only have one exec stream per client
+ startOnce sync.Once
+ // startErr tracks the error when initializing the stream, it will
+ // be returned on subsequent calls to Start
+ startErr error
+}
+
+func newMessageForwarder(ctx context.Context, client pb.LLBBridgeClient) *messageForwarder {
+ ctx, cancel := context.WithCancel(ctx)
+ eg, ctx := errgroup.WithContext(ctx)
+ return &messageForwarder{
+ client: client,
+ pids: map[string]*procMessageForwarder{},
+ ctx: ctx,
+ cancel: cancel,
+ eg: eg,
+ }
+}
+
+func (m *messageForwarder) Start() (err error) {
+ defer func() {
+ if err != nil {
+ m.startErr = err
+ }
+ }()
+
+ if m.startErr != nil {
+ return m.startErr
+ }
+
+ m.startOnce.Do(func() {
+ m.stream, err = m.client.ExecProcess(m.ctx)
+ if err != nil {
+ return
+ }
+ m.eg.Go(func() error {
+ for {
+ msg, err := m.stream.Recv()
+ if errors.Is(err, io.EOF) || grpcerrors.Code(err) == codes.Canceled {
+ return nil
+ }
+ logrus.Debugf("|<--- %s", debugMessage(msg))
+
+ if err != nil {
+ return err
+ }
+
+ m.mu.Lock()
+ msgs, ok := m.pids[msg.ProcessID]
+ m.mu.Unlock()
+
+ if !ok {
+ logrus.Debugf("Received exec message for unregistered process: %s", msg.String())
+ continue
+ }
+ msgs.Send(m.ctx, msg)
+ }
+ })
+ })
+ return err
+}
+
+func debugMessage(msg *pb.ExecMessage) string {
+ switch m := msg.GetInput().(type) {
+ case *pb.ExecMessage_Init:
+ return fmt.Sprintf("Init Message %s", msg.ProcessID)
+ case *pb.ExecMessage_File:
+ if m.File.EOF {
+ return fmt.Sprintf("File Message %s, fd=%d, EOF", msg.ProcessID, m.File.Fd)
+ }
+ return fmt.Sprintf("File Message %s, fd=%d, %d bytes", msg.ProcessID, m.File.Fd, len(m.File.Data))
+ case *pb.ExecMessage_Resize:
+ return fmt.Sprintf("Resize Message %s", msg.ProcessID)
+ case *pb.ExecMessage_Started:
+ return fmt.Sprintf("Started Message %s", msg.ProcessID)
+ case *pb.ExecMessage_Exit:
+ return fmt.Sprintf("Exit Message %s, code=%d, err=%s", msg.ProcessID, m.Exit.Code, m.Exit.Error)
+ case *pb.ExecMessage_Done:
+ return fmt.Sprintf("Done Message %s", msg.ProcessID)
+ }
+ return fmt.Sprintf("Unknown Message %s", msg.String())
+}
+
+func (m *messageForwarder) Send(msg *pb.ExecMessage) error {
+ m.mu.Lock()
+ _, ok := m.pids[msg.ProcessID]
+ defer m.mu.Unlock()
+ if !ok {
+ return errors.Errorf("process %s has ended, not sending message %#v", msg.ProcessID, msg.Input)
+ }
+ logrus.Debugf("|---> %s", debugMessage(msg))
+ return m.stream.Send(msg)
+}
+
+func (m *messageForwarder) Release() error {
+ m.cancel()
+ return m.eg.Wait()
+}
+
+func (m *messageForwarder) Register(pid string) *procMessageForwarder {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ sender := newProcMessageForwarder()
+ m.pids[pid] = sender
+ return sender
+}
+
+func (m *messageForwarder) Deregister(pid string) {
+ m.mu.Lock()
+ defer m.mu.Unlock()
+ sender, ok := m.pids[pid]
+ if !ok {
+ return
+ }
+ delete(m.pids, pid)
+ sender.Close()
+}
+
+type msgWriter struct {
+ mux *messageForwarder
+ fd uint32
+ processID string
+}
+
+func (w *msgWriter) Write(msg []byte) (int, error) {
+ err := w.mux.Send(&pb.ExecMessage{
+ ProcessID: w.processID,
+ Input: &pb.ExecMessage_File{
+ File: &pb.FdMessage{
+ Fd: w.fd,
+ Data: msg,
+ },
+ },
+ })
+ if err != nil {
+ return 0, err
+ }
+ return len(msg), nil
+}
+
+func (c *grpcClient) NewContainer(ctx context.Context, req client.NewContainerRequest) (client.Container, error) {
+ err := c.caps.Supports(pb.CapGatewayExec)
+ if err != nil {
+ return nil, err
+ }
+ id := identity.NewID()
+ var mounts []*opspb.Mount
+ for _, m := range req.Mounts {
+ var resultID string
+ if m.Ref != nil {
+ ref, ok := m.Ref.(*reference)
+ if !ok {
+ return nil, errors.Errorf("unexpected type for reference, got %T", m.Ref)
+ }
+ resultID = ref.id
+ }
+ mounts = append(mounts, &opspb.Mount{
+ Dest: m.Dest,
+ Selector: m.Selector,
+ Readonly: m.Readonly,
+ MountType: m.MountType,
+ ResultID: resultID,
+ CacheOpt: m.CacheOpt,
+ SecretOpt: m.SecretOpt,
+ SSHOpt: m.SSHOpt,
+ })
+ }
+
+ logrus.Debugf("|---> NewContainer %s", id)
+ _, err = c.client.NewContainer(ctx, &pb.NewContainerRequest{
+ ContainerID: id,
+ Mounts: mounts,
+ Platform: req.Platform,
+ Constraints: req.Constraints,
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ // ensure message forwarder is started, only sets up stream first time called
+ err = c.execMsgs.Start()
+ if err != nil {
+ return nil, err
+ }
+
+ return &container{
+ client: c.client,
+ id: id,
+ execMsgs: c.execMsgs,
+ }, nil
+}
+
+type container struct {
+ client pb.LLBBridgeClient
+ id string
+ execMsgs *messageForwarder
+}
+
+func (ctr *container) Start(ctx context.Context, req client.StartRequest) (client.ContainerProcess, error) {
+ pid := fmt.Sprintf("%s:%s", ctr.id, identity.NewID())
+ msgs := ctr.execMsgs.Register(pid)
+
+ init := &pb.InitMessage{
+ ContainerID: ctr.id,
+ Meta: &opspb.Meta{
+ Args: req.Args,
+ Env: req.Env,
+ Cwd: req.Cwd,
+ User: req.User,
+ },
+ Tty: req.Tty,
+ Security: req.SecurityMode,
+ }
+ if req.Stdin != nil {
+ init.Fds = append(init.Fds, 0)
+ }
+ if req.Stdout != nil {
+ init.Fds = append(init.Fds, 1)
+ }
+ if req.Stderr != nil {
+ init.Fds = append(init.Fds, 2)
+ }
+
+ err := ctr.execMsgs.Send(&pb.ExecMessage{
+ ProcessID: pid,
+ Input: &pb.ExecMessage_Init{
+ Init: init,
+ },
+ })
+ if err != nil {
+ return nil, err
+ }
+
+ msg, _ := msgs.Recv(ctx)
+ if msg == nil {
+ return nil, errors.Errorf("failed to receive started message")
+ }
+ started := msg.GetStarted()
+ if started == nil {
+ return nil, errors.Errorf("expecting started message, got %T", msg.GetInput())
+ }
+
+ eg, ctx := errgroup.WithContext(ctx)
+ done := make(chan struct{})
+
+ ctrProc := &containerProcess{
+ execMsgs: ctr.execMsgs,
+ id: pid,
+ eg: eg,
+ }
+
+ var stdinReader *io.PipeReader
+ ctrProc.eg.Go(func() error {
+ <-done
+ if stdinReader != nil {
+ return stdinReader.Close()
+ }
+ return nil
+ })
+
+ if req.Stdin != nil {
+ var stdinWriter io.WriteCloser
+ stdinReader, stdinWriter = io.Pipe()
+ // This go routine is intentionally not part of the errgroup because
+ // if os.Stdin is used for req.Stdin then this will block until
+ // the user closes the input, which will likely be after we are done
+ // with the container, so we can't Wait on it.
+ go func() {
+ io.Copy(stdinWriter, req.Stdin)
+ stdinWriter.Close()
+ }()
+
+ ctrProc.eg.Go(func() error {
+ m := &msgWriter{
+ mux: ctr.execMsgs,
+ processID: pid,
+ fd: 0,
+ }
+ _, err := io.Copy(m, stdinReader)
+ // ignore ErrClosedPipe, it is EOF for our usage.
+ if err != nil && !errors.Is(err, io.ErrClosedPipe) {
+ return err
+ }
+ // not an error so must be eof
+ return ctr.execMsgs.Send(&pb.ExecMessage{
+ ProcessID: pid,
+ Input: &pb.ExecMessage_File{
+ File: &pb.FdMessage{
+ Fd: 0,
+ EOF: true,
+ },
+ },
+ })
+ })
+ }
+
+ ctrProc.eg.Go(func() error {
+ var closeDoneOnce sync.Once
+ var exitError error
+ for {
+ msg, ok := msgs.Recv(ctx)
+ if !ok {
+ // no more messages, return
+ return exitError
+ }
+
+ if msg == nil {
+ // empty message from ctx cancel, so just start shutting down
+ // input, but continue processing more exit/done messages
+ closeDoneOnce.Do(func() {
+ close(done)
+ })
+ continue
+ }
+
+ if file := msg.GetFile(); file != nil {
+ var out io.WriteCloser
+ switch file.Fd {
+ case 1:
+ out = req.Stdout
+ case 2:
+ out = req.Stderr
+ }
+ if out == nil {
+ // if things are plumbed correctly this should never happen
+ return errors.Errorf("missing writer for output fd %d", file.Fd)
+ }
+ if len(file.Data) > 0 {
+ _, err := out.Write(file.Data)
+ if err != nil {
+ return err
+ }
+ }
+ } else if exit := msg.GetExit(); exit != nil {
+ // capture exit message to exitError so we can return it after
+ // the server sends the Done message
+ closeDoneOnce.Do(func() {
+ close(done)
+ })
+ if exit.Code == 0 {
+ continue
+ }
+ exitError = grpcerrors.FromGRPC(status.ErrorProto(&spb.Status{
+ Code: exit.Error.Code,
+ Message: exit.Error.Message,
+ Details: convertGogoAny(exit.Error.Details),
+ }))
+ if exit.Code != containerd.UnknownExitStatus {
+ exitError = &errdefs.ExitError{ExitCode: exit.Code, Err: exitError}
+ }
+ } else if serverDone := msg.GetDone(); serverDone != nil {
+ return exitError
+ } else {
+ return errors.Errorf("unexpected Exec Message for pid %s: %T", pid, msg.GetInput())
+ }
+ }
+ })
+
+ return ctrProc, nil
+}
+
+func (ctr *container) Release(ctx context.Context) error {
+ logrus.Debugf("|---> ReleaseContainer %s", ctr.id)
+ _, err := ctr.client.ReleaseContainer(ctx, &pb.ReleaseContainerRequest{
+ ContainerID: ctr.id,
+ })
+ return err
+}
+
+type containerProcess struct {
+ execMsgs *messageForwarder
+ id string
+ eg *errgroup.Group
+}
+
+func (ctrProc *containerProcess) Wait() error {
+ defer ctrProc.execMsgs.Deregister(ctrProc.id)
+ return ctrProc.eg.Wait()
+}
+
+func (ctrProc *containerProcess) Resize(_ context.Context, size client.WinSize) error {
+ return ctrProc.execMsgs.Send(&pb.ExecMessage{
+ ProcessID: ctrProc.id,
+ Input: &pb.ExecMessage_Resize{
+ Resize: &pb.ResizeMessage{
+ Cols: size.Cols,
+ Rows: size.Rows,
+ },
+ },
+ })
}
type reference struct {
- c *grpcClient
- id string
- def *opspb.Definition
- output llb.Output
+ c *grpcClient
+ id string
+ def *opspb.Definition
}
func newReference(c *grpcClient, ref *pb.Ref) (*reference, error) {
@@ -502,11 +971,11 @@
}
func grpcClientConn(ctx context.Context) (context.Context, *grpc.ClientConn, error) {
- dialOpt := grpc.WithDialer(func(addr string, d time.Duration) (net.Conn, error) {
+ dialOpt := grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
return stdioConn(), nil
})
- cc, err := grpc.DialContext(ctx, "", dialOpt, grpc.WithInsecure(), grpc.WithUnaryInterceptor(grpcerrors.UnaryClientInterceptor), grpc.WithStreamInterceptor(grpcerrors.StreamClientInterceptor))
+ cc, err := grpc.DialContext(ctx, "localhost", dialOpt, grpc.WithInsecure(), grpc.WithUnaryInterceptor(grpcerrors.UnaryClientInterceptor), grpc.WithStreamInterceptor(grpcerrors.StreamClientInterceptor))
if err != nil {
return nil, nil, errors.Wrap(err, "failed to create grpc client")
}
@@ -593,6 +1062,14 @@
return os.Getenv("BUILDKIT_EXPORTEDPRODUCT")
}
+func convertGogoAny(in []*gogotypes.Any) []*any.Any {
+ out := make([]*any.Any, len(in))
+ for i := range in {
+ out[i] = &any.Any{TypeUrl: in[i].TypeUrl, Value: in[i].Value}
+ }
+ return out
+}
+
func convertToGogoAny(in []*any.Any) []*gogotypes.Any {
out := make([]*gogotypes.Any, len(in))
for i := range in {
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/pb/caps.go b/vendor/github.com/moby/buildkit/frontend/gateway/pb/caps.go
index afb51cf..2c8760f 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/pb/caps.go
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/pb/caps.go
@@ -1,4 +1,4 @@
-package moby_buildkit_v1_frontend
+package moby_buildkit_v1_frontend //nolint:golint
import "github.com/moby/buildkit/util/apicaps"
@@ -35,6 +35,13 @@
// CapGatewaySolveMetadata can be used to check if solve calls from gateway reliably return metadata
CapGatewaySolveMetadata apicaps.CapID = "gateway.solve.metadata"
+
+ // CapGatewayExec is the capability to create and interact with new
+ // containers directly through the gateway
+ CapGatewayExec apicaps.CapID = "gateway.exec"
+
+ // CapFrontendCaps can be used to check that frontends define support for certain capabilities
+ CapFrontendCaps apicaps.CapID = "frontend.caps"
)
func init() {
@@ -136,4 +143,18 @@
Enabled: true,
Status: apicaps.CapStatusExperimental,
})
+
+ Caps.Init(apicaps.Cap{
+ ID: CapGatewayExec,
+ Name: "gateway exec",
+ Enabled: true,
+ Status: apicaps.CapStatusExperimental,
+ })
+
+ Caps.Init(apicaps.Cap{
+ ID: CapFrontendCaps,
+ Name: "frontend capabilities",
+ Enabled: true,
+ Status: apicaps.CapStatusExperimental,
+ })
}
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.pb.go b/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.pb.go
index a155367..69936cd 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.pb.go
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.pb.go
@@ -1322,6 +1322,689 @@
return nil
}
+type NewContainerRequest struct {
+ ContainerID string `protobuf:"bytes,1,opt,name=ContainerID,proto3" json:"ContainerID,omitempty"`
+ // For mount input values we can use random identifiers passed with ref
+ Mounts []*pb.Mount `protobuf:"bytes,2,rep,name=Mounts,proto3" json:"Mounts,omitempty"`
+ Network pb.NetMode `protobuf:"varint,3,opt,name=Network,proto3,enum=pb.NetMode" json:"Network,omitempty"`
+ Platform *pb.Platform `protobuf:"bytes,4,opt,name=platform,proto3" json:"platform,omitempty"`
+ Constraints *pb.WorkerConstraints `protobuf:"bytes,5,opt,name=constraints,proto3" json:"constraints,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *NewContainerRequest) Reset() { *m = NewContainerRequest{} }
+func (m *NewContainerRequest) String() string { return proto.CompactTextString(m) }
+func (*NewContainerRequest) ProtoMessage() {}
+func (*NewContainerRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{22}
+}
+func (m *NewContainerRequest) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *NewContainerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_NewContainerRequest.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *NewContainerRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_NewContainerRequest.Merge(m, src)
+}
+func (m *NewContainerRequest) XXX_Size() int {
+ return m.Size()
+}
+func (m *NewContainerRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_NewContainerRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_NewContainerRequest proto.InternalMessageInfo
+
+func (m *NewContainerRequest) GetContainerID() string {
+ if m != nil {
+ return m.ContainerID
+ }
+ return ""
+}
+
+func (m *NewContainerRequest) GetMounts() []*pb.Mount {
+ if m != nil {
+ return m.Mounts
+ }
+ return nil
+}
+
+func (m *NewContainerRequest) GetNetwork() pb.NetMode {
+ if m != nil {
+ return m.Network
+ }
+ return pb.NetMode_UNSET
+}
+
+func (m *NewContainerRequest) GetPlatform() *pb.Platform {
+ if m != nil {
+ return m.Platform
+ }
+ return nil
+}
+
+func (m *NewContainerRequest) GetConstraints() *pb.WorkerConstraints {
+ if m != nil {
+ return m.Constraints
+ }
+ return nil
+}
+
+type NewContainerResponse struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *NewContainerResponse) Reset() { *m = NewContainerResponse{} }
+func (m *NewContainerResponse) String() string { return proto.CompactTextString(m) }
+func (*NewContainerResponse) ProtoMessage() {}
+func (*NewContainerResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{23}
+}
+func (m *NewContainerResponse) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *NewContainerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_NewContainerResponse.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *NewContainerResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_NewContainerResponse.Merge(m, src)
+}
+func (m *NewContainerResponse) XXX_Size() int {
+ return m.Size()
+}
+func (m *NewContainerResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_NewContainerResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_NewContainerResponse proto.InternalMessageInfo
+
+type ReleaseContainerRequest struct {
+ ContainerID string `protobuf:"bytes,1,opt,name=ContainerID,proto3" json:"ContainerID,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ReleaseContainerRequest) Reset() { *m = ReleaseContainerRequest{} }
+func (m *ReleaseContainerRequest) String() string { return proto.CompactTextString(m) }
+func (*ReleaseContainerRequest) ProtoMessage() {}
+func (*ReleaseContainerRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{24}
+}
+func (m *ReleaseContainerRequest) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *ReleaseContainerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_ReleaseContainerRequest.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *ReleaseContainerRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ReleaseContainerRequest.Merge(m, src)
+}
+func (m *ReleaseContainerRequest) XXX_Size() int {
+ return m.Size()
+}
+func (m *ReleaseContainerRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_ReleaseContainerRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ReleaseContainerRequest proto.InternalMessageInfo
+
+func (m *ReleaseContainerRequest) GetContainerID() string {
+ if m != nil {
+ return m.ContainerID
+ }
+ return ""
+}
+
+type ReleaseContainerResponse struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ReleaseContainerResponse) Reset() { *m = ReleaseContainerResponse{} }
+func (m *ReleaseContainerResponse) String() string { return proto.CompactTextString(m) }
+func (*ReleaseContainerResponse) ProtoMessage() {}
+func (*ReleaseContainerResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{25}
+}
+func (m *ReleaseContainerResponse) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *ReleaseContainerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_ReleaseContainerResponse.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *ReleaseContainerResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ReleaseContainerResponse.Merge(m, src)
+}
+func (m *ReleaseContainerResponse) XXX_Size() int {
+ return m.Size()
+}
+func (m *ReleaseContainerResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_ReleaseContainerResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ReleaseContainerResponse proto.InternalMessageInfo
+
+type ExecMessage struct {
+ ProcessID string `protobuf:"bytes,1,opt,name=ProcessID,proto3" json:"ProcessID,omitempty"`
+ // Types that are valid to be assigned to Input:
+ // *ExecMessage_Init
+ // *ExecMessage_File
+ // *ExecMessage_Resize
+ // *ExecMessage_Started
+ // *ExecMessage_Exit
+ // *ExecMessage_Done
+ Input isExecMessage_Input `protobuf_oneof:"Input"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ExecMessage) Reset() { *m = ExecMessage{} }
+func (m *ExecMessage) String() string { return proto.CompactTextString(m) }
+func (*ExecMessage) ProtoMessage() {}
+func (*ExecMessage) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{26}
+}
+func (m *ExecMessage) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *ExecMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_ExecMessage.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *ExecMessage) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ExecMessage.Merge(m, src)
+}
+func (m *ExecMessage) XXX_Size() int {
+ return m.Size()
+}
+func (m *ExecMessage) XXX_DiscardUnknown() {
+ xxx_messageInfo_ExecMessage.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ExecMessage proto.InternalMessageInfo
+
+type isExecMessage_Input interface {
+ isExecMessage_Input()
+ MarshalTo([]byte) (int, error)
+ Size() int
+}
+
+type ExecMessage_Init struct {
+ Init *InitMessage `protobuf:"bytes,2,opt,name=Init,proto3,oneof" json:"Init,omitempty"`
+}
+type ExecMessage_File struct {
+ File *FdMessage `protobuf:"bytes,3,opt,name=File,proto3,oneof" json:"File,omitempty"`
+}
+type ExecMessage_Resize struct {
+ Resize *ResizeMessage `protobuf:"bytes,4,opt,name=Resize,proto3,oneof" json:"Resize,omitempty"`
+}
+type ExecMessage_Started struct {
+ Started *StartedMessage `protobuf:"bytes,5,opt,name=Started,proto3,oneof" json:"Started,omitempty"`
+}
+type ExecMessage_Exit struct {
+ Exit *ExitMessage `protobuf:"bytes,6,opt,name=Exit,proto3,oneof" json:"Exit,omitempty"`
+}
+type ExecMessage_Done struct {
+ Done *DoneMessage `protobuf:"bytes,7,opt,name=Done,proto3,oneof" json:"Done,omitempty"`
+}
+
+func (*ExecMessage_Init) isExecMessage_Input() {}
+func (*ExecMessage_File) isExecMessage_Input() {}
+func (*ExecMessage_Resize) isExecMessage_Input() {}
+func (*ExecMessage_Started) isExecMessage_Input() {}
+func (*ExecMessage_Exit) isExecMessage_Input() {}
+func (*ExecMessage_Done) isExecMessage_Input() {}
+
+func (m *ExecMessage) GetInput() isExecMessage_Input {
+ if m != nil {
+ return m.Input
+ }
+ return nil
+}
+
+func (m *ExecMessage) GetProcessID() string {
+ if m != nil {
+ return m.ProcessID
+ }
+ return ""
+}
+
+func (m *ExecMessage) GetInit() *InitMessage {
+ if x, ok := m.GetInput().(*ExecMessage_Init); ok {
+ return x.Init
+ }
+ return nil
+}
+
+func (m *ExecMessage) GetFile() *FdMessage {
+ if x, ok := m.GetInput().(*ExecMessage_File); ok {
+ return x.File
+ }
+ return nil
+}
+
+func (m *ExecMessage) GetResize() *ResizeMessage {
+ if x, ok := m.GetInput().(*ExecMessage_Resize); ok {
+ return x.Resize
+ }
+ return nil
+}
+
+func (m *ExecMessage) GetStarted() *StartedMessage {
+ if x, ok := m.GetInput().(*ExecMessage_Started); ok {
+ return x.Started
+ }
+ return nil
+}
+
+func (m *ExecMessage) GetExit() *ExitMessage {
+ if x, ok := m.GetInput().(*ExecMessage_Exit); ok {
+ return x.Exit
+ }
+ return nil
+}
+
+func (m *ExecMessage) GetDone() *DoneMessage {
+ if x, ok := m.GetInput().(*ExecMessage_Done); ok {
+ return x.Done
+ }
+ return nil
+}
+
+// XXX_OneofWrappers is for the internal use of the proto package.
+func (*ExecMessage) XXX_OneofWrappers() []interface{} {
+ return []interface{}{
+ (*ExecMessage_Init)(nil),
+ (*ExecMessage_File)(nil),
+ (*ExecMessage_Resize)(nil),
+ (*ExecMessage_Started)(nil),
+ (*ExecMessage_Exit)(nil),
+ (*ExecMessage_Done)(nil),
+ }
+}
+
+type InitMessage struct {
+ ContainerID string `protobuf:"bytes,1,opt,name=ContainerID,proto3" json:"ContainerID,omitempty"`
+ Meta *pb.Meta `protobuf:"bytes,2,opt,name=Meta,proto3" json:"Meta,omitempty"`
+ Fds []uint32 `protobuf:"varint,3,rep,packed,name=Fds,proto3" json:"Fds,omitempty"`
+ Tty bool `protobuf:"varint,4,opt,name=Tty,proto3" json:"Tty,omitempty"`
+ Security pb.SecurityMode `protobuf:"varint,5,opt,name=Security,proto3,enum=pb.SecurityMode" json:"Security,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *InitMessage) Reset() { *m = InitMessage{} }
+func (m *InitMessage) String() string { return proto.CompactTextString(m) }
+func (*InitMessage) ProtoMessage() {}
+func (*InitMessage) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{27}
+}
+func (m *InitMessage) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *InitMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_InitMessage.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *InitMessage) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_InitMessage.Merge(m, src)
+}
+func (m *InitMessage) XXX_Size() int {
+ return m.Size()
+}
+func (m *InitMessage) XXX_DiscardUnknown() {
+ xxx_messageInfo_InitMessage.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_InitMessage proto.InternalMessageInfo
+
+func (m *InitMessage) GetContainerID() string {
+ if m != nil {
+ return m.ContainerID
+ }
+ return ""
+}
+
+func (m *InitMessage) GetMeta() *pb.Meta {
+ if m != nil {
+ return m.Meta
+ }
+ return nil
+}
+
+func (m *InitMessage) GetFds() []uint32 {
+ if m != nil {
+ return m.Fds
+ }
+ return nil
+}
+
+func (m *InitMessage) GetTty() bool {
+ if m != nil {
+ return m.Tty
+ }
+ return false
+}
+
+func (m *InitMessage) GetSecurity() pb.SecurityMode {
+ if m != nil {
+ return m.Security
+ }
+ return pb.SecurityMode_SANDBOX
+}
+
+type ExitMessage struct {
+ Code uint32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
+ Error *rpc.Status `protobuf:"bytes,2,opt,name=Error,proto3" json:"Error,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ExitMessage) Reset() { *m = ExitMessage{} }
+func (m *ExitMessage) String() string { return proto.CompactTextString(m) }
+func (*ExitMessage) ProtoMessage() {}
+func (*ExitMessage) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{28}
+}
+func (m *ExitMessage) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *ExitMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_ExitMessage.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *ExitMessage) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ExitMessage.Merge(m, src)
+}
+func (m *ExitMessage) XXX_Size() int {
+ return m.Size()
+}
+func (m *ExitMessage) XXX_DiscardUnknown() {
+ xxx_messageInfo_ExitMessage.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ExitMessage proto.InternalMessageInfo
+
+func (m *ExitMessage) GetCode() uint32 {
+ if m != nil {
+ return m.Code
+ }
+ return 0
+}
+
+func (m *ExitMessage) GetError() *rpc.Status {
+ if m != nil {
+ return m.Error
+ }
+ return nil
+}
+
+type StartedMessage struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *StartedMessage) Reset() { *m = StartedMessage{} }
+func (m *StartedMessage) String() string { return proto.CompactTextString(m) }
+func (*StartedMessage) ProtoMessage() {}
+func (*StartedMessage) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{29}
+}
+func (m *StartedMessage) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *StartedMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_StartedMessage.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *StartedMessage) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_StartedMessage.Merge(m, src)
+}
+func (m *StartedMessage) XXX_Size() int {
+ return m.Size()
+}
+func (m *StartedMessage) XXX_DiscardUnknown() {
+ xxx_messageInfo_StartedMessage.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_StartedMessage proto.InternalMessageInfo
+
+type DoneMessage struct {
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *DoneMessage) Reset() { *m = DoneMessage{} }
+func (m *DoneMessage) String() string { return proto.CompactTextString(m) }
+func (*DoneMessage) ProtoMessage() {}
+func (*DoneMessage) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{30}
+}
+func (m *DoneMessage) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *DoneMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_DoneMessage.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *DoneMessage) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_DoneMessage.Merge(m, src)
+}
+func (m *DoneMessage) XXX_Size() int {
+ return m.Size()
+}
+func (m *DoneMessage) XXX_DiscardUnknown() {
+ xxx_messageInfo_DoneMessage.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_DoneMessage proto.InternalMessageInfo
+
+type FdMessage struct {
+ Fd uint32 `protobuf:"varint,1,opt,name=Fd,proto3" json:"Fd,omitempty"`
+ EOF bool `protobuf:"varint,2,opt,name=EOF,proto3" json:"EOF,omitempty"`
+ Data []byte `protobuf:"bytes,3,opt,name=Data,proto3" json:"Data,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *FdMessage) Reset() { *m = FdMessage{} }
+func (m *FdMessage) String() string { return proto.CompactTextString(m) }
+func (*FdMessage) ProtoMessage() {}
+func (*FdMessage) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{31}
+}
+func (m *FdMessage) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *FdMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_FdMessage.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *FdMessage) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_FdMessage.Merge(m, src)
+}
+func (m *FdMessage) XXX_Size() int {
+ return m.Size()
+}
+func (m *FdMessage) XXX_DiscardUnknown() {
+ xxx_messageInfo_FdMessage.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_FdMessage proto.InternalMessageInfo
+
+func (m *FdMessage) GetFd() uint32 {
+ if m != nil {
+ return m.Fd
+ }
+ return 0
+}
+
+func (m *FdMessage) GetEOF() bool {
+ if m != nil {
+ return m.EOF
+ }
+ return false
+}
+
+func (m *FdMessage) GetData() []byte {
+ if m != nil {
+ return m.Data
+ }
+ return nil
+}
+
+type ResizeMessage struct {
+ Rows uint32 `protobuf:"varint,1,opt,name=Rows,proto3" json:"Rows,omitempty"`
+ Cols uint32 `protobuf:"varint,2,opt,name=Cols,proto3" json:"Cols,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *ResizeMessage) Reset() { *m = ResizeMessage{} }
+func (m *ResizeMessage) String() string { return proto.CompactTextString(m) }
+func (*ResizeMessage) ProtoMessage() {}
+func (*ResizeMessage) Descriptor() ([]byte, []int) {
+ return fileDescriptor_f1a937782ebbded5, []int{32}
+}
+func (m *ResizeMessage) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *ResizeMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_ResizeMessage.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *ResizeMessage) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_ResizeMessage.Merge(m, src)
+}
+func (m *ResizeMessage) XXX_Size() int {
+ return m.Size()
+}
+func (m *ResizeMessage) XXX_DiscardUnknown() {
+ xxx_messageInfo_ResizeMessage.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_ResizeMessage proto.InternalMessageInfo
+
+func (m *ResizeMessage) GetRows() uint32 {
+ if m != nil {
+ return m.Rows
+ }
+ return 0
+}
+
+func (m *ResizeMessage) GetCols() uint32 {
+ if m != nil {
+ return m.Cols
+ }
+ return 0
+}
+
func init() {
proto.RegisterType((*Result)(nil), "moby.buildkit.v1.frontend.Result")
proto.RegisterMapType((map[string][]byte)(nil), "moby.buildkit.v1.frontend.Result.MetadataEntry")
@@ -1352,102 +2035,142 @@
proto.RegisterType((*StatFileResponse)(nil), "moby.buildkit.v1.frontend.StatFileResponse")
proto.RegisterType((*PingRequest)(nil), "moby.buildkit.v1.frontend.PingRequest")
proto.RegisterType((*PongResponse)(nil), "moby.buildkit.v1.frontend.PongResponse")
+ proto.RegisterType((*NewContainerRequest)(nil), "moby.buildkit.v1.frontend.NewContainerRequest")
+ proto.RegisterType((*NewContainerResponse)(nil), "moby.buildkit.v1.frontend.NewContainerResponse")
+ proto.RegisterType((*ReleaseContainerRequest)(nil), "moby.buildkit.v1.frontend.ReleaseContainerRequest")
+ proto.RegisterType((*ReleaseContainerResponse)(nil), "moby.buildkit.v1.frontend.ReleaseContainerResponse")
+ proto.RegisterType((*ExecMessage)(nil), "moby.buildkit.v1.frontend.ExecMessage")
+ proto.RegisterType((*InitMessage)(nil), "moby.buildkit.v1.frontend.InitMessage")
+ proto.RegisterType((*ExitMessage)(nil), "moby.buildkit.v1.frontend.ExitMessage")
+ proto.RegisterType((*StartedMessage)(nil), "moby.buildkit.v1.frontend.StartedMessage")
+ proto.RegisterType((*DoneMessage)(nil), "moby.buildkit.v1.frontend.DoneMessage")
+ proto.RegisterType((*FdMessage)(nil), "moby.buildkit.v1.frontend.FdMessage")
+ proto.RegisterType((*ResizeMessage)(nil), "moby.buildkit.v1.frontend.ResizeMessage")
}
func init() { proto.RegisterFile("gateway.proto", fileDescriptor_f1a937782ebbded5) }
var fileDescriptor_f1a937782ebbded5 = []byte{
- // 1436 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0xcd, 0x6e, 0xdb, 0xc6,
- 0x16, 0x36, 0xad, 0x1f, 0x5b, 0x47, 0x92, 0xad, 0x4c, 0x2e, 0x2e, 0x14, 0x2e, 0x1c, 0x5d, 0x22,
- 0xf0, 0x55, 0x12, 0x87, 0x6a, 0x9d, 0x04, 0x4e, 0x9d, 0x22, 0x69, 0x14, 0x27, 0xb0, 0x5b, 0x3b,
- 0x51, 0x27, 0x2d, 0x02, 0x04, 0x29, 0x50, 0x4a, 0x1c, 0x32, 0x44, 0x24, 0x0e, 0x3b, 0x1c, 0x25,
- 0x15, 0xba, 0x69, 0x77, 0xdd, 0x17, 0xe8, 0x03, 0xf4, 0x01, 0x8a, 0x3e, 0x41, 0xd7, 0x59, 0x76,
- 0x59, 0x74, 0x11, 0x14, 0x7e, 0x92, 0x62, 0x7e, 0x68, 0x51, 0xb2, 0x4c, 0x59, 0xe8, 0x4a, 0x33,
- 0x87, 0xe7, 0x3b, 0x73, 0xce, 0x37, 0xe7, 0x67, 0x04, 0x55, 0xdf, 0xe1, 0xe4, 0xad, 0x33, 0xb2,
- 0x23, 0x46, 0x39, 0x45, 0x97, 0x06, 0xb4, 0x3b, 0xb2, 0xbb, 0xc3, 0xa0, 0xef, 0xbe, 0x0e, 0xb8,
- 0xfd, 0xe6, 0x43, 0xdb, 0x63, 0x34, 0xe4, 0x24, 0x74, 0xcd, 0x1b, 0x7e, 0xc0, 0x5f, 0x0d, 0xbb,
- 0x76, 0x8f, 0x0e, 0x5a, 0x3e, 0xf5, 0x69, 0x4b, 0x22, 0xba, 0x43, 0x4f, 0xee, 0xe4, 0x46, 0xae,
- 0x94, 0x25, 0x73, 0x7b, 0x5a, 0xdd, 0xa7, 0xd4, 0xef, 0x13, 0x27, 0x0a, 0x62, 0xbd, 0x6c, 0xb1,
- 0xa8, 0xd7, 0x8a, 0xb9, 0xc3, 0x87, 0xb1, 0xc6, 0x6c, 0xa5, 0x30, 0xc2, 0x91, 0x56, 0xe2, 0x48,
- 0x2b, 0xa6, 0xfd, 0x37, 0x84, 0xb5, 0xa2, 0x6e, 0x8b, 0x46, 0x89, 0x76, 0xeb, 0x4c, 0x6d, 0x27,
- 0x0a, 0x5a, 0x7c, 0x14, 0x91, 0xb8, 0xf5, 0x96, 0xb2, 0xd7, 0x84, 0x69, 0xc0, 0xcd, 0x33, 0x01,
- 0x43, 0x1e, 0xf4, 0x05, 0xaa, 0xe7, 0x44, 0xb1, 0x38, 0x44, 0xfc, 0x6a, 0x50, 0x3a, 0x6c, 0x4e,
- 0xc3, 0x20, 0xe6, 0x41, 0xe0, 0x07, 0x2d, 0x2f, 0x96, 0x18, 0x75, 0x8a, 0x08, 0x42, 0xa9, 0x5b,
- 0x3f, 0xe6, 0xa0, 0x88, 0x49, 0x3c, 0xec, 0x73, 0xb4, 0x09, 0x55, 0x46, 0xbc, 0x3d, 0x12, 0x31,
- 0xd2, 0x73, 0x38, 0x71, 0xeb, 0x46, 0xc3, 0x68, 0x96, 0xf6, 0x97, 0xf0, 0xa4, 0x18, 0x7d, 0x09,
- 0x6b, 0x8c, 0x78, 0x71, 0x4a, 0x71, 0xb9, 0x61, 0x34, 0xcb, 0xdb, 0xd7, 0xed, 0x33, 0x2f, 0xc3,
- 0xc6, 0xc4, 0x3b, 0x72, 0xa2, 0x31, 0x64, 0x7f, 0x09, 0x4f, 0x19, 0x41, 0xdb, 0x90, 0x63, 0xc4,
- 0xab, 0xe7, 0xa4, 0xad, 0x8d, 0x6c, 0x5b, 0xfb, 0x4b, 0x58, 0x28, 0xa3, 0x1d, 0xc8, 0x0b, 0x2b,
- 0xf5, 0xbc, 0x04, 0xfd, 0x6f, 0xae, 0x03, 0xfb, 0x4b, 0x58, 0x02, 0xd0, 0x67, 0xb0, 0x3a, 0x20,
- 0xdc, 0x71, 0x1d, 0xee, 0xd4, 0xa1, 0x91, 0x6b, 0x96, 0xb7, 0x5b, 0x99, 0x60, 0x41, 0x90, 0x7d,
- 0xa4, 0x11, 0x8f, 0x42, 0xce, 0x46, 0xf8, 0xc4, 0x80, 0x79, 0x17, 0xaa, 0x13, 0x9f, 0x50, 0x0d,
- 0x72, 0xaf, 0xc9, 0x48, 0xf1, 0x87, 0xc5, 0x12, 0xfd, 0x07, 0x0a, 0x6f, 0x9c, 0xfe, 0x90, 0x48,
- 0xaa, 0x2a, 0x58, 0x6d, 0x76, 0x97, 0xef, 0x18, 0xed, 0x55, 0x28, 0x32, 0x69, 0xde, 0xfa, 0xd9,
- 0x80, 0xda, 0x34, 0x4f, 0xe8, 0x40, 0x47, 0x68, 0x48, 0x27, 0x6f, 0x2f, 0x40, 0xb1, 0x10, 0xc4,
- 0xca, 0x55, 0x69, 0xc2, 0xdc, 0x81, 0xd2, 0x89, 0x68, 0x9e, 0x8b, 0xa5, 0x94, 0x8b, 0xd6, 0x0e,
- 0xe4, 0x30, 0xf1, 0xd0, 0x1a, 0x2c, 0x07, 0x3a, 0x29, 0xf0, 0x72, 0xe0, 0xa2, 0x06, 0xe4, 0x5c,
- 0xe2, 0xe9, 0xcb, 0x5f, 0xb3, 0xa3, 0xae, 0xbd, 0x47, 0xbc, 0x20, 0x0c, 0x78, 0x40, 0x43, 0x2c,
- 0x3e, 0x59, 0xbf, 0x18, 0x22, 0xb9, 0x84, 0x5b, 0xe8, 0xfe, 0x44, 0x1c, 0xf3, 0x53, 0xe5, 0x94,
- 0xf7, 0xcf, 0xb3, 0xbd, 0xbf, 0x95, 0xf6, 0x7e, 0x6e, 0xfe, 0xa4, 0xa3, 0xe3, 0x50, 0xc5, 0x84,
- 0x0f, 0x59, 0x88, 0xc9, 0x37, 0x43, 0x12, 0x73, 0xf4, 0x51, 0x72, 0x23, 0xd2, 0xfe, 0xbc, 0xb4,
- 0x12, 0x8a, 0x58, 0x03, 0x50, 0x13, 0x0a, 0x84, 0x31, 0xca, 0xb4, 0x17, 0xc8, 0x56, 0x9d, 0xc3,
- 0x66, 0x51, 0xcf, 0x7e, 0x26, 0x3b, 0x07, 0x56, 0x0a, 0x56, 0x0d, 0xd6, 0x92, 0x53, 0xe3, 0x88,
- 0x86, 0x31, 0xb1, 0xd6, 0xa1, 0x7a, 0x10, 0x46, 0x43, 0x1e, 0x6b, 0x3f, 0xac, 0xdf, 0x0d, 0x58,
- 0x4b, 0x24, 0x4a, 0x07, 0xbd, 0x84, 0xf2, 0x98, 0xe3, 0x84, 0xcc, 0xdd, 0x0c, 0xff, 0x26, 0xf1,
- 0xa9, 0x0b, 0xd2, 0xdc, 0xa6, 0xcd, 0x99, 0x4f, 0xa0, 0x36, 0xad, 0x30, 0x83, 0xe9, 0x2b, 0x93,
- 0x4c, 0x4f, 0x5f, 0x7c, 0x8a, 0xd9, 0x9f, 0x0c, 0xb8, 0x84, 0x89, 0x6c, 0x85, 0x07, 0x03, 0xc7,
- 0x27, 0x0f, 0x69, 0xe8, 0x05, 0x7e, 0x42, 0x73, 0x4d, 0x66, 0x55, 0x62, 0x59, 0x24, 0x58, 0x13,
- 0x56, 0x3b, 0x7d, 0x87, 0x7b, 0x94, 0x0d, 0xb4, 0xf1, 0x8a, 0x30, 0x9e, 0xc8, 0xf0, 0xc9, 0x57,
- 0xd4, 0x80, 0xb2, 0x36, 0x7c, 0x44, 0x5d, 0x22, 0x7b, 0x46, 0x09, 0xa7, 0x45, 0xa8, 0x0e, 0x2b,
- 0x87, 0xd4, 0x7f, 0xe2, 0x0c, 0x88, 0x6c, 0x0e, 0x25, 0x9c, 0x6c, 0xad, 0xef, 0x0d, 0x30, 0x67,
- 0x79, 0xa5, 0x29, 0xfe, 0x14, 0x8a, 0x7b, 0x81, 0x4f, 0x62, 0x75, 0xfb, 0xa5, 0xf6, 0xf6, 0xbb,
- 0xf7, 0x97, 0x97, 0xfe, 0x7a, 0x7f, 0xf9, 0x5a, 0xaa, 0xaf, 0xd2, 0x88, 0x84, 0x3d, 0x1a, 0x72,
- 0x27, 0x08, 0x09, 0x13, 0xe3, 0xe1, 0x86, 0x2b, 0x21, 0xb6, 0x42, 0x62, 0x6d, 0x01, 0xfd, 0x17,
- 0x8a, 0xca, 0xba, 0x2e, 0x7b, 0xbd, 0xb3, 0xfe, 0x2c, 0x40, 0xe5, 0x99, 0x70, 0x20, 0xe1, 0xc2,
- 0x06, 0x18, 0x53, 0xa8, 0xd3, 0x6e, 0x9a, 0xd8, 0x94, 0x06, 0x32, 0x61, 0xf5, 0xb1, 0xbe, 0x62,
- 0x5d, 0xae, 0x27, 0x7b, 0xf4, 0x02, 0xca, 0xc9, 0xfa, 0x69, 0xc4, 0xeb, 0x39, 0x99, 0x23, 0x77,
- 0x32, 0x72, 0x24, 0xed, 0x89, 0x9d, 0x82, 0xea, 0x0c, 0x49, 0x49, 0xd0, 0xc7, 0x70, 0xe9, 0x60,
- 0x10, 0x51, 0xc6, 0x1f, 0x3a, 0xbd, 0x57, 0x04, 0x4f, 0x4e, 0x81, 0x7c, 0x23, 0xd7, 0x2c, 0xe1,
- 0xb3, 0x15, 0xd0, 0x16, 0x5c, 0x70, 0xfa, 0x7d, 0xfa, 0x56, 0x17, 0x8d, 0x4c, 0xff, 0x7a, 0xa1,
- 0x61, 0x34, 0x57, 0xf1, 0xe9, 0x0f, 0xe8, 0x03, 0xb8, 0x98, 0x12, 0x3e, 0x60, 0xcc, 0x19, 0x89,
- 0x7c, 0x29, 0x4a, 0xfd, 0x59, 0x9f, 0x44, 0x07, 0x7b, 0x1c, 0x84, 0x4e, 0xbf, 0x0e, 0x52, 0x47,
- 0x6d, 0x90, 0x05, 0x95, 0x47, 0xdf, 0x0a, 0x97, 0x08, 0x7b, 0xc0, 0x39, 0xab, 0x97, 0xe5, 0x55,
- 0x4c, 0xc8, 0x50, 0x07, 0x2a, 0xd2, 0x61, 0xe5, 0x7b, 0x5c, 0xaf, 0x48, 0xd2, 0xb6, 0x32, 0x48,
- 0x93, 0xea, 0x4f, 0xa3, 0x54, 0x29, 0x4d, 0x58, 0x40, 0x3d, 0x58, 0x4b, 0x88, 0x53, 0x35, 0x58,
- 0xaf, 0x4a, 0x9b, 0x77, 0x17, 0xbd, 0x08, 0x85, 0x56, 0x47, 0x4c, 0x99, 0x34, 0xef, 0x41, 0x6d,
- 0xfa, 0xbe, 0x16, 0x69, 0xec, 0xe6, 0xe7, 0x70, 0x71, 0xc6, 0x31, 0xff, 0xaa, 0xe6, 0x7f, 0x33,
- 0xe0, 0xc2, 0x29, 0x6e, 0x10, 0x82, 0xfc, 0x17, 0xa3, 0x88, 0x68, 0x93, 0x72, 0x8d, 0x8e, 0xa0,
- 0x20, 0xb8, 0x8f, 0xeb, 0xcb, 0x92, 0x98, 0x9d, 0x45, 0xc8, 0xb6, 0x25, 0x52, 0x91, 0xa2, 0xac,
- 0x98, 0x77, 0x00, 0xc6, 0xc2, 0x85, 0xc6, 0xdb, 0x4b, 0xa8, 0x6a, 0xe6, 0x75, 0x0b, 0xa8, 0xa9,
- 0x97, 0x88, 0x06, 0x8b, 0x77, 0xc6, 0x78, 0x24, 0xe4, 0x16, 0x1c, 0x09, 0xd6, 0x77, 0xb0, 0x8e,
- 0x89, 0xe3, 0x3e, 0x0e, 0xfa, 0xe4, 0xec, 0xce, 0x27, 0xea, 0x39, 0xe8, 0x93, 0x8e, 0xc3, 0x5f,
- 0x9d, 0xd4, 0xb3, 0xde, 0xa3, 0x5d, 0x28, 0x60, 0x27, 0xf4, 0x89, 0x3e, 0xfa, 0x4a, 0xc6, 0xd1,
- 0xf2, 0x10, 0xa1, 0x8b, 0x15, 0xc4, 0xba, 0x0b, 0xa5, 0x13, 0x99, 0xe8, 0x46, 0x4f, 0x3d, 0x2f,
- 0x26, 0xaa, 0xb3, 0xe5, 0xb0, 0xde, 0x09, 0xf9, 0x21, 0x09, 0x7d, 0x7d, 0x74, 0x0e, 0xeb, 0x9d,
- 0xb5, 0x29, 0x9e, 0x23, 0x89, 0xe7, 0x9a, 0x1a, 0x04, 0xf9, 0x3d, 0xf1, 0x66, 0x32, 0x64, 0x11,
- 0xc9, 0xb5, 0xe5, 0x8a, 0x51, 0xe6, 0xb8, 0x7b, 0x01, 0x3b, 0x3b, 0xc0, 0x3a, 0xac, 0xec, 0x05,
- 0x2c, 0x15, 0x5f, 0xb2, 0x45, 0x9b, 0x62, 0xc8, 0xf5, 0xfa, 0x43, 0x57, 0x44, 0xcb, 0x09, 0x0b,
- 0x75, 0x37, 0x9f, 0x92, 0x5a, 0xf7, 0x15, 0x8f, 0xf2, 0x14, 0xed, 0xcc, 0x16, 0xac, 0x90, 0x90,
- 0xb3, 0x80, 0x24, 0x93, 0x10, 0xd9, 0xea, 0x99, 0x6b, 0xcb, 0x67, 0xae, 0x9c, 0xb8, 0x38, 0x51,
- 0xb1, 0x76, 0x60, 0x5d, 0x08, 0xb2, 0x2f, 0x02, 0x41, 0x3e, 0xe5, 0xa4, 0x5c, 0x5b, 0xbb, 0x50,
- 0x1b, 0x03, 0xf5, 0xd1, 0x9b, 0x90, 0x17, 0x8f, 0x68, 0xdd, 0xaa, 0x67, 0x9d, 0x2b, 0xbf, 0x5b,
- 0x55, 0x28, 0x77, 0x82, 0x30, 0x99, 0x79, 0xd6, 0xb1, 0x01, 0x95, 0x0e, 0x0d, 0xc7, 0xd3, 0xa6,
- 0x03, 0xeb, 0x49, 0x05, 0x3e, 0xe8, 0x1c, 0x3c, 0x74, 0xa2, 0x24, 0x94, 0xc6, 0xe9, 0x6b, 0xd6,
- 0xef, 0x7d, 0x5b, 0x29, 0xb6, 0xf3, 0x62, 0x30, 0xe1, 0x69, 0x38, 0xfa, 0x04, 0x56, 0x0e, 0x0f,
- 0xdb, 0xd2, 0xd2, 0xf2, 0x42, 0x96, 0x12, 0x18, 0xba, 0x07, 0x2b, 0xcf, 0xe5, 0xdf, 0x90, 0x58,
- 0x0f, 0x8f, 0x19, 0x29, 0xa7, 0x02, 0x55, 0x6a, 0x98, 0xf4, 0x28, 0x73, 0x71, 0x02, 0xda, 0xfe,
- 0xb5, 0x08, 0xa5, 0xc3, 0xc3, 0x76, 0x9b, 0x05, 0xae, 0x4f, 0xd0, 0x0f, 0x06, 0xa0, 0xd3, 0xe3,
- 0x16, 0xdd, 0xca, 0xae, 0xa0, 0xd9, 0x6f, 0x06, 0xf3, 0xf6, 0x82, 0x28, 0xcd, 0xf2, 0x0b, 0x28,
- 0xc8, 0x0a, 0x47, 0xff, 0x3f, 0x67, 0xf7, 0x35, 0x9b, 0xf3, 0x15, 0xb5, 0xed, 0x1e, 0xac, 0x26,
- 0x55, 0x82, 0xae, 0x65, 0xba, 0x37, 0xd1, 0x04, 0xcc, 0xeb, 0xe7, 0xd2, 0xd5, 0x87, 0x7c, 0x0d,
- 0x2b, 0x3a, 0xf9, 0xd1, 0xd5, 0x39, 0xb8, 0x71, 0x19, 0x9a, 0xd7, 0xce, 0xa3, 0x3a, 0x0e, 0x23,
- 0x49, 0xf2, 0xcc, 0x30, 0xa6, 0x4a, 0x28, 0x33, 0x8c, 0x53, 0x55, 0xf3, 0x1c, 0xf2, 0xa2, 0x1a,
- 0xd0, 0x66, 0x06, 0x28, 0x55, 0x2e, 0x66, 0xd6, 0x75, 0x4d, 0x94, 0xd1, 0x57, 0xe2, 0x7f, 0x86,
- 0x7c, 0x35, 0x34, 0x33, 0x63, 0x4e, 0x3d, 0xf3, 0xcd, 0xab, 0xe7, 0xd0, 0x1c, 0x9b, 0x57, 0xf3,
- 0x31, 0xd3, 0xfc, 0xc4, 0xeb, 0x3d, 0xd3, 0xfc, 0xe4, 0xab, 0xbc, 0x5d, 0x79, 0x77, 0xbc, 0x61,
- 0xfc, 0x71, 0xbc, 0x61, 0xfc, 0x7d, 0xbc, 0x61, 0x74, 0x8b, 0xf2, 0x8f, 0xf9, 0xcd, 0x7f, 0x02,
- 0x00, 0x00, 0xff, 0xff, 0xa9, 0x05, 0x0f, 0x9d, 0xea, 0x10, 0x00, 0x00,
+ // 1899 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x58, 0xcf, 0x6f, 0x1b, 0xc7,
+ 0xf5, 0xd7, 0x8a, 0xa4, 0x48, 0x3e, 0x92, 0x32, 0x33, 0xce, 0x37, 0x5f, 0x7a, 0x11, 0x38, 0xcc,
+ 0x22, 0x55, 0x69, 0x47, 0x59, 0xa6, 0x74, 0x02, 0xb9, 0x72, 0x90, 0xd4, 0xd4, 0x0f, 0x58, 0x8d,
+ 0x24, 0xab, 0xe3, 0x14, 0x06, 0x82, 0x14, 0xe8, 0x8a, 0x3b, 0xa4, 0x17, 0xa6, 0x76, 0xb7, 0xb3,
+ 0x43, 0xcb, 0x4c, 0x2e, 0xed, 0xad, 0xf7, 0x02, 0xbd, 0x16, 0xe8, 0x5f, 0xd0, 0x4b, 0xaf, 0x3d,
+ 0xe7, 0xd8, 0x63, 0xd1, 0x43, 0x50, 0x18, 0xfd, 0x3f, 0x5a, 0xbc, 0xf9, 0x41, 0x2e, 0x29, 0x6a,
+ 0x29, 0xa2, 0x27, 0xce, 0xbc, 0x7d, 0x9f, 0x37, 0x6f, 0x3e, 0xf3, 0xe6, 0xbd, 0x37, 0x84, 0xda,
+ 0xc0, 0x13, 0xec, 0xd2, 0x1b, 0xbb, 0x31, 0x8f, 0x44, 0x44, 0xee, 0x5c, 0x44, 0xe7, 0x63, 0xf7,
+ 0x7c, 0x14, 0x0c, 0xfd, 0x97, 0x81, 0x70, 0x5f, 0xfd, 0xc4, 0xed, 0xf3, 0x28, 0x14, 0x2c, 0xf4,
+ 0xed, 0x8f, 0x06, 0x81, 0x78, 0x31, 0x3a, 0x77, 0x7b, 0xd1, 0x45, 0x7b, 0x10, 0x0d, 0xa2, 0xb6,
+ 0x44, 0x9c, 0x8f, 0xfa, 0x72, 0x26, 0x27, 0x72, 0xa4, 0x2c, 0xd9, 0x9d, 0x79, 0xf5, 0x41, 0x14,
+ 0x0d, 0x86, 0xcc, 0x8b, 0x83, 0x44, 0x0f, 0xdb, 0x3c, 0xee, 0xb5, 0x13, 0xe1, 0x89, 0x51, 0xa2,
+ 0x31, 0xdb, 0x29, 0x0c, 0x3a, 0xd2, 0x36, 0x8e, 0xb4, 0x93, 0x68, 0xf8, 0x8a, 0xf1, 0x76, 0x7c,
+ 0xde, 0x8e, 0x62, 0xa3, 0xdd, 0xbe, 0x56, 0xdb, 0x8b, 0x83, 0xb6, 0x18, 0xc7, 0x2c, 0x69, 0x5f,
+ 0x46, 0xfc, 0x25, 0xe3, 0x1a, 0xf0, 0xe0, 0x5a, 0xc0, 0x48, 0x04, 0x43, 0x44, 0xf5, 0xbc, 0x38,
+ 0xc1, 0x45, 0xf0, 0x57, 0x83, 0xd2, 0xdb, 0x16, 0x51, 0x18, 0x24, 0x22, 0x08, 0x06, 0x41, 0xbb,
+ 0x9f, 0x48, 0x8c, 0x5a, 0x05, 0x37, 0xa1, 0xd4, 0x9d, 0xdf, 0xe7, 0x60, 0x83, 0xb2, 0x64, 0x34,
+ 0x14, 0x64, 0x0b, 0x6a, 0x9c, 0xf5, 0xf7, 0x59, 0xcc, 0x59, 0xcf, 0x13, 0xcc, 0x6f, 0x58, 0x4d,
+ 0xab, 0x55, 0x7e, 0xb2, 0x46, 0x67, 0xc5, 0xe4, 0x97, 0xb0, 0xc9, 0x59, 0x3f, 0x49, 0x29, 0xae,
+ 0x37, 0xad, 0x56, 0xa5, 0xf3, 0xa1, 0x7b, 0xed, 0x61, 0xb8, 0x94, 0xf5, 0x4f, 0xbc, 0x78, 0x0a,
+ 0x79, 0xb2, 0x46, 0xe7, 0x8c, 0x90, 0x0e, 0xe4, 0x38, 0xeb, 0x37, 0x72, 0xd2, 0xd6, 0xdd, 0x6c,
+ 0x5b, 0x4f, 0xd6, 0x28, 0x2a, 0x93, 0x1d, 0xc8, 0xa3, 0x95, 0x46, 0x5e, 0x82, 0xde, 0x5f, 0xea,
+ 0xc0, 0x93, 0x35, 0x2a, 0x01, 0xe4, 0x4b, 0x28, 0x5d, 0x30, 0xe1, 0xf9, 0x9e, 0xf0, 0x1a, 0xd0,
+ 0xcc, 0xb5, 0x2a, 0x9d, 0x76, 0x26, 0x18, 0x09, 0x72, 0x4f, 0x34, 0xe2, 0x20, 0x14, 0x7c, 0x4c,
+ 0x27, 0x06, 0xec, 0x47, 0x50, 0x9b, 0xf9, 0x44, 0xea, 0x90, 0x7b, 0xc9, 0xc6, 0x8a, 0x3f, 0x8a,
+ 0x43, 0xf2, 0x36, 0x14, 0x5e, 0x79, 0xc3, 0x11, 0x93, 0x54, 0x55, 0xa9, 0x9a, 0xec, 0xae, 0x3f,
+ 0xb4, 0xba, 0x25, 0xd8, 0xe0, 0xd2, 0xbc, 0xf3, 0x47, 0x0b, 0xea, 0xf3, 0x3c, 0x91, 0x23, 0xbd,
+ 0x43, 0x4b, 0x3a, 0xf9, 0xe9, 0x0a, 0x14, 0xa3, 0x20, 0x51, 0xae, 0x4a, 0x13, 0xf6, 0x0e, 0x94,
+ 0x27, 0xa2, 0x65, 0x2e, 0x96, 0x53, 0x2e, 0x3a, 0x3b, 0x90, 0xa3, 0xac, 0x4f, 0x36, 0x61, 0x3d,
+ 0xd0, 0x41, 0x41, 0xd7, 0x03, 0x9f, 0x34, 0x21, 0xe7, 0xb3, 0xbe, 0x3e, 0xfc, 0x4d, 0x37, 0x3e,
+ 0x77, 0xf7, 0x59, 0x3f, 0x08, 0x03, 0x11, 0x44, 0x21, 0xc5, 0x4f, 0xce, 0x9f, 0x2d, 0x0c, 0x2e,
+ 0x74, 0x8b, 0x7c, 0x31, 0xb3, 0x8f, 0xe5, 0xa1, 0x72, 0xc5, 0xfb, 0xe7, 0xd9, 0xde, 0x7f, 0x92,
+ 0xf6, 0x7e, 0x69, 0xfc, 0xa4, 0x77, 0x27, 0xa0, 0x46, 0x99, 0x18, 0xf1, 0x90, 0xb2, 0xdf, 0x8c,
+ 0x58, 0x22, 0xc8, 0x4f, 0xcd, 0x89, 0x48, 0xfb, 0xcb, 0xc2, 0x0a, 0x15, 0xa9, 0x06, 0x90, 0x16,
+ 0x14, 0x18, 0xe7, 0x11, 0xd7, 0x5e, 0x10, 0x57, 0x65, 0x0e, 0x97, 0xc7, 0x3d, 0xf7, 0x99, 0xcc,
+ 0x1c, 0x54, 0x29, 0x38, 0x75, 0xd8, 0x34, 0xab, 0x26, 0x71, 0x14, 0x26, 0xcc, 0xb9, 0x05, 0xb5,
+ 0xa3, 0x30, 0x1e, 0x89, 0x44, 0xfb, 0xe1, 0xfc, 0xcd, 0x82, 0x4d, 0x23, 0x51, 0x3a, 0xe4, 0x1b,
+ 0xa8, 0x4c, 0x39, 0x36, 0x64, 0xee, 0x66, 0xf8, 0x37, 0x8b, 0x4f, 0x1d, 0x90, 0xe6, 0x36, 0x6d,
+ 0xce, 0x3e, 0x85, 0xfa, 0xbc, 0xc2, 0x02, 0xa6, 0x3f, 0x98, 0x65, 0x7a, 0xfe, 0xe0, 0x53, 0xcc,
+ 0xfe, 0xc1, 0x82, 0x3b, 0x94, 0xc9, 0x54, 0x78, 0x74, 0xe1, 0x0d, 0xd8, 0x5e, 0x14, 0xf6, 0x83,
+ 0x81, 0xa1, 0xb9, 0x2e, 0xa3, 0xca, 0x58, 0xc6, 0x00, 0x6b, 0x41, 0xe9, 0x6c, 0xe8, 0x89, 0x7e,
+ 0xc4, 0x2f, 0xb4, 0xf1, 0x2a, 0x1a, 0x37, 0x32, 0x3a, 0xf9, 0x4a, 0x9a, 0x50, 0xd1, 0x86, 0x4f,
+ 0x22, 0x9f, 0xc9, 0x9c, 0x51, 0xa6, 0x69, 0x11, 0x69, 0x40, 0xf1, 0x38, 0x1a, 0x9c, 0x7a, 0x17,
+ 0x4c, 0x26, 0x87, 0x32, 0x35, 0x53, 0xe7, 0xb7, 0x16, 0xd8, 0x8b, 0xbc, 0xd2, 0x14, 0xff, 0x1c,
+ 0x36, 0xf6, 0x83, 0x01, 0x4b, 0xd4, 0xe9, 0x97, 0xbb, 0x9d, 0xef, 0x7f, 0x78, 0x6f, 0xed, 0x9f,
+ 0x3f, 0xbc, 0x77, 0x3f, 0x95, 0x57, 0xa3, 0x98, 0x85, 0xbd, 0x28, 0x14, 0x5e, 0x10, 0x32, 0x8e,
+ 0xe5, 0xe1, 0x23, 0x5f, 0x42, 0x5c, 0x85, 0xa4, 0xda, 0x02, 0x79, 0x07, 0x36, 0x94, 0x75, 0x7d,
+ 0xed, 0xf5, 0xcc, 0xf9, 0x47, 0x01, 0xaa, 0xcf, 0xd0, 0x01, 0xc3, 0x85, 0x0b, 0x30, 0xa5, 0x50,
+ 0x87, 0xdd, 0x3c, 0xb1, 0x29, 0x0d, 0x62, 0x43, 0xe9, 0x50, 0x1f, 0xb1, 0xbe, 0xae, 0x93, 0x39,
+ 0xf9, 0x1a, 0x2a, 0x66, 0xfc, 0x34, 0x16, 0x8d, 0x9c, 0x8c, 0x91, 0x87, 0x19, 0x31, 0x92, 0xf6,
+ 0xc4, 0x4d, 0x41, 0x75, 0x84, 0xa4, 0x24, 0xe4, 0x33, 0xb8, 0x73, 0x74, 0x11, 0x47, 0x5c, 0xec,
+ 0x79, 0xbd, 0x17, 0x8c, 0xce, 0x56, 0x81, 0x7c, 0x33, 0xd7, 0x2a, 0xd3, 0xeb, 0x15, 0xc8, 0x36,
+ 0xbc, 0xe5, 0x0d, 0x87, 0xd1, 0xa5, 0xbe, 0x34, 0x32, 0xfc, 0x1b, 0x85, 0xa6, 0xd5, 0x2a, 0xd1,
+ 0xab, 0x1f, 0xc8, 0xc7, 0x70, 0x3b, 0x25, 0x7c, 0xcc, 0xb9, 0x37, 0xc6, 0x78, 0xd9, 0x90, 0xfa,
+ 0x8b, 0x3e, 0x61, 0x06, 0x3b, 0x0c, 0x42, 0x6f, 0xd8, 0x00, 0xa9, 0xa3, 0x26, 0xc4, 0x81, 0xea,
+ 0xc1, 0x6b, 0x74, 0x89, 0xf1, 0xc7, 0x42, 0xf0, 0x46, 0x45, 0x1e, 0xc5, 0x8c, 0x8c, 0x9c, 0x41,
+ 0x55, 0x3a, 0xac, 0x7c, 0x4f, 0x1a, 0x55, 0x49, 0xda, 0x76, 0x06, 0x69, 0x52, 0xfd, 0x69, 0x9c,
+ 0xba, 0x4a, 0x33, 0x16, 0x48, 0x0f, 0x36, 0x0d, 0x71, 0xea, 0x0e, 0x36, 0x6a, 0xd2, 0xe6, 0xa3,
+ 0x55, 0x0f, 0x42, 0xa1, 0xd5, 0x12, 0x73, 0x26, 0xed, 0xcf, 0xa1, 0x3e, 0x7f, 0x5e, 0xab, 0x24,
+ 0x76, 0xfb, 0x17, 0x70, 0x7b, 0xc1, 0x32, 0xff, 0xd3, 0x9d, 0xff, 0x8b, 0x05, 0x6f, 0x5d, 0xe1,
+ 0x86, 0x10, 0xc8, 0x7f, 0x35, 0x8e, 0x99, 0x36, 0x29, 0xc7, 0xe4, 0x04, 0x0a, 0xc8, 0x7d, 0xd2,
+ 0x58, 0x97, 0xc4, 0xec, 0xac, 0x42, 0xb6, 0x2b, 0x91, 0x8a, 0x14, 0x65, 0xc5, 0x7e, 0x08, 0x30,
+ 0x15, 0xae, 0x54, 0xde, 0xbe, 0x81, 0x9a, 0x66, 0x5e, 0xa7, 0x80, 0xba, 0xea, 0x44, 0x34, 0x18,
+ 0xfb, 0x8c, 0x69, 0x49, 0xc8, 0xad, 0x58, 0x12, 0x9c, 0xef, 0xe0, 0x16, 0x65, 0x9e, 0x7f, 0x18,
+ 0x0c, 0xd9, 0xf5, 0x99, 0x0f, 0xef, 0x73, 0x30, 0x64, 0x67, 0x9e, 0x78, 0x31, 0xb9, 0xcf, 0x7a,
+ 0x4e, 0x76, 0xa1, 0x40, 0xbd, 0x70, 0xc0, 0xf4, 0xd2, 0x1f, 0x64, 0x2c, 0x2d, 0x17, 0x41, 0x5d,
+ 0xaa, 0x20, 0xce, 0x23, 0x28, 0x4f, 0x64, 0x98, 0x8d, 0x9e, 0xf6, 0xfb, 0x09, 0x53, 0x99, 0x2d,
+ 0x47, 0xf5, 0x0c, 0xe5, 0xc7, 0x2c, 0x1c, 0xe8, 0xa5, 0x73, 0x54, 0xcf, 0x9c, 0x2d, 0x6c, 0x47,
+ 0x8c, 0xe7, 0x9a, 0x1a, 0x02, 0xf9, 0x7d, 0xec, 0x99, 0x2c, 0x79, 0x89, 0xe4, 0xd8, 0xf1, 0xb1,
+ 0x94, 0x79, 0xfe, 0x7e, 0xc0, 0xaf, 0xdf, 0x60, 0x03, 0x8a, 0xfb, 0x01, 0x4f, 0xed, 0xcf, 0x4c,
+ 0xc9, 0x16, 0x16, 0xb9, 0xde, 0x70, 0xe4, 0xe3, 0x6e, 0x05, 0xe3, 0xa1, 0xce, 0xe6, 0x73, 0x52,
+ 0xe7, 0x0b, 0xc5, 0xa3, 0x5c, 0x45, 0x3b, 0xb3, 0x0d, 0x45, 0x16, 0x0a, 0x1e, 0x30, 0x53, 0x09,
+ 0x89, 0xab, 0xda, 0x5c, 0x57, 0xb6, 0xb9, 0xb2, 0xe2, 0x52, 0xa3, 0xe2, 0xec, 0xc0, 0x2d, 0x14,
+ 0x64, 0x1f, 0x04, 0x81, 0x7c, 0xca, 0x49, 0x39, 0x76, 0x76, 0xa1, 0x3e, 0x05, 0xea, 0xa5, 0xb7,
+ 0x20, 0x8f, 0x4d, 0xb4, 0x4e, 0xd5, 0x8b, 0xd6, 0x95, 0xdf, 0x9d, 0x1a, 0x54, 0xce, 0x82, 0xd0,
+ 0xd4, 0x3c, 0xe7, 0x8d, 0x05, 0xd5, 0xb3, 0x28, 0x9c, 0x56, 0x9b, 0x33, 0xb8, 0x65, 0x6e, 0xe0,
+ 0xe3, 0xb3, 0xa3, 0x3d, 0x2f, 0x36, 0x5b, 0x69, 0x5e, 0x3d, 0x66, 0xdd, 0xef, 0xbb, 0x4a, 0xb1,
+ 0x9b, 0xc7, 0xc2, 0x44, 0xe7, 0xe1, 0xe4, 0x67, 0x50, 0x3c, 0x3e, 0xee, 0x4a, 0x4b, 0xeb, 0x2b,
+ 0x59, 0x32, 0x30, 0xf2, 0x39, 0x14, 0x9f, 0xcb, 0x67, 0x48, 0xa2, 0x8b, 0xc7, 0x82, 0x90, 0x53,
+ 0x1b, 0x55, 0x6a, 0x94, 0xf5, 0x22, 0xee, 0x53, 0x03, 0x72, 0xfe, 0x6d, 0xc1, 0xed, 0x53, 0x76,
+ 0xb9, 0x67, 0x0a, 0xa4, 0x61, 0xbb, 0x09, 0x95, 0x89, 0xec, 0x68, 0x5f, 0xb3, 0x9e, 0x16, 0x91,
+ 0xf7, 0x61, 0xe3, 0x24, 0x1a, 0x85, 0xc2, 0xb8, 0x5e, 0xc6, 0x3c, 0x23, 0x25, 0x54, 0x7f, 0x20,
+ 0x3f, 0x82, 0xe2, 0x29, 0x13, 0xf8, 0x4c, 0x92, 0x71, 0xb2, 0xd9, 0xa9, 0xa0, 0xce, 0x29, 0x13,
+ 0x58, 0xf5, 0xa9, 0xf9, 0x86, 0xad, 0x44, 0x6c, 0x5a, 0x89, 0xfc, 0xa2, 0x56, 0xc2, 0x7c, 0x25,
+ 0x3b, 0x50, 0xe9, 0x45, 0x61, 0x22, 0xb8, 0x17, 0xe0, 0xc2, 0x05, 0xa9, 0xfc, 0x7f, 0xa8, 0xac,
+ 0xf6, 0xb3, 0x37, 0xfd, 0x48, 0xd3, 0x9a, 0xce, 0x3b, 0xf0, 0xf6, 0xec, 0x2e, 0x75, 0x1f, 0xf7,
+ 0x08, 0xfe, 0x9f, 0xb2, 0x21, 0xf3, 0x12, 0xb6, 0x3a, 0x03, 0x8e, 0x0d, 0x8d, 0xab, 0x60, 0x6d,
+ 0xf8, 0xaf, 0x39, 0xa8, 0x1c, 0xbc, 0x66, 0xbd, 0x13, 0x96, 0x24, 0xde, 0x80, 0x91, 0x77, 0xa1,
+ 0x7c, 0xc6, 0xa3, 0x1e, 0x4b, 0x92, 0x89, 0xad, 0xa9, 0x80, 0x7c, 0x06, 0xf9, 0xa3, 0x30, 0x10,
+ 0x3a, 0x63, 0x6f, 0x65, 0xf6, 0x88, 0x81, 0xd0, 0x36, 0xf1, 0x7d, 0x84, 0x53, 0xb2, 0x0b, 0x79,
+ 0x8c, 0xf7, 0x9b, 0xe4, 0x1c, 0x3f, 0x85, 0x45, 0x0c, 0xe9, 0xca, 0x17, 0x65, 0xf0, 0x2d, 0xd3,
+ 0xcc, 0xb7, 0xb2, 0x93, 0x65, 0xf0, 0x2d, 0x9b, 0x5a, 0xd0, 0x48, 0x72, 0x00, 0xc5, 0x67, 0xc2,
+ 0xe3, 0xd8, 0x56, 0xa8, 0x13, 0xb9, 0x97, 0x55, 0x37, 0x95, 0xe6, 0xd4, 0x8a, 0xc1, 0x22, 0x09,
+ 0x07, 0xaf, 0x03, 0x21, 0x9b, 0x86, 0x6c, 0x12, 0x50, 0x2d, 0xb5, 0x11, 0x9c, 0x22, 0x7a, 0x3f,
+ 0x0a, 0x59, 0xa3, 0xb8, 0x14, 0x8d, 0x6a, 0x29, 0x34, 0x4e, 0xbb, 0x45, 0x28, 0xc8, 0xa2, 0xea,
+ 0xfc, 0xc9, 0x82, 0x4a, 0x8a, 0xe3, 0x1b, 0xdc, 0x83, 0x77, 0x21, 0x8f, 0x0f, 0x4a, 0x7d, 0x76,
+ 0x25, 0x79, 0x0b, 0x98, 0xf0, 0xa8, 0x94, 0x62, 0xd6, 0x3a, 0xf4, 0xd5, 0xdd, 0xac, 0x51, 0x1c,
+ 0xa2, 0xe4, 0x2b, 0x31, 0x96, 0x74, 0x97, 0x28, 0x0e, 0xc9, 0x36, 0x94, 0x9e, 0xb1, 0xde, 0x88,
+ 0x07, 0x62, 0x2c, 0x09, 0xdc, 0xec, 0xd4, 0xd1, 0x8a, 0x91, 0xc9, 0xcb, 0x32, 0xd1, 0x70, 0xbe,
+ 0xc4, 0xc0, 0x9a, 0x3a, 0x48, 0x20, 0xbf, 0x87, 0x6d, 0x35, 0x7a, 0x56, 0xa3, 0x72, 0x8c, 0x2f,
+ 0x9b, 0x83, 0x65, 0x2f, 0x9b, 0x03, 0xf3, 0xb2, 0x99, 0x3d, 0x10, 0x4c, 0x82, 0x29, 0x82, 0x9c,
+ 0xc7, 0x50, 0x9e, 0x04, 0x0d, 0x3e, 0x2a, 0x0f, 0x7d, 0xbd, 0xd2, 0xfa, 0xa1, 0x8f, 0x5b, 0x39,
+ 0x78, 0x7a, 0x28, 0x57, 0x29, 0x51, 0x1c, 0x4e, 0x4a, 0x4e, 0x2e, 0x55, 0x72, 0x76, 0xf0, 0xcd,
+ 0x96, 0x8a, 0x1c, 0x54, 0xa2, 0xd1, 0x65, 0x62, 0x5c, 0xc6, 0xb1, 0xda, 0xc6, 0x30, 0x91, 0xb6,
+ 0xe4, 0x36, 0x86, 0x49, 0xe7, 0x3f, 0x25, 0x28, 0x1f, 0x1f, 0x77, 0xbb, 0x3c, 0xf0, 0x07, 0x8c,
+ 0xfc, 0xce, 0x02, 0x72, 0xf5, 0x29, 0x40, 0x3e, 0xc9, 0x0e, 0xd8, 0xc5, 0xef, 0x19, 0xfb, 0xd3,
+ 0x15, 0x51, 0xba, 0x02, 0x7c, 0x0d, 0x05, 0xd9, 0x7d, 0x90, 0x1f, 0xdf, 0xb0, 0x33, 0xb4, 0x5b,
+ 0xcb, 0x15, 0xb5, 0xed, 0x1e, 0x94, 0x4c, 0x05, 0x27, 0xf7, 0x33, 0xdd, 0x9b, 0x69, 0x50, 0xec,
+ 0x0f, 0x6f, 0xa4, 0xab, 0x17, 0xf9, 0x35, 0x14, 0x75, 0x61, 0x26, 0xf7, 0x96, 0xe0, 0xa6, 0x2d,
+ 0x82, 0x7d, 0xff, 0x26, 0xaa, 0xd3, 0x6d, 0x98, 0x02, 0x9c, 0xb9, 0x8d, 0xb9, 0xf2, 0x9e, 0xb9,
+ 0x8d, 0x2b, 0x15, 0xfd, 0x39, 0xe4, 0xb1, 0x52, 0x93, 0xac, 0x6b, 0x9e, 0x2a, 0xe5, 0x76, 0xd6,
+ 0x71, 0xcd, 0x94, 0xf8, 0x5f, 0x61, 0x3a, 0x94, 0x2f, 0x9a, 0xec, 0x44, 0x98, 0xfa, 0x0b, 0xc2,
+ 0xbe, 0x77, 0x03, 0xcd, 0xa9, 0x79, 0xd5, 0xbb, 0x67, 0x9a, 0x9f, 0xf9, 0x67, 0x21, 0xd3, 0xfc,
+ 0xdc, 0x3f, 0x0e, 0x11, 0x54, 0xd3, 0x55, 0x8e, 0xb8, 0x19, 0xd0, 0x05, 0x45, 0xdf, 0x6e, 0xdf,
+ 0x58, 0x5f, 0x2f, 0xf8, 0x1d, 0x76, 0x9d, 0xb3, 0x15, 0x90, 0x74, 0x32, 0xe9, 0x58, 0x58, 0x6b,
+ 0xed, 0x07, 0x2b, 0x61, 0xf4, 0xe2, 0x9e, 0xaa, 0xb0, 0xba, 0x8a, 0x92, 0xec, 0x82, 0x31, 0xa9,
+ 0xc4, 0xf6, 0x0d, 0xf5, 0x5a, 0xd6, 0xc7, 0x56, 0xb7, 0xfa, 0xfd, 0x9b, 0xbb, 0xd6, 0xdf, 0xdf,
+ 0xdc, 0xb5, 0xfe, 0xf5, 0xe6, 0xae, 0x75, 0xbe, 0x21, 0xff, 0x85, 0x7d, 0xf0, 0xdf, 0x00, 0x00,
+ 0x00, 0xff, 0xff, 0x8e, 0x01, 0x01, 0xc8, 0xd7, 0x16, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -1476,6 +2199,9 @@
Return(ctx context.Context, in *ReturnRequest, opts ...grpc.CallOption) (*ReturnResponse, error)
// apicaps:CapFrontendInputs
Inputs(ctx context.Context, in *InputsRequest, opts ...grpc.CallOption) (*InputsResponse, error)
+ NewContainer(ctx context.Context, in *NewContainerRequest, opts ...grpc.CallOption) (*NewContainerResponse, error)
+ ReleaseContainer(ctx context.Context, in *ReleaseContainerRequest, opts ...grpc.CallOption) (*ReleaseContainerResponse, error)
+ ExecProcess(ctx context.Context, opts ...grpc.CallOption) (LLBBridge_ExecProcessClient, error)
}
type lLBBridgeClient struct {
@@ -1558,6 +2284,55 @@
return out, nil
}
+func (c *lLBBridgeClient) NewContainer(ctx context.Context, in *NewContainerRequest, opts ...grpc.CallOption) (*NewContainerResponse, error) {
+ out := new(NewContainerResponse)
+ err := c.cc.Invoke(ctx, "/moby.buildkit.v1.frontend.LLBBridge/NewContainer", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *lLBBridgeClient) ReleaseContainer(ctx context.Context, in *ReleaseContainerRequest, opts ...grpc.CallOption) (*ReleaseContainerResponse, error) {
+ out := new(ReleaseContainerResponse)
+ err := c.cc.Invoke(ctx, "/moby.buildkit.v1.frontend.LLBBridge/ReleaseContainer", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *lLBBridgeClient) ExecProcess(ctx context.Context, opts ...grpc.CallOption) (LLBBridge_ExecProcessClient, error) {
+ stream, err := c.cc.NewStream(ctx, &_LLBBridge_serviceDesc.Streams[0], "/moby.buildkit.v1.frontend.LLBBridge/ExecProcess", opts...)
+ if err != nil {
+ return nil, err
+ }
+ x := &lLBBridgeExecProcessClient{stream}
+ return x, nil
+}
+
+type LLBBridge_ExecProcessClient interface {
+ Send(*ExecMessage) error
+ Recv() (*ExecMessage, error)
+ grpc.ClientStream
+}
+
+type lLBBridgeExecProcessClient struct {
+ grpc.ClientStream
+}
+
+func (x *lLBBridgeExecProcessClient) Send(m *ExecMessage) error {
+ return x.ClientStream.SendMsg(m)
+}
+
+func (x *lLBBridgeExecProcessClient) Recv() (*ExecMessage, error) {
+ m := new(ExecMessage)
+ if err := x.ClientStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
// LLBBridgeServer is the server API for LLBBridge service.
type LLBBridgeServer interface {
// apicaps:CapResolveImage
@@ -1574,6 +2349,9 @@
Return(context.Context, *ReturnRequest) (*ReturnResponse, error)
// apicaps:CapFrontendInputs
Inputs(context.Context, *InputsRequest) (*InputsResponse, error)
+ NewContainer(context.Context, *NewContainerRequest) (*NewContainerResponse, error)
+ ReleaseContainer(context.Context, *ReleaseContainerRequest) (*ReleaseContainerResponse, error)
+ ExecProcess(LLBBridge_ExecProcessServer) error
}
// UnimplementedLLBBridgeServer can be embedded to have forward compatible implementations.
@@ -1604,6 +2382,15 @@
func (*UnimplementedLLBBridgeServer) Inputs(ctx context.Context, req *InputsRequest) (*InputsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Inputs not implemented")
}
+func (*UnimplementedLLBBridgeServer) NewContainer(ctx context.Context, req *NewContainerRequest) (*NewContainerResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method NewContainer not implemented")
+}
+func (*UnimplementedLLBBridgeServer) ReleaseContainer(ctx context.Context, req *ReleaseContainerRequest) (*ReleaseContainerResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method ReleaseContainer not implemented")
+}
+func (*UnimplementedLLBBridgeServer) ExecProcess(srv LLBBridge_ExecProcessServer) error {
+ return status.Errorf(codes.Unimplemented, "method ExecProcess not implemented")
+}
func RegisterLLBBridgeServer(s *grpc.Server, srv LLBBridgeServer) {
s.RegisterService(&_LLBBridge_serviceDesc, srv)
@@ -1753,6 +2540,68 @@
return interceptor(ctx, in, info, handler)
}
+func _LLBBridge_NewContainer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(NewContainerRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(LLBBridgeServer).NewContainer(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/moby.buildkit.v1.frontend.LLBBridge/NewContainer",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(LLBBridgeServer).NewContainer(ctx, req.(*NewContainerRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _LLBBridge_ReleaseContainer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(ReleaseContainerRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(LLBBridgeServer).ReleaseContainer(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/moby.buildkit.v1.frontend.LLBBridge/ReleaseContainer",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(LLBBridgeServer).ReleaseContainer(ctx, req.(*ReleaseContainerRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _LLBBridge_ExecProcess_Handler(srv interface{}, stream grpc.ServerStream) error {
+ return srv.(LLBBridgeServer).ExecProcess(&lLBBridgeExecProcessServer{stream})
+}
+
+type LLBBridge_ExecProcessServer interface {
+ Send(*ExecMessage) error
+ Recv() (*ExecMessage, error)
+ grpc.ServerStream
+}
+
+type lLBBridgeExecProcessServer struct {
+ grpc.ServerStream
+}
+
+func (x *lLBBridgeExecProcessServer) Send(m *ExecMessage) error {
+ return x.ServerStream.SendMsg(m)
+}
+
+func (x *lLBBridgeExecProcessServer) Recv() (*ExecMessage, error) {
+ m := new(ExecMessage)
+ if err := x.ServerStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
var _LLBBridge_serviceDesc = grpc.ServiceDesc{
ServiceName: "moby.buildkit.v1.frontend.LLBBridge",
HandlerType: (*LLBBridgeServer)(nil),
@@ -1789,8 +2638,23 @@
MethodName: "Inputs",
Handler: _LLBBridge_Inputs_Handler,
},
+ {
+ MethodName: "NewContainer",
+ Handler: _LLBBridge_NewContainer_Handler,
+ },
+ {
+ MethodName: "ReleaseContainer",
+ Handler: _LLBBridge_ReleaseContainer_Handler,
+ },
},
- Streams: []grpc.StreamDesc{},
+ Streams: []grpc.StreamDesc{
+ {
+ StreamName: "ExecProcess",
+ Handler: _LLBBridge_ExecProcess_Handler,
+ ServerStreams: true,
+ ClientStreams: true,
+ },
+ },
Metadata: "gateway.proto",
}
@@ -2971,6 +3835,603 @@
return len(dAtA) - i, nil
}
+func (m *NewContainerRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *NewContainerRequest) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *NewContainerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ if m.Constraints != nil {
+ {
+ size, err := m.Constraints.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x2a
+ }
+ if m.Platform != nil {
+ {
+ size, err := m.Platform.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x22
+ }
+ if m.Network != 0 {
+ i = encodeVarintGateway(dAtA, i, uint64(m.Network))
+ i--
+ dAtA[i] = 0x18
+ }
+ if len(m.Mounts) > 0 {
+ for iNdEx := len(m.Mounts) - 1; iNdEx >= 0; iNdEx-- {
+ {
+ size, err := m.Mounts[iNdEx].MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x12
+ }
+ }
+ if len(m.ContainerID) > 0 {
+ i -= len(m.ContainerID)
+ copy(dAtA[i:], m.ContainerID)
+ i = encodeVarintGateway(dAtA, i, uint64(len(m.ContainerID)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *NewContainerResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *NewContainerResponse) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *NewContainerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *ReleaseContainerRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ReleaseContainerRequest) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ReleaseContainerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ if len(m.ContainerID) > 0 {
+ i -= len(m.ContainerID)
+ copy(dAtA[i:], m.ContainerID)
+ i = encodeVarintGateway(dAtA, i, uint64(len(m.ContainerID)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *ReleaseContainerResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ReleaseContainerResponse) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ReleaseContainerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *ExecMessage) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ExecMessage) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ExecMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ if m.Input != nil {
+ {
+ size := m.Input.Size()
+ i -= size
+ if _, err := m.Input.MarshalTo(dAtA[i:]); err != nil {
+ return 0, err
+ }
+ }
+ }
+ if len(m.ProcessID) > 0 {
+ i -= len(m.ProcessID)
+ copy(dAtA[i:], m.ProcessID)
+ i = encodeVarintGateway(dAtA, i, uint64(len(m.ProcessID)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *ExecMessage_Init) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ExecMessage_Init) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ if m.Init != nil {
+ {
+ size, err := m.Init.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x12
+ }
+ return len(dAtA) - i, nil
+}
+func (m *ExecMessage_File) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ExecMessage_File) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ if m.File != nil {
+ {
+ size, err := m.File.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x1a
+ }
+ return len(dAtA) - i, nil
+}
+func (m *ExecMessage_Resize) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ExecMessage_Resize) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ if m.Resize != nil {
+ {
+ size, err := m.Resize.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x22
+ }
+ return len(dAtA) - i, nil
+}
+func (m *ExecMessage_Started) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ExecMessage_Started) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ if m.Started != nil {
+ {
+ size, err := m.Started.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x2a
+ }
+ return len(dAtA) - i, nil
+}
+func (m *ExecMessage_Exit) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ExecMessage_Exit) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ if m.Exit != nil {
+ {
+ size, err := m.Exit.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x32
+ }
+ return len(dAtA) - i, nil
+}
+func (m *ExecMessage_Done) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ExecMessage_Done) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ if m.Done != nil {
+ {
+ size, err := m.Done.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x3a
+ }
+ return len(dAtA) - i, nil
+}
+func (m *InitMessage) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *InitMessage) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *InitMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ if m.Security != 0 {
+ i = encodeVarintGateway(dAtA, i, uint64(m.Security))
+ i--
+ dAtA[i] = 0x28
+ }
+ if m.Tty {
+ i--
+ if m.Tty {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i--
+ dAtA[i] = 0x20
+ }
+ if len(m.Fds) > 0 {
+ dAtA24 := make([]byte, len(m.Fds)*10)
+ var j23 int
+ for _, num := range m.Fds {
+ for num >= 1<<7 {
+ dAtA24[j23] = uint8(uint64(num)&0x7f | 0x80)
+ num >>= 7
+ j23++
+ }
+ dAtA24[j23] = uint8(num)
+ j23++
+ }
+ i -= j23
+ copy(dAtA[i:], dAtA24[:j23])
+ i = encodeVarintGateway(dAtA, i, uint64(j23))
+ i--
+ dAtA[i] = 0x1a
+ }
+ if m.Meta != nil {
+ {
+ size, err := m.Meta.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x12
+ }
+ if len(m.ContainerID) > 0 {
+ i -= len(m.ContainerID)
+ copy(dAtA[i:], m.ContainerID)
+ i = encodeVarintGateway(dAtA, i, uint64(len(m.ContainerID)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *ExitMessage) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ExitMessage) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ExitMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ if m.Error != nil {
+ {
+ size, err := m.Error.MarshalToSizedBuffer(dAtA[:i])
+ if err != nil {
+ return 0, err
+ }
+ i -= size
+ i = encodeVarintGateway(dAtA, i, uint64(size))
+ }
+ i--
+ dAtA[i] = 0x12
+ }
+ if m.Code != 0 {
+ i = encodeVarintGateway(dAtA, i, uint64(m.Code))
+ i--
+ dAtA[i] = 0x8
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *StartedMessage) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *StartedMessage) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *StartedMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *DoneMessage) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *DoneMessage) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *DoneMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *FdMessage) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *FdMessage) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *FdMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ if len(m.Data) > 0 {
+ i -= len(m.Data)
+ copy(dAtA[i:], m.Data)
+ i = encodeVarintGateway(dAtA, i, uint64(len(m.Data)))
+ i--
+ dAtA[i] = 0x1a
+ }
+ if m.EOF {
+ i--
+ if m.EOF {
+ dAtA[i] = 1
+ } else {
+ dAtA[i] = 0
+ }
+ i--
+ dAtA[i] = 0x10
+ }
+ if m.Fd != 0 {
+ i = encodeVarintGateway(dAtA, i, uint64(m.Fd))
+ i--
+ dAtA[i] = 0x8
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *ResizeMessage) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *ResizeMessage) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *ResizeMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ i -= len(m.XXX_unrecognized)
+ copy(dAtA[i:], m.XXX_unrecognized)
+ }
+ if m.Cols != 0 {
+ i = encodeVarintGateway(dAtA, i, uint64(m.Cols))
+ i--
+ dAtA[i] = 0x10
+ }
+ if m.Rows != 0 {
+ i = encodeVarintGateway(dAtA, i, uint64(m.Rows))
+ i--
+ dAtA[i] = 0x8
+ }
+ return len(dAtA) - i, nil
+}
+
func encodeVarintGateway(dAtA []byte, offset int, v uint64) int {
offset -= sovGateway(v)
base := offset
@@ -3525,6 +4986,286 @@
return n
}
+func (m *NewContainerRequest) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.ContainerID)
+ if l > 0 {
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if len(m.Mounts) > 0 {
+ for _, e := range m.Mounts {
+ l = e.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ }
+ if m.Network != 0 {
+ n += 1 + sovGateway(uint64(m.Network))
+ }
+ if m.Platform != nil {
+ l = m.Platform.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if m.Constraints != nil {
+ l = m.Constraints.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *NewContainerResponse) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *ReleaseContainerRequest) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.ContainerID)
+ if l > 0 {
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *ReleaseContainerResponse) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *ExecMessage) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.ProcessID)
+ if l > 0 {
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if m.Input != nil {
+ n += m.Input.Size()
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *ExecMessage_Init) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.Init != nil {
+ l = m.Init.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ return n
+}
+func (m *ExecMessage_File) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.File != nil {
+ l = m.File.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ return n
+}
+func (m *ExecMessage_Resize) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.Resize != nil {
+ l = m.Resize.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ return n
+}
+func (m *ExecMessage_Started) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.Started != nil {
+ l = m.Started.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ return n
+}
+func (m *ExecMessage_Exit) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.Exit != nil {
+ l = m.Exit.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ return n
+}
+func (m *ExecMessage_Done) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.Done != nil {
+ l = m.Done.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ return n
+}
+func (m *InitMessage) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.ContainerID)
+ if l > 0 {
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if m.Meta != nil {
+ l = m.Meta.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if len(m.Fds) > 0 {
+ l = 0
+ for _, e := range m.Fds {
+ l += sovGateway(uint64(e))
+ }
+ n += 1 + sovGateway(uint64(l)) + l
+ }
+ if m.Tty {
+ n += 2
+ }
+ if m.Security != 0 {
+ n += 1 + sovGateway(uint64(m.Security))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *ExitMessage) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.Code != 0 {
+ n += 1 + sovGateway(uint64(m.Code))
+ }
+ if m.Error != nil {
+ l = m.Error.Size()
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *StartedMessage) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *DoneMessage) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *FdMessage) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.Fd != 0 {
+ n += 1 + sovGateway(uint64(m.Fd))
+ }
+ if m.EOF {
+ n += 2
+ }
+ l = len(m.Data)
+ if l > 0 {
+ n += 1 + l + sovGateway(uint64(l))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
+func (m *ResizeMessage) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ if m.Rows != 0 {
+ n += 1 + sovGateway(uint64(m.Rows))
+ }
+ if m.Cols != 0 {
+ n += 1 + sovGateway(uint64(m.Cols))
+ }
+ if m.XXX_unrecognized != nil {
+ n += len(m.XXX_unrecognized)
+ }
+ return n
+}
+
func sovGateway(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@@ -6922,6 +8663,1380 @@
}
return nil
}
+func (m *NewContainerRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: NewContainerRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: NewContainerRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ContainerID", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ContainerID = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Mounts", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Mounts = append(m.Mounts, &pb.Mount{})
+ if err := m.Mounts[len(m.Mounts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Network", wireType)
+ }
+ m.Network = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Network |= pb.NetMode(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Platform", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Platform == nil {
+ m.Platform = &pb.Platform{}
+ }
+ if err := m.Platform.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 5:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Constraints", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Constraints == nil {
+ m.Constraints = &pb.WorkerConstraints{}
+ }
+ if err := m.Constraints.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *NewContainerResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: NewContainerResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: NewContainerResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ReleaseContainerRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ReleaseContainerRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ReleaseContainerRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ContainerID", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ContainerID = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ReleaseContainerResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ReleaseContainerResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ReleaseContainerResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ExecMessage) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ExecMessage: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ExecMessage: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ProcessID", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ProcessID = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Init", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &InitMessage{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Input = &ExecMessage_Init{v}
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field File", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &FdMessage{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Input = &ExecMessage_File{v}
+ iNdEx = postIndex
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Resize", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &ResizeMessage{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Input = &ExecMessage_Resize{v}
+ iNdEx = postIndex
+ case 5:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Started", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &StartedMessage{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Input = &ExecMessage_Started{v}
+ iNdEx = postIndex
+ case 6:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Exit", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &ExitMessage{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Input = &ExecMessage_Exit{v}
+ iNdEx = postIndex
+ case 7:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Done", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ v := &DoneMessage{}
+ if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ m.Input = &ExecMessage_Done{v}
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *InitMessage) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: InitMessage: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: InitMessage: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ContainerID", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ContainerID = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Meta", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Meta == nil {
+ m.Meta = &pb.Meta{}
+ }
+ if err := m.Meta.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType == 0 {
+ var v uint32
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= uint32(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Fds = append(m.Fds, v)
+ } else if wireType == 2 {
+ var packedLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ packedLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if packedLen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + packedLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ var elementCount int
+ var count int
+ for _, integer := range dAtA[iNdEx:postIndex] {
+ if integer < 128 {
+ count++
+ }
+ }
+ elementCount = count
+ if elementCount != 0 && len(m.Fds) == 0 {
+ m.Fds = make([]uint32, 0, elementCount)
+ }
+ for iNdEx < postIndex {
+ var v uint32
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= uint32(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Fds = append(m.Fds, v)
+ }
+ } else {
+ return fmt.Errorf("proto: wrong wireType = %d for field Fds", wireType)
+ }
+ case 4:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Tty", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.Tty = bool(v != 0)
+ case 5:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Security", wireType)
+ }
+ m.Security = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Security |= pb.SecurityMode(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ExitMessage) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ExitMessage: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ExitMessage: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
+ }
+ m.Code = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Code |= uint32(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType)
+ }
+ var msglen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ msglen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if msglen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + msglen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ if m.Error == nil {
+ m.Error = &rpc.Status{}
+ }
+ if err := m.Error.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
+ return err
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *StartedMessage) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: StartedMessage: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: StartedMessage: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *DoneMessage) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: DoneMessage: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: DoneMessage: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *FdMessage) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: FdMessage: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: FdMessage: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Fd", wireType)
+ }
+ m.Fd = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Fd |= uint32(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field EOF", wireType)
+ }
+ var v int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ v |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ m.EOF = bool(v != 0)
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthGateway
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...)
+ if m.Data == nil {
+ m.Data = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *ResizeMessage) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: ResizeMessage: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: ResizeMessage: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Rows", wireType)
+ }
+ m.Rows = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Rows |= uint32(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Cols", wireType)
+ }
+ m.Cols = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowGateway
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.Cols |= uint32(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipGateway(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthGateway
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.XXX_unrecognized = append(m.XXX_unrecognized, dAtA[iNdEx:iNdEx+skippy]...)
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
func skipGateway(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.proto b/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.proto
index 8b4725e..ea870e2 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.proto
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/pb/gateway.proto
@@ -28,6 +28,10 @@
rpc Return(ReturnRequest) returns (ReturnResponse);
// apicaps:CapFrontendInputs
rpc Inputs(InputsRequest) returns (InputsResponse);
+
+ rpc NewContainer(NewContainerRequest) returns (NewContainerResponse);
+ rpc ReleaseContainer(ReleaseContainerRequest) returns (ReleaseContainerResponse);
+ rpc ExecProcess(stream ExecMessage) returns (stream ExecMessage);
}
message Result {
@@ -162,3 +166,71 @@
repeated moby.buildkit.v1.apicaps.APICap LLBCaps = 2 [(gogoproto.nullable) = false];
repeated moby.buildkit.v1.types.WorkerRecord Workers = 3;
}
+
+message NewContainerRequest {
+ string ContainerID = 1;
+ // For mount input values we can use random identifiers passed with ref
+ repeated pb.Mount Mounts = 2;
+ pb.NetMode Network = 3;
+ pb.Platform platform = 4;
+ pb.WorkerConstraints constraints = 5;
+}
+
+message NewContainerResponse{}
+
+message ReleaseContainerRequest {
+ string ContainerID = 1;
+}
+
+message ReleaseContainerResponse{}
+
+message ExecMessage {
+ string ProcessID = 1;
+ oneof Input {
+ // InitMessage sent from client to server will start a new process in a
+ // container
+ InitMessage Init = 2;
+ // FdMessage used from client to server for input (stdin) and
+ // from server to client for output (stdout, stderr)
+ FdMessage File = 3;
+ // ResizeMessage used from client to server for terminal resize events
+ ResizeMessage Resize = 4;
+ // StartedMessage sent from server to client after InitMessage to
+ // indicate the process has started.
+ StartedMessage Started = 5;
+ // ExitMessage sent from server to client will contain the exit code
+ // when the process ends.
+ ExitMessage Exit = 6;
+ // DoneMessage from server to client will be the last message for any
+ // process. Note that FdMessage might be sent after ExitMessage.
+ DoneMessage Done = 7;
+ }
+}
+
+message InitMessage{
+ string ContainerID = 1;
+ pb.Meta Meta = 2;
+ repeated uint32 Fds = 3;
+ bool Tty = 4;
+ pb.SecurityMode Security = 5;
+}
+
+message ExitMessage {
+ uint32 Code = 1;
+ google.rpc.Status Error = 2;
+}
+
+message StartedMessage{}
+
+message DoneMessage{}
+
+message FdMessage{
+ uint32 Fd = 1; // what fd the data was from
+ bool EOF = 2; // true if eof was reached
+ bytes Data = 3;
+}
+
+message ResizeMessage{
+ uint32 Rows = 1;
+ uint32 Cols = 2;
+}
diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/pb/generate.go b/vendor/github.com/moby/buildkit/frontend/gateway/pb/generate.go
index 4ab07c6..e17b9da 100644
--- a/vendor/github.com/moby/buildkit/frontend/gateway/pb/generate.go
+++ b/vendor/github.com/moby/buildkit/frontend/gateway/pb/generate.go
@@ -1,3 +1,3 @@
-package moby_buildkit_v1_frontend
+package moby_buildkit_v1_frontend //nolint:golint
//go:generate protoc -I=. -I=../../../vendor/ -I=../../../../../../ --gogo_out=plugins=grpc:. gateway.proto
diff --git a/vendor/github.com/moby/buildkit/frontend/subrequests/describe.go b/vendor/github.com/moby/buildkit/frontend/subrequests/describe.go
new file mode 100644
index 0000000..cc8053e
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/frontend/subrequests/describe.go
@@ -0,0 +1,63 @@
+package subrequests
+
+import (
+ "context"
+ "encoding/json"
+
+ "github.com/moby/buildkit/frontend/gateway/client"
+ gwpb "github.com/moby/buildkit/frontend/gateway/pb"
+ "github.com/moby/buildkit/solver/errdefs"
+ "github.com/pkg/errors"
+)
+
+const RequestSubrequestsDescribe = "frontend.subrequests.describe"
+
+var SubrequestsDescribeDefinition = Request{
+ Name: RequestSubrequestsDescribe,
+ Version: "1.0.0",
+ Type: TypeRPC,
+ Description: "List available subrequest types",
+ Metadata: []Named{
+ {
+ Name: "result.json",
+ },
+ },
+}
+
+func Describe(ctx context.Context, c client.Client) ([]Request, error) {
+ gwcaps := c.BuildOpts().Caps
+
+ if err := (&gwcaps).Supports(gwpb.CapFrontendCaps); err != nil {
+ return nil, errdefs.NewUnsupportedSubrequestError(RequestSubrequestsDescribe)
+ }
+
+ res, err := c.Solve(ctx, client.SolveRequest{
+ FrontendOpt: map[string]string{
+ "requestid": RequestSubrequestsDescribe,
+ "frontend.caps": "moby.buildkit.frontend.subrequests",
+ },
+ Frontend: "dockerfile.v0",
+ })
+ if err != nil {
+ var reqErr *errdefs.UnsupportedSubrequestError
+ if errors.As(err, &reqErr) {
+ return nil, err
+ }
+ var capErr *errdefs.UnsupportedFrontendCapError
+ if errors.As(err, &capErr) {
+ return nil, errdefs.NewUnsupportedSubrequestError(RequestSubrequestsDescribe)
+ }
+ return nil, err
+ }
+
+ dt, ok := res.Metadata["result.json"]
+ if !ok {
+ return nil, errors.Errorf("no result.json metadata in response")
+ }
+
+ var reqs []Request
+ if err := json.Unmarshal(dt, &reqs); err != nil {
+ return nil, errors.Wrap(err, "failed to parse describe result")
+ }
+ return reqs, nil
+}
diff --git a/vendor/github.com/moby/buildkit/frontend/subrequests/types.go b/vendor/github.com/moby/buildkit/frontend/subrequests/types.go
new file mode 100644
index 0000000..db62afe
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/frontend/subrequests/types.go
@@ -0,0 +1,21 @@
+package subrequests
+
+type Request struct {
+ Name string `json:"name"`
+ Version string `json:"version"`
+ Type RequestType `json:"type"`
+ Description string `json:"description"`
+ Opts []Named `json:"opts"`
+ Inputs []Named `json:"inputs"`
+ Metadata []Named `json:"metadata"`
+ Refs []Named `json:"refs"`
+}
+
+type Named struct {
+ Name string `json:"name"`
+ Description string `json:"description"`
+}
+
+type RequestType string
+
+const TypeRPC RequestType = "rpc"
diff --git a/vendor/github.com/moby/buildkit/go.mod b/vendor/github.com/moby/buildkit/go.mod
index f92a2b7..6736953 100644
--- a/vendor/github.com/moby/buildkit/go.mod
+++ b/vendor/github.com/moby/buildkit/go.mod
@@ -3,76 +3,77 @@
go 1.13
require (
- github.com/AkihiroSuda/containerd-fuse-overlayfs v0.0.0-20200512015515-32086ef23a5a
- github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
+ github.com/AkihiroSuda/containerd-fuse-overlayfs v1.0.0
github.com/BurntSushi/toml v0.3.1
- github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5
- github.com/apache/thrift v0.0.0-20161221203622-b2a4d4ae21c7 // indirect
+ github.com/Microsoft/go-winio v0.4.15-0.20200908182639-5b44b70ab3ab
+ github.com/Microsoft/hcsshim v0.8.9
github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58 // indirect
- github.com/containerd/cgroups v0.0.0-20200327175542-b44481373989 // indirect
- github.com/containerd/console v1.0.0
- github.com/containerd/containerd v1.4.0-0
- github.com/containerd/continuity v0.0.0-20200413184840-d3ef23f19fbb
- github.com/containerd/fifo v0.0.0-20200410184934-f15a3290365b // indirect
- github.com/containerd/go-cni v0.0.0-20200107172653-c154a49e2c75
- github.com/containerd/go-runc v0.0.0-20200220073739-7016d3ce2328
- github.com/coreos/go-systemd/v22 v22.0.0
- github.com/docker/cli v0.0.0-20200227165822-2298e6a3fe24
+ github.com/containerd/console v1.0.1
+ github.com/containerd/containerd v1.4.1-0.20200903181227-d4e78200d6da
+ github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe
+ github.com/containerd/go-cni v1.0.1
+ github.com/containerd/go-runc v0.0.0-20201020171139-16b287bc67d0
+ github.com/containerd/stargz-snapshotter v0.0.0-20201027054423-3a04e4c2c116
+ github.com/containerd/typeurl v1.0.1
+ github.com/coreos/go-systemd/v22 v22.1.0
+ github.com/docker/cli v20.10.0-beta1.0.20201029214301-1d20b15adc38+incompatible
github.com/docker/distribution v2.7.1+incompatible
- github.com/docker/docker v0.0.0
- github.com/docker/docker-credential-helpers v0.6.0 // indirect
- github.com/docker/go-connections v0.3.0
- github.com/docker/libnetwork v0.8.0-dev.2.0.20200226230617-d8334ccdb9be
- github.com/gofrs/flock v0.7.0
+ github.com/docker/docker v20.10.0-beta1.0.20201110211921-af34b94a78a1+incompatible
+ github.com/docker/go-connections v0.4.0
+ github.com/docker/libnetwork v0.8.0-dev.2.0.20200917202933-d0951081b35f
+ github.com/gofrs/flock v0.7.3
github.com/gogo/googleapis v1.3.2
github.com/gogo/protobuf v1.3.1
- github.com/golang/protobuf v1.3.3
- github.com/google/go-cmp v0.4.0
- github.com/google/shlex v0.0.0-20150127133951-6f45313302b9
- github.com/google/uuid v1.1.1 // indirect
- github.com/gorilla/mux v1.7.4 // indirect
+ // protobuf: the actual version is replaced in replace()
+ github.com/golang/protobuf v1.4.2
+ github.com/google/go-cmp v0.4.1
+ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
+ github.com/gorilla/mux v1.8.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.2.0
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645
github.com/hashicorp/go-immutable-radix v1.0.0
- github.com/hashicorp/golang-lru v0.5.1
+ github.com/hashicorp/golang-lru v0.5.3
github.com/hashicorp/uuid v0.0.0-20160311170451-ebb0a03e909c // indirect
- github.com/imdario/mergo v0.3.9 // indirect
github.com/ishidawataru/sctp v0.0.0-20191218070446-00ab2ac2db07 // indirect
github.com/jaguilar/vt100 v0.0.0-20150826170717-2703a27b14ea
github.com/mitchellh/hashstructure v1.0.0
- github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c
+ github.com/moby/locker v1.0.1
+ github.com/moby/sys/mount v0.1.1 // indirect; force more current version of sys/mount than go mod selects automatically
+ github.com/moby/sys/mountinfo v0.4.0 // indirect; force more current version of sys/mountinfo than go mod selects automatically
+ github.com/moby/term v0.0.0-20200915141129-7f0af18e79f2 // indirect
+ github.com/morikuni/aec v1.0.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.1
- github.com/opencontainers/runc v1.0.0-rc10
- github.com/opencontainers/runtime-spec v1.0.2
- github.com/opencontainers/selinux v1.5.1 // indirect
- github.com/opentracing-contrib/go-stdlib v0.0.0-20171029140428-b1a47cfbdd75
- github.com/opentracing/opentracing-go v1.1.0
+ github.com/opencontainers/runc v1.0.0-rc92
+ github.com/opencontainers/runtime-spec v1.0.3-0.20200728170252-4d89ac9fbff6
+ github.com/opentracing-contrib/go-stdlib v1.0.0
+ github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
- github.com/pkg/profile v1.2.1
+ github.com/pkg/profile v1.5.0
github.com/serialx/hashring v0.0.0-20190422032157-8b2912629002
- github.com/sirupsen/logrus v1.4.2
+ github.com/sirupsen/logrus v1.7.0
github.com/stretchr/testify v1.5.1
- github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2 // indirect
- github.com/tonistiigi/fsutil v0.0.0-20200512175118-ae3a8d753069
+ github.com/tonistiigi/fsutil v0.0.0-20200724193237-c3ed55f3b481
github.com/tonistiigi/units v0.0.0-20180711220420-6950e57a87ea
- github.com/uber/jaeger-client-go v2.11.2+incompatible
- github.com/uber/jaeger-lib v1.2.1 // indirect
+ github.com/uber/jaeger-client-go v2.25.0+incompatible
+ github.com/uber/jaeger-lib v2.2.0+incompatible // indirect
github.com/urfave/cli v1.22.2
- github.com/vishvananda/netlink v1.1.0 // indirect
- go.etcd.io/bbolt v1.3.3
- golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d
- golang.org/x/net v0.0.0-20200226121028-0de0cce0169b
- golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
- golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527
- golang.org/x/time v0.0.0-20191024005414-555d28b269f0
- google.golang.org/genproto v0.0.0-20200227132054-3f1135a288c9
- google.golang.org/grpc v1.27.1
+ go.etcd.io/bbolt v1.3.5
+ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
+ golang.org/x/net v0.0.0-20200707034311-ab3426394381
+ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
+ golang.org/x/sys v0.0.0-20200922070232-aee5d888a860
+ golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1
+ // genproto: the actual version is replaced in replace()
+ google.golang.org/genproto v0.0.0-20200527145253-8367513e4ece
+ google.golang.org/grpc v1.29.1
)
replace (
- github.com/containerd/containerd => github.com/containerd/containerd v1.3.1-0.20200512144102-f13ba8f2f2fd
- github.com/docker/docker => github.com/docker/docker v17.12.0-ce-rc1.0.20200310163718-4634ce647cf2+incompatible
+ // protobuf: corresponds to containerd
+ github.com/golang/protobuf => github.com/golang/protobuf v1.3.5
github.com/hashicorp/go-immutable-radix => github.com/tonistiigi/go-immutable-radix v0.0.0-20170803185627-826af9ccf0fe
github.com/jaguilar/vt100 => github.com/tonistiigi/vt100 v0.0.0-20190402012908-ad4c4a574305
+ // genproto: corresponds to containerd
+ google.golang.org/genproto => google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63
)
diff --git a/vendor/github.com/moby/buildkit/session/auth/auth.go b/vendor/github.com/moby/buildkit/session/auth/auth.go
index 6a65eb8..864ed5d 100644
--- a/vendor/github.com/moby/buildkit/session/auth/auth.go
+++ b/vendor/github.com/moby/buildkit/session/auth/auth.go
@@ -2,16 +2,33 @@
import (
"context"
+ "crypto/subtle"
+ "math/rand"
+ "sync"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/util/grpcerrors"
+ "github.com/pkg/errors"
+ "golang.org/x/crypto/nacl/sign"
"google.golang.org/grpc/codes"
)
-func CredentialsFunc(sm *session.Manager, g session.Group) func(string) (string, string, error) {
- return func(host string) (string, string, error) {
- var user, secret string
- err := sm.Any(context.TODO(), g, func(ctx context.Context, _ string, c session.Caller) error {
+var salt []byte
+var saltOnce sync.Once
+
+// getSalt returns unique component per daemon restart to avoid persistent keys
+func getSalt() []byte {
+ saltOnce.Do(func() {
+ salt = make([]byte, 32)
+ rand.Read(salt)
+ })
+ return salt
+}
+
+func CredentialsFunc(sm *session.Manager, g session.Group) func(string) (session, username, secret string, err error) {
+ return func(host string) (string, string, string, error) {
+ var sessionID, user, secret string
+ err := sm.Any(context.TODO(), g, func(ctx context.Context, id string, c session.Caller) error {
client := NewAuthClient(c.Conn())
resp, err := client.Credentials(ctx, &CredentialsRequest{
@@ -23,13 +40,91 @@
}
return err
}
+ sessionID = id
user = resp.Username
secret = resp.Secret
return nil
})
if err != nil {
- return "", "", err
+ return "", "", "", err
}
- return user, secret, nil
+ return sessionID, user, secret, nil
}
}
+
+func FetchToken(req *FetchTokenRequest, sm *session.Manager, g session.Group) (resp *FetchTokenResponse, err error) {
+ err = sm.Any(context.TODO(), g, func(ctx context.Context, id string, c session.Caller) error {
+ client := NewAuthClient(c.Conn())
+
+ resp, err = client.FetchToken(ctx, req)
+ if err != nil {
+ return err
+ }
+ return nil
+ })
+ if err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+func VerifyTokenAuthority(host string, pubKey *[32]byte, sm *session.Manager, g session.Group) (sessionID string, ok bool, err error) {
+ var verified bool
+ err = sm.Any(context.TODO(), g, func(ctx context.Context, id string, c session.Caller) error {
+ client := NewAuthClient(c.Conn())
+
+ payload := make([]byte, 32)
+ rand.Read(payload)
+ resp, err := client.VerifyTokenAuthority(ctx, &VerifyTokenAuthorityRequest{
+ Host: host,
+ Salt: getSalt(),
+ Payload: payload,
+ })
+ if err != nil {
+ if grpcerrors.Code(err) == codes.Unimplemented {
+ return nil
+ }
+ return err
+ }
+ var dt []byte
+ dt, ok = sign.Open(nil, resp.Signed, pubKey)
+ if ok && subtle.ConstantTimeCompare(dt, payload) == 1 {
+ verified = true
+ }
+ sessionID = id
+ return nil
+ })
+ if err != nil {
+ return "", false, err
+ }
+ return sessionID, verified, nil
+}
+
+func GetTokenAuthority(host string, sm *session.Manager, g session.Group) (sessionID string, pubKey *[32]byte, err error) {
+ err = sm.Any(context.TODO(), g, func(ctx context.Context, id string, c session.Caller) error {
+ client := NewAuthClient(c.Conn())
+
+ resp, err := client.GetTokenAuthority(ctx, &GetTokenAuthorityRequest{
+ Host: host,
+ Salt: getSalt(),
+ })
+ if err != nil {
+ if grpcerrors.Code(err) == codes.Unimplemented || grpcerrors.Code(err) == codes.Unavailable {
+ return nil
+ }
+ return err
+ }
+ if len(resp.PublicKey) != 32 {
+ return errors.Errorf("invalid pubkey length %d", len(pubKey))
+ }
+
+ sessionID = id
+ pubKey = new([32]byte)
+ copy((*pubKey)[:], resp.PublicKey)
+ return nil
+ })
+ if err != nil {
+ return "", nil, err
+ }
+ return sessionID, pubKey, nil
+}
diff --git a/vendor/github.com/moby/buildkit/session/auth/auth.pb.go b/vendor/github.com/moby/buildkit/session/auth/auth.pb.go
index 04afb3d..ffe60e9 100644
--- a/vendor/github.com/moby/buildkit/session/auth/auth.pb.go
+++ b/vendor/github.com/moby/buildkit/session/auth/auth.pb.go
@@ -4,6 +4,7 @@
package auth
import (
+ bytes "bytes"
context "context"
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
@@ -122,30 +123,384 @@
return ""
}
+type FetchTokenRequest struct {
+ ClientID string `protobuf:"bytes,1,opt,name=ClientID,proto3" json:"ClientID,omitempty"`
+ Host string `protobuf:"bytes,2,opt,name=Host,proto3" json:"Host,omitempty"`
+ Realm string `protobuf:"bytes,3,opt,name=Realm,proto3" json:"Realm,omitempty"`
+ Service string `protobuf:"bytes,4,opt,name=Service,proto3" json:"Service,omitempty"`
+ Scopes []string `protobuf:"bytes,5,rep,name=Scopes,proto3" json:"Scopes,omitempty"`
+}
+
+func (m *FetchTokenRequest) Reset() { *m = FetchTokenRequest{} }
+func (*FetchTokenRequest) ProtoMessage() {}
+func (*FetchTokenRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8bbd6f3875b0e874, []int{2}
+}
+func (m *FetchTokenRequest) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *FetchTokenRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_FetchTokenRequest.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *FetchTokenRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_FetchTokenRequest.Merge(m, src)
+}
+func (m *FetchTokenRequest) XXX_Size() int {
+ return m.Size()
+}
+func (m *FetchTokenRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_FetchTokenRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_FetchTokenRequest proto.InternalMessageInfo
+
+func (m *FetchTokenRequest) GetClientID() string {
+ if m != nil {
+ return m.ClientID
+ }
+ return ""
+}
+
+func (m *FetchTokenRequest) GetHost() string {
+ if m != nil {
+ return m.Host
+ }
+ return ""
+}
+
+func (m *FetchTokenRequest) GetRealm() string {
+ if m != nil {
+ return m.Realm
+ }
+ return ""
+}
+
+func (m *FetchTokenRequest) GetService() string {
+ if m != nil {
+ return m.Service
+ }
+ return ""
+}
+
+func (m *FetchTokenRequest) GetScopes() []string {
+ if m != nil {
+ return m.Scopes
+ }
+ return nil
+}
+
+type FetchTokenResponse struct {
+ Token string `protobuf:"bytes,1,opt,name=Token,proto3" json:"Token,omitempty"`
+ ExpiresIn int64 `protobuf:"varint,2,opt,name=ExpiresIn,proto3" json:"ExpiresIn,omitempty"`
+ IssuedAt int64 `protobuf:"varint,3,opt,name=IssuedAt,proto3" json:"IssuedAt,omitempty"`
+}
+
+func (m *FetchTokenResponse) Reset() { *m = FetchTokenResponse{} }
+func (*FetchTokenResponse) ProtoMessage() {}
+func (*FetchTokenResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8bbd6f3875b0e874, []int{3}
+}
+func (m *FetchTokenResponse) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *FetchTokenResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_FetchTokenResponse.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *FetchTokenResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_FetchTokenResponse.Merge(m, src)
+}
+func (m *FetchTokenResponse) XXX_Size() int {
+ return m.Size()
+}
+func (m *FetchTokenResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_FetchTokenResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_FetchTokenResponse proto.InternalMessageInfo
+
+func (m *FetchTokenResponse) GetToken() string {
+ if m != nil {
+ return m.Token
+ }
+ return ""
+}
+
+func (m *FetchTokenResponse) GetExpiresIn() int64 {
+ if m != nil {
+ return m.ExpiresIn
+ }
+ return 0
+}
+
+func (m *FetchTokenResponse) GetIssuedAt() int64 {
+ if m != nil {
+ return m.IssuedAt
+ }
+ return 0
+}
+
+type GetTokenAuthorityRequest struct {
+ Host string `protobuf:"bytes,1,opt,name=Host,proto3" json:"Host,omitempty"`
+ Salt []byte `protobuf:"bytes,2,opt,name=Salt,proto3" json:"Salt,omitempty"`
+}
+
+func (m *GetTokenAuthorityRequest) Reset() { *m = GetTokenAuthorityRequest{} }
+func (*GetTokenAuthorityRequest) ProtoMessage() {}
+func (*GetTokenAuthorityRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8bbd6f3875b0e874, []int{4}
+}
+func (m *GetTokenAuthorityRequest) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *GetTokenAuthorityRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_GetTokenAuthorityRequest.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *GetTokenAuthorityRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_GetTokenAuthorityRequest.Merge(m, src)
+}
+func (m *GetTokenAuthorityRequest) XXX_Size() int {
+ return m.Size()
+}
+func (m *GetTokenAuthorityRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_GetTokenAuthorityRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_GetTokenAuthorityRequest proto.InternalMessageInfo
+
+func (m *GetTokenAuthorityRequest) GetHost() string {
+ if m != nil {
+ return m.Host
+ }
+ return ""
+}
+
+func (m *GetTokenAuthorityRequest) GetSalt() []byte {
+ if m != nil {
+ return m.Salt
+ }
+ return nil
+}
+
+type GetTokenAuthorityResponse struct {
+ PublicKey []byte `protobuf:"bytes,1,opt,name=PublicKey,proto3" json:"PublicKey,omitempty"`
+}
+
+func (m *GetTokenAuthorityResponse) Reset() { *m = GetTokenAuthorityResponse{} }
+func (*GetTokenAuthorityResponse) ProtoMessage() {}
+func (*GetTokenAuthorityResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8bbd6f3875b0e874, []int{5}
+}
+func (m *GetTokenAuthorityResponse) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *GetTokenAuthorityResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_GetTokenAuthorityResponse.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *GetTokenAuthorityResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_GetTokenAuthorityResponse.Merge(m, src)
+}
+func (m *GetTokenAuthorityResponse) XXX_Size() int {
+ return m.Size()
+}
+func (m *GetTokenAuthorityResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_GetTokenAuthorityResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_GetTokenAuthorityResponse proto.InternalMessageInfo
+
+func (m *GetTokenAuthorityResponse) GetPublicKey() []byte {
+ if m != nil {
+ return m.PublicKey
+ }
+ return nil
+}
+
+type VerifyTokenAuthorityRequest struct {
+ Host string `protobuf:"bytes,1,opt,name=Host,proto3" json:"Host,omitempty"`
+ Payload []byte `protobuf:"bytes,2,opt,name=Payload,proto3" json:"Payload,omitempty"`
+ Salt []byte `protobuf:"bytes,3,opt,name=Salt,proto3" json:"Salt,omitempty"`
+}
+
+func (m *VerifyTokenAuthorityRequest) Reset() { *m = VerifyTokenAuthorityRequest{} }
+func (*VerifyTokenAuthorityRequest) ProtoMessage() {}
+func (*VerifyTokenAuthorityRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8bbd6f3875b0e874, []int{6}
+}
+func (m *VerifyTokenAuthorityRequest) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *VerifyTokenAuthorityRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_VerifyTokenAuthorityRequest.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *VerifyTokenAuthorityRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_VerifyTokenAuthorityRequest.Merge(m, src)
+}
+func (m *VerifyTokenAuthorityRequest) XXX_Size() int {
+ return m.Size()
+}
+func (m *VerifyTokenAuthorityRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_VerifyTokenAuthorityRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_VerifyTokenAuthorityRequest proto.InternalMessageInfo
+
+func (m *VerifyTokenAuthorityRequest) GetHost() string {
+ if m != nil {
+ return m.Host
+ }
+ return ""
+}
+
+func (m *VerifyTokenAuthorityRequest) GetPayload() []byte {
+ if m != nil {
+ return m.Payload
+ }
+ return nil
+}
+
+func (m *VerifyTokenAuthorityRequest) GetSalt() []byte {
+ if m != nil {
+ return m.Salt
+ }
+ return nil
+}
+
+type VerifyTokenAuthorityResponse struct {
+ Signed []byte `protobuf:"bytes,1,opt,name=Signed,proto3" json:"Signed,omitempty"`
+}
+
+func (m *VerifyTokenAuthorityResponse) Reset() { *m = VerifyTokenAuthorityResponse{} }
+func (*VerifyTokenAuthorityResponse) ProtoMessage() {}
+func (*VerifyTokenAuthorityResponse) Descriptor() ([]byte, []int) {
+ return fileDescriptor_8bbd6f3875b0e874, []int{7}
+}
+func (m *VerifyTokenAuthorityResponse) XXX_Unmarshal(b []byte) error {
+ return m.Unmarshal(b)
+}
+func (m *VerifyTokenAuthorityResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ if deterministic {
+ return xxx_messageInfo_VerifyTokenAuthorityResponse.Marshal(b, m, deterministic)
+ } else {
+ b = b[:cap(b)]
+ n, err := m.MarshalToSizedBuffer(b)
+ if err != nil {
+ return nil, err
+ }
+ return b[:n], nil
+ }
+}
+func (m *VerifyTokenAuthorityResponse) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_VerifyTokenAuthorityResponse.Merge(m, src)
+}
+func (m *VerifyTokenAuthorityResponse) XXX_Size() int {
+ return m.Size()
+}
+func (m *VerifyTokenAuthorityResponse) XXX_DiscardUnknown() {
+ xxx_messageInfo_VerifyTokenAuthorityResponse.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_VerifyTokenAuthorityResponse proto.InternalMessageInfo
+
+func (m *VerifyTokenAuthorityResponse) GetSigned() []byte {
+ if m != nil {
+ return m.Signed
+ }
+ return nil
+}
+
func init() {
proto.RegisterType((*CredentialsRequest)(nil), "moby.filesync.v1.CredentialsRequest")
proto.RegisterType((*CredentialsResponse)(nil), "moby.filesync.v1.CredentialsResponse")
+ proto.RegisterType((*FetchTokenRequest)(nil), "moby.filesync.v1.FetchTokenRequest")
+ proto.RegisterType((*FetchTokenResponse)(nil), "moby.filesync.v1.FetchTokenResponse")
+ proto.RegisterType((*GetTokenAuthorityRequest)(nil), "moby.filesync.v1.GetTokenAuthorityRequest")
+ proto.RegisterType((*GetTokenAuthorityResponse)(nil), "moby.filesync.v1.GetTokenAuthorityResponse")
+ proto.RegisterType((*VerifyTokenAuthorityRequest)(nil), "moby.filesync.v1.VerifyTokenAuthorityRequest")
+ proto.RegisterType((*VerifyTokenAuthorityResponse)(nil), "moby.filesync.v1.VerifyTokenAuthorityResponse")
}
func init() { proto.RegisterFile("auth.proto", fileDescriptor_8bbd6f3875b0e874) }
var fileDescriptor_8bbd6f3875b0e874 = []byte{
- // 233 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x4a, 0x2c, 0x2d, 0xc9,
- 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0xc8, 0xcd, 0x4f, 0xaa, 0xd4, 0x4b, 0xcb, 0xcc,
- 0x49, 0x2d, 0xae, 0xcc, 0x4b, 0xd6, 0x2b, 0x33, 0x54, 0xd2, 0xe0, 0x12, 0x72, 0x2e, 0x4a, 0x4d,
- 0x49, 0xcd, 0x2b, 0xc9, 0x4c, 0xcc, 0x29, 0x0e, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0x12,
- 0xe2, 0x62, 0xf1, 0xc8, 0x2f, 0x2e, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x95,
- 0x3c, 0xb9, 0x84, 0x51, 0x54, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x0a, 0x49, 0x71, 0x71, 0x84,
- 0x16, 0xa7, 0x16, 0xe5, 0x25, 0xe6, 0xa6, 0x42, 0x95, 0xc3, 0xf9, 0x42, 0x62, 0x5c, 0x6c, 0xc1,
- 0xa9, 0xc9, 0x45, 0xa9, 0x25, 0x12, 0x4c, 0x60, 0x19, 0x28, 0xcf, 0x28, 0x89, 0x8b, 0xc5, 0xb1,
- 0xb4, 0x24, 0x43, 0x28, 0x8a, 0x8b, 0x1b, 0xc9, 0x48, 0x21, 0x15, 0x3d, 0x74, 0xe7, 0xe9, 0x61,
- 0xba, 0x4d, 0x4a, 0x95, 0x80, 0x2a, 0x88, 0xbb, 0x9c, 0xac, 0x2e, 0x3c, 0x94, 0x63, 0xb8, 0xf1,
- 0x50, 0x8e, 0xe1, 0xc3, 0x43, 0x39, 0xc6, 0x86, 0x47, 0x72, 0x8c, 0x2b, 0x1e, 0xc9, 0x31, 0x9e,
- 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x2f, 0x1e, 0xc9, 0x31,
- 0x7c, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb,
- 0x31, 0x44, 0xb1, 0x80, 0x02, 0x2b, 0x89, 0x0d, 0x1c, 0x5a, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff,
- 0xff, 0x64, 0x61, 0x71, 0x59, 0x3b, 0x01, 0x00, 0x00,
+ // 513 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xcd, 0x6e, 0xd3, 0x40,
+ 0x10, 0xc7, 0xbd, 0x75, 0xd2, 0x36, 0x43, 0x0f, 0x74, 0x89, 0x90, 0x31, 0xd1, 0xaa, 0x32, 0x45,
+ 0xaa, 0x40, 0x58, 0x02, 0x24, 0x24, 0xb8, 0xb5, 0xe5, 0x2b, 0xe2, 0x52, 0x39, 0x7c, 0x48, 0xbd,
+ 0x20, 0xc7, 0x9e, 0x12, 0x0b, 0xc7, 0x0e, 0xde, 0x75, 0x85, 0x6f, 0xdc, 0xb9, 0xf0, 0x08, 0x1c,
+ 0x79, 0x14, 0x8e, 0x39, 0xf6, 0x48, 0x9c, 0x0b, 0xc7, 0x3c, 0x02, 0xf2, 0x66, 0x9d, 0x04, 0x1c,
+ 0xd2, 0xdc, 0xfc, 0x1f, 0xff, 0x77, 0xe6, 0xb7, 0x33, 0xa3, 0x05, 0x70, 0x53, 0xd1, 0xb3, 0x07,
+ 0x49, 0x2c, 0x62, 0x7a, 0xb5, 0x1f, 0x77, 0x33, 0xfb, 0x2c, 0x08, 0x91, 0x67, 0x91, 0x67, 0x9f,
+ 0xdf, 0xb7, 0x0e, 0x80, 0x1e, 0x27, 0xe8, 0x63, 0x24, 0x02, 0x37, 0xe4, 0x0e, 0x7e, 0x4a, 0x91,
+ 0x0b, 0x4a, 0xa1, 0xf6, 0x32, 0xe6, 0xc2, 0x20, 0x7b, 0xe4, 0xa0, 0xe1, 0xc8, 0x6f, 0xab, 0x0d,
+ 0xd7, 0xfe, 0x72, 0xf2, 0x41, 0x1c, 0x71, 0xa4, 0x26, 0x6c, 0xbf, 0xe1, 0x98, 0x44, 0x6e, 0x1f,
+ 0x95, 0x7d, 0xa6, 0xe9, 0x75, 0xd8, 0xec, 0xa0, 0x97, 0xa0, 0x30, 0x36, 0xe4, 0x1f, 0xa5, 0xac,
+ 0xaf, 0x04, 0x76, 0x9f, 0xa3, 0xf0, 0x7a, 0xaf, 0xe3, 0x8f, 0x18, 0x95, 0x45, 0x4d, 0xd8, 0x3e,
+ 0x0e, 0x03, 0x8c, 0x44, 0xfb, 0x69, 0x99, 0xa9, 0xd4, 0x33, 0xa0, 0x8d, 0x39, 0x10, 0x6d, 0x42,
+ 0xdd, 0x41, 0x37, 0xec, 0x1b, 0xba, 0x0c, 0x4e, 0x05, 0x35, 0x60, 0xab, 0x83, 0xc9, 0x79, 0xe0,
+ 0xa1, 0x51, 0x93, 0xf1, 0x52, 0x4a, 0x1a, 0x2f, 0x1e, 0x20, 0x37, 0xea, 0x7b, 0xba, 0xa4, 0x91,
+ 0xca, 0xf2, 0x81, 0x2e, 0xc2, 0xa8, 0x7b, 0x35, 0xa1, 0x2e, 0x03, 0x0a, 0x65, 0x2a, 0x68, 0x0b,
+ 0x1a, 0xcf, 0x3e, 0x0f, 0x82, 0x04, 0x79, 0x3b, 0x92, 0x30, 0xba, 0x33, 0x0f, 0x14, 0x37, 0x68,
+ 0x73, 0x9e, 0xa2, 0x7f, 0x28, 0x24, 0x94, 0xee, 0xcc, 0xb4, 0x75, 0x04, 0xc6, 0x0b, 0x14, 0x32,
+ 0xcb, 0x61, 0x2a, 0x7a, 0x71, 0x12, 0x88, 0x6c, 0x45, 0xbb, 0x8b, 0x58, 0xc7, 0x0d, 0xa7, 0x37,
+ 0xde, 0x71, 0xe4, 0xb7, 0xf5, 0x18, 0x6e, 0x2c, 0xc9, 0xa1, 0x80, 0x5b, 0xd0, 0x38, 0x49, 0xbb,
+ 0x61, 0xe0, 0xbd, 0xc2, 0x4c, 0x66, 0xda, 0x71, 0xe6, 0x01, 0xeb, 0x3d, 0xdc, 0x7c, 0x8b, 0x49,
+ 0x70, 0x96, 0xad, 0x4f, 0x60, 0xc0, 0xd6, 0x89, 0x9b, 0x85, 0xb1, 0xeb, 0x2b, 0x88, 0x52, 0xce,
+ 0xd8, 0xf4, 0x05, 0xb6, 0x47, 0xd0, 0x5a, 0x5e, 0x40, 0xe1, 0x15, 0xdd, 0x0f, 0x3e, 0x44, 0xe8,
+ 0x2b, 0x36, 0xa5, 0x1e, 0x7c, 0xd7, 0xa1, 0x56, 0xb8, 0xe9, 0x29, 0x5c, 0x59, 0xd8, 0x2f, 0xba,
+ 0x6f, 0xff, 0xbb, 0xab, 0x76, 0x75, 0x51, 0xcd, 0xdb, 0x97, 0xb8, 0x54, 0xf1, 0x77, 0x00, 0xf3,
+ 0x11, 0xd3, 0x5b, 0xd5, 0x43, 0x95, 0x6d, 0x34, 0xf7, 0x57, 0x9b, 0x54, 0xe2, 0x10, 0x76, 0x2b,
+ 0x13, 0xa1, 0x77, 0xaa, 0x47, 0xff, 0x37, 0x7a, 0xf3, 0xee, 0x5a, 0x5e, 0x55, 0x2d, 0x85, 0xe6,
+ 0xb2, 0x1e, 0xd3, 0x7b, 0xd5, 0x24, 0x2b, 0x86, 0x6d, 0xda, 0xeb, 0xda, 0xa7, 0x65, 0x8f, 0x9e,
+ 0x0c, 0x47, 0x4c, 0xbb, 0x18, 0x31, 0x6d, 0x32, 0x62, 0xe4, 0x4b, 0xce, 0xc8, 0x8f, 0x9c, 0x91,
+ 0x9f, 0x39, 0x23, 0xc3, 0x9c, 0x91, 0x5f, 0x39, 0x23, 0xbf, 0x73, 0xa6, 0x4d, 0x72, 0x46, 0xbe,
+ 0x8d, 0x99, 0x36, 0x1c, 0x33, 0xed, 0x62, 0xcc, 0xb4, 0xd3, 0x5a, 0xf1, 0xee, 0x74, 0x37, 0xe5,
+ 0xc3, 0xf3, 0xf0, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xba, 0xb3, 0x18, 0x70, 0x86, 0x04, 0x00,
+ 0x00,
}
func (this *CredentialsRequest) Equal(that interface{}) bool {
@@ -199,6 +554,182 @@
}
return true
}
+func (this *FetchTokenRequest) Equal(that interface{}) bool {
+ if that == nil {
+ return this == nil
+ }
+
+ that1, ok := that.(*FetchTokenRequest)
+ if !ok {
+ that2, ok := that.(FetchTokenRequest)
+ if ok {
+ that1 = &that2
+ } else {
+ return false
+ }
+ }
+ if that1 == nil {
+ return this == nil
+ } else if this == nil {
+ return false
+ }
+ if this.ClientID != that1.ClientID {
+ return false
+ }
+ if this.Host != that1.Host {
+ return false
+ }
+ if this.Realm != that1.Realm {
+ return false
+ }
+ if this.Service != that1.Service {
+ return false
+ }
+ if len(this.Scopes) != len(that1.Scopes) {
+ return false
+ }
+ for i := range this.Scopes {
+ if this.Scopes[i] != that1.Scopes[i] {
+ return false
+ }
+ }
+ return true
+}
+func (this *FetchTokenResponse) Equal(that interface{}) bool {
+ if that == nil {
+ return this == nil
+ }
+
+ that1, ok := that.(*FetchTokenResponse)
+ if !ok {
+ that2, ok := that.(FetchTokenResponse)
+ if ok {
+ that1 = &that2
+ } else {
+ return false
+ }
+ }
+ if that1 == nil {
+ return this == nil
+ } else if this == nil {
+ return false
+ }
+ if this.Token != that1.Token {
+ return false
+ }
+ if this.ExpiresIn != that1.ExpiresIn {
+ return false
+ }
+ if this.IssuedAt != that1.IssuedAt {
+ return false
+ }
+ return true
+}
+func (this *GetTokenAuthorityRequest) Equal(that interface{}) bool {
+ if that == nil {
+ return this == nil
+ }
+
+ that1, ok := that.(*GetTokenAuthorityRequest)
+ if !ok {
+ that2, ok := that.(GetTokenAuthorityRequest)
+ if ok {
+ that1 = &that2
+ } else {
+ return false
+ }
+ }
+ if that1 == nil {
+ return this == nil
+ } else if this == nil {
+ return false
+ }
+ if this.Host != that1.Host {
+ return false
+ }
+ if !bytes.Equal(this.Salt, that1.Salt) {
+ return false
+ }
+ return true
+}
+func (this *GetTokenAuthorityResponse) Equal(that interface{}) bool {
+ if that == nil {
+ return this == nil
+ }
+
+ that1, ok := that.(*GetTokenAuthorityResponse)
+ if !ok {
+ that2, ok := that.(GetTokenAuthorityResponse)
+ if ok {
+ that1 = &that2
+ } else {
+ return false
+ }
+ }
+ if that1 == nil {
+ return this == nil
+ } else if this == nil {
+ return false
+ }
+ if !bytes.Equal(this.PublicKey, that1.PublicKey) {
+ return false
+ }
+ return true
+}
+func (this *VerifyTokenAuthorityRequest) Equal(that interface{}) bool {
+ if that == nil {
+ return this == nil
+ }
+
+ that1, ok := that.(*VerifyTokenAuthorityRequest)
+ if !ok {
+ that2, ok := that.(VerifyTokenAuthorityRequest)
+ if ok {
+ that1 = &that2
+ } else {
+ return false
+ }
+ }
+ if that1 == nil {
+ return this == nil
+ } else if this == nil {
+ return false
+ }
+ if this.Host != that1.Host {
+ return false
+ }
+ if !bytes.Equal(this.Payload, that1.Payload) {
+ return false
+ }
+ if !bytes.Equal(this.Salt, that1.Salt) {
+ return false
+ }
+ return true
+}
+func (this *VerifyTokenAuthorityResponse) Equal(that interface{}) bool {
+ if that == nil {
+ return this == nil
+ }
+
+ that1, ok := that.(*VerifyTokenAuthorityResponse)
+ if !ok {
+ that2, ok := that.(VerifyTokenAuthorityResponse)
+ if ok {
+ that1 = &that2
+ } else {
+ return false
+ }
+ }
+ if that1 == nil {
+ return this == nil
+ } else if this == nil {
+ return false
+ }
+ if !bytes.Equal(this.Signed, that1.Signed) {
+ return false
+ }
+ return true
+}
func (this *CredentialsRequest) GoString() string {
if this == nil {
return "nil"
@@ -220,6 +751,75 @@
s = append(s, "}")
return strings.Join(s, "")
}
+func (this *FetchTokenRequest) GoString() string {
+ if this == nil {
+ return "nil"
+ }
+ s := make([]string, 0, 9)
+ s = append(s, "&auth.FetchTokenRequest{")
+ s = append(s, "ClientID: "+fmt.Sprintf("%#v", this.ClientID)+",\n")
+ s = append(s, "Host: "+fmt.Sprintf("%#v", this.Host)+",\n")
+ s = append(s, "Realm: "+fmt.Sprintf("%#v", this.Realm)+",\n")
+ s = append(s, "Service: "+fmt.Sprintf("%#v", this.Service)+",\n")
+ s = append(s, "Scopes: "+fmt.Sprintf("%#v", this.Scopes)+",\n")
+ s = append(s, "}")
+ return strings.Join(s, "")
+}
+func (this *FetchTokenResponse) GoString() string {
+ if this == nil {
+ return "nil"
+ }
+ s := make([]string, 0, 7)
+ s = append(s, "&auth.FetchTokenResponse{")
+ s = append(s, "Token: "+fmt.Sprintf("%#v", this.Token)+",\n")
+ s = append(s, "ExpiresIn: "+fmt.Sprintf("%#v", this.ExpiresIn)+",\n")
+ s = append(s, "IssuedAt: "+fmt.Sprintf("%#v", this.IssuedAt)+",\n")
+ s = append(s, "}")
+ return strings.Join(s, "")
+}
+func (this *GetTokenAuthorityRequest) GoString() string {
+ if this == nil {
+ return "nil"
+ }
+ s := make([]string, 0, 6)
+ s = append(s, "&auth.GetTokenAuthorityRequest{")
+ s = append(s, "Host: "+fmt.Sprintf("%#v", this.Host)+",\n")
+ s = append(s, "Salt: "+fmt.Sprintf("%#v", this.Salt)+",\n")
+ s = append(s, "}")
+ return strings.Join(s, "")
+}
+func (this *GetTokenAuthorityResponse) GoString() string {
+ if this == nil {
+ return "nil"
+ }
+ s := make([]string, 0, 5)
+ s = append(s, "&auth.GetTokenAuthorityResponse{")
+ s = append(s, "PublicKey: "+fmt.Sprintf("%#v", this.PublicKey)+",\n")
+ s = append(s, "}")
+ return strings.Join(s, "")
+}
+func (this *VerifyTokenAuthorityRequest) GoString() string {
+ if this == nil {
+ return "nil"
+ }
+ s := make([]string, 0, 7)
+ s = append(s, "&auth.VerifyTokenAuthorityRequest{")
+ s = append(s, "Host: "+fmt.Sprintf("%#v", this.Host)+",\n")
+ s = append(s, "Payload: "+fmt.Sprintf("%#v", this.Payload)+",\n")
+ s = append(s, "Salt: "+fmt.Sprintf("%#v", this.Salt)+",\n")
+ s = append(s, "}")
+ return strings.Join(s, "")
+}
+func (this *VerifyTokenAuthorityResponse) GoString() string {
+ if this == nil {
+ return "nil"
+ }
+ s := make([]string, 0, 5)
+ s = append(s, "&auth.VerifyTokenAuthorityResponse{")
+ s = append(s, "Signed: "+fmt.Sprintf("%#v", this.Signed)+",\n")
+ s = append(s, "}")
+ return strings.Join(s, "")
+}
func valueToGoStringAuth(v interface{}, typ string) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
@@ -242,6 +842,9 @@
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type AuthClient interface {
Credentials(ctx context.Context, in *CredentialsRequest, opts ...grpc.CallOption) (*CredentialsResponse, error)
+ FetchToken(ctx context.Context, in *FetchTokenRequest, opts ...grpc.CallOption) (*FetchTokenResponse, error)
+ GetTokenAuthority(ctx context.Context, in *GetTokenAuthorityRequest, opts ...grpc.CallOption) (*GetTokenAuthorityResponse, error)
+ VerifyTokenAuthority(ctx context.Context, in *VerifyTokenAuthorityRequest, opts ...grpc.CallOption) (*VerifyTokenAuthorityResponse, error)
}
type authClient struct {
@@ -261,9 +864,39 @@
return out, nil
}
+func (c *authClient) FetchToken(ctx context.Context, in *FetchTokenRequest, opts ...grpc.CallOption) (*FetchTokenResponse, error) {
+ out := new(FetchTokenResponse)
+ err := c.cc.Invoke(ctx, "/moby.filesync.v1.Auth/FetchToken", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) GetTokenAuthority(ctx context.Context, in *GetTokenAuthorityRequest, opts ...grpc.CallOption) (*GetTokenAuthorityResponse, error) {
+ out := new(GetTokenAuthorityResponse)
+ err := c.cc.Invoke(ctx, "/moby.filesync.v1.Auth/GetTokenAuthority", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *authClient) VerifyTokenAuthority(ctx context.Context, in *VerifyTokenAuthorityRequest, opts ...grpc.CallOption) (*VerifyTokenAuthorityResponse, error) {
+ out := new(VerifyTokenAuthorityResponse)
+ err := c.cc.Invoke(ctx, "/moby.filesync.v1.Auth/VerifyTokenAuthority", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
// AuthServer is the server API for Auth service.
type AuthServer interface {
Credentials(context.Context, *CredentialsRequest) (*CredentialsResponse, error)
+ FetchToken(context.Context, *FetchTokenRequest) (*FetchTokenResponse, error)
+ GetTokenAuthority(context.Context, *GetTokenAuthorityRequest) (*GetTokenAuthorityResponse, error)
+ VerifyTokenAuthority(context.Context, *VerifyTokenAuthorityRequest) (*VerifyTokenAuthorityResponse, error)
}
// UnimplementedAuthServer can be embedded to have forward compatible implementations.
@@ -273,6 +906,15 @@
func (*UnimplementedAuthServer) Credentials(ctx context.Context, req *CredentialsRequest) (*CredentialsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Credentials not implemented")
}
+func (*UnimplementedAuthServer) FetchToken(ctx context.Context, req *FetchTokenRequest) (*FetchTokenResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method FetchToken not implemented")
+}
+func (*UnimplementedAuthServer) GetTokenAuthority(ctx context.Context, req *GetTokenAuthorityRequest) (*GetTokenAuthorityResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method GetTokenAuthority not implemented")
+}
+func (*UnimplementedAuthServer) VerifyTokenAuthority(ctx context.Context, req *VerifyTokenAuthorityRequest) (*VerifyTokenAuthorityResponse, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method VerifyTokenAuthority not implemented")
+}
func RegisterAuthServer(s *grpc.Server, srv AuthServer) {
s.RegisterService(&_Auth_serviceDesc, srv)
@@ -296,6 +938,60 @@
return interceptor(ctx, in, info, handler)
}
+func _Auth_FetchToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(FetchTokenRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).FetchToken(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/moby.filesync.v1.Auth/FetchToken",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).FetchToken(ctx, req.(*FetchTokenRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_GetTokenAuthority_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(GetTokenAuthorityRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).GetTokenAuthority(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/moby.filesync.v1.Auth/GetTokenAuthority",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).GetTokenAuthority(ctx, req.(*GetTokenAuthorityRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Auth_VerifyTokenAuthority_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(VerifyTokenAuthorityRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(AuthServer).VerifyTokenAuthority(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/moby.filesync.v1.Auth/VerifyTokenAuthority",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(AuthServer).VerifyTokenAuthority(ctx, req.(*VerifyTokenAuthorityRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
var _Auth_serviceDesc = grpc.ServiceDesc{
ServiceName: "moby.filesync.v1.Auth",
HandlerType: (*AuthServer)(nil),
@@ -304,6 +1000,18 @@
MethodName: "Credentials",
Handler: _Auth_Credentials_Handler,
},
+ {
+ MethodName: "FetchToken",
+ Handler: _Auth_FetchToken_Handler,
+ },
+ {
+ MethodName: "GetTokenAuthority",
+ Handler: _Auth_GetTokenAuthority_Handler,
+ },
+ {
+ MethodName: "VerifyTokenAuthority",
+ Handler: _Auth_VerifyTokenAuthority_Handler,
+ },
},
Streams: []grpc.StreamDesc{},
Metadata: "auth.proto",
@@ -376,6 +1084,247 @@
return len(dAtA) - i, nil
}
+func (m *FetchTokenRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *FetchTokenRequest) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *FetchTokenRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if len(m.Scopes) > 0 {
+ for iNdEx := len(m.Scopes) - 1; iNdEx >= 0; iNdEx-- {
+ i -= len(m.Scopes[iNdEx])
+ copy(dAtA[i:], m.Scopes[iNdEx])
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Scopes[iNdEx])))
+ i--
+ dAtA[i] = 0x2a
+ }
+ }
+ if len(m.Service) > 0 {
+ i -= len(m.Service)
+ copy(dAtA[i:], m.Service)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Service)))
+ i--
+ dAtA[i] = 0x22
+ }
+ if len(m.Realm) > 0 {
+ i -= len(m.Realm)
+ copy(dAtA[i:], m.Realm)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Realm)))
+ i--
+ dAtA[i] = 0x1a
+ }
+ if len(m.Host) > 0 {
+ i -= len(m.Host)
+ copy(dAtA[i:], m.Host)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Host)))
+ i--
+ dAtA[i] = 0x12
+ }
+ if len(m.ClientID) > 0 {
+ i -= len(m.ClientID)
+ copy(dAtA[i:], m.ClientID)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.ClientID)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *FetchTokenResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *FetchTokenResponse) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *FetchTokenResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if m.IssuedAt != 0 {
+ i = encodeVarintAuth(dAtA, i, uint64(m.IssuedAt))
+ i--
+ dAtA[i] = 0x18
+ }
+ if m.ExpiresIn != 0 {
+ i = encodeVarintAuth(dAtA, i, uint64(m.ExpiresIn))
+ i--
+ dAtA[i] = 0x10
+ }
+ if len(m.Token) > 0 {
+ i -= len(m.Token)
+ copy(dAtA[i:], m.Token)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Token)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *GetTokenAuthorityRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *GetTokenAuthorityRequest) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *GetTokenAuthorityRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if len(m.Salt) > 0 {
+ i -= len(m.Salt)
+ copy(dAtA[i:], m.Salt)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Salt)))
+ i--
+ dAtA[i] = 0x12
+ }
+ if len(m.Host) > 0 {
+ i -= len(m.Host)
+ copy(dAtA[i:], m.Host)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Host)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *GetTokenAuthorityResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *GetTokenAuthorityResponse) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *GetTokenAuthorityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if len(m.PublicKey) > 0 {
+ i -= len(m.PublicKey)
+ copy(dAtA[i:], m.PublicKey)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.PublicKey)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *VerifyTokenAuthorityRequest) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *VerifyTokenAuthorityRequest) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *VerifyTokenAuthorityRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if len(m.Salt) > 0 {
+ i -= len(m.Salt)
+ copy(dAtA[i:], m.Salt)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Salt)))
+ i--
+ dAtA[i] = 0x1a
+ }
+ if len(m.Payload) > 0 {
+ i -= len(m.Payload)
+ copy(dAtA[i:], m.Payload)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Payload)))
+ i--
+ dAtA[i] = 0x12
+ }
+ if len(m.Host) > 0 {
+ i -= len(m.Host)
+ copy(dAtA[i:], m.Host)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Host)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
+func (m *VerifyTokenAuthorityResponse) Marshal() (dAtA []byte, err error) {
+ size := m.Size()
+ dAtA = make([]byte, size)
+ n, err := m.MarshalToSizedBuffer(dAtA[:size])
+ if err != nil {
+ return nil, err
+ }
+ return dAtA[:n], nil
+}
+
+func (m *VerifyTokenAuthorityResponse) MarshalTo(dAtA []byte) (int, error) {
+ size := m.Size()
+ return m.MarshalToSizedBuffer(dAtA[:size])
+}
+
+func (m *VerifyTokenAuthorityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
+ i := len(dAtA)
+ _ = i
+ var l int
+ _ = l
+ if len(m.Signed) > 0 {
+ i -= len(m.Signed)
+ copy(dAtA[i:], m.Signed)
+ i = encodeVarintAuth(dAtA, i, uint64(len(m.Signed)))
+ i--
+ dAtA[i] = 0xa
+ }
+ return len(dAtA) - i, nil
+}
+
func encodeVarintAuth(dAtA []byte, offset int, v uint64) int {
offset -= sovAuth(v)
base := offset
@@ -417,6 +1366,120 @@
return n
}
+func (m *FetchTokenRequest) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.ClientID)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ l = len(m.Host)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ l = len(m.Realm)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ l = len(m.Service)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ if len(m.Scopes) > 0 {
+ for _, s := range m.Scopes {
+ l = len(s)
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ }
+ return n
+}
+
+func (m *FetchTokenResponse) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.Token)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ if m.ExpiresIn != 0 {
+ n += 1 + sovAuth(uint64(m.ExpiresIn))
+ }
+ if m.IssuedAt != 0 {
+ n += 1 + sovAuth(uint64(m.IssuedAt))
+ }
+ return n
+}
+
+func (m *GetTokenAuthorityRequest) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.Host)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ l = len(m.Salt)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ return n
+}
+
+func (m *GetTokenAuthorityResponse) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.PublicKey)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ return n
+}
+
+func (m *VerifyTokenAuthorityRequest) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.Host)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ l = len(m.Payload)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ l = len(m.Salt)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ return n
+}
+
+func (m *VerifyTokenAuthorityResponse) Size() (n int) {
+ if m == nil {
+ return 0
+ }
+ var l int
+ _ = l
+ l = len(m.Signed)
+ if l > 0 {
+ n += 1 + l + sovAuth(uint64(l))
+ }
+ return n
+}
+
func sovAuth(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@@ -444,6 +1507,75 @@
}, "")
return s
}
+func (this *FetchTokenRequest) String() string {
+ if this == nil {
+ return "nil"
+ }
+ s := strings.Join([]string{`&FetchTokenRequest{`,
+ `ClientID:` + fmt.Sprintf("%v", this.ClientID) + `,`,
+ `Host:` + fmt.Sprintf("%v", this.Host) + `,`,
+ `Realm:` + fmt.Sprintf("%v", this.Realm) + `,`,
+ `Service:` + fmt.Sprintf("%v", this.Service) + `,`,
+ `Scopes:` + fmt.Sprintf("%v", this.Scopes) + `,`,
+ `}`,
+ }, "")
+ return s
+}
+func (this *FetchTokenResponse) String() string {
+ if this == nil {
+ return "nil"
+ }
+ s := strings.Join([]string{`&FetchTokenResponse{`,
+ `Token:` + fmt.Sprintf("%v", this.Token) + `,`,
+ `ExpiresIn:` + fmt.Sprintf("%v", this.ExpiresIn) + `,`,
+ `IssuedAt:` + fmt.Sprintf("%v", this.IssuedAt) + `,`,
+ `}`,
+ }, "")
+ return s
+}
+func (this *GetTokenAuthorityRequest) String() string {
+ if this == nil {
+ return "nil"
+ }
+ s := strings.Join([]string{`&GetTokenAuthorityRequest{`,
+ `Host:` + fmt.Sprintf("%v", this.Host) + `,`,
+ `Salt:` + fmt.Sprintf("%v", this.Salt) + `,`,
+ `}`,
+ }, "")
+ return s
+}
+func (this *GetTokenAuthorityResponse) String() string {
+ if this == nil {
+ return "nil"
+ }
+ s := strings.Join([]string{`&GetTokenAuthorityResponse{`,
+ `PublicKey:` + fmt.Sprintf("%v", this.PublicKey) + `,`,
+ `}`,
+ }, "")
+ return s
+}
+func (this *VerifyTokenAuthorityRequest) String() string {
+ if this == nil {
+ return "nil"
+ }
+ s := strings.Join([]string{`&VerifyTokenAuthorityRequest{`,
+ `Host:` + fmt.Sprintf("%v", this.Host) + `,`,
+ `Payload:` + fmt.Sprintf("%v", this.Payload) + `,`,
+ `Salt:` + fmt.Sprintf("%v", this.Salt) + `,`,
+ `}`,
+ }, "")
+ return s
+}
+func (this *VerifyTokenAuthorityResponse) String() string {
+ if this == nil {
+ return "nil"
+ }
+ s := strings.Join([]string{`&VerifyTokenAuthorityResponse{`,
+ `Signed:` + fmt.Sprintf("%v", this.Signed) + `,`,
+ `}`,
+ }, "")
+ return s
+}
func valueToStringAuth(v interface{}) string {
rv := reflect.ValueOf(v)
if rv.IsNil() {
@@ -654,6 +1786,788 @@
}
return nil
}
+func (m *FetchTokenRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: FetchTokenRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: FetchTokenRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ClientID = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Host", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Host = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Realm", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Realm = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 4:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Service", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Service = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 5:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Scopes", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Scopes = append(m.Scopes, string(dAtA[iNdEx:postIndex]))
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *FetchTokenResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: FetchTokenResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: FetchTokenResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Token = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ExpiresIn", wireType)
+ }
+ m.ExpiresIn = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.ExpiresIn |= int64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ case 3:
+ if wireType != 0 {
+ return fmt.Errorf("proto: wrong wireType = %d for field IssuedAt", wireType)
+ }
+ m.IssuedAt = 0
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ m.IssuedAt |= int64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *GetTokenAuthorityRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: GetTokenAuthorityRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: GetTokenAuthorityRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Host", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Host = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Salt = append(m.Salt[:0], dAtA[iNdEx:postIndex]...)
+ if m.Salt == nil {
+ m.Salt = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *GetTokenAuthorityResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: GetTokenAuthorityResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: GetTokenAuthorityResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.PublicKey = append(m.PublicKey[:0], dAtA[iNdEx:postIndex]...)
+ if m.PublicKey == nil {
+ m.PublicKey = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *VerifyTokenAuthorityRequest) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: VerifyTokenAuthorityRequest: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: VerifyTokenAuthorityRequest: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Host", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Host = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
+ case 2:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...)
+ if m.Payload == nil {
+ m.Payload = []byte{}
+ }
+ iNdEx = postIndex
+ case 3:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Salt", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Salt = append(m.Salt[:0], dAtA[iNdEx:postIndex]...)
+ if m.Salt == nil {
+ m.Salt = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
+func (m *VerifyTokenAuthorityResponse) Unmarshal(dAtA []byte) error {
+ l := len(dAtA)
+ iNdEx := 0
+ for iNdEx < l {
+ preIndex := iNdEx
+ var wire uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ wire |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ fieldNum := int32(wire >> 3)
+ wireType := int(wire & 0x7)
+ if wireType == 4 {
+ return fmt.Errorf("proto: VerifyTokenAuthorityResponse: wiretype end group for non-group")
+ }
+ if fieldNum <= 0 {
+ return fmt.Errorf("proto: VerifyTokenAuthorityResponse: illegal tag %d (wire type %d)", fieldNum, wire)
+ }
+ switch fieldNum {
+ case 1:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Signed", wireType)
+ }
+ var byteLen int
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowAuth
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ byteLen |= int(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ if byteLen < 0 {
+ return ErrInvalidLengthAuth
+ }
+ postIndex := iNdEx + byteLen
+ if postIndex < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Signed = append(m.Signed[:0], dAtA[iNdEx:postIndex]...)
+ if m.Signed == nil {
+ m.Signed = []byte{}
+ }
+ iNdEx = postIndex
+ default:
+ iNdEx = preIndex
+ skippy, err := skipAuth(dAtA[iNdEx:])
+ if err != nil {
+ return err
+ }
+ if skippy < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) < 0 {
+ return ErrInvalidLengthAuth
+ }
+ if (iNdEx + skippy) > l {
+ return io.ErrUnexpectedEOF
+ }
+ iNdEx += skippy
+ }
+ }
+
+ if iNdEx > l {
+ return io.ErrUnexpectedEOF
+ }
+ return nil
+}
func skipAuth(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
diff --git a/vendor/github.com/moby/buildkit/session/auth/auth.proto b/vendor/github.com/moby/buildkit/session/auth/auth.proto
index 5933127..139b0d0 100644
--- a/vendor/github.com/moby/buildkit/session/auth/auth.proto
+++ b/vendor/github.com/moby/buildkit/session/auth/auth.proto
@@ -6,9 +6,11 @@
service Auth{
rpc Credentials(CredentialsRequest) returns (CredentialsResponse);
+ rpc FetchToken(FetchTokenRequest) returns (FetchTokenResponse);
+ rpc GetTokenAuthority(GetTokenAuthorityRequest) returns (GetTokenAuthorityResponse);
+ rpc VerifyTokenAuthority(VerifyTokenAuthorityRequest) returns (VerifyTokenAuthorityResponse);
}
-
message CredentialsRequest {
string Host = 1;
}
@@ -17,3 +19,36 @@
string Username = 1;
string Secret = 2;
}
+
+message FetchTokenRequest {
+ string ClientID = 1;
+ string Host = 2;
+ string Realm = 3;
+ string Service = 4;
+ repeated string Scopes = 5;
+}
+
+message FetchTokenResponse {
+ string Token = 1;
+ int64 ExpiresIn = 2; // seconds
+ int64 IssuedAt = 3; // timestamp
+}
+
+message GetTokenAuthorityRequest {
+ string Host = 1;
+ bytes Salt = 2;
+}
+
+message GetTokenAuthorityResponse {
+ bytes PublicKey = 1;
+}
+
+message VerifyTokenAuthorityRequest {
+ string Host = 1;
+ bytes Payload = 2;
+ bytes Salt = 3;
+}
+
+message VerifyTokenAuthorityResponse {
+ bytes Signed = 1;
+}
diff --git a/vendor/github.com/moby/buildkit/session/filesync/diffcopy.go b/vendor/github.com/moby/buildkit/session/filesync/diffcopy.go
index ac255e4..c3104db 100644
--- a/vendor/github.com/moby/buildkit/session/filesync/diffcopy.go
+++ b/vendor/github.com/moby/buildkit/session/filesync/diffcopy.go
@@ -2,6 +2,7 @@
import (
"bufio"
+ "context"
io "io"
"os"
"time"
@@ -13,7 +14,13 @@
"google.golang.org/grpc"
)
-func sendDiffCopy(stream grpc.Stream, fs fsutil.FS, progress progressCb) error {
+type Stream interface {
+ Context() context.Context
+ SendMsg(m interface{}) error
+ RecvMsg(m interface{}) error
+}
+
+func sendDiffCopy(stream Stream, fs fsutil.FS, progress progressCb) error {
return errors.WithStack(fsutil.Send(stream.Context(), stream, fs, progress))
}
@@ -63,7 +70,7 @@
return nil
}
-func recvDiffCopy(ds grpc.Stream, dest string, cu CacheUpdater, progress progressCb, filter func(string, *fstypes.Stat) bool) error {
+func recvDiffCopy(ds grpc.ClientStream, dest string, cu CacheUpdater, progress progressCb, filter func(string, *fstypes.Stat) bool) error {
st := time.Now()
defer func() {
logrus.Debugf("diffcopy took: %v", time.Since(st))
@@ -83,7 +90,7 @@
}))
}
-func syncTargetDiffCopy(ds grpc.Stream, dest string) error {
+func syncTargetDiffCopy(ds grpc.ServerStream, dest string) error {
if err := os.MkdirAll(dest, 0700); err != nil {
return errors.Wrapf(err, "failed to create synctarget dest dir %s", dest)
}
@@ -101,7 +108,7 @@
}))
}
-func writeTargetFile(ds grpc.Stream, wc io.WriteCloser) error {
+func writeTargetFile(ds grpc.ServerStream, wc io.WriteCloser) error {
for {
bm := BytesMessage{}
if err := ds.RecvMsg(&bm); err != nil {
diff --git a/vendor/github.com/moby/buildkit/session/filesync/filesync.go b/vendor/github.com/moby/buildkit/session/filesync/filesync.go
index 51dd3c5..af62d1c 100644
--- a/vendor/github.com/moby/buildkit/session/filesync/filesync.go
+++ b/vendor/github.com/moby/buildkit/session/filesync/filesync.go
@@ -129,8 +129,8 @@
type protocol struct {
name string
- sendFn func(stream grpc.Stream, fs fsutil.FS, progress progressCb) error
- recvFn func(stream grpc.Stream, destDir string, cu CacheUpdater, progress progressCb, mapFunc func(string, *fstypes.Stat) bool) error
+ sendFn func(stream Stream, fs fsutil.FS, progress progressCb) error
+ recvFn func(stream grpc.ClientStream, destDir string, cu CacheUpdater, progress progressCb, mapFunc func(string, *fstypes.Stat) bool) error
}
func isProtoSupported(p string) bool {
diff --git a/vendor/github.com/moby/buildkit/session/group.go b/vendor/github.com/moby/buildkit/session/group.go
index 88409bf..4b9ba22 100644
--- a/vendor/github.com/moby/buildkit/session/group.go
+++ b/vendor/github.com/moby/buildkit/session/group.go
@@ -74,7 +74,7 @@
timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
- c, err := sm.Get(timeoutCtx, id)
+ c, err := sm.Get(timeoutCtx, id, false)
if err != nil {
lastErr = err
continue
diff --git a/vendor/github.com/moby/buildkit/session/grpc.go b/vendor/github.com/moby/buildkit/session/grpc.go
index 02870ca..728ea2e 100644
--- a/vendor/github.com/moby/buildkit/session/grpc.go
+++ b/vendor/github.com/moby/buildkit/session/grpc.go
@@ -31,7 +31,7 @@
var stream []grpc.StreamClientInterceptor
var dialCount int64
- dialer := grpc.WithDialer(func(addr string, d time.Duration) (net.Conn, error) {
+ dialer := grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
if c := atomic.AddInt64(&dialCount, 1); c > 1 {
return nil, errors.Errorf("only one connection allowed")
}
@@ -64,7 +64,7 @@
dialOpts = append(dialOpts, grpc.WithStreamInterceptor(grpc_middleware.ChainStreamClient(stream...)))
}
- cc, err := grpc.DialContext(ctx, "", dialOpts...)
+ cc, err := grpc.DialContext(ctx, "localhost", dialOpts...)
if err != nil {
return nil, nil, errors.Wrap(err, "failed to create grpc client")
}
diff --git a/vendor/github.com/moby/buildkit/session/grpchijack/dial.go b/vendor/github.com/moby/buildkit/session/grpchijack/dial.go
index 2486563..5f0cf3d 100644
--- a/vendor/github.com/moby/buildkit/session/grpchijack/dial.go
+++ b/vendor/github.com/moby/buildkit/session/grpchijack/dial.go
@@ -33,21 +33,26 @@
}
}
-func streamToConn(stream grpc.Stream) (net.Conn, <-chan struct{}) {
+type stream interface {
+ Context() context.Context
+ SendMsg(m interface{}) error
+ RecvMsg(m interface{}) error
+}
+
+func streamToConn(stream stream) (net.Conn, <-chan struct{}) {
closeCh := make(chan struct{})
c := &conn{stream: stream, buf: make([]byte, 32*1<<10), closeCh: closeCh}
return c, closeCh
}
type conn struct {
- stream grpc.Stream
+ stream stream
buf []byte
lastBuf []byte
closedOnce sync.Once
readMu sync.Mutex
writeMu sync.Mutex
- err error
closeCh chan struct{}
}
diff --git a/vendor/github.com/moby/buildkit/session/manager.go b/vendor/github.com/moby/buildkit/session/manager.go
index e01b047..edac930 100644
--- a/vendor/github.com/moby/buildkit/session/manager.go
+++ b/vendor/github.com/moby/buildkit/session/manager.go
@@ -149,7 +149,7 @@
}
// Get returns a session by ID
-func (sm *Manager) Get(ctx context.Context, id string) (Caller, error) {
+func (sm *Manager) Get(ctx context.Context, id string, noWait bool) (Caller, error) {
// session prefix is used to identify vertexes with different contexts so
// they would not collide, but for lookup we don't need the prefix
if p := strings.SplitN(id, ":", 2); len(p) == 2 && len(p[1]) > 0 {
@@ -180,7 +180,7 @@
}
var ok bool
c, ok = sm.sessions[id]
- if !ok || c.closed() {
+ if (!ok || c.closed()) && !noWait {
sm.updateCondition.Wait()
continue
}
@@ -188,6 +188,10 @@
break
}
+ if c == nil {
+ return nil, nil
+ }
+
return c, nil
}
diff --git a/vendor/github.com/moby/buildkit/session/sshforward/copy.go b/vendor/github.com/moby/buildkit/session/sshforward/copy.go
index 85366f1..6db4148 100644
--- a/vendor/github.com/moby/buildkit/session/sshforward/copy.go
+++ b/vendor/github.com/moby/buildkit/session/sshforward/copy.go
@@ -6,10 +6,14 @@
"github.com/pkg/errors"
context "golang.org/x/net/context"
"golang.org/x/sync/errgroup"
- "google.golang.org/grpc"
)
-func Copy(ctx context.Context, conn io.ReadWriteCloser, stream grpc.Stream, closeStream func() error) error {
+type Stream interface {
+ SendMsg(m interface{}) error
+ RecvMsg(m interface{}) error
+}
+
+func Copy(ctx context.Context, conn io.ReadWriteCloser, stream Stream, closeStream func() error) error {
g, ctx := errgroup.WithContext(ctx)
g.Go(func() (retErr error) {
diff --git a/vendor/github.com/moby/buildkit/snapshot/localmounter_windows.go b/vendor/github.com/moby/buildkit/snapshot/localmounter_windows.go
index a5cd1a2..df2e99b 100644
--- a/vendor/github.com/moby/buildkit/snapshot/localmounter_windows.go
+++ b/vendor/github.com/moby/buildkit/snapshot/localmounter_windows.go
@@ -25,12 +25,27 @@
return "", errors.Wrapf(errdefs.ErrNotImplemented, "request to mount %d layers, only 1 is supported", len(lm.mounts))
}
+ m := lm.mounts[0]
+
+ if m.Type == "bind" || m.Type == "rbind" {
+ ro := false
+ for _, opt := range m.Options {
+ if opt == "ro" {
+ ro = true
+ break
+ }
+ }
+ if !ro {
+ return m.Source, nil
+ }
+ }
+
// Windows mounts always activate in-place, so the target of the mount must be the source directory.
// See https://github.com/containerd/containerd/pull/2366
- dir := lm.mounts[0].Source
+ dir := m.Source
- if err := lm.mounts[0].Mount(dir); err != nil {
- return "", errors.Wrapf(err, "failed to mount in-place: %v", lm.mounts[0])
+ if err := m.Mount(dir); err != nil {
+ return "", errors.Wrapf(err, "failed to mount in-place: %v", m)
}
lm.target = dir
return lm.target, nil
diff --git a/vendor/github.com/moby/buildkit/solver/bboltcachestorage/storage.go b/vendor/github.com/moby/buildkit/solver/bboltcachestorage/storage.go
index 1975581..515feff 100644
--- a/vendor/github.com/moby/buildkit/solver/bboltcachestorage/storage.go
+++ b/vendor/github.com/moby/buildkit/solver/bboltcachestorage/storage.go
@@ -233,12 +233,6 @@
}
}
- links := tx.Bucket([]byte(resultBucket))
- if results == nil {
- return nil
- }
- links = links.Bucket([]byte(id))
-
return s.emptyBranchWithParents(tx, []byte(id))
}
diff --git a/vendor/github.com/moby/buildkit/solver/cacheopts.go b/vendor/github.com/moby/buildkit/solver/cacheopts.go
new file mode 100644
index 0000000..7c58d82
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/solver/cacheopts.go
@@ -0,0 +1,88 @@
+package solver
+
+import (
+ "context"
+
+ digest "github.com/opencontainers/go-digest"
+ "github.com/sirupsen/logrus"
+)
+
+type CacheOpts map[interface{}]interface{}
+
+type cacheOptGetterKey struct{}
+
+func CacheOptGetterOf(ctx context.Context) func(keys ...interface{}) map[interface{}]interface{} {
+ if v := ctx.Value(cacheOptGetterKey{}); v != nil {
+ if getter, ok := v.(func(keys ...interface{}) map[interface{}]interface{}); ok {
+ return getter
+ }
+ }
+ return nil
+}
+
+func withAncestorCacheOpts(ctx context.Context, start *state) context.Context {
+ return context.WithValue(ctx, cacheOptGetterKey{}, func(keys ...interface{}) map[interface{}]interface{} {
+ keySet := make(map[interface{}]struct{})
+ for _, k := range keys {
+ keySet[k] = struct{}{}
+ }
+ values := make(map[interface{}]interface{})
+ walkAncestors(start, func(st *state) bool {
+ if st.clientVertex.Error != "" {
+ // don't use values from cancelled or otherwise error'd vertexes
+ return false
+ }
+ for _, res := range st.op.cacheRes {
+ if res.Opts == nil {
+ continue
+ }
+ for k := range keySet {
+ if v, ok := res.Opts[k]; ok {
+ values[k] = v
+ delete(keySet, k)
+ if len(keySet) == 0 {
+ return true
+ }
+ }
+ }
+ }
+ return false
+ })
+ return values
+ })
+}
+
+func walkAncestors(start *state, f func(*state) bool) {
+ stack := [][]*state{{start}}
+ cache := make(map[digest.Digest]struct{})
+ for len(stack) > 0 {
+ sts := stack[len(stack)-1]
+ if len(sts) == 0 {
+ stack = stack[:len(stack)-1]
+ continue
+ }
+ st := sts[len(sts)-1]
+ stack[len(stack)-1] = sts[:len(sts)-1]
+ if st == nil {
+ continue
+ }
+ if _, ok := cache[st.origDigest]; ok {
+ continue
+ }
+ cache[st.origDigest] = struct{}{}
+ if shouldStop := f(st); shouldStop {
+ return
+ }
+ stack = append(stack, []*state{})
+ for _, parentDgst := range st.clientVertex.Inputs {
+ st.solver.mu.RLock()
+ parent := st.solver.actives[parentDgst]
+ st.solver.mu.RUnlock()
+ if parent == nil {
+ logrus.Warnf("parent %q not found in active job list during cache opt search", parentDgst)
+ continue
+ }
+ stack[len(stack)-1] = append(stack[len(stack)-1], parent)
+ }
+ }
+}
diff --git a/vendor/github.com/moby/buildkit/solver/cachestorage.go b/vendor/github.com/moby/buildkit/solver/cachestorage.go
index cc1e211..1279722 100644
--- a/vendor/github.com/moby/buildkit/solver/cachestorage.go
+++ b/vendor/github.com/moby/buildkit/solver/cachestorage.go
@@ -4,6 +4,7 @@
"context"
"time"
+ "github.com/moby/buildkit/session"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)
@@ -46,6 +47,6 @@
type CacheResultStorage interface {
Save(Result, time.Time) (CacheResult, error)
Load(ctx context.Context, res CacheResult) (Result, error)
- LoadRemote(ctx context.Context, res CacheResult) (*Remote, error)
+ LoadRemote(ctx context.Context, res CacheResult, s session.Group) (*Remote, error)
Exists(id string) bool
}
diff --git a/vendor/github.com/moby/buildkit/solver/edge.go b/vendor/github.com/moby/buildkit/solver/edge.go
index 52613ad..6ebf3a7 100644
--- a/vendor/github.com/moby/buildkit/solver/edge.go
+++ b/vendor/github.com/moby/buildkit/solver/edge.go
@@ -76,8 +76,6 @@
edgeState
index Index
keyMap map[string]*CacheKey
- desiredState edgeStatusType
- e *edge
slowCacheReq pipe.Receiver
slowCacheComplete bool
slowCacheFoundKey bool
@@ -119,7 +117,7 @@
// incrementReferenceCount increases the number of times release needs to be
// called to release the edge. Called on merging edges.
func (e *edge) incrementReferenceCount() {
- e.releaserCount += 1
+ e.releaserCount++
}
// release releases the edge resources
@@ -225,6 +223,14 @@
return e.cacheMap.Deps[int(dep.index)].ComputeDigestFunc
}
+// preprocessFunc returns result based cache func
+func (e *edge) preprocessFunc(dep *dep) PreprocessFunc {
+ if e.cacheMap == nil {
+ return nil
+ }
+ return e.cacheMap.Deps[int(dep.index)].PreprocessFunc
+}
+
// allDepsHaveKeys checks if all dependencies have at least one key. used for
// determining if there is enough data for combining cache key for edge
func (e *edge) allDepsHaveKeys(matching bool) bool {
@@ -489,17 +495,20 @@
e.err = upt.Status().Err
}
} else if !dep.slowCacheComplete {
- k := NewCacheKey(upt.Status().Value.(digest.Digest), -1)
- dep.slowCacheKey = &ExportableCacheKey{CacheKey: k, Exporter: &exporter{k: k}}
- slowKeyExp := CacheKeyWithSelector{CacheKey: *dep.slowCacheKey}
- defKeys := make([]CacheKeyWithSelector, 0, len(dep.result.CacheKeys()))
- for _, dk := range dep.result.CacheKeys() {
- defKeys = append(defKeys, CacheKeyWithSelector{CacheKey: dk, Selector: e.cacheMap.Deps[i].Selector})
- }
- dep.slowCacheFoundKey = e.probeCache(dep, []CacheKeyWithSelector{slowKeyExp})
+ dgst := upt.Status().Value.(digest.Digest)
+ if e.cacheMap.Deps[int(dep.index)].ComputeDigestFunc != nil && dgst != "" {
+ k := NewCacheKey(dgst, -1)
+ dep.slowCacheKey = &ExportableCacheKey{CacheKey: k, Exporter: &exporter{k: k}}
+ slowKeyExp := CacheKeyWithSelector{CacheKey: *dep.slowCacheKey}
+ defKeys := make([]CacheKeyWithSelector, 0, len(dep.result.CacheKeys()))
+ for _, dk := range dep.result.CacheKeys() {
+ defKeys = append(defKeys, CacheKeyWithSelector{CacheKey: dk, Selector: e.cacheMap.Deps[i].Selector})
+ }
+ dep.slowCacheFoundKey = e.probeCache(dep, []CacheKeyWithSelector{slowKeyExp})
- // connect def key to slow key
- e.op.Cache().Query(append(defKeys, slowKeyExp), dep.index, e.cacheMap.Digest, e.edge.Index)
+ // connect def key to slow key
+ e.op.Cache().Query(append(defKeys, slowKeyExp), dep.index, e.cacheMap.Digest, e.edge.Index)
+ }
dep.slowCacheComplete = true
e.keysDidChange = true
@@ -585,7 +594,7 @@
stHigh := edgeStatusCacheSlow // maximum possible state
if e.cacheMap != nil {
for _, dep := range e.deps {
- isSlowIncomplete := e.slowCacheFunc(dep) != nil && (dep.state == edgeStatusCacheSlow || (dep.state == edgeStatusComplete && !dep.slowCacheComplete))
+ isSlowIncomplete := (e.slowCacheFunc(dep) != nil || e.preprocessFunc(dep) != nil) && (dep.state == edgeStatusCacheSlow || (dep.state == edgeStatusComplete && !dep.slowCacheComplete))
if dep.state > stLow && len(dep.keyMap) == 0 && !isSlowIncomplete {
stLow = dep.state
@@ -806,15 +815,16 @@
}
}
// initialize function to compute cache key based on dependency result
- if dep.state == edgeStatusComplete && dep.slowCacheReq == nil && e.slowCacheFunc(dep) != nil && e.cacheMap != nil {
+ if dep.state == edgeStatusComplete && dep.slowCacheReq == nil && (e.slowCacheFunc(dep) != nil || e.preprocessFunc(dep) != nil) && e.cacheMap != nil {
+ pfn := e.preprocessFunc(dep)
fn := e.slowCacheFunc(dep)
res := dep.result
- func(fn ResultBasedCacheFunc, res Result, index Index) {
+ func(pfn PreprocessFunc, fn ResultBasedCacheFunc, res Result, index Index) {
dep.slowCacheReq = f.NewFuncRequest(func(ctx context.Context) (interface{}, error) {
- v, err := e.op.CalcSlowCache(ctx, index, fn, res)
+ v, err := e.op.CalcSlowCache(ctx, index, pfn, fn, res)
return v, errors.Wrap(err, "failed to compute cache key")
})
- }(fn, res, dep.index)
+ }(pfn, fn, res, dep.index)
addedNew = true
}
}
@@ -867,6 +877,7 @@
logrus.Debugf("load cache for %s with %s", e.edge.Vertex.Name(), rec.ID)
res, err := e.op.LoadCache(ctx, rec)
if err != nil {
+ logrus.Debugf("load cache for %s err: %v", e.edge.Vertex.Name(), err)
return nil, errors.Wrap(err, "failed to load cache")
}
diff --git a/vendor/github.com/moby/buildkit/solver/errdefs/errdefs.pb.go b/vendor/github.com/moby/buildkit/solver/errdefs/errdefs.pb.go
index f179e99..4375ebd 100644
--- a/vendor/github.com/moby/buildkit/solver/errdefs/errdefs.pb.go
+++ b/vendor/github.com/moby/buildkit/solver/errdefs/errdefs.pb.go
@@ -105,25 +105,105 @@
return nil
}
+type FrontendCap struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *FrontendCap) Reset() { *m = FrontendCap{} }
+func (m *FrontendCap) String() string { return proto.CompactTextString(m) }
+func (*FrontendCap) ProtoMessage() {}
+func (*FrontendCap) Descriptor() ([]byte, []int) {
+ return fileDescriptor_689dc58a5060aff5, []int{2}
+}
+func (m *FrontendCap) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_FrontendCap.Unmarshal(m, b)
+}
+func (m *FrontendCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_FrontendCap.Marshal(b, m, deterministic)
+}
+func (m *FrontendCap) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_FrontendCap.Merge(m, src)
+}
+func (m *FrontendCap) XXX_Size() int {
+ return xxx_messageInfo_FrontendCap.Size(m)
+}
+func (m *FrontendCap) XXX_DiscardUnknown() {
+ xxx_messageInfo_FrontendCap.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_FrontendCap proto.InternalMessageInfo
+
+func (m *FrontendCap) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+type Subrequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *Subrequest) Reset() { *m = Subrequest{} }
+func (m *Subrequest) String() string { return proto.CompactTextString(m) }
+func (*Subrequest) ProtoMessage() {}
+func (*Subrequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_689dc58a5060aff5, []int{3}
+}
+func (m *Subrequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_Subrequest.Unmarshal(m, b)
+}
+func (m *Subrequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_Subrequest.Marshal(b, m, deterministic)
+}
+func (m *Subrequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_Subrequest.Merge(m, src)
+}
+func (m *Subrequest) XXX_Size() int {
+ return xxx_messageInfo_Subrequest.Size(m)
+}
+func (m *Subrequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_Subrequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_Subrequest proto.InternalMessageInfo
+
+func (m *Subrequest) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
func init() {
proto.RegisterType((*Vertex)(nil), "errdefs.Vertex")
proto.RegisterType((*Source)(nil), "errdefs.Source")
+ proto.RegisterType((*FrontendCap)(nil), "errdefs.FrontendCap")
+ proto.RegisterType((*Subrequest)(nil), "errdefs.Subrequest")
}
func init() { proto.RegisterFile("errdefs.proto", fileDescriptor_689dc58a5060aff5) }
var fileDescriptor_689dc58a5060aff5 = []byte{
- // 177 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x2c, 0xcd, 0xc1, 0x8a, 0x83, 0x30,
- 0x10, 0x80, 0x61, 0xdc, 0x5d, 0xb2, 0x18, 0xd9, 0x3d, 0xe4, 0x50, 0xa4, 0x27, 0xeb, 0xc9, 0x43,
- 0x49, 0xc0, 0x3e, 0x45, 0x4f, 0x85, 0x14, 0x7a, 0x6f, 0x74, 0xb4, 0xa1, 0xea, 0x84, 0x49, 0x2c,
- 0xed, 0xdb, 0x17, 0x6d, 0x8e, 0xff, 0x7c, 0x33, 0x0c, 0xff, 0x03, 0xa2, 0x16, 0x3a, 0x2f, 0x1d,
- 0x61, 0x40, 0xf1, 0x1b, 0x73, 0xbb, 0xef, 0x6d, 0xb8, 0xcd, 0x46, 0x36, 0x38, 0xaa, 0x11, 0xcd,
- 0x4b, 0x99, 0xd9, 0x0e, 0xed, 0xdd, 0x06, 0xe5, 0x71, 0x78, 0x00, 0x29, 0x67, 0x14, 0xba, 0x78,
- 0x56, 0x16, 0x9c, 0x5d, 0x80, 0x02, 0x3c, 0xc5, 0x86, 0xb3, 0xd6, 0xf6, 0xe0, 0x43, 0x9e, 0x14,
- 0x49, 0x95, 0xea, 0x58, 0xe5, 0x89, 0xb3, 0x33, 0xce, 0xd4, 0x80, 0x28, 0xf9, 0x8f, 0x9d, 0x3a,
- 0x5c, 0x3d, 0xab, 0xff, 0xa5, 0x33, 0xf2, 0x23, 0xc7, 0xa9, 0x43, 0xbd, 0x9a, 0xd8, 0x71, 0x46,
- 0xd7, 0xa9, 0x07, 0x9f, 0x7f, 0x15, 0xdf, 0x55, 0x56, 0xa7, 0xcb, 0x96, 0x5e, 0x26, 0x3a, 0x82,
- 0x61, 0xeb, 0xe7, 0xc3, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x93, 0xb5, 0x8b, 0x2a, 0xc1, 0x00, 0x00,
- 0x00,
+ // 213 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x8e, 0xc1, 0x4a, 0x03, 0x31,
+ 0x10, 0x86, 0xa9, 0x96, 0x48, 0x67, 0xd1, 0x43, 0x0e, 0x52, 0x3c, 0x6d, 0x73, 0xea, 0x41, 0x36,
+ 0x50, 0x1f, 0x41, 0x10, 0x3c, 0x09, 0x5b, 0xf0, 0xbe, 0x69, 0x66, 0xd7, 0x60, 0x37, 0x13, 0x27,
+ 0x89, 0xe8, 0xdb, 0xcb, 0xc6, 0x1c, 0x7b, 0x9b, 0x7f, 0xbe, 0x6f, 0x98, 0x1f, 0x6e, 0x91, 0xd9,
+ 0xe2, 0x18, 0xbb, 0xc0, 0x94, 0x48, 0xde, 0xd4, 0xf8, 0xf0, 0x38, 0xb9, 0xf4, 0x91, 0x4d, 0x77,
+ 0xa2, 0x59, 0xcf, 0x64, 0x7e, 0xb5, 0xc9, 0xee, 0x6c, 0x3f, 0x5d, 0xd2, 0x91, 0xce, 0xdf, 0xc8,
+ 0x3a, 0x18, 0x4d, 0xa1, 0x9e, 0xa9, 0x16, 0xc4, 0x3b, 0x72, 0xc2, 0x1f, 0x79, 0x0f, 0xc2, 0xba,
+ 0x09, 0x63, 0xda, 0xae, 0xda, 0xd5, 0x7e, 0xd3, 0xd7, 0xa4, 0xde, 0x40, 0x1c, 0x29, 0xf3, 0x09,
+ 0xa5, 0x82, 0xb5, 0xf3, 0x23, 0x15, 0xde, 0x1c, 0xee, 0xba, 0x60, 0xba, 0x7f, 0xf2, 0xea, 0x47,
+ 0xea, 0x0b, 0x93, 0x3b, 0x10, 0x3c, 0xf8, 0x09, 0xe3, 0xf6, 0xaa, 0xbd, 0xde, 0x37, 0x87, 0xcd,
+ 0x62, 0xf5, 0xcb, 0xa6, 0xaf, 0x40, 0xed, 0xa0, 0x79, 0x61, 0xf2, 0x09, 0xbd, 0x7d, 0x1e, 0x82,
+ 0x94, 0xb0, 0xf6, 0xc3, 0x8c, 0xf5, 0x6b, 0x99, 0x55, 0x0b, 0x70, 0xcc, 0x86, 0xf1, 0x2b, 0x63,
+ 0x4c, 0x97, 0x0c, 0x23, 0x4a, 0xfd, 0xa7, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x75, 0x4b, 0xfe,
+ 0xad, 0x06, 0x01, 0x00, 0x00,
}
diff --git a/vendor/github.com/moby/buildkit/solver/errdefs/errdefs.proto b/vendor/github.com/moby/buildkit/solver/errdefs/errdefs.proto
index 7e808cb..f41ed14b 100644
--- a/vendor/github.com/moby/buildkit/solver/errdefs/errdefs.proto
+++ b/vendor/github.com/moby/buildkit/solver/errdefs/errdefs.proto
@@ -12,3 +12,11 @@
pb.SourceInfo info = 1;
repeated pb.Range ranges = 2;
}
+
+message FrontendCap {
+ string name = 1;
+}
+
+message Subrequest {
+ string name = 1;
+}
diff --git a/vendor/github.com/moby/buildkit/solver/errdefs/exec.go b/vendor/github.com/moby/buildkit/solver/errdefs/exec.go
new file mode 100644
index 0000000..2c6bbf6
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/solver/errdefs/exec.go
@@ -0,0 +1,24 @@
+package errdefs
+
+import fmt "fmt"
+
+// ExitError will be returned when the container process exits with a non-zero
+// exit code.
+type ExitError struct {
+ ExitCode uint32
+ Err error
+}
+
+func (err *ExitError) Error() string {
+ if err.Err != nil {
+ return err.Err.Error()
+ }
+ return fmt.Sprintf("exit code: %d", err.ExitCode)
+}
+
+func (err *ExitError) Unwrap() error {
+ if err.Err == nil {
+ return fmt.Errorf("exit code: %d", err.ExitCode)
+ }
+ return err.Err
+}
diff --git a/vendor/github.com/moby/buildkit/solver/errdefs/fronetendcap.go b/vendor/github.com/moby/buildkit/solver/errdefs/fronetendcap.go
new file mode 100644
index 0000000..e8af9ff
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/solver/errdefs/fronetendcap.go
@@ -0,0 +1,41 @@
+package errdefs
+
+import (
+ fmt "fmt"
+
+ "github.com/containerd/typeurl"
+ "github.com/moby/buildkit/util/grpcerrors"
+)
+
+func init() {
+ typeurl.Register((*FrontendCap)(nil), "github.com/moby/buildkit", "errdefs.FrontendCap+json")
+}
+
+type UnsupportedFrontendCapError struct {
+ FrontendCap
+ error
+}
+
+func (e *UnsupportedFrontendCapError) Error() string {
+ msg := fmt.Sprintf("unsupported frontend capability %s", e.FrontendCap.Name)
+ if e.error != nil {
+ msg += ": " + e.error.Error()
+ }
+ return msg
+}
+
+func (e *UnsupportedFrontendCapError) Unwrap() error {
+ return e.error
+}
+
+func (e *UnsupportedFrontendCapError) ToProto() grpcerrors.TypedErrorProto {
+ return &e.FrontendCap
+}
+
+func NewUnsupportedFrontendCapError(name string) error {
+ return &UnsupportedFrontendCapError{FrontendCap: FrontendCap{Name: name}}
+}
+
+func (v *FrontendCap) WrapError(err error) error {
+ return &UnsupportedFrontendCapError{error: err, FrontendCap: *v}
+}
diff --git a/vendor/github.com/moby/buildkit/solver/errdefs/subrequest.go b/vendor/github.com/moby/buildkit/solver/errdefs/subrequest.go
new file mode 100644
index 0000000..b30eab3
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/solver/errdefs/subrequest.go
@@ -0,0 +1,41 @@
+package errdefs
+
+import (
+ fmt "fmt"
+
+ "github.com/containerd/typeurl"
+ "github.com/moby/buildkit/util/grpcerrors"
+)
+
+func init() {
+ typeurl.Register((*Subrequest)(nil), "github.com/moby/buildkit", "errdefs.Subrequest+json")
+}
+
+type UnsupportedSubrequestError struct {
+ Subrequest
+ error
+}
+
+func (e *UnsupportedSubrequestError) Error() string {
+ msg := fmt.Sprintf("unsupported request %s", e.Subrequest.Name)
+ if e.error != nil {
+ msg += ": " + e.error.Error()
+ }
+ return msg
+}
+
+func (e *UnsupportedSubrequestError) Unwrap() error {
+ return e.error
+}
+
+func (e *UnsupportedSubrequestError) ToProto() grpcerrors.TypedErrorProto {
+ return &e.Subrequest
+}
+
+func NewUnsupportedSubrequestError(name string) error {
+ return &UnsupportedSubrequestError{Subrequest: Subrequest{Name: name}}
+}
+
+func (v *Subrequest) WrapError(err error) error {
+ return &UnsupportedSubrequestError{error: err, Subrequest: *v}
+}
diff --git a/vendor/github.com/moby/buildkit/solver/errdefs/vertex.go b/vendor/github.com/moby/buildkit/solver/errdefs/vertex.go
index 71fdb6c..4ec3751 100644
--- a/vendor/github.com/moby/buildkit/solver/errdefs/vertex.go
+++ b/vendor/github.com/moby/buildkit/solver/errdefs/vertex.go
@@ -1,14 +1,14 @@
package errdefs
import (
- proto "github.com/golang/protobuf/proto"
+ "github.com/containerd/typeurl"
"github.com/moby/buildkit/util/grpcerrors"
digest "github.com/opencontainers/go-digest"
)
func init() {
- proto.RegisterType((*Vertex)(nil), "errdefs.Vertex")
- proto.RegisterType((*Source)(nil), "errdefs.Source")
+ typeurl.Register((*Vertex)(nil), "github.com/moby/buildkit", "errdefs.Vertex+json")
+ typeurl.Register((*Source)(nil), "github.com/moby/buildkit", "errdefs.Source+json")
}
type VertexError struct {
diff --git a/vendor/github.com/moby/buildkit/solver/exporter.go b/vendor/github.com/moby/buildkit/solver/exporter.go
index 6a07396..26ca2fb 100644
--- a/vendor/github.com/moby/buildkit/solver/exporter.go
+++ b/vendor/github.com/moby/buildkit/solver/exporter.go
@@ -100,7 +100,7 @@
return nil, err
}
- remote, err = cm.results.LoadRemote(ctx, res)
+ remote, err = cm.results.LoadRemote(ctx, res, opt.Session)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/solver/index.go b/vendor/github.com/moby/buildkit/solver/index.go
index 78a2cca..4a33066 100644
--- a/vendor/github.com/moby/buildkit/solver/index.go
+++ b/vendor/github.com/moby/buildkit/solver/index.go
@@ -121,14 +121,14 @@
}
// enforceLinked adds links from current ID to all dep keys
-func (er *edgeIndex) enforceLinked(id string, k *CacheKey) {
- main, ok := er.items[id]
+func (ei *edgeIndex) enforceLinked(id string, k *CacheKey) {
+ main, ok := ei.items[id]
if !ok {
main = &indexItem{
links: map[CacheInfoLink]map[string]struct{}{},
deps: map[string]struct{}{},
}
- er.items[id] = main
+ ei.items[id] = main
}
deps := k.Deps()
@@ -136,10 +136,10 @@
for i, dd := range deps {
for _, d := range dd {
ck := d.CacheKey.CacheKey
- er.enforceIndexID(ck)
+ ei.enforceIndexID(ck)
ll := CacheInfoLink{Input: Index(i), Digest: k.Digest(), Output: k.Output(), Selector: d.Selector}
for _, ckID := range ck.indexIDs {
- if item, ok := er.items[ckID]; ok {
+ if item, ok := ei.items[ckID]; ok {
links, ok := item.links[ll]
if !ok {
links = map[string]struct{}{}
diff --git a/vendor/github.com/moby/buildkit/solver/jobs.go b/vendor/github.com/moby/buildkit/solver/jobs.go
index 182a6d0..d34db5e 100644
--- a/vendor/github.com/moby/buildkit/solver/jobs.go
+++ b/vendor/github.com/moby/buildkit/solver/jobs.go
@@ -230,6 +230,7 @@
pw progress.Writer
span opentracing.Span
values sync.Map
+ id string
progressCloser func()
SessionID string
@@ -267,6 +268,17 @@
st.setEdge(e.Index, newEdge)
}
+func (jl *Solver) getState(e Edge) *state {
+ jl.mu.RLock()
+ defer jl.mu.RUnlock()
+
+ st, ok := jl.actives[e.Vertex.Digest()]
+ if !ok {
+ return nil
+ }
+ return st
+}
+
func (jl *Solver) getEdge(e Edge) *edge {
jl.mu.RLock()
defer jl.mu.RUnlock()
@@ -429,6 +441,7 @@
pw: pw,
progressCloser: progressCloser,
span: (&opentracing.NoopTracer{}).StartSpan(""),
+ id: id,
}
jl.jobs[id] = j
@@ -513,6 +526,8 @@
}
st.mu.Unlock()
}
+
+ delete(j.list.jobs, j.id)
return nil
}
@@ -543,7 +558,7 @@
Exec(ctx context.Context, inputs []Result) (outputs []Result, exporters []ExportableCacheKey, err error)
IgnoreCache() bool
Cache() CacheManager
- CalcSlowCache(context.Context, Index, ResultBasedCacheFunc, Result) (digest.Digest, error)
+ CalcSlowCache(context.Context, Index, PreprocessFunc, ResultBasedCacheFunc, Result) (digest.Digest, error)
}
func newSharedOp(resolver ResolveOpFunc, cacheManager CacheManager, st *state) *sharedOp {
@@ -596,20 +611,20 @@
// no cache hit. start evaluating the node
span, ctx := tracing.StartSpan(ctx, "load cache: "+s.st.vtx.Name())
notifyStarted(ctx, &s.st.clientVertex, true)
- res, err := s.Cache().Load(ctx, rec)
+ res, err := s.Cache().Load(withAncestorCacheOpts(ctx, s.st), rec)
tracing.FinishWithError(span, err)
notifyCompleted(ctx, &s.st.clientVertex, err, true)
return res, err
}
-func (s *sharedOp) CalcSlowCache(ctx context.Context, index Index, f ResultBasedCacheFunc, res Result) (dgst digest.Digest, err error) {
+func (s *sharedOp) CalcSlowCache(ctx context.Context, index Index, p PreprocessFunc, f ResultBasedCacheFunc, res Result) (dgst digest.Digest, err error) {
defer func() {
err = errdefs.WrapVertex(err, s.st.origDigest)
}()
key, err := s.g.Do(ctx, fmt.Sprintf("slow-compute-%d", index), func(ctx context.Context) (interface{}, error) {
s.slowMu.Lock()
// TODO: add helpers for these stored values
- if res := s.slowCacheRes[index]; res != "" {
+ if res, ok := s.slowCacheRes[index]; ok {
s.slowMu.Unlock()
return res, nil
}
@@ -618,9 +633,23 @@
return err, nil
}
s.slowMu.Unlock()
- ctx = opentracing.ContextWithSpan(progress.WithProgress(ctx, s.st.mpw), s.st.mspan)
- key, err := f(ctx, res)
+
complete := true
+ if p != nil {
+ st := s.st.solver.getState(s.st.vtx.Inputs()[index])
+ ctx2 := opentracing.ContextWithSpan(progress.WithProgress(ctx, st.mpw), st.mspan)
+ err = p(ctx2, res, st)
+ if err != nil {
+ f = nil
+ ctx = ctx2
+ }
+ }
+
+ var key digest.Digest
+ if f != nil {
+ ctx = opentracing.ContextWithSpan(progress.WithProgress(ctx, s.st.mpw), s.st.mspan)
+ key, err = f(withAncestorCacheOpts(ctx, s.st), res, s.st)
+ }
if err != nil {
select {
case <-ctx.Done():
@@ -666,6 +695,7 @@
return nil, s.cacheErr
}
ctx = opentracing.ContextWithSpan(progress.WithProgress(ctx, s.st.mpw), s.st.mspan)
+ ctx = withAncestorCacheOpts(ctx, s.st)
if len(s.st.vtx.Inputs()) == 0 {
// no cache hit. start evaluating the node
span, ctx := tracing.StartSpan(ctx, "cache request: "+s.st.vtx.Name())
@@ -721,6 +751,7 @@
}
ctx = opentracing.ContextWithSpan(progress.WithProgress(ctx, s.st.mpw), s.st.mspan)
+ ctx = withAncestorCacheOpts(ctx, s.st)
// no cache hit. start evaluating the node
span, ctx := tracing.StartSpan(ctx, s.st.vtx.Name())
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/bridge.go b/vendor/github.com/moby/buildkit/solver/llbsolver/bridge.go
index d08d061..df3e4b7 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/bridge.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/bridge.go
@@ -9,7 +9,6 @@
"github.com/containerd/containerd/platforms"
"github.com/mitchellh/hashstructure"
- "github.com/moby/buildkit/cache"
"github.com/moby/buildkit/cache/remotecache"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/executor"
@@ -131,7 +130,7 @@
if !ok {
return nil, errors.Errorf("invalid frontend: %s", req.Frontend)
}
- res, err = f.Solve(ctx, b, req.FrontendOpt, req.FrontendInputs, sid)
+ res, err = f.Solve(ctx, b, req.FrontendOpt, req.FrontendInputs, sid, b.sm)
if err != nil {
return nil, errors.Wrapf(err, "failed to solve with frontend %s", req.Frontend)
}
@@ -245,8 +244,8 @@
return nil, err
}
-func (s *llbBridge) Run(ctx context.Context, id string, root cache.Mountable, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
- w, err := s.resolveWorker()
+func (b *llbBridge) Run(ctx context.Context, id string, root executor.Mount, mounts []executor.Mount, process executor.ProcessInfo, started chan<- struct{}) (err error) {
+ w, err := b.resolveWorker()
if err != nil {
return err
}
@@ -256,8 +255,8 @@
return err
}
-func (s *llbBridge) Exec(ctx context.Context, id string, process executor.ProcessInfo) (err error) {
- w, err := s.resolveWorker()
+func (b *llbBridge) Exec(ctx context.Context, id string, process executor.ProcessInfo) (err error) {
+ w, err := b.resolveWorker()
if err != nil {
return err
}
@@ -267,8 +266,8 @@
return err
}
-func (s *llbBridge) ResolveImageConfig(ctx context.Context, ref string, opt llb.ResolveImageConfigOpt) (dgst digest.Digest, config []byte, err error) {
- w, err := s.resolveWorker()
+func (b *llbBridge) ResolveImageConfig(ctx context.Context, ref string, opt llb.ResolveImageConfigOpt) (dgst digest.Digest, config []byte, err error) {
+ w, err := b.resolveWorker()
if err != nil {
return "", nil, err
}
@@ -281,8 +280,8 @@
} else {
id += platforms.Format(*platform)
}
- err = inBuilderContext(ctx, s.builder, opt.LogName, id, func(ctx context.Context, g session.Group) error {
- dgst, config, err = w.ResolveImageConfig(ctx, ref, opt, s.sm, g)
+ err = inBuilderContext(ctx, b.builder, opt.LogName, id, func(ctx context.Context, g session.Group) error {
+ dgst, config, err = w.ResolveImageConfig(ctx, ref, opt, b.sm, g)
return err
})
return dgst, config, err
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/file/backend.go b/vendor/github.com/moby/buildkit/solver/llbsolver/file/backend.go
index a690012..8ecf648 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/file/backend.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/file/backend.go
@@ -37,13 +37,13 @@
// non-nil old is already mapped
if idmap != nil {
identity, err := idmap.ToHost(idtools.Identity{
- UID: old.Uid,
- GID: old.Gid,
+ UID: old.UID,
+ GID: old.GID,
})
if err != nil {
return nil, err
}
- return ©.User{Uid: identity.UID, Gid: identity.GID}, nil
+ return ©.User{UID: identity.UID, GID: identity.GID}, nil
}
}
return old, nil
@@ -52,14 +52,14 @@
u := *user
if idmap != nil {
identity, err := idmap.ToHost(idtools.Identity{
- UID: user.Uid,
- GID: user.Gid,
+ UID: user.UID,
+ GID: user.GID,
})
if err != nil {
return nil, err
}
- u.Uid = identity.UID
- u.Gid = identity.GID
+ u.UID = identity.UID
+ u.GID = identity.GID
}
return func(*copy.User) (*copy.User, error) {
return &u, nil
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/file/refmanager.go b/vendor/github.com/moby/buildkit/solver/llbsolver/file/refmanager.go
index faa4cdb..a803d7f 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/file/refmanager.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/file/refmanager.go
@@ -4,6 +4,7 @@
"context"
"github.com/moby/buildkit/cache"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/solver/llbsolver/ops/fileoptypes"
"github.com/pkg/errors"
@@ -17,25 +18,25 @@
cm cache.Manager
}
-func (rm *RefManager) Prepare(ctx context.Context, ref fileoptypes.Ref, readonly bool) (fileoptypes.Mount, error) {
+func (rm *RefManager) Prepare(ctx context.Context, ref fileoptypes.Ref, readonly bool, g session.Group) (fileoptypes.Mount, error) {
ir, ok := ref.(cache.ImmutableRef)
if !ok && ref != nil {
return nil, errors.Errorf("invalid ref type: %T", ref)
}
if ir != nil && readonly {
- m, err := ir.Mount(ctx, readonly)
+ m, err := ir.Mount(ctx, readonly, g)
if err != nil {
return nil, err
}
return &Mount{m: m}, nil
}
- mr, err := rm.cm.New(ctx, ir, cache.WithDescription("fileop target"), cache.CachePolicyRetain)
+ mr, err := rm.cm.New(ctx, ir, g, cache.WithDescription("fileop target"), cache.CachePolicyRetain)
if err != nil {
return nil, err
}
- m, err := mr.Mount(ctx, readonly)
+ m, err := mr.Mount(ctx, readonly, g)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/file/user_linux.go b/vendor/github.com/moby/buildkit/solver/llbsolver/file/user_linux.go
index 93b3236..8e4848c 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/file/user_linux.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/file/user_linux.go
@@ -58,12 +58,12 @@
}
if len(users) > 0 {
- us.Uid = users[0].Uid
- us.Gid = users[0].Gid
+ us.UID = users[0].Uid
+ us.GID = users[0].Gid
}
case *pb.UserOpt_ByID:
- us.Uid = int(u.ByID)
- us.Gid = int(u.ByID)
+ us.UID = int(u.ByID)
+ us.GID = int(u.ByID)
}
}
@@ -108,10 +108,10 @@
}
if len(groups) > 0 {
- us.Gid = groups[0].Gid
+ us.GID = groups[0].Gid
}
case *pb.UserOpt_ByID:
- us.Gid = int(u.ByID)
+ us.GID = int(u.ByID)
}
}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/file/user_nolinux.go b/vendor/github.com/moby/buildkit/solver/llbsolver/file/user_nolinux.go
index 780b559..246f187 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/file/user_nolinux.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/file/user_nolinux.go
@@ -10,5 +10,8 @@
)
func readUser(chopt *pb.ChownOpt, mu, mg fileoptypes.Mount) (*copy.User, error) {
+ if chopt == nil {
+ return nil, nil
+ }
return nil, errors.New("only implemented in linux")
}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/mounts/mount.go b/vendor/github.com/moby/buildkit/solver/llbsolver/mounts/mount.go
new file mode 100644
index 0000000..f9e3db8
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/mounts/mount.go
@@ -0,0 +1,516 @@
+package mounts
+
+import (
+ "context"
+ "fmt"
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "sync"
+ "time"
+
+ "github.com/containerd/containerd/mount"
+ "github.com/containerd/containerd/sys"
+ "github.com/docker/docker/pkg/idtools"
+ "github.com/moby/buildkit/cache"
+ "github.com/moby/buildkit/cache/metadata"
+ "github.com/moby/buildkit/client"
+ "github.com/moby/buildkit/identity"
+ "github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/session/secrets"
+ "github.com/moby/buildkit/session/sshforward"
+ "github.com/moby/buildkit/snapshot"
+ "github.com/moby/buildkit/solver/pb"
+ "github.com/moby/buildkit/util/grpcerrors"
+ "github.com/moby/locker"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+ bolt "go.etcd.io/bbolt"
+ "google.golang.org/grpc/codes"
+)
+
+func NewMountManager(name string, cm cache.Manager, sm *session.Manager, md *metadata.Store) *MountManager {
+ return &MountManager{
+ cm: cm,
+ sm: sm,
+ cacheMounts: map[string]*cacheRefShare{},
+ md: md,
+ managerName: name,
+ }
+}
+
+type MountManager struct {
+ cm cache.Manager
+ sm *session.Manager
+ cacheMountsMu sync.Mutex
+ cacheMounts map[string]*cacheRefShare
+ md *metadata.Store
+ managerName string
+}
+
+func (mm *MountManager) getRefCacheDir(ctx context.Context, ref cache.ImmutableRef, id string, m *pb.Mount, sharing pb.CacheSharingOpt, s session.Group) (mref cache.MutableRef, err error) {
+ g := &cacheRefGetter{
+ locker: &mm.cacheMountsMu,
+ cacheMounts: mm.cacheMounts,
+ cm: mm.cm,
+ md: mm.md,
+ globalCacheRefs: sharedCacheRefs,
+ name: fmt.Sprintf("cached mount %s from %s", m.Dest, mm.managerName),
+ session: s,
+ }
+ return g.getRefCacheDir(ctx, ref, id, sharing)
+}
+
+type cacheRefGetter struct {
+ locker sync.Locker
+ cacheMounts map[string]*cacheRefShare
+ cm cache.Manager
+ md *metadata.Store
+ globalCacheRefs *cacheRefs
+ name string
+ session session.Group
+}
+
+func (g *cacheRefGetter) getRefCacheDir(ctx context.Context, ref cache.ImmutableRef, id string, sharing pb.CacheSharingOpt) (mref cache.MutableRef, err error) {
+ key := "cache-dir:" + id
+ if ref != nil {
+ key += ":" + ref.ID()
+ }
+ mu := g.locker
+ mu.Lock()
+ defer mu.Unlock()
+
+ if ref, ok := g.cacheMounts[key]; ok {
+ return ref.clone(), nil
+ }
+ defer func() {
+ if err == nil {
+ share := &cacheRefShare{MutableRef: mref, refs: map[*cacheRef]struct{}{}}
+ g.cacheMounts[key] = share
+ mref = share.clone()
+ }
+ }()
+
+ switch sharing {
+ case pb.CacheSharingOpt_SHARED:
+ return g.globalCacheRefs.get(key, func() (cache.MutableRef, error) {
+ return g.getRefCacheDirNoCache(ctx, key, ref, id, false)
+ })
+ case pb.CacheSharingOpt_PRIVATE:
+ return g.getRefCacheDirNoCache(ctx, key, ref, id, false)
+ case pb.CacheSharingOpt_LOCKED:
+ return g.getRefCacheDirNoCache(ctx, key, ref, id, true)
+ default:
+ return nil, errors.Errorf("invalid cache sharing option: %s", sharing.String())
+ }
+}
+
+func (g *cacheRefGetter) getRefCacheDirNoCache(ctx context.Context, key string, ref cache.ImmutableRef, id string, block bool) (cache.MutableRef, error) {
+ makeMutable := func(ref cache.ImmutableRef) (cache.MutableRef, error) {
+ return g.cm.New(ctx, ref, g.session, cache.WithRecordType(client.UsageRecordTypeCacheMount), cache.WithDescription(g.name), cache.CachePolicyRetain)
+ }
+
+ cacheRefsLocker.Lock(key)
+ defer cacheRefsLocker.Unlock(key)
+ for {
+ sis, err := g.md.Search(key)
+ if err != nil {
+ return nil, err
+ }
+ locked := false
+ for _, si := range sis {
+ if mRef, err := g.cm.GetMutable(ctx, si.ID()); err == nil {
+ logrus.Debugf("reusing ref for cache dir: %s", mRef.ID())
+ return mRef, nil
+ } else if errors.Is(err, cache.ErrLocked) {
+ locked = true
+ }
+ }
+ if block && locked {
+ cacheRefsLocker.Unlock(key)
+ select {
+ case <-ctx.Done():
+ cacheRefsLocker.Lock(key)
+ return nil, ctx.Err()
+ case <-time.After(100 * time.Millisecond):
+ cacheRefsLocker.Lock(key)
+ }
+ } else {
+ break
+ }
+ }
+ mRef, err := makeMutable(ref)
+ if err != nil {
+ return nil, err
+ }
+
+ si, _ := g.md.Get(mRef.ID())
+ v, err := metadata.NewValue(key)
+ if err != nil {
+ mRef.Release(context.TODO())
+ return nil, err
+ }
+ v.Index = key
+ if err := si.Update(func(b *bolt.Bucket) error {
+ return si.SetValue(b, key, v)
+ }); err != nil {
+ mRef.Release(context.TODO())
+ return nil, err
+ }
+ return mRef, nil
+}
+
+func (mm *MountManager) getSSHMountable(ctx context.Context, m *pb.Mount, g session.Group) (cache.Mountable, error) {
+ var caller session.Caller
+ err := mm.sm.Any(ctx, g, func(ctx context.Context, _ string, c session.Caller) error {
+ if err := sshforward.CheckSSHID(ctx, c, m.SSHOpt.ID); err != nil {
+ if m.SSHOpt.Optional {
+ return nil
+ }
+ if grpcerrors.Code(err) == codes.Unimplemented {
+ return errors.Errorf("no SSH key %q forwarded from the client", m.SSHOpt.ID)
+ }
+ return err
+ }
+ caller = c
+ return nil
+ })
+ if err != nil {
+ return nil, err
+ }
+ // because ssh socket remains active, to actually handle session disconnecting ssh error
+ // should restart the whole exec with new session
+ return &sshMount{mount: m, caller: caller, idmap: mm.cm.IdentityMapping()}, nil
+}
+
+type sshMount struct {
+ mount *pb.Mount
+ caller session.Caller
+ idmap *idtools.IdentityMapping
+}
+
+func (sm *sshMount) Mount(ctx context.Context, readonly bool, g session.Group) (snapshot.Mountable, error) {
+ return &sshMountInstance{sm: sm, idmap: sm.idmap}, nil
+}
+
+type sshMountInstance struct {
+ sm *sshMount
+ idmap *idtools.IdentityMapping
+}
+
+func (sm *sshMountInstance) Mount() ([]mount.Mount, func() error, error) {
+ ctx, cancel := context.WithCancel(context.TODO())
+
+ uid := int(sm.sm.mount.SSHOpt.Uid)
+ gid := int(sm.sm.mount.SSHOpt.Gid)
+
+ if sm.idmap != nil {
+ identity, err := sm.idmap.ToHost(idtools.Identity{
+ UID: uid,
+ GID: gid,
+ })
+ if err != nil {
+ cancel()
+ return nil, nil, err
+ }
+ uid = identity.UID
+ gid = identity.GID
+ }
+
+ sock, cleanup, err := sshforward.MountSSHSocket(ctx, sm.sm.caller, sshforward.SocketOpt{
+ ID: sm.sm.mount.SSHOpt.ID,
+ UID: uid,
+ GID: gid,
+ Mode: int(sm.sm.mount.SSHOpt.Mode & 0777),
+ })
+ if err != nil {
+ cancel()
+ return nil, nil, err
+ }
+ release := func() error {
+ var err error
+ if cleanup != nil {
+ err = cleanup()
+ }
+ cancel()
+ return err
+ }
+
+ return []mount.Mount{{
+ Type: "bind",
+ Source: sock,
+ Options: []string{"rbind"},
+ }}, release, nil
+}
+
+func (sm *sshMountInstance) IdentityMapping() *idtools.IdentityMapping {
+ return sm.idmap
+}
+
+func (mm *MountManager) getSecretMountable(ctx context.Context, m *pb.Mount, g session.Group) (cache.Mountable, error) {
+ if m.SecretOpt == nil {
+ return nil, errors.Errorf("invalid secret mount options")
+ }
+ sopt := *m.SecretOpt
+
+ id := sopt.ID
+ if id == "" {
+ return nil, errors.Errorf("secret ID missing from mount options")
+ }
+ var dt []byte
+ var err error
+ err = mm.sm.Any(ctx, g, func(ctx context.Context, _ string, caller session.Caller) error {
+ dt, err = secrets.GetSecret(ctx, caller, id)
+ if err != nil {
+ if errors.Is(err, secrets.ErrNotFound) && m.SecretOpt.Optional {
+ return nil
+ }
+ return err
+ }
+ return nil
+ })
+ if err != nil || dt == nil {
+ return nil, err
+ }
+ return &secretMount{mount: m, data: dt, idmap: mm.cm.IdentityMapping()}, nil
+}
+
+type secretMount struct {
+ mount *pb.Mount
+ data []byte
+ idmap *idtools.IdentityMapping
+}
+
+func (sm *secretMount) Mount(ctx context.Context, readonly bool, g session.Group) (snapshot.Mountable, error) {
+ return &secretMountInstance{sm: sm, idmap: sm.idmap}, nil
+}
+
+type secretMountInstance struct {
+ sm *secretMount
+ root string
+ idmap *idtools.IdentityMapping
+}
+
+func (sm *secretMountInstance) Mount() ([]mount.Mount, func() error, error) {
+ dir, err := ioutil.TempDir("", "buildkit-secrets")
+ if err != nil {
+ return nil, nil, errors.Wrap(err, "failed to create temp dir")
+ }
+ cleanupDir := func() error {
+ return os.RemoveAll(dir)
+ }
+
+ if err := os.Chmod(dir, 0711); err != nil {
+ cleanupDir()
+ return nil, nil, err
+ }
+
+ tmpMount := mount.Mount{
+ Type: "tmpfs",
+ Source: "tmpfs",
+ Options: []string{"nodev", "nosuid", "noexec", fmt.Sprintf("uid=%d,gid=%d", os.Geteuid(), os.Getegid())},
+ }
+
+ if sys.RunningInUserNS() {
+ tmpMount.Options = nil
+ }
+
+ if err := mount.All([]mount.Mount{tmpMount}, dir); err != nil {
+ cleanupDir()
+ return nil, nil, errors.Wrap(err, "unable to setup secret mount")
+ }
+ sm.root = dir
+
+ cleanup := func() error {
+ if err := mount.Unmount(dir, 0); err != nil {
+ return err
+ }
+ return cleanupDir()
+ }
+
+ randID := identity.NewID()
+ fp := filepath.Join(dir, randID)
+ if err := ioutil.WriteFile(fp, sm.sm.data, 0600); err != nil {
+ cleanup()
+ return nil, nil, err
+ }
+
+ uid := int(sm.sm.mount.SecretOpt.Uid)
+ gid := int(sm.sm.mount.SecretOpt.Gid)
+
+ if sm.idmap != nil {
+ identity, err := sm.idmap.ToHost(idtools.Identity{
+ UID: uid,
+ GID: gid,
+ })
+ if err != nil {
+ cleanup()
+ return nil, nil, err
+ }
+ uid = identity.UID
+ gid = identity.GID
+ }
+
+ if err := os.Chown(fp, uid, gid); err != nil {
+ cleanup()
+ return nil, nil, err
+ }
+
+ if err := os.Chmod(fp, os.FileMode(sm.sm.mount.SecretOpt.Mode&0777)); err != nil {
+ cleanup()
+ return nil, nil, err
+ }
+
+ return []mount.Mount{{
+ Type: "bind",
+ Source: fp,
+ Options: []string{"ro", "rbind", "nodev", "nosuid", "noexec"},
+ }}, cleanup, nil
+}
+
+func (sm *secretMountInstance) IdentityMapping() *idtools.IdentityMapping {
+ return sm.idmap
+}
+
+func (mm *MountManager) MountableCache(ctx context.Context, m *pb.Mount, ref cache.ImmutableRef, g session.Group) (cache.MutableRef, error) {
+ if m.CacheOpt == nil {
+ return nil, errors.Errorf("missing cache mount options")
+ }
+ return mm.getRefCacheDir(ctx, ref, m.CacheOpt.ID, m, m.CacheOpt.Sharing, g)
+}
+
+func (mm *MountManager) MountableTmpFS() cache.Mountable {
+ return newTmpfs(mm.cm.IdentityMapping())
+}
+
+func (mm *MountManager) MountableSecret(ctx context.Context, m *pb.Mount, g session.Group) (cache.Mountable, error) {
+ return mm.getSecretMountable(ctx, m, g)
+}
+
+func (mm *MountManager) MountableSSH(ctx context.Context, m *pb.Mount, g session.Group) (cache.Mountable, error) {
+ return mm.getSSHMountable(ctx, m, g)
+}
+
+func newTmpfs(idmap *idtools.IdentityMapping) cache.Mountable {
+ return &tmpfs{idmap: idmap}
+}
+
+type tmpfs struct {
+ idmap *idtools.IdentityMapping
+}
+
+func (f *tmpfs) Mount(ctx context.Context, readonly bool, g session.Group) (snapshot.Mountable, error) {
+ return &tmpfsMount{readonly: readonly, idmap: f.idmap}, nil
+}
+
+type tmpfsMount struct {
+ readonly bool
+ idmap *idtools.IdentityMapping
+}
+
+func (m *tmpfsMount) Mount() ([]mount.Mount, func() error, error) {
+ opt := []string{"nosuid"}
+ if m.readonly {
+ opt = append(opt, "ro")
+ }
+ return []mount.Mount{{
+ Type: "tmpfs",
+ Source: "tmpfs",
+ Options: opt,
+ }}, func() error { return nil }, nil
+}
+
+func (m *tmpfsMount) IdentityMapping() *idtools.IdentityMapping {
+ return m.idmap
+}
+
+var cacheRefsLocker = locker.New()
+var sharedCacheRefs = &cacheRefs{}
+
+type cacheRefs struct {
+ mu sync.Mutex
+ shares map[string]*cacheRefShare
+}
+
+// ClearActiveCacheMounts clears shared cache mounts currently in use.
+// Caller needs to hold CacheMountsLocker before calling
+func ClearActiveCacheMounts() {
+ sharedCacheRefs.shares = nil
+}
+
+func CacheMountsLocker() sync.Locker {
+ return &sharedCacheRefs.mu
+}
+
+func (r *cacheRefs) get(key string, fn func() (cache.MutableRef, error)) (cache.MutableRef, error) {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+
+ if r.shares == nil {
+ r.shares = map[string]*cacheRefShare{}
+ }
+
+ share, ok := r.shares[key]
+ if ok {
+ return share.clone(), nil
+ }
+
+ mref, err := fn()
+ if err != nil {
+ return nil, err
+ }
+
+ share = &cacheRefShare{MutableRef: mref, main: r, key: key, refs: map[*cacheRef]struct{}{}}
+ r.shares[key] = share
+ return share.clone(), nil
+}
+
+type cacheRefShare struct {
+ cache.MutableRef
+ mu sync.Mutex
+ refs map[*cacheRef]struct{}
+ main *cacheRefs
+ key string
+}
+
+func (r *cacheRefShare) clone() cache.MutableRef {
+ cacheRef := &cacheRef{cacheRefShare: r}
+ if cacheRefCloneHijack != nil {
+ cacheRefCloneHijack()
+ }
+ r.mu.Lock()
+ r.refs[cacheRef] = struct{}{}
+ r.mu.Unlock()
+ return cacheRef
+}
+
+func (r *cacheRefShare) release(ctx context.Context) error {
+ if r.main != nil {
+ delete(r.main.shares, r.key)
+ }
+ return r.MutableRef.Release(ctx)
+}
+
+var cacheRefReleaseHijack func()
+var cacheRefCloneHijack func()
+
+type cacheRef struct {
+ *cacheRefShare
+}
+
+func (r *cacheRef) Release(ctx context.Context) error {
+ if r.main != nil {
+ r.main.mu.Lock()
+ defer r.main.mu.Unlock()
+ }
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ delete(r.refs, r)
+ if len(r.refs) == 0 {
+ if cacheRefReleaseHijack != nil {
+ cacheRefReleaseHijack()
+ }
+ return r.release(ctx)
+ }
+ return nil
+}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/build.go b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/build.go
index d8b748d..5e7fbc7 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/build.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/build.go
@@ -54,6 +54,7 @@
Deps: make([]struct {
Selector digest.Digest
ComputeDigestFunc solver.ResultBasedCacheFunc
+ PreprocessFunc solver.PreprocessFunc
}, len(b.v.Inputs())),
}, true, nil
}
@@ -80,7 +81,7 @@
return nil, errors.Errorf("invalid reference for build %T", inp.Sys())
}
- mount, err := ref.ImmutableRef.Mount(ctx, true)
+ mount, err := ref.ImmutableRef.Mount(ctx, true, g)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go
index 6258ff5..1ad1890 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go
@@ -5,34 +5,22 @@
"context"
"encoding/json"
"fmt"
- "io/ioutil"
"net"
"os"
"path"
- "path/filepath"
"sort"
"strings"
- "sync"
- "time"
- "github.com/containerd/containerd/mount"
"github.com/containerd/containerd/platforms"
- "github.com/containerd/containerd/sys"
- "github.com/docker/docker/pkg/idtools"
- "github.com/docker/docker/pkg/locker"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/cache/metadata"
- "github.com/moby/buildkit/client"
"github.com/moby/buildkit/executor"
- "github.com/moby/buildkit/identity"
"github.com/moby/buildkit/session"
- "github.com/moby/buildkit/session/secrets"
- "github.com/moby/buildkit/session/sshforward"
"github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/solver"
"github.com/moby/buildkit/solver/llbsolver"
+ "github.com/moby/buildkit/solver/llbsolver/mounts"
"github.com/moby/buildkit/solver/pb"
- "github.com/moby/buildkit/util/grpcerrors"
"github.com/moby/buildkit/util/progress/logs"
utilsystem "github.com/moby/buildkit/util/system"
"github.com/moby/buildkit/worker"
@@ -40,8 +28,6 @@
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
- bolt "go.etcd.io/bbolt"
- "google.golang.org/grpc/codes"
)
const execCacheType = "buildkit.exec.v0"
@@ -49,31 +35,26 @@
type execOp struct {
op *pb.ExecOp
cm cache.Manager
- sm *session.Manager
- md *metadata.Store
+ mm *mounts.MountManager
exec executor.Executor
w worker.Worker
platform *pb.Platform
numInputs int
-
- cacheMounts map[string]*cacheRefShare
- cacheMountsMu sync.Mutex
}
func NewExecOp(v solver.Vertex, op *pb.Op_Exec, platform *pb.Platform, cm cache.Manager, sm *session.Manager, md *metadata.Store, exec executor.Executor, w worker.Worker) (solver.Op, error) {
if err := llbsolver.ValidateOp(&pb.Op{Op: op}); err != nil {
return nil, err
}
+ name := fmt.Sprintf("exec %s", strings.Join(op.Exec.Meta.Args, " "))
return &execOp{
- op: op.Exec,
- cm: cm,
- sm: sm,
- md: md,
- exec: exec,
- numInputs: len(v.Inputs()),
- w: w,
- platform: platform,
- cacheMounts: map[string]*cacheRefShare{},
+ op: op.Exec,
+ mm: mounts.NewMountManager(name, cm, sm, md),
+ cm: cm,
+ exec: exec,
+ numInputs: len(v.Inputs()),
+ w: w,
+ platform: platform,
}, nil
}
@@ -137,6 +118,7 @@
Deps: make([]struct {
Selector digest.Digest
ComputeDigestFunc solver.ResultBasedCacheFunc
+ PreprocessFunc solver.PreprocessFunc
}, e.numInputs),
}
@@ -156,6 +138,7 @@
if !dep.NoContentBasedHash {
cm.Deps[i].ComputeDigestFunc = llbsolver.NewContentHashFunc(toSelectors(dedupePaths(dep.Selectors)))
}
+ cm.Deps[i].PreprocessFunc = llbsolver.UnlazyResultFunc
}
return cm, true, nil
@@ -221,328 +204,6 @@
return deps, nil
}
-func (e *execOp) getRefCacheDir(ctx context.Context, ref cache.ImmutableRef, id string, m *pb.Mount, sharing pb.CacheSharingOpt) (mref cache.MutableRef, err error) {
- g := &cacheRefGetter{
- locker: &e.cacheMountsMu,
- cacheMounts: e.cacheMounts,
- cm: e.cm,
- md: e.md,
- globalCacheRefs: sharedCacheRefs,
- name: fmt.Sprintf("cached mount %s from exec %s", m.Dest, strings.Join(e.op.Meta.Args, " ")),
- }
- return g.getRefCacheDir(ctx, ref, id, sharing)
-}
-
-type cacheRefGetter struct {
- locker sync.Locker
- cacheMounts map[string]*cacheRefShare
- cm cache.Manager
- md *metadata.Store
- globalCacheRefs *cacheRefs
- name string
-}
-
-func (g *cacheRefGetter) getRefCacheDir(ctx context.Context, ref cache.ImmutableRef, id string, sharing pb.CacheSharingOpt) (mref cache.MutableRef, err error) {
- key := "cache-dir:" + id
- if ref != nil {
- key += ":" + ref.ID()
- }
- mu := g.locker
- mu.Lock()
- defer mu.Unlock()
-
- if ref, ok := g.cacheMounts[key]; ok {
- return ref.clone(), nil
- }
- defer func() {
- if err == nil {
- share := &cacheRefShare{MutableRef: mref, refs: map[*cacheRef]struct{}{}}
- g.cacheMounts[key] = share
- mref = share.clone()
- }
- }()
-
- switch sharing {
- case pb.CacheSharingOpt_SHARED:
- return g.globalCacheRefs.get(key, func() (cache.MutableRef, error) {
- return g.getRefCacheDirNoCache(ctx, key, ref, id, false)
- })
- case pb.CacheSharingOpt_PRIVATE:
- return g.getRefCacheDirNoCache(ctx, key, ref, id, false)
- case pb.CacheSharingOpt_LOCKED:
- return g.getRefCacheDirNoCache(ctx, key, ref, id, true)
- default:
- return nil, errors.Errorf("invalid cache sharing option: %s", sharing.String())
- }
-}
-
-func (g *cacheRefGetter) getRefCacheDirNoCache(ctx context.Context, key string, ref cache.ImmutableRef, id string, block bool) (cache.MutableRef, error) {
- makeMutable := func(ref cache.ImmutableRef) (cache.MutableRef, error) {
- return g.cm.New(ctx, ref, cache.WithRecordType(client.UsageRecordTypeCacheMount), cache.WithDescription(g.name), cache.CachePolicyRetain)
- }
-
- cacheRefsLocker.Lock(key)
- defer cacheRefsLocker.Unlock(key)
- for {
- sis, err := g.md.Search(key)
- if err != nil {
- return nil, err
- }
- locked := false
- for _, si := range sis {
- if mRef, err := g.cm.GetMutable(ctx, si.ID()); err == nil {
- logrus.Debugf("reusing ref for cache dir: %s", mRef.ID())
- return mRef, nil
- } else if errors.Is(err, cache.ErrLocked) {
- locked = true
- }
- }
- if block && locked {
- cacheRefsLocker.Unlock(key)
- select {
- case <-ctx.Done():
- cacheRefsLocker.Lock(key)
- return nil, ctx.Err()
- case <-time.After(100 * time.Millisecond):
- cacheRefsLocker.Lock(key)
- }
- } else {
- break
- }
- }
- mRef, err := makeMutable(ref)
- if err != nil {
- return nil, err
- }
-
- si, _ := g.md.Get(mRef.ID())
- v, err := metadata.NewValue(key)
- if err != nil {
- mRef.Release(context.TODO())
- return nil, err
- }
- v.Index = key
- if err := si.Update(func(b *bolt.Bucket) error {
- return si.SetValue(b, key, v)
- }); err != nil {
- mRef.Release(context.TODO())
- return nil, err
- }
- return mRef, nil
-}
-
-func (e *execOp) getSSHMountable(ctx context.Context, m *pb.Mount, g session.Group) (cache.Mountable, error) {
- var caller session.Caller
- err := e.sm.Any(ctx, g, func(ctx context.Context, _ string, c session.Caller) error {
- if err := sshforward.CheckSSHID(ctx, c, m.SSHOpt.ID); err != nil {
- if m.SSHOpt.Optional {
- return nil
- }
- if grpcerrors.Code(err) == codes.Unimplemented {
- return errors.Errorf("no SSH key %q forwarded from the client", m.SSHOpt.ID)
- }
- return err
- }
- caller = c
- return nil
- })
- if err != nil {
- return nil, err
- }
- // because ssh socket remains active, to actually handle session disconnecting ssh error
- // should restart the whole exec with new session
- return &sshMount{mount: m, caller: caller, idmap: e.cm.IdentityMapping()}, nil
-}
-
-type sshMount struct {
- mount *pb.Mount
- caller session.Caller
- idmap *idtools.IdentityMapping
-}
-
-func (sm *sshMount) Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error) {
- return &sshMountInstance{sm: sm, idmap: sm.idmap}, nil
-}
-
-type sshMountInstance struct {
- sm *sshMount
- idmap *idtools.IdentityMapping
-}
-
-func (sm *sshMountInstance) Mount() ([]mount.Mount, func() error, error) {
- ctx, cancel := context.WithCancel(context.TODO())
-
- uid := int(sm.sm.mount.SSHOpt.Uid)
- gid := int(sm.sm.mount.SSHOpt.Gid)
-
- if sm.idmap != nil {
- identity, err := sm.idmap.ToHost(idtools.Identity{
- UID: uid,
- GID: gid,
- })
- if err != nil {
- cancel()
- return nil, nil, err
- }
- uid = identity.UID
- gid = identity.GID
- }
-
- sock, cleanup, err := sshforward.MountSSHSocket(ctx, sm.sm.caller, sshforward.SocketOpt{
- ID: sm.sm.mount.SSHOpt.ID,
- UID: uid,
- GID: gid,
- Mode: int(sm.sm.mount.SSHOpt.Mode & 0777),
- })
- if err != nil {
- cancel()
- return nil, nil, err
- }
- release := func() error {
- var err error
- if cleanup != nil {
- err = cleanup()
- }
- cancel()
- return err
- }
-
- return []mount.Mount{{
- Type: "bind",
- Source: sock,
- Options: []string{"rbind"},
- }}, release, nil
-}
-
-func (sm *sshMountInstance) IdentityMapping() *idtools.IdentityMapping {
- return sm.idmap
-}
-
-func (e *execOp) getSecretMountable(ctx context.Context, m *pb.Mount, g session.Group) (cache.Mountable, error) {
- if m.SecretOpt == nil {
- return nil, errors.Errorf("invalid sercet mount options")
- }
- sopt := *m.SecretOpt
-
- id := sopt.ID
- if id == "" {
- return nil, errors.Errorf("secret ID missing from mount options")
- }
- var dt []byte
- var err error
- err = e.sm.Any(ctx, g, func(ctx context.Context, _ string, caller session.Caller) error {
- dt, err = secrets.GetSecret(ctx, caller, id)
- if err != nil {
- if errors.Is(err, secrets.ErrNotFound) && m.SecretOpt.Optional {
- return nil
- }
- return err
- }
- return nil
- })
- if err != nil || dt == nil {
- return nil, err
- }
- return &secretMount{mount: m, data: dt, idmap: e.cm.IdentityMapping()}, nil
-}
-
-type secretMount struct {
- mount *pb.Mount
- data []byte
- idmap *idtools.IdentityMapping
-}
-
-func (sm *secretMount) Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error) {
- return &secretMountInstance{sm: sm, idmap: sm.idmap}, nil
-}
-
-type secretMountInstance struct {
- sm *secretMount
- root string
- idmap *idtools.IdentityMapping
-}
-
-func (sm *secretMountInstance) Mount() ([]mount.Mount, func() error, error) {
- dir, err := ioutil.TempDir("", "buildkit-secrets")
- if err != nil {
- return nil, nil, errors.Wrap(err, "failed to create temp dir")
- }
- cleanupDir := func() error {
- return os.RemoveAll(dir)
- }
-
- if err := os.Chmod(dir, 0711); err != nil {
- cleanupDir()
- return nil, nil, err
- }
-
- tmpMount := mount.Mount{
- Type: "tmpfs",
- Source: "tmpfs",
- Options: []string{"nodev", "nosuid", "noexec", fmt.Sprintf("uid=%d,gid=%d", os.Geteuid(), os.Getegid())},
- }
-
- if sys.RunningInUserNS() {
- tmpMount.Options = nil
- }
-
- if err := mount.All([]mount.Mount{tmpMount}, dir); err != nil {
- cleanupDir()
- return nil, nil, errors.Wrap(err, "unable to setup secret mount")
- }
- sm.root = dir
-
- cleanup := func() error {
- if err := mount.Unmount(dir, 0); err != nil {
- return err
- }
- return cleanupDir()
- }
-
- randID := identity.NewID()
- fp := filepath.Join(dir, randID)
- if err := ioutil.WriteFile(fp, sm.sm.data, 0600); err != nil {
- cleanup()
- return nil, nil, err
- }
-
- uid := int(sm.sm.mount.SecretOpt.Uid)
- gid := int(sm.sm.mount.SecretOpt.Gid)
-
- if sm.idmap != nil {
- identity, err := sm.idmap.ToHost(idtools.Identity{
- UID: uid,
- GID: gid,
- })
- if err != nil {
- cleanup()
- return nil, nil, err
- }
- uid = identity.UID
- gid = identity.GID
- }
-
- if err := os.Chown(fp, uid, gid); err != nil {
- cleanup()
- return nil, nil, err
- }
-
- if err := os.Chmod(fp, os.FileMode(sm.sm.mount.SecretOpt.Mode&0777)); err != nil {
- cleanup()
- return nil, nil, err
- }
-
- return []mount.Mount{{
- Type: "bind",
- Source: fp,
- Options: []string{"ro", "rbind", "nodev", "nosuid", "noexec"},
- }}, cleanup, nil
-}
-
-func (sm *secretMountInstance) IdentityMapping() *idtools.IdentityMapping {
- return sm.idmap
-}
-
func addDefaultEnvvar(env []string, k, v string) []string {
for _, e := range env {
if strings.HasPrefix(e, k+"=") {
@@ -592,14 +253,14 @@
makeMutable := func(ref cache.ImmutableRef) (cache.MutableRef, error) {
desc := fmt.Sprintf("mount %s from exec %s", m.Dest, strings.Join(e.op.Meta.Args, " "))
- return e.cm.New(ctx, ref, cache.WithDescription(desc))
+ return e.cm.New(ctx, ref, g, cache.WithDescription(desc))
}
switch m.MountType {
case pb.MountType_BIND:
// if mount creates an output
if m.Output != pb.SkipOutput {
- // it it is readonly and not root then output is the input
+ // if it is readonly and not root then output is the input
if m.Readonly && ref != nil && m.Dest != pb.RootMount {
outputs = append(outputs, ref.Clone())
} else {
@@ -622,10 +283,7 @@
}
case pb.MountType_CACHE:
- if m.CacheOpt == nil {
- return nil, errors.Errorf("missing cache mount options")
- }
- mRef, err := e.getRefCacheDir(ctx, ref, m.CacheOpt.ID, m, m.CacheOpt.Sharing)
+ mRef, err := e.mm.MountableCache(ctx, m, ref, g)
if err != nil {
return nil, err
}
@@ -638,27 +296,25 @@
}
case pb.MountType_TMPFS:
- mountable = newTmpfs(e.cm.IdentityMapping())
-
+ mountable = e.mm.MountableTmpFS()
case pb.MountType_SECRET:
- secretMount, err := e.getSecretMountable(ctx, m, g)
+ var err error
+ mountable, err = e.mm.MountableSecret(ctx, m, g)
if err != nil {
return nil, err
}
- if secretMount == nil {
+ if mountable == nil {
continue
}
- mountable = secretMount
-
case pb.MountType_SSH:
- sshMount, err := e.getSSHMountable(ctx, m, g)
+ var err error
+ mountable, err = e.mm.MountableSSH(ctx, m, g)
if err != nil {
return nil, err
}
- if sshMount == nil {
+ if mountable == nil {
continue
}
- mountable = sshMount
default:
return nil, errors.Errorf("mount type %s not implemented", m.MountType)
@@ -684,7 +340,11 @@
root = active
}
} else {
- mounts = append(mounts, executor.Mount{Src: mountable, Dest: m.Dest, Readonly: m.Readonly, Selector: m.Selector})
+ mws := mountWithSession(mountable, g)
+ mws.Dest = m.Dest
+ mws.Readonly = m.Readonly
+ mws.Selector = m.Selector
+ mounts = append(mounts, mws)
}
}
@@ -717,6 +377,7 @@
Env: e.op.Meta.Env,
Cwd: e.op.Meta.Cwd,
User: e.op.Meta.User,
+ Hostname: e.op.Meta.Hostname,
ReadonlyRootFS: readonlyRootFS,
ExtraHosts: extraHosts,
NetMode: e.op.Network,
@@ -726,13 +387,17 @@
if e.op.Meta.ProxyEnv != nil {
meta.Env = append(meta.Env, proxyEnvList(e.op.Meta.ProxyEnv)...)
}
- meta.Env = addDefaultEnvvar(meta.Env, "PATH", utilsystem.DefaultPathEnv)
+ var currentOS string
+ if e.platform != nil {
+ currentOS = e.platform.OS
+ }
+ meta.Env = addDefaultEnvvar(meta.Env, "PATH", utilsystem.DefaultPathEnv(currentOS))
stdout, stderr := logs.NewLogStreams(ctx, os.Getenv("BUILDKIT_DEBUG_EXEC_OUTPUT") == "1")
defer stdout.Close()
defer stderr.Close()
- if err := e.exec.Run(ctx, "", root, mounts, executor.ProcessInfo{Meta: meta, Stdin: nil, Stdout: stdout, Stderr: stderr}, nil); err != nil {
+ if err := e.exec.Run(ctx, "", mountWithSession(root, g), mounts, executor.ProcessInfo{Meta: meta, Stdin: nil, Stdout: stdout, Stderr: stderr}, nil); err != nil {
return nil, errors.Wrapf(err, "executor failed running %v", meta.Args)
}
@@ -769,130 +434,6 @@
return out
}
-func newTmpfs(idmap *idtools.IdentityMapping) cache.Mountable {
- return &tmpfs{idmap: idmap}
-}
-
-type tmpfs struct {
- idmap *idtools.IdentityMapping
-}
-
-func (f *tmpfs) Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error) {
- return &tmpfsMount{readonly: readonly, idmap: f.idmap}, nil
-}
-
-type tmpfsMount struct {
- readonly bool
- idmap *idtools.IdentityMapping
-}
-
-func (m *tmpfsMount) Mount() ([]mount.Mount, func() error, error) {
- opt := []string{"nosuid"}
- if m.readonly {
- opt = append(opt, "ro")
- }
- return []mount.Mount{{
- Type: "tmpfs",
- Source: "tmpfs",
- Options: opt,
- }}, func() error { return nil }, nil
-}
-
-func (m *tmpfsMount) IdentityMapping() *idtools.IdentityMapping {
- return m.idmap
-}
-
-var cacheRefsLocker = locker.New()
-var sharedCacheRefs = &cacheRefs{}
-
-type cacheRefs struct {
- mu sync.Mutex
- shares map[string]*cacheRefShare
-}
-
-// ClearActiveCacheMounts clears shared cache mounts currently in use.
-// Caller needs to hold CacheMountsLocker before calling
-func ClearActiveCacheMounts() {
- sharedCacheRefs.shares = nil
-}
-
-func CacheMountsLocker() sync.Locker {
- return &sharedCacheRefs.mu
-}
-
-func (r *cacheRefs) get(key string, fn func() (cache.MutableRef, error)) (cache.MutableRef, error) {
- r.mu.Lock()
- defer r.mu.Unlock()
-
- if r.shares == nil {
- r.shares = map[string]*cacheRefShare{}
- }
-
- share, ok := r.shares[key]
- if ok {
- return share.clone(), nil
- }
-
- mref, err := fn()
- if err != nil {
- return nil, err
- }
-
- share = &cacheRefShare{MutableRef: mref, main: r, key: key, refs: map[*cacheRef]struct{}{}}
- r.shares[key] = share
- return share.clone(), nil
-}
-
-type cacheRefShare struct {
- cache.MutableRef
- mu sync.Mutex
- refs map[*cacheRef]struct{}
- main *cacheRefs
- key string
-}
-
-func (r *cacheRefShare) clone() cache.MutableRef {
- cacheRef := &cacheRef{cacheRefShare: r}
- if cacheRefCloneHijack != nil {
- cacheRefCloneHijack()
- }
- r.mu.Lock()
- r.refs[cacheRef] = struct{}{}
- r.mu.Unlock()
- return cacheRef
-}
-
-func (r *cacheRefShare) release(ctx context.Context) error {
- if r.main != nil {
- delete(r.main.shares, r.key)
- }
- return r.MutableRef.Release(ctx)
-}
-
-var cacheRefReleaseHijack func()
-var cacheRefCloneHijack func()
-
-type cacheRef struct {
- *cacheRefShare
-}
-
-func (r *cacheRef) Release(ctx context.Context) error {
- if r.main != nil {
- r.main.mu.Lock()
- defer r.main.mu.Unlock()
- }
- r.mu.Lock()
- defer r.mu.Unlock()
- delete(r.refs, r)
- if len(r.refs) == 0 {
- if cacheRefReleaseHijack != nil {
- cacheRefReleaseHijack()
- }
- return r.release(ctx)
- }
- return nil
-}
-
func parseExtraHosts(ips []*pb.HostIP) ([]executor.HostIP, error) {
out := make([]executor.HostIP, len(ips))
for i, hip := range ips {
@@ -907,3 +448,20 @@
}
return out, nil
}
+
+func mountWithSession(m cache.Mountable, g session.Group) executor.Mount {
+ _, readonly := m.(cache.ImmutableRef)
+ return executor.Mount{
+ Src: &mountable{m: m, g: g},
+ Readonly: readonly,
+ }
+}
+
+type mountable struct {
+ m cache.Mountable
+ g session.Group
+}
+
+func (m *mountable) Mount(ctx context.Context, readonly bool) (snapshot.Mountable, error) {
+ return m.m.Mount(ctx, readonly, m.g)
+}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec_binfmt.go b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec_binfmt.go
index 5eea8ff..0603cf5 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec_binfmt.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec_binfmt.go
@@ -12,7 +12,7 @@
"github.com/docker/docker/pkg/idtools"
"github.com/moby/buildkit/snapshot"
"github.com/moby/buildkit/solver/pb"
- "github.com/moby/buildkit/util/binfmt_misc"
+ "github.com/moby/buildkit/util/archutil"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
copy "github.com/tonistiigi/fsutil/copy"
@@ -83,7 +83,7 @@
}
func getEmulator(p *pb.Platform, idmap *idtools.IdentityMapping) (*emulator, error) {
- all := binfmt_misc.SupportedPlatforms(false)
+ all := archutil.SupportedPlatforms(false)
m := make(map[string]struct{}, len(all))
for _, p := range all {
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/file.go b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/file.go
index db10cfb..78b0c03 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/file.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/file.go
@@ -120,6 +120,7 @@
Deps: make([]struct {
Selector digest.Digest
ComputeDigestFunc solver.ResultBasedCacheFunc
+ PreprocessFunc solver.PreprocessFunc
}, f.numInputs),
}
@@ -138,6 +139,9 @@
cm.Deps[idx].ComputeDigestFunc = llbsolver.NewContentHashFunc(dedupeSelectors(m))
}
+ for idx := range cm.Deps {
+ cm.Deps[idx].PreprocessFunc = llbsolver.UnlazyResultFunc
+ }
return cm, true, nil
}
@@ -152,7 +156,7 @@
inpRefs = append(inpRefs, workerRef.ImmutableRef)
}
- outs, err := f.solver.Solve(ctx, inpRefs, f.op.Actions)
+ outs, err := f.solver.Solve(ctx, inpRefs, f.op.Actions, g)
if err != nil {
return nil, err
}
@@ -279,7 +283,7 @@
ref fileoptypes.Ref
}
-func (s *FileOpSolver) Solve(ctx context.Context, inputs []fileoptypes.Ref, actions []*pb.FileAction) ([]fileoptypes.Ref, error) {
+func (s *FileOpSolver) Solve(ctx context.Context, inputs []fileoptypes.Ref, actions []*pb.FileAction, g session.Group) ([]fileoptypes.Ref, error) {
for i, a := range actions {
if int(a.Input) < -1 || int(a.Input) >= len(inputs)+len(actions) {
return nil, errors.Errorf("invalid input index %d, %d provided", a.Input, len(inputs)+len(actions))
@@ -337,7 +341,7 @@
if err := s.validate(idx, inputs, actions, nil); err != nil {
return err
}
- inp, err := s.getInput(ctx, idx, inputs, actions)
+ inp, err := s.getInput(ctx, idx, inputs, actions, g)
if err != nil {
return err
}
@@ -378,7 +382,7 @@
return nil
}
-func (s *FileOpSolver) getInput(ctx context.Context, idx int, inputs []fileoptypes.Ref, actions []*pb.FileAction) (input, error) {
+func (s *FileOpSolver) getInput(ctx context.Context, idx int, inputs []fileoptypes.Ref, actions []*pb.FileAction, g session.Group) (input, error) {
inp, err := s.g.Do(ctx, fmt.Sprintf("inp-%d", idx), func(ctx context.Context) (_ interface{}, err error) {
s.mu.Lock()
inp := s.ins[idx]
@@ -411,12 +415,12 @@
loadInput := func(ctx context.Context) func() error {
return func() error {
- inp, err := s.getInput(ctx, int(action.Input), inputs, actions)
+ inp, err := s.getInput(ctx, int(action.Input), inputs, actions, g)
if err != nil {
return err
}
if inp.ref != nil {
- m, err := s.r.Prepare(ctx, inp.ref, false)
+ m, err := s.r.Prepare(ctx, inp.ref, false, g)
if err != nil {
return err
}
@@ -431,12 +435,12 @@
loadSecondaryInput := func(ctx context.Context) func() error {
return func() error {
- inp, err := s.getInput(ctx, int(action.SecondaryInput), inputs, actions)
+ inp, err := s.getInput(ctx, int(action.SecondaryInput), inputs, actions, g)
if err != nil {
return err
}
if inp.ref != nil {
- m, err := s.r.Prepare(ctx, inp.ref, true)
+ m, err := s.r.Prepare(ctx, inp.ref, true, g)
if err != nil {
return err
}
@@ -459,12 +463,12 @@
if u.ByName.Input < 0 {
return nil, errors.Errorf("invalid user index: %d", u.ByName.Input)
}
- inp, err := s.getInput(ctx, int(u.ByName.Input), inputs, actions)
+ inp, err := s.getInput(ctx, int(u.ByName.Input), inputs, actions, g)
if err != nil {
return nil, err
}
if inp.ref != nil {
- mm, err := s.r.Prepare(ctx, inp.ref, true)
+ mm, err := s.r.Prepare(ctx, inp.ref, true, g)
if err != nil {
return nil, err
}
@@ -515,7 +519,7 @@
}
if inpMount == nil {
- m, err := s.r.Prepare(ctx, nil, false)
+ m, err := s.r.Prepare(ctx, nil, false, g)
if err != nil {
return nil, err
}
@@ -546,7 +550,7 @@
}
case *pb.FileAction_Copy:
if inpMountSecondary == nil {
- m, err := s.r.Prepare(ctx, nil, true)
+ m, err := s.r.Prepare(ctx, nil, true, g)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/fileoptypes/types.go b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/fileoptypes/types.go
index 67aab02..ca7f3e2 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/fileoptypes/types.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/fileoptypes/types.go
@@ -3,6 +3,7 @@
import (
"context"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver/pb"
)
@@ -23,6 +24,6 @@
}
type RefManager interface {
- Prepare(ctx context.Context, ref Ref, readonly bool) (Mount, error)
+ Prepare(ctx context.Context, ref Ref, readonly bool, g session.Group) (Mount, error)
Commit(ctx context.Context, mount Mount) (Ref, error)
}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/source.go b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/source.go
index b1972ad..4f8b669 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/source.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/source.go
@@ -24,9 +24,10 @@
src source.SourceInstance
sessM *session.Manager
w worker.Worker
+ vtx solver.Vertex
}
-func NewSourceOp(_ solver.Vertex, op *pb.Op_Source, platform *pb.Platform, sm *source.Manager, sessM *session.Manager, w worker.Worker) (solver.Op, error) {
+func NewSourceOp(vtx solver.Vertex, op *pb.Op_Source, platform *pb.Platform, sm *source.Manager, sessM *session.Manager, w worker.Worker) (solver.Op, error) {
if err := llbsolver.ValidateOp(&pb.Op{Op: op}); err != nil {
return nil, err
}
@@ -36,6 +37,7 @@
w: w,
sessM: sessM,
platform: platform,
+ vtx: vtx,
}, nil
}
@@ -49,7 +51,7 @@
if err != nil {
return nil, err
}
- src, err := s.sm.Resolve(ctx, id, s.sessM)
+ src, err := s.sm.Resolve(ctx, id, s.sessM, s.vtx)
if err != nil {
return nil, err
}
@@ -62,7 +64,7 @@
if err != nil {
return nil, false, err
}
- k, done, err := src.CacheKey(ctx, g, index)
+ k, cacheOpts, done, err := src.CacheKey(ctx, g, index)
if err != nil {
return nil, false, err
}
@@ -76,6 +78,7 @@
return &solver.CacheMap{
// TODO: add os/arch
Digest: dgst,
+ Opts: cacheOpts,
}, done, nil
}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/result.go b/vendor/github.com/moby/buildkit/solver/llbsolver/result.go
index dc96e4d..4c72353 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/result.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/result.go
@@ -6,7 +6,9 @@
"path"
"github.com/moby/buildkit/cache/contenthash"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/util/compression"
"github.com/moby/buildkit/worker"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
@@ -19,8 +21,19 @@
FollowLinks bool
}
+func UnlazyResultFunc(ctx context.Context, res solver.Result, g session.Group) error {
+ ref, ok := res.Sys().(*worker.WorkerRef)
+ if !ok {
+ return errors.Errorf("invalid reference: %T", res)
+ }
+ if ref.ImmutableRef == nil {
+ return nil
+ }
+ return ref.ImmutableRef.Extract(ctx, g)
+}
+
func NewContentHashFunc(selectors []Selector) solver.ResultBasedCacheFunc {
- return func(ctx context.Context, res solver.Result) (digest.Digest, error) {
+ return func(ctx context.Context, res solver.Result, s session.Group) (digest.Digest, error) {
ref, ok := res.Sys().(*worker.WorkerRef)
if !ok {
return "", errors.Errorf("invalid reference: %T", res)
@@ -35,25 +48,23 @@
eg, ctx := errgroup.WithContext(ctx)
for i, sel := range selectors {
- // FIXME(tonistiigi): enabling this parallelization seems to create wrong results for some big inputs(like gobuild)
- // func(i int) {
- // eg.Go(func() error {
- if !sel.Wildcard {
- dgst, err := contenthash.Checksum(ctx, ref.ImmutableRef, path.Join("/", sel.Path), sel.FollowLinks)
- if err != nil {
- return "", err
+ i, sel := i, sel
+ eg.Go(func() error {
+ if !sel.Wildcard {
+ dgst, err := contenthash.Checksum(ctx, ref.ImmutableRef, path.Join("/", sel.Path), sel.FollowLinks, s)
+ if err != nil {
+ return err
+ }
+ dgsts[i] = []byte(dgst)
+ } else {
+ dgst, err := contenthash.ChecksumWildcard(ctx, ref.ImmutableRef, path.Join("/", sel.Path), sel.FollowLinks, s)
+ if err != nil {
+ return err
+ }
+ dgsts[i] = []byte(dgst)
}
- dgsts[i] = []byte(dgst)
- } else {
- dgst, err := contenthash.ChecksumWildcard(ctx, ref.ImmutableRef, path.Join("/", sel.Path), sel.FollowLinks)
- if err != nil {
- return "", err
- }
- dgsts[i] = []byte(dgst)
- }
- // return nil
- // })
- // }(i)
+ return nil
+ })
}
if err := eg.Wait(); err != nil {
@@ -64,11 +75,13 @@
}
}
-func workerRefConverter(ctx context.Context, res solver.Result) (*solver.Remote, error) {
- ref, ok := res.Sys().(*worker.WorkerRef)
- if !ok {
- return nil, errors.Errorf("invalid result: %T", res.Sys())
- }
+func workerRefConverter(g session.Group) func(ctx context.Context, res solver.Result) (*solver.Remote, error) {
+ return func(ctx context.Context, res solver.Result) (*solver.Remote, error) {
+ ref, ok := res.Sys().(*worker.WorkerRef)
+ if !ok {
+ return nil, errors.Errorf("invalid result: %T", res.Sys())
+ }
- return ref.Worker.GetRemote(ctx, ref.ImmutableRef, true)
+ return ref.GetRemote(ctx, true, compression.Default, g)
+ }
}
diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/solver.go b/vendor/github.com/moby/buildkit/solver/llbsolver/solver.go
index 3d4f2da..d3ef585 100644
--- a/vendor/github.com/moby/buildkit/solver/llbsolver/solver.go
+++ b/vendor/github.com/moby/buildkit/solver/llbsolver/solver.go
@@ -16,6 +16,7 @@
"github.com/moby/buildkit/frontend/gateway"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/util/compression"
"github.com/moby/buildkit/util/entitlements"
"github.com/moby/buildkit/util/progress"
"github.com/moby/buildkit/worker"
@@ -106,7 +107,7 @@
var res *frontend.Result
if s.gatewayForwarder != nil && req.Definition == nil && req.Frontend == "" {
- fwd := gateway.NewBridgeForwarder(ctx, s.Bridge(j), s.workerController, req.FrontendInputs, sessionID)
+ fwd := gateway.NewBridgeForwarder(ctx, s.Bridge(j), s.workerController, req.FrontendInputs, sessionID, s.sm)
defer fwd.Discard()
if err := s.gatewayForwarder.RegisterBuild(ctx, id, fwd); err != nil {
return nil, err
@@ -168,7 +169,7 @@
}
inp.Ref = workerRef.ImmutableRef
- dt, err := inlineCache(ctx, exp.CacheExporter, r)
+ dt, err := inlineCache(ctx, exp.CacheExporter, r, session.NewGroup(sessionID))
if err != nil {
return nil, err
}
@@ -192,7 +193,7 @@
}
m[k] = workerRef.ImmutableRef
- dt, err := inlineCache(ctx, exp.CacheExporter, r)
+ dt, err := inlineCache(ctx, exp.CacheExporter, r, session.NewGroup(sessionID))
if err != nil {
return nil, err
}
@@ -212,6 +213,7 @@
}
}
+ g := session.NewGroup(j.SessionID)
var cacheExporterResponse map[string]string
if e := exp.CacheExporter; e != nil {
if err := inBuilderContext(ctx, j, "exporting cache", "", func(ctx context.Context, _ session.Group) error {
@@ -223,8 +225,9 @@
}
// all keys have same export chain so exporting others is not needed
_, err = r.CacheKeys()[0].Exporter.ExportTo(ctx, e, solver.CacheExportOpt{
- Convert: workerRefConverter,
+ Convert: workerRefConverter(g),
Mode: exp.CacheExportMode,
+ Session: g,
})
return err
}); err != nil {
@@ -258,7 +261,7 @@
}, nil
}
-func inlineCache(ctx context.Context, e remotecache.Exporter, res solver.CachedResult) ([]byte, error) {
+func inlineCache(ctx context.Context, e remotecache.Exporter, res solver.CachedResult, g session.Group) ([]byte, error) {
if efl, ok := e.(interface {
ExportForLayers([]digest.Digest) ([]byte, error)
}); ok {
@@ -267,7 +270,7 @@
return nil, errors.Errorf("invalid reference: %T", res.Sys())
}
- remote, err := workerRef.Worker.GetRemote(ctx, workerRef.ImmutableRef, true)
+ remote, err := workerRef.GetRemote(ctx, true, compression.Default, g)
if err != nil || remote == nil {
return nil, nil
}
@@ -278,8 +281,9 @@
}
if _, err := res.CacheKeys()[0].Exporter.ExportTo(ctx, e, solver.CacheExportOpt{
- Convert: workerRefConverter,
+ Convert: workerRefConverter(g),
Mode: solver.CacheExportModeMin,
+ Session: g,
}); err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/solver/memorycachestorage.go b/vendor/github.com/moby/buildkit/solver/memorycachestorage.go
index e0e58f0..6754d48 100644
--- a/vendor/github.com/moby/buildkit/solver/memorycachestorage.go
+++ b/vendor/github.com/moby/buildkit/solver/memorycachestorage.go
@@ -5,6 +5,7 @@
"sync"
"time"
+ "github.com/moby/buildkit/session"
"github.com/pkg/errors"
)
@@ -297,7 +298,7 @@
return v.(Result), nil
}
-func (s *inMemoryResultStore) LoadRemote(ctx context.Context, res CacheResult) (*Remote, error) {
+func (s *inMemoryResultStore) LoadRemote(_ context.Context, _ CacheResult, _ session.Group) (*Remote, error) {
return nil, nil
}
diff --git a/vendor/github.com/moby/buildkit/solver/pb/caps.go b/vendor/github.com/moby/buildkit/solver/pb/caps.go
index 43a1817..86552b2 100644
--- a/vendor/github.com/moby/buildkit/solver/pb/caps.go
+++ b/vendor/github.com/moby/buildkit/solver/pb/caps.go
@@ -22,7 +22,7 @@
CapSourceGit apicaps.CapID = "source.git"
CapSourceGitKeepDir apicaps.CapID = "source.git.keepgitdir"
CapSourceGitFullURL apicaps.CapID = "source.git.fullurl"
- CapSourceGitHttpAuth apicaps.CapID = "source.git.httpauth"
+ CapSourceGitHTTPAuth apicaps.CapID = "source.git.httpauth"
CapSourceHTTP apicaps.CapID = "source.http"
CapSourceHTTPChecksum apicaps.CapID = "source.http.checksum"
@@ -133,7 +133,7 @@
})
Caps.Init(apicaps.Cap{
- ID: CapSourceGitHttpAuth,
+ ID: CapSourceGitHTTPAuth,
Enabled: true,
Status: apicaps.CapStatusExperimental,
})
diff --git a/vendor/github.com/moby/buildkit/solver/pb/ops.pb.go b/vendor/github.com/moby/buildkit/solver/pb/ops.pb.go
index 90e549d..93023b3 100644
--- a/vendor/github.com/moby/buildkit/solver/pb/ops.pb.go
+++ b/vendor/github.com/moby/buildkit/solver/pb/ops.pb.go
@@ -467,6 +467,7 @@
User string `protobuf:"bytes,4,opt,name=user,proto3" json:"user,omitempty"`
ProxyEnv *ProxyEnv `protobuf:"bytes,5,opt,name=proxy_env,json=proxyEnv,proto3" json:"proxy_env,omitempty"`
ExtraHosts []*HostIP `protobuf:"bytes,6,rep,name=extraHosts,proto3" json:"extraHosts,omitempty"`
+ Hostname string `protobuf:"bytes,7,opt,name=hostname,proto3" json:"hostname,omitempty"`
}
func (m *Meta) Reset() { *m = Meta{} }
@@ -540,6 +541,13 @@
return nil
}
+func (m *Meta) GetHostname() string {
+ if m != nil {
+ return m.Hostname
+ }
+ return ""
+}
+
// Mount specifies how to mount an input Op as a filesystem.
type Mount struct {
Input InputIndex `protobuf:"varint,1,opt,name=input,proto3,customtype=InputIndex" json:"input"`
@@ -551,6 +559,7 @@
CacheOpt *CacheOpt `protobuf:"bytes,20,opt,name=cacheOpt,proto3" json:"cacheOpt,omitempty"`
SecretOpt *SecretOpt `protobuf:"bytes,21,opt,name=secretOpt,proto3" json:"secretOpt,omitempty"`
SSHOpt *SSHOpt `protobuf:"bytes,22,opt,name=SSHOpt,proto3" json:"SSHOpt,omitempty"`
+ ResultID string `protobuf:"bytes,23,opt,name=resultID,proto3" json:"resultID,omitempty"`
}
func (m *Mount) Reset() { *m = Mount{} }
@@ -631,6 +640,13 @@
return nil
}
+func (m *Mount) GetResultID() string {
+ if m != nil {
+ return m.ResultID
+ }
+ return ""
+}
+
// CacheOpt defines options specific to cache mounts
type CacheOpt struct {
// ID is an optional namespace for the mount
@@ -2316,144 +2332,146 @@
func init() { proto.RegisterFile("ops.proto", fileDescriptor_8de16154b2733812) }
var fileDescriptor_8de16154b2733812 = []byte{
- // 2189 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4b, 0x6f, 0x1b, 0xc9,
- 0xf1, 0x17, 0xdf, 0x64, 0x51, 0x92, 0xf9, 0xef, 0xf5, 0xee, 0x9f, 0xab, 0x38, 0x92, 0x76, 0xec,
- 0x2c, 0x64, 0xd9, 0xa6, 0x00, 0x2d, 0xb0, 0x5e, 0x2c, 0x82, 0x20, 0xe2, 0xc3, 0x10, 0xd7, 0xb6,
- 0x28, 0x34, 0xfd, 0xc8, 0xcd, 0x18, 0x0d, 0x9b, 0xd4, 0x40, 0xe4, 0xf4, 0xa0, 0xa7, 0x69, 0x8b,
- 0x97, 0x1c, 0xfc, 0x09, 0x16, 0x08, 0x90, 0x5b, 0x02, 0xe4, 0x12, 0x20, 0xf7, 0x5c, 0x73, 0xdf,
- 0xe3, 0x22, 0xc8, 0x61, 0x91, 0xc3, 0x26, 0xb0, 0x3f, 0x47, 0x80, 0xa0, 0xaa, 0x7b, 0x1e, 0x94,
- 0x65, 0xd8, 0x46, 0x82, 0x9c, 0xd8, 0xfd, 0xab, 0x5f, 0x57, 0x57, 0x57, 0x55, 0xd7, 0x54, 0x13,
- 0x6a, 0x32, 0x8c, 0x5a, 0xa1, 0x92, 0x5a, 0xb2, 0x7c, 0x78, 0xb2, 0x71, 0x67, 0xe2, 0xeb, 0xd3,
- 0xf9, 0x49, 0xcb, 0x93, 0xb3, 0xbd, 0x89, 0x9c, 0xc8, 0x3d, 0x12, 0x9d, 0xcc, 0xc7, 0x34, 0xa3,
- 0x09, 0x8d, 0xcc, 0x12, 0xe7, 0x0f, 0x79, 0xc8, 0x0f, 0x42, 0xf6, 0x19, 0x94, 0xfd, 0x20, 0x9c,
- 0xeb, 0xa8, 0x99, 0xdb, 0x2e, 0xec, 0xd4, 0xf7, 0x6b, 0xad, 0xf0, 0xa4, 0xd5, 0x47, 0x84, 0x5b,
- 0x01, 0xdb, 0x86, 0xa2, 0x38, 0x17, 0x5e, 0x33, 0xbf, 0x9d, 0xdb, 0xa9, 0xef, 0x03, 0x12, 0x7a,
- 0xe7, 0xc2, 0x1b, 0x84, 0x87, 0x2b, 0x9c, 0x24, 0xec, 0x73, 0x28, 0x47, 0x72, 0xae, 0x3c, 0xd1,
- 0x2c, 0x10, 0x67, 0x15, 0x39, 0x43, 0x42, 0x88, 0x65, 0xa5, 0xa8, 0x69, 0xec, 0x4f, 0x45, 0xb3,
- 0x98, 0x6a, 0xba, 0xe7, 0x4f, 0x0d, 0x87, 0x24, 0xec, 0x3a, 0x94, 0x4e, 0xe6, 0xfe, 0x74, 0xd4,
- 0x2c, 0x11, 0xa5, 0x8e, 0x94, 0x36, 0x02, 0xc4, 0x31, 0x32, 0xb6, 0x03, 0xd5, 0x70, 0xea, 0xea,
- 0xb1, 0x54, 0xb3, 0x26, 0xa4, 0x1b, 0x1e, 0x5b, 0x8c, 0x27, 0x52, 0x76, 0x17, 0xea, 0x9e, 0x0c,
- 0x22, 0xad, 0x5c, 0x3f, 0xd0, 0x51, 0xb3, 0x4e, 0xe4, 0x8f, 0x91, 0xfc, 0x54, 0xaa, 0x33, 0xa1,
- 0x3a, 0xa9, 0x90, 0x67, 0x99, 0xed, 0x22, 0xe4, 0x65, 0xe8, 0xfc, 0x36, 0x07, 0xd5, 0x58, 0x2b,
- 0x73, 0x60, 0xf5, 0x40, 0x79, 0xa7, 0xbe, 0x16, 0x9e, 0x9e, 0x2b, 0xd1, 0xcc, 0x6d, 0xe7, 0x76,
- 0x6a, 0x7c, 0x09, 0x63, 0xeb, 0x90, 0x1f, 0x0c, 0xc9, 0x51, 0x35, 0x9e, 0x1f, 0x0c, 0x59, 0x13,
- 0x2a, 0x4f, 0x5c, 0xe5, 0xbb, 0x81, 0x26, 0xcf, 0xd4, 0x78, 0x3c, 0x65, 0xd7, 0xa0, 0x36, 0x18,
- 0x3e, 0x11, 0x2a, 0xf2, 0x65, 0x40, 0xfe, 0xa8, 0xf1, 0x14, 0x60, 0x9b, 0x00, 0x83, 0xe1, 0x3d,
- 0xe1, 0xa2, 0xd2, 0xa8, 0x59, 0xda, 0x2e, 0xec, 0xd4, 0x78, 0x06, 0x71, 0x7e, 0x0d, 0x25, 0x8a,
- 0x11, 0xfb, 0x06, 0xca, 0x23, 0x7f, 0x22, 0x22, 0x6d, 0xcc, 0x69, 0xef, 0x7f, 0xf7, 0xe3, 0xd6,
- 0xca, 0xdf, 0x7f, 0xdc, 0xda, 0xcd, 0x24, 0x83, 0x0c, 0x45, 0xe0, 0xc9, 0x40, 0xbb, 0x7e, 0x20,
- 0x54, 0xb4, 0x37, 0x91, 0x77, 0xcc, 0x92, 0x56, 0x97, 0x7e, 0xb8, 0xd5, 0xc0, 0x6e, 0x42, 0xc9,
- 0x0f, 0x46, 0xe2, 0x9c, 0xec, 0x2f, 0xb4, 0x3f, 0xb2, 0xaa, 0xea, 0x83, 0xb9, 0x0e, 0xe7, 0xba,
- 0x8f, 0x22, 0x6e, 0x18, 0xce, 0xef, 0x73, 0x50, 0x36, 0x39, 0xc0, 0xae, 0x41, 0x71, 0x26, 0xb4,
- 0x4b, 0xfb, 0xd7, 0xf7, 0xab, 0xe8, 0xdb, 0x87, 0x42, 0xbb, 0x9c, 0x50, 0x4c, 0xaf, 0x99, 0x9c,
- 0xa3, 0xef, 0xf3, 0x69, 0x7a, 0x3d, 0x44, 0x84, 0x5b, 0x01, 0xfb, 0x19, 0x54, 0x02, 0xa1, 0x5f,
- 0x48, 0x75, 0x46, 0x3e, 0x5a, 0x37, 0x41, 0x3f, 0x12, 0xfa, 0xa1, 0x1c, 0x09, 0x1e, 0xcb, 0xd8,
- 0x6d, 0xa8, 0x46, 0xc2, 0x9b, 0x2b, 0x5f, 0x2f, 0xc8, 0x5f, 0xeb, 0xfb, 0x0d, 0xca, 0x32, 0x8b,
- 0x11, 0x39, 0x61, 0x38, 0x7f, 0xca, 0x41, 0x11, 0xcd, 0x60, 0x0c, 0x8a, 0xae, 0x9a, 0x98, 0xec,
- 0xae, 0x71, 0x1a, 0xb3, 0x06, 0x14, 0x44, 0xf0, 0x9c, 0x2c, 0xaa, 0x71, 0x1c, 0x22, 0xe2, 0xbd,
- 0x18, 0xd9, 0x18, 0xe1, 0x10, 0xd7, 0xcd, 0x23, 0xa1, 0x6c, 0x68, 0x68, 0xcc, 0x6e, 0x42, 0x2d,
- 0x54, 0xf2, 0x7c, 0xf1, 0x0c, 0x57, 0x97, 0x32, 0x89, 0x87, 0x60, 0x2f, 0x78, 0xce, 0xab, 0xa1,
- 0x1d, 0xb1, 0x5d, 0x00, 0x71, 0xae, 0x95, 0x7b, 0x28, 0x23, 0x1d, 0x35, 0xcb, 0x74, 0x76, 0xca,
- 0x77, 0x04, 0xfa, 0xc7, 0x3c, 0x23, 0x75, 0xfe, 0x9a, 0x87, 0x12, 0xb9, 0x84, 0xed, 0x60, 0x04,
- 0xc2, 0xb9, 0x09, 0x66, 0xa1, 0xcd, 0x6c, 0x04, 0x80, 0x62, 0x9d, 0x04, 0x00, 0xe3, 0xbe, 0x81,
- 0xde, 0x98, 0x0a, 0x4f, 0x4b, 0x65, 0xd3, 0x2d, 0x99, 0xa3, 0xe9, 0x23, 0xcc, 0x08, 0x73, 0x1a,
- 0x1a, 0xb3, 0x5b, 0x50, 0x96, 0x14, 0x46, 0x3a, 0xd0, 0x5b, 0x82, 0x6b, 0x29, 0xa8, 0x5c, 0x09,
- 0x77, 0x24, 0x83, 0xe9, 0x82, 0x8e, 0x59, 0xe5, 0xc9, 0x9c, 0xdd, 0x82, 0x1a, 0xc5, 0xed, 0xd1,
- 0x22, 0x14, 0xcd, 0x32, 0xc5, 0x61, 0x2d, 0x89, 0x29, 0x82, 0x3c, 0x95, 0xe3, 0x45, 0xf5, 0x5c,
- 0xef, 0x54, 0x0c, 0x42, 0xdd, 0xbc, 0x9a, 0xfa, 0xab, 0x63, 0x31, 0x9e, 0x48, 0x51, 0x6d, 0x24,
- 0x3c, 0x25, 0x34, 0x52, 0x3f, 0x26, 0xea, 0x9a, 0x0d, 0xaf, 0x01, 0x79, 0x2a, 0x67, 0x0e, 0x94,
- 0x87, 0xc3, 0x43, 0x64, 0x7e, 0x92, 0x16, 0x12, 0x83, 0x70, 0x2b, 0x71, 0xfa, 0x50, 0x8d, 0xb7,
- 0xc1, 0x5b, 0xd9, 0xef, 0xda, 0xfb, 0x9a, 0xef, 0x77, 0xd9, 0x1d, 0xa8, 0x44, 0xa7, 0xae, 0xf2,
- 0x83, 0x09, 0xf9, 0x6e, 0x7d, 0xff, 0xa3, 0xc4, 0xaa, 0xa1, 0xc1, 0x51, 0x53, 0xcc, 0x71, 0x24,
- 0xd4, 0x12, 0x33, 0xde, 0xd0, 0xd5, 0x80, 0xc2, 0xdc, 0x1f, 0x91, 0x9e, 0x35, 0x8e, 0x43, 0x44,
- 0x26, 0xbe, 0xc9, 0xa5, 0x35, 0x8e, 0x43, 0x0c, 0xc8, 0x4c, 0x8e, 0x4c, 0xd9, 0x5b, 0xe3, 0x34,
- 0x46, 0x1f, 0xcb, 0x50, 0xfb, 0x32, 0x70, 0xa7, 0xb1, 0x8f, 0xe3, 0xb9, 0x33, 0x8d, 0xcf, 0xf7,
- 0x3f, 0xd9, 0xed, 0x37, 0x39, 0xa8, 0xc6, 0xb5, 0x1a, 0x0b, 0x8f, 0x3f, 0x12, 0x81, 0xf6, 0xc7,
- 0xbe, 0x50, 0x76, 0xe3, 0x0c, 0xc2, 0xee, 0x40, 0xc9, 0xd5, 0x5a, 0xc5, 0xd7, 0xf9, 0xff, 0xb3,
- 0x85, 0xbe, 0x75, 0x80, 0x92, 0x5e, 0xa0, 0xd5, 0x82, 0x1b, 0xd6, 0xc6, 0x57, 0x00, 0x29, 0x88,
- 0xb6, 0x9e, 0x89, 0x85, 0xd5, 0x8a, 0x43, 0x76, 0x15, 0x4a, 0xcf, 0xdd, 0xe9, 0x5c, 0xd8, 0x1c,
- 0x36, 0x93, 0xaf, 0xf3, 0x5f, 0xe5, 0x9c, 0xbf, 0xe4, 0xa1, 0x62, 0x0b, 0x3f, 0xbb, 0x0d, 0x15,
- 0x2a, 0xfc, 0xd6, 0xa2, 0xcb, 0x2f, 0x46, 0x4c, 0x61, 0x7b, 0xc9, 0x17, 0x2d, 0x63, 0xa3, 0x55,
- 0x65, 0xbe, 0x6c, 0xd6, 0xc6, 0xf4, 0xfb, 0x56, 0x18, 0x89, 0xb1, 0xfd, 0x74, 0xad, 0x23, 0xbb,
- 0x2b, 0xc6, 0x7e, 0xe0, 0xa3, 0x7f, 0x38, 0x8a, 0xd8, 0xed, 0xf8, 0xd4, 0x45, 0xd2, 0xf8, 0x49,
- 0x56, 0xe3, 0x9b, 0x87, 0xee, 0x43, 0x3d, 0xb3, 0xcd, 0x25, 0xa7, 0xbe, 0x91, 0x3d, 0xb5, 0xdd,
- 0x92, 0xd4, 0x99, 0xef, 0x6e, 0xea, 0x85, 0xff, 0xc0, 0x7f, 0x5f, 0x02, 0xa4, 0x2a, 0xdf, 0xbf,
- 0xb0, 0x38, 0x2f, 0x0b, 0x00, 0x83, 0x10, 0x4b, 0xe7, 0xc8, 0xa5, 0xfa, 0xbd, 0xea, 0x4f, 0x02,
- 0xa9, 0xc4, 0x33, 0xba, 0xaa, 0xb4, 0xbe, 0xca, 0xeb, 0x06, 0xa3, 0x1b, 0xc3, 0x0e, 0xa0, 0x3e,
- 0x12, 0x91, 0xa7, 0x7c, 0x4a, 0x28, 0xeb, 0xf4, 0x2d, 0x3c, 0x53, 0xaa, 0xa7, 0xd5, 0x4d, 0x19,
- 0xc6, 0x57, 0xd9, 0x35, 0x6c, 0x1f, 0x56, 0xc5, 0x79, 0x28, 0x95, 0xb6, 0xbb, 0x98, 0xfe, 0xe0,
- 0x8a, 0xe9, 0x34, 0x10, 0xa7, 0x9d, 0x78, 0x5d, 0xa4, 0x13, 0xe6, 0x42, 0xd1, 0x73, 0x43, 0xf3,
- 0x71, 0xac, 0xef, 0x37, 0x2f, 0xec, 0xd7, 0x71, 0x43, 0xe3, 0xb4, 0xf6, 0x17, 0x78, 0xd6, 0x97,
- 0xff, 0xd8, 0xba, 0x95, 0xf9, 0x22, 0xce, 0xe4, 0xc9, 0x62, 0x8f, 0xf2, 0xe5, 0xcc, 0xd7, 0x7b,
- 0x73, 0xed, 0x4f, 0xf7, 0xdc, 0xd0, 0x47, 0x75, 0xb8, 0xb0, 0xdf, 0xe5, 0xa4, 0x7a, 0xe3, 0x17,
- 0xd0, 0xb8, 0x68, 0xf7, 0x87, 0xc4, 0x60, 0xe3, 0x2e, 0xd4, 0x12, 0x3b, 0xde, 0xb5, 0xb0, 0x9a,
- 0x0d, 0xde, 0x9f, 0x73, 0x50, 0x36, 0xb7, 0x8a, 0xdd, 0x85, 0xda, 0x54, 0x7a, 0x2e, 0x1a, 0x10,
- 0xb7, 0x68, 0x9f, 0xa6, 0x97, 0xae, 0xf5, 0x20, 0x96, 0x19, 0xaf, 0xa6, 0x5c, 0x4c, 0x32, 0x3f,
- 0x18, 0xcb, 0xf8, 0x16, 0xac, 0xa7, 0x8b, 0xfa, 0xc1, 0x58, 0x72, 0x23, 0xdc, 0xb8, 0x0f, 0xeb,
- 0xcb, 0x2a, 0x2e, 0xb1, 0xf3, 0xfa, 0x72, 0xba, 0x52, 0x5d, 0x4e, 0x16, 0x65, 0xcd, 0xbe, 0x0b,
- 0xb5, 0x04, 0x67, 0xbb, 0x6f, 0x1a, 0xbe, 0x9a, 0x5d, 0x99, 0xb1, 0xd5, 0x99, 0x02, 0xa4, 0xa6,
- 0x61, 0xb1, 0xc2, 0x5e, 0x30, 0x70, 0x67, 0x71, 0x93, 0x95, 0xcc, 0xe9, 0xdb, 0xe6, 0x6a, 0x97,
- 0x4c, 0x59, 0xe5, 0x34, 0x66, 0x2d, 0x80, 0x51, 0x72, 0x61, 0xdf, 0x72, 0x8d, 0x33, 0x0c, 0x67,
- 0x00, 0xd5, 0xd8, 0x08, 0xb6, 0x0d, 0xf5, 0xc8, 0xee, 0x8c, 0x9d, 0x0f, 0x6e, 0x57, 0xe2, 0x59,
- 0x08, 0x3b, 0x18, 0xe5, 0x06, 0x13, 0xb1, 0xd4, 0xc1, 0x70, 0x44, 0xb8, 0x15, 0x38, 0x4f, 0xa1,
- 0x44, 0x00, 0x5e, 0xb3, 0x48, 0xbb, 0x4a, 0xdb, 0x66, 0xc8, 0x34, 0x07, 0x32, 0xa2, 0x6d, 0xdb,
- 0x45, 0x4c, 0x44, 0x6e, 0x08, 0xec, 0x06, 0xb6, 0x20, 0x23, 0xeb, 0xd1, 0xcb, 0x78, 0x28, 0x76,
- 0x7e, 0x0e, 0xd5, 0x18, 0xc6, 0x93, 0x3f, 0xf0, 0x03, 0x61, 0x4d, 0xa4, 0x31, 0x36, 0x91, 0x9d,
- 0x53, 0x57, 0xb9, 0x9e, 0x16, 0xa6, 0x0d, 0x28, 0xf1, 0x14, 0x70, 0xae, 0x43, 0x3d, 0x73, 0x7b,
- 0x30, 0xdd, 0x9e, 0x50, 0x18, 0xcd, 0x1d, 0x36, 0x13, 0xe7, 0x25, 0xb6, 0xb8, 0x71, 0xd7, 0xf2,
- 0x53, 0x80, 0x53, 0xad, 0xc3, 0x67, 0xd4, 0xc6, 0x58, 0xdf, 0xd7, 0x10, 0x21, 0x06, 0xdb, 0x82,
- 0x3a, 0x4e, 0x22, 0x2b, 0x37, 0xf9, 0x4e, 0x2b, 0x22, 0x43, 0xf8, 0x09, 0xd4, 0xc6, 0xc9, 0xf2,
- 0x82, 0x0d, 0x5d, 0xbc, 0xfa, 0x53, 0xa8, 0x06, 0xd2, 0xca, 0x4c, 0x57, 0x55, 0x09, 0x24, 0x89,
- 0x9c, 0x5b, 0xf0, 0x7f, 0x6f, 0xf4, 0xe3, 0xec, 0x13, 0x28, 0x8f, 0xfd, 0xa9, 0xa6, 0xa2, 0x8f,
- 0x8d, 0x9a, 0x9d, 0x39, 0xff, 0xca, 0x01, 0xa4, 0x91, 0xc5, 0x7c, 0xc5, 0xea, 0x8d, 0x9c, 0x55,
- 0x53, 0xad, 0xa7, 0x50, 0x9d, 0xd9, 0x3a, 0x60, 0x63, 0x76, 0x6d, 0x39, 0x1b, 0x5a, 0x71, 0x99,
- 0x30, 0x15, 0x62, 0xdf, 0x56, 0x88, 0x0f, 0xe9, 0x99, 0x93, 0x1d, 0xa8, 0x19, 0xc9, 0xbe, 0x7d,
- 0x20, 0xbd, 0x68, 0xdc, 0x4a, 0x36, 0xee, 0xc3, 0xda, 0xd2, 0x96, 0xef, 0xf9, 0x4d, 0x48, 0xeb,
- 0x59, 0xf6, 0x96, 0xdd, 0x86, 0xb2, 0x69, 0x22, 0x31, 0x25, 0x70, 0x64, 0xd5, 0xd0, 0x98, 0x3a,
- 0x86, 0xe3, 0xf8, 0x05, 0xd2, 0x3f, 0x76, 0xf6, 0xa1, 0x6c, 0x9e, 0x58, 0x6c, 0x07, 0x2a, 0xae,
- 0x67, 0xae, 0x63, 0xa6, 0x24, 0xa0, 0xf0, 0x80, 0x60, 0x1e, 0x8b, 0x9d, 0xbf, 0xe5, 0x01, 0x52,
- 0xfc, 0x03, 0xba, 0xd2, 0xaf, 0x61, 0x3d, 0x12, 0x9e, 0x0c, 0x46, 0xae, 0x5a, 0x90, 0xd4, 0x3e,
- 0x25, 0x2e, 0x5b, 0x72, 0x81, 0x99, 0xe9, 0x50, 0x0b, 0xef, 0xee, 0x50, 0x77, 0xa0, 0xe8, 0xc9,
- 0x70, 0x61, 0x3f, 0x14, 0x6c, 0xf9, 0x20, 0x1d, 0x19, 0x2e, 0xf0, 0x41, 0x89, 0x0c, 0xd6, 0x82,
- 0xf2, 0xec, 0x8c, 0x1e, 0x9d, 0xa6, 0x61, 0xbf, 0xba, 0xcc, 0x7d, 0x78, 0x86, 0x63, 0x7c, 0xa2,
- 0x1a, 0x16, 0xbb, 0x05, 0xa5, 0xd9, 0xd9, 0xc8, 0x57, 0xd4, 0xdb, 0xd6, 0x4d, 0x67, 0x98, 0xa5,
- 0x77, 0x7d, 0x85, 0x0f, 0x51, 0xe2, 0x30, 0x07, 0xf2, 0x6a, 0xd6, 0xac, 0x10, 0xb3, 0x71, 0xc1,
- 0x9b, 0xb3, 0xc3, 0x15, 0x9e, 0x57, 0xb3, 0x76, 0x15, 0xca, 0xc6, 0xaf, 0xce, 0x1f, 0x0b, 0xb0,
- 0xbe, 0x6c, 0x25, 0xe6, 0x41, 0xa4, 0xbc, 0x38, 0x0f, 0x22, 0xe5, 0x25, 0xcd, 0x7b, 0x3e, 0xd3,
- 0xbc, 0x3b, 0x50, 0x92, 0x2f, 0x02, 0xa1, 0xb2, 0xaf, 0xeb, 0xce, 0xa9, 0x7c, 0x11, 0x60, 0x9b,
- 0x6a, 0x44, 0x4b, 0x5d, 0x5f, 0xc9, 0x76, 0x7d, 0x37, 0x60, 0x6d, 0x2c, 0xa7, 0x53, 0xf9, 0x62,
- 0xb8, 0x98, 0x4d, 0xfd, 0xe0, 0xcc, 0xb6, 0x7e, 0xcb, 0x20, 0xdb, 0x81, 0x2b, 0x23, 0x5f, 0xa1,
- 0x39, 0x1d, 0x19, 0x68, 0x11, 0xd0, 0x7b, 0x05, 0x79, 0x17, 0x61, 0xf6, 0x0d, 0x6c, 0xbb, 0x5a,
- 0x8b, 0x59, 0xa8, 0x1f, 0x07, 0xa1, 0xeb, 0x9d, 0x75, 0xa5, 0x47, 0x77, 0x76, 0x16, 0xba, 0xda,
- 0x3f, 0xf1, 0xa7, 0xf8, 0x34, 0xab, 0xd0, 0xd2, 0x77, 0xf2, 0xd8, 0xe7, 0xb0, 0xee, 0x29, 0xe1,
- 0x6a, 0xd1, 0x15, 0x91, 0x3e, 0x76, 0xf5, 0x69, 0xb3, 0x4a, 0x2b, 0x2f, 0xa0, 0x78, 0x06, 0x17,
- 0xad, 0x7d, 0xea, 0x4f, 0x47, 0x9e, 0xab, 0x46, 0xcd, 0x9a, 0x39, 0xc3, 0x12, 0xc8, 0x5a, 0xc0,
- 0x08, 0xe8, 0xcd, 0x42, 0xbd, 0x48, 0xa8, 0x40, 0xd4, 0x4b, 0x24, 0x58, 0x38, 0xb5, 0x3f, 0x13,
- 0x91, 0x76, 0x67, 0x21, 0xfd, 0x2b, 0x50, 0xe0, 0x29, 0xe0, 0x7c, 0x9b, 0x83, 0xc6, 0xc5, 0x14,
- 0x41, 0x07, 0x87, 0x68, 0xa6, 0xbd, 0x6c, 0x38, 0x4e, 0x9c, 0x9e, 0xcf, 0x38, 0x3d, 0xfe, 0x42,
- 0x15, 0x32, 0x5f, 0xa8, 0x24, 0x80, 0xc5, 0xb7, 0x07, 0x70, 0xc9, 0xa4, 0xd2, 0x45, 0x93, 0x7e,
- 0x97, 0x83, 0x2b, 0x17, 0xd2, 0xf0, 0xbd, 0x2d, 0xda, 0x86, 0xfa, 0xcc, 0x3d, 0x13, 0xc7, 0xae,
- 0xa2, 0xe0, 0x16, 0x4c, 0x0b, 0x97, 0x81, 0xfe, 0x0b, 0xf6, 0x05, 0xb0, 0x9a, 0xcd, 0xfd, 0x4b,
- 0x6d, 0x8b, 0x43, 0x79, 0x24, 0xf5, 0x3d, 0x39, 0xb7, 0x5f, 0xbf, 0x38, 0x94, 0x31, 0xf8, 0x66,
- 0xc0, 0x0b, 0x97, 0x04, 0xdc, 0x39, 0x82, 0x6a, 0x6c, 0x20, 0xdb, 0xb2, 0x4f, 0xf5, 0x5c, 0xfa,
- 0x97, 0xd1, 0xe3, 0x48, 0x28, 0xb4, 0xdd, 0xbc, 0xdb, 0x3f, 0x83, 0xd2, 0x44, 0xc9, 0x79, 0x68,
- 0x6b, 0xeb, 0x12, 0xc3, 0x48, 0x9c, 0x21, 0x54, 0x2c, 0xc2, 0x76, 0xa1, 0x7c, 0xb2, 0x38, 0x8a,
- 0x9b, 0x0f, 0x7b, 0xb1, 0x71, 0x3e, 0xb2, 0x0c, 0xac, 0x16, 0x86, 0xc1, 0xae, 0x42, 0xf1, 0x64,
- 0xd1, 0xef, 0x9a, 0x07, 0x19, 0xd6, 0x1c, 0x9c, 0xb5, 0xcb, 0xc6, 0x20, 0xe7, 0x01, 0xac, 0x66,
- 0xd7, 0xa1, 0x53, 0x32, 0x4d, 0x0d, 0x8d, 0xd3, 0xe2, 0x9a, 0x7f, 0x47, 0x71, 0xdd, 0xdd, 0x81,
- 0x8a, 0xfd, 0x53, 0x84, 0xd5, 0xa0, 0xf4, 0xf8, 0x68, 0xd8, 0x7b, 0xd4, 0x58, 0x61, 0x55, 0x28,
- 0x1e, 0x0e, 0x86, 0x8f, 0x1a, 0x39, 0x1c, 0x1d, 0x0d, 0x8e, 0x7a, 0x8d, 0xfc, 0xee, 0x4d, 0x58,
- 0xcd, 0xfe, 0x2d, 0xc2, 0xea, 0x50, 0x19, 0x1e, 0x1c, 0x75, 0xdb, 0x83, 0x5f, 0x35, 0x56, 0xd8,
- 0x2a, 0x54, 0xfb, 0x47, 0xc3, 0x5e, 0xe7, 0x31, 0xef, 0x35, 0x72, 0xbb, 0xbf, 0x84, 0x5a, 0xf2,
- 0x72, 0x47, 0x0d, 0xed, 0xfe, 0x51, 0xb7, 0xb1, 0xc2, 0x00, 0xca, 0xc3, 0x5e, 0x87, 0xf7, 0x50,
- 0x6f, 0x05, 0x0a, 0xc3, 0xe1, 0x61, 0x23, 0x8f, 0xbb, 0x76, 0x0e, 0x3a, 0x87, 0xbd, 0x46, 0x01,
- 0x87, 0x8f, 0x1e, 0x1e, 0xdf, 0x1b, 0x36, 0x8a, 0xbb, 0x5f, 0xc2, 0x95, 0x0b, 0x2f, 0x67, 0x5a,
- 0x7d, 0x78, 0xc0, 0x7b, 0xa8, 0xa9, 0x0e, 0x95, 0x63, 0xde, 0x7f, 0x72, 0xf0, 0xa8, 0xd7, 0xc8,
- 0xa1, 0xe0, 0xc1, 0xa0, 0x73, 0xbf, 0xd7, 0x6d, 0xe4, 0xdb, 0xd7, 0xbe, 0x7b, 0xb5, 0x99, 0xfb,
- 0xfe, 0xd5, 0x66, 0xee, 0x87, 0x57, 0x9b, 0xb9, 0x7f, 0xbe, 0xda, 0xcc, 0x7d, 0xfb, 0x7a, 0x73,
- 0xe5, 0xfb, 0xd7, 0x9b, 0x2b, 0x3f, 0xbc, 0xde, 0x5c, 0x39, 0x29, 0xd3, 0x9f, 0x94, 0x5f, 0xfc,
- 0x3b, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x60, 0x46, 0x7d, 0xe4, 0x14, 0x00, 0x00,
+ // 2217 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xcd, 0x6f, 0x1b, 0xc7,
+ 0x15, 0x17, 0xbf, 0xc9, 0x47, 0x49, 0x66, 0x27, 0x4e, 0xc2, 0xa8, 0xae, 0xa4, 0x6c, 0xdc, 0x40,
+ 0x96, 0x6d, 0x0a, 0x50, 0x80, 0x38, 0x08, 0x8a, 0xa2, 0xe2, 0x87, 0x21, 0xc6, 0xb6, 0x28, 0x0c,
+ 0xfd, 0xd1, 0x9b, 0xb1, 0x5a, 0x0e, 0xa9, 0x85, 0xc8, 0x9d, 0xc5, 0xec, 0xd0, 0x16, 0x2f, 0x3d,
+ 0xf8, 0x2f, 0x08, 0x50, 0xa0, 0xb7, 0x16, 0xe8, 0xa5, 0x7f, 0x41, 0xaf, 0x3d, 0x16, 0xc8, 0x31,
+ 0x87, 0x1e, 0x82, 0x1e, 0xd2, 0xc2, 0xbe, 0xf7, 0x3f, 0x28, 0x50, 0xbc, 0x37, 0xb3, 0x1f, 0x94,
+ 0x65, 0xd8, 0x46, 0x8b, 0x9e, 0x76, 0xe6, 0xbd, 0xdf, 0xbc, 0x79, 0xf3, 0xbe, 0xe6, 0xcd, 0x42,
+ 0x4d, 0x86, 0x51, 0x2b, 0x54, 0x52, 0x4b, 0x96, 0x0f, 0x4f, 0x36, 0x6e, 0x4f, 0x7c, 0x7d, 0x3a,
+ 0x3f, 0x69, 0x79, 0x72, 0xb6, 0x37, 0x91, 0x13, 0xb9, 0x47, 0xac, 0x93, 0xf9, 0x98, 0x66, 0x34,
+ 0xa1, 0x91, 0x59, 0xe2, 0xfc, 0x31, 0x0f, 0xf9, 0x41, 0xc8, 0x3e, 0x85, 0xb2, 0x1f, 0x84, 0x73,
+ 0x1d, 0x35, 0x73, 0xdb, 0x85, 0x9d, 0xfa, 0x7e, 0xad, 0x15, 0x9e, 0xb4, 0xfa, 0x48, 0xe1, 0x96,
+ 0xc1, 0xb6, 0xa1, 0x28, 0xce, 0x85, 0xd7, 0xcc, 0x6f, 0xe7, 0x76, 0xea, 0xfb, 0x80, 0x80, 0xde,
+ 0xb9, 0xf0, 0x06, 0xe1, 0xe1, 0x0a, 0x27, 0x0e, 0xfb, 0x1c, 0xca, 0x91, 0x9c, 0x2b, 0x4f, 0x34,
+ 0x0b, 0x84, 0x59, 0x45, 0xcc, 0x90, 0x28, 0x84, 0xb2, 0x5c, 0x94, 0x34, 0xf6, 0xa7, 0xa2, 0x59,
+ 0x4c, 0x25, 0xdd, 0xf5, 0xa7, 0x06, 0x43, 0x1c, 0xf6, 0x19, 0x94, 0x4e, 0xe6, 0xfe, 0x74, 0xd4,
+ 0x2c, 0x11, 0xa4, 0x8e, 0x90, 0x36, 0x12, 0x08, 0x63, 0x78, 0x6c, 0x07, 0xaa, 0xe1, 0xd4, 0xd5,
+ 0x63, 0xa9, 0x66, 0x4d, 0x48, 0x37, 0x3c, 0xb6, 0x34, 0x9e, 0x70, 0xd9, 0x1d, 0xa8, 0x7b, 0x32,
+ 0x88, 0xb4, 0x72, 0xfd, 0x40, 0x47, 0xcd, 0x3a, 0x81, 0x3f, 0x44, 0xf0, 0x13, 0xa9, 0xce, 0x84,
+ 0xea, 0xa4, 0x4c, 0x9e, 0x45, 0xb6, 0x8b, 0x90, 0x97, 0xa1, 0xf3, 0xbb, 0x1c, 0x54, 0x63, 0xa9,
+ 0xcc, 0x81, 0xd5, 0x03, 0xe5, 0x9d, 0xfa, 0x5a, 0x78, 0x7a, 0xae, 0x44, 0x33, 0xb7, 0x9d, 0xdb,
+ 0xa9, 0xf1, 0x25, 0x1a, 0x5b, 0x87, 0xfc, 0x60, 0x48, 0x86, 0xaa, 0xf1, 0xfc, 0x60, 0xc8, 0x9a,
+ 0x50, 0x79, 0xec, 0x2a, 0xdf, 0x0d, 0x34, 0x59, 0xa6, 0xc6, 0xe3, 0x29, 0xbb, 0x06, 0xb5, 0xc1,
+ 0xf0, 0xb1, 0x50, 0x91, 0x2f, 0x03, 0xb2, 0x47, 0x8d, 0xa7, 0x04, 0xb6, 0x09, 0x30, 0x18, 0xde,
+ 0x15, 0x2e, 0x0a, 0x8d, 0x9a, 0xa5, 0xed, 0xc2, 0x4e, 0x8d, 0x67, 0x28, 0xce, 0x6f, 0xa0, 0x44,
+ 0x3e, 0x62, 0xdf, 0x40, 0x79, 0xe4, 0x4f, 0x44, 0xa4, 0x8d, 0x3a, 0xed, 0xfd, 0xef, 0x7e, 0xdc,
+ 0x5a, 0xf9, 0xfb, 0x8f, 0x5b, 0xbb, 0x99, 0x60, 0x90, 0xa1, 0x08, 0x3c, 0x19, 0x68, 0xd7, 0x0f,
+ 0x84, 0x8a, 0xf6, 0x26, 0xf2, 0xb6, 0x59, 0xd2, 0xea, 0xd2, 0x87, 0x5b, 0x09, 0xec, 0x06, 0x94,
+ 0xfc, 0x60, 0x24, 0xce, 0x49, 0xff, 0x42, 0xfb, 0x03, 0x2b, 0xaa, 0x3e, 0x98, 0xeb, 0x70, 0xae,
+ 0xfb, 0xc8, 0xe2, 0x06, 0xe1, 0xfc, 0x21, 0x07, 0x65, 0x13, 0x03, 0xec, 0x1a, 0x14, 0x67, 0x42,
+ 0xbb, 0xb4, 0x7f, 0x7d, 0xbf, 0x8a, 0xb6, 0x7d, 0x20, 0xb4, 0xcb, 0x89, 0x8a, 0xe1, 0x35, 0x93,
+ 0x73, 0xb4, 0x7d, 0x3e, 0x0d, 0xaf, 0x07, 0x48, 0xe1, 0x96, 0xc1, 0x7e, 0x0e, 0x95, 0x40, 0xe8,
+ 0xe7, 0x52, 0x9d, 0x91, 0x8d, 0xd6, 0x8d, 0xd3, 0x8f, 0x84, 0x7e, 0x20, 0x47, 0x82, 0xc7, 0x3c,
+ 0x76, 0x0b, 0xaa, 0x91, 0xf0, 0xe6, 0xca, 0xd7, 0x0b, 0xb2, 0xd7, 0xfa, 0x7e, 0x83, 0xa2, 0xcc,
+ 0xd2, 0x08, 0x9c, 0x20, 0x9c, 0xbf, 0xe6, 0xa0, 0x88, 0x6a, 0x30, 0x06, 0x45, 0x57, 0x4d, 0x4c,
+ 0x74, 0xd7, 0x38, 0x8d, 0x59, 0x03, 0x0a, 0x22, 0x78, 0x46, 0x1a, 0xd5, 0x38, 0x0e, 0x91, 0xe2,
+ 0x3d, 0x1f, 0x59, 0x1f, 0xe1, 0x10, 0xd7, 0xcd, 0x23, 0xa1, 0xac, 0x6b, 0x68, 0xcc, 0x6e, 0x40,
+ 0x2d, 0x54, 0xf2, 0x7c, 0xf1, 0x14, 0x57, 0x97, 0x32, 0x81, 0x87, 0xc4, 0x5e, 0xf0, 0x8c, 0x57,
+ 0x43, 0x3b, 0x62, 0xbb, 0x00, 0xe2, 0x5c, 0x2b, 0xf7, 0x50, 0x46, 0x3a, 0x6a, 0x96, 0xe9, 0xec,
+ 0x14, 0xef, 0x48, 0xe8, 0x1f, 0xf3, 0x0c, 0x97, 0x6d, 0x40, 0xf5, 0x54, 0x46, 0x3a, 0x70, 0x67,
+ 0xa2, 0x59, 0xa1, 0xed, 0x92, 0xb9, 0xf3, 0xaf, 0x3c, 0x94, 0xc8, 0x5c, 0x6c, 0x07, 0xbd, 0x13,
+ 0xce, 0x8d, 0xa3, 0x0b, 0x6d, 0x66, 0xbd, 0x03, 0x14, 0x07, 0x89, 0x73, 0x30, 0x26, 0x36, 0xd0,
+ 0x52, 0x53, 0xe1, 0x69, 0xa9, 0x6c, 0x28, 0x26, 0x73, 0x3c, 0xd6, 0x08, 0xa3, 0xc5, 0x9c, 0x94,
+ 0xc6, 0xec, 0x26, 0x94, 0x25, 0xb9, 0x98, 0x0e, 0xfb, 0x06, 0xc7, 0x5b, 0x08, 0x0a, 0x57, 0xc2,
+ 0x1d, 0xc9, 0x60, 0xba, 0x20, 0x13, 0x54, 0x79, 0x32, 0x67, 0x37, 0xa1, 0x46, 0x3e, 0x7d, 0xb8,
+ 0x08, 0x45, 0xb3, 0x4c, 0x3e, 0x5a, 0x4b, 0xfc, 0x8d, 0x44, 0x9e, 0xf2, 0x31, 0x89, 0x3d, 0xd7,
+ 0x3b, 0x15, 0x83, 0x50, 0x37, 0xaf, 0xa6, 0xb6, 0xec, 0x58, 0x1a, 0x4f, 0xb8, 0x28, 0x36, 0x12,
+ 0x9e, 0x12, 0x1a, 0xa1, 0x1f, 0x12, 0x74, 0xcd, 0xba, 0xde, 0x10, 0x79, 0xca, 0x67, 0x0e, 0x94,
+ 0x87, 0xc3, 0x43, 0x44, 0x7e, 0x94, 0x16, 0x19, 0x43, 0xe1, 0x96, 0x63, 0xce, 0x10, 0xcd, 0xa7,
+ 0xba, 0xdf, 0x6d, 0x7e, 0x6c, 0x0c, 0x14, 0xcf, 0x9d, 0x3e, 0x54, 0x63, 0x15, 0x30, 0x9b, 0xfb,
+ 0x5d, 0x9b, 0xe7, 0xf9, 0x7e, 0x97, 0xdd, 0x86, 0x4a, 0x74, 0xea, 0x2a, 0x3f, 0x98, 0x90, 0x5d,
+ 0xd7, 0xf7, 0x3f, 0x48, 0x34, 0x1e, 0x1a, 0x3a, 0xee, 0x12, 0x63, 0x1c, 0x09, 0xb5, 0x44, 0xc5,
+ 0xd7, 0x64, 0x35, 0xa0, 0x30, 0xf7, 0x47, 0x24, 0x67, 0x8d, 0xe3, 0x10, 0x29, 0x13, 0xdf, 0xc4,
+ 0xe0, 0x1a, 0xc7, 0x21, 0x3a, 0x6b, 0x26, 0x47, 0xa6, 0x5c, 0xae, 0x71, 0x1a, 0xa3, 0xee, 0x32,
+ 0xd4, 0xbe, 0x0c, 0xdc, 0x69, 0x6c, 0xff, 0x78, 0xee, 0x4c, 0xe3, 0xb3, 0xff, 0x5f, 0x76, 0xfb,
+ 0x6d, 0x0e, 0xaa, 0x71, 0x8d, 0xc7, 0x82, 0xe5, 0x8f, 0x44, 0xa0, 0xfd, 0xb1, 0x2f, 0x94, 0xdd,
+ 0x38, 0x43, 0x61, 0xb7, 0xa1, 0xe4, 0x6a, 0xad, 0xe2, 0x32, 0xf0, 0x71, 0xf6, 0x82, 0x68, 0x1d,
+ 0x20, 0xa7, 0x17, 0x68, 0xb5, 0xe0, 0x06, 0xb5, 0xf1, 0x15, 0x40, 0x4a, 0x44, 0x5d, 0xcf, 0xc4,
+ 0xc2, 0x4a, 0xc5, 0x21, 0xbb, 0x0a, 0xa5, 0x67, 0xee, 0x74, 0x2e, 0x6c, 0x7c, 0x9b, 0xc9, 0xd7,
+ 0xf9, 0xaf, 0x72, 0xce, 0x5f, 0xf2, 0x50, 0xb1, 0x17, 0x06, 0xbb, 0x05, 0x15, 0xba, 0x30, 0xac,
+ 0x46, 0x97, 0x27, 0x4d, 0x0c, 0x61, 0x7b, 0xc9, 0x4d, 0x98, 0xd1, 0xd1, 0x8a, 0x32, 0x37, 0xa2,
+ 0xd5, 0x31, 0xbd, 0x17, 0x0b, 0x23, 0x31, 0xb6, 0x57, 0xde, 0x3a, 0xa2, 0xbb, 0x62, 0xec, 0x07,
+ 0x3e, 0xda, 0x87, 0x23, 0x8b, 0xdd, 0x8a, 0x4f, 0x5d, 0x24, 0x89, 0x1f, 0x65, 0x25, 0xbe, 0x7e,
+ 0xe8, 0x3e, 0xd4, 0x33, 0xdb, 0x5c, 0x72, 0xea, 0xeb, 0xd9, 0x53, 0xdb, 0x2d, 0x49, 0x9c, 0xb9,
+ 0xaf, 0x53, 0x2b, 0xfc, 0x17, 0xf6, 0xfb, 0x12, 0x20, 0x15, 0xf9, 0xee, 0x45, 0xc7, 0x79, 0x51,
+ 0x00, 0x18, 0x84, 0x58, 0x72, 0x47, 0x2e, 0xd5, 0xfd, 0x55, 0x7f, 0x12, 0x48, 0x25, 0x9e, 0x52,
+ 0x1a, 0xd3, 0xfa, 0x2a, 0xaf, 0x1b, 0x1a, 0x65, 0x0c, 0x3b, 0x80, 0xfa, 0x48, 0x44, 0x9e, 0xf2,
+ 0x29, 0xa0, 0xac, 0xd1, 0xb7, 0xf0, 0x4c, 0xa9, 0x9c, 0x56, 0x37, 0x45, 0x18, 0x5b, 0x65, 0xd7,
+ 0xb0, 0x7d, 0x58, 0x15, 0xe7, 0xa1, 0x54, 0xda, 0xee, 0x62, 0xfa, 0x8a, 0x2b, 0xa6, 0x43, 0x41,
+ 0x3a, 0xed, 0xc4, 0xeb, 0x22, 0x9d, 0x30, 0x17, 0x8a, 0x9e, 0x1b, 0x9a, 0x4b, 0xb5, 0xbe, 0xdf,
+ 0xbc, 0xb0, 0x5f, 0xc7, 0x0d, 0x8d, 0xd1, 0xda, 0x5f, 0xe0, 0x59, 0x5f, 0xfc, 0x63, 0xeb, 0x66,
+ 0xe6, 0x26, 0x9d, 0xc9, 0x93, 0xc5, 0x1e, 0xc5, 0xcb, 0x99, 0xaf, 0xf7, 0xe6, 0xda, 0x9f, 0xee,
+ 0xb9, 0xa1, 0x8f, 0xe2, 0x70, 0x61, 0xbf, 0xcb, 0x49, 0xf4, 0xc6, 0x2f, 0xa1, 0x71, 0x51, 0xef,
+ 0xf7, 0xf1, 0xc1, 0xc6, 0x1d, 0xa8, 0x25, 0x7a, 0xbc, 0x6d, 0x61, 0x35, 0xeb, 0xbc, 0x3f, 0xe7,
+ 0xa0, 0x6c, 0xb2, 0x8a, 0xdd, 0x81, 0xda, 0x54, 0x7a, 0x2e, 0x2a, 0x10, 0xb7, 0x76, 0x9f, 0xa4,
+ 0x49, 0xd7, 0xba, 0x1f, 0xf3, 0x8c, 0x55, 0x53, 0x2c, 0x06, 0x99, 0x1f, 0x8c, 0x65, 0x9c, 0x05,
+ 0xeb, 0xe9, 0xa2, 0x7e, 0x30, 0x96, 0xdc, 0x30, 0x37, 0xee, 0xc1, 0xfa, 0xb2, 0x88, 0x4b, 0xf4,
+ 0xfc, 0x6c, 0x39, 0x5c, 0xa9, 0x66, 0x27, 0x8b, 0xb2, 0x6a, 0xdf, 0x81, 0x5a, 0x42, 0x67, 0xbb,
+ 0xaf, 0x2b, 0xbe, 0x9a, 0x5d, 0x99, 0xd1, 0xd5, 0x99, 0x02, 0xa4, 0xaa, 0x61, 0xb1, 0xc2, 0x1e,
+ 0x92, 0xee, 0x51, 0xa3, 0x46, 0x32, 0xa7, 0x7b, 0xcf, 0xd5, 0x2e, 0xa9, 0xb2, 0xca, 0x69, 0xcc,
+ 0x5a, 0x00, 0xa3, 0x24, 0x61, 0xdf, 0x90, 0xc6, 0x19, 0x84, 0x33, 0x80, 0x6a, 0xac, 0x04, 0xdb,
+ 0x86, 0x7a, 0x64, 0x77, 0xc6, 0x8e, 0x09, 0xb7, 0x2b, 0xf1, 0x2c, 0x09, 0x3b, 0x1f, 0xe5, 0x06,
+ 0x13, 0xb1, 0xd4, 0xf9, 0x70, 0xa4, 0x70, 0xcb, 0x70, 0x9e, 0x40, 0x89, 0x08, 0x98, 0x66, 0x91,
+ 0x76, 0x95, 0xb6, 0x4d, 0x94, 0x69, 0x2a, 0x64, 0x44, 0xdb, 0xb6, 0x8b, 0x18, 0x88, 0xdc, 0x00,
+ 0xd8, 0x75, 0x6c, 0x5d, 0x46, 0xd6, 0xa2, 0x97, 0xe1, 0x90, 0xed, 0xfc, 0x02, 0xaa, 0x31, 0x19,
+ 0x4f, 0x7e, 0xdf, 0x0f, 0x84, 0x55, 0x91, 0xc6, 0xd8, 0x7c, 0x76, 0x4e, 0x5d, 0xe5, 0x7a, 0x5a,
+ 0x98, 0x16, 0xa1, 0xc4, 0x53, 0x82, 0xf3, 0x19, 0xd4, 0x33, 0xd9, 0x83, 0xe1, 0xf6, 0x98, 0xdc,
+ 0x68, 0x72, 0xd8, 0x4c, 0x9c, 0x17, 0xd8, 0x1a, 0xc7, 0xdd, 0xce, 0xcf, 0x00, 0x4e, 0xb5, 0x0e,
+ 0x9f, 0x52, 0xfb, 0x63, 0x6d, 0x5f, 0x43, 0x0a, 0x21, 0xd8, 0x16, 0xd4, 0x71, 0x12, 0x59, 0xbe,
+ 0x89, 0x77, 0x5a, 0x11, 0x19, 0xc0, 0x4f, 0xa1, 0x36, 0x4e, 0x96, 0x17, 0xac, 0xeb, 0xe2, 0xd5,
+ 0x9f, 0x40, 0x35, 0x90, 0x96, 0x67, 0xba, 0xb1, 0x4a, 0x20, 0x89, 0xe5, 0xdc, 0x84, 0x9f, 0xbc,
+ 0xd6, 0xc7, 0xb3, 0x8f, 0xa0, 0x3c, 0xf6, 0xa7, 0x9a, 0x8a, 0x3e, 0x36, 0x78, 0x76, 0xe6, 0xfc,
+ 0x3b, 0x07, 0x90, 0x7a, 0x16, 0xe3, 0x15, 0xab, 0x37, 0x62, 0x56, 0x4d, 0xb5, 0x9e, 0x42, 0x75,
+ 0x66, 0xeb, 0x80, 0xf5, 0xd9, 0xb5, 0xe5, 0x68, 0x68, 0xc5, 0x65, 0xc2, 0x54, 0x88, 0x7d, 0x5b,
+ 0x21, 0xde, 0xa7, 0xd7, 0x4e, 0x76, 0xa0, 0x46, 0x25, 0xfb, 0x66, 0x82, 0x34, 0xd1, 0xb8, 0xe5,
+ 0x6c, 0xdc, 0x83, 0xb5, 0xa5, 0x2d, 0xdf, 0xf1, 0x4e, 0x48, 0xeb, 0x59, 0x36, 0xcb, 0x6e, 0x41,
+ 0xd9, 0x34, 0x9f, 0x18, 0x12, 0x38, 0xb2, 0x62, 0x68, 0x4c, 0x1d, 0xc3, 0x71, 0xfc, 0x72, 0xe9,
+ 0x1f, 0x3b, 0xfb, 0x50, 0x36, 0x4f, 0x33, 0xb6, 0x03, 0x15, 0xd7, 0x33, 0xe9, 0x98, 0x29, 0x09,
+ 0xc8, 0x3c, 0x20, 0x32, 0x8f, 0xd9, 0xce, 0xdf, 0xf2, 0x00, 0x29, 0xfd, 0x3d, 0x3a, 0xd6, 0xaf,
+ 0x61, 0x3d, 0x12, 0x9e, 0x0c, 0x46, 0xae, 0x5a, 0x10, 0xd7, 0x3e, 0x41, 0x2e, 0x5b, 0x72, 0x01,
+ 0x99, 0xe9, 0x5e, 0x0b, 0x6f, 0xef, 0x5e, 0x77, 0xa0, 0xe8, 0xc9, 0x70, 0x61, 0x2f, 0x0a, 0xb6,
+ 0x7c, 0x90, 0x8e, 0x0c, 0x17, 0xf8, 0x10, 0x45, 0x04, 0x6b, 0x41, 0x79, 0x76, 0x46, 0x8f, 0x55,
+ 0xd3, 0xe8, 0x5f, 0x5d, 0xc6, 0x3e, 0x38, 0xc3, 0x31, 0x3e, 0x6d, 0x0d, 0x8a, 0xdd, 0x84, 0xd2,
+ 0xec, 0x6c, 0xe4, 0x2b, 0xea, 0x7b, 0xeb, 0xa6, 0x33, 0xcc, 0xc2, 0xbb, 0xbe, 0xc2, 0x07, 0x2c,
+ 0x61, 0x98, 0x03, 0x79, 0x35, 0xa3, 0x5e, 0xbf, 0x6e, 0x5e, 0x31, 0x19, 0x6b, 0xce, 0x0e, 0x57,
+ 0x78, 0x5e, 0xcd, 0xda, 0x55, 0x28, 0x1b, 0xbb, 0x3a, 0x7f, 0x2a, 0xc0, 0xfa, 0xb2, 0x96, 0x18,
+ 0x07, 0x91, 0xf2, 0xe2, 0x38, 0x88, 0x94, 0x97, 0x34, 0xf6, 0xf9, 0x4c, 0x63, 0xef, 0x40, 0x49,
+ 0x3e, 0x0f, 0x84, 0xca, 0xbe, 0xca, 0x3b, 0xa7, 0xf2, 0x79, 0x80, 0x6d, 0xaa, 0x61, 0x2d, 0x75,
+ 0x7d, 0x25, 0xdb, 0xf5, 0x5d, 0x87, 0xb5, 0xb1, 0x9c, 0x4e, 0xe5, 0xf3, 0xe1, 0x62, 0x36, 0xf5,
+ 0x83, 0x33, 0xdb, 0xfa, 0x2d, 0x13, 0xd9, 0x0e, 0x5c, 0x19, 0xf9, 0x0a, 0xd5, 0xe9, 0xc8, 0x40,
+ 0x8b, 0x80, 0xde, 0x39, 0x88, 0xbb, 0x48, 0x66, 0xdf, 0xc0, 0xb6, 0xab, 0xb5, 0x98, 0x85, 0xfa,
+ 0x51, 0x10, 0xba, 0xde, 0x59, 0x57, 0x7a, 0x94, 0xb3, 0xb3, 0xd0, 0xd5, 0xfe, 0x89, 0x3f, 0xc5,
+ 0x27, 0x5d, 0x85, 0x96, 0xbe, 0x15, 0xc7, 0x3e, 0x87, 0x75, 0x4f, 0x09, 0x57, 0x8b, 0xae, 0x88,
+ 0xf4, 0xb1, 0xab, 0x4f, 0x9b, 0x55, 0x5a, 0x79, 0x81, 0x8a, 0x67, 0x70, 0x51, 0xdb, 0x27, 0xfe,
+ 0x74, 0xe4, 0xb9, 0x6a, 0xd4, 0xac, 0x99, 0x33, 0x2c, 0x11, 0x59, 0x0b, 0x18, 0x11, 0x7a, 0xb3,
+ 0x50, 0x2f, 0x12, 0x28, 0x10, 0xf4, 0x12, 0x0e, 0x16, 0x4e, 0xed, 0xcf, 0x44, 0xa4, 0xdd, 0x59,
+ 0x48, 0x7f, 0x13, 0x0a, 0x3c, 0x25, 0x38, 0xdf, 0xe6, 0xa0, 0x71, 0x31, 0x44, 0xd0, 0xc0, 0x21,
+ 0xaa, 0x69, 0x93, 0x0d, 0xc7, 0x89, 0xd1, 0xf3, 0x19, 0xa3, 0xc7, 0x37, 0x54, 0x21, 0x73, 0x43,
+ 0x25, 0x0e, 0x2c, 0xbe, 0xd9, 0x81, 0x4b, 0x2a, 0x95, 0x2e, 0xaa, 0xf4, 0xfb, 0x1c, 0x5c, 0xb9,
+ 0x10, 0x86, 0xef, 0xac, 0xd1, 0x36, 0xd4, 0x67, 0xee, 0x99, 0x38, 0x76, 0x15, 0x39, 0xb7, 0x60,
+ 0x5a, 0xb8, 0x0c, 0xe9, 0x7f, 0xa0, 0x5f, 0x00, 0xab, 0xd9, 0xd8, 0xbf, 0x54, 0xb7, 0xd8, 0x95,
+ 0x47, 0x52, 0xdf, 0x95, 0x73, 0x7b, 0xfb, 0xc5, 0xae, 0x8c, 0x89, 0xaf, 0x3b, 0xbc, 0x70, 0x89,
+ 0xc3, 0x9d, 0x23, 0xa8, 0xc6, 0x0a, 0xb2, 0x2d, 0xfb, 0xc4, 0xcf, 0xa5, 0xbf, 0x9a, 0x1e, 0x45,
+ 0x42, 0xa1, 0xee, 0xe6, 0xbd, 0xff, 0x29, 0x94, 0x26, 0x4a, 0xce, 0x43, 0x5b, 0x5b, 0x97, 0x10,
+ 0x86, 0xe3, 0x0c, 0xa1, 0x62, 0x29, 0x6c, 0x17, 0xca, 0x27, 0x8b, 0xa3, 0xb8, 0xf9, 0xb0, 0x89,
+ 0x8d, 0xf3, 0x91, 0x45, 0x60, 0xb5, 0x30, 0x08, 0x76, 0x15, 0x8a, 0x27, 0x8b, 0x7e, 0xd7, 0x3c,
+ 0xc8, 0xb0, 0xe6, 0xe0, 0xac, 0x5d, 0x36, 0x0a, 0x39, 0xf7, 0x61, 0x35, 0xbb, 0x0e, 0x8d, 0x92,
+ 0x69, 0x6a, 0x68, 0x9c, 0x16, 0xd7, 0xfc, 0x5b, 0x8a, 0xeb, 0xee, 0x0e, 0x54, 0xec, 0xcf, 0x14,
+ 0x56, 0x83, 0xd2, 0xa3, 0xa3, 0x61, 0xef, 0x61, 0x63, 0x85, 0x55, 0xa1, 0x78, 0x38, 0x18, 0x3e,
+ 0x6c, 0xe4, 0x70, 0x74, 0x34, 0x38, 0xea, 0x35, 0xf2, 0xbb, 0x37, 0x60, 0x35, 0xfb, 0x3b, 0x85,
+ 0xd5, 0xa1, 0x32, 0x3c, 0x38, 0xea, 0xb6, 0x07, 0xbf, 0x6e, 0xac, 0xb0, 0x55, 0xa8, 0xf6, 0x8f,
+ 0x86, 0xbd, 0xce, 0x23, 0xde, 0x6b, 0xe4, 0x76, 0x7f, 0x05, 0xb5, 0xe4, 0x55, 0x8f, 0x12, 0xda,
+ 0xfd, 0xa3, 0x6e, 0x63, 0x85, 0x01, 0x94, 0x87, 0xbd, 0x0e, 0xef, 0xa1, 0xdc, 0x0a, 0x14, 0x86,
+ 0xc3, 0xc3, 0x46, 0x1e, 0x77, 0xed, 0x1c, 0x74, 0x0e, 0x7b, 0x8d, 0x02, 0x0e, 0x1f, 0x3e, 0x38,
+ 0xbe, 0x3b, 0x6c, 0x14, 0x77, 0xbf, 0x84, 0x2b, 0x17, 0x5e, 0xce, 0xb4, 0xfa, 0xf0, 0x80, 0xf7,
+ 0x50, 0x52, 0x1d, 0x2a, 0xc7, 0xbc, 0xff, 0xf8, 0xe0, 0x61, 0xaf, 0x91, 0x43, 0xc6, 0xfd, 0x41,
+ 0xe7, 0x5e, 0xaf, 0xdb, 0xc8, 0xb7, 0xaf, 0x7d, 0xf7, 0x72, 0x33, 0xf7, 0xfd, 0xcb, 0xcd, 0xdc,
+ 0x0f, 0x2f, 0x37, 0x73, 0xff, 0x7c, 0xb9, 0x99, 0xfb, 0xf6, 0xd5, 0xe6, 0xca, 0xf7, 0xaf, 0x36,
+ 0x57, 0x7e, 0x78, 0xb5, 0xb9, 0x72, 0x52, 0xa6, 0x9f, 0x9b, 0x5f, 0xfc, 0x27, 0x00, 0x00, 0xff,
+ 0xff, 0xa4, 0x50, 0x4f, 0x17, 0x1c, 0x15, 0x00, 0x00,
}
func (m *Op) Marshal() (dAtA []byte, err error) {
@@ -2784,6 +2802,13 @@
_ = i
var l int
_ = l
+ if len(m.Hostname) > 0 {
+ i -= len(m.Hostname)
+ copy(dAtA[i:], m.Hostname)
+ i = encodeVarintOps(dAtA, i, uint64(len(m.Hostname)))
+ i--
+ dAtA[i] = 0x3a
+ }
if len(m.ExtraHosts) > 0 {
for iNdEx := len(m.ExtraHosts) - 1; iNdEx >= 0; iNdEx-- {
{
@@ -2865,6 +2890,15 @@
_ = i
var l int
_ = l
+ if len(m.ResultID) > 0 {
+ i -= len(m.ResultID)
+ copy(dAtA[i:], m.ResultID)
+ i = encodeVarintOps(dAtA, i, uint64(len(m.ResultID)))
+ i--
+ dAtA[i] = 0x1
+ i--
+ dAtA[i] = 0xba
+ }
if m.SSHOpt != nil {
{
size, err := m.SSHOpt.MarshalToSizedBuffer(dAtA[:i])
@@ -4663,6 +4697,10 @@
n += 1 + l + sovOps(uint64(l))
}
}
+ l = len(m.Hostname)
+ if l > 0 {
+ n += 1 + l + sovOps(uint64(l))
+ }
return n
}
@@ -4704,6 +4742,10 @@
l = m.SSHOpt.Size()
n += 2 + l + sovOps(uint64(l))
}
+ l = len(m.ResultID)
+ if l > 0 {
+ n += 2 + l + sovOps(uint64(l))
+ }
return n
}
@@ -6359,6 +6401,38 @@
return err
}
iNdEx = postIndex
+ case 7:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field Hostname", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowOps
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthOps
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthOps
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.Hostname = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipOps(dAtA[iNdEx:])
@@ -6661,6 +6735,38 @@
return err
}
iNdEx = postIndex
+ case 23:
+ if wireType != 2 {
+ return fmt.Errorf("proto: wrong wireType = %d for field ResultID", wireType)
+ }
+ var stringLen uint64
+ for shift := uint(0); ; shift += 7 {
+ if shift >= 64 {
+ return ErrIntOverflowOps
+ }
+ if iNdEx >= l {
+ return io.ErrUnexpectedEOF
+ }
+ b := dAtA[iNdEx]
+ iNdEx++
+ stringLen |= uint64(b&0x7F) << shift
+ if b < 0x80 {
+ break
+ }
+ }
+ intStringLen := int(stringLen)
+ if intStringLen < 0 {
+ return ErrInvalidLengthOps
+ }
+ postIndex := iNdEx + intStringLen
+ if postIndex < 0 {
+ return ErrInvalidLengthOps
+ }
+ if postIndex > l {
+ return io.ErrUnexpectedEOF
+ }
+ m.ResultID = string(dAtA[iNdEx:postIndex])
+ iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipOps(dAtA[iNdEx:])
diff --git a/vendor/github.com/moby/buildkit/solver/pb/ops.proto b/vendor/github.com/moby/buildkit/solver/pb/ops.proto
index 087c346..a975e91 100644
--- a/vendor/github.com/moby/buildkit/solver/pb/ops.proto
+++ b/vendor/github.com/moby/buildkit/solver/pb/ops.proto
@@ -57,6 +57,7 @@
string user = 4;
ProxyEnv proxy_env = 5;
repeated HostIP extraHosts = 6;
+ string hostname = 7;
}
enum NetMode {
@@ -81,6 +82,7 @@
CacheOpt cacheOpt = 20;
SecretOpt secretOpt = 21;
SSHOpt SSHOpt = 22;
+ string resultID = 23;
}
// MountType defines a type of a mount from a supported set
diff --git a/vendor/github.com/moby/buildkit/solver/result.go b/vendor/github.com/moby/buildkit/solver/result.go
index c7e100b..75b378c 100644
--- a/vendor/github.com/moby/buildkit/solver/result.go
+++ b/vendor/github.com/moby/buildkit/solver/result.go
@@ -91,12 +91,12 @@
cr CachedResult
}
-func (r *clonedCachedResult) ID() string {
- return r.Result.ID()
+func (ccr *clonedCachedResult) ID() string {
+ return ccr.Result.ID()
}
-func (cr *clonedCachedResult) CacheKeys() []ExportableCacheKey {
- return cr.cr.CacheKeys()
+func (ccr *clonedCachedResult) CacheKeys() []ExportableCacheKey {
+ return ccr.cr.CacheKeys()
}
type SharedCachedResult struct {
diff --git a/vendor/github.com/moby/buildkit/solver/types.go b/vendor/github.com/moby/buildkit/solver/types.go
index f148ac1..76e4c91 100644
--- a/vendor/github.com/moby/buildkit/solver/types.go
+++ b/vendor/github.com/moby/buildkit/solver/types.go
@@ -95,6 +95,8 @@
Convert func(context.Context, Result) (*Remote, error)
// Mode defines a cache export algorithm
Mode CacheExportMode
+ // Session is the session group to client (for auth credentials etc)
+ Session session.Group
}
// CacheExporter can export the artifacts of the build chain
@@ -145,7 +147,8 @@
Exec(ctx context.Context, g session.Group, inputs []Result) (outputs []Result, err error)
}
-type ResultBasedCacheFunc func(context.Context, Result) (digest.Digest, error)
+type ResultBasedCacheFunc func(context.Context, Result, session.Group) (digest.Digest, error)
+type PreprocessFunc func(context.Context, Result, session.Group) error
// CacheMap is a description for calculating the cache key of an operation.
type CacheMap struct {
@@ -171,7 +174,16 @@
// For example, in LLB this is invoked to calculate the cache key based on
// the checksum of file contents from input snapshots.
ComputeDigestFunc ResultBasedCacheFunc
+
+ // PreprocessFunc is a function that runs on an input before it is passed to op
+ PreprocessFunc PreprocessFunc
}
+
+ // Opts specifies generic options that will be passed to cache load calls if/when
+ // the key associated with this CacheMap is used to load a ref. It allows options
+ // such as oci descriptor content providers and progress writers to be passed to
+ // the cache. Opts should not have any impact on the computed cache key.
+ Opts CacheOpts
}
// ExportableCacheKey is a cache key connected with an exporter that can export
diff --git a/vendor/github.com/moby/buildkit/source/git/gitsource.go b/vendor/github.com/moby/buildkit/source/git/gitsource.go
index 2c96e1b..0197c3c 100644
--- a/vendor/github.com/moby/buildkit/source/git/gitsource.go
+++ b/vendor/github.com/moby/buildkit/source/git/gitsource.go
@@ -13,7 +13,6 @@
"regexp"
"strings"
- "github.com/docker/docker/pkg/locker"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/cache/metadata"
"github.com/moby/buildkit/client"
@@ -21,8 +20,10 @@
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/secrets"
"github.com/moby/buildkit/snapshot"
+ "github.com/moby/buildkit/solver"
"github.com/moby/buildkit/source"
"github.com/moby/buildkit/util/progress/logs"
+ "github.com/moby/locker"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
bolt "go.etcd.io/bbolt"
@@ -63,7 +64,7 @@
}
// needs to be called with repo lock
-func (gs *gitSource) mountRemote(ctx context.Context, remote string, auth []string) (target string, release func(), retErr error) {
+func (gs *gitSource) mountRemote(ctx context.Context, remote string, auth []string, g session.Group) (target string, release func(), retErr error) {
remoteKey := "git-remote::" + remote
sis, err := gs.md.Search(remoteKey)
@@ -87,7 +88,7 @@
initializeRepo := false
if remoteRef == nil {
- remoteRef, err = gs.cache.New(ctx, nil, cache.CachePolicyRetain, cache.WithDescription(fmt.Sprintf("shared git repo for %s", remote)))
+ remoteRef, err = gs.cache.New(ctx, nil, g, cache.CachePolicyRetain, cache.WithDescription(fmt.Sprintf("shared git repo for %s", remote)))
if err != nil {
return "", nil, errors.Wrapf(err, "failed to create new mutable for %s", remote)
}
@@ -104,7 +105,7 @@
}
}()
- mount, err := remoteRef.Mount(ctx, false)
+ mount, err := remoteRef.Mount(ctx, false, g)
if err != nil {
return "", nil, err
}
@@ -166,7 +167,7 @@
return key
}
-func (gs *gitSource) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager) (source.SourceInstance, error) {
+func (gs *gitSource) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager, _ solver.Vertex) (source.SourceInstance, error) {
gitIdentifier, ok := id.(*source.GitIdentifier)
if !ok {
return nil, errors.Errorf("invalid git identifier %v", id)
@@ -231,7 +232,7 @@
})
}
-func (gs *gitSourceHandler) CacheKey(ctx context.Context, g session.Group, index int) (string, bool, error) {
+func (gs *gitSourceHandler) CacheKey(ctx context.Context, g session.Group, index int) (string, solver.CacheOpts, bool, error) {
remote := gs.src.Remote
ref := gs.src.Ref
if ref == "" {
@@ -243,14 +244,14 @@
if isCommitSHA(ref) {
ref = gs.shaToCacheKey(ref)
gs.cacheKey = ref
- return ref, true, nil
+ return ref, nil, true, nil
}
gs.getAuthToken(ctx, g)
- gitDir, unmountGitDir, err := gs.mountRemote(ctx, remote, gs.auth)
+ gitDir, unmountGitDir, err := gs.mountRemote(ctx, remote, gs.auth, g)
if err != nil {
- return "", false, err
+ return "", nil, false, err
}
defer unmountGitDir()
@@ -258,21 +259,21 @@
buf, err := gitWithinDir(ctx, gitDir, "", gs.auth, "ls-remote", "origin", ref)
if err != nil {
- return "", false, errors.Wrapf(err, "failed to fetch remote %s", remote)
+ return "", nil, false, errors.Wrapf(err, "failed to fetch remote %s", remote)
}
out := buf.String()
idx := strings.Index(out, "\t")
if idx == -1 {
- return "", false, errors.Errorf("repository does not contain ref %s, output: %q", ref, string(out))
+ return "", nil, false, errors.Errorf("repository does not contain ref %s, output: %q", ref, string(out))
}
sha := string(out[:idx])
if !isCommitSHA(sha) {
- return "", false, errors.Errorf("invalid commit sha %q", sha)
+ return "", nil, false, errors.Errorf("invalid commit sha %q", sha)
}
sha = gs.shaToCacheKey(sha)
gs.cacheKey = sha
- return sha, true, nil
+ return sha, nil, true, nil
}
func (gs *gitSourceHandler) Snapshot(ctx context.Context, g session.Group) (out cache.ImmutableRef, retErr error) {
@@ -284,7 +285,7 @@
cacheKey := gs.cacheKey
if cacheKey == "" {
var err error
- cacheKey, _, err = gs.CacheKey(ctx, g, 0)
+ cacheKey, _, _, err = gs.CacheKey(ctx, g, 0)
if err != nil {
return nil, err
}
@@ -306,7 +307,7 @@
gs.locker.Lock(gs.src.Remote)
defer gs.locker.Unlock(gs.src.Remote)
- gitDir, unmountGitDir, err := gs.mountRemote(ctx, gs.src.Remote, gs.auth)
+ gitDir, unmountGitDir, err := gs.mountRemote(ctx, gs.src.Remote, gs.auth, g)
if err != nil {
return nil, err
}
@@ -344,7 +345,7 @@
}
}
- checkoutRef, err := gs.cache.New(ctx, nil, cache.WithRecordType(client.UsageRecordTypeGitCheckout), cache.WithDescription(fmt.Sprintf("git snapshot for %s#%s", gs.src.Remote, ref)))
+ checkoutRef, err := gs.cache.New(ctx, nil, g, cache.WithRecordType(client.UsageRecordTypeGitCheckout), cache.WithDescription(fmt.Sprintf("git snapshot for %s#%s", gs.src.Remote, ref)))
if err != nil {
return nil, errors.Wrapf(err, "failed to create new mutable for %s", gs.src.Remote)
}
@@ -355,7 +356,7 @@
}
}()
- mount, err := checkoutRef.Mount(ctx, false)
+ mount, err := checkoutRef.Mount(ctx, false, g)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/source/http/httpsource.go b/vendor/github.com/moby/buildkit/source/http/httpsource.go
index 951d99c..dd9c127 100644
--- a/vendor/github.com/moby/buildkit/source/http/httpsource.go
+++ b/vendor/github.com/moby/buildkit/source/http/httpsource.go
@@ -16,13 +16,14 @@
"time"
"github.com/docker/docker/pkg/idtools"
- "github.com/docker/docker/pkg/locker"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/cache/metadata"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/snapshot"
+ "github.com/moby/buildkit/solver"
"github.com/moby/buildkit/source"
"github.com/moby/buildkit/util/tracing"
+ "github.com/moby/locker"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
bolt "go.etcd.io/bbolt"
@@ -56,19 +57,19 @@
}
func (hs *httpSource) ID() string {
- return source.HttpsScheme
+ return source.HTTPSScheme
}
type httpSourceHandler struct {
*httpSource
- src source.HttpIdentifier
+ src source.HTTPIdentifier
refID string
cacheKey digest.Digest
sm *session.Manager
}
-func (hs *httpSource) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager) (source.SourceInstance, error) {
- httpIdentifier, ok := id.(*source.HttpIdentifier)
+func (hs *httpSource) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager, _ solver.Vertex) (source.SourceInstance, error) {
+ httpIdentifier, ok := id.(*source.HTTPIdentifier)
if !ok {
return nil, errors.Errorf("invalid http identifier %v", id)
}
@@ -122,26 +123,26 @@
return digest.FromBytes(dt)
}
-func (hs *httpSourceHandler) CacheKey(ctx context.Context, g session.Group, index int) (string, bool, error) {
+func (hs *httpSourceHandler) CacheKey(ctx context.Context, g session.Group, index int) (string, solver.CacheOpts, bool, error) {
if hs.src.Checksum != "" {
hs.cacheKey = hs.src.Checksum
- return hs.formatCacheKey(getFileName(hs.src.URL, hs.src.Filename, nil), hs.src.Checksum, "").String(), true, nil
+ return hs.formatCacheKey(getFileName(hs.src.URL, hs.src.Filename, nil), hs.src.Checksum, "").String(), nil, true, nil
}
uh, err := hs.urlHash()
if err != nil {
- return "", false, nil
+ return "", nil, false, nil
}
// look up metadata(previously stored headers) for that URL
sis, err := hs.md.Search(uh.String())
if err != nil {
- return "", false, errors.Wrapf(err, "failed to search metadata for %s", uh)
+ return "", nil, false, errors.Wrapf(err, "failed to search metadata for %s", uh)
}
req, err := http.NewRequest("GET", hs.src.URL, nil)
if err != nil {
- return "", false, err
+ return "", nil, false, err
}
req = req.WithContext(ctx)
m := map[string]*metadata.StorageItem{}
@@ -198,7 +199,7 @@
if dgst != "" {
modTime := getModTime(si)
resp.Body.Close()
- return hs.formatCacheKey(getFileName(hs.src.URL, hs.src.Filename, resp), dgst, modTime).String(), true, nil
+ return hs.formatCacheKey(getFileName(hs.src.URL, hs.src.Filename, resp), dgst, modTime).String(), nil, true, nil
}
}
}
@@ -209,10 +210,10 @@
resp, err := client.Do(req)
if err != nil {
- return "", false, err
+ return "", nil, false, err
}
if resp.StatusCode < 200 || resp.StatusCode >= 400 {
- return "", false, errors.Errorf("invalid response status %d", resp.StatusCode)
+ return "", nil, false, errors.Errorf("invalid response status %d", resp.StatusCode)
}
if resp.StatusCode == http.StatusNotModified {
respETag := resp.Header.Get("ETag")
@@ -225,31 +226,31 @@
}
si, ok := m[respETag]
if !ok {
- return "", false, errors.Errorf("invalid not-modified ETag: %v", respETag)
+ return "", nil, false, errors.Errorf("invalid not-modified ETag: %v", respETag)
}
hs.refID = si.ID()
dgst := getChecksum(si)
if dgst == "" {
- return "", false, errors.Errorf("invalid metadata change")
+ return "", nil, false, errors.Errorf("invalid metadata change")
}
modTime := getModTime(si)
resp.Body.Close()
- return hs.formatCacheKey(getFileName(hs.src.URL, hs.src.Filename, resp), dgst, modTime).String(), true, nil
+ return hs.formatCacheKey(getFileName(hs.src.URL, hs.src.Filename, resp), dgst, modTime).String(), nil, true, nil
}
- ref, dgst, err := hs.save(ctx, resp)
+ ref, dgst, err := hs.save(ctx, resp, g)
if err != nil {
- return "", false, err
+ return "", nil, false, err
}
ref.Release(context.TODO())
hs.cacheKey = dgst
- return hs.formatCacheKey(getFileName(hs.src.URL, hs.src.Filename, resp), dgst, resp.Header.Get("Last-Modified")).String(), true, nil
+ return hs.formatCacheKey(getFileName(hs.src.URL, hs.src.Filename, resp), dgst, resp.Header.Get("Last-Modified")).String(), nil, true, nil
}
-func (hs *httpSourceHandler) save(ctx context.Context, resp *http.Response) (ref cache.ImmutableRef, dgst digest.Digest, retErr error) {
- newRef, err := hs.cache.New(ctx, nil, cache.CachePolicyRetain, cache.WithDescription(fmt.Sprintf("http url %s", hs.src.URL)))
+func (hs *httpSourceHandler) save(ctx context.Context, resp *http.Response, s session.Group) (ref cache.ImmutableRef, dgst digest.Digest, retErr error) {
+ newRef, err := hs.cache.New(ctx, nil, s, cache.CachePolicyRetain, cache.WithDescription(fmt.Sprintf("http url %s", hs.src.URL)))
if err != nil {
return nil, "", err
}
@@ -264,7 +265,7 @@
}
}()
- mount, err := newRef.Mount(ctx, false)
+ mount, err := newRef.Mount(ctx, false, s)
if err != nil {
return nil, "", err
}
@@ -391,7 +392,7 @@
return nil, err
}
- ref, dgst, err := hs.save(ctx, resp)
+ ref, dgst, err := hs.save(ctx, resp, g)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/source/identifier.go b/vendor/github.com/moby/buildkit/source/identifier.go
index fd500a1..c240731 100644
--- a/vendor/github.com/moby/buildkit/source/identifier.go
+++ b/vendor/github.com/moby/buildkit/source/identifier.go
@@ -30,8 +30,8 @@
DockerImageScheme = "docker-image"
GitScheme = "git"
LocalScheme = "local"
- HttpScheme = "http"
- HttpsScheme = "https"
+ HTTPScheme = "http"
+ HTTPSScheme = "https"
)
type Identifier interface {
@@ -52,10 +52,10 @@
return NewGitIdentifier(parts[1])
case LocalScheme:
return NewLocalIdentifier(parts[1])
- case HttpsScheme:
- return NewHttpIdentifier(parts[1], true)
- case HttpScheme:
- return NewHttpIdentifier(parts[1], false)
+ case HTTPSScheme:
+ return NewHTTPIdentifier(parts[1], true)
+ case HTTPScheme:
+ return NewHTTPIdentifier(parts[1], false)
default:
return nil, errors.Wrapf(errNotFound, "unknown schema %s", parts[0])
}
@@ -142,7 +142,7 @@
}
}
}
- if id, ok := id.(*HttpIdentifier); ok {
+ if id, ok := id.(*HTTPIdentifier); ok {
for k, v := range op.Source.Attrs {
switch k {
case pb.AttrHTTPChecksum:
@@ -196,7 +196,7 @@
return &ImageIdentifier{Reference: ref}, nil
}
-func (_ *ImageIdentifier) ID() string {
+func (*ImageIdentifier) ID() string {
return DockerImageScheme
}
@@ -217,15 +217,15 @@
return LocalScheme
}
-func NewHttpIdentifier(str string, tls bool) (*HttpIdentifier, error) {
+func NewHTTPIdentifier(str string, tls bool) (*HTTPIdentifier, error) {
proto := "https://"
if !tls {
proto = "http://"
}
- return &HttpIdentifier{TLS: tls, URL: proto + str}, nil
+ return &HTTPIdentifier{TLS: tls, URL: proto + str}, nil
}
-type HttpIdentifier struct {
+type HTTPIdentifier struct {
TLS bool
URL string
Checksum digest.Digest
@@ -235,8 +235,8 @@
GID int
}
-func (_ *HttpIdentifier) ID() string {
- return HttpsScheme
+func (*HTTPIdentifier) ID() string {
+ return HTTPSScheme
}
func (r ResolveMode) String() string {
diff --git a/vendor/github.com/moby/buildkit/source/local/local.go b/vendor/github.com/moby/buildkit/source/local/local.go
index 06241d0..3d385ab 100644
--- a/vendor/github.com/moby/buildkit/source/local/local.go
+++ b/vendor/github.com/moby/buildkit/source/local/local.go
@@ -14,6 +14,7 @@
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/session/filesync"
"github.com/moby/buildkit/snapshot"
+ "github.com/moby/buildkit/solver"
"github.com/moby/buildkit/source"
"github.com/moby/buildkit/util/progress"
digest "github.com/opencontainers/go-digest"
@@ -51,7 +52,7 @@
return source.LocalScheme
}
-func (ls *localSource) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager) (source.SourceInstance, error) {
+func (ls *localSource) Resolve(ctx context.Context, id source.Identifier, sm *session.Manager, _ solver.Vertex) (source.SourceInstance, error) {
localIdentifier, ok := id.(*source.LocalIdentifier)
if !ok {
return nil, errors.Errorf("invalid local identifier %v", id)
@@ -70,13 +71,13 @@
*localSource
}
-func (ls *localSourceHandler) CacheKey(ctx context.Context, g session.Group, index int) (string, bool, error) {
+func (ls *localSourceHandler) CacheKey(ctx context.Context, g session.Group, index int) (string, solver.CacheOpts, bool, error) {
sessionID := ls.src.SessionID
if sessionID == "" {
id := g.SessionIterator().NextSession()
if id == "" {
- return "", false, errors.New("could not access local files without session")
+ return "", nil, false, errors.New("could not access local files without session")
}
sessionID = id
}
@@ -87,15 +88,15 @@
FollowPaths []string
}{SessionID: sessionID, IncludePatterns: ls.src.IncludePatterns, ExcludePatterns: ls.src.ExcludePatterns, FollowPaths: ls.src.FollowPaths})
if err != nil {
- return "", false, err
+ return "", nil, false, err
}
- return "session:" + ls.src.Name + ":" + digest.FromBytes(dt).String(), true, nil
+ return "session:" + ls.src.Name + ":" + digest.FromBytes(dt).String(), nil, true, nil
}
func (ls *localSourceHandler) Snapshot(ctx context.Context, g session.Group) (cache.ImmutableRef, error) {
var ref cache.ImmutableRef
err := ls.sm.Any(ctx, g, func(ctx context.Context, _ string, c session.Caller) error {
- r, err := ls.snapshot(ctx, c)
+ r, err := ls.snapshot(ctx, g, c)
if err != nil {
return err
}
@@ -108,7 +109,7 @@
return ref, nil
}
-func (ls *localSourceHandler) snapshot(ctx context.Context, caller session.Caller) (out cache.ImmutableRef, retErr error) {
+func (ls *localSourceHandler) snapshot(ctx context.Context, s session.Group, caller session.Caller) (out cache.ImmutableRef, retErr error) {
sharedKey := keySharedKey + ":" + ls.src.Name + ":" + ls.src.SharedKeyHint + ":" + caller.SharedKey() // TODO: replace caller.SharedKey() with source based hint from client(absolute-path+nodeid)
var mutable cache.MutableRef
@@ -125,7 +126,7 @@
}
if mutable == nil {
- m, err := ls.cm.New(ctx, nil, cache.CachePolicyRetain, cache.WithRecordType(client.UsageRecordTypeLocalSource), cache.WithDescription(fmt.Sprintf("local source for %s", ls.src.Name)))
+ m, err := ls.cm.New(ctx, nil, s, cache.CachePolicyRetain, cache.WithRecordType(client.UsageRecordTypeLocalSource), cache.WithDescription(fmt.Sprintf("local source for %s", ls.src.Name)))
if err != nil {
return nil, err
}
@@ -145,7 +146,7 @@
}
}()
- mount, err := mutable.Mount(ctx, false)
+ mount, err := mutable.Mount(ctx, false, s)
if err != nil {
return nil, err
}
diff --git a/vendor/github.com/moby/buildkit/source/manager.go b/vendor/github.com/moby/buildkit/source/manager.go
index 9539389..aba45bf 100644
--- a/vendor/github.com/moby/buildkit/source/manager.go
+++ b/vendor/github.com/moby/buildkit/source/manager.go
@@ -6,16 +6,17 @@
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/solver"
"github.com/pkg/errors"
)
type Source interface {
ID() string
- Resolve(ctx context.Context, id Identifier, sm *session.Manager) (SourceInstance, error)
+ Resolve(ctx context.Context, id Identifier, sm *session.Manager, vtx solver.Vertex) (SourceInstance, error)
}
type SourceInstance interface {
- CacheKey(ctx context.Context, g session.Group, index int) (string, bool, error)
+ CacheKey(ctx context.Context, g session.Group, index int) (string, solver.CacheOpts, bool, error)
Snapshot(ctx context.Context, g session.Group) (cache.ImmutableRef, error)
}
@@ -36,7 +37,7 @@
sm.mu.Unlock()
}
-func (sm *Manager) Resolve(ctx context.Context, id Identifier, sessM *session.Manager) (SourceInstance, error) {
+func (sm *Manager) Resolve(ctx context.Context, id Identifier, sessM *session.Manager, vtx solver.Vertex) (SourceInstance, error) {
sm.mu.Lock()
src, ok := sm.sources[id.ID()]
sm.mu.Unlock()
@@ -45,5 +46,5 @@
return nil, errors.Errorf("no handler for %s", id.ID())
}
- return src.Resolve(ctx, id, sessM)
+ return src.Resolve(ctx, id, sessM, vtx)
}
diff --git a/vendor/github.com/moby/buildkit/util/apicaps/pb/generate.go b/vendor/github.com/moby/buildkit/util/apicaps/pb/generate.go
index 281dfab..addfccf 100644
--- a/vendor/github.com/moby/buildkit/util/apicaps/pb/generate.go
+++ b/vendor/github.com/moby/buildkit/util/apicaps/pb/generate.go
@@ -1,3 +1,3 @@
-package moby_buildkit_v1_apicaps
+package moby_buildkit_v1_apicaps //nolint:golint
//go:generate protoc -I=. -I=../../../vendor/ -I=../../../../../../ --gogo_out=plugins=grpc:. caps.proto
diff --git a/vendor/github.com/moby/buildkit/util/archutil/386_binary.go b/vendor/github.com/moby/buildkit/util/archutil/386_binary.go
new file mode 100644
index 0000000..dab00ec
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/archutil/386_binary.go
@@ -0,0 +1,8 @@
+// +build !386
+
+package archutil
+
+// This file is generated by running make inside the archutil package.
+// Do not edit manually.
+
+const Binary386 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\xd8\x31\x8a\xc2\x40\x14\x06\xe0\x7f\x36\xb3\xd9\x84\xdd\x62\x0e\x10\x96\x2d\xb6\xd8\x6a\x58\x21\x57\x50\x1b\x11\x2c\x3c\x80\x62\xd0\x2a\x09\xc9\x08\x5a\x99\x23\x78\x18\x0b\x4b\x2f\x20\xd8\x5b\x7b\x0f\x79\xc9\x0b\xa4\x48\x63\xff\x3e\xf8\x19\x7c\xf3\x7c\xa9\xdf\x1c\x86\x93\x91\x52\x0a\xad\x37\x78\xa8\x7f\x1d\x75\x10\x03\xf8\x37\x4d\x3d\xc6\x0f\x34\xfe\xa0\xdb\x7b\x52\xe9\x80\x72\x03\x40\xd1\x54\x33\x68\xee\x4d\x33\x83\x12\x02\xa0\xbc\x73\x9d\xfa\x4e\x94\x4a\x07\x94\x08\x40\xc4\xff\xa7\xcc\x1e\x6e\x85\x1e\x3e\x8f\xa5\x9e\x2f\x9e\x37\x9e\xce\xe9\x7b\x17\xaa\x29\x08\x21\x84\x10\x42\x08\x21\x84\x10\xa2\xcf\x99\x96\xe6\xc1\xfd\x5a\xc1\x96\x9b\xd2\x15\x6e\xb1\x84\x4d\x33\x97\xd8\x75\xba\xb5\x79\x91\xe5\x49\xe1\xf6\xb0\x2e\xd9\xb9\x57\xe6\x7e\x02\xf8\xa8\xdf\x13\x78\xcf\xe7\x1d\xbf\xa5\xf9\xfc\xe6\xbd\xdd\xe7\x37\x07\x5a\xf0\xc3\x4e\x9f\xea\x9c\x5e\xa7\x1e\x1a\xe0\xb7\xa7\xef\x19\x00\x00\xff\xff\x32\x71\x64\x98\xd0\x10\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/386_check.go b/vendor/github.com/moby/buildkit/util/archutil/386_check.go
similarity index 78%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/386_check.go
rename to vendor/github.com/moby/buildkit/util/archutil/386_check.go
index 8137d35..5ef488f 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/386_check.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/386_check.go
@@ -1,6 +1,6 @@
// +build !386
-package binfmt_misc
+package archutil
func i386Supported() error {
return check(Binary386)
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/386_check_386.go b/vendor/github.com/moby/buildkit/util/archutil/386_check_386.go
similarity index 74%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/386_check_386.go
rename to vendor/github.com/moby/buildkit/util/archutil/386_check_386.go
index 2b2ab45..f2c0ee3 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/386_check_386.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/386_check_386.go
@@ -1,6 +1,6 @@
// +build 386
-package binfmt_misc
+package archutil
func i386Supported() error {
return nil
diff --git a/vendor/github.com/moby/buildkit/util/archutil/amd64_binary.go b/vendor/github.com/moby/buildkit/util/archutil/amd64_binary.go
new file mode 100644
index 0000000..59f135f
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/archutil/amd64_binary.go
@@ -0,0 +1,8 @@
+// +build !amd64
+
+package archutil
+
+// This file is generated by running make inside the archutil package.
+// Do not edit manually.
+
+const Binaryamd64 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x06\x3b\x06\x30\x4f\xc0\x01\xcc\x77\x80\x8a\x1b\x08\xc0\x95\x30\x38\x30\x58\x30\xb0\x30\x38\x30\xb0\x30\x30\x83\xd5\xb2\x30\x20\x03\x07\x14\xda\x01\x6a\x34\x8c\x66\x80\x9a\x03\xe2\xb2\x22\xf1\x61\xf6\xc1\x68\x1e\xa8\x30\x8c\x86\xa9\x63\x81\x62\x05\xa8\x79\x0a\x8c\x0e\xa8\x34\x54\x39\x8c\xe6\x80\xd2\x81\x4f\x4b\x52\xd8\x18\x88\x07\x30\x67\xb1\x40\xd9\x20\xb7\xba\xfb\x85\x82\xdc\x7d\x80\x05\xea\xfe\x51\x30\x0a\x46\xc1\x28\x18\x05\xa3\x60\x14\x8c\x82\x51\x30\x0a\x46\xc1\x28\x18\x05\xa3\x60\xa8\x00\x8f\xe3\x07\x6c\x40\x94\xe1\x7f\x7e\x56\x06\xbd\xe2\x8c\xe2\x92\xa2\x92\xc4\x24\x06\xbd\xbc\xfc\x92\x54\xbd\xf4\xbc\x52\xbd\x82\xa2\xfc\x82\xd4\xa2\x92\x4a\x06\xbd\x92\xd4\x8a\x12\x8a\xed\xe3\x66\x60\x60\x60\x07\x8f\x33\xa0\xf7\xdf\x51\xfb\xed\x0c\x68\xfd\x77\x18\x90\x83\xf6\xbd\xe1\x7d\x79\xf8\xb8\x01\xda\x78\x01\x03\x62\x9c\x01\x9d\xcf\x8c\xc5\x5d\x3c\x50\xfd\x2a\x04\xf4\x03\x02\x00\x00\xff\xff\x90\x57\x64\xbb\x30\x11\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_check.go b/vendor/github.com/moby/buildkit/util/archutil/amd64_check.go
similarity index 79%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_check.go
rename to vendor/github.com/moby/buildkit/util/archutil/amd64_check.go
index 6191338..3942860 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_check.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/amd64_check.go
@@ -1,6 +1,6 @@
// +build !amd64
-package binfmt_misc
+package archutil
func amd64Supported() error {
return check(Binaryamd64)
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_check_amd64.go b/vendor/github.com/moby/buildkit/util/archutil/amd64_check_amd64.go
similarity index 75%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_check_amd64.go
rename to vendor/github.com/moby/buildkit/util/archutil/amd64_check_amd64.go
index e437dfe..538840d 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_check_amd64.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/amd64_check_amd64.go
@@ -1,6 +1,6 @@
// +build amd64
-package binfmt_misc
+package archutil
func amd64Supported() error {
return nil
diff --git a/vendor/github.com/moby/buildkit/util/archutil/arm64_binary.go b/vendor/github.com/moby/buildkit/util/archutil/arm64_binary.go
new file mode 100644
index 0000000..f5b7fef
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/archutil/arm64_binary.go
@@ -0,0 +1,8 @@
+// +build !arm64
+
+package archutil
+
+// This file is generated by running make inside the archutil package.
+// Do not edit manually.
+
+const Binaryarm64 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x86\xed\x0c\x20\xde\x06\x06\x07\x30\xdf\x01\x2a\x7e\x81\x01\x01\x1c\x18\x2c\x18\x98\x18\x1c\x18\x98\x19\x98\xc0\x6a\x59\x19\x18\x50\x64\x91\xe9\x3d\x50\xde\x1e\xb8\x3c\xc4\xae\xc0\xa7\x25\x29\x6c\x0c\xc4\x03\x01\x38\xab\xe1\xd2\x0a\xee\x86\x4b\x8c\x0c\x0c\x57\x18\xf4\x8a\x33\x8a\x4b\x8a\x4a\x12\x93\x18\xf4\x4a\x52\x2b\x4a\x18\xa8\x00\xb8\xa1\x2e\x84\xb9\x0d\x16\x0e\x1b\xa0\x7c\x1e\x34\xf5\x2c\x68\x7c\x90\x5e\x66\x2c\xe6\xc2\xfc\x2f\x88\x45\x3d\x32\x00\x04\x00\x00\xff\xff\xbb\x46\x88\x1e\x90\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_check.go b/vendor/github.com/moby/buildkit/util/archutil/arm64_check.go
similarity index 79%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_check.go
rename to vendor/github.com/moby/buildkit/util/archutil/arm64_check.go
index 334d314..76600d0 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_check.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/arm64_check.go
@@ -1,6 +1,6 @@
// +build !arm64
-package binfmt_misc
+package archutil
func arm64Supported() error {
return check(Binaryarm64)
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_check_arm64.go b/vendor/github.com/moby/buildkit/util/archutil/arm64_check_arm64.go
similarity index 75%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_check_arm64.go
rename to vendor/github.com/moby/buildkit/util/archutil/arm64_check_arm64.go
index a5fc6dc..1b1c8c6 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_check_arm64.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/arm64_check_arm64.go
@@ -1,6 +1,6 @@
// +build arm64
-package binfmt_misc
+package archutil
func arm64Supported() error {
return nil
diff --git a/vendor/github.com/moby/buildkit/util/archutil/arm_binary.go b/vendor/github.com/moby/buildkit/util/archutil/arm_binary.go
new file mode 100644
index 0000000..15e6f25
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/archutil/arm_binary.go
@@ -0,0 +1,8 @@
+// +build !arm
+
+package archutil
+
+// This file is generated by running make inside the archutil package.
+// Do not edit manually.
+
+const Binaryarm = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\x8c\x8f\x3d\x6e\xc2\x40\x10\x85\xbf\x89\x7f\x12\x29\x29\x92\x9c\x20\xe9\xa8\xb6\xf2\x05\x5c\x40\x05\x05\xdc\x60\x2d\x2c\xe1\xce\xb2\x07\x89\x0e\xce\xc0\x09\x7c\x08\x6e\x64\x51\x73\x05\xe4\x65\x2d\xb6\x70\xc1\x93\x46\xb3\xfb\xcd\x2b\xde\x3b\xce\x97\x0b\x11\x61\xd4\x1b\x33\x86\x9f\x22\x64\xc0\xe5\x01\x93\x8c\x3f\x77\x8b\x89\x78\xba\xc5\xcd\x09\xdc\x24\x9e\xad\xaf\xba\x65\x42\x29\xf0\xed\x5e\x5d\x2f\x75\xd7\x03\xb7\xfc\x07\xb0\xa5\x2d\x2a\xe4\x1d\xf8\x10\x4c\xbb\x6b\xb5\x51\x5b\x60\xb4\x3c\x28\x26\xdf\xac\x8c\x55\x6d\xaa\x62\xaf\x65\xcb\xcb\xfa\xf4\x09\x53\xdf\x47\x81\xaf\xe0\x1e\xfb\x3d\x44\x88\xa0\x1e\xf9\xd0\xe5\x37\xf0\x49\xb0\xa3\x80\x9f\x81\xff\x09\xdf\x3d\x00\x00\xff\xff\x0b\x8f\xbf\xbd\x54\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm_check.go b/vendor/github.com/moby/buildkit/util/archutil/arm_check.go
similarity index 78%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/arm_check.go
rename to vendor/github.com/moby/buildkit/util/archutil/arm_check.go
index 3a10daa..745e705 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm_check.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/arm_check.go
@@ -1,6 +1,6 @@
// +build !arm
-package binfmt_misc
+package archutil
func armSupported() error {
return check(Binaryarm)
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm_check_arm.go b/vendor/github.com/moby/buildkit/util/archutil/arm_check_arm.go
similarity index 74%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/arm_check_arm.go
rename to vendor/github.com/moby/buildkit/util/archutil/arm_check_arm.go
index 11cfe61..d6dea6f 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm_check_arm.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/arm_check_arm.go
@@ -1,6 +1,6 @@
// +build arm
-package binfmt_misc
+package archutil
func armSupported() error {
return nil
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/check_unix.go b/vendor/github.com/moby/buildkit/util/archutil/check_unix.go
similarity index 97%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/check_unix.go
rename to vendor/github.com/moby/buildkit/util/archutil/check_unix.go
index 670e6d2..236c96a 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/check_unix.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/check_unix.go
@@ -1,6 +1,6 @@
// +build !windows
-package binfmt_misc
+package archutil
import (
"bytes"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/check_windows.go b/vendor/github.com/moby/buildkit/util/archutil/check_windows.go
similarity index 90%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/check_windows.go
rename to vendor/github.com/moby/buildkit/util/archutil/check_windows.go
index f246184..18ec34d 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/check_windows.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/check_windows.go
@@ -1,6 +1,6 @@
// +build windows
-package binfmt_misc
+package archutil
import (
"errors"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/detect.go b/vendor/github.com/moby/buildkit/util/archutil/detect.go
similarity index 89%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/detect.go
rename to vendor/github.com/moby/buildkit/util/archutil/detect.go
index 73eb405..7b4673c 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/detect.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/detect.go
@@ -1,4 +1,4 @@
-package binfmt_misc
+package archutil
import (
"strings"
@@ -82,37 +82,37 @@
if p != def {
if p == "linux/amd64" {
if err := amd64Supported(); err != nil {
- printPlatfromWarning(p, err)
+ printPlatformWarning(p, err)
}
}
if p == "linux/arm64" {
if err := arm64Supported(); err != nil {
- printPlatfromWarning(p, err)
+ printPlatformWarning(p, err)
}
}
if p == "linux/riscv64" {
if err := riscv64Supported(); err != nil {
- printPlatfromWarning(p, err)
+ printPlatformWarning(p, err)
}
}
if p == "linux/ppc64le" {
if err := ppc64leSupported(); err != nil {
- printPlatfromWarning(p, err)
+ printPlatformWarning(p, err)
}
}
if p == "linux/s390x" {
if err := s390xSupported(); err != nil {
- printPlatfromWarning(p, err)
+ printPlatformWarning(p, err)
}
}
if p == "linux/386" {
if err := i386Supported(); err != nil {
- printPlatfromWarning(p, err)
+ printPlatformWarning(p, err)
}
}
if strings.HasPrefix(p, "linux/arm/v6") || strings.HasPrefix(p, "linux/arm/v7") {
if err := armSupported(); err != nil {
- printPlatfromWarning(p, err)
+ printPlatformWarning(p, err)
}
}
}
@@ -123,11 +123,11 @@
return platforms.Format(platforms.Normalize(platforms.DefaultSpec()))
}
-func printPlatfromWarning(p string, err error) {
+func printPlatformWarning(p string, err error) {
if strings.Contains(err.Error(), "exec format error") {
logrus.Warnf("platform %s cannot pass the validation, kernel support for miscellaneous binary may have not enabled.", p)
} else if strings.Contains(err.Error(), "no such file or directory") {
- logrus.Warnf("platforms %s cannot pass the validation, '-F' flag might have not set for 'binfmt_misc'.", p)
+ logrus.Warnf("platforms %s cannot pass the validation, '-F' flag might have not set for 'archutil'.", p)
} else {
logrus.Warnf("platforms %s cannot pass the validation: %s", p, err.Error())
}
diff --git a/vendor/github.com/moby/buildkit/util/archutil/ppc64le_binary.go b/vendor/github.com/moby/buildkit/util/archutil/ppc64le_binary.go
new file mode 100644
index 0000000..3e4d4b3
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/archutil/ppc64le_binary.go
@@ -0,0 +1,8 @@
+// +build !ppc64le
+
+package archutil
+
+// This file is generated by running make inside the archutil package.
+// Do not edit manually.
+
+const Binaryppc64le = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x06\x51\x06\x10\x6f\x03\x03\x83\x00\x88\xef\x00\x15\xbf\x01\x97\x07\x89\x59\x30\x30\x31\x38\x30\xb0\x30\x30\x83\xd5\xb2\x32\xa0\x00\x01\x64\x7a\x0f\x94\xb3\x07\x2e\x0d\xb1\x2b\xf0\x69\x49\x0a\x1b\x03\xf1\x40\x00\xa1\xdb\x82\x81\x21\xc1\x82\x89\x81\xc1\x85\x41\xaf\x38\xa3\xb8\xa4\xa8\x24\x31\x89\x41\xaf\x24\xb5\xa2\x84\x41\x2f\x35\x23\x3e\xad\x28\x31\x37\x95\x81\x62\xc0\x0d\x75\x29\xcc\x8d\xb0\xf0\xd8\x00\xe5\xf3\xa0\xa9\xe7\x40\xe3\x0b\x42\xf5\x33\x21\xfc\x2f\x80\x1a\x0e\xa8\x80\x05\x8d\x0f\xd2\xcb\x8c\x45\x1d\x4c\xbf\x34\x16\xf5\xc8\x00\x10\x00\x00\xff\xff\x59\x3e\xf6\x64\xd8\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_check.go b/vendor/github.com/moby/buildkit/util/archutil/ppc64le_check.go
similarity index 80%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_check.go
rename to vendor/github.com/moby/buildkit/util/archutil/ppc64le_check.go
index 4d5b3bf..0172583 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_check.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/ppc64le_check.go
@@ -1,6 +1,6 @@
// +build !ppc64le
-package binfmt_misc
+package archutil
func ppc64leSupported() error {
return check(Binaryppc64le)
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_check_ppc64le.go b/vendor/github.com/moby/buildkit/util/archutil/ppc64le_check_ppc64le.go
similarity index 76%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_check_ppc64le.go
rename to vendor/github.com/moby/buildkit/util/archutil/ppc64le_check_ppc64le.go
index 27e4ab8..7da12d4 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_check_ppc64le.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/ppc64le_check_ppc64le.go
@@ -1,6 +1,6 @@
// +build ppc64le
-package binfmt_misc
+package archutil
func ppc64leSupported() error {
return nil
diff --git a/vendor/github.com/moby/buildkit/util/archutil/riscv64_binary.go b/vendor/github.com/moby/buildkit/util/archutil/riscv64_binary.go
new file mode 100644
index 0000000..a5e115d
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/archutil/riscv64_binary.go
@@ -0,0 +1,8 @@
+// +build !riscv64
+
+package archutil
+
+// This file is generated by running make inside the archutil package.
+// Do not edit manually.
+
+const Binaryriscv64 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x86\xcf\x0c\x20\xde\x06\x06\x88\x98\x03\x54\xfc\x02\x94\x66\x01\x8b\x59\x30\x30\x31\x38\x30\x30\x33\x30\x81\x55\xb1\x32\x20\x03\x46\x14\x7a\x0f\x94\x07\xa3\x19\x04\x20\x54\xe0\xd3\x92\x14\x36\x06\xe2\x01\x54\x1b\x83\x30\x2b\x03\xc3\x64\x8e\x0b\xac\xc5\x20\x8e\x5e\x71\x46\x71\x49\x51\x49\x62\x12\x83\x5e\x49\x6a\x45\x09\x03\x15\x00\x37\xd4\xe5\x30\xb7\xc1\xc2\x61\x03\x94\xcf\x83\xa6\x9e\x05\x8d\x0f\x52\xcd\x8c\xc5\x5c\x98\xff\x05\xb1\xa8\x47\x06\x80\x00\x00\x00\xff\xff\x34\x4f\x05\xf7\x90\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_check.go b/vendor/github.com/moby/buildkit/util/archutil/riscv64_check.go
similarity index 80%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_check.go
rename to vendor/github.com/moby/buildkit/util/archutil/riscv64_check.go
index c2f31f7..c1272d0 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_check.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/riscv64_check.go
@@ -1,6 +1,6 @@
// +build !riscv64
-package binfmt_misc
+package archutil
func riscv64Supported() error {
return check(Binaryriscv64)
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_check_riscv64.go b/vendor/github.com/moby/buildkit/util/archutil/riscv64_check_riscv64.go
similarity index 76%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_check_riscv64.go
rename to vendor/github.com/moby/buildkit/util/archutil/riscv64_check_riscv64.go
index 7ae5736..ceeb560 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_check_riscv64.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/riscv64_check_riscv64.go
@@ -1,6 +1,6 @@
// +build riscv64
-package binfmt_misc
+package archutil
func riscv64Supported() error {
return nil
diff --git a/vendor/github.com/moby/buildkit/util/archutil/s390x_binary.go b/vendor/github.com/moby/buildkit/util/archutil/s390x_binary.go
new file mode 100644
index 0000000..0f43a0b
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/archutil/s390x_binary.go
@@ -0,0 +1,8 @@
+// +build !s390x
+
+package archutil
+
+// This file is generated by running make inside the archutil package.
+// Do not edit manually.
+
+const Binarys390x = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x62\x64\x80\x03\x26\x06\x31\x06\x06\x06\xb0\x00\x23\x03\xc3\x06\xa8\xa8\x03\x94\xbe\x00\xe5\x59\x30\x30\x31\x38\x30\x30\x33\x30\x41\xd5\xb2\x32\x20\x01\x46\x34\x9a\x81\x81\x61\x07\x2a\x2d\xc0\x90\x52\xf2\x34\x90\x81\x81\x81\x8d\x81\x34\x20\xb0\x5c\x93\x81\x81\x8b\x91\x9d\x9d\x41\xaf\x38\xa3\xb8\xa4\xa8\x24\x31\x89\x41\xaf\x24\xb5\xa2\x84\x81\x7a\x80\x1b\xc9\xe9\x6c\x68\xe1\x00\xa3\x39\xd0\xf4\xb0\xa0\x79\x9f\x19\x87\xd9\xb0\x70\x10\x44\x13\x87\x07\x15\x20\x00\x00\xff\xff\x28\x7b\x76\xee\x90\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_check.go b/vendor/github.com/moby/buildkit/util/archutil/s390x_check.go
similarity index 79%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_check.go
rename to vendor/github.com/moby/buildkit/util/archutil/s390x_check.go
index 1d5b4a0..89f5cf4 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_check.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/s390x_check.go
@@ -1,6 +1,6 @@
// +build !s390x
-package binfmt_misc
+package archutil
func s390xSupported() error {
return check(Binarys390x)
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_check_s390x.go b/vendor/github.com/moby/buildkit/util/archutil/s390x_check_s390x.go
similarity index 75%
rename from vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_check_s390x.go
rename to vendor/github.com/moby/buildkit/util/archutil/s390x_check_s390x.go
index 9255422..664bb15 100644
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_check_s390x.go
+++ b/vendor/github.com/moby/buildkit/util/archutil/s390x_check_s390x.go
@@ -1,6 +1,6 @@
// +build s390x
-package binfmt_misc
+package archutil
func s390xSupported() error {
return nil
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/386_binary.go b/vendor/github.com/moby/buildkit/util/binfmt_misc/386_binary.go
deleted file mode 100644
index 580f152..0000000
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/386_binary.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build !386
-
-package binfmt_misc
-
-// This file is generated by running make inside the binfmt_misc package.
-// Do not edit manually.
-
-const Binary386 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xec\xd8\x31\x6e\xc2\x30\x14\x06\xe0\xdf\x8d\xdb\x26\x6a\x07\x1f\x20\xaa\x3a\x74\xe8\x64\xb5\x52\xae\x00\x2c\x88\x8d\x03\x80\x14\xc1\x94\x44\x89\x91\x60\x22\x47\x60\xe0\x20\x8c\x8c\x5c\x80\x13\x70\x19\xf4\xe2\x67\x91\x81\x25\xfb\xfb\xa4\x5f\x16\xcf\xe6\x29\xeb\x7b\xfb\xd1\x74\xac\x94\x42\xf0\x82\x08\xdd\xaf\x83\x8e\x33\x00\x7f\xc6\xd7\x33\x7c\x23\xc2\x2f\x74\xb8\x27\xad\x8e\x29\x27\x00\x14\x4d\x35\x03\x7f\x6f\x7c\x0f\x4a\x02\x80\xf2\xca\x75\x7a\x77\xa4\xb4\x3a\xa6\xa4\x00\x52\xfe\x7f\xc8\x27\xbf\x9f\xcc\xe6\xd4\xef\x42\xb5\xc7\x57\x0a\x21\x84\x10\x42\x08\x21\x84\x10\x62\x88\x33\x0d\xd5\xff\xb7\x6b\x0b\xdb\xac\x1b\x57\xbb\xc5\x12\xb6\x28\x5d\x6e\x57\xc5\xc6\x56\x75\x59\xe5\xb5\xdb\xc1\xba\x7c\xeb\x86\xf4\xfd\x00\xf0\xde\xed\x13\x78\xce\xe7\x19\x3f\xd0\x7c\x7e\xf1\x5c\xff\xc6\x3b\x07\x18\xbf\x2b\x08\x54\xef\x8c\x7a\xf5\xc4\x00\x3f\x4f\xde\xdd\x03\x00\x00\xff\xff\x8d\xf7\xd2\x72\xd0\x10\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_binary.go b/vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_binary.go
deleted file mode 100644
index 3cafea9..0000000
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/amd64_binary.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build !amd64
-
-package binfmt_misc
-
-// This file is generated by running make inside the binfmt_misc package.
-// Do not edit manually.
-
-const Binaryamd64 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x06\x3b\x06\x30\x4f\xc0\x01\xcc\x77\x80\x8a\x1b\x08\xc0\x95\x30\x38\x30\x58\x30\x30\x33\x38\x30\xb0\x30\x30\x83\xd5\xb2\x30\x20\x03\x07\x14\x9a\x03\x6a\x34\x8c\x66\x80\x9a\x03\xe2\xb2\x22\xf1\x61\xf6\xc1\x68\x1e\xa8\x30\x8c\x86\xa9\x63\x81\xe2\x17\x50\xe1\x17\x50\x7b\x60\xb4\x02\x54\x1c\x46\x73\x30\x20\xf4\x09\x40\xed\x74\xf7\x0b\x05\xd9\x7f\x80\x05\xea\x8e\x51\x30\x0a\x46\xc1\x28\x18\x05\xa3\x60\x14\x8c\x82\x51\x30\x0a\x46\xc1\x28\x18\x05\xa3\x60\xb8\x03\x8f\xe3\x07\x6c\x40\x94\xe1\x7f\x7e\x56\x06\xbd\xe2\x8c\xe2\x92\xa2\x92\xc4\x24\x06\xbd\xbc\xfc\x92\x54\xbd\xf4\xbc\x52\xbd\x82\xa2\xfc\x82\xd4\xa2\x92\x4a\x06\xbd\x92\xd4\x8a\x12\x8a\xed\xe3\x66\x60\x60\x60\x07\x8f\x33\xa0\xf7\xdf\x51\xfb\xed\x0c\x68\xfd\x77\x18\x90\x83\xf6\xd9\xd9\x18\xd0\xc7\x0d\xd0\xc6\x0b\x18\x10\xe3\x0c\xe8\x7c\x66\x2c\xee\xe2\x81\xea\x57\x21\xa0\x1f\x10\x00\x00\xff\xff\x8a\x1b\xd7\x73\x30\x11\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_binary.go b/vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_binary.go
deleted file mode 100644
index 01cdf9a..0000000
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm64_binary.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build !arm64
-
-package binfmt_misc
-
-// This file is generated by running make inside the binfmt_misc package.
-// Do not edit manually.
-
-const Binaryarm64 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x86\xed\x0c\x20\x5e\x05\x83\x03\x98\xef\x00\x15\x9f\xc1\x80\x00\x0e\x0c\x16\x0c\x8c\x0c\x0e\x0c\xcc\x0c\x4c\x60\xb5\xac\x0c\x0c\x28\xb2\xc8\x74\x0b\x94\xd7\x02\x97\x87\xd9\xd5\x70\x69\x05\x77\xc3\x25\x46\x06\x86\x2b\x0c\x7a\xc5\x19\xc5\x25\x45\x25\x89\x49\x0c\x7a\x25\xa9\x15\x25\x0c\x54\x00\xdc\x50\x9b\xd8\xa0\x7c\x98\x7f\x2a\xa0\x7c\x1e\x34\xf5\x2c\x68\x7c\x90\x5e\x66\x2c\xe6\xc2\xfc\x21\x88\x45\x3d\x32\x00\x04\x00\x00\xff\xff\xe7\x30\x54\x02\x58\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm_binary.go b/vendor/github.com/moby/buildkit/util/binfmt_misc/arm_binary.go
deleted file mode 100644
index c780578..0000000
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/arm_binary.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build !arm
-
-package binfmt_misc
-
-// This file is generated by running make inside the binfmt_misc package.
-// Do not edit manually.
-
-const Binaryarm = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\x8c\x8e\x31\x0e\x82\x40\x14\x44\xdf\x17\x50\x13\x6d\xf4\x04\xda\x51\x6d\xc5\x05\x28\xb4\xd2\xc6\x70\x00\x97\x84\x44\x3a\x02\xdf\xc4\xce\x4b\x78\x00\xee\xc6\x01\xbc\x82\x01\x17\xdd\xc2\xc2\x49\x26\x93\x7d\x3b\xc9\x9f\xfb\xee\xb0\x17\x11\x46\x4d\x88\xe9\x5f\x19\x42\x02\x3c\xde\x30\x4a\xd8\x20\xc4\x84\x04\x7c\xdb\x32\xf8\x0c\x83\xa3\x0f\x6b\x3b\xa9\xda\x0e\x78\xa6\x2b\xc0\x16\x36\x2f\x91\x19\x30\x17\x4c\x73\x69\xb4\x56\x9b\x63\xb4\xb8\x29\x26\x3d\x1d\x8d\x55\xad\xcb\xfc\xaa\x45\xc3\xdf\x5a\xb8\x6b\x53\xb7\x37\x03\x96\xde\x7f\xe8\xb2\x9f\x10\x40\x35\xf2\x7e\xeb\xda\xeb\x89\x97\x81\xc7\x6b\x60\xfb\xa3\xf7\x0a\x00\x00\xff\xff\x73\x8f\xca\xf1\x34\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_binary.go b/vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_binary.go
deleted file mode 100644
index 511db71..0000000
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/ppc64le_binary.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build !ppc64le
-
-package binfmt_misc
-
-// This file is generated by running make inside the binfmt_misc package.
-// Do not edit manually.
-
-const Binaryppc64le = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x06\x51\x06\x10\xaf\x82\x81\x41\x00\xc4\x77\x80\x8a\x2f\x80\xcb\x83\xc4\x2c\x18\x18\x19\x1c\x18\x58\x18\x98\xc1\x6a\x59\x19\x50\x80\x00\x32\xdd\x02\xe5\xb4\xc0\xa5\x19\x61\xa4\x05\x03\x43\x82\x05\x13\x03\x83\x0b\x83\x5e\x71\x46\x71\x49\x51\x49\x62\x12\x83\x5e\x49\x6a\x45\x09\x83\x5e\x6a\x46\x7c\x5a\x51\x62\x6e\x2a\x03\xc5\x80\x1b\x6a\x23\x1b\x94\x0f\xf3\x57\x05\x94\xcf\x83\xa6\x9e\x03\x8d\x2f\x08\xd5\xcf\x84\xf0\x87\x00\xaa\x7f\x50\x01\x0b\x1a\x1f\xa4\x97\x19\x8b\x3a\x98\x7e\x69\x2c\xea\x91\x01\x20\x00\x00\xff\xff\xce\xf7\x15\x75\xa0\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_binary.go b/vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_binary.go
deleted file mode 100644
index 146618e..0000000
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/riscv64_binary.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build !riscv64
-
-package binfmt_misc
-
-// This file is generated by running make inside the binfmt_misc package.
-// Do not edit manually.
-
-const Binaryriscv64 = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x64\x64\x80\x01\x26\x86\xcf\x0c\x20\x5e\x05\x03\x44\xcc\x01\x2a\x3e\x03\x4a\xb3\x80\xc5\x2c\x18\x18\x19\x1c\x18\x98\x19\x98\xc0\xaa\x58\x19\x90\x01\x23\x0a\xdd\x02\xe5\xc1\x68\x06\x01\x08\x25\xcc\xca\xc0\x30\x99\xe3\x02\x6b\x31\x88\xa3\x57\x9c\x51\x5c\x52\x54\x92\x98\xc4\xa0\x57\x92\x5a\x51\xc2\x40\x05\xc0\x0d\x75\x01\x1b\x94\x0f\xf3\x4f\x05\x94\xcf\x83\xa6\x9e\x05\x8d\x0f\x52\xcd\x8c\xc5\x5c\x98\x3f\x04\xb1\xa8\x47\x06\x80\x00\x00\x00\xff\xff\x39\x41\xdf\xa1\x58\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_binary.go b/vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_binary.go
deleted file mode 100644
index 3d34c2e..0000000
--- a/vendor/github.com/moby/buildkit/util/binfmt_misc/s390x_binary.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// +build !s390x
-
-package binfmt_misc
-
-// This file is generated by running make inside the binfmt_misc package.
-// Do not edit manually.
-
-const Binarys390x = "\x1f\x8b\x08\x00\x00\x00\x00\x00\x02\xff\xaa\x77\xf5\x71\x63\x62\x62\x64\x80\x03\x26\x06\x31\x06\x06\x06\xb0\x00\x23\x03\x43\x05\x54\xd4\x01\x4a\xcf\x80\xf2\x2c\x18\x18\x19\x1c\x18\x98\x19\x98\xa0\x6a\x59\x19\x90\x00\x23\x1a\xcd\xc0\xc0\xd0\x80\x4a\x0b\x30\x2c\xd7\x64\x60\xe0\x62\x64\x67\x67\xd0\x2b\xce\x28\x2e\x29\x2a\x49\x4c\x62\xd0\x2b\x49\xad\x28\x61\xa0\x1e\xe0\x46\x72\x02\x1b\x9a\x7f\x60\x34\x07\x9a\x1e\x16\x34\x6f\x30\xe3\x30\x1b\xe6\x1f\x41\x34\x71\xb8\x97\x01\x01\x00\x00\xff\xff\x0c\x76\x9a\xe1\x58\x01\x00\x00"
diff --git a/vendor/github.com/moby/buildkit/util/compression/compression.go b/vendor/github.com/moby/buildkit/util/compression/compression.go
new file mode 100644
index 0000000..f63d293
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/compression/compression.go
@@ -0,0 +1,136 @@
+package compression
+
+import (
+ "bytes"
+ "context"
+ "io"
+
+ "github.com/containerd/containerd/content"
+ "github.com/containerd/containerd/images"
+ digest "github.com/opencontainers/go-digest"
+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+)
+
+// Type represents compression type for blob data.
+type Type int
+
+const (
+ // Uncompressed indicates no compression.
+ Uncompressed Type = iota
+
+ // Gzip is used for blob data.
+ Gzip
+
+ // UnknownCompression means not supported yet.
+ UnknownCompression Type = -1
+)
+
+var Default = Gzip
+
+func (ct Type) String() string {
+ switch ct {
+ case Uncompressed:
+ return "uncompressed"
+ case Gzip:
+ return "gzip"
+ default:
+ return "unknown"
+ }
+}
+
+// DetectLayerMediaType returns media type from existing blob data.
+func DetectLayerMediaType(ctx context.Context, cs content.Store, id digest.Digest, oci bool) (string, error) {
+ ra, err := cs.ReaderAt(ctx, ocispec.Descriptor{Digest: id})
+ if err != nil {
+ return "", err
+ }
+ defer ra.Close()
+
+ ct, err := detectCompressionType(content.NewReader(ra))
+ if err != nil {
+ return "", err
+ }
+
+ switch ct {
+ case Uncompressed:
+ if oci {
+ return ocispec.MediaTypeImageLayer, nil
+ }
+ return images.MediaTypeDockerSchema2Layer, nil
+ case Gzip:
+ if oci {
+ return ocispec.MediaTypeImageLayerGzip, nil
+ }
+ return images.MediaTypeDockerSchema2LayerGzip, nil
+ default:
+ return "", errors.Errorf("failed to detect layer %v compression type", id)
+ }
+}
+
+// detectCompressionType detects compression type from real blob data.
+func detectCompressionType(cr io.Reader) (Type, error) {
+ var buf [10]byte
+ var n int
+ var err error
+
+ if n, err = cr.Read(buf[:]); err != nil && err != io.EOF {
+ // Note: we'll ignore any io.EOF error because there are some
+ // odd cases where the layer.tar file will be empty (zero bytes)
+ // and we'll just treat it as a non-compressed stream and that
+ // means just create an empty layer.
+ //
+ // See issue docker/docker#18170
+ return UnknownCompression, err
+ }
+
+ for c, m := range map[Type][]byte{
+ Gzip: {0x1F, 0x8B, 0x08},
+ } {
+ if n < len(m) {
+ continue
+ }
+ if bytes.Equal(m, buf[:len(m)]) {
+ return c, nil
+ }
+ }
+ return Uncompressed, nil
+}
+
+var toDockerLayerType = map[string]string{
+ ocispec.MediaTypeImageLayer: images.MediaTypeDockerSchema2Layer,
+ images.MediaTypeDockerSchema2Layer: images.MediaTypeDockerSchema2Layer,
+ ocispec.MediaTypeImageLayerGzip: images.MediaTypeDockerSchema2LayerGzip,
+ images.MediaTypeDockerSchema2LayerGzip: images.MediaTypeDockerSchema2LayerGzip,
+}
+
+var toOCILayerType = map[string]string{
+ ocispec.MediaTypeImageLayer: ocispec.MediaTypeImageLayer,
+ images.MediaTypeDockerSchema2Layer: ocispec.MediaTypeImageLayer,
+ ocispec.MediaTypeImageLayerGzip: ocispec.MediaTypeImageLayerGzip,
+ images.MediaTypeDockerSchema2LayerGzip: ocispec.MediaTypeImageLayerGzip,
+}
+
+func convertLayerMediaType(mediaType string, oci bool) string {
+ var converted string
+ if oci {
+ converted = toOCILayerType[mediaType]
+ } else {
+ converted = toDockerLayerType[mediaType]
+ }
+ if converted == "" {
+ logrus.Warnf("unhandled conversion for mediatype %q", mediaType)
+ return mediaType
+ }
+ return converted
+}
+
+func ConvertAllLayerMediaTypes(oci bool, descs ...ocispec.Descriptor) []ocispec.Descriptor {
+ var converted []ocispec.Descriptor
+ for _, desc := range descs {
+ desc.MediaType = convertLayerMediaType(desc.MediaType, oci)
+ converted = append(converted, desc)
+ }
+ return converted
+}
diff --git a/vendor/github.com/moby/buildkit/util/contentutil/refs.go b/vendor/github.com/moby/buildkit/util/contentutil/refs.go
index e62d798..9e41ea0 100644
--- a/vendor/github.com/moby/buildkit/util/contentutil/refs.go
+++ b/vendor/github.com/moby/buildkit/util/contentutil/refs.go
@@ -9,7 +9,7 @@
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
- "github.com/docker/docker/pkg/locker"
+ "github.com/moby/locker"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
diff --git a/vendor/github.com/moby/buildkit/util/entitlements/security/security_linux.go b/vendor/github.com/moby/buildkit/util/entitlements/security/security_linux.go
index 7c0fe84..08e4408 100644
--- a/vendor/github.com/moby/buildkit/util/entitlements/security/security_linux.go
+++ b/vendor/github.com/moby/buildkit/util/entitlements/security/security_linux.go
@@ -154,7 +154,7 @@
}
defer fd.Close()
- const _LOOP_CTL_GET_FREE = 0x4C82
+ const _LOOP_CTL_GET_FREE = 0x4C82 //nolint:golint
r1, _, uerr := unix.Syscall(unix.SYS_IOCTL, fd.Fd(), _LOOP_CTL_GET_FREE, 0)
if uerr == 0 {
return int(r1), nil
diff --git a/vendor/github.com/moby/buildkit/util/grpcerrors/grpcerrors.go b/vendor/github.com/moby/buildkit/util/grpcerrors/grpcerrors.go
index acba275..f12f10b 100644
--- a/vendor/github.com/moby/buildkit/util/grpcerrors/grpcerrors.go
+++ b/vendor/github.com/moby/buildkit/util/grpcerrors/grpcerrors.go
@@ -1,11 +1,15 @@
package grpcerrors
import (
+ "encoding/json"
+ "errors"
+
+ "github.com/containerd/typeurl"
gogotypes "github.com/gogo/protobuf/types"
"github.com/golang/protobuf/proto"
- "github.com/golang/protobuf/ptypes"
"github.com/golang/protobuf/ptypes/any"
"github.com/moby/buildkit/util/stack"
+ "github.com/sirupsen/logrus"
spb "google.golang.org/genproto/googleapis/rpc/status"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
@@ -29,8 +33,12 @@
st = status.New(Code(err), err.Error())
}
if st.Code() != Code(err) {
+ code := Code(err)
+ if code == codes.OK {
+ code = codes.Unknown
+ }
pb := st.Proto()
- pb.Code = int32(Code(err))
+ pb.Code = int32(code)
st = status.FromProto(pb)
}
@@ -47,7 +55,7 @@
})
if len(details) > 0 {
- if st2, err := st.WithDetails(details...); err == nil {
+ if st2, err := withDetails(st, details...); err == nil {
st = st2
}
}
@@ -55,6 +63,26 @@
return st.Err()
}
+func withDetails(s *status.Status, details ...proto.Message) (*status.Status, error) {
+ if s.Code() == codes.OK {
+ return nil, errors.New("no error details for status with code OK")
+ }
+ p := s.Proto()
+ for _, detail := range details {
+ url, err := typeurl.TypeURL(detail)
+ if err != nil {
+ logrus.Warnf("ignoring typed error %T: not registered", detail)
+ continue
+ }
+ dt, err := json.Marshal(detail)
+ if err != nil {
+ return nil, err
+ }
+ p.Details = append(p.Details, &any.Any{TypeUrl: url, Value: dt})
+ }
+ return status.FromProto(p), nil
+}
+
func Code(err error) codes.Code {
if se, ok := err.(interface {
Code() codes.Code
@@ -72,9 +100,10 @@
Unwrap() error
})
if ok {
- return Code(wrapped.Unwrap())
+ if err := wrapped.Unwrap(); err != nil {
+ return Code(err)
+ }
}
-
return status.FromContextError(err).Code()
}
@@ -96,7 +125,9 @@
Unwrap() error
})
if ok {
- return AsGRPCStatus(wrapped.Unwrap())
+ if err := wrapped.Unwrap(); err != nil {
+ return AsGRPCStatus(err)
+ }
}
return nil, false
@@ -123,17 +154,9 @@
// details that we don't understand are copied as proto
for _, d := range pb.Details {
- var m interface{}
- detail := &ptypes.DynamicAny{}
- if err := ptypes.UnmarshalAny(d, detail); err != nil {
- detail := &gogotypes.DynamicAny{}
- if err := gogotypes.UnmarshalAny(gogoAny(d), detail); err != nil {
- n.Details = append(n.Details, d)
- continue
- }
- m = detail.Message
- } else {
- m = detail.Message
+ m, err := typeurl.UnmarshalAny(gogoAny(d))
+ if err != nil {
+ continue
}
switch v := m.(type) {
@@ -144,7 +167,6 @@
default:
n.Details = append(n.Details, d)
}
-
}
err = status.FromProto(n).Err()
@@ -159,6 +181,10 @@
err = d.WrapError(err)
}
+ if err != nil {
+ stack.Helper()
+ }
+
return stack.Enable(err)
}
@@ -167,6 +193,10 @@
error
}
+func (e *withCode) Code() codes.Code {
+ return e.code
+}
+
func (e *withCode) Unwrap() error {
return e.error
}
diff --git a/vendor/github.com/moby/buildkit/util/grpcerrors/intercept.go b/vendor/github.com/moby/buildkit/util/grpcerrors/intercept.go
index 77618c1..1c17e4c 100644
--- a/vendor/github.com/moby/buildkit/util/grpcerrors/intercept.go
+++ b/vendor/github.com/moby/buildkit/util/grpcerrors/intercept.go
@@ -2,27 +2,53 @@
import (
"context"
+ "log"
+ "os"
+ "github.com/moby/buildkit/util/stack"
+ "github.com/pkg/errors"
"google.golang.org/grpc"
)
func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
resp, err = handler(ctx, req)
+ oldErr := err
if err != nil {
+ stack.Helper()
err = ToGRPC(err)
}
+ if oldErr != nil && err == nil {
+ logErr := errors.Wrap(err, "invalid grpc error conversion")
+ if os.Getenv("BUILDKIT_DEBUG_PANIC_ON_ERROR") == "1" {
+ panic(logErr)
+ }
+ log.Printf("%v", logErr)
+ err = oldErr
+ }
+
return resp, err
}
func StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
- return ToGRPC(handler(srv, ss))
+ err := ToGRPC(handler(srv, ss))
+ if err != nil {
+ stack.Helper()
+ }
+ return err
}
func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
- return FromGRPC(invoker(ctx, method, req, reply, cc, opts...))
+ err := FromGRPC(invoker(ctx, method, req, reply, cc, opts...))
+ if err != nil {
+ stack.Helper()
+ }
+ return err
}
func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
s, err := streamer(ctx, desc, cc, method, opts...)
+ if err != nil {
+ stack.Helper()
+ }
return s, ToGRPC(err)
}
diff --git a/vendor/github.com/moby/buildkit/util/imageutil/config.go b/vendor/github.com/moby/buildkit/util/imageutil/config.go
index e0d9f17..80ed268 100644
--- a/vendor/github.com/moby/buildkit/util/imageutil/config.go
+++ b/vendor/github.com/moby/buildkit/util/imageutil/config.go
@@ -36,6 +36,12 @@
leasesMu.Unlock()
}
+func AddLease(f func(context.Context) error) {
+ leasesMu.Lock()
+ leasesF = append(leasesF, f)
+ leasesMu.Unlock()
+}
+
func Config(ctx context.Context, str string, resolver remotes.Resolver, cache ContentCache, leaseManager leases.Manager, p *specs.Platform) (digest.Digest, []byte, error) {
// TODO: fix buildkit to take interface instead of struct
var platform platforms.MatchComparer
@@ -57,9 +63,7 @@
ctx = ctx2
defer func() {
// this lease is not deleted to allow other components to access manifest/config from cache. It will be deleted after 5 min deadline or on pruning inactive builder
- leasesMu.Lock()
- leasesF = append(leasesF, done)
- leasesMu.Unlock()
+ AddLease(done)
}()
}
diff --git a/vendor/github.com/moby/buildkit/util/network/host.go b/vendor/github.com/moby/buildkit/util/network/host.go
index dc58b1c..09aefdf 100644
--- a/vendor/github.com/moby/buildkit/util/network/host.go
+++ b/vendor/github.com/moby/buildkit/util/network/host.go
@@ -1,3 +1,5 @@
+// +build !windows
+
package network
import (
@@ -19,8 +21,8 @@
type hostNS struct {
}
-func (h *hostNS) Set(s *specs.Spec) {
- oci.WithHostNamespace(specs.NetworkNamespace)(nil, nil, nil, s)
+func (h *hostNS) Set(s *specs.Spec) error {
+ return oci.WithHostNamespace(specs.NetworkNamespace)(nil, nil, nil, s)
}
func (h *hostNS) Close() error {
diff --git a/vendor/github.com/moby/buildkit/util/network/network.go b/vendor/github.com/moby/buildkit/util/network/network.go
index 70b0ccc..befeef0 100644
--- a/vendor/github.com/moby/buildkit/util/network/network.go
+++ b/vendor/github.com/moby/buildkit/util/network/network.go
@@ -15,5 +15,5 @@
type Namespace interface {
io.Closer
// Set the namespace on the spec
- Set(*specs.Spec)
+ Set(*specs.Spec) error
}
diff --git a/vendor/github.com/moby/buildkit/util/network/none.go b/vendor/github.com/moby/buildkit/util/network/none.go
index ebf1ebd..336ff68 100644
--- a/vendor/github.com/moby/buildkit/util/network/none.go
+++ b/vendor/github.com/moby/buildkit/util/network/none.go
@@ -18,7 +18,8 @@
type noneNS struct {
}
-func (h *noneNS) Set(s *specs.Spec) {
+func (h *noneNS) Set(s *specs.Spec) error {
+ return nil
}
func (h *noneNS) Close() error {
diff --git a/vendor/github.com/moby/buildkit/util/progress/logs/logs.go b/vendor/github.com/moby/buildkit/util/progress/logs/logs.go
index 54f6ff8..d54dfd3 100644
--- a/vendor/github.com/moby/buildkit/util/progress/logs/logs.go
+++ b/vendor/github.com/moby/buildkit/util/progress/logs/logs.go
@@ -2,15 +2,26 @@
import (
"context"
+ "fmt"
"io"
+ "math"
"os"
+ "strconv"
+ "sync"
+ "time"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/identity"
"github.com/moby/buildkit/util/progress"
"github.com/pkg/errors"
+ "github.com/tonistiigi/units"
)
+var defaultMaxLogSize = 1024 * 1024
+var defaultMaxLogSpeed = 100 * 1024 // per second
+
+var configCheckOnce sync.Once
+
func NewLogStreams(ctx context.Context, printOutput bool) (io.WriteCloser, io.WriteCloser) {
return newStreamWriter(ctx, 1, printOutput), newStreamWriter(ctx, 2, printOutput)
}
@@ -21,31 +32,92 @@
pw: pw,
stream: stream,
printOutput: printOutput,
+ created: time.Now(),
}
}
type streamWriter struct {
- pw progress.Writer
- stream int
- printOutput bool
+ pw progress.Writer
+ stream int
+ printOutput bool
+ created time.Time
+ size int
+ clipping bool
+ clipReasonSpeed bool
+}
+
+func (sw *streamWriter) checkLimit(n int) int {
+ configCheckOnce.Do(func() {
+ maxLogSize, err := strconv.ParseInt(os.Getenv("BUILDKIT_STEP_LOG_MAX_SIZE"), 10, 32)
+ if err == nil {
+ defaultMaxLogSize = int(maxLogSize)
+ }
+ maxLogSpeed, err := strconv.ParseInt(os.Getenv("BUILDKIT_STEP_LOG_MAX_SPEED"), 10, 32)
+ if err == nil {
+ defaultMaxLogSpeed = int(maxLogSpeed)
+ }
+ })
+
+ oldSize := sw.size
+ sw.size += n
+
+ maxSize := -1
+ if defaultMaxLogSpeed != -1 {
+ maxSize = int(math.Ceil(time.Since(sw.created).Seconds())) * defaultMaxLogSpeed
+ sw.clipReasonSpeed = true
+ }
+ if maxSize > defaultMaxLogSize {
+ maxSize = defaultMaxLogSize
+ sw.clipReasonSpeed = false
+ }
+ if maxSize < oldSize {
+ return 0
+ }
+
+ if maxSize != -1 {
+ if sw.size > maxSize {
+ return maxSize - oldSize
+ }
+ }
+ return n
+}
+
+func (sw *streamWriter) clipLimitMessage() string {
+ if sw.clipReasonSpeed {
+ return fmt.Sprintf("%#g/s", units.Bytes(defaultMaxLogSpeed))
+ }
+ return fmt.Sprintf("%#g", units.Bytes(defaultMaxLogSize))
}
func (sw *streamWriter) Write(dt []byte) (int, error) {
- sw.pw.Write(identity.NewID(), client.VertexLog{
- Stream: sw.stream,
- Data: append([]byte{}, dt...),
- })
- if sw.printOutput {
- switch sw.stream {
- case 1:
- return os.Stdout.Write(dt)
- case 2:
- return os.Stderr.Write(dt)
- default:
- return 0, errors.Errorf("invalid stream %d", sw.stream)
+ oldSize := len(dt)
+ dt = append([]byte{}, dt[:sw.checkLimit(len(dt))]...)
+
+ if sw.clipping && oldSize == len(dt) {
+ sw.clipping = false
+ }
+ if !sw.clipping && oldSize != len(dt) {
+ dt = append(dt, []byte(fmt.Sprintf("\n[output clipped, log limit %s reached]\n", sw.clipLimitMessage()))...)
+ sw.clipping = true
+ }
+
+ if len(dt) != 0 {
+ sw.pw.Write(identity.NewID(), client.VertexLog{
+ Stream: sw.stream,
+ Data: dt,
+ })
+ if sw.printOutput {
+ switch sw.stream {
+ case 1:
+ return os.Stdout.Write(dt)
+ case 2:
+ return os.Stderr.Write(dt)
+ default:
+ return 0, errors.Errorf("invalid stream %d", sw.stream)
+ }
}
}
- return len(dt), nil
+ return oldSize, nil
}
func (sw *streamWriter) Close() error {
diff --git a/vendor/github.com/moby/buildkit/util/progress/multiwriter.go b/vendor/github.com/moby/buildkit/util/progress/multiwriter.go
index 5198936..1ce37ea 100644
--- a/vendor/github.com/moby/buildkit/util/progress/multiwriter.go
+++ b/vendor/github.com/moby/buildkit/util/progress/multiwriter.go
@@ -15,7 +15,6 @@
mu sync.Mutex
items []*Progress
writers map[rawProgressWriter]struct{}
- done bool
meta map[string]interface{}
}
diff --git a/vendor/github.com/moby/buildkit/util/progress/progress.go b/vendor/github.com/moby/buildkit/util/progress/progress.go
index ffe3d88..3ce2129 100644
--- a/vendor/github.com/moby/buildkit/util/progress/progress.go
+++ b/vendor/github.com/moby/buildkit/util/progress/progress.go
@@ -62,6 +62,11 @@
}
}
+type Controller interface {
+ Start(context.Context) (context.Context, func(error))
+ Status(id string, action string) func()
+}
+
type Writer interface {
Write(id string, value interface{}) error
Close() error
diff --git a/vendor/github.com/moby/buildkit/util/pull/pullprogress/progress.go b/vendor/github.com/moby/buildkit/util/pull/pullprogress/progress.go
new file mode 100644
index 0000000..f16a069
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/pull/pullprogress/progress.go
@@ -0,0 +1,138 @@
+package pullprogress
+
+import (
+ "context"
+ "io"
+ "time"
+
+ "github.com/containerd/containerd/content"
+ "github.com/containerd/containerd/errdefs"
+ "github.com/containerd/containerd/remotes"
+ "github.com/moby/buildkit/util/progress"
+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+)
+
+type PullManager interface {
+ content.IngestManager
+ content.Manager
+}
+
+type ProviderWithProgress struct {
+ Provider content.Provider
+ Manager PullManager
+}
+
+func (p *ProviderWithProgress) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
+ ra, err := p.Provider.ReaderAt(ctx, desc)
+ if err != nil {
+ return nil, err
+ }
+
+ ctx, cancel := context.WithCancel(ctx)
+ doneCh := make(chan struct{})
+ go trackProgress(ctx, desc, p.Manager, doneCh)
+ return readerAtWithCancel{ReaderAt: ra, cancel: cancel, doneCh: doneCh}, nil
+}
+
+type readerAtWithCancel struct {
+ content.ReaderAt
+ cancel func()
+ doneCh <-chan struct{}
+}
+
+func (ra readerAtWithCancel) Close() error {
+ ra.cancel()
+ select {
+ case <-ra.doneCh:
+ case <-time.After(time.Second):
+ logrus.Warn("timeout waiting for pull progress to complete")
+ }
+ return ra.ReaderAt.Close()
+}
+
+type FetcherWithProgress struct {
+ Fetcher remotes.Fetcher
+ Manager PullManager
+}
+
+func (f *FetcherWithProgress) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.ReadCloser, error) {
+ rc, err := f.Fetcher.Fetch(ctx, desc)
+ if err != nil {
+ return nil, err
+ }
+
+ ctx, cancel := context.WithCancel(ctx)
+ doneCh := make(chan struct{})
+ go trackProgress(ctx, desc, f.Manager, doneCh)
+ return readerWithCancel{ReadCloser: rc, cancel: cancel, doneCh: doneCh}, nil
+}
+
+type readerWithCancel struct {
+ io.ReadCloser
+ cancel func()
+ doneCh <-chan struct{}
+}
+
+func (r readerWithCancel) Close() error {
+ r.cancel()
+ select {
+ case <-r.doneCh:
+ case <-time.After(time.Second):
+ logrus.Warn("timeout waiting for pull progress to complete")
+ }
+ return r.ReadCloser.Close()
+}
+
+func trackProgress(ctx context.Context, desc ocispec.Descriptor, manager PullManager, doneCh chan<- struct{}) {
+
+ defer close(doneCh)
+
+ ticker := time.NewTicker(150 * time.Millisecond)
+ defer ticker.Stop()
+ go func() {
+ <-ctx.Done()
+ ticker.Stop()
+ }()
+
+ pw, _, _ := progress.FromContext(ctx)
+ defer pw.Close()
+
+ ingestRef := remotes.MakeRefKey(ctx, desc)
+
+ started := time.Now()
+ onFinalStatus := false
+ for !onFinalStatus {
+ select {
+ case <-ctx.Done():
+ onFinalStatus = true
+ case <-ticker.C:
+ }
+
+ status, err := manager.Status(ctx, ingestRef)
+ if err == nil {
+ pw.Write(desc.Digest.String(), progress.Status{
+ Current: int(status.Offset),
+ Total: int(status.Total),
+ Started: &started,
+ })
+ continue
+ } else if !errors.Is(err, errdefs.ErrNotFound) {
+ logrus.Errorf("unexpected error getting ingest status of %q: %v", ingestRef, err)
+ return
+ }
+
+ info, err := manager.Info(ctx, desc.Digest)
+ if err == nil {
+ pw.Write(desc.Digest.String(), progress.Status{
+ Current: int(info.Size),
+ Total: int(info.Size),
+ Started: &started,
+ Completed: &info.CreatedAt,
+ })
+ return
+ }
+
+ }
+}
diff --git a/vendor/github.com/moby/buildkit/util/resolver/authorizer.go b/vendor/github.com/moby/buildkit/util/resolver/authorizer.go
new file mode 100644
index 0000000..80e2a35
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/resolver/authorizer.go
@@ -0,0 +1,489 @@
+package resolver
+
+import (
+ "context"
+ "encoding/base64"
+ "fmt"
+ "net/http"
+ "sort"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/containerd/containerd/errdefs"
+ "github.com/containerd/containerd/log"
+ "github.com/containerd/containerd/remotes/docker"
+ "github.com/containerd/containerd/remotes/docker/auth"
+ remoteserrors "github.com/containerd/containerd/remotes/errors"
+ "github.com/moby/buildkit/session"
+ sessionauth "github.com/moby/buildkit/session/auth"
+ "github.com/moby/buildkit/util/flightcontrol"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+)
+
+type authHandlerNS struct {
+ counter int64 // needs to be 64bit aligned for 32bit systems
+
+ mu sync.Mutex
+ handlers map[string]*authHandler
+ hosts map[string][]docker.RegistryHost
+ sm *session.Manager
+ g flightcontrol.Group
+}
+
+func newAuthHandlerNS(sm *session.Manager) *authHandlerNS {
+ return &authHandlerNS{
+ handlers: map[string]*authHandler{},
+ hosts: map[string][]docker.RegistryHost{},
+ sm: sm,
+ }
+}
+
+func (a *authHandlerNS) get(host string, sm *session.Manager, g session.Group) *authHandler {
+ if g != nil {
+ if iter := g.SessionIterator(); iter != nil {
+ for {
+ id := iter.NextSession()
+ if id == "" {
+ break
+ }
+ h, ok := a.handlers[host+"/"+id]
+ if ok {
+ h.lastUsed = time.Now()
+ return h
+ }
+ }
+ }
+ }
+
+ // link another handler
+ for k, h := range a.handlers {
+ parts := strings.SplitN(k, "/", 2)
+ if len(parts) != 2 {
+ continue
+ }
+ if parts[0] == host {
+ if h.authority != nil {
+ session, ok, err := sessionauth.VerifyTokenAuthority(host, h.authority, sm, g)
+ if err == nil && ok {
+ a.handlers[host+"/"+session] = h
+ h.lastUsed = time.Now()
+ return h
+ }
+ } else {
+ session, username, password, err := sessionauth.CredentialsFunc(sm, g)(host)
+ if err == nil {
+ if username == h.common.Username && password == h.common.Secret {
+ a.handlers[host+"/"+session] = h
+ h.lastUsed = time.Now()
+ return h
+ }
+ }
+ }
+ }
+ }
+
+ return nil
+}
+
+func (a *authHandlerNS) set(host, session string, h *authHandler) {
+ a.handlers[host+"/"+session] = h
+}
+
+func (a *authHandlerNS) delete(h *authHandler) {
+ for k, v := range a.handlers {
+ if v == h {
+ delete(a.handlers, k)
+ }
+ }
+}
+
+type dockerAuthorizer struct {
+ client *http.Client
+
+ sm *session.Manager
+ session session.Group
+ handlers *authHandlerNS
+}
+
+func newDockerAuthorizer(client *http.Client, handlers *authHandlerNS, sm *session.Manager, group session.Group) *dockerAuthorizer {
+ return &dockerAuthorizer{
+ client: client,
+ handlers: handlers,
+ sm: sm,
+ session: group,
+ }
+}
+
+// Authorize handles auth request.
+func (a *dockerAuthorizer) Authorize(ctx context.Context, req *http.Request) error {
+ a.handlers.mu.Lock()
+ defer a.handlers.mu.Unlock()
+
+ // skip if there is no auth handler
+ ah := a.handlers.get(req.URL.Host, a.sm, a.session)
+ if ah == nil {
+ return nil
+ }
+
+ auth, err := ah.authorize(ctx, a.sm, a.session)
+ if err != nil {
+ return err
+ }
+
+ req.Header.Set("Authorization", auth)
+ return nil
+}
+
+func (a *dockerAuthorizer) getCredentials(host string) (sessionID, username, secret string, err error) {
+ return sessionauth.CredentialsFunc(a.sm, a.session)(host)
+}
+
+func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.Response) error {
+ a.handlers.mu.Lock()
+ defer a.handlers.mu.Unlock()
+
+ last := responses[len(responses)-1]
+ host := last.Request.URL.Host
+
+ handler := a.handlers.get(host, a.sm, a.session)
+
+ for _, c := range auth.ParseAuthHeader(last.Header) {
+ if c.Scheme == auth.BearerAuth {
+ var oldScopes []string
+ if err := invalidAuthorization(c, responses); err != nil {
+ a.handlers.delete(handler)
+
+ if handler != nil {
+ oldScopes = handler.common.Scopes
+ }
+ handler = nil
+
+ // this hacky way seems to be best method to detect that error is fatal and should not be retried with a new token
+ if c.Parameters["error"] == "insufficient_scope" && parseScopes(oldScopes).contains(parseScopes(strings.Split(c.Parameters["scope"], " "))) {
+ return err
+ }
+ }
+
+ // reuse existing handler
+ //
+ // assume that one registry will return the common
+ // challenge information, including realm and service.
+ // and the resource scope is only different part
+ // which can be provided by each request.
+ if handler != nil {
+ return nil
+ }
+
+ var username, secret string
+ session, pubKey, err := sessionauth.GetTokenAuthority(host, a.sm, a.session)
+ if err != nil {
+ return err
+ }
+ if pubKey == nil {
+ session, username, secret, err = a.getCredentials(host)
+ if err != nil {
+ return err
+ }
+ }
+
+ common, err := auth.GenerateTokenOptions(ctx, host, username, secret, c)
+ if err != nil {
+ return err
+ }
+ common.Scopes = parseScopes(append(common.Scopes, oldScopes...)).normalize()
+
+ a.handlers.set(host, session, newAuthHandler(host, a.client, c.Scheme, pubKey, common))
+
+ return nil
+ } else if c.Scheme == auth.BasicAuth {
+ session, username, secret, err := a.getCredentials(host)
+ if err != nil {
+ return err
+ }
+
+ if username != "" && secret != "" {
+ common := auth.TokenOptions{
+ Username: username,
+ Secret: secret,
+ }
+
+ a.handlers.set(host, session, newAuthHandler(host, a.client, c.Scheme, nil, common))
+
+ return nil
+ }
+ }
+ }
+ return errors.Wrap(errdefs.ErrNotImplemented, "failed to find supported auth scheme")
+}
+
+// authResult is used to control limit rate.
+type authResult struct {
+ sync.WaitGroup
+ token string
+ err error
+ expires time.Time
+}
+
+// authHandler is used to handle auth request per registry server.
+type authHandler struct {
+ sync.Mutex
+
+ client *http.Client
+
+ // only support basic and bearer schemes
+ scheme auth.AuthenticationScheme
+
+ // common contains common challenge answer
+ common auth.TokenOptions
+
+ // scopedTokens caches token indexed by scopes, which used in
+ // bearer auth case
+ scopedTokens map[string]*authResult
+
+ lastUsed time.Time
+
+ host string
+
+ authority *[32]byte
+}
+
+func newAuthHandler(host string, client *http.Client, scheme auth.AuthenticationScheme, authority *[32]byte, opts auth.TokenOptions) *authHandler {
+ return &authHandler{
+ host: host,
+ client: client,
+ scheme: scheme,
+ common: opts,
+ scopedTokens: map[string]*authResult{},
+ lastUsed: time.Now(),
+ authority: authority,
+ }
+}
+
+func (ah *authHandler) authorize(ctx context.Context, sm *session.Manager, g session.Group) (string, error) {
+ switch ah.scheme {
+ case auth.BasicAuth:
+ return ah.doBasicAuth(ctx)
+ case auth.BearerAuth:
+ return ah.doBearerAuth(ctx, sm, g)
+ default:
+ return "", errors.Wrapf(errdefs.ErrNotImplemented, "failed to find supported auth scheme: %s", string(ah.scheme))
+ }
+}
+
+func (ah *authHandler) doBasicAuth(ctx context.Context) (string, error) {
+ username, secret := ah.common.Username, ah.common.Secret
+
+ if username == "" || secret == "" {
+ return "", fmt.Errorf("failed to handle basic auth because missing username or secret")
+ }
+
+ auth := base64.StdEncoding.EncodeToString([]byte(username + ":" + secret))
+ return fmt.Sprintf("Basic %s", auth), nil
+}
+
+func (ah *authHandler) doBearerAuth(ctx context.Context, sm *session.Manager, g session.Group) (token string, err error) {
+ // copy common tokenOptions
+ to := ah.common
+
+ to.Scopes = parseScopes(docker.GetTokenScopes(ctx, to.Scopes)).normalize()
+
+ // Docs: https://docs.docker.com/registry/spec/auth/scope
+ scoped := strings.Join(to.Scopes, " ")
+
+ ah.Lock()
+ for {
+ r, exist := ah.scopedTokens[scoped]
+ if !exist {
+ // no entry cached
+ break
+ }
+ ah.Unlock()
+ r.Wait()
+ if r.err != nil {
+ select {
+ case <-ctx.Done():
+ return "", r.err
+ default:
+ }
+ }
+ if !errors.Is(r.err, context.Canceled) &&
+ (r.expires.IsZero() || r.expires.After(time.Now())) {
+ return r.token, r.err
+ }
+ // r.err is canceled or token expired. Get rid of it and try again
+ ah.Lock()
+ r2, exist := ah.scopedTokens[scoped]
+ if exist && r == r2 {
+ delete(ah.scopedTokens, scoped)
+ }
+ }
+
+ // only one fetch token job
+ r := new(authResult)
+ r.Add(1)
+ ah.scopedTokens[scoped] = r
+ ah.Unlock()
+
+ var issuedAt time.Time
+ var expires int
+ defer func() {
+ token = fmt.Sprintf("Bearer %s", token)
+ r.token, r.err = token, err
+ if err == nil {
+ if issuedAt.IsZero() {
+ issuedAt = time.Now()
+ }
+ if exp := issuedAt.Add(time.Duration(float64(expires)*0.9) * time.Second); time.Now().Before(exp) {
+ r.expires = exp
+ }
+ }
+ r.Done()
+ }()
+
+ if ah.authority != nil {
+ resp, err := sessionauth.FetchToken(&sessionauth.FetchTokenRequest{
+ ClientID: "buildkit-client",
+ Host: ah.host,
+ Realm: to.Realm,
+ Service: to.Service,
+ Scopes: to.Scopes,
+ }, sm, g)
+ if err != nil {
+ return "", err
+ }
+ issuedAt, expires = time.Unix(resp.IssuedAt, 0), int(resp.ExpiresIn)
+ return resp.Token, nil
+ }
+
+ // fetch token for the resource scope
+ if to.Secret != "" {
+ defer func() {
+ err = errors.Wrap(err, "failed to fetch oauth token")
+ }()
+ // try GET first because Docker Hub does not support POST
+ // switch once support has landed
+ resp, err := auth.FetchToken(ctx, ah.client, nil, to)
+ if err != nil {
+ var errStatus remoteserrors.ErrUnexpectedStatus
+ if errors.As(err, &errStatus) {
+ // retry with POST request
+ // As of September 2017, GCR is known to return 404.
+ // As of February 2018, JFrog Artifactory is known to return 401.
+ if (errStatus.StatusCode == 405 && to.Username != "") || errStatus.StatusCode == 404 || errStatus.StatusCode == 401 {
+ resp, err := auth.FetchTokenWithOAuth(ctx, ah.client, nil, "buildkit-client", to)
+ if err != nil {
+ return "", err
+ }
+ issuedAt, expires = resp.IssuedAt, resp.ExpiresIn
+ return resp.AccessToken, nil
+ }
+ log.G(ctx).WithFields(logrus.Fields{
+ "status": errStatus.Status,
+ "body": string(errStatus.Body),
+ }).Debugf("token request failed")
+ }
+ return "", err
+ }
+ issuedAt, expires = resp.IssuedAt, resp.ExpiresIn
+ return resp.Token, nil
+ }
+ // do request anonymously
+ resp, err := auth.FetchToken(ctx, ah.client, nil, to)
+ if err != nil {
+ return "", errors.Wrap(err, "failed to fetch anonymous token")
+ }
+ issuedAt, expires = resp.IssuedAt, resp.ExpiresIn
+
+ return resp.Token, nil
+}
+
+func invalidAuthorization(c auth.Challenge, responses []*http.Response) error {
+ errStr := c.Parameters["error"]
+ if errStr == "" {
+ return nil
+ }
+
+ n := len(responses)
+ if n == 1 || (n > 1 && !sameRequest(responses[n-2].Request, responses[n-1].Request)) {
+ return nil
+ }
+
+ return errors.Wrapf(docker.ErrInvalidAuthorization, "server message: %s", errStr)
+}
+
+func sameRequest(r1, r2 *http.Request) bool {
+ if r1.Method != r2.Method {
+ return false
+ }
+ if *r1.URL != *r2.URL {
+ return false
+ }
+ return true
+}
+
+type scopes map[string]map[string]struct{}
+
+func parseScopes(s []string) scopes {
+ // https://docs.docker.com/registry/spec/auth/scope/
+ m := map[string]map[string]struct{}{}
+ for _, scope := range s {
+ parts := strings.SplitN(scope, ":", 3)
+ names := []string{parts[0]}
+ if len(parts) > 1 {
+ names = append(names, parts[1])
+ }
+ var actions []string
+ if len(parts) == 3 {
+ actions = append(actions, strings.Split(parts[2], ",")...)
+ }
+ name := strings.Join(names, ":")
+ ma, ok := m[name]
+ if !ok {
+ ma = map[string]struct{}{}
+ m[name] = ma
+ }
+
+ for _, a := range actions {
+ ma[a] = struct{}{}
+ }
+ }
+ return m
+}
+
+func (s scopes) normalize() []string {
+ names := make([]string, 0, len(s))
+ for n := range s {
+ names = append(names, n)
+ }
+ sort.Strings(names)
+
+ out := make([]string, 0, len(s))
+
+ for _, n := range names {
+ actions := make([]string, 0, len(s[n]))
+ for a := range s[n] {
+ actions = append(actions, a)
+ }
+ sort.Strings(actions)
+
+ out = append(out, n+":"+strings.Join(actions, ","))
+ }
+ return out
+}
+
+func (s scopes) contains(s2 scopes) bool {
+ for n := range s2 {
+ v, ok := s[n]
+ if !ok {
+ return false
+ }
+ for a := range s2[n] {
+ if _, ok := v[a]; !ok {
+ return false
+ }
+ }
+ }
+ return true
+}
diff --git a/vendor/github.com/moby/buildkit/util/resolver/pool.go b/vendor/github.com/moby/buildkit/util/resolver/pool.go
new file mode 100644
index 0000000..20344ea
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/resolver/pool.go
@@ -0,0 +1,206 @@
+package resolver
+
+import (
+ "context"
+ "fmt"
+ "strings"
+ "sync"
+ "sync/atomic"
+ "time"
+
+ "github.com/containerd/containerd/images"
+ "github.com/containerd/containerd/remotes"
+ "github.com/containerd/containerd/remotes/docker"
+ distreference "github.com/docker/distribution/reference"
+ "github.com/moby/buildkit/session"
+ "github.com/moby/buildkit/source"
+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+)
+
+// DefaultPool is the default shared resolver pool instance
+var DefaultPool = NewPool()
+
+// Pool is a cache of recently used resolvers
+type Pool struct {
+ mu sync.Mutex
+ m map[string]*authHandlerNS
+}
+
+// NewPool creates a new pool for caching resolvers
+func NewPool() *Pool {
+ p := &Pool{
+ m: map[string]*authHandlerNS{},
+ }
+ time.AfterFunc(5*time.Minute, p.gc)
+ return p
+}
+
+func (p *Pool) gc() {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+
+ for k, ns := range p.m {
+ ns.mu.Lock()
+ for key, h := range ns.handlers {
+ if time.Since(h.lastUsed) < 10*time.Minute {
+ continue
+ }
+ parts := strings.SplitN(key, "/", 2)
+ if len(parts) != 2 {
+ delete(ns.handlers, key)
+ continue
+ }
+ c, err := ns.sm.Get(context.TODO(), parts[1], true)
+ if c == nil || err != nil {
+ delete(ns.handlers, key)
+ }
+ }
+ if len(ns.handlers) == 0 {
+ delete(p.m, k)
+ }
+ ns.mu.Unlock()
+ }
+
+ time.AfterFunc(5*time.Minute, p.gc)
+}
+
+// Clear deletes currently cached items. This may be called on config changes for example.
+func (p *Pool) Clear() {
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ p.m = map[string]*authHandlerNS{}
+}
+
+// GetResolver gets a resolver for a specified scope from the pool
+func (p *Pool) GetResolver(hosts docker.RegistryHosts, ref, scope string, sm *session.Manager, g session.Group) *Resolver {
+ name := ref
+ named, err := distreference.ParseNormalizedNamed(ref)
+ if err == nil {
+ name = named.Name()
+ }
+
+ key := fmt.Sprintf("%s::%s", name, scope)
+
+ p.mu.Lock()
+ defer p.mu.Unlock()
+ h, ok := p.m[key]
+ if !ok {
+ h = newAuthHandlerNS(sm)
+ p.m[key] = h
+ }
+ return newResolver(hosts, h, sm, g)
+}
+
+func newResolver(hosts docker.RegistryHosts, handler *authHandlerNS, sm *session.Manager, g session.Group) *Resolver {
+ if hosts == nil {
+ hosts = docker.ConfigureDefaultRegistries(
+ docker.WithClient(newDefaultClient()),
+ docker.WithPlainHTTP(docker.MatchLocalhost),
+ )
+ }
+ r := &Resolver{
+ hosts: hosts,
+ sm: sm,
+ g: g,
+ handler: handler,
+ }
+ r.Resolver = docker.NewResolver(docker.ResolverOptions{
+ Hosts: r.hostsFunc,
+ })
+ return r
+}
+
+// Resolver is a wrapper around remotes.Resolver
+type Resolver struct {
+ remotes.Resolver
+ hosts docker.RegistryHosts
+ sm *session.Manager
+ g session.Group
+ handler *authHandlerNS
+ auth *dockerAuthorizer
+
+ is images.Store
+ mode source.ResolveMode
+}
+
+func (r *Resolver) hostsFunc(host string) ([]docker.RegistryHost, error) {
+ return func(domain string) ([]docker.RegistryHost, error) {
+ v, err := r.handler.g.Do(context.TODO(), domain, func(ctx context.Context) (interface{}, error) {
+ // long lock not needed because flightcontrol.Do
+ r.handler.mu.Lock()
+ v, ok := r.handler.hosts[domain]
+ r.handler.mu.Unlock()
+ if ok {
+ return v, nil
+ }
+ res, err := r.hosts(domain)
+ if err != nil {
+ return nil, err
+ }
+ r.handler.mu.Lock()
+ r.handler.hosts[domain] = res
+ r.handler.mu.Unlock()
+ return res, nil
+ })
+ if err != nil || v == nil {
+ return nil, err
+ }
+ res := v.([]docker.RegistryHost)
+ if len(res) == 0 {
+ return nil, nil
+ }
+ auth := newDockerAuthorizer(res[0].Client, r.handler, r.sm, r.g)
+ for i := range res {
+ res[i].Authorizer = auth
+ }
+ return res, nil
+ }(host)
+}
+
+// WithSession returns a new resolver that works with new session group
+func (r *Resolver) WithSession(s session.Group) *Resolver {
+ r2 := *r
+ r2.auth = nil
+ r2.g = s
+ return &r2
+}
+
+// WithImageStore returns new resolver that can also resolve from local images store
+func (r *Resolver) WithImageStore(is images.Store, mode source.ResolveMode) *Resolver {
+ r2 := *r
+ r2.Resolver = r.Resolver
+ r2.is = is
+ r2.mode = mode
+ return &r2
+}
+
+// Fetcher returns a new fetcher for the provided reference.
+func (r *Resolver) Fetcher(ctx context.Context, ref string) (remotes.Fetcher, error) {
+ if atomic.LoadInt64(&r.handler.counter) == 0 {
+ r.Resolve(ctx, ref)
+ }
+ return r.Resolver.Fetcher(ctx, ref)
+}
+
+// Resolve attempts to resolve the reference into a name and descriptor.
+func (r *Resolver) Resolve(ctx context.Context, ref string) (string, ocispec.Descriptor, error) {
+ if r.mode == source.ResolveModePreferLocal && r.is != nil {
+ if img, err := r.is.Get(ctx, ref); err == nil {
+ return ref, img.Target, nil
+ }
+ }
+
+ n, desc, err := r.Resolver.Resolve(ctx, ref)
+ if err == nil {
+ atomic.AddInt64(&r.handler.counter, 1)
+ return n, desc, err
+ }
+
+ if r.mode == source.ResolveModeDefault && r.is != nil {
+ if img, err := r.is.Get(ctx, ref); err == nil {
+ return ref, img.Target, nil
+ }
+ }
+
+ return "", ocispec.Descriptor{}, err
+}
diff --git a/vendor/github.com/moby/buildkit/util/resolver/resolver.go b/vendor/github.com/moby/buildkit/util/resolver/resolver.go
index e7b3c97..42c940b 100644
--- a/vendor/github.com/moby/buildkit/util/resolver/resolver.go
+++ b/vendor/github.com/moby/buildkit/util/resolver/resolver.go
@@ -10,41 +10,59 @@
"path/filepath"
"runtime"
"strings"
- "sync"
"time"
- "github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
"github.com/moby/buildkit/cmd/buildkitd/config"
- "github.com/moby/buildkit/session"
- "github.com/moby/buildkit/session/auth"
"github.com/moby/buildkit/util/tracing"
"github.com/pkg/errors"
)
-func fillInsecureOpts(host string, c config.RegistryConfig, h *docker.RegistryHost) error {
+func fillInsecureOpts(host string, c config.RegistryConfig, h docker.RegistryHost) ([]docker.RegistryHost, error) {
+ var hosts []docker.RegistryHost
+
tc, err := loadTLSConfig(c)
if err != nil {
- return err
+ return nil, err
}
+ var isHTTP bool
if c.PlainHTTP != nil && *c.PlainHTTP {
- h.Scheme = "http"
- } else if c.Insecure != nil && *c.Insecure {
- tc.InsecureSkipVerify = true
- } else if c.PlainHTTP == nil {
+ isHTTP = true
+ }
+ if c.PlainHTTP == nil {
if ok, _ := docker.MatchLocalhost(host); ok {
- h.Scheme = "http"
+ isHTTP = true
}
}
- transport := newDefaultTransport()
- transport.TLSClientConfig = tc
-
- h.Client = &http.Client{
- Transport: tracing.NewTransport(transport),
+ if isHTTP {
+ h2 := h
+ h2.Scheme = "http"
+ hosts = append(hosts, h2)
}
- return nil
+ if c.Insecure != nil && *c.Insecure {
+ h2 := h
+ transport := newDefaultTransport()
+ transport.TLSClientConfig = tc
+ h2.Client = &http.Client{
+ Transport: tracing.NewTransport(transport),
+ }
+ tc.InsecureSkipVerify = true
+ hosts = append(hosts, h2)
+ }
+
+ if len(hosts) == 0 {
+ transport := newDefaultTransport()
+ transport.TLSClientConfig = tc
+
+ h.Client = &http.Client{
+ Transport: tracing.NewTransport(transport),
+ }
+ hosts = append(hosts, h)
+ }
+
+ return hosts, nil
}
func loadTLSConfig(c config.RegistryConfig) (*tls.Config, error) {
@@ -97,6 +115,7 @@
return tc, nil
}
+// NewRegistryConfig converts registry config to docker.RegistryHosts callback
func NewRegistryConfig(m map[string]config.RegistryConfig) docker.RegistryHosts {
return docker.Registries(
func(host string) ([]docker.RegistryHost, error) {
@@ -116,11 +135,12 @@
Capabilities: docker.HostCapabilityPull | docker.HostCapabilityResolve,
}
- if err := fillInsecureOpts(mirror, m[mirror], &h); err != nil {
+ hosts, err := fillInsecureOpts(mirror, m[mirror], h)
+ if err != nil {
return nil, err
}
- out = append(out, h)
+ out = append(out, hosts...)
}
if host == "docker.io" {
@@ -135,11 +155,12 @@
Capabilities: docker.HostCapabilityPush | docker.HostCapabilityPull | docker.HostCapabilityResolve,
}
- if err := fillInsecureOpts(host, c, &h); err != nil {
+ hosts, err := fillInsecureOpts(host, c, h)
+ if err != nil {
return nil, err
}
- out = append(out, h)
+ out = append(out, hosts...)
return out, nil
},
docker.ConfigureDefaultRegistries(
@@ -149,92 +170,9 @@
)
}
-type SessionAuthenticator struct {
- sm *session.Manager
- groups []session.Group
- mu sync.RWMutex
- cache map[string]credentials
- cacheMu sync.RWMutex
-}
-
-type credentials struct {
- user string
- secret string
- created time.Time
-}
-
-func NewSessionAuthenticator(sm *session.Manager, g session.Group) *SessionAuthenticator {
- return &SessionAuthenticator{sm: sm, groups: []session.Group{g}, cache: map[string]credentials{}}
-}
-
-func (a *SessionAuthenticator) credentials(h string) (string, string, error) {
- const credentialsTimeout = time.Minute
-
- a.cacheMu.RLock()
- c, ok := a.cache[h]
- if ok && time.Since(c.created) < credentialsTimeout {
- a.cacheMu.RUnlock()
- return c.user, c.secret, nil
- }
- a.cacheMu.RUnlock()
-
- a.mu.RLock()
- defer a.mu.RUnlock()
-
- var err error
- for i := len(a.groups) - 1; i >= 0; i-- {
- var user, secret string
- user, secret, err = auth.CredentialsFunc(a.sm, a.groups[i])(h)
- if err != nil {
- continue
- }
- a.cacheMu.Lock()
- a.cache[h] = credentials{user: user, secret: secret, created: time.Now()}
- a.cacheMu.Unlock()
- return user, secret, nil
- }
- return "", "", err
-}
-
-func (a *SessionAuthenticator) AddSession(g session.Group) {
- a.mu.Lock()
- a.groups = append(a.groups, g)
- a.mu.Unlock()
-}
-
-func New(hosts docker.RegistryHosts, auth *SessionAuthenticator) remotes.Resolver {
- return docker.NewResolver(docker.ResolverOptions{
- Hosts: hostsWithCredentials(hosts, auth),
- })
-}
-
-func hostsWithCredentials(hosts docker.RegistryHosts, auth *SessionAuthenticator) docker.RegistryHosts {
- if hosts == nil {
- return nil
- }
- return func(domain string) ([]docker.RegistryHost, error) {
- res, err := hosts(domain)
- if err != nil {
- return nil, err
- }
- if len(res) == 0 {
- return nil, nil
- }
-
- a := docker.NewDockerAuthorizer(
- docker.WithAuthClient(res[0].Client),
- docker.WithAuthCreds(auth.credentials),
- )
- for i := range res {
- res[i].Authorizer = a
- }
- return res, nil
- }
-}
-
func newDefaultClient() *http.Client {
return &http.Client{
- Transport: newDefaultTransport(),
+ Transport: tracing.NewTransport(newDefaultTransport()),
}
}
@@ -250,14 +188,12 @@
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
- KeepAlive: 30 * time.Second,
- DualStack: true,
+ KeepAlive: 60 * time.Second,
}).DialContext,
MaxIdleConns: 10,
IdleConnTimeout: 30 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 5 * time.Second,
- DisableKeepAlives: true,
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),
}
}
diff --git a/vendor/github.com/moby/buildkit/util/rootless/specconv/specconv_nonlinux.go b/vendor/github.com/moby/buildkit/util/rootless/specconv/specconv_nonlinux.go
new file mode 100644
index 0000000..bb08ec1
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/rootless/specconv/specconv_nonlinux.go
@@ -0,0 +1,19 @@
+// +build !linux
+
+package specconv
+
+import (
+ "runtime"
+
+ "github.com/opencontainers/runtime-spec/specs-go"
+ "github.com/pkg/errors"
+)
+
+// ToRootless converts spec to be compatible with "rootless" runc.
+// * Remove /sys mount
+// * Remove cgroups
+//
+// See docs/rootless.md for the supported runc revision.
+func ToRootless(spec *specs.Spec) error {
+ return errors.Errorf("not implemented on on %s", runtime.GOOS)
+}
diff --git a/vendor/github.com/moby/buildkit/util/stack/stack.go b/vendor/github.com/moby/buildkit/util/stack/stack.go
index 6d3cfc8..3409ac0 100644
--- a/vendor/github.com/moby/buildkit/util/stack/stack.go
+++ b/vendor/github.com/moby/buildkit/util/stack/stack.go
@@ -4,12 +4,24 @@
"fmt"
io "io"
"os"
+ "runtime"
"strconv"
"strings"
+ "sync"
+ "github.com/containerd/typeurl"
"github.com/pkg/errors"
)
+var helpers map[string]struct{}
+var helpersMu sync.RWMutex
+
+func init() {
+ typeurl.Register((*Stack)(nil), "github.com/moby/buildkit", "stack.Stack+json")
+
+ helpers = map[string]struct{}{}
+}
+
var version string
var revision string
@@ -18,6 +30,19 @@
revision = r
}
+func Helper() {
+ var pc [1]uintptr
+ n := runtime.Callers(2, pc[:])
+ if n == 0 {
+ return
+ }
+ frames := runtime.CallersFrames(pc[:n])
+ frame, _ := frames.Next()
+ helpersMu.Lock()
+ helpers[frame.Function] = struct{}{}
+ helpersMu.Unlock()
+}
+
func Traces(err error) []*Stack {
var st []*Stack
@@ -47,6 +72,7 @@
if err == nil {
return nil
}
+ Helper()
if !hasLocalStackTrace(err) {
return errors.WithStack(err)
}
@@ -107,6 +133,8 @@
func convertStack(s errors.StackTrace) *Stack {
var out Stack
+ helpersMu.RLock()
+ defer helpersMu.RUnlock()
for _, f := range s {
dt, err := f.MarshalText()
if err != nil {
@@ -116,6 +144,9 @@
if len(p) != 2 {
continue
}
+ if _, ok := helpers[p[0]]; ok {
+ continue
+ }
idx := strings.LastIndexByte(p[1], ':')
if idx == -1 {
continue
diff --git a/vendor/github.com/moby/buildkit/util/system/path.go b/vendor/github.com/moby/buildkit/util/system/path.go
new file mode 100644
index 0000000..f6dc70d
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/system/path.go
@@ -0,0 +1,18 @@
+package system
+
+// DefaultPathEnvUnix is unix style list of directories to search for
+// executables. Each directory is separated from the next by a colon
+// ':' character .
+const DefaultPathEnvUnix = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+
+// DefaultPathEnvWindows is windows style list of directories to search for
+// executables. Each directory is separated from the next by a colon
+// ';' character .
+const DefaultPathEnvWindows = "c:\\Windows\\System32;c:\\Windows"
+
+func DefaultPathEnv(os string) string {
+ if os == "windows" {
+ return DefaultPathEnvWindows
+ }
+ return DefaultPathEnvUnix
+}
diff --git a/vendor/github.com/moby/buildkit/util/system/path_unix.go b/vendor/github.com/moby/buildkit/util/system/path_unix.go
index c607c4d..f3762e6 100644
--- a/vendor/github.com/moby/buildkit/util/system/path_unix.go
+++ b/vendor/github.com/moby/buildkit/util/system/path_unix.go
@@ -2,11 +2,6 @@
package system
-// DefaultPathEnv is unix style list of directories to search for
-// executables. Each directory is separated from the next by a colon
-// ':' character .
-const DefaultPathEnv = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
-
// CheckSystemDriveAndRemoveDriveLetter verifies that a path, if it includes a drive letter,
// is the system drive. This is a no-op on Linux.
func CheckSystemDriveAndRemoveDriveLetter(path string) (string, error) {
diff --git a/vendor/github.com/moby/buildkit/util/system/path_windows.go b/vendor/github.com/moby/buildkit/util/system/path_windows.go
index cbfe2c1..3fc4744 100644
--- a/vendor/github.com/moby/buildkit/util/system/path_windows.go
+++ b/vendor/github.com/moby/buildkit/util/system/path_windows.go
@@ -8,10 +8,6 @@
"strings"
)
-// DefaultPathEnv is deliberately empty on Windows as the default path will be set by
-// the container. Docker has no context of what the default path should be.
-const DefaultPathEnv = ""
-
// CheckSystemDriveAndRemoveDriveLetter verifies and manipulates a Windows path.
// This is used, for example, when validating a user provided path in docker cp.
// If a drive letter is supplied, it must be the system drive. The drive letter
diff --git a/vendor/github.com/moby/buildkit/util/throttle/throttle.go b/vendor/github.com/moby/buildkit/util/throttle/throttle.go
index 490ccd9..dfc4aef 100644
--- a/vendor/github.com/moby/buildkit/util/throttle/throttle.go
+++ b/vendor/github.com/moby/buildkit/util/throttle/throttle.go
@@ -11,10 +11,10 @@
return throttle(d, f, true)
}
-// ThrottleAfter wraps a function so that internal function does not get called
+// After wraps a function so that internal function does not get called
// more frequently than the specified duration. The delay is added after function
// has been called.
-func ThrottleAfter(d time.Duration, f func()) func() {
+func After(d time.Duration, f func()) func() {
return throttle(d, f, false)
}
diff --git a/vendor/github.com/moby/buildkit/util/winlayers/applier.go b/vendor/github.com/moby/buildkit/util/winlayers/applier.go
new file mode 100644
index 0000000..91e4152
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/winlayers/applier.go
@@ -0,0 +1,187 @@
+package winlayers
+
+import (
+ "archive/tar"
+ "context"
+ "io"
+ "io/ioutil"
+ "runtime"
+ "strings"
+ "sync"
+
+ "github.com/containerd/containerd/archive"
+ "github.com/containerd/containerd/archive/compression"
+ "github.com/containerd/containerd/content"
+ "github.com/containerd/containerd/diff"
+ "github.com/containerd/containerd/errdefs"
+ "github.com/containerd/containerd/images"
+ "github.com/containerd/containerd/mount"
+ digest "github.com/opencontainers/go-digest"
+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/pkg/errors"
+)
+
+func NewFileSystemApplierWithWindows(cs content.Provider, a diff.Applier) diff.Applier {
+ if runtime.GOOS == "windows" {
+ return a
+ }
+
+ return &winApplier{
+ cs: cs,
+ a: a,
+ }
+}
+
+type winApplier struct {
+ cs content.Provider
+ a diff.Applier
+}
+
+func (s *winApplier) Apply(ctx context.Context, desc ocispec.Descriptor, mounts []mount.Mount, opts ...diff.ApplyOpt) (d ocispec.Descriptor, err error) {
+ if !hasWindowsLayerMode(ctx) {
+ return s.a.Apply(ctx, desc, mounts, opts...)
+ }
+
+ compressed, err := images.DiffCompression(ctx, desc.MediaType)
+ if err != nil {
+ return ocispec.Descriptor{}, errors.Wrapf(errdefs.ErrNotImplemented, "unsupported diff media type: %v", desc.MediaType)
+ }
+
+ var ocidesc ocispec.Descriptor
+ if err := mount.WithTempMount(ctx, mounts, func(root string) error {
+ ra, err := s.cs.ReaderAt(ctx, desc)
+ if err != nil {
+ return errors.Wrap(err, "failed to get reader from content store")
+ }
+ defer ra.Close()
+
+ r := content.NewReader(ra)
+ if compressed != "" {
+ ds, err := compression.DecompressStream(r)
+ if err != nil {
+ return err
+ }
+ defer ds.Close()
+ r = ds
+ }
+
+ digester := digest.Canonical.Digester()
+ rc := &readCounter{
+ r: io.TeeReader(r, digester.Hash()),
+ }
+
+ rc2, discard := filter(rc, func(hdr *tar.Header) bool {
+ if strings.HasPrefix(hdr.Name, "Files/") {
+ hdr.Name = strings.TrimPrefix(hdr.Name, "Files/")
+ hdr.Linkname = strings.TrimPrefix(hdr.Linkname, "Files/")
+ // TODO: could convert the windows PAX headers to xattr here to reuse
+ // the original ones in diff for parent directories and file modifications
+ return true
+ }
+ return false
+ })
+
+ if _, err := archive.Apply(ctx, root, rc2); err != nil {
+ discard(err)
+ return err
+ }
+
+ // Read any trailing data
+ if _, err := io.Copy(ioutil.Discard, rc); err != nil {
+ discard(err)
+ return err
+ }
+
+ ocidesc = ocispec.Descriptor{
+ MediaType: ocispec.MediaTypeImageLayer,
+ Size: rc.c,
+ Digest: digester.Digest(),
+ }
+ return nil
+
+ }); err != nil {
+ return ocispec.Descriptor{}, err
+ }
+ return ocidesc, nil
+}
+
+type readCounter struct {
+ r io.Reader
+ c int64
+}
+
+func (rc *readCounter) Read(p []byte) (n int, err error) {
+ n, err = rc.r.Read(p)
+ rc.c += int64(n)
+ return
+}
+
+func filter(in io.Reader, f func(*tar.Header) bool) (io.Reader, func(error)) {
+ pr, pw := io.Pipe()
+
+ rc := &readCanceler{Reader: in}
+
+ go func() {
+ tarReader := tar.NewReader(rc)
+ tarWriter := tar.NewWriter(pw)
+
+ pw.CloseWithError(func() error {
+ for {
+ h, err := tarReader.Next()
+ if err == io.EOF {
+ break
+ }
+ if err != nil {
+ return err
+ }
+ if f(h) {
+ if err := tarWriter.WriteHeader(h); err != nil {
+ return err
+ }
+ if h.Size > 0 {
+ if _, err := io.Copy(tarWriter, tarReader); err != nil {
+ return err
+ }
+ }
+ } else {
+ if h.Size > 0 {
+ if _, err := io.Copy(ioutil.Discard, tarReader); err != nil {
+ return err
+ }
+ }
+ }
+ }
+ return tarWriter.Close()
+ }())
+ }()
+
+ discard := func(err error) {
+ rc.cancel(err)
+ pw.CloseWithError(err)
+ }
+
+ return pr, discard
+}
+
+type readCanceler struct {
+ mu sync.Mutex
+ io.Reader
+ err error
+}
+
+func (r *readCanceler) Read(b []byte) (int, error) {
+ r.mu.Lock()
+ if r.err != nil {
+ r.mu.Unlock()
+ return 0, r.err
+ }
+ n, err := r.Reader.Read(b)
+ r.mu.Unlock()
+ return n, err
+}
+
+func (r *readCanceler) cancel(err error) {
+ r.mu.Lock()
+ r.err = err
+ r.mu.Unlock()
+}
diff --git a/vendor/github.com/moby/buildkit/util/winlayers/context.go b/vendor/github.com/moby/buildkit/util/winlayers/context.go
new file mode 100644
index 0000000..c0bd3f8
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/winlayers/context.go
@@ -0,0 +1,19 @@
+package winlayers
+
+import "context"
+
+type contextKeyT string
+
+var contextKey = contextKeyT("buildkit/winlayers-on")
+
+func UseWindowsLayerMode(ctx context.Context) context.Context {
+ return context.WithValue(ctx, contextKey, true)
+}
+
+func hasWindowsLayerMode(ctx context.Context) bool {
+ v := ctx.Value(contextKey)
+ if v == nil {
+ return false
+ }
+ return true
+}
diff --git a/vendor/github.com/moby/buildkit/util/winlayers/differ.go b/vendor/github.com/moby/buildkit/util/winlayers/differ.go
new file mode 100644
index 0000000..cdbc335
--- /dev/null
+++ b/vendor/github.com/moby/buildkit/util/winlayers/differ.go
@@ -0,0 +1,274 @@
+package winlayers
+
+import (
+ "archive/tar"
+ "context"
+ "crypto/rand"
+ "encoding/base64"
+ "fmt"
+ "io"
+ "time"
+
+ "github.com/containerd/containerd/archive"
+ "github.com/containerd/containerd/archive/compression"
+ "github.com/containerd/containerd/content"
+ "github.com/containerd/containerd/diff"
+ "github.com/containerd/containerd/errdefs"
+ "github.com/containerd/containerd/log"
+ "github.com/containerd/containerd/mount"
+ digest "github.com/opencontainers/go-digest"
+ ocispec "github.com/opencontainers/image-spec/specs-go/v1"
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+)
+
+const (
+ keyFileAttr = "MSWINDOWS.fileattr"
+ keySDRaw = "MSWINDOWS.rawsd"
+ keyCreationTime = "LIBARCHIVE.creationtime"
+)
+
+func NewWalkingDiffWithWindows(store content.Store, d diff.Comparer) diff.Comparer {
+ return &winDiffer{
+ store: store,
+ d: d,
+ }
+}
+
+var emptyDesc = ocispec.Descriptor{}
+
+type winDiffer struct {
+ store content.Store
+ d diff.Comparer
+}
+
+// Compare creates a diff between the given mounts and uploads the result
+// to the content store.
+func (s *winDiffer) Compare(ctx context.Context, lower, upper []mount.Mount, opts ...diff.Opt) (d ocispec.Descriptor, err error) {
+ if !hasWindowsLayerMode(ctx) {
+ return s.d.Compare(ctx, lower, upper, opts...)
+ }
+
+ var config diff.Config
+ for _, opt := range opts {
+ if err := opt(&config); err != nil {
+ return emptyDesc, err
+ }
+ }
+
+ if config.MediaType == "" {
+ config.MediaType = ocispec.MediaTypeImageLayerGzip
+ }
+
+ var isCompressed bool
+ switch config.MediaType {
+ case ocispec.MediaTypeImageLayer:
+ case ocispec.MediaTypeImageLayerGzip:
+ isCompressed = true
+ default:
+ return emptyDesc, errors.Wrapf(errdefs.ErrNotImplemented, "unsupported diff media type: %v", config.MediaType)
+ }
+
+ var ocidesc ocispec.Descriptor
+ if err := mount.WithTempMount(ctx, lower, func(lowerRoot string) error {
+ return mount.WithTempMount(ctx, upper, func(upperRoot string) error {
+ var newReference bool
+ if config.Reference == "" {
+ newReference = true
+ config.Reference = uniqueRef()
+ }
+
+ cw, err := s.store.Writer(ctx,
+ content.WithRef(config.Reference),
+ content.WithDescriptor(ocispec.Descriptor{
+ MediaType: config.MediaType, // most contentstore implementations just ignore this
+ }))
+ if err != nil {
+ return errors.Wrap(err, "failed to open writer")
+ }
+ defer func() {
+ if err != nil {
+ cw.Close()
+ if newReference {
+ if err := s.store.Abort(ctx, config.Reference); err != nil {
+ log.G(ctx).WithField("ref", config.Reference).Warnf("failed to delete diff upload")
+ }
+ }
+ }
+ }()
+ if !newReference {
+ if err := cw.Truncate(0); err != nil {
+ return err
+ }
+ }
+
+ if isCompressed {
+ dgstr := digest.SHA256.Digester()
+ compressed, err := compression.CompressStream(cw, compression.Gzip)
+ if err != nil {
+ return errors.Wrap(err, "failed to get compressed stream")
+ }
+ var w io.Writer = io.MultiWriter(compressed, dgstr.Hash())
+ w, discard, done := makeWindowsLayer(w)
+ err = archive.WriteDiff(ctx, w, lowerRoot, upperRoot)
+ if err != nil {
+ discard(err)
+ }
+ <-done
+ compressed.Close()
+ if err != nil {
+ return errors.Wrap(err, "failed to write compressed diff")
+ }
+
+ if config.Labels == nil {
+ config.Labels = map[string]string{}
+ }
+ config.Labels["containerd.io/uncompressed"] = dgstr.Digest().String()
+ } else {
+ w, discard, done := makeWindowsLayer(cw)
+ if err = archive.WriteDiff(ctx, w, lowerRoot, upperRoot); err != nil {
+ discard(err)
+ return errors.Wrap(err, "failed to write diff")
+ }
+ <-done
+ }
+
+ var commitopts []content.Opt
+ if config.Labels != nil {
+ commitopts = append(commitopts, content.WithLabels(config.Labels))
+ }
+
+ dgst := cw.Digest()
+ if err := cw.Commit(ctx, 0, dgst, commitopts...); err != nil {
+ return errors.Wrap(err, "failed to commit")
+ }
+
+ info, err := s.store.Info(ctx, dgst)
+ if err != nil {
+ return errors.Wrap(err, "failed to get info from content store")
+ }
+
+ ocidesc = ocispec.Descriptor{
+ MediaType: config.MediaType,
+ Size: info.Size,
+ Digest: info.Digest,
+ }
+ return nil
+ })
+ }); err != nil {
+ return emptyDesc, err
+ }
+
+ return ocidesc, nil
+}
+
+func uniqueRef() string {
+ t := time.Now()
+ var b [3]byte
+ // Ignore read failures, just decreases uniqueness
+ rand.Read(b[:])
+ return fmt.Sprintf("%d-%s", t.UnixNano(), base64.URLEncoding.EncodeToString(b[:]))
+}
+
+func prepareWinHeader(h *tar.Header) {
+ if h.PAXRecords == nil {
+ h.PAXRecords = map[string]string{}
+ }
+ if h.Typeflag == tar.TypeDir {
+ h.Mode |= 1 << 14
+ h.PAXRecords[keyFileAttr] = "16"
+ }
+
+ if h.Typeflag == tar.TypeReg {
+ h.Mode |= 1 << 15
+ h.PAXRecords[keyFileAttr] = "32"
+ }
+
+ if !h.ModTime.IsZero() {
+ h.PAXRecords[keyCreationTime] = fmt.Sprintf("%d.%d", h.ModTime.Unix(), h.ModTime.Nanosecond())
+ }
+
+ h.Format = tar.FormatPAX
+}
+
+func addSecurityDescriptor(h *tar.Header) {
+ if h.Typeflag == tar.TypeDir {
+ // O:BAG:SYD:(A;OICI;FA;;;BA)(A;OICI;FA;;;SY)(A;;FA;;;BA)(A;OICIIO;GA;;;CO)(A;OICI;0x1200a9;;;BU)(A;CI;LC;;;BU)(A;CI;DC;;;BU)
+ h.PAXRecords[keySDRaw] = "AQAEgBQAAAAkAAAAAAAAADAAAAABAgAAAAAABSAAAAAgAgAAAQEAAAAAAAUSAAAAAgCoAAcAAAAAAxgA/wEfAAECAAAAAAAFIAAAACACAAAAAxQA/wEfAAEBAAAAAAAFEgAAAAAAGAD/AR8AAQIAAAAAAAUgAAAAIAIAAAALFAAAAAAQAQEAAAAAAAMAAAAAAAMYAKkAEgABAgAAAAAABSAAAAAhAgAAAAIYAAQAAAABAgAAAAAABSAAAAAhAgAAAAIYAAIAAAABAgAAAAAABSAAAAAhAgAA"
+ }
+
+ if h.Typeflag == tar.TypeReg {
+ // O:BAG:SYD:(A;;FA;;;BA)(A;;FA;;;SY)(A;;0x1200a9;;;BU)
+ h.PAXRecords[keySDRaw] = "AQAEgBQAAAAkAAAAAAAAADAAAAABAgAAAAAABSAAAAAgAgAAAQEAAAAAAAUSAAAAAgBMAAMAAAAAABgA/wEfAAECAAAAAAAFIAAAACACAAAAABQA/wEfAAEBAAAAAAAFEgAAAAAAGACpABIAAQIAAAAAAAUgAAAAIQIAAA=="
+ }
+}
+
+func makeWindowsLayer(w io.Writer) (io.Writer, func(error), chan error) {
+ pr, pw := io.Pipe()
+ done := make(chan error)
+
+ go func() {
+ tarReader := tar.NewReader(pr)
+ tarWriter := tar.NewWriter(w)
+
+ err := func() error {
+
+ h := &tar.Header{
+ Name: "Hives",
+ Typeflag: tar.TypeDir,
+ ModTime: time.Now(),
+ }
+ prepareWinHeader(h)
+ if err := tarWriter.WriteHeader(h); err != nil {
+ return err
+ }
+
+ h = &tar.Header{
+ Name: "Files",
+ Typeflag: tar.TypeDir,
+ ModTime: time.Now(),
+ }
+ prepareWinHeader(h)
+ if err := tarWriter.WriteHeader(h); err != nil {
+ return err
+ }
+
+ for {
+ h, err := tarReader.Next()
+ if err == io.EOF {
+ break
+ }
+ if err != nil {
+ return err
+ }
+ h.Name = "Files/" + h.Name
+ if h.Linkname != "" {
+ h.Linkname = "Files/" + h.Linkname
+ }
+ prepareWinHeader(h)
+ addSecurityDescriptor(h)
+ if err := tarWriter.WriteHeader(h); err != nil {
+ return err
+ }
+ if h.Size > 0 {
+ if _, err := io.Copy(tarWriter, tarReader); err != nil {
+ return err
+ }
+ }
+ }
+ return tarWriter.Close()
+ }()
+ if err != nil {
+ logrus.Errorf("makeWindowsLayer %+v", err)
+ }
+ pw.CloseWithError(err)
+ done <- err
+ return
+ }()
+
+ discard := func(err error) {
+ pw.CloseWithError(err)
+ }
+
+ return pw, discard, done
+}
diff --git a/vendor/github.com/moby/buildkit/worker/cacheresult.go b/vendor/github.com/moby/buildkit/worker/cacheresult.go
index d0ee1a2..0e684e7 100644
--- a/vendor/github.com/moby/buildkit/worker/cacheresult.go
+++ b/vendor/github.com/moby/buildkit/worker/cacheresult.go
@@ -6,7 +6,9 @@
"time"
"github.com/moby/buildkit/cache"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/util/compression"
"github.com/pkg/errors"
)
@@ -36,7 +38,7 @@
return solver.CacheResult{ID: ref.ID(), CreatedAt: createdAt}, nil
}
func (s *cacheResultStorage) Load(ctx context.Context, res solver.CacheResult) (solver.Result, error) {
- return s.load(res.ID, false)
+ return s.load(ctx, res.ID, false)
}
func (s *cacheResultStorage) getWorkerRef(id string) (Worker, string, error) {
@@ -51,7 +53,7 @@
return w, refID, nil
}
-func (s *cacheResultStorage) load(id string, hidden bool) (solver.Result, error) {
+func (s *cacheResultStorage) load(ctx context.Context, id string, hidden bool) (solver.Result, error) {
w, refID, err := s.getWorkerRef(id)
if err != nil {
return nil, err
@@ -59,31 +61,32 @@
if refID == "" {
return NewWorkerRefResult(nil, w), nil
}
- ref, err := w.LoadRef(refID, hidden)
+ ref, err := w.LoadRef(ctx, refID, hidden)
if err != nil {
return nil, err
}
return NewWorkerRefResult(ref, w), nil
}
-func (s *cacheResultStorage) LoadRemote(ctx context.Context, res solver.CacheResult) (*solver.Remote, error) {
+func (s *cacheResultStorage) LoadRemote(ctx context.Context, res solver.CacheResult, g session.Group) (*solver.Remote, error) {
w, refID, err := s.getWorkerRef(res.ID)
if err != nil {
return nil, err
}
- ref, err := w.LoadRef(refID, true)
+ ref, err := w.LoadRef(ctx, refID, true)
if err != nil {
return nil, err
}
defer ref.Release(context.TODO())
- remote, err := w.GetRemote(ctx, ref, false)
+ wref := WorkerRef{ref, w}
+ remote, err := wref.GetRemote(ctx, false, compression.Default, g)
if err != nil {
return nil, nil // ignore error. loadRemote is best effort
}
return remote, nil
}
func (s *cacheResultStorage) Exists(id string) bool {
- ref, err := s.load(id, true)
+ ref, err := s.load(context.TODO(), id, true)
if err != nil {
return false
}
diff --git a/vendor/github.com/moby/buildkit/worker/result.go b/vendor/github.com/moby/buildkit/worker/result.go
index 9aa6af4..e178ef3 100644
--- a/vendor/github.com/moby/buildkit/worker/result.go
+++ b/vendor/github.com/moby/buildkit/worker/result.go
@@ -4,7 +4,9 @@
"context"
"github.com/moby/buildkit/cache"
+ "github.com/moby/buildkit/session"
"github.com/moby/buildkit/solver"
+ "github.com/moby/buildkit/util/compression"
)
func NewWorkerRefResult(ref cache.ImmutableRef, worker Worker) solver.Result {
@@ -24,6 +26,18 @@
return wr.Worker.ID() + "::" + refID
}
+// GetRemote method abstracts ImmutableRef's GetRemote to allow a Worker to override.
+// This is needed for moby integration.
+// Use this method instead of calling ImmutableRef.GetRemote() directly.
+func (wr *WorkerRef) GetRemote(ctx context.Context, createIfNeeded bool, compressionType compression.Type, g session.Group) (*solver.Remote, error) {
+ if w, ok := wr.Worker.(interface {
+ GetRemote(context.Context, cache.ImmutableRef, bool, compression.Type, session.Group) (*solver.Remote, error)
+ }); ok {
+ return w.GetRemote(ctx, wr.ImmutableRef, createIfNeeded, compressionType, g)
+ }
+ return wr.ImmutableRef.GetRemote(ctx, createIfNeeded, compressionType, g)
+}
+
type workerRefResult struct {
*WorkerRef
}
diff --git a/vendor/github.com/moby/buildkit/worker/worker.go b/vendor/github.com/moby/buildkit/worker/worker.go
index bc095bc..a34e598 100644
--- a/vendor/github.com/moby/buildkit/worker/worker.go
+++ b/vendor/github.com/moby/buildkit/worker/worker.go
@@ -5,6 +5,7 @@
"github.com/containerd/containerd/content"
"github.com/moby/buildkit/cache"
+ "github.com/moby/buildkit/cache/metadata"
"github.com/moby/buildkit/client"
"github.com/moby/buildkit/client/llb"
"github.com/moby/buildkit/executor"
@@ -23,19 +24,19 @@
Platforms(noCache bool) []specs.Platform
GCPolicy() []client.PruneInfo
- LoadRef(id string, hidden bool) (cache.ImmutableRef, error)
+ LoadRef(ctx context.Context, id string, hidden bool) (cache.ImmutableRef, error)
// ResolveOp resolves Vertex.Sys() to Op implementation.
ResolveOp(v solver.Vertex, s frontend.FrontendLLBBridge, sm *session.Manager) (solver.Op, error)
ResolveImageConfig(ctx context.Context, ref string, opt llb.ResolveImageConfigOpt, sm *session.Manager, g session.Group) (digest.Digest, []byte, error)
DiskUsage(ctx context.Context, opt client.DiskUsageInfo) ([]*client.UsageInfo, error)
Exporter(name string, sm *session.Manager) (exporter.Exporter, error)
Prune(ctx context.Context, ch chan client.UsageInfo, opt ...client.PruneInfo) error
- GetRemote(ctx context.Context, ref cache.ImmutableRef, createIfNeeded bool) (*solver.Remote, error)
FromRemote(ctx context.Context, remote *solver.Remote) (cache.ImmutableRef, error)
PruneCacheMounts(ctx context.Context, ids []string) error
ContentStore() content.Store
Executor() executor.Executor
CacheManager() cache.Manager
+ MetadataStore() *metadata.Store
}
// Pre-defined label keys
diff --git a/vendor/github.com/moby/sys/mount/doc.go b/vendor/github.com/moby/sys/mount/doc.go
new file mode 100644
index 0000000..86c2e01
--- /dev/null
+++ b/vendor/github.com/moby/sys/mount/doc.go
@@ -0,0 +1,4 @@
+// Package mount provides a set of functions to mount and unmount mounts.
+//
+// Currently it supports Linux. For historical reasons, there is also some support for FreeBSD.
+package mount
diff --git a/vendor/github.com/moby/sys/mount/flags_freebsd.go b/vendor/github.com/moby/sys/mount/flags_bsd.go
similarity index 79%
rename from vendor/github.com/moby/sys/mount/flags_freebsd.go
rename to vendor/github.com/moby/sys/mount/flags_bsd.go
index 69c5068..27d8440 100644
--- a/vendor/github.com/moby/sys/mount/flags_freebsd.go
+++ b/vendor/github.com/moby/sys/mount/flags_bsd.go
@@ -1,28 +1,25 @@
-// +build freebsd,cgo
+// +build freebsd openbsd
package mount
-/*
-#include <sys/mount.h>
-*/
-import "C"
+import "golang.org/x/sys/unix"
const (
// RDONLY will mount the filesystem as read-only.
- RDONLY = C.MNT_RDONLY
+ RDONLY = unix.MNT_RDONLY
// NOSUID will not allow set-user-identifier or set-group-identifier bits to
// take effect.
- NOSUID = C.MNT_NOSUID
+ NOSUID = unix.MNT_NOSUID
// NOEXEC will not allow execution of any binaries on the mounted file system.
- NOEXEC = C.MNT_NOEXEC
+ NOEXEC = unix.MNT_NOEXEC
// SYNCHRONOUS will allow any I/O to the file system to be done synchronously.
- SYNCHRONOUS = C.MNT_SYNCHRONOUS
+ SYNCHRONOUS = unix.MNT_SYNCHRONOUS
// NOATIME will not update the file access time when reading from a file.
- NOATIME = C.MNT_NOATIME
+ NOATIME = unix.MNT_NOATIME
)
// These flags are unsupported.
diff --git a/vendor/github.com/moby/sys/mount/flags.go b/vendor/github.com/moby/sys/mount/flags_unix.go
similarity index 98%
rename from vendor/github.com/moby/sys/mount/flags.go
rename to vendor/github.com/moby/sys/mount/flags_unix.go
index d514a9d..995d728 100644
--- a/vendor/github.com/moby/sys/mount/flags.go
+++ b/vendor/github.com/moby/sys/mount/flags_unix.go
@@ -1,3 +1,5 @@
+// +build !darwin,!windows
+
package mount
import (
diff --git a/vendor/github.com/moby/sys/mount/flags_unsupported.go b/vendor/github.com/moby/sys/mount/flags_unsupported.go
deleted file mode 100644
index e1d64f6..0000000
--- a/vendor/github.com/moby/sys/mount/flags_unsupported.go
+++ /dev/null
@@ -1,30 +0,0 @@
-// +build !linux,!freebsd freebsd,!cgo
-
-package mount
-
-// These flags are unsupported.
-const (
- BIND = 0
- DIRSYNC = 0
- MANDLOCK = 0
- NOATIME = 0
- NODEV = 0
- NODIRATIME = 0
- NOEXEC = 0
- NOSUID = 0
- UNBINDABLE = 0
- RUNBINDABLE = 0
- PRIVATE = 0
- RPRIVATE = 0
- SHARED = 0
- RSHARED = 0
- SLAVE = 0
- RSLAVE = 0
- RBIND = 0
- RELATIME = 0
- REMOUNT = 0
- STRICTATIME = 0
- SYNCHRONOUS = 0
- RDONLY = 0
- mntDetach = 0
-)
diff --git a/vendor/github.com/moby/sys/mount/go.mod b/vendor/github.com/moby/sys/mount/go.mod
index 21cef0a..749327a 100644
--- a/vendor/github.com/moby/sys/mount/go.mod
+++ b/vendor/github.com/moby/sys/mount/go.mod
@@ -3,6 +3,6 @@
go 1.14
require (
- github.com/moby/sys/mountinfo v0.1.0
- golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae
+ github.com/moby/sys/mountinfo v0.3.1
+ golang.org/x/sys v0.0.0-20200922070232-aee5d888a860
)
diff --git a/vendor/github.com/moby/sys/mount/mount.go b/vendor/github.com/moby/sys/mount/mount.go
deleted file mode 100644
index 883f8df..0000000
--- a/vendor/github.com/moby/sys/mount/mount.go
+++ /dev/null
@@ -1,56 +0,0 @@
-// +build go1.13
-
-package mount
-
-import (
- "fmt"
- "sort"
-
- "github.com/moby/sys/mountinfo"
-)
-
-// Mount will mount filesystem according to the specified configuration.
-// Options must be specified like the mount or fstab unix commands:
-// "opt1=val1,opt2=val2". See flags.go for supported option flags.
-func Mount(device, target, mType, options string) error {
- flag, data := parseOptions(options)
- return mount(device, target, mType, uintptr(flag), data)
-}
-
-// Unmount lazily unmounts a filesystem on supported platforms, otherwise
-// does a normal unmount.
-func Unmount(target string) error {
- return unmount(target, mntDetach)
-}
-
-// RecursiveUnmount unmounts the target and all mounts underneath, starting with
-// the deepsest mount first.
-func RecursiveUnmount(target string) error {
- mounts, err := mountinfo.GetMounts(mountinfo.PrefixFilter(target))
- if err != nil {
- return err
- }
-
- // Make the deepest mount be first
- sort.Slice(mounts, func(i, j int) bool {
- return len(mounts[i].Mountpoint) > len(mounts[j].Mountpoint)
- })
-
- var suberr error
- for i, m := range mounts {
- err = unmount(m.Mountpoint, mntDetach)
- if err != nil {
- if i == len(mounts)-1 { // last mount
- return fmt.Errorf("%w (possible cause: %s)", err, suberr)
- }
- // This is a submount, we can ignore the error for now,
- // the final unmount will fail if this is a real problem.
- // With that in mind, the _first_ failed unmount error
- // might be the real error cause, so let's keep it.
- if suberr == nil {
- suberr = err
- }
- }
- }
- return nil
-}
diff --git a/vendor/github.com/moby/sys/mount/mount_unix.go b/vendor/github.com/moby/sys/mount/mount_unix.go
new file mode 100644
index 0000000..a250bfc
--- /dev/null
+++ b/vendor/github.com/moby/sys/mount/mount_unix.go
@@ -0,0 +1,87 @@
+// +build !darwin,!windows
+
+package mount
+
+import (
+ "fmt"
+ "sort"
+
+ "github.com/moby/sys/mountinfo"
+ "golang.org/x/sys/unix"
+)
+
+// Mount will mount filesystem according to the specified configuration.
+// Options must be specified like the mount or fstab unix commands:
+// "opt1=val1,opt2=val2". See flags.go for supported option flags.
+func Mount(device, target, mType, options string) error {
+ flag, data := parseOptions(options)
+ return mount(device, target, mType, uintptr(flag), data)
+}
+
+// Unmount lazily unmounts a filesystem on supported platforms, otherwise does
+// a normal unmount. If target is not a mount point, no error is returned.
+func Unmount(target string) error {
+ err := unix.Unmount(target, mntDetach)
+ if err == nil || err == unix.EINVAL {
+ // Ignore "not mounted" error here. Note the same error
+ // can be returned if flags are invalid, so this code
+ // assumes that the flags value is always correct.
+ return nil
+ }
+
+ return &mountError{
+ op: "umount",
+ target: target,
+ flags: uintptr(mntDetach),
+ err: err,
+ }
+}
+
+// RecursiveUnmount unmounts the target and all mounts underneath, starting
+// with the deepest mount first. The argument does not have to be a mount
+// point itself.
+func RecursiveUnmount(target string) error {
+ // Fast path, works if target is a mount point that can be unmounted.
+ // On Linux, mntDetach flag ensures a recursive unmount. For other
+ // platforms, if there are submounts, we'll get EBUSY (and fall back
+ // to the slow path). NOTE we do not ignore EINVAL here as target might
+ // not be a mount point itself (but there can be mounts underneath).
+ if err := unix.Unmount(target, mntDetach); err == nil {
+ return nil
+ }
+
+ // Slow path: get all submounts, sort, unmount one by one.
+ mounts, err := mountinfo.GetMounts(mountinfo.PrefixFilter(target))
+ if err != nil {
+ return err
+ }
+
+ // Make the deepest mount be first
+ sort.Slice(mounts, func(i, j int) bool {
+ return len(mounts[i].Mountpoint) > len(mounts[j].Mountpoint)
+ })
+
+ var (
+ suberr error
+ lastMount = len(mounts) - 1
+ )
+ for i, m := range mounts {
+ err = Unmount(m.Mountpoint)
+ if err != nil {
+ if i == lastMount {
+ if suberr != nil {
+ return fmt.Errorf("%w (possible cause: %s)", err, suberr)
+ }
+ return err
+ }
+ // This is a submount, we can ignore the error for now,
+ // the final unmount will fail if this is a real problem.
+ // With that in mind, the _first_ failed unmount error
+ // might be the real error cause, so let's keep it.
+ if suberr == nil {
+ suberr = err
+ }
+ }
+ }
+ return nil
+}
diff --git a/vendor/github.com/moby/sys/mount/mounter_freebsd.go b/vendor/github.com/moby/sys/mount/mounter_bsd.go
similarity index 96%
rename from vendor/github.com/moby/sys/mount/mounter_freebsd.go
rename to vendor/github.com/moby/sys/mount/mounter_bsd.go
index 3964af4..656b762 100644
--- a/vendor/github.com/moby/sys/mount/mounter_freebsd.go
+++ b/vendor/github.com/moby/sys/mount/mounter_bsd.go
@@ -1,3 +1,5 @@
+// +build freebsd,cgo openbsd,cgo
+
package mount
/*
diff --git a/vendor/github.com/moby/sys/mount/mounter_unsupported.go b/vendor/github.com/moby/sys/mount/mounter_unsupported.go
index 1538067..e7ff5bd 100644
--- a/vendor/github.com/moby/sys/mount/mounter_unsupported.go
+++ b/vendor/github.com/moby/sys/mount/mounter_unsupported.go
@@ -1,7 +1,7 @@
-// +build !linux,!freebsd freebsd,!cgo
+// +build !linux,!freebsd,!openbsd,!windows freebsd,!cgo openbsd,!cgo
package mount
func mount(device, target, mType string, flag uintptr, data string) error {
- panic("Not implemented")
+ panic("cgo required on freebsd and openbsd")
}
diff --git a/vendor/github.com/moby/sys/mount/unmount_unix.go b/vendor/github.com/moby/sys/mount/unmount_unix.go
deleted file mode 100644
index 1d1afee..0000000
--- a/vendor/github.com/moby/sys/mount/unmount_unix.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// +build !windows
-
-package mount
-
-import "golang.org/x/sys/unix"
-
-func unmount(target string, flags int) error {
- err := unix.Unmount(target, flags)
- if err == nil || err == unix.EINVAL {
- // Ignore "not mounted" error here. Note the same error
- // can be returned if flags are invalid, so this code
- // assumes that the flags value is always correct.
- return nil
- }
-
- return &mountError{
- op: "umount",
- target: target,
- flags: uintptr(flags),
- err: err,
- }
-}
diff --git a/vendor/github.com/moby/sys/mount/unmount_unsupported.go b/vendor/github.com/moby/sys/mount/unmount_unsupported.go
deleted file mode 100644
index eebc4ab..0000000
--- a/vendor/github.com/moby/sys/mount/unmount_unsupported.go
+++ /dev/null
@@ -1,7 +0,0 @@
-// +build windows
-
-package mount
-
-func unmount(target string, flag int) error {
- panic("Not implemented")
-}
diff --git a/vendor/github.com/moby/sys/mountinfo/doc.go b/vendor/github.com/moby/sys/mountinfo/doc.go
new file mode 100644
index 0000000..b80e05e
--- /dev/null
+++ b/vendor/github.com/moby/sys/mountinfo/doc.go
@@ -0,0 +1,44 @@
+// Package mountinfo provides a set of functions to retrieve information about OS mounts.
+//
+// Currently it supports Linux. For historical reasons, there is also some support for FreeBSD and OpenBSD,
+// and a shallow implementation for Windows, but in general this is Linux-only package, so
+// the rest of the document only applies to Linux, unless explicitly specified otherwise.
+//
+// In Linux, information about mounts seen by the current process is available from
+// /proc/self/mountinfo. Note that due to mount namespaces, different processes can
+// see different mounts. A per-process mountinfo table is available from /proc/<PID>/mountinfo,
+// where <PID> is a numerical process identifier.
+//
+// In general, /proc is not a very efficient interface, and mountinfo is not an exception.
+// For example, there is no way to get information about a specific mount point (i.e. it
+// is all-or-nothing). This package tries to hide the /proc ineffectiveness by using
+// parse filters while reading mountinfo. A filter can skip some entries, or stop
+// processing the rest of the file once the needed information is found.
+//
+// For mountinfo filters that accept path as an argument, the path must be absolute,
+// having all symlinks resolved, and being cleaned (i.e. no extra slashes or dots).
+// One way to achieve all of the above is to employ filepath.Abs followed by
+// filepath.EvalSymlinks (the latter calls filepath.Clean on the result so
+// there is no need to explicitly call filepath.Clean).
+//
+// NOTE that in many cases there is no need to consult mountinfo at all. Here are some
+// of the cases where mountinfo should not be parsed:
+//
+// 1. Before performing a mount. Usually, this is not needed, but if required (say to
+// prevent over-mounts), to check whether a directory is mounted, call os.Lstat
+// on it and its parent directory, and compare their st.Sys().(*syscall.Stat_t).Dev
+// fields -- if they differ, then the directory is the mount point. NOTE this does
+// not work for bind mounts. Optionally, the filesystem type can also be checked
+// by calling unix.Statfs and checking the Type field (i.e. filesystem type).
+//
+// 2. After performing a mount. If there is no error returned, the mount succeeded;
+// checking the mount table for a new mount is redundant and expensive.
+//
+// 3. Before performing an unmount. It is more efficient to do an unmount and ignore
+// a specific error (EINVAL) which tells the directory is not mounted.
+//
+// 4. After performing an unmount. If there is no error returned, the unmount succeeded.
+//
+// 5. To find the mount point root of a specific directory. You can perform os.Stat()
+// on the directory and traverse up until the Dev field of a parent directory differs.
+package mountinfo
diff --git a/vendor/github.com/moby/sys/mountinfo/go.mod b/vendor/github.com/moby/sys/mountinfo/go.mod
index 10d9a15..9749ea9 100644
--- a/vendor/github.com/moby/sys/mountinfo/go.mod
+++ b/vendor/github.com/moby/sys/mountinfo/go.mod
@@ -1,3 +1,5 @@
module github.com/moby/sys/mountinfo
go 1.14
+
+require golang.org/x/sys v0.0.0-20200909081042-eff7692f9009
diff --git a/vendor/github.com/moby/sys/mountinfo/mounted_linux.go b/vendor/github.com/moby/sys/mountinfo/mounted_linux.go
new file mode 100644
index 0000000..bc9f6b2
--- /dev/null
+++ b/vendor/github.com/moby/sys/mountinfo/mounted_linux.go
@@ -0,0 +1,58 @@
+package mountinfo
+
+import (
+ "os"
+ "path/filepath"
+
+ "golang.org/x/sys/unix"
+)
+
+// mountedByOpenat2 is a method of detecting a mount that works for all kinds
+// of mounts (incl. bind mounts), but requires a recent (v5.6+) linux kernel.
+func mountedByOpenat2(path string) (bool, error) {
+ dir, last := filepath.Split(path)
+
+ dirfd, err := unix.Openat2(unix.AT_FDCWD, dir, &unix.OpenHow{
+ Flags: unix.O_PATH | unix.O_CLOEXEC,
+ })
+ if err != nil {
+ if err == unix.ENOENT { // not a mount
+ return false, nil
+ }
+ return false, &os.PathError{Op: "openat2", Path: dir, Err: err}
+ }
+ fd, err := unix.Openat2(dirfd, last, &unix.OpenHow{
+ Flags: unix.O_PATH | unix.O_CLOEXEC | unix.O_NOFOLLOW,
+ Resolve: unix.RESOLVE_NO_XDEV,
+ })
+ _ = unix.Close(dirfd)
+ switch err {
+ case nil: // definitely not a mount
+ _ = unix.Close(fd)
+ return false, nil
+ case unix.EXDEV: // definitely a mount
+ return true, nil
+ case unix.ENOENT: // not a mount
+ return false, nil
+ }
+ // not sure
+ return false, &os.PathError{Op: "openat2", Path: path, Err: err}
+}
+
+func mounted(path string) (bool, error) {
+ // Try a fast path, using openat2() with RESOLVE_NO_XDEV.
+ mounted, err := mountedByOpenat2(path)
+ if err == nil {
+ return mounted, nil
+ }
+ // Another fast path: compare st.st_dev fields.
+ mounted, err = mountedByStat(path)
+ // This does not work for bind mounts, so false negative
+ // is possible, therefore only trust if return is true.
+ if mounted && err == nil {
+ return mounted, nil
+ }
+
+ // Fallback to parsing mountinfo
+ return mountedByMountinfo(path)
+}
diff --git a/vendor/github.com/moby/sys/mountinfo/mounted_unix.go b/vendor/github.com/moby/sys/mountinfo/mounted_unix.go
new file mode 100644
index 0000000..efb0397
--- /dev/null
+++ b/vendor/github.com/moby/sys/mountinfo/mounted_unix.go
@@ -0,0 +1,66 @@
+// +build linux freebsd,cgo openbsd,cgo
+
+package mountinfo
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "path/filepath"
+
+ "golang.org/x/sys/unix"
+)
+
+func mountedByStat(path string) (bool, error) {
+ var st unix.Stat_t
+
+ if err := unix.Lstat(path, &st); err != nil {
+ if err == unix.ENOENT {
+ // Treat ENOENT as "not mounted".
+ return false, nil
+ }
+ return false, &os.PathError{Op: "stat", Path: path, Err: err}
+ }
+ dev := st.Dev
+ parent := filepath.Dir(path)
+ if err := unix.Lstat(parent, &st); err != nil {
+ return false, &os.PathError{Op: "stat", Path: parent, Err: err}
+ }
+ if dev != st.Dev {
+ // Device differs from that of parent,
+ // so definitely a mount point.
+ return true, nil
+ }
+ // NB: this does not detect bind mounts on Linux.
+ return false, nil
+}
+
+func normalizePath(path string) (realPath string, err error) {
+ if realPath, err = filepath.Abs(path); err != nil {
+ return "", fmt.Errorf("unable to get absolute path for %q: %w", path, err)
+ }
+ if realPath, err = filepath.EvalSymlinks(realPath); err != nil {
+ return "", fmt.Errorf("failed to canonicalise path for %q: %w", path, err)
+ }
+ if _, err := os.Stat(realPath); err != nil {
+ return "", fmt.Errorf("failed to stat target of %q: %w", path, err)
+ }
+ return realPath, nil
+}
+
+func mountedByMountinfo(path string) (bool, error) {
+ path, err := normalizePath(path)
+ if err != nil {
+ if errors.Is(err, unix.ENOENT) {
+ // treat ENOENT as "not mounted"
+ return false, nil
+ }
+ return false, err
+ }
+ entries, err := GetMounts(SingleEntryFilter(path))
+ if err != nil {
+ return false, err
+ }
+
+ return len(entries) > 0, nil
+}
diff --git a/vendor/github.com/moby/sys/mountinfo/mountinfo.go b/vendor/github.com/moby/sys/mountinfo/mountinfo.go
index 136b141..fe828c8 100644
--- a/vendor/github.com/moby/sys/mountinfo/mountinfo.go
+++ b/vendor/github.com/moby/sys/mountinfo/mountinfo.go
@@ -1,6 +1,8 @@
package mountinfo
-import "io"
+import (
+ "os"
+)
// GetMounts retrieves a list of mounts for the current running process,
// with an optional filter applied (use nil for no filter).
@@ -8,23 +10,17 @@
return parseMountTable(f)
}
-// GetMountsFromReader retrieves a list of mounts from the
-// reader provided, with an optional filter applied (use nil
-// for no filter). This can be useful in tests or benchmarks
-// that provide a fake mountinfo data.
-func GetMountsFromReader(reader io.Reader, f FilterFunc) ([]*Info, error) {
- return parseInfoFile(reader, f)
-}
-
-// Mounted determines if a specified mountpoint has been mounted.
-// On Linux it looks at /proc/self/mountinfo.
-func Mounted(mountpoint string) (bool, error) {
- entries, err := GetMounts(SingleEntryFilter(mountpoint))
- if err != nil {
- return false, err
+// Mounted determines if a specified path is a mount point.
+//
+// The argument must be an absolute path, with all symlinks resolved, and clean.
+// One way to ensure it is to process the path using filepath.Abs followed by
+// filepath.EvalSymlinks before calling this function.
+func Mounted(path string) (bool, error) {
+ // root is always mounted
+ if path == string(os.PathSeparator) {
+ return true, nil
}
-
- return len(entries) > 0, nil
+ return mounted(path)
}
// Info reveals information about a particular mounted filesystem. This
@@ -50,18 +46,18 @@
// Mountpoint indicates the mount point relative to the process's root.
Mountpoint string
- // Opts represents mount-specific options.
- Opts string
+ // Options represents mount-specific options.
+ Options string
// Optional represents optional fields.
Optional string
- // Fstype indicates the type of filesystem, such as EXT3.
- Fstype string
+ // FSType indicates the type of filesystem, such as EXT3.
+ FSType string
// Source indicates filesystem specific information or "none".
Source string
- // VfsOpts represents per super block options.
- VfsOpts string
+ // VFSOptions represents per super block options.
+ VFSOptions string
}
diff --git a/vendor/github.com/moby/sys/mountinfo/mountinfo_freebsd.go b/vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
similarity index 73%
rename from vendor/github.com/moby/sys/mountinfo/mountinfo_freebsd.go
rename to vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
index a7dbb1b..b1c12d0 100644
--- a/vendor/github.com/moby/sys/mountinfo/mountinfo_freebsd.go
+++ b/vendor/github.com/moby/sys/mountinfo/mountinfo_bsd.go
@@ -1,3 +1,5 @@
+// +build freebsd,cgo openbsd,cgo
+
package mountinfo
/*
@@ -33,7 +35,7 @@
var mountinfo Info
var skip, stop bool
mountinfo.Mountpoint = C.GoString(&entry.f_mntonname[0])
- mountinfo.Fstype = C.GoString(&entry.f_fstypename[0])
+ mountinfo.FSType = C.GoString(&entry.f_fstypename[0])
mountinfo.Source = C.GoString(&entry.f_mntfromname[0])
if filter != nil {
@@ -51,3 +53,15 @@
}
return out, nil
}
+
+func mounted(path string) (bool, error) {
+ // Fast path: compare st.st_dev fields.
+ // This should always work for FreeBSD and OpenBSD.
+ mounted, err := mountedByStat(path)
+ if err == nil {
+ return mounted, nil
+ }
+
+ // Fallback to parsing mountinfo
+ return mountedByMountinfo(path)
+}
diff --git a/vendor/github.com/moby/sys/mountinfo/mountinfo_filters.go b/vendor/github.com/moby/sys/mountinfo/mountinfo_filters.go
index 7950264..5869b2c 100644
--- a/vendor/github.com/moby/sys/mountinfo/mountinfo_filters.go
+++ b/vendor/github.com/moby/sys/mountinfo/mountinfo_filters.go
@@ -6,16 +6,16 @@
// used to filter out mountinfo entries we're not interested in,
// and/or stop further processing if we found what we wanted.
//
-// It takes a pointer to the Info struct (not fully populated,
-// currently only Mountpoint, Fstype, Source, and (on Linux)
-// VfsOpts are filled in), and returns two booleans:
+// It takes a pointer to the Info struct (fully populated with all available
+// fields on the GOOS platform), and returns two booleans:
//
-// - skip: true if the entry should be skipped
-// - stop: true if parsing should be stopped after the entry
+// skip: true if the entry should be skipped;
+//
+// stop: true if parsing should be stopped after the entry.
type FilterFunc func(*Info) (skip, stop bool)
// PrefixFilter discards all entries whose mount points
-// do not start with a specific prefix
+// do not start with a specific prefix.
func PrefixFilter(prefix string) FilterFunc {
return func(m *Info) (bool, bool) {
skip := !strings.HasPrefix(m.Mountpoint, prefix)
@@ -23,7 +23,7 @@
}
}
-// SingleEntryFilter looks for a specific entry
+// SingleEntryFilter looks for a specific entry.
func SingleEntryFilter(mp string) FilterFunc {
return func(m *Info) (bool, bool) {
if m.Mountpoint == mp {
@@ -36,8 +36,8 @@
// ParentsFilter returns all entries whose mount points
// can be parents of a path specified, discarding others.
//
-// For example, given `/var/lib/docker/something`, entries
-// like `/var/lib/docker`, `/var` and `/` are returned.
+// For example, given /var/lib/docker/something, entries
+// like /var/lib/docker, /var and / are returned.
func ParentsFilter(path string) FilterFunc {
return func(m *Info) (bool, bool) {
skip := !strings.HasPrefix(path, m.Mountpoint)
@@ -45,12 +45,12 @@
}
}
-// FstypeFilter returns all entries that match provided fstype(s).
-func FstypeFilter(fstype ...string) FilterFunc {
+// FSTypeFilter returns all entries that match provided fstype(s).
+func FSTypeFilter(fstype ...string) FilterFunc {
return func(m *Info) (bool, bool) {
for _, t := range fstype {
- if m.Fstype == t {
- return false, false // don't skeep, keep going
+ if m.FSType == t {
+ return false, false // don't skip, keep going
}
}
return true, false // skip, keep going
diff --git a/vendor/github.com/moby/sys/mountinfo/mountinfo_linux.go b/vendor/github.com/moby/sys/mountinfo/mountinfo_linux.go
index 2d630c8..e591c83 100644
--- a/vendor/github.com/moby/sys/mountinfo/mountinfo_linux.go
+++ b/vendor/github.com/moby/sys/mountinfo/mountinfo_linux.go
@@ -1,5 +1,3 @@
-// +build go1.13
-
package mountinfo
import (
@@ -11,14 +9,18 @@
"strings"
)
-func parseInfoFile(r io.Reader, filter FilterFunc) ([]*Info, error) {
+// GetMountsFromReader retrieves a list of mounts from the
+// reader provided, with an optional filter applied (use nil
+// for no filter). This can be useful in tests or benchmarks
+// that provide a fake mountinfo data.
+//
+// This function is Linux-specific.
+func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
s := bufio.NewScanner(r)
out := []*Info{}
- var err error
for s.Scan() {
- if err = s.Err(); err != nil {
- return nil, err
- }
+ var err error
+
/*
See http://man7.org/linux/man-pages/man5/proc.5.html
@@ -70,26 +72,19 @@
p := &Info{}
- // Fill in the fields that a filter might check
- p.Mountpoint, err = strconv.Unquote(`"` + fields[4] + `"`)
+ p.Mountpoint, err = unescape(fields[4])
if err != nil {
- return nil, fmt.Errorf("Parsing '%s' failed: unable to unquote mount point field: %w", fields[4], err)
+ return nil, fmt.Errorf("Parsing '%s' failed: mount point: %w", fields[4], err)
}
- p.Fstype = fields[sepIdx+1]
- p.Source = fields[sepIdx+2]
- p.VfsOpts = fields[sepIdx+3]
-
- // Run a filter soon so we can skip parsing/adding entries
- // the caller is not interested in
- var skip, stop bool
- if filter != nil {
- skip, stop = filter(p)
- if skip {
- continue
- }
+ p.FSType, err = unescape(fields[sepIdx+1])
+ if err != nil {
+ return nil, fmt.Errorf("Parsing '%s' failed: fstype: %w", fields[sepIdx+1], err)
}
-
- // Fill in the rest of the fields
+ p.Source, err = unescape(fields[sepIdx+2])
+ if err != nil {
+ return nil, fmt.Errorf("Parsing '%s' failed: source: %w", fields[sepIdx+2], err)
+ }
+ p.VFSOptions = fields[sepIdx+3]
// ignore any numbers parsing errors, as there should not be any
p.ID, _ = strconv.Atoi(fields[0])
@@ -101,12 +96,12 @@
p.Major, _ = strconv.Atoi(mm[0])
p.Minor, _ = strconv.Atoi(mm[1])
- p.Root, err = strconv.Unquote(`"` + fields[3] + `"`)
+ p.Root, err = unescape(fields[3])
if err != nil {
- return nil, fmt.Errorf("Parsing '%s' failed: unable to unquote root field: %w", fields[3], err)
+ return nil, fmt.Errorf("Parsing '%s' failed: root: %w", fields[3], err)
}
- p.Opts = fields[5]
+ p.Options = fields[5]
// zero or more optional fields
switch {
@@ -118,11 +113,23 @@
p.Optional = strings.Join(fields[6:sepIdx-1], " ")
}
+ // Run the filter after parsing all of the fields.
+ var skip, stop bool
+ if filter != nil {
+ skip, stop = filter(p)
+ if skip {
+ continue
+ }
+ }
+
out = append(out, p)
if stop {
break
}
}
+ if err := s.Err(); err != nil {
+ return nil, err
+ }
return out, nil
}
@@ -135,12 +142,17 @@
}
defer f.Close()
- return parseInfoFile(f, filter)
+ return GetMountsFromReader(f, filter)
}
-// PidMountInfo collects the mounts for a specific process ID. If the process
-// ID is unknown, it is better to use `GetMounts` which will inspect
-// "/proc/self/mountinfo" instead.
+// PidMountInfo retrieves the list of mounts from a given process' mount
+// namespace. Unless there is a need to get mounts from a mount namespace
+// different from that of a calling process, use GetMounts.
+//
+// This function is Linux-specific.
+//
+// Deprecated: this will be removed before v1; use GetMountsFromReader with
+// opened /proc/<pid>/mountinfo as an argument instead.
func PidMountInfo(pid int) ([]*Info, error) {
f, err := os.Open(fmt.Sprintf("/proc/%d/mountinfo", pid))
if err != nil {
@@ -148,5 +160,63 @@
}
defer f.Close()
- return parseInfoFile(f, nil)
+ return GetMountsFromReader(f, nil)
+}
+
+// A few specific characters in mountinfo path entries (root and mountpoint)
+// are escaped using a backslash followed by a character's ascii code in octal.
+//
+// space -- as \040
+// tab (aka \t) -- as \011
+// newline (aka \n) -- as \012
+// backslash (aka \\) -- as \134
+//
+// This function converts path from mountinfo back, i.e. it unescapes the above sequences.
+func unescape(path string) (string, error) {
+ // try to avoid copying
+ if strings.IndexByte(path, '\\') == -1 {
+ return path, nil
+ }
+
+ // The following code is UTF-8 transparent as it only looks for some
+ // specific characters (backslash and 0..7) with values < utf8.RuneSelf,
+ // and everything else is passed through as is.
+ buf := make([]byte, len(path))
+ bufLen := 0
+ for i := 0; i < len(path); i++ {
+ if path[i] != '\\' {
+ buf[bufLen] = path[i]
+ bufLen++
+ continue
+ }
+ s := path[i:]
+ if len(s) < 4 {
+ // too short
+ return "", fmt.Errorf("bad escape sequence %q: too short", s)
+ }
+ c := s[1]
+ switch c {
+ case '0', '1', '2', '3', '4', '5', '6', '7':
+ v := c - '0'
+ for j := 2; j < 4; j++ { // one digit already; two more
+ if s[j] < '0' || s[j] > '7' {
+ return "", fmt.Errorf("bad escape sequence %q: not a digit", s[:3])
+ }
+ x := s[j] - '0'
+ v = (v << 3) | x
+ }
+ if v > 255 {
+ return "", fmt.Errorf("bad escape sequence %q: out of range" + s[:3])
+ }
+ buf[bufLen] = v
+ bufLen++
+ i += 3
+ continue
+ default:
+ return "", fmt.Errorf("bad escape sequence %q: not a digit" + s[:3])
+
+ }
+ }
+
+ return string(buf[:bufLen]), nil
}
diff --git a/vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go b/vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go
index dc18692..d33ebca 100644
--- a/vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go
+++ b/vendor/github.com/moby/sys/mountinfo/mountinfo_unsupported.go
@@ -1,17 +1,18 @@
-// +build !windows,!linux,!freebsd freebsd,!cgo
+// +build !windows,!linux,!freebsd,!openbsd freebsd,!cgo openbsd,!cgo
package mountinfo
import (
"fmt"
- "io"
"runtime"
)
+var errNotImplemented = fmt.Errorf("not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+
func parseMountTable(_ FilterFunc) ([]*Info, error) {
- return nil, fmt.Errorf("mount.parseMountTable is not implemented on %s/%s", runtime.GOOS, runtime.GOARCH)
+ return nil, errNotImplemented
}
-func parseInfoFile(_ io.Reader, f FilterFunc) ([]*Info, error) {
- return parseMountTable(f)
+func mounted(path string) (bool, error) {
+ return false, errNotImplemented
}
diff --git a/vendor/github.com/moby/sys/mountinfo/mountinfo_windows.go b/vendor/github.com/moby/sys/mountinfo/mountinfo_windows.go
index 69ffdc5..13fad16 100644
--- a/vendor/github.com/moby/sys/mountinfo/mountinfo_windows.go
+++ b/vendor/github.com/moby/sys/mountinfo/mountinfo_windows.go
@@ -1,12 +1,10 @@
package mountinfo
-import "io"
-
func parseMountTable(_ FilterFunc) ([]*Info, error) {
// Do NOT return an error!
return nil, nil
}
-func parseInfoFile(_ io.Reader, f FilterFunc) ([]*Info, error) {
- return parseMountTable(f)
+func mounted(_ string) (bool, error) {
+ return false, nil
}
diff --git a/pkg/symlink/LICENSE.APACHE b/vendor/github.com/moby/sys/symlink/LICENSE.APACHE
similarity index 100%
rename from pkg/symlink/LICENSE.APACHE
rename to vendor/github.com/moby/sys/symlink/LICENSE.APACHE
diff --git a/pkg/symlink/LICENSE.BSD b/vendor/github.com/moby/sys/symlink/LICENSE.BSD
similarity index 100%
rename from pkg/symlink/LICENSE.BSD
rename to vendor/github.com/moby/sys/symlink/LICENSE.BSD
diff --git a/pkg/symlink/README.md b/vendor/github.com/moby/sys/symlink/README.md
similarity index 100%
rename from pkg/symlink/README.md
rename to vendor/github.com/moby/sys/symlink/README.md
diff --git a/vendor/github.com/moby/sys/symlink/doc.go b/vendor/github.com/moby/sys/symlink/doc.go
new file mode 100644
index 0000000..d2de7ec
--- /dev/null
+++ b/vendor/github.com/moby/sys/symlink/doc.go
@@ -0,0 +1,4 @@
+// Package symlink implements EvalSymlinksInScope which is an extension of
+// filepath.EvalSymlinks, as well as a Windows long-path aware version of
+// filepath.EvalSymlinks from the Go standard library (https://golang.org/pkg/path/filepath).
+package symlink
diff --git a/pkg/symlink/fs.go b/vendor/github.com/moby/sys/symlink/fs.go
similarity index 98%
rename from pkg/symlink/fs.go
rename to vendor/github.com/moby/sys/symlink/fs.go
index fb8b77f..244b009 100644
--- a/pkg/symlink/fs.go
+++ b/vendor/github.com/moby/sys/symlink/fs.go
@@ -4,7 +4,7 @@
// This code is a modified version of path/filepath/symlink.go from the Go standard library.
-package symlink // import "github.com/docker/docker/pkg/symlink"
+package symlink
import (
"bytes"
diff --git a/pkg/symlink/fs_unix.go b/vendor/github.com/moby/sys/symlink/fs_unix.go
similarity index 78%
rename from pkg/symlink/fs_unix.go
rename to vendor/github.com/moby/sys/symlink/fs_unix.go
index 855fda5..ef960a0 100644
--- a/pkg/symlink/fs_unix.go
+++ b/vendor/github.com/moby/sys/symlink/fs_unix.go
@@ -1,6 +1,6 @@
// +build !windows
-package symlink // import "github.com/docker/docker/pkg/symlink"
+package symlink
import (
"path/filepath"
diff --git a/pkg/symlink/fs_windows.go b/vendor/github.com/moby/sys/symlink/fs_windows.go
similarity index 98%
rename from pkg/symlink/fs_windows.go
rename to vendor/github.com/moby/sys/symlink/fs_windows.go
index 495518f..7603faf 100644
--- a/pkg/symlink/fs_windows.go
+++ b/vendor/github.com/moby/sys/symlink/fs_windows.go
@@ -1,4 +1,4 @@
-package symlink // import "github.com/docker/docker/pkg/symlink"
+package symlink
import (
"bytes"
diff --git a/vendor/github.com/moby/sys/symlink/go.mod b/vendor/github.com/moby/sys/symlink/go.mod
new file mode 100644
index 0000000..6383f09
--- /dev/null
+++ b/vendor/github.com/moby/sys/symlink/go.mod
@@ -0,0 +1,5 @@
+module github.com/moby/sys/symlink
+
+go 1.13
+
+require golang.org/x/sys v0.0.0-20200922070232-aee5d888a860
diff --git a/vendor/github.com/opentracing-contrib/go-stdlib/LICENSE b/vendor/github.com/opentracing-contrib/go-stdlib/LICENSE
index c259d12..261eeb9 100644
--- a/vendor/github.com/opentracing-contrib/go-stdlib/LICENSE
+++ b/vendor/github.com/opentracing-contrib/go-stdlib/LICENSE
@@ -1,27 +1,201 @@
-Copyright (c) 2016, opentracing-contrib
-All rights reserved.
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-* Redistributions of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
+ 1. Definitions.
-* Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
-* Neither the name of go-stdlib nor the names of its
- contributors may be used to endorse or promote products derived from
- this software without specific prior written permission.
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendor/github.com/opentracing-contrib/go-stdlib/README.md b/vendor/github.com/opentracing-contrib/go-stdlib/README.md
index 139709c..c820daa 100644
--- a/vendor/github.com/opentracing-contrib/go-stdlib/README.md
+++ b/vendor/github.com/opentracing-contrib/go-stdlib/README.md
@@ -16,3 +16,7 @@
- **net/http**: Client and server instrumentation. *Only supported
with Go 1.7 and later.*
+
+## License
+
+By contributing to this repository, you agree that your contributions will be licensed under [Apache 2.0 License](./LICENSE).
diff --git a/vendor/github.com/opentracing-contrib/go-stdlib/go.mod b/vendor/github.com/opentracing-contrib/go-stdlib/go.mod
new file mode 100644
index 0000000..3b3c5c2
--- /dev/null
+++ b/vendor/github.com/opentracing-contrib/go-stdlib/go.mod
@@ -0,0 +1,7 @@
+module github.com/opentracing-contrib/go-stdlib
+
+go 1.14
+
+require (
+ github.com/opentracing/opentracing-go v1.1.0
+)
diff --git a/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/client.go b/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/client.go
index 8d33bcb..bfb305f 100644
--- a/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/client.go
+++ b/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/client.go
@@ -7,6 +7,7 @@
"io"
"net/http"
"net/http/httptrace"
+ "net/url"
"github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
@@ -31,9 +32,12 @@
}
type clientOptions struct {
- operationName string
- componentName string
- disableClientTrace bool
+ operationName string
+ componentName string
+ urlTagFunc func(u *url.URL) string
+ disableClientTrace bool
+ disableInjectSpanContext bool
+ spanObserver func(span opentracing.Span, r *http.Request)
}
// ClientOption contols the behavior of TraceRequest.
@@ -47,6 +51,15 @@
}
}
+// URLTagFunc returns a ClientOption that uses given function f
+// to set the span's http.url tag. Can be used to change the default
+// http.url tag, eg to redact sensitive information.
+func URLTagFunc(f func(u *url.URL) string) ClientOption {
+ return func(options *clientOptions) {
+ options.urlTagFunc = f
+ }
+}
+
// ComponentName returns a ClientOption that sets the component
// name for the client-side span.
func ComponentName(componentName string) ClientOption {
@@ -63,6 +76,24 @@
}
}
+// InjectSpanContext returns a ClientOption that turns on or off
+// injection of the Span context in the request HTTP headers.
+// If this option is not used, the default behaviour is to
+// inject the span context.
+func InjectSpanContext(enabled bool) ClientOption {
+ return func(options *clientOptions) {
+ options.disableInjectSpanContext = !enabled
+ }
+}
+
+// ClientSpanObserver returns a ClientOption that observes the span
+// for the client-side span.
+func ClientSpanObserver(f func(span opentracing.Span, r *http.Request)) ClientOption {
+ return func(options *clientOptions) {
+ options.spanObserver = f
+ }
+}
+
// TraceRequest adds a ClientTracer to req, tracing the request and
// all requests caused due to redirects. When tracing requests this
// way you must also use Transport.
@@ -88,7 +119,12 @@
// return nil
// }
func TraceRequest(tr opentracing.Tracer, req *http.Request, options ...ClientOption) (*http.Request, *Tracer) {
- opts := &clientOptions{}
+ opts := &clientOptions{
+ urlTagFunc: func(u *url.URL) string {
+ return u.String()
+ },
+ spanObserver: func(_ opentracing.Span, _ *http.Request) {},
+ }
for _, opt := range options {
opt(opts)
}
@@ -113,24 +149,38 @@
return err
}
+// TracerFromRequest retrieves the Tracer from the request. If the request does
+// not have a Tracer it will return nil.
+func TracerFromRequest(req *http.Request) *Tracer {
+ tr, ok := req.Context().Value(keyTracer).(*Tracer)
+ if !ok {
+ return nil
+ }
+ return tr
+}
+
// RoundTrip implements the RoundTripper interface.
func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
rt := t.RoundTripper
if rt == nil {
rt = http.DefaultTransport
}
- tracer, ok := req.Context().Value(keyTracer).(*Tracer)
- if !ok {
+ tracer := TracerFromRequest(req)
+ if tracer == nil {
return rt.RoundTrip(req)
}
tracer.start(req)
ext.HTTPMethod.Set(tracer.sp, req.Method)
- ext.HTTPUrl.Set(tracer.sp, req.URL.String())
+ ext.HTTPUrl.Set(tracer.sp, tracer.opts.urlTagFunc(req.URL))
+ tracer.opts.spanObserver(tracer.sp, req)
- carrier := opentracing.HTTPHeadersCarrier(req.Header)
- tracer.sp.Tracer().Inject(tracer.sp.Context(), opentracing.HTTPHeaders, carrier)
+ if !tracer.opts.disableInjectSpanContext {
+ carrier := opentracing.HTTPHeadersCarrier(req.Header)
+ tracer.sp.Tracer().Inject(tracer.sp.Context(), opentracing.HTTPHeaders, carrier)
+ }
+
resp, err := rt.RoundTrip(req)
if err != nil {
@@ -138,6 +188,9 @@
return resp, err
}
ext.HTTPStatusCode.Set(tracer.sp, uint16(resp.StatusCode))
+ if resp.StatusCode >= http.StatusInternalServerError {
+ ext.Error.Set(tracer.sp, true)
+ }
if req.Method == "HEAD" {
tracer.sp.Finish()
} else {
diff --git a/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/server.go b/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/server.go
index 2b31415..db2df66 100644
--- a/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/server.go
+++ b/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/server.go
@@ -4,23 +4,17 @@
import (
"net/http"
+ "net/url"
opentracing "github.com/opentracing/opentracing-go"
"github.com/opentracing/opentracing-go/ext"
)
-type statusCodeTracker struct {
- http.ResponseWriter
- status int
-}
-
-func (w *statusCodeTracker) WriteHeader(status int) {
- w.status = status
- w.ResponseWriter.WriteHeader(status)
-}
-
type mwOptions struct {
opNameFunc func(r *http.Request) string
+ spanFilter func(r *http.Request) bool
+ spanObserver func(span opentracing.Span, r *http.Request)
+ urlTagFunc func(u *url.URL) string
componentName string
}
@@ -36,13 +30,39 @@
}
// MWComponentName returns a MWOption that sets the component name
-// name for the server-side span.
+// for the server-side span.
func MWComponentName(componentName string) MWOption {
return func(options *mwOptions) {
options.componentName = componentName
}
}
+// MWSpanFilter returns a MWOption that filters requests from creating a span
+// for the server-side span.
+// Span won't be created if it returns false.
+func MWSpanFilter(f func(r *http.Request) bool) MWOption {
+ return func(options *mwOptions) {
+ options.spanFilter = f
+ }
+}
+
+// MWSpanObserver returns a MWOption that observe the span
+// for the server-side span.
+func MWSpanObserver(f func(span opentracing.Span, r *http.Request)) MWOption {
+ return func(options *mwOptions) {
+ options.spanObserver = f
+ }
+}
+
+// MWURLTagFunc returns a MWOption that uses given function f
+// to set the span's http.url tag. Can be used to change the default
+// http.url tag, eg to redact sensitive information.
+func MWURLTagFunc(f func(u *url.URL) string) MWOption {
+ return func(options *mwOptions) {
+ options.urlTagFunc = f
+ }
+}
+
// Middleware wraps an http.Handler and traces incoming requests.
// Additionally, it adds the span to the request's context.
//
@@ -58,39 +78,80 @@
// mw := nethttp.Middleware(
// tracer,
// http.DefaultServeMux,
-// nethttp.OperationName(func(r *http.Request) string {
+// nethttp.OperationNameFunc(func(r *http.Request) string {
// return "HTTP " + r.Method + ":/api/customers"
// }),
+// nethttp.MWSpanObserver(func(sp opentracing.Span, r *http.Request) {
+// sp.SetTag("http.uri", r.URL.EscapedPath())
+// }),
// )
func Middleware(tr opentracing.Tracer, h http.Handler, options ...MWOption) http.Handler {
+ return MiddlewareFunc(tr, h.ServeHTTP, options...)
+}
+
+// MiddlewareFunc wraps an http.HandlerFunc and traces incoming requests.
+// It behaves identically to the Middleware function above.
+//
+// Example:
+// http.ListenAndServe("localhost:80", nethttp.MiddlewareFunc(tracer, MyHandler))
+func MiddlewareFunc(tr opentracing.Tracer, h http.HandlerFunc, options ...MWOption) http.HandlerFunc {
opts := mwOptions{
opNameFunc: func(r *http.Request) string {
return "HTTP " + r.Method
},
+ spanFilter: func(r *http.Request) bool { return true },
+ spanObserver: func(span opentracing.Span, r *http.Request) {},
+ urlTagFunc: func(u *url.URL) string {
+ return u.String()
+ },
}
for _, opt := range options {
opt(&opts)
}
+ // set component name, use "net/http" if caller does not specify
+ componentName := opts.componentName
+ if componentName == "" {
+ componentName = defaultComponentName
+ }
+
fn := func(w http.ResponseWriter, r *http.Request) {
+ if !opts.spanFilter(r) {
+ h(w, r)
+ return
+ }
ctx, _ := tr.Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(r.Header))
sp := tr.StartSpan(opts.opNameFunc(r), ext.RPCServerOption(ctx))
ext.HTTPMethod.Set(sp, r.Method)
- ext.HTTPUrl.Set(sp, r.URL.String())
-
- // set component name, use "net/http" if caller does not specify
- componentName := opts.componentName
- if componentName == "" {
- componentName = defaultComponentName
- }
+ ext.HTTPUrl.Set(sp, opts.urlTagFunc(r.URL))
ext.Component.Set(sp, componentName)
+ opts.spanObserver(sp, r)
- w = &statusCodeTracker{w, 200}
+ sct := &statusCodeTracker{ResponseWriter: w}
r = r.WithContext(opentracing.ContextWithSpan(r.Context(), sp))
- h.ServeHTTP(w, r)
+ defer func() {
+ panicErr := recover()
+ didPanic := panicErr != nil
- ext.HTTPStatusCode.Set(sp, uint16(w.(*statusCodeTracker).status))
- sp.Finish()
+ if sct.status == 0 && !didPanic {
+ // Standard behavior of http.Server is to assume status code 200 if one was not written by a handler that returned successfully.
+ // https://github.com/golang/go/blob/fca286bed3ed0e12336532cc711875ae5b3cb02a/src/net/http/server.go#L120
+ sct.status = 200
+ }
+ if sct.status > 0 {
+ ext.HTTPStatusCode.Set(sp, uint16(sct.status))
+ }
+ if sct.status >= http.StatusInternalServerError || didPanic {
+ ext.Error.Set(sp, true)
+ }
+ sp.Finish()
+
+ if didPanic {
+ panic(panicErr)
+ }
+ }()
+
+ h(sct.wrappedResponseWriter(), r)
}
return http.HandlerFunc(fn)
}
diff --git a/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/status-code-tracker.go b/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/status-code-tracker.go
new file mode 100644
index 0000000..80a5ce0
--- /dev/null
+++ b/vendor/github.com/opentracing-contrib/go-stdlib/nethttp/status-code-tracker.go
@@ -0,0 +1,251 @@
+// +build go1.8
+
+package nethttp
+
+import (
+ "io"
+ "net/http"
+)
+
+type statusCodeTracker struct {
+ http.ResponseWriter
+ status int
+}
+
+func (w *statusCodeTracker) WriteHeader(status int) {
+ w.status = status
+ w.ResponseWriter.WriteHeader(status)
+}
+
+func (w *statusCodeTracker) Write(b []byte) (int, error) {
+ return w.ResponseWriter.Write(b)
+}
+
+// wrappedResponseWriter returns a wrapped version of the original
+// ResponseWriter and only implements the same combination of additional
+// interfaces as the original. This implementation is based on
+// https://github.com/felixge/httpsnoop.
+func (w *statusCodeTracker) wrappedResponseWriter() http.ResponseWriter {
+ var (
+ hj, i0 = w.ResponseWriter.(http.Hijacker)
+ cn, i1 = w.ResponseWriter.(http.CloseNotifier)
+ pu, i2 = w.ResponseWriter.(http.Pusher)
+ fl, i3 = w.ResponseWriter.(http.Flusher)
+ rf, i4 = w.ResponseWriter.(io.ReaderFrom)
+ )
+
+ switch {
+ case !i0 && !i1 && !i2 && !i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ }{w}
+ case !i0 && !i1 && !i2 && !i3 && i4:
+ return struct {
+ http.ResponseWriter
+ io.ReaderFrom
+ }{w, rf}
+ case !i0 && !i1 && !i2 && i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Flusher
+ }{w, fl}
+ case !i0 && !i1 && !i2 && i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Flusher
+ io.ReaderFrom
+ }{w, fl, rf}
+ case !i0 && !i1 && i2 && !i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Pusher
+ }{w, pu}
+ case !i0 && !i1 && i2 && !i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Pusher
+ io.ReaderFrom
+ }{w, pu, rf}
+ case !i0 && !i1 && i2 && i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Pusher
+ http.Flusher
+ }{w, pu, fl}
+ case !i0 && !i1 && i2 && i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Pusher
+ http.Flusher
+ io.ReaderFrom
+ }{w, pu, fl, rf}
+ case !i0 && i1 && !i2 && !i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.CloseNotifier
+ }{w, cn}
+ case !i0 && i1 && !i2 && !i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.CloseNotifier
+ io.ReaderFrom
+ }{w, cn, rf}
+ case !i0 && i1 && !i2 && i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.CloseNotifier
+ http.Flusher
+ }{w, cn, fl}
+ case !i0 && i1 && !i2 && i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.CloseNotifier
+ http.Flusher
+ io.ReaderFrom
+ }{w, cn, fl, rf}
+ case !i0 && i1 && i2 && !i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.CloseNotifier
+ http.Pusher
+ }{w, cn, pu}
+ case !i0 && i1 && i2 && !i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.CloseNotifier
+ http.Pusher
+ io.ReaderFrom
+ }{w, cn, pu, rf}
+ case !i0 && i1 && i2 && i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.CloseNotifier
+ http.Pusher
+ http.Flusher
+ }{w, cn, pu, fl}
+ case !i0 && i1 && i2 && i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.CloseNotifier
+ http.Pusher
+ http.Flusher
+ io.ReaderFrom
+ }{w, cn, pu, fl, rf}
+ case i0 && !i1 && !i2 && !i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ }{w, hj}
+ case i0 && !i1 && !i2 && !i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ io.ReaderFrom
+ }{w, hj, rf}
+ case i0 && !i1 && !i2 && i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.Flusher
+ }{w, hj, fl}
+ case i0 && !i1 && !i2 && i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.Flusher
+ io.ReaderFrom
+ }{w, hj, fl, rf}
+ case i0 && !i1 && i2 && !i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.Pusher
+ }{w, hj, pu}
+ case i0 && !i1 && i2 && !i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.Pusher
+ io.ReaderFrom
+ }{w, hj, pu, rf}
+ case i0 && !i1 && i2 && i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.Pusher
+ http.Flusher
+ }{w, hj, pu, fl}
+ case i0 && !i1 && i2 && i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.Pusher
+ http.Flusher
+ io.ReaderFrom
+ }{w, hj, pu, fl, rf}
+ case i0 && i1 && !i2 && !i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.CloseNotifier
+ }{w, hj, cn}
+ case i0 && i1 && !i2 && !i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.CloseNotifier
+ io.ReaderFrom
+ }{w, hj, cn, rf}
+ case i0 && i1 && !i2 && i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.CloseNotifier
+ http.Flusher
+ }{w, hj, cn, fl}
+ case i0 && i1 && !i2 && i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.CloseNotifier
+ http.Flusher
+ io.ReaderFrom
+ }{w, hj, cn, fl, rf}
+ case i0 && i1 && i2 && !i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.CloseNotifier
+ http.Pusher
+ }{w, hj, cn, pu}
+ case i0 && i1 && i2 && !i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.CloseNotifier
+ http.Pusher
+ io.ReaderFrom
+ }{w, hj, cn, pu, rf}
+ case i0 && i1 && i2 && i3 && !i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.CloseNotifier
+ http.Pusher
+ http.Flusher
+ }{w, hj, cn, pu, fl}
+ case i0 && i1 && i2 && i3 && i4:
+ return struct {
+ http.ResponseWriter
+ http.Hijacker
+ http.CloseNotifier
+ http.Pusher
+ http.Flusher
+ io.ReaderFrom
+ }{w, hj, cn, pu, fl, rf}
+ default:
+ return struct {
+ http.ResponseWriter
+ }{w}
+ }
+}
diff --git a/vendor/github.com/opentracing/opentracing-go/LICENSE b/vendor/github.com/opentracing/opentracing-go/LICENSE
index 148509a..f002734 100644
--- a/vendor/github.com/opentracing/opentracing-go/LICENSE
+++ b/vendor/github.com/opentracing/opentracing-go/LICENSE
@@ -1,21 +1,201 @@
-The MIT License (MIT)
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
-Copyright (c) 2016 The OpenTracing Authors
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+ 1. Definitions.
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2016 The OpenTracing Authors
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendor/github.com/opentracing/opentracing-go/README.md b/vendor/github.com/opentracing/opentracing-go/README.md
index 19a541c..6ef1d7c 100644
--- a/vendor/github.com/opentracing/opentracing-go/README.md
+++ b/vendor/github.com/opentracing/opentracing-go/README.md
@@ -8,8 +8,8 @@
## Required Reading
In order to understand the Go platform API, one must first be familiar with the
-[OpenTracing project](http://opentracing.io) and
-[terminology](http://opentracing.io/documentation/pages/spec.html) more specifically.
+[OpenTracing project](https://opentracing.io) and
+[terminology](https://opentracing.io/specification/) more specifically.
## API overview for those adding instrumentation
@@ -27,7 +27,7 @@
import ".../some_tracing_impl"
func main() {
- opentracing.InitGlobalTracer(
+ opentracing.SetGlobalTracer(
// tracing impl specific:
some_tracing_impl.New(...),
)
@@ -35,7 +35,7 @@
}
```
-##### Non-Singleton initialization
+#### Non-Singleton initialization
If you prefer direct control to singletons, manage ownership of the
`opentracing.Tracer` implementation explicitly.
@@ -161,3 +161,11 @@
## API compatibility
For the time being, "mild" backwards-incompatible changes may be made without changing the major version number. As OpenTracing and `opentracing-go` mature, backwards compatibility will become more of a priority.
+
+## Tracer test suite
+
+A test suite is available in the [harness](https://godoc.org/github.com/opentracing/opentracing-go/harness) package that can assist Tracer implementors to assert that their Tracer is working correctly.
+
+## Licensing
+
+[Apache 2.0 License](./LICENSE).
diff --git a/vendor/github.com/opentracing/opentracing-go/ext.go b/vendor/github.com/opentracing/opentracing-go/ext.go
new file mode 100644
index 0000000..e11977e
--- /dev/null
+++ b/vendor/github.com/opentracing/opentracing-go/ext.go
@@ -0,0 +1,24 @@
+package opentracing
+
+import (
+ "context"
+)
+
+// TracerContextWithSpanExtension is an extension interface that the
+// implementation of the Tracer interface may want to implement. It
+// allows to have some control over the go context when the
+// ContextWithSpan is invoked.
+//
+// The primary purpose of this extension are adapters from opentracing
+// API to some other tracing API.
+type TracerContextWithSpanExtension interface {
+ // ContextWithSpanHook gets called by the ContextWithSpan
+ // function, when the Tracer implementation also implements
+ // this interface. It allows to put extra information into the
+ // context and make it available to the callers of the
+ // ContextWithSpan.
+ //
+ // This hook is invoked before the ContextWithSpan function
+ // actually puts the span into the context.
+ ContextWithSpanHook(ctx context.Context, span Span) context.Context
+}
diff --git a/vendor/github.com/opentracing/opentracing-go/ext/field.go b/vendor/github.com/opentracing/opentracing-go/ext/field.go
new file mode 100644
index 0000000..8282bd7
--- /dev/null
+++ b/vendor/github.com/opentracing/opentracing-go/ext/field.go
@@ -0,0 +1,17 @@
+package ext
+
+import (
+ "github.com/opentracing/opentracing-go"
+ "github.com/opentracing/opentracing-go/log"
+)
+
+// LogError sets the error=true tag on the Span and logs err as an "error" event.
+func LogError(span opentracing.Span, err error, fields ...log.Field) {
+ Error.Set(span, true)
+ ef := []log.Field{
+ log.Event("error"),
+ log.Error(err),
+ }
+ ef = append(ef, fields...)
+ span.LogFields(ef...)
+}
diff --git a/vendor/github.com/opentracing/opentracing-go/ext/tags.go b/vendor/github.com/opentracing/opentracing-go/ext/tags.go
index 8800129..a414b59 100644
--- a/vendor/github.com/opentracing/opentracing-go/ext/tags.go
+++ b/vendor/github.com/opentracing/opentracing-go/ext/tags.go
@@ -1,6 +1,6 @@
package ext
-import opentracing "github.com/opentracing/opentracing-go"
+import "github.com/opentracing/opentracing-go"
// These constants define common tag names recommended for better portability across
// tracing systems and languages/platforms.
@@ -47,40 +47,40 @@
// Component is a low-cardinality identifier of the module, library,
// or package that is generating a span.
- Component = stringTagName("component")
+ Component = StringTagName("component")
//////////////////////////////////////////////////////////////////////
// Sampling hint
//////////////////////////////////////////////////////////////////////
// SamplingPriority determines the priority of sampling this Span.
- SamplingPriority = uint16TagName("sampling.priority")
+ SamplingPriority = Uint16TagName("sampling.priority")
//////////////////////////////////////////////////////////////////////
- // Peer tags. These tags can be emitted by either client-side of
+ // Peer tags. These tags can be emitted by either client-side or
// server-side to describe the other side/service in a peer-to-peer
// communications, like an RPC call.
//////////////////////////////////////////////////////////////////////
// PeerService records the service name of the peer.
- PeerService = stringTagName("peer.service")
+ PeerService = StringTagName("peer.service")
// PeerAddress records the address name of the peer. This may be a "ip:port",
// a bare "hostname", a FQDN or even a database DSN substring
// like "mysql://username@127.0.0.1:3306/dbname"
- PeerAddress = stringTagName("peer.address")
+ PeerAddress = StringTagName("peer.address")
// PeerHostname records the host name of the peer
- PeerHostname = stringTagName("peer.hostname")
+ PeerHostname = StringTagName("peer.hostname")
// PeerHostIPv4 records IP v4 host address of the peer
- PeerHostIPv4 = ipv4Tag("peer.ipv4")
+ PeerHostIPv4 = IPv4TagName("peer.ipv4")
// PeerHostIPv6 records IP v6 host address of the peer
- PeerHostIPv6 = stringTagName("peer.ipv6")
+ PeerHostIPv6 = StringTagName("peer.ipv6")
// PeerPort records port number of the peer
- PeerPort = uint16TagName("peer.port")
+ PeerPort = Uint16TagName("peer.port")
//////////////////////////////////////////////////////////////////////
// HTTP Tags
@@ -88,46 +88,46 @@
// HTTPUrl should be the URL of the request being handled in this segment
// of the trace, in standard URI format. The protocol is optional.
- HTTPUrl = stringTagName("http.url")
+ HTTPUrl = StringTagName("http.url")
// HTTPMethod is the HTTP method of the request, and is case-insensitive.
- HTTPMethod = stringTagName("http.method")
+ HTTPMethod = StringTagName("http.method")
// HTTPStatusCode is the numeric HTTP status code (200, 404, etc) of the
// HTTP response.
- HTTPStatusCode = uint16TagName("http.status_code")
+ HTTPStatusCode = Uint16TagName("http.status_code")
//////////////////////////////////////////////////////////////////////
// DB Tags
//////////////////////////////////////////////////////////////////////
// DBInstance is database instance name.
- DBInstance = stringTagName("db.instance")
+ DBInstance = StringTagName("db.instance")
// DBStatement is a database statement for the given database type.
// It can be a query or a prepared statement (i.e., before substitution).
- DBStatement = stringTagName("db.statement")
+ DBStatement = StringTagName("db.statement")
// DBType is a database type. For any SQL database, "sql".
// For others, the lower-case database category, e.g. "redis"
- DBType = stringTagName("db.type")
+ DBType = StringTagName("db.type")
// DBUser is a username for accessing database.
- DBUser = stringTagName("db.user")
+ DBUser = StringTagName("db.user")
//////////////////////////////////////////////////////////////////////
// Message Bus Tag
//////////////////////////////////////////////////////////////////////
// MessageBusDestination is an address at which messages can be exchanged
- MessageBusDestination = stringTagName("message_bus.destination")
+ MessageBusDestination = StringTagName("message_bus.destination")
//////////////////////////////////////////////////////////////////////
// Error Tag
//////////////////////////////////////////////////////////////////////
// Error indicates that operation represented by the span resulted in an error.
- Error = boolTagName("error")
+ Error = BoolTagName("error")
)
// ---
@@ -163,48 +163,53 @@
// ---
-type stringTagName string
+// StringTagName is a common tag name to be set to a string value
+type StringTagName string
// Set adds a string tag to the `span`
-func (tag stringTagName) Set(span opentracing.Span, value string) {
+func (tag StringTagName) Set(span opentracing.Span, value string) {
span.SetTag(string(tag), value)
}
// ---
-type uint32TagName string
+// Uint32TagName is a common tag name to be set to a uint32 value
+type Uint32TagName string
// Set adds a uint32 tag to the `span`
-func (tag uint32TagName) Set(span opentracing.Span, value uint32) {
+func (tag Uint32TagName) Set(span opentracing.Span, value uint32) {
span.SetTag(string(tag), value)
}
// ---
-type uint16TagName string
+// Uint16TagName is a common tag name to be set to a uint16 value
+type Uint16TagName string
// Set adds a uint16 tag to the `span`
-func (tag uint16TagName) Set(span opentracing.Span, value uint16) {
+func (tag Uint16TagName) Set(span opentracing.Span, value uint16) {
span.SetTag(string(tag), value)
}
// ---
-type boolTagName string
+// BoolTagName is a common tag name to be set to a bool value
+type BoolTagName string
-// Add adds a bool tag to the `span`
-func (tag boolTagName) Set(span opentracing.Span, value bool) {
+// Set adds a bool tag to the `span`
+func (tag BoolTagName) Set(span opentracing.Span, value bool) {
span.SetTag(string(tag), value)
}
-type ipv4Tag string
+// IPv4TagName is a common tag name to be set to an ipv4 value
+type IPv4TagName string
// Set adds IP v4 host address of the peer as an uint32 value to the `span`, keep this for backward and zipkin compatibility
-func (tag ipv4Tag) Set(span opentracing.Span, value uint32) {
+func (tag IPv4TagName) Set(span opentracing.Span, value uint32) {
span.SetTag(string(tag), value)
}
// SetString records IP v4 host address of the peer as a .-separated tuple to the `span`. E.g., "127.0.0.1"
-func (tag ipv4Tag) SetString(span opentracing.Span, value string) {
+func (tag IPv4TagName) SetString(span opentracing.Span, value string) {
span.SetTag(string(tag), value)
}
diff --git a/vendor/github.com/opentracing/opentracing-go/globaltracer.go b/vendor/github.com/opentracing/opentracing-go/globaltracer.go
index 8c8e793..4f7066a 100644
--- a/vendor/github.com/opentracing/opentracing-go/globaltracer.go
+++ b/vendor/github.com/opentracing/opentracing-go/globaltracer.go
@@ -1,7 +1,12 @@
package opentracing
+type registeredTracer struct {
+ tracer Tracer
+ isRegistered bool
+}
+
var (
- globalTracer Tracer = NoopTracer{}
+ globalTracer = registeredTracer{NoopTracer{}, false}
)
// SetGlobalTracer sets the [singleton] opentracing.Tracer returned by
@@ -11,22 +16,27 @@
// Prior to calling `SetGlobalTracer`, any Spans started via the `StartSpan`
// (etc) globals are noops.
func SetGlobalTracer(tracer Tracer) {
- globalTracer = tracer
+ globalTracer = registeredTracer{tracer, true}
}
// GlobalTracer returns the global singleton `Tracer` implementation.
// Before `SetGlobalTracer()` is called, the `GlobalTracer()` is a noop
// implementation that drops all data handed to it.
func GlobalTracer() Tracer {
- return globalTracer
+ return globalTracer.tracer
}
// StartSpan defers to `Tracer.StartSpan`. See `GlobalTracer()`.
func StartSpan(operationName string, opts ...StartSpanOption) Span {
- return globalTracer.StartSpan(operationName, opts...)
+ return globalTracer.tracer.StartSpan(operationName, opts...)
}
// InitGlobalTracer is deprecated. Please use SetGlobalTracer.
func InitGlobalTracer(tracer Tracer) {
SetGlobalTracer(tracer)
}
+
+// IsGlobalTracerRegistered returns a `bool` to indicate if a tracer has been globally registered
+func IsGlobalTracerRegistered() bool {
+ return globalTracer.isRegistered
+}
diff --git a/vendor/github.com/opentracing/opentracing-go/go.mod b/vendor/github.com/opentracing/opentracing-go/go.mod
new file mode 100644
index 0000000..bf48bb5
--- /dev/null
+++ b/vendor/github.com/opentracing/opentracing-go/go.mod
@@ -0,0 +1,5 @@
+module github.com/opentracing/opentracing-go
+
+go 1.14
+
+require github.com/stretchr/testify v1.3.0
diff --git a/vendor/github.com/opentracing/opentracing-go/gocontext.go b/vendor/github.com/opentracing/opentracing-go/gocontext.go
index 222a652..1831bc9 100644
--- a/vendor/github.com/opentracing/opentracing-go/gocontext.go
+++ b/vendor/github.com/opentracing/opentracing-go/gocontext.go
@@ -1,14 +1,19 @@
package opentracing
-import "golang.org/x/net/context"
+import "context"
type contextKey struct{}
var activeSpanKey = contextKey{}
// ContextWithSpan returns a new `context.Context` that holds a reference to
-// `span`'s SpanContext.
+// the span. If span is nil, a new context without an active span is returned.
func ContextWithSpan(ctx context.Context, span Span) context.Context {
+ if span != nil {
+ if tracerWithHook, ok := span.Tracer().(TracerContextWithSpanExtension); ok {
+ ctx = tracerWithHook.ContextWithSpanHook(ctx, span)
+ }
+ }
return context.WithValue(ctx, activeSpanKey, span)
}
@@ -41,17 +46,20 @@
// ...
// }
func StartSpanFromContext(ctx context.Context, operationName string, opts ...StartSpanOption) (Span, context.Context) {
- return startSpanFromContextWithTracer(ctx, GlobalTracer(), operationName, opts...)
+ return StartSpanFromContextWithTracer(ctx, GlobalTracer(), operationName, opts...)
}
-// startSpanFromContextWithTracer is factored out for testing purposes.
-func startSpanFromContextWithTracer(ctx context.Context, tracer Tracer, operationName string, opts ...StartSpanOption) (Span, context.Context) {
- var span Span
+// StartSpanFromContextWithTracer starts and returns a span with `operationName`
+// using a span found within the context as a ChildOfRef. If that doesn't exist
+// it creates a root span. It also returns a context.Context object built
+// around the returned span.
+//
+// It's behavior is identical to StartSpanFromContext except that it takes an explicit
+// tracer as opposed to using the global tracer.
+func StartSpanFromContextWithTracer(ctx context.Context, tracer Tracer, operationName string, opts ...StartSpanOption) (Span, context.Context) {
if parentSpan := SpanFromContext(ctx); parentSpan != nil {
opts = append(opts, ChildOf(parentSpan.Context()))
- span = tracer.StartSpan(operationName, opts...)
- } else {
- span = tracer.StartSpan(operationName, opts...)
}
+ span := tracer.StartSpan(operationName, opts...)
return span, ContextWithSpan(ctx, span)
}
diff --git a/vendor/github.com/opentracing/opentracing-go/log/field.go b/vendor/github.com/opentracing/opentracing-go/log/field.go
index 50feea3..f222ded 100644
--- a/vendor/github.com/opentracing/opentracing-go/log/field.go
+++ b/vendor/github.com/opentracing/opentracing-go/log/field.go
@@ -122,16 +122,19 @@
}
}
-// Error adds an error with the key "error" to a Span.LogFields() record
+// Error adds an error with the key "error.object" to a Span.LogFields() record
func Error(err error) Field {
return Field{
- key: "error",
+ key: "error.object",
fieldType: errorType,
interfaceVal: err,
}
}
// Object adds an object-valued key:value pair to a Span.LogFields() record
+// Please pass in an immutable object, otherwise there may be concurrency issues.
+// Such as passing in the map, log.Object may result in "fatal error: concurrent map iteration and map write".
+// Because span is sent asynchronously, it is possible that this map will also be modified.
func Object(key string, obj interface{}) Field {
return Field{
key: key,
@@ -140,6 +143,16 @@
}
}
+// Event creates a string-valued Field for span logs with key="event" and value=val.
+func Event(val string) Field {
+ return String("event", val)
+}
+
+// Message creates a string-valued Field for span logs with key="message" and value=val.
+func Message(val string) Field {
+ return String("message", val)
+}
+
// LazyLogger allows for user-defined, late-bound logging of arbitrary data
type LazyLogger func(fv Encoder)
diff --git a/vendor/github.com/opentracing/opentracing-go/log/util.go b/vendor/github.com/opentracing/opentracing-go/log/util.go
index 3832feb..d57e28a 100644
--- a/vendor/github.com/opentracing/opentracing-go/log/util.go
+++ b/vendor/github.com/opentracing/opentracing-go/log/util.go
@@ -1,6 +1,9 @@
package log
-import "fmt"
+import (
+ "fmt"
+ "reflect"
+)
// InterleavedKVToFields converts keyValues a la Span.LogKV() to a Field slice
// a la Span.LogFields().
@@ -46,6 +49,10 @@
case float64:
fields[i] = Float64(key, typedVal)
default:
+ if typedVal == nil || (reflect.ValueOf(typedVal).Kind() == reflect.Ptr && reflect.ValueOf(typedVal).IsNil()) {
+ fields[i] = String(key, "nil")
+ continue
+ }
// When in doubt, coerce to a string
fields[i] = String(key, fmt.Sprint(typedVal))
}
diff --git a/vendor/github.com/opentracing/opentracing-go/noop.go b/vendor/github.com/opentracing/opentracing-go/noop.go
index 0d32f69..f9b680a 100644
--- a/vendor/github.com/opentracing/opentracing-go/noop.go
+++ b/vendor/github.com/opentracing/opentracing-go/noop.go
@@ -21,9 +21,9 @@
type noopSpanContext struct{}
var (
- defaultNoopSpanContext = noopSpanContext{}
- defaultNoopSpan = noopSpan{}
- defaultNoopTracer = NoopTracer{}
+ defaultNoopSpanContext SpanContext = noopSpanContext{}
+ defaultNoopSpan Span = noopSpan{}
+ defaultNoopTracer Tracer = NoopTracer{}
)
const (
@@ -35,7 +35,7 @@
// noopSpan:
func (n noopSpan) Context() SpanContext { return defaultNoopSpanContext }
-func (n noopSpan) SetBaggageItem(key, val string) Span { return defaultNoopSpan }
+func (n noopSpan) SetBaggageItem(key, val string) Span { return n }
func (n noopSpan) BaggageItem(key string) string { return emptyString }
func (n noopSpan) SetTag(key string, value interface{}) Span { return n }
func (n noopSpan) LogFields(fields ...log.Field) {}
diff --git a/vendor/github.com/opentracing/opentracing-go/propagation.go b/vendor/github.com/opentracing/opentracing-go/propagation.go
index 0dd466a..b0c275e 100644
--- a/vendor/github.com/opentracing/opentracing-go/propagation.go
+++ b/vendor/github.com/opentracing/opentracing-go/propagation.go
@@ -160,7 +160,7 @@
// Set conforms to the TextMapWriter interface.
func (c HTTPHeadersCarrier) Set(key, val string) {
h := http.Header(c)
- h.Add(key, val)
+ h.Set(key, val)
}
// ForeachKey conforms to the TextMapReader interface.
diff --git a/vendor/github.com/opentracing/opentracing-go/span.go b/vendor/github.com/opentracing/opentracing-go/span.go
index f6c3234..0d3fb53 100644
--- a/vendor/github.com/opentracing/opentracing-go/span.go
+++ b/vendor/github.com/opentracing/opentracing-go/span.go
@@ -41,6 +41,8 @@
Context() SpanContext
// Sets or changes the operation name.
+ //
+ // Returns a reference to this Span for chaining.
SetOperationName(operationName string) Span
// Adds a tag to the span.
@@ -51,6 +53,8 @@
// other tag value types is undefined at the OpenTracing level. If a
// tracing system does not know how to handle a particular value type, it
// may ignore the tag, but shall not panic.
+ //
+ // Returns a reference to this Span for chaining.
SetTag(key string, value interface{}) Span
// LogFields is an efficient and type-checked way to record key:value
diff --git a/vendor/github.com/opentracing/opentracing-go/tracer.go b/vendor/github.com/opentracing/opentracing-go/tracer.go
index 7bca1f7..715f0ce 100644
--- a/vendor/github.com/opentracing/opentracing-go/tracer.go
+++ b/vendor/github.com/opentracing/opentracing-go/tracer.go
@@ -44,8 +44,7 @@
// and each has an expected carrier type.
//
// Other packages may declare their own `format` values, much like the keys
- // used by `context.Context` (see
- // https://godoc.org/golang.org/x/net/context#WithValue).
+ // used by `context.Context` (see https://godoc.org/context#WithValue).
//
// Example usage (sans error handling):
//
diff --git a/vendor/github.com/spf13/cobra/README.md b/vendor/github.com/spf13/cobra/README.md
index 9d79934..3cf1b25 100644
--- a/vendor/github.com/spf13/cobra/README.md
+++ b/vendor/github.com/spf13/cobra/README.md
@@ -2,35 +2,14 @@
Cobra is both a library for creating powerful modern CLI applications as well as a program to generate applications and command files.
-Many of the most widely used Go projects are built using Cobra, such as:
-[Kubernetes](http://kubernetes.io/),
-[Hugo](http://gohugo.io),
-[rkt](https://github.com/coreos/rkt),
-[etcd](https://github.com/coreos/etcd),
-[Moby (former Docker)](https://github.com/moby/moby),
-[Docker (distribution)](https://github.com/docker/distribution),
-[OpenShift](https://www.openshift.com/),
-[Delve](https://github.com/derekparker/delve),
-[GopherJS](http://www.gopherjs.org/),
-[CockroachDB](http://www.cockroachlabs.com/),
-[Bleve](http://www.blevesearch.com/),
-[ProjectAtomic (enterprise)](http://www.projectatomic.io/),
-[Giant Swarm's gsctl](https://github.com/giantswarm/gsctl),
-[Nanobox](https://github.com/nanobox-io/nanobox)/[Nanopack](https://github.com/nanopack),
-[rclone](http://rclone.org/),
-[nehm](https://github.com/bogem/nehm),
-[Pouch](https://github.com/alibaba/pouch),
-[Istio](https://istio.io),
-[Prototool](https://github.com/uber/prototool),
-[mattermost-server](https://github.com/mattermost/mattermost-server),
-[Gardener](https://github.com/gardener/gardenctl),
-[Linkerd](https://linkerd.io/),
-[Github CLI](https://github.com/cli/cli)
-etc.
+Cobra is used in many Go projects such as [Kubernetes](http://kubernetes.io/),
+[Hugo](https://gohugo.io), and [Github CLI](https://github.com/cli/cli) to
+name a few. [This list](./projects_using_cobra.md) contains a more extensive list of projects using Cobra.
[![Build Status](https://travis-ci.org/spf13/cobra.svg "Travis CI status")](https://travis-ci.org/spf13/cobra)
[![GoDoc](https://godoc.org/github.com/spf13/cobra?status.svg)](https://godoc.org/github.com/spf13/cobra)
[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/cobra)](https://goreportcard.com/report/github.com/spf13/cobra)
+[![Slack](https://img.shields.io/badge/Slack-cobra-brightgreen)](https://gophers.slack.com/archives/CD3LP1199)
# Table of Contents
@@ -50,9 +29,8 @@
* [PreRun and PostRun Hooks](#prerun-and-postrun-hooks)
* [Suggestions when "unknown command" happens](#suggestions-when-unknown-command-happens)
* [Generating documentation for your command](#generating-documentation-for-your-command)
- * [Generating bash completions](#generating-bash-completions)
- * [Generating zsh completions](#generating-zsh-completions)
-- [Contributing](#contributing)
+ * [Generating shell completions](#generating-shell-completions)
+- [Contributing](CONTRIBUTING.md)
- [License](#license)
# Overview
@@ -72,7 +50,7 @@
* Intelligent suggestions (`app srver`... did you mean `app server`?)
* Automatic help generation for commands and flags
* Automatic help flag recognition of `-h`, `--help`, etc.
-* Automatically generated bash autocomplete for your application
+* Automatically generated shell autocomplete for your application (bash, zsh, fish, powershell)
* Automatically generated man pages for your application
* Command aliases so you can change things without breaking them
* The flexibility to define your own help, usage, etc.
@@ -130,7 +108,7 @@
of the library. This command will install the `cobra` generator executable
along with the library and its dependencies:
- go get -u github.com/spf13/cobra/cobra
+ go get -u github.com/spf13/cobra
Next, include Cobra in your application:
@@ -199,7 +177,7 @@
func Execute() {
if err := rootCmd.Execute(); err != nil {
- fmt.Println(err)
+ fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
@@ -335,6 +313,37 @@
}
```
+### Returning and handling errors
+
+If you wish to return an error to the caller of a command, `RunE` can be used.
+
+```go
+package cmd
+
+import (
+ "fmt"
+
+ "github.com/spf13/cobra"
+)
+
+func init() {
+ rootCmd.AddCommand(tryCmd)
+}
+
+var tryCmd = &cobra.Command{
+ Use: "try",
+ Short: "Try and possibly fail at something",
+ RunE: func(cmd *cobra.Command, args []string) error {
+ if err := someFunc(); err != nil {
+ return err
+ }
+ return nil
+ },
+}
+```
+
+The error can then be caught at the execute function call.
+
## Working with Flags
Flags provide modifiers to control how the action command operates.
@@ -410,6 +419,12 @@
rootCmd.MarkFlagRequired("region")
```
+Or, for persistent flags:
+```go
+rootCmd.PersistentFlags().StringVarP(&Region, "region", "r", "", "AWS region (required)")
+rootCmd.MarkPersistentFlagRequired("region")
+```
+
## Positional and Custom Arguments
Validation of positional arguments can be specified using the `Args` field
@@ -740,30 +755,11 @@
## Generating documentation for your command
-Cobra can generate documentation based on subcommands, flags, etc. in the following formats:
+Cobra can generate documentation based on subcommands, flags, etc. Read more about it in the [docs generation documentation](doc/README.md).
-- [Markdown](doc/md_docs.md)
-- [ReStructured Text](doc/rest_docs.md)
-- [Man Page](doc/man_docs.md)
+## Generating shell completions
-## Generating bash completions
-
-Cobra can generate a bash-completion file. If you add more information to your command, these completions can be amazingly powerful and flexible. Read more about it in [Bash Completions](bash_completions.md).
-
-## Generating zsh completions
-
-Cobra can generate zsh-completion file. Read more about it in
-[Zsh Completions](zsh_completions.md).
-
-# Contributing
-
-1. Fork it
-2. Download your fork to your PC (`git clone https://github.com/your_username/cobra && cd cobra`)
-3. Create your feature branch (`git checkout -b my-new-feature`)
-4. Make changes and add them (`git add .`)
-5. Commit your changes (`git commit -m 'Add some feature'`)
-6. Push to the branch (`git push origin my-new-feature`)
-7. Create new pull request
+Cobra can generate a shell-completion file for the following shells: Bash, Zsh, Fish, Powershell. If you add more information to your commands, these completions can be amazingly powerful and flexible. Read more about it in [Shell Completions](shell_completions.md).
# License
diff --git a/vendor/github.com/spf13/cobra/bash_completions.go b/vendor/github.com/spf13/cobra/bash_completions.go
index 1e27188..846636d 100644
--- a/vendor/github.com/spf13/cobra/bash_completions.go
+++ b/vendor/github.com/spf13/cobra/bash_completions.go
@@ -62,6 +62,12 @@
{
__%[1]s_debug "${FUNCNAME[0]}: cur is ${cur}, words[*] is ${words[*]}, #words[@] is ${#words[@]}"
+ local shellCompDirectiveError=%[3]d
+ local shellCompDirectiveNoSpace=%[4]d
+ local shellCompDirectiveNoFileComp=%[5]d
+ local shellCompDirectiveFilterFileExt=%[6]d
+ local shellCompDirectiveFilterDirs=%[7]d
+
local out requestComp lastParam lastChar comp directive args
# Prepare the command to request completions for the program.
@@ -95,24 +101,50 @@
__%[1]s_debug "${FUNCNAME[0]}: the completion directive is: ${directive}"
__%[1]s_debug "${FUNCNAME[0]}: the completions are: ${out[*]}"
- if [ $((directive & %[3]d)) -ne 0 ]; then
+ if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
# Error code. No completion.
__%[1]s_debug "${FUNCNAME[0]}: received error from custom completion go code"
return
else
- if [ $((directive & %[4]d)) -ne 0 ]; then
+ if [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ]; then
if [[ $(type -t compopt) = "builtin" ]]; then
__%[1]s_debug "${FUNCNAME[0]}: activating no space"
compopt -o nospace
fi
fi
- if [ $((directive & %[5]d)) -ne 0 ]; then
+ if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
if [[ $(type -t compopt) = "builtin" ]]; then
__%[1]s_debug "${FUNCNAME[0]}: activating no file completion"
compopt +o default
fi
fi
+ fi
+ if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
+ # File extension filtering
+ local fullFilter filter filteringCmd
+ # Do not use quotes around the $out variable or else newline
+ # characters will be kept.
+ for filter in ${out[*]}; do
+ fullFilter+="$filter|"
+ done
+
+ filteringCmd="_filedir $fullFilter"
+ __%[1]s_debug "File filtering command: $filteringCmd"
+ $filteringCmd
+ elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
+ # File completion for directories only
+ local subDir
+ # Use printf to strip any trailing newline
+ subdir=$(printf "%%s" "${out[0]}")
+ if [ -n "$subdir" ]; then
+ __%[1]s_debug "Listing directories in $subdir"
+ __%[1]s_handle_subdirs_in_dir_flag "$subdir"
+ else
+ __%[1]s_debug "Listing directories in ."
+ _filedir -d
+ fi
+ else
while IFS='' read -r comp; do
COMPREPLY+=("$comp")
done < <(compgen -W "${out[*]}" -- "$cur")
@@ -181,10 +213,9 @@
local completions
completions=("${commands[@]}")
if [[ ${#must_have_one_noun[@]} -ne 0 ]]; then
- completions=("${must_have_one_noun[@]}")
+ completions+=("${must_have_one_noun[@]}")
elif [[ -n "${has_completion_function}" ]]; then
# if a go completion function is provided, defer to that function
- completions=()
__%[1]s_handle_go_custom_completion
fi
if [[ ${#must_have_one_flag[@]} -ne 0 ]]; then
@@ -344,7 +375,9 @@
__%[1]s_handle_word
}
-`, name, ShellCompNoDescRequestCmd, ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp))
+`, name, ShellCompNoDescRequestCmd,
+ ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
+ ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs))
}
func writePostscript(buf *bytes.Buffer, name string) {
@@ -390,7 +423,7 @@
func writeCommands(buf *bytes.Buffer, cmd *Command) {
buf.WriteString(" commands=()\n")
for _, c := range cmd.Commands() {
- if !c.IsAvailableCommand() || c == cmd.helpCommand {
+ if !c.IsAvailableCommand() && c != cmd.helpCommand {
continue
}
buf.WriteString(fmt.Sprintf(" commands+=(%q)\n", c.Name()))
@@ -462,12 +495,14 @@
func writeLocalNonPersistentFlag(buf *bytes.Buffer, flag *pflag.Flag) {
name := flag.Name
- format := " local_nonpersistent_flags+=(\"--%s"
+ format := " local_nonpersistent_flags+=(\"--%[1]s\")\n"
if len(flag.NoOptDefVal) == 0 {
- format += "="
+ format += " local_nonpersistent_flags+=(\"--%[1]s=\")\n"
}
- format += "\")\n"
buf.WriteString(fmt.Sprintf(format, name))
+ if len(flag.Shorthand) > 0 {
+ buf.WriteString(fmt.Sprintf(" local_nonpersistent_flags+=(\"-%s\")\n", flag.Shorthand))
+ }
}
// Setup annotations for go completions for registered flags
@@ -502,7 +537,9 @@
if len(flag.Shorthand) > 0 {
writeShortFlag(buf, flag, cmd)
}
- if localNonPersistentFlags.Lookup(flag.Name) != nil {
+ // localNonPersistentFlags are used to stop the completion of subcommands when one is set
+ // if TraverseChildren is true we should allow to complete subcommands
+ if localNonPersistentFlags.Lookup(flag.Name) != nil && !cmd.Root().TraverseChildren {
writeLocalNonPersistentFlag(buf, flag)
}
})
@@ -583,7 +620,7 @@
func gen(buf *bytes.Buffer, cmd *Command) {
for _, c := range cmd.Commands() {
- if !c.IsAvailableCommand() || c == cmd.helpCommand {
+ if !c.IsAvailableCommand() && c != cmd.helpCommand {
continue
}
gen(buf, c)
diff --git a/vendor/github.com/spf13/cobra/command.go b/vendor/github.com/spf13/cobra/command.go
index 88e6ed7..77b399e 100644
--- a/vendor/github.com/spf13/cobra/command.go
+++ b/vendor/github.com/spf13/cobra/command.go
@@ -37,6 +37,14 @@
// definition to ensure usability.
type Command struct {
// Use is the one-line usage message.
+ // Recommended syntax is as follow:
+ // [ ] identifies an optional argument. Arguments that are not enclosed in brackets are required.
+ // ... indicates that you can specify multiple values for the previous argument.
+ // | indicates mutually exclusive information. You can use the argument to the left of the separator or the
+ // argument to the right of the separator. You cannot use both arguments in a single use of the command.
+ // { } delimits a set of mutually exclusive arguments when one of the arguments is required. If the arguments are
+ // optional, they are enclosed in brackets ([ ]).
+ // Example: add [-F file | -D dir]... [-f format] profile
Use string
// Aliases is an array of aliases that can be used instead of the first word in Use.
@@ -359,7 +367,7 @@
c.mergePersistentFlags()
err := tmpl(c.OutOrStderr(), c.UsageTemplate(), c)
if err != nil {
- c.Println(err)
+ c.PrintErrln(err)
}
return err
}
@@ -387,7 +395,7 @@
// See https://github.com/spf13/cobra/issues/1002
err := tmpl(c.OutOrStdout(), c.HelpTemplate(), c)
if err != nil {
- c.Println(err)
+ c.PrintErrln(err)
}
}
}
@@ -930,8 +938,8 @@
c = cmd
}
if !c.SilenceErrors {
- c.Println("Error:", err.Error())
- c.Printf("Run '%v --help' for usage.\n", c.CommandPath())
+ c.PrintErrln("Error:", err.Error())
+ c.PrintErrf("Run '%v --help' for usage.\n", c.CommandPath())
}
return c, err
}
@@ -959,7 +967,7 @@
// If root command has SilentErrors flagged,
// all subcommands should respect it
if !cmd.SilenceErrors && !c.SilenceErrors {
- c.Println("Error:", err.Error())
+ c.PrintErrln("Error:", err.Error())
}
// If root command has SilentUsage flagged,
@@ -979,6 +987,10 @@
}
func (c *Command) validateRequiredFlags() error {
+ if c.DisableFlagParsing {
+ return nil
+ }
+
flags := c.Flags()
missingFlagNames := []string{}
flags.VisitAll(func(pflag *flag.Flag) {
@@ -1052,7 +1064,25 @@
Short: "Help about any command",
Long: `Help provides help for any command in the application.
Simply type ` + c.Name() + ` help [path to command] for full details.`,
-
+ ValidArgsFunction: func(c *Command, args []string, toComplete string) ([]string, ShellCompDirective) {
+ var completions []string
+ cmd, _, e := c.Root().Find(args)
+ if e != nil {
+ return nil, ShellCompDirectiveNoFileComp
+ }
+ if cmd == nil {
+ // Root help command.
+ cmd = c.Root()
+ }
+ for _, subCmd := range cmd.Commands() {
+ if subCmd.IsAvailableCommand() || subCmd == cmd.helpCommand {
+ if strings.HasPrefix(subCmd.Name(), toComplete) {
+ completions = append(completions, fmt.Sprintf("%s\t%s", subCmd.Name(), subCmd.Short))
+ }
+ }
+ }
+ return completions, ShellCompDirectiveNoFileComp
+ },
Run: func(c *Command, args []string) {
cmd, _, e := c.Root().Find(args)
if cmd == nil || e != nil {
@@ -1179,12 +1209,12 @@
// PrintErrln is a convenience method to Println to the defined Err output, fallback to Stderr if not set.
func (c *Command) PrintErrln(i ...interface{}) {
- c.Print(fmt.Sprintln(i...))
+ c.PrintErr(fmt.Sprintln(i...))
}
// PrintErrf is a convenience method to Printf to the defined Err output, fallback to Stderr if not set.
func (c *Command) PrintErrf(format string, i ...interface{}) {
- c.Print(fmt.Sprintf(format, i...))
+ c.PrintErr(fmt.Sprintf(format, i...))
}
// CommandPath returns the full path to this command.
diff --git a/vendor/github.com/spf13/cobra/custom_completions.go b/vendor/github.com/spf13/cobra/custom_completions.go
index ba57327..f9e88e0 100644
--- a/vendor/github.com/spf13/cobra/custom_completions.go
+++ b/vendor/github.com/spf13/cobra/custom_completions.go
@@ -1,7 +1,6 @@
package cobra
import (
- "errors"
"fmt"
"os"
"strings"
@@ -38,8 +37,29 @@
// This currently does not work for zsh or bash < 4
ShellCompDirectiveNoFileComp
+ // ShellCompDirectiveFilterFileExt indicates that the provided completions
+ // should be used as file extension filters.
+ // For flags, using Command.MarkFlagFilename() and Command.MarkPersistentFlagFilename()
+ // is a shortcut to using this directive explicitly. The BashCompFilenameExt
+ // annotation can also be used to obtain the same behavior for flags.
+ ShellCompDirectiveFilterFileExt
+
+ // ShellCompDirectiveFilterDirs indicates that only directory names should
+ // be provided in file completion. To request directory names within another
+ // directory, the returned completions should specify the directory within
+ // which to search. The BashCompSubdirsInDir annotation can be used to
+ // obtain the same behavior but only for flags.
+ ShellCompDirectiveFilterDirs
+
+ // ===========================================================================
+
+ // All directives using iota should be above this one.
+ // For internal use.
+ shellCompDirectiveMaxValue
+
// ShellCompDirectiveDefault indicates to let the shell perform its default
// behavior after completions have been provided.
+ // This one must be last to avoid messing up the iota count.
ShellCompDirectiveDefault ShellCompDirective = 0
)
@@ -68,11 +88,17 @@
if d&ShellCompDirectiveNoFileComp != 0 {
directives = append(directives, "ShellCompDirectiveNoFileComp")
}
+ if d&ShellCompDirectiveFilterFileExt != 0 {
+ directives = append(directives, "ShellCompDirectiveFilterFileExt")
+ }
+ if d&ShellCompDirectiveFilterDirs != 0 {
+ directives = append(directives, "ShellCompDirectiveFilterDirs")
+ }
if len(directives) == 0 {
directives = append(directives, "ShellCompDirectiveDefault")
}
- if d > ShellCompDirectiveError+ShellCompDirectiveNoSpace+ShellCompDirectiveNoFileComp {
+ if d >= shellCompDirectiveMaxValue {
return fmt.Sprintf("ERROR: unexpected ShellCompDirective value: %d", d)
}
return strings.Join(directives, ", ")
@@ -105,11 +131,25 @@
// Remove any description that may be included following a tab character.
comp = strings.Split(comp, "\t")[0]
}
+
+ // Make sure we only write the first line to the output.
+ // This is needed if a description contains a linebreak.
+ // Otherwise the shell scripts will interpret the other lines as new flags
+ // and could therefore provide a wrong completion.
+ comp = strings.Split(comp, "\n")[0]
+
+ // Finally trim the completion. This is especially important to get rid
+ // of a trailing tab when there are no description following it.
+ // For example, a sub-command without a description should not be completed
+ // with a tab at the end (or else zsh will show a -- following it
+ // although there is no description).
+ comp = strings.TrimSpace(comp)
+
// Print each possible completion to stdout for the completion script to consume.
fmt.Fprintln(finalCmd.OutOrStdout(), comp)
}
- if directive > ShellCompDirectiveError+ShellCompDirectiveNoSpace+ShellCompDirectiveNoFileComp {
+ if directive >= shellCompDirectiveMaxValue {
directive = ShellCompDirectiveDefault
}
@@ -136,82 +176,104 @@
}
func (c *Command) getCompletions(args []string) (*Command, []string, ShellCompDirective, error) {
- var completions []string
-
// The last argument, which is not completely typed by the user,
// should not be part of the list of arguments
toComplete := args[len(args)-1]
trimmedArgs := args[:len(args)-1]
+ var finalCmd *Command
+ var finalArgs []string
+ var err error
// Find the real command for which completion must be performed
- finalCmd, finalArgs, err := c.Root().Find(trimmedArgs)
+ // check if we need to traverse here to parse local flags on parent commands
+ if c.Root().TraverseChildren {
+ finalCmd, finalArgs, err = c.Root().Traverse(trimmedArgs)
+ } else {
+ finalCmd, finalArgs, err = c.Root().Find(trimmedArgs)
+ }
if err != nil {
// Unable to find the real command. E.g., <program> someInvalidCmd <TAB>
- return c, completions, ShellCompDirectiveDefault, fmt.Errorf("Unable to find a command for arguments: %v", trimmedArgs)
+ return c, []string{}, ShellCompDirectiveDefault, fmt.Errorf("Unable to find a command for arguments: %v", trimmedArgs)
+ }
+
+ // Check if we are doing flag value completion before parsing the flags.
+ // This is important because if we are completing a flag value, we need to also
+ // remove the flag name argument from the list of finalArgs or else the parsing
+ // could fail due to an invalid value (incomplete) for the flag.
+ flag, finalArgs, toComplete, err := checkIfFlagCompletion(finalCmd, finalArgs, toComplete)
+ if err != nil {
+ // Error while attempting to parse flags
+ return finalCmd, []string{}, ShellCompDirectiveDefault, err
+ }
+
+ // Parse the flags early so we can check if required flags are set
+ if err = finalCmd.ParseFlags(finalArgs); err != nil {
+ return finalCmd, []string{}, ShellCompDirectiveDefault, fmt.Errorf("Error while parsing flags from args %v: %s", finalArgs, err.Error())
+ }
+
+ if flag != nil {
+ // Check if we are completing a flag value subject to annotations
+ if validExts, present := flag.Annotations[BashCompFilenameExt]; present {
+ if len(validExts) != 0 {
+ // File completion filtered by extensions
+ return finalCmd, validExts, ShellCompDirectiveFilterFileExt, nil
+ }
+
+ // The annotation requests simple file completion. There is no reason to do
+ // that since it is the default behavior anyway. Let's ignore this annotation
+ // in case the program also registered a completion function for this flag.
+ // Even though it is a mistake on the program's side, let's be nice when we can.
+ }
+
+ if subDir, present := flag.Annotations[BashCompSubdirsInDir]; present {
+ if len(subDir) == 1 {
+ // Directory completion from within a directory
+ return finalCmd, subDir, ShellCompDirectiveFilterDirs, nil
+ }
+ // Directory completion
+ return finalCmd, []string{}, ShellCompDirectiveFilterDirs, nil
+ }
}
// When doing completion of a flag name, as soon as an argument starts with
// a '-' we know it is a flag. We cannot use isFlagArg() here as it requires
- // the flag to be complete
- if len(toComplete) > 0 && toComplete[0] == '-' && !strings.Contains(toComplete, "=") {
- // We are completing a flag name
- finalCmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
- completions = append(completions, getFlagNameCompletions(flag, toComplete)...)
- })
- finalCmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) {
- completions = append(completions, getFlagNameCompletions(flag, toComplete)...)
- })
+ // the flag name to be complete
+ if flag == nil && len(toComplete) > 0 && toComplete[0] == '-' && !strings.Contains(toComplete, "=") {
+ var completions []string
- directive := ShellCompDirectiveDefault
- if len(completions) > 0 {
- if strings.HasSuffix(completions[0], "=") {
- directive = ShellCompDirectiveNoSpace
- }
- }
- return finalCmd, completions, directive, nil
- }
+ // First check for required flags
+ completions = completeRequireFlags(finalCmd, toComplete)
- var flag *pflag.Flag
- if !finalCmd.DisableFlagParsing {
- // We only do flag completion if we are allowed to parse flags
- // This is important for commands which have requested to do their own flag completion.
- flag, finalArgs, toComplete, err = checkIfFlagCompletion(finalCmd, finalArgs, toComplete)
- if err != nil {
- // Error while attempting to parse flags
- return finalCmd, completions, ShellCompDirectiveDefault, err
- }
- }
-
- if flag == nil {
- // Complete subcommand names
- for _, subCmd := range finalCmd.Commands() {
- if subCmd.IsAvailableCommand() && strings.HasPrefix(subCmd.Name(), toComplete) {
- completions = append(completions, fmt.Sprintf("%s\t%s", subCmd.Name(), subCmd.Short))
- }
- }
-
- if len(finalCmd.ValidArgs) > 0 {
- // Always complete ValidArgs, even if we are completing a subcommand name.
- // This is for commands that have both subcommands and ValidArgs.
- for _, validArg := range finalCmd.ValidArgs {
- if strings.HasPrefix(validArg, toComplete) {
- completions = append(completions, validArg)
+ // If we have not found any required flags, only then can we show regular flags
+ if len(completions) == 0 {
+ doCompleteFlags := func(flag *pflag.Flag) {
+ if !flag.Changed ||
+ strings.Contains(flag.Value.Type(), "Slice") ||
+ strings.Contains(flag.Value.Type(), "Array") {
+ // If the flag is not already present, or if it can be specified multiple times (Array or Slice)
+ // we suggest it as a completion
+ completions = append(completions, getFlagNameCompletions(flag, toComplete)...)
}
}
- // If there are ValidArgs specified (even if they don't match), we stop completion.
- // Only one of ValidArgs or ValidArgsFunction can be used for a single command.
- return finalCmd, completions, ShellCompDirectiveNoFileComp, nil
+ // We cannot use finalCmd.Flags() because we may not have called ParsedFlags() for commands
+ // that have set DisableFlagParsing; it is ParseFlags() that merges the inherited and
+ // non-inherited flags.
+ finalCmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) {
+ doCompleteFlags(flag)
+ })
+ finalCmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
+ doCompleteFlags(flag)
+ })
}
- // Always let the logic continue so as to add any ValidArgsFunction completions,
- // even if we already found sub-commands.
- // This is for commands that have subcommands but also specify a ValidArgsFunction.
- }
-
- // Parse the flags and extract the arguments to prepare for calling the completion function
- if err = finalCmd.ParseFlags(finalArgs); err != nil {
- return finalCmd, completions, ShellCompDirectiveDefault, fmt.Errorf("Error while parsing flags from args %v: %s", finalArgs, err.Error())
+ directive := ShellCompDirectiveNoFileComp
+ if len(completions) == 1 && strings.HasSuffix(completions[0], "=") {
+ // If there is a single completion, the shell usually adds a space
+ // after the completion. We don't want that if the flag ends with an =
+ directive = ShellCompDirectiveNoSpace
+ }
+ return finalCmd, completions, directive, nil
}
// We only remove the flags from the arguments if DisableFlagParsing is not set.
@@ -220,6 +282,73 @@
finalArgs = finalCmd.Flags().Args()
}
+ var completions []string
+ directive := ShellCompDirectiveDefault
+ if flag == nil {
+ foundLocalNonPersistentFlag := false
+ // If TraverseChildren is true on the root command we don't check for
+ // local flags because we can use a local flag on a parent command
+ if !finalCmd.Root().TraverseChildren {
+ // Check if there are any local, non-persistent flags on the command-line
+ localNonPersistentFlags := finalCmd.LocalNonPersistentFlags()
+ finalCmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
+ if localNonPersistentFlags.Lookup(flag.Name) != nil && flag.Changed {
+ foundLocalNonPersistentFlag = true
+ }
+ })
+ }
+
+ // Complete subcommand names, including the help command
+ if len(finalArgs) == 0 && !foundLocalNonPersistentFlag {
+ // We only complete sub-commands if:
+ // - there are no arguments on the command-line and
+ // - there are no local, non-peristent flag on the command-line or TraverseChildren is true
+ for _, subCmd := range finalCmd.Commands() {
+ if subCmd.IsAvailableCommand() || subCmd == finalCmd.helpCommand {
+ if strings.HasPrefix(subCmd.Name(), toComplete) {
+ completions = append(completions, fmt.Sprintf("%s\t%s", subCmd.Name(), subCmd.Short))
+ }
+ directive = ShellCompDirectiveNoFileComp
+ }
+ }
+ }
+
+ // Complete required flags even without the '-' prefix
+ completions = append(completions, completeRequireFlags(finalCmd, toComplete)...)
+
+ // Always complete ValidArgs, even if we are completing a subcommand name.
+ // This is for commands that have both subcommands and ValidArgs.
+ if len(finalCmd.ValidArgs) > 0 {
+ if len(finalArgs) == 0 {
+ // ValidArgs are only for the first argument
+ for _, validArg := range finalCmd.ValidArgs {
+ if strings.HasPrefix(validArg, toComplete) {
+ completions = append(completions, validArg)
+ }
+ }
+ directive = ShellCompDirectiveNoFileComp
+
+ // If no completions were found within commands or ValidArgs,
+ // see if there are any ArgAliases that should be completed.
+ if len(completions) == 0 {
+ for _, argAlias := range finalCmd.ArgAliases {
+ if strings.HasPrefix(argAlias, toComplete) {
+ completions = append(completions, argAlias)
+ }
+ }
+ }
+ }
+
+ // If there are ValidArgs specified (even if they don't match), we stop completion.
+ // Only one of ValidArgs or ValidArgsFunction can be used for a single command.
+ return finalCmd, completions, directive, nil
+ }
+
+ // Let the logic continue so as to add any ValidArgsFunction completions,
+ // even if we already found sub-commands.
+ // This is for commands that have subcommands but also specify a ValidArgsFunction.
+ }
+
// Find the completion function for the flag or command
var completionFn func(cmd *Command, args []string, toComplete string) ([]string, ShellCompDirective)
if flag != nil {
@@ -227,14 +356,14 @@
} else {
completionFn = finalCmd.ValidArgsFunction
}
- if completionFn == nil {
- // Go custom completion not supported/needed for this flag or command
- return finalCmd, completions, ShellCompDirectiveDefault, nil
+ if completionFn != nil {
+ // Go custom completion defined for this flag or command.
+ // Call the registered completion function to get the completions.
+ var comps []string
+ comps, directive = completionFn(finalCmd, finalArgs, toComplete)
+ completions = append(completions, comps...)
}
- // Call the registered completion function to get the completions
- comps, directive := completionFn(finalCmd, finalArgs, toComplete)
- completions = append(completions, comps...)
return finalCmd, completions, directive, nil
}
@@ -249,11 +378,18 @@
// Flag without the =
completions = append(completions, fmt.Sprintf("%s\t%s", flagName, flag.Usage))
- if len(flag.NoOptDefVal) == 0 {
- // Flag requires a value, so it can be suffixed with =
- flagName += "="
- completions = append(completions, fmt.Sprintf("%s\t%s", flagName, flag.Usage))
- }
+ // Why suggest both long forms: --flag and --flag= ?
+ // This forces the user to *always* have to type either an = or a space after the flag name.
+ // Let's be nice and avoid making users have to do that.
+ // Since boolean flags and shortname flags don't show the = form, let's go that route and never show it.
+ // The = form will still work, we just won't suggest it.
+ // This also makes the list of suggested flags shorter as we avoid all the = forms.
+ //
+ // if len(flag.NoOptDefVal) == 0 {
+ // // Flag requires a value, so it can be suffixed with =
+ // flagName += "="
+ // completions = append(completions, fmt.Sprintf("%s\t%s", flagName, flag.Usage))
+ // }
}
flagName = "-" + flag.Shorthand
@@ -264,17 +400,54 @@
return completions
}
+func completeRequireFlags(finalCmd *Command, toComplete string) []string {
+ var completions []string
+
+ doCompleteRequiredFlags := func(flag *pflag.Flag) {
+ if _, present := flag.Annotations[BashCompOneRequiredFlag]; present {
+ if !flag.Changed {
+ // If the flag is not already present, we suggest it as a completion
+ completions = append(completions, getFlagNameCompletions(flag, toComplete)...)
+ }
+ }
+ }
+
+ // We cannot use finalCmd.Flags() because we may not have called ParsedFlags() for commands
+ // that have set DisableFlagParsing; it is ParseFlags() that merges the inherited and
+ // non-inherited flags.
+ finalCmd.InheritedFlags().VisitAll(func(flag *pflag.Flag) {
+ doCompleteRequiredFlags(flag)
+ })
+ finalCmd.NonInheritedFlags().VisitAll(func(flag *pflag.Flag) {
+ doCompleteRequiredFlags(flag)
+ })
+
+ return completions
+}
+
func checkIfFlagCompletion(finalCmd *Command, args []string, lastArg string) (*pflag.Flag, []string, string, error) {
+ if finalCmd.DisableFlagParsing {
+ // We only do flag completion if we are allowed to parse flags
+ // This is important for commands which have requested to do their own flag completion.
+ return nil, args, lastArg, nil
+ }
+
var flagName string
trimmedArgs := args
flagWithEqual := false
- if isFlagArg(lastArg) {
+
+ // When doing completion of a flag name, as soon as an argument starts with
+ // a '-' we know it is a flag. We cannot use isFlagArg() here as that function
+ // requires the flag name to be complete
+ if len(lastArg) > 0 && lastArg[0] == '-' {
if index := strings.Index(lastArg, "="); index >= 0 {
+ // Flag with an =
flagName = strings.TrimLeft(lastArg[:index], "-")
lastArg = lastArg[index+1:]
flagWithEqual = true
} else {
- return nil, nil, "", errors.New("Unexpected completion request for flag")
+ // Normal flag completion
+ return nil, args, lastArg, nil
}
}
diff --git a/vendor/github.com/spf13/cobra/fish_completions.go b/vendor/github.com/spf13/cobra/fish_completions.go
index c83609c..eaae9bc 100644
--- a/vendor/github.com/spf13/cobra/fish_completions.go
+++ b/vendor/github.com/spf13/cobra/fish_completions.go
@@ -5,9 +5,15 @@
"fmt"
"io"
"os"
+ "strings"
)
func genFishComp(buf *bytes.Buffer, name string, includeDesc bool) {
+ // Variables should not contain a '-' or ':' character
+ nameForVar := name
+ nameForVar = strings.Replace(nameForVar, "-", "_", -1)
+ nameForVar = strings.Replace(nameForVar, ":", "_", -1)
+
compCmd := ShellCompRequestCmd
if !includeDesc {
compCmd = ShellCompNoDescRequestCmd
@@ -37,7 +43,13 @@
end
__%[1]s_debug "emptyArg: $emptyArg"
- set requestComp "$args[1] %[2]s $args[2..-1] $emptyArg"
+ if not type -q "$args[1]"
+ # This can happen when "complete --do-complete %[2]s" is called when running this script.
+ __%[1]s_debug "Cannot find $args[1]. No completions."
+ return
+ end
+
+ set requestComp "$args[1] %[3]s $args[2..-1] $emptyArg"
__%[1]s_debug "Calling $requestComp"
set results (eval $requestComp 2> /dev/null)
@@ -71,7 +83,8 @@
# Check if the command-line is already provided. This is useful for testing.
if not set --query __%[1]s_comp_commandLine
- set __%[1]s_comp_commandLine (commandline)
+ # Use the -c flag to allow for completion in the middle of the line
+ set __%[1]s_comp_commandLine (commandline -c)
end
__%[1]s_debug "commandLine is: $__%[1]s_comp_commandLine"
@@ -83,7 +96,7 @@
__%[1]s_debug "No completion, probably due to a failure"
# Might as well do file completion, in case it helps
set --global __%[1]s_comp_do_file_comp 1
- return 0
+ return 1
end
set directive (string sub --start 2 $results[-1])
@@ -92,20 +105,35 @@
__%[1]s_debug "Completions are: $__%[1]s_comp_results"
__%[1]s_debug "Directive is: $directive"
+ set shellCompDirectiveError %[4]d
+ set shellCompDirectiveNoSpace %[5]d
+ set shellCompDirectiveNoFileComp %[6]d
+ set shellCompDirectiveFilterFileExt %[7]d
+ set shellCompDirectiveFilterDirs %[8]d
+
if test -z "$directive"
set directive 0
end
- set compErr (math (math --scale 0 $directive / %[3]d) %% 2)
+ set compErr (math (math --scale 0 $directive / $shellCompDirectiveError) %% 2)
if test $compErr -eq 1
__%[1]s_debug "Received error directive: aborting."
# Might as well do file completion, in case it helps
set --global __%[1]s_comp_do_file_comp 1
- return 0
+ return 1
end
- set nospace (math (math --scale 0 $directive / %[4]d) %% 2)
- set nofiles (math (math --scale 0 $directive / %[5]d) %% 2)
+ set filefilter (math (math --scale 0 $directive / $shellCompDirectiveFilterFileExt) %% 2)
+ set dirfilter (math (math --scale 0 $directive / $shellCompDirectiveFilterDirs) %% 2)
+ if test $filefilter -eq 1; or test $dirfilter -eq 1
+ __%[1]s_debug "File extension filtering or directory filtering not supported"
+ # Do full file completion instead
+ set --global __%[1]s_comp_do_file_comp 1
+ return 1
+ end
+
+ set nospace (math (math --scale 0 $directive / $shellCompDirectiveNoSpace) %% 2)
+ set nofiles (math (math --scale 0 $directive / $shellCompDirectiveNoFileComp) %% 2)
__%[1]s_debug "nospace: $nospace, nofiles: $nofiles"
@@ -132,24 +160,31 @@
return (not set --query __%[1]s_comp_do_file_comp)
end
-# Remove any pre-existing completions for the program since we will be handling all of them
-# TODO this cleanup is not sufficient. Fish completions are only loaded once the user triggers
-# them, so the below deletion will not work as it is run too early. What else can we do?
-complete -c %[1]s -e
+# Since Fish completions are only loaded once the user triggers them, we trigger them ourselves
+# so we can properly delete any completions provided by another script.
+# The space after the the program name is essential to trigger completion for the program
+# and not completion of the program name itself.
+complete --do-complete "%[2]s " > /dev/null 2>&1
+# Using '> /dev/null 2>&1' since '&>' is not supported in older versions of fish.
+
+# Remove any pre-existing completions for the program since we will be handling all of them.
+complete -c %[2]s -e
# The order in which the below two lines are defined is very important so that __%[1]s_prepare_completions
# is called first. It is __%[1]s_prepare_completions that sets up the __%[1]s_comp_do_file_comp variable.
#
# This completion will be run second as complete commands are added FILO.
# It triggers file completion choices when __%[1]s_comp_do_file_comp is set.
-complete -c %[1]s -n 'set --query __%[1]s_comp_do_file_comp'
+complete -c %[2]s -n 'set --query __%[1]s_comp_do_file_comp'
# This completion will be run first as complete commands are added FILO.
-# The call to __%[1]s_prepare_completions will setup both __%[1]s_comp_results abd __%[1]s_comp_do_file_comp.
+# The call to __%[1]s_prepare_completions will setup both __%[1]s_comp_results and __%[1]s_comp_do_file_comp.
# It provides the program's completion choices.
-complete -c %[1]s -n '__%[1]s_prepare_completions' -f -a '$__%[1]s_comp_results'
+complete -c %[2]s -n '__%[1]s_prepare_completions' -f -a '$__%[1]s_comp_results'
-`, name, compCmd, ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp))
+`, nameForVar, name, compCmd,
+ ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
+ ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs))
}
// GenFishCompletion generates fish completion file and writes to the passed writer.
diff --git a/vendor/github.com/spf13/cobra/go.mod b/vendor/github.com/spf13/cobra/go.mod
index dea1030..57e3244 100644
--- a/vendor/github.com/spf13/cobra/go.mod
+++ b/vendor/github.com/spf13/cobra/go.mod
@@ -6,7 +6,7 @@
github.com/cpuguy83/go-md2man/v2 v2.0.0
github.com/inconshreveable/mousetrap v1.0.0
github.com/mitchellh/go-homedir v1.1.0
- github.com/spf13/pflag v1.0.3
- github.com/spf13/viper v1.4.0
- gopkg.in/yaml.v2 v2.2.2
+ github.com/spf13/pflag v1.0.5
+ github.com/spf13/viper v1.7.0
+ gopkg.in/yaml.v2 v2.2.8
)
diff --git a/vendor/github.com/spf13/cobra/shell_completions.go b/vendor/github.com/spf13/cobra/shell_completions.go
index ba0af9c..d99bf91 100644
--- a/vendor/github.com/spf13/cobra/shell_completions.go
+++ b/vendor/github.com/spf13/cobra/shell_completions.go
@@ -4,82 +4,81 @@
"github.com/spf13/pflag"
)
-// MarkFlagRequired adds the BashCompOneRequiredFlag annotation to the named flag if it exists,
+// MarkFlagRequired instructs the various shell completion implementations to
+// prioritize the named flag when performing completion,
// and causes your command to report an error if invoked without the flag.
func (c *Command) MarkFlagRequired(name string) error {
return MarkFlagRequired(c.Flags(), name)
}
-// MarkPersistentFlagRequired adds the BashCompOneRequiredFlag annotation to the named persistent flag if it exists,
+// MarkPersistentFlagRequired instructs the various shell completion implementations to
+// prioritize the named persistent flag when performing completion,
// and causes your command to report an error if invoked without the flag.
func (c *Command) MarkPersistentFlagRequired(name string) error {
return MarkFlagRequired(c.PersistentFlags(), name)
}
-// MarkFlagRequired adds the BashCompOneRequiredFlag annotation to the named flag if it exists,
+// MarkFlagRequired instructs the various shell completion implementations to
+// prioritize the named flag when performing completion,
// and causes your command to report an error if invoked without the flag.
func MarkFlagRequired(flags *pflag.FlagSet, name string) error {
return flags.SetAnnotation(name, BashCompOneRequiredFlag, []string{"true"})
}
-// MarkFlagFilename adds the BashCompFilenameExt annotation to the named flag, if it exists.
-// Generated bash autocompletion will select filenames for the flag, limiting to named extensions if provided.
+// MarkFlagFilename instructs the various shell completion implementations to
+// limit completions for the named flag to the specified file extensions.
func (c *Command) MarkFlagFilename(name string, extensions ...string) error {
return MarkFlagFilename(c.Flags(), name, extensions...)
}
// MarkFlagCustom adds the BashCompCustom annotation to the named flag, if it exists.
-// Generated bash autocompletion will call the bash function f for the flag.
+// The bash completion script will call the bash function f for the flag.
+//
+// This will only work for bash completion.
+// It is recommended to instead use c.RegisterFlagCompletionFunc(...) which allows
+// to register a Go function which will work across all shells.
func (c *Command) MarkFlagCustom(name string, f string) error {
return MarkFlagCustom(c.Flags(), name, f)
}
// MarkPersistentFlagFilename instructs the various shell completion
-// implementations to limit completions for this persistent flag to the
-// specified extensions (patterns).
-//
-// Shell Completion compatibility matrix: bash, zsh
+// implementations to limit completions for the named persistent flag to the
+// specified file extensions.
func (c *Command) MarkPersistentFlagFilename(name string, extensions ...string) error {
return MarkFlagFilename(c.PersistentFlags(), name, extensions...)
}
// MarkFlagFilename instructs the various shell completion implementations to
-// limit completions for this flag to the specified extensions (patterns).
-//
-// Shell Completion compatibility matrix: bash, zsh
+// limit completions for the named flag to the specified file extensions.
func MarkFlagFilename(flags *pflag.FlagSet, name string, extensions ...string) error {
return flags.SetAnnotation(name, BashCompFilenameExt, extensions)
}
-// MarkFlagCustom instructs the various shell completion implementations to
-// limit completions for this flag to the specified extensions (patterns).
+// MarkFlagCustom adds the BashCompCustom annotation to the named flag, if it exists.
+// The bash completion script will call the bash function f for the flag.
//
-// Shell Completion compatibility matrix: bash, zsh
+// This will only work for bash completion.
+// It is recommended to instead use c.RegisterFlagCompletionFunc(...) which allows
+// to register a Go function which will work across all shells.
func MarkFlagCustom(flags *pflag.FlagSet, name string, f string) error {
return flags.SetAnnotation(name, BashCompCustom, []string{f})
}
// MarkFlagDirname instructs the various shell completion implementations to
-// complete only directories with this named flag.
-//
-// Shell Completion compatibility matrix: zsh
+// limit completions for the named flag to directory names.
func (c *Command) MarkFlagDirname(name string) error {
return MarkFlagDirname(c.Flags(), name)
}
// MarkPersistentFlagDirname instructs the various shell completion
-// implementations to complete only directories with this persistent named flag.
-//
-// Shell Completion compatibility matrix: zsh
+// implementations to limit completions for the named persistent flag to
+// directory names.
func (c *Command) MarkPersistentFlagDirname(name string) error {
return MarkFlagDirname(c.PersistentFlags(), name)
}
// MarkFlagDirname instructs the various shell completion implementations to
-// complete only directories with this specified flag.
-//
-// Shell Completion compatibility matrix: zsh
+// limit completions for the named flag to directory names.
func MarkFlagDirname(flags *pflag.FlagSet, name string) error {
- zshPattern := "-(/)"
- return flags.SetAnnotation(name, zshCompDirname, []string{zshPattern})
+ return flags.SetAnnotation(name, BashCompSubdirsInDir, []string{})
}
diff --git a/vendor/github.com/spf13/cobra/zsh_completions.go b/vendor/github.com/spf13/cobra/zsh_completions.go
index 1275548..92a7039 100644
--- a/vendor/github.com/spf13/cobra/zsh_completions.go
+++ b/vendor/github.com/spf13/cobra/zsh_completions.go
@@ -1,336 +1,240 @@
package cobra
import (
- "encoding/json"
+ "bytes"
"fmt"
"io"
"os"
- "sort"
- "strings"
- "text/template"
-
- "github.com/spf13/pflag"
)
-const (
- zshCompArgumentAnnotation = "cobra_annotations_zsh_completion_argument_annotation"
- zshCompArgumentFilenameComp = "cobra_annotations_zsh_completion_argument_file_completion"
- zshCompArgumentWordComp = "cobra_annotations_zsh_completion_argument_word_completion"
- zshCompDirname = "cobra_annotations_zsh_dirname"
-)
-
-var (
- zshCompFuncMap = template.FuncMap{
- "genZshFuncName": zshCompGenFuncName,
- "extractFlags": zshCompExtractFlag,
- "genFlagEntryForZshArguments": zshCompGenFlagEntryForArguments,
- "extractArgsCompletions": zshCompExtractArgumentCompletionHintsForRendering,
- }
- zshCompletionText = `
-{{/* should accept Command (that contains subcommands) as parameter */}}
-{{define "argumentsC" -}}
-{{ $cmdPath := genZshFuncName .}}
-function {{$cmdPath}} {
- local -a commands
-
- _arguments -C \{{- range extractFlags .}}
- {{genFlagEntryForZshArguments .}} \{{- end}}
- "1: :->cmnds" \
- "*::arg:->args"
-
- case $state in
- cmnds)
- commands=({{range .Commands}}{{if not .Hidden}}
- "{{.Name}}:{{.Short}}"{{end}}{{end}}
- )
- _describe "command" commands
- ;;
- esac
-
- case "$words[1]" in {{- range .Commands}}{{if not .Hidden}}
- {{.Name}})
- {{$cmdPath}}_{{.Name}}
- ;;{{end}}{{end}}
- esac
-}
-{{range .Commands}}{{if not .Hidden}}
-{{template "selectCmdTemplate" .}}
-{{- end}}{{end}}
-{{- end}}
-
-{{/* should accept Command without subcommands as parameter */}}
-{{define "arguments" -}}
-function {{genZshFuncName .}} {
-{{" _arguments"}}{{range extractFlags .}} \
- {{genFlagEntryForZshArguments . -}}
-{{end}}{{range extractArgsCompletions .}} \
- {{.}}{{end}}
-}
-{{end}}
-
-{{/* dispatcher for commands with or without subcommands */}}
-{{define "selectCmdTemplate" -}}
-{{if .Hidden}}{{/* ignore hidden*/}}{{else -}}
-{{if .Commands}}{{template "argumentsC" .}}{{else}}{{template "arguments" .}}{{end}}
-{{- end}}
-{{- end}}
-
-{{/* template entry point */}}
-{{define "Main" -}}
-#compdef _{{.Name}} {{.Name}}
-
-{{template "selectCmdTemplate" .}}
-{{end}}
-`
-)
-
-// zshCompArgsAnnotation is used to encode/decode zsh completion for
-// arguments to/from Command.Annotations.
-type zshCompArgsAnnotation map[int]zshCompArgHint
-
-type zshCompArgHint struct {
- // Indicates the type of the completion to use. One of:
- // zshCompArgumentFilenameComp or zshCompArgumentWordComp
- Tipe string `json:"type"`
-
- // A value for the type above (globs for file completion or words)
- Options []string `json:"options"`
-}
-
-// GenZshCompletionFile generates zsh completion file.
+// GenZshCompletionFile generates zsh completion file including descriptions.
func (c *Command) GenZshCompletionFile(filename string) error {
+ return c.genZshCompletionFile(filename, true)
+}
+
+// GenZshCompletion generates zsh completion file including descriptions
+// and writes it to the passed writer.
+func (c *Command) GenZshCompletion(w io.Writer) error {
+ return c.genZshCompletion(w, true)
+}
+
+// GenZshCompletionFileNoDesc generates zsh completion file without descriptions.
+func (c *Command) GenZshCompletionFileNoDesc(filename string) error {
+ return c.genZshCompletionFile(filename, false)
+}
+
+// GenZshCompletionNoDesc generates zsh completion file without descriptions
+// and writes it to the passed writer.
+func (c *Command) GenZshCompletionNoDesc(w io.Writer) error {
+ return c.genZshCompletion(w, false)
+}
+
+// MarkZshCompPositionalArgumentFile only worked for zsh and its behavior was
+// not consistent with Bash completion. It has therefore been disabled.
+// Instead, when no other completion is specified, file completion is done by
+// default for every argument. One can disable file completion on a per-argument
+// basis by using ValidArgsFunction and ShellCompDirectiveNoFileComp.
+// To achieve file extension filtering, one can use ValidArgsFunction and
+// ShellCompDirectiveFilterFileExt.
+//
+// Deprecated
+func (c *Command) MarkZshCompPositionalArgumentFile(argPosition int, patterns ...string) error {
+ return nil
+}
+
+// MarkZshCompPositionalArgumentWords only worked for zsh. It has therefore
+// been disabled.
+// To achieve the same behavior across all shells, one can use
+// ValidArgs (for the first argument only) or ValidArgsFunction for
+// any argument (can include the first one also).
+//
+// Deprecated
+func (c *Command) MarkZshCompPositionalArgumentWords(argPosition int, words ...string) error {
+ return nil
+}
+
+func (c *Command) genZshCompletionFile(filename string, includeDesc bool) error {
outFile, err := os.Create(filename)
if err != nil {
return err
}
defer outFile.Close()
- return c.GenZshCompletion(outFile)
+ return c.genZshCompletion(outFile, includeDesc)
}
-// GenZshCompletion generates a zsh completion file and writes to the passed
-// writer. The completion always run on the root command regardless of the
-// command it was called from.
-func (c *Command) GenZshCompletion(w io.Writer) error {
- tmpl, err := template.New("Main").Funcs(zshCompFuncMap).Parse(zshCompletionText)
- if err != nil {
- return fmt.Errorf("error creating zsh completion template: %v", err)
- }
- return tmpl.Execute(w, c.Root())
+func (c *Command) genZshCompletion(w io.Writer, includeDesc bool) error {
+ buf := new(bytes.Buffer)
+ genZshComp(buf, c.Name(), includeDesc)
+ _, err := buf.WriteTo(w)
+ return err
}
-// MarkZshCompPositionalArgumentFile marks the specified argument (first
-// argument is 1) as completed by file selection. patterns (e.g. "*.txt") are
-// optional - if not provided the completion will search for all files.
-func (c *Command) MarkZshCompPositionalArgumentFile(argPosition int, patterns ...string) error {
- if argPosition < 1 {
- return fmt.Errorf("Invalid argument position (%d)", argPosition)
+func genZshComp(buf *bytes.Buffer, name string, includeDesc bool) {
+ compCmd := ShellCompRequestCmd
+ if !includeDesc {
+ compCmd = ShellCompNoDescRequestCmd
}
- annotation, err := c.zshCompGetArgsAnnotations()
- if err != nil {
- return err
- }
- if c.zshcompArgsAnnotationnIsDuplicatePosition(annotation, argPosition) {
- return fmt.Errorf("Duplicate annotation for positional argument at index %d", argPosition)
- }
- annotation[argPosition] = zshCompArgHint{
- Tipe: zshCompArgumentFilenameComp,
- Options: patterns,
- }
- return c.zshCompSetArgsAnnotations(annotation)
+ buf.WriteString(fmt.Sprintf(`#compdef _%[1]s %[1]s
+
+# zsh completion for %-36[1]s -*- shell-script -*-
+
+__%[1]s_debug()
+{
+ local file="$BASH_COMP_DEBUG_FILE"
+ if [[ -n ${file} ]]; then
+ echo "$*" >> "${file}"
+ fi
}
-// MarkZshCompPositionalArgumentWords marks the specified positional argument
-// (first argument is 1) as completed by the provided words. At east one word
-// must be provided, spaces within words will be offered completion with
-// "word\ word".
-func (c *Command) MarkZshCompPositionalArgumentWords(argPosition int, words ...string) error {
- if argPosition < 1 {
- return fmt.Errorf("Invalid argument position (%d)", argPosition)
- }
- if len(words) == 0 {
- return fmt.Errorf("Trying to set empty word list for positional argument %d", argPosition)
- }
- annotation, err := c.zshCompGetArgsAnnotations()
- if err != nil {
- return err
- }
- if c.zshcompArgsAnnotationnIsDuplicatePosition(annotation, argPosition) {
- return fmt.Errorf("Duplicate annotation for positional argument at index %d", argPosition)
- }
- annotation[argPosition] = zshCompArgHint{
- Tipe: zshCompArgumentWordComp,
- Options: words,
- }
- return c.zshCompSetArgsAnnotations(annotation)
+_%[1]s()
+{
+ local shellCompDirectiveError=%[3]d
+ local shellCompDirectiveNoSpace=%[4]d
+ local shellCompDirectiveNoFileComp=%[5]d
+ local shellCompDirectiveFilterFileExt=%[6]d
+ local shellCompDirectiveFilterDirs=%[7]d
+
+ local lastParam lastChar flagPrefix requestComp out directive compCount comp lastComp
+ local -a completions
+
+ __%[1]s_debug "\n========= starting completion logic =========="
+ __%[1]s_debug "CURRENT: ${CURRENT}, words[*]: ${words[*]}"
+
+ # The user could have moved the cursor backwards on the command-line.
+ # We need to trigger completion from the $CURRENT location, so we need
+ # to truncate the command-line ($words) up to the $CURRENT location.
+ # (We cannot use $CURSOR as its value does not work when a command is an alias.)
+ words=("${=words[1,CURRENT]}")
+ __%[1]s_debug "Truncated words[*]: ${words[*]},"
+
+ lastParam=${words[-1]}
+ lastChar=${lastParam[-1]}
+ __%[1]s_debug "lastParam: ${lastParam}, lastChar: ${lastChar}"
+
+ # For zsh, when completing a flag with an = (e.g., %[1]s -n=<TAB>)
+ # completions must be prefixed with the flag
+ setopt local_options BASH_REMATCH
+ if [[ "${lastParam}" =~ '-.*=' ]]; then
+ # We are dealing with a flag with an =
+ flagPrefix="-P ${BASH_REMATCH}"
+ fi
+
+ # Prepare the command to obtain completions
+ requestComp="${words[1]} %[2]s ${words[2,-1]}"
+ if [ "${lastChar}" = "" ]; then
+ # If the last parameter is complete (there is a space following it)
+ # We add an extra empty parameter so we can indicate this to the go completion code.
+ __%[1]s_debug "Adding extra empty parameter"
+ requestComp="${requestComp} \"\""
+ fi
+
+ __%[1]s_debug "About to call: eval ${requestComp}"
+
+ # Use eval to handle any environment variables and such
+ out=$(eval ${requestComp} 2>/dev/null)
+ __%[1]s_debug "completion output: ${out}"
+
+ # Extract the directive integer following a : from the last line
+ local lastLine
+ while IFS='\n' read -r line; do
+ lastLine=${line}
+ done < <(printf "%%s\n" "${out[@]}")
+ __%[1]s_debug "last line: ${lastLine}"
+
+ if [ "${lastLine[1]}" = : ]; then
+ directive=${lastLine[2,-1]}
+ # Remove the directive including the : and the newline
+ local suffix
+ (( suffix=${#lastLine}+2))
+ out=${out[1,-$suffix]}
+ else
+ # There is no directive specified. Leave $out as is.
+ __%[1]s_debug "No directive found. Setting do default"
+ directive=0
+ fi
+
+ __%[1]s_debug "directive: ${directive}"
+ __%[1]s_debug "completions: ${out}"
+ __%[1]s_debug "flagPrefix: ${flagPrefix}"
+
+ if [ $((directive & shellCompDirectiveError)) -ne 0 ]; then
+ __%[1]s_debug "Completion received error. Ignoring completions."
+ return
+ fi
+
+ compCount=0
+ while IFS='\n' read -r comp; do
+ if [ -n "$comp" ]; then
+ # If requested, completions are returned with a description.
+ # The description is preceded by a TAB character.
+ # For zsh's _describe, we need to use a : instead of a TAB.
+ # We first need to escape any : as part of the completion itself.
+ comp=${comp//:/\\:}
+
+ local tab=$(printf '\t')
+ comp=${comp//$tab/:}
+
+ ((compCount++))
+ __%[1]s_debug "Adding completion: ${comp}"
+ completions+=${comp}
+ lastComp=$comp
+ fi
+ done < <(printf "%%s\n" "${out[@]}")
+
+ if [ $((directive & shellCompDirectiveFilterFileExt)) -ne 0 ]; then
+ # File extension filtering
+ local filteringCmd
+ filteringCmd='_files'
+ for filter in ${completions[@]}; do
+ if [ ${filter[1]} != '*' ]; then
+ # zsh requires a glob pattern to do file filtering
+ filter="\*.$filter"
+ fi
+ filteringCmd+=" -g $filter"
+ done
+ filteringCmd+=" ${flagPrefix}"
+
+ __%[1]s_debug "File filtering command: $filteringCmd"
+ _arguments '*:filename:'"$filteringCmd"
+ elif [ $((directive & shellCompDirectiveFilterDirs)) -ne 0 ]; then
+ # File completion for directories only
+ local subDir
+ subdir="${completions[1]}"
+ if [ -n "$subdir" ]; then
+ __%[1]s_debug "Listing directories in $subdir"
+ pushd "${subdir}" >/dev/null 2>&1
+ else
+ __%[1]s_debug "Listing directories in ."
+ fi
+
+ _arguments '*:dirname:_files -/'" ${flagPrefix}"
+ if [ -n "$subdir" ]; then
+ popd >/dev/null 2>&1
+ fi
+ elif [ $((directive & shellCompDirectiveNoSpace)) -ne 0 ] && [ ${compCount} -eq 1 ]; then
+ __%[1]s_debug "Activating nospace."
+ # We can use compadd here as there is no description when
+ # there is only one completion.
+ compadd -S '' "${lastComp}"
+ elif [ ${compCount} -eq 0 ]; then
+ if [ $((directive & shellCompDirectiveNoFileComp)) -ne 0 ]; then
+ __%[1]s_debug "deactivating file completion"
+ else
+ # Perform file completion
+ __%[1]s_debug "activating file completion"
+ _arguments '*:filename:_files'" ${flagPrefix}"
+ fi
+ else
+ _describe "completions" completions $(echo $flagPrefix)
+ fi
}
-func zshCompExtractArgumentCompletionHintsForRendering(c *Command) ([]string, error) {
- var result []string
- annotation, err := c.zshCompGetArgsAnnotations()
- if err != nil {
- return nil, err
- }
- for k, v := range annotation {
- s, err := zshCompRenderZshCompArgHint(k, v)
- if err != nil {
- return nil, err
- }
- result = append(result, s)
- }
- if len(c.ValidArgs) > 0 {
- if _, positionOneExists := annotation[1]; !positionOneExists {
- s, err := zshCompRenderZshCompArgHint(1, zshCompArgHint{
- Tipe: zshCompArgumentWordComp,
- Options: c.ValidArgs,
- })
- if err != nil {
- return nil, err
- }
- result = append(result, s)
- }
- }
- sort.Strings(result)
- return result, nil
-}
-
-func zshCompRenderZshCompArgHint(i int, z zshCompArgHint) (string, error) {
- switch t := z.Tipe; t {
- case zshCompArgumentFilenameComp:
- var globs []string
- for _, g := range z.Options {
- globs = append(globs, fmt.Sprintf(`-g "%s"`, g))
- }
- return fmt.Sprintf(`'%d: :_files %s'`, i, strings.Join(globs, " ")), nil
- case zshCompArgumentWordComp:
- var words []string
- for _, w := range z.Options {
- words = append(words, fmt.Sprintf("%q", w))
- }
- return fmt.Sprintf(`'%d: :(%s)'`, i, strings.Join(words, " ")), nil
- default:
- return "", fmt.Errorf("Invalid zsh argument completion annotation: %s", t)
- }
-}
-
-func (c *Command) zshcompArgsAnnotationnIsDuplicatePosition(annotation zshCompArgsAnnotation, position int) bool {
- _, dup := annotation[position]
- return dup
-}
-
-func (c *Command) zshCompGetArgsAnnotations() (zshCompArgsAnnotation, error) {
- annotation := make(zshCompArgsAnnotation)
- annotationString, ok := c.Annotations[zshCompArgumentAnnotation]
- if !ok {
- return annotation, nil
- }
- err := json.Unmarshal([]byte(annotationString), &annotation)
- if err != nil {
- return annotation, fmt.Errorf("Error unmarshaling zsh argument annotation: %v", err)
- }
- return annotation, nil
-}
-
-func (c *Command) zshCompSetArgsAnnotations(annotation zshCompArgsAnnotation) error {
- jsn, err := json.Marshal(annotation)
- if err != nil {
- return fmt.Errorf("Error marshaling zsh argument annotation: %v", err)
- }
- if c.Annotations == nil {
- c.Annotations = make(map[string]string)
- }
- c.Annotations[zshCompArgumentAnnotation] = string(jsn)
- return nil
-}
-
-func zshCompGenFuncName(c *Command) string {
- if c.HasParent() {
- return zshCompGenFuncName(c.Parent()) + "_" + c.Name()
- }
- return "_" + c.Name()
-}
-
-func zshCompExtractFlag(c *Command) []*pflag.Flag {
- var flags []*pflag.Flag
- c.LocalFlags().VisitAll(func(f *pflag.Flag) {
- if !f.Hidden {
- flags = append(flags, f)
- }
- })
- c.InheritedFlags().VisitAll(func(f *pflag.Flag) {
- if !f.Hidden {
- flags = append(flags, f)
- }
- })
- return flags
-}
-
-// zshCompGenFlagEntryForArguments returns an entry that matches _arguments
-// zsh-completion parameters. It's too complicated to generate in a template.
-func zshCompGenFlagEntryForArguments(f *pflag.Flag) string {
- if f.Name == "" || f.Shorthand == "" {
- return zshCompGenFlagEntryForSingleOptionFlag(f)
- }
- return zshCompGenFlagEntryForMultiOptionFlag(f)
-}
-
-func zshCompGenFlagEntryForSingleOptionFlag(f *pflag.Flag) string {
- var option, multiMark, extras string
-
- if zshCompFlagCouldBeSpecifiedMoreThenOnce(f) {
- multiMark = "*"
- }
-
- option = "--" + f.Name
- if option == "--" {
- option = "-" + f.Shorthand
- }
- extras = zshCompGenFlagEntryExtras(f)
-
- return fmt.Sprintf(`'%s%s[%s]%s'`, multiMark, option, zshCompQuoteFlagDescription(f.Usage), extras)
-}
-
-func zshCompGenFlagEntryForMultiOptionFlag(f *pflag.Flag) string {
- var options, parenMultiMark, curlyMultiMark, extras string
-
- if zshCompFlagCouldBeSpecifiedMoreThenOnce(f) {
- parenMultiMark = "*"
- curlyMultiMark = "\\*"
- }
-
- options = fmt.Sprintf(`'(%s-%s %s--%s)'{%s-%s,%s--%s}`,
- parenMultiMark, f.Shorthand, parenMultiMark, f.Name, curlyMultiMark, f.Shorthand, curlyMultiMark, f.Name)
- extras = zshCompGenFlagEntryExtras(f)
-
- return fmt.Sprintf(`%s'[%s]%s'`, options, zshCompQuoteFlagDescription(f.Usage), extras)
-}
-
-func zshCompGenFlagEntryExtras(f *pflag.Flag) string {
- if f.NoOptDefVal != "" {
- return ""
- }
-
- extras := ":" // allow options for flag (even without assistance)
- for key, values := range f.Annotations {
- switch key {
- case zshCompDirname:
- extras = fmt.Sprintf(":filename:_files -g %q", values[0])
- case BashCompFilenameExt:
- extras = ":filename:_files"
- for _, pattern := range values {
- extras = extras + fmt.Sprintf(` -g "%s"`, pattern)
- }
- }
- }
-
- return extras
-}
-
-func zshCompFlagCouldBeSpecifiedMoreThenOnce(f *pflag.Flag) bool {
- return strings.Contains(f.Value.Type(), "Slice") ||
- strings.Contains(f.Value.Type(), "Array")
-}
-
-func zshCompQuoteFlagDescription(s string) string {
- return strings.Replace(s, "'", `'\''`, -1)
+# don't run the completion function when being source-ed or eval-ed
+if [ "$funcstack[1]" = "_%[1]s" ]; then
+ _%[1]s
+fi
+`, name, compCmd,
+ ShellCompDirectiveError, ShellCompDirectiveNoSpace, ShellCompDirectiveNoFileComp,
+ ShellCompDirectiveFilterFileExt, ShellCompDirectiveFilterDirs))
}
diff --git a/vendor/github.com/tonistiigi/fsutil/chtimes_nolinux.go b/vendor/github.com/tonistiigi/fsutil/chtimes_nolinux.go
index cdd80ec..a3ba098 100644
--- a/vendor/github.com/tonistiigi/fsutil/chtimes_nolinux.go
+++ b/vendor/github.com/tonistiigi/fsutil/chtimes_nolinux.go
@@ -5,16 +5,18 @@
import (
"os"
"time"
+
+ "github.com/pkg/errors"
)
func chtimes(path string, un int64) error {
mtime := time.Unix(0, un)
fi, err := os.Lstat(path)
if err != nil {
- return err
+ return errors.WithStack(err)
}
if fi.Mode()&os.ModeSymlink != 0 {
return nil
}
- return os.Chtimes(path, mtime, mtime)
+ return errors.WithStack(os.Chtimes(path, mtime, mtime))
}
diff --git a/vendor/github.com/tonistiigi/fsutil/copy/copy.go b/vendor/github.com/tonistiigi/fsutil/copy/copy.go
index 27b7d56..02b3dc9 100644
--- a/vendor/github.com/tonistiigi/fsutil/copy/copy.go
+++ b/vendor/github.com/tonistiigi/fsutil/copy/copy.go
@@ -147,7 +147,7 @@
}
type User struct {
- Uid, Gid int
+ UID, GID int
}
type Chowner func(*User) (*User, error)
@@ -175,7 +175,7 @@
func WithChown(uid, gid int) Opt {
return func(ci *CopyInfo) {
ci.Chown = func(*User) (*User, error) {
- return &User{Uid: uid, Gid: gid}, nil
+ return &User{UID: uid, GID: gid}, nil
}
}
}
diff --git a/vendor/github.com/tonistiigi/fsutil/copy/copy_linux.go b/vendor/github.com/tonistiigi/fsutil/copy/copy_linux.go
index 268a9fc..4e6b93c 100644
--- a/vendor/github.com/tonistiigi/fsutil/copy/copy_linux.go
+++ b/vendor/github.com/tonistiigi/fsutil/copy/copy_linux.go
@@ -10,7 +10,7 @@
"golang.org/x/sys/unix"
)
-func getUidGid(fi os.FileInfo) (uid, gid int) {
+func getUIDGID(fi os.FileInfo) (uid, gid int) {
st := fi.Sys().(*syscall.Stat_t)
return int(st.Uid), int(st.Gid)
}
@@ -19,8 +19,8 @@
st := fi.Sys().(*syscall.Stat_t)
chown := c.chown
- uid, gid := getUidGid(fi)
- old := &User{Uid: uid, Gid: gid}
+ uid, gid := getUIDGID(fi)
+ old := &User{UID: uid, GID: gid}
if chown == nil {
chown = func(u *User) (*User, error) {
return u, nil
diff --git a/vendor/github.com/tonistiigi/fsutil/copy/copy_unix.go b/vendor/github.com/tonistiigi/fsutil/copy/copy_unix.go
index e80ee78..6debee2 100644
--- a/vendor/github.com/tonistiigi/fsutil/copy/copy_unix.go
+++ b/vendor/github.com/tonistiigi/fsutil/copy/copy_unix.go
@@ -10,7 +10,7 @@
"golang.org/x/sys/unix"
)
-func getUidGid(fi os.FileInfo) (uid, gid int) {
+func getUIDGID(fi os.FileInfo) (uid, gid int) {
st := fi.Sys().(*syscall.Stat_t)
return int(st.Uid), int(st.Gid)
}
@@ -18,8 +18,8 @@
func (c *copier) copyFileInfo(fi os.FileInfo, name string) error {
st := fi.Sys().(*syscall.Stat_t)
chown := c.chown
- uid, gid := getUidGid(fi)
- old := &User{Uid: uid, Gid: gid}
+ uid, gid := getUIDGID(fi)
+ old := &User{UID: uid, GID: gid}
if chown == nil {
chown = func(u *User) (*User, error) {
return u, nil
diff --git a/vendor/github.com/tonistiigi/fsutil/copy/mkdir.go b/vendor/github.com/tonistiigi/fsutil/copy/mkdir.go
index b5eeb90..9854754 100644
--- a/vendor/github.com/tonistiigi/fsutil/copy/mkdir.go
+++ b/vendor/github.com/tonistiigi/fsutil/copy/mkdir.go
@@ -17,7 +17,7 @@
return errors.WithStack(err)
}
if user != nil {
- if err := os.Lchown(p, user.Uid, user.Gid); err != nil {
+ if err := os.Lchown(p, user.UID, user.GID); err != nil {
return err
}
}
diff --git a/vendor/github.com/tonistiigi/fsutil/diff.go b/vendor/github.com/tonistiigi/fsutil/diff.go
index 1cbc32b..a7405dc 100644
--- a/vendor/github.com/tonistiigi/fsutil/diff.go
+++ b/vendor/github.com/tonistiigi/fsutil/diff.go
@@ -19,9 +19,9 @@
type ContentHasher func(*types.Stat) (hash.Hash, error)
-func GetWalkerFn(root string) walkerFn {
+func getWalkerFn(root string) walkerFn {
return func(ctx context.Context, pathC chan<- *currentPath) error {
- return Walk(ctx, root, nil, func(path string, f os.FileInfo, err error) error {
+ return errors.Wrap(Walk(ctx, root, nil, func(path string, f os.FileInfo, err error) error {
if err != nil {
return err
}
@@ -42,7 +42,7 @@
case pathC <- p:
return nil
}
- })
+ }), "failed to walk")
}
}
diff --git a/vendor/github.com/tonistiigi/fsutil/diff_containerd_linux.go b/vendor/github.com/tonistiigi/fsutil/diff_containerd_linux.go
deleted file mode 100644
index 4ac7ec5..0000000
--- a/vendor/github.com/tonistiigi/fsutil/diff_containerd_linux.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package fsutil
-
-import (
- "bytes"
- "syscall"
-
- "github.com/containerd/continuity/sysx"
- "github.com/pkg/errors"
-)
-
-// compareSysStat returns whether the stats are equivalent,
-// whether the files are considered the same file, and
-// an error
-func compareSysStat(s1, s2 interface{}) (bool, error) {
- ls1, ok := s1.(*syscall.Stat_t)
- if !ok {
- return false, nil
- }
- ls2, ok := s2.(*syscall.Stat_t)
- if !ok {
- return false, nil
- }
-
- return ls1.Mode == ls2.Mode && ls1.Uid == ls2.Uid && ls1.Gid == ls2.Gid && ls1.Rdev == ls2.Rdev, nil
-}
-
-func compareCapabilities(p1, p2 string) (bool, error) {
- c1, err := sysx.LGetxattr(p1, "security.capability")
- if err != nil && err != syscall.ENODATA {
- return false, errors.Wrapf(err, "failed to get xattr for %s", p1)
- }
- c2, err := sysx.LGetxattr(p2, "security.capability")
- if err != nil && err != syscall.ENODATA {
- return false, errors.Wrapf(err, "failed to get xattr for %s", p2)
- }
- return bytes.Equal(c1, c2), nil
-}
diff --git a/vendor/github.com/tonistiigi/fsutil/diskwriter.go b/vendor/github.com/tonistiigi/fsutil/diskwriter.go
index 70323c8..7864322 100644
--- a/vendor/github.com/tonistiigi/fsutil/diskwriter.go
+++ b/vendor/github.com/tonistiigi/fsutil/diskwriter.go
@@ -8,6 +8,7 @@
"path/filepath"
"strconv"
"sync"
+ "syscall"
"time"
"github.com/opencontainers/go-digest"
@@ -32,7 +33,6 @@
opt DiskWriterOpt
dest string
- wg sync.WaitGroup
ctx context.Context
cancel func()
eg *errgroup.Group
@@ -104,7 +104,7 @@
stat, ok := fi.Sys().(*types.Stat)
if !ok {
- return errors.Errorf("%s invalid change without stat information", p)
+ return errors.WithStack(&os.PathError{Path: p, Err: syscall.EBADMSG, Op: "change without stat info"})
}
statCopy := *stat
@@ -118,13 +118,13 @@
rename := true
oldFi, err := os.Lstat(destPath)
if err != nil {
- if os.IsNotExist(err) {
+ if errors.Is(err, os.ErrNotExist) {
if kind != ChangeKindAdd {
- return errors.Wrapf(err, "invalid addition: %s", destPath)
+ return errors.Wrap(err, "modify/rm")
}
rename = false
} else {
- return errors.Wrapf(err, "failed to stat %s", destPath)
+ return errors.WithStack(err)
}
}
@@ -285,7 +285,6 @@
type lazyFileWriter struct {
dest string
- ctx context.Context
f *os.File
fileMode *os.FileMode
}
diff --git a/vendor/github.com/tonistiigi/fsutil/diskwriter_unix.go b/vendor/github.com/tonistiigi/fsutil/diskwriter_unix.go
index ff0a22e..aa2d298 100644
--- a/vendor/github.com/tonistiigi/fsutil/diskwriter_unix.go
+++ b/vendor/github.com/tonistiigi/fsutil/diskwriter_unix.go
@@ -17,17 +17,17 @@
}
if err := os.Lchown(p, int(stat.Uid), int(stat.Gid)); err != nil {
- return errors.Wrapf(err, "failed to lchown %s", p)
+ return errors.WithStack(err)
}
if os.FileMode(stat.Mode)&os.ModeSymlink == 0 {
if err := os.Chmod(p, os.FileMode(stat.Mode)); err != nil {
- return errors.Wrapf(err, "failed to chown %s", p)
+ return errors.WithStack(err)
}
}
if err := chtimes(p, stat.ModTime); err != nil {
- return errors.Wrapf(err, "failed to chtimes %s", p)
+ return err
}
return nil
@@ -46,7 +46,7 @@
}
if err := syscall.Mknod(path, mode, int(mkdev(stat.Devmajor, stat.Devminor))); err != nil {
- return err
+ return errors.WithStack(err)
}
return nil
}
diff --git a/vendor/github.com/tonistiigi/fsutil/followlinks.go b/vendor/github.com/tonistiigi/fsutil/followlinks.go
index ed4af6e..a094241 100644
--- a/vendor/github.com/tonistiigi/fsutil/followlinks.go
+++ b/vendor/github.com/tonistiigi/fsutil/followlinks.go
@@ -77,10 +77,10 @@
if allowWildcard && containsWildcards(base) {
fis, err := ioutil.ReadDir(filepath.Dir(realPath))
if err != nil {
- if os.IsNotExist(err) {
+ if errors.Is(err, os.ErrNotExist) {
return nil, nil
}
- return nil, errors.Wrapf(err, "failed to read dir %s", filepath.Dir(realPath))
+ return nil, errors.Wrap(err, "readdir")
}
var out []string
for _, f := range fis {
@@ -97,17 +97,17 @@
fi, err := os.Lstat(realPath)
if err != nil {
- if os.IsNotExist(err) {
+ if errors.Is(err, os.ErrNotExist) {
return nil, nil
}
- return nil, errors.Wrapf(err, "failed to lstat %s", realPath)
+ return nil, errors.WithStack(err)
}
if fi.Mode()&os.ModeSymlink == 0 {
return nil, nil
}
link, err := os.Readlink(realPath)
if err != nil {
- return nil, errors.Wrapf(err, "failed to readlink %s", realPath)
+ return nil, errors.WithStack(err)
}
link = filepath.Clean(link)
if filepath.IsAbs(link) {
diff --git a/vendor/github.com/tonistiigi/fsutil/fs.go b/vendor/github.com/tonistiigi/fsutil/fs.go
index a9467e9..e26110b 100644
--- a/vendor/github.com/tonistiigi/fsutil/fs.go
+++ b/vendor/github.com/tonistiigi/fsutil/fs.go
@@ -9,6 +9,7 @@
"path/filepath"
"sort"
"strings"
+ "syscall"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil/types"
@@ -36,7 +37,8 @@
}
func (fs *fs) Open(p string) (io.ReadCloser, error) {
- return os.Open(filepath.Join(fs.root, p))
+ rc, err := os.Open(filepath.Join(fs.root, p))
+ return rc, errors.WithStack(err)
}
type Dir struct {
@@ -51,10 +53,10 @@
m := map[string]Dir{}
for _, d := range dirs {
if path.Base(d.Stat.Path) != d.Stat.Path {
- return nil, errors.Errorf("subdir %s must be single file", d.Stat.Path)
+ return nil, errors.WithStack(&os.PathError{Path: d.Stat.Path, Err: syscall.EISDIR, Op: "invalid path"})
}
if _, ok := m[d.Stat.Path]; ok {
- return nil, errors.Errorf("invalid path %s", d.Stat.Path)
+ return nil, errors.WithStack(&os.PathError{Path: d.Stat.Path, Err: syscall.EEXIST, Op: "duplicate path"})
}
m[d.Stat.Path] = d
}
@@ -70,7 +72,7 @@
for _, d := range fs.dirs {
fi := &StatInfo{Stat: &d.Stat}
if !fi.IsDir() {
- return errors.Errorf("fs subdir %s not mode directory", d.Stat.Path)
+ return errors.WithStack(&os.PathError{Path: d.Stat.Path, Err: syscall.ENOTDIR, Op: "walk subdir"})
}
if err := fn(d.Stat.Path, fi, nil); err != nil {
return err
@@ -78,7 +80,7 @@
if err := d.FS.Walk(ctx, func(p string, fi os.FileInfo, err error) error {
stat, ok := fi.Sys().(*types.Stat)
if !ok {
- return errors.Wrapf(err, "invalid fileinfo without stat info: %s", p)
+ return errors.WithStack(&os.PathError{Path: d.Stat.Path, Err: syscall.EBADMSG, Op: "fileinfo without stat info"})
}
stat.Path = path.Join(d.Stat.Path, stat.Path)
if stat.Linkname != "" {
@@ -105,7 +107,7 @@
}
d, ok := fs.m[parts[0]]
if !ok {
- return nil, os.ErrNotExist
+ return nil, errors.WithStack(&os.PathError{Path: parts[0], Err: syscall.ENOENT, Op: "open"})
}
return d.FS.Open(parts[1])
}
diff --git a/vendor/github.com/tonistiigi/fsutil/go.mod b/vendor/github.com/tonistiigi/fsutil/go.mod
index ed41f53..d95432c 100644
--- a/vendor/github.com/tonistiigi/fsutil/go.mod
+++ b/vendor/github.com/tonistiigi/fsutil/go.mod
@@ -5,14 +5,10 @@
require (
github.com/Microsoft/hcsshim v0.8.9 // indirect
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc
- github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/docker v0.0.0-20200511152416-a93e9eb0e95c
github.com/gogo/protobuf v1.3.1
- github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect
github.com/moby/sys/mount v0.1.0 // indirect
github.com/moby/sys/mountinfo v0.1.3 // indirect
- github.com/onsi/ginkgo v1.7.0 // indirect
- github.com/onsi/gomega v1.4.3 // indirect
github.com/opencontainers/go-digest v1.0.0-rc1
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v1.0.0-rc10 // indirect
@@ -20,6 +16,5 @@
github.com/stretchr/testify v1.5.1
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae
- gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
- gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
+ gotest.tools/v3 v3.0.2 // indirect
)
diff --git a/vendor/github.com/tonistiigi/fsutil/hardlinks.go b/vendor/github.com/tonistiigi/fsutil/hardlinks.go
index d977f0d..ef8bbfb 100644
--- a/vendor/github.com/tonistiigi/fsutil/hardlinks.go
+++ b/vendor/github.com/tonistiigi/fsutil/hardlinks.go
@@ -2,6 +2,7 @@
import (
"os"
+ "syscall"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil/types"
@@ -28,7 +29,7 @@
stat, ok := fi.Sys().(*types.Stat)
if !ok {
- return errors.Errorf("invalid change without stat info: %s", p)
+ return errors.WithStack(&os.PathError{Path: p, Err: syscall.EBADMSG, Op: "change without stat info"})
}
if fi.IsDir() || fi.Mode()&os.ModeSymlink != 0 {
diff --git a/vendor/github.com/tonistiigi/fsutil/receive.go b/vendor/github.com/tonistiigi/fsutil/receive.go
index 0210dcd..5c6a486 100644
--- a/vendor/github.com/tonistiigi/fsutil/receive.go
+++ b/vendor/github.com/tonistiigi/fsutil/receive.go
@@ -20,7 +20,7 @@
}
func Receive(ctx context.Context, conn Stream, dest string, opt ReceiveOpt) error {
- ctx, cancel := context.WithCancel(context.Background())
+ ctx, cancel := context.WithCancel(ctx)
defer cancel()
r := &receiver{
@@ -105,7 +105,6 @@
return ctx.Err()
}
}
- return nil
}
func (r *receiver) run(ctx context.Context) error {
@@ -131,7 +130,7 @@
}()
destWalker := emptyWalker
if !r.merge {
- destWalker = GetWalkerFn(r.dest)
+ destWalker = getWalkerFn(r.dest)
}
err := doubleWalkDiff(ctx, dw.HandleChange, destWalker, w.fill, r.filter)
if err != nil {
diff --git a/vendor/github.com/tonistiigi/fsutil/send.go b/vendor/github.com/tonistiigi/fsutil/send.go
index e7c5a37..2c1a380 100644
--- a/vendor/github.com/tonistiigi/fsutil/send.go
+++ b/vendor/github.com/tonistiigi/fsutil/send.go
@@ -5,6 +5,7 @@
"io"
"os"
"sync"
+ "syscall"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil/types"
@@ -13,7 +14,8 @@
var bufPool = sync.Pool{
New: func() interface{} {
- return make([]byte, 32*1<<10)
+ buf := make([]byte, 32*1<<10)
+ return &buf
},
}
@@ -131,9 +133,9 @@
f, err := s.fs.Open(h.path)
if err == nil {
defer f.Close()
- buf := bufPool.Get().([]byte)
+ buf := bufPool.Get().(*[]byte)
defer bufPool.Put(buf)
- if _, err := io.CopyBuffer(&fileSender{sender: s, id: h.id}, f, buf); err != nil {
+ if _, err := io.CopyBuffer(&fileSender{sender: s, id: h.id}, f, *buf); err != nil {
return err
}
}
@@ -148,7 +150,7 @@
}
stat, ok := fi.Sys().(*types.Stat)
if !ok {
- return errors.Wrapf(err, "invalid fileinfo without stat info: %s", path)
+ return errors.WithStack(&os.PathError{Path: path, Err: syscall.EBADMSG, Op: "fileinfo without stat info"})
}
p := &types.Packet{
diff --git a/vendor/github.com/tonistiigi/fsutil/stat.go b/vendor/github.com/tonistiigi/fsutil/stat.go
index 789dce3..2ab8da1 100644
--- a/vendor/github.com/tonistiigi/fsutil/stat.go
+++ b/vendor/github.com/tonistiigi/fsutil/stat.go
@@ -31,13 +31,13 @@
if fi.Mode()&os.ModeSymlink != 0 {
link, err := os.Readlink(path)
if err != nil {
- return nil, errors.Wrapf(err, "failed to readlink %s", path)
+ return nil, errors.WithStack(err)
}
stat.Linkname = link
}
}
if err := loadXattr(path, stat); err != nil {
- return nil, errors.Wrapf(err, "failed to xattr %s", relpath)
+ return nil, err
}
if runtime.GOOS == "windows" {
@@ -58,7 +58,7 @@
func Stat(path string) (*types.Stat, error) {
fi, err := os.Lstat(path)
if err != nil {
- return nil, errors.Wrap(err, "os stat")
+ return nil, errors.WithStack(err)
}
return mkstat(path, filepath.Base(path), fi, nil)
}
diff --git a/vendor/github.com/tonistiigi/fsutil/tarwriter.go b/vendor/github.com/tonistiigi/fsutil/tarwriter.go
index 06f28c5..bd46a22 100644
--- a/vendor/github.com/tonistiigi/fsutil/tarwriter.go
+++ b/vendor/github.com/tonistiigi/fsutil/tarwriter.go
@@ -7,6 +7,7 @@
"os"
"path/filepath"
"strings"
+ "syscall"
"github.com/pkg/errors"
"github.com/tonistiigi/fsutil/types"
@@ -15,9 +16,12 @@
func WriteTar(ctx context.Context, fs FS, w io.Writer) error {
tw := tar.NewWriter(w)
err := fs.Walk(ctx, func(path string, fi os.FileInfo, err error) error {
+ if err != nil && !errors.Is(err, os.ErrNotExist) {
+ return err
+ }
stat, ok := fi.Sys().(*types.Stat)
if !ok {
- return errors.Wrapf(err, "invalid fileinfo without stat info: %s", path)
+ return errors.WithStack(&os.PathError{Path: path, Err: syscall.EBADMSG, Op: "fileinfo without stat info"})
}
hdr, err := tar.FileInfoHeader(fi, stat.Linkname)
if err != nil {
@@ -37,7 +41,7 @@
hdr.Linkname = stat.Linkname
if hdr.Linkname != "" {
hdr.Size = 0
- if fi.Mode() & os.ModeSymlink != 0 {
+ if fi.Mode()&os.ModeSymlink != 0 {
hdr.Typeflag = tar.TypeSymlink
} else {
hdr.Typeflag = tar.TypeLink
@@ -52,7 +56,7 @@
}
if err := tw.WriteHeader(hdr); err != nil {
- return errors.Wrap(err, "failed to write file header")
+ return errors.Wrapf(err, "failed to write file header %s", name)
}
if hdr.Typeflag == tar.TypeReg && hdr.Size > 0 && hdr.Linkname == "" {
@@ -61,10 +65,10 @@
return err
}
if _, err := io.Copy(tw, rc); err != nil {
- return err
+ return errors.WithStack(err)
}
if err := rc.Close(); err != nil {
- return err
+ return errors.WithStack(err)
}
}
return nil
diff --git a/vendor/github.com/tonistiigi/fsutil/validator.go b/vendor/github.com/tonistiigi/fsutil/validator.go
index 2bd1287..9bd7d94 100644
--- a/vendor/github.com/tonistiigi/fsutil/validator.go
+++ b/vendor/github.com/tonistiigi/fsutil/validator.go
@@ -6,6 +6,7 @@
"runtime"
"sort"
"strings"
+ "syscall"
"github.com/pkg/errors"
)
@@ -31,10 +32,10 @@
p = strings.Replace(p, "\\", "", -1)
}
if p != path.Clean(p) {
- return errors.Errorf("invalid unclean path %s", p)
+ return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "unclean path"})
}
if path.IsAbs(p) {
- return errors.Errorf("abolute path %s not allowed", p)
+ return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "absolute path"})
}
dir := path.Dir(p)
base := path.Base(p)
@@ -42,7 +43,7 @@
dir = ""
}
if dir == ".." || strings.HasPrefix(p, "../") {
- return errors.Errorf("invalid path: %s", p)
+ return errors.WithStack(&os.PathError{Path: p, Err: syscall.EINVAL, Op: "escape check"})
}
// find a parent dir from saved records
diff --git a/vendor/github.com/tonistiigi/fsutil/walker.go b/vendor/github.com/tonistiigi/fsutil/walker.go
index 6004b88..b10383e 100644
--- a/vendor/github.com/tonistiigi/fsutil/walker.go
+++ b/vendor/github.com/tonistiigi/fsutil/walker.go
@@ -25,21 +25,21 @@
func Walk(ctx context.Context, p string, opt *WalkOpt, fn filepath.WalkFunc) error {
root, err := filepath.EvalSymlinks(p)
if err != nil {
- return errors.Wrapf(err, "failed to resolve %s", root)
+ return errors.WithStack(&os.PathError{Op: "resolve", Path: root, Err: err})
}
fi, err := os.Stat(root)
if err != nil {
- return errors.Wrapf(err, "failed to stat: %s", root)
+ return errors.WithStack(err)
}
if !fi.IsDir() {
- return errors.Errorf("%s is not a directory", root)
+ return errors.WithStack(&os.PathError{Op: "walk", Path: root, Err: syscall.ENOTDIR})
}
var pm *fileutils.PatternMatcher
if opt != nil && opt.ExcludePatterns != nil {
pm, err = fileutils.NewPatternMatcher(opt.ExcludePatterns)
if err != nil {
- return errors.Wrapf(err, "invalid excludepaths %s", opt.ExcludePatterns)
+ return errors.Wrapf(err, "invalid excludepatterns: %s", opt.ExcludePatterns)
}
}
@@ -65,17 +65,15 @@
seenFiles := make(map[uint64]string)
return filepath.Walk(root, func(path string, fi os.FileInfo, err error) (retErr error) {
- if err != nil {
- if os.IsNotExist(err) {
- return filepath.SkipDir
- }
- return err
- }
defer func() {
if retErr != nil && isNotExist(retErr) {
retErr = filepath.SkipDir
}
}()
+ if err != nil {
+ return err
+ }
+
origpath := path
path, err = filepath.Rel(root, path)
if err != nil {
diff --git a/vendor/github.com/tonistiigi/units/LICENSE b/vendor/github.com/tonistiigi/units/LICENSE
new file mode 100644
index 0000000..5c1095d
--- /dev/null
+++ b/vendor/github.com/tonistiigi/units/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 Tõnis Tiigi
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/vendor/github.com/tonistiigi/units/bytes.go b/vendor/github.com/tonistiigi/units/bytes.go
new file mode 100644
index 0000000..5a82fc1
--- /dev/null
+++ b/vendor/github.com/tonistiigi/units/bytes.go
@@ -0,0 +1,125 @@
+/*
+ Simple byte size formatting.
+
+ This package implements types that can be used in stdlib formatting functions
+ like `fmt.Printf` to control the output of the expected printed string.
+
+
+ Floating point flags %f and %g print the value in using the correct unit
+ suffix. Decimal units are default, # switches to binary units. If a value is
+ best represented as full bytes, integer bytes are printed instead.
+
+ Examples:
+ fmt.Printf("%.2f", 123 * B) => "123B"
+ fmt.Printf("%.2f", 1234 * B) => "1.23kB"
+ fmt.Printf("%g", 1200 * B) => "1.2kB"
+ fmt.Printf("%#g", 1024 * B) => "1KiB"
+
+
+ Integer flag %d always prints the value in bytes. # flag adds an unit prefix.
+
+ Examples:
+ fmt.Printf("%d", 1234 * B) => "1234"
+ fmt.Printf("%#d", 1234 * B) => "1234B"
+
+ %v is equal to %g
+
+*/
+package units
+
+import (
+ "fmt"
+ "io"
+ "math"
+ "math/big"
+)
+
+type Bytes int64
+
+const (
+ B Bytes = 1 << (10 * iota)
+ KiB
+ MiB
+ GiB
+ TiB
+ PiB
+ EiB
+
+ KB = 1e3 * B
+ MB = 1e3 * KB
+ GB = 1e3 * MB
+ TB = 1e3 * GB
+ PB = 1e3 * TB
+ EB = 1e3 * PB
+)
+
+var units = map[bool][]string{
+ false: []string{
+ "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB",
+ },
+ true: []string{
+ "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB",
+ },
+}
+
+func (b Bytes) Format(f fmt.State, c rune) {
+ switch c {
+ case 'f', 'g':
+ fv, unit, ok := b.floatValue(f.Flag('#'))
+ if !ok {
+ b.formatInt(&noPrecision{f}, 'd', true)
+ return
+ }
+ big.NewFloat(fv).Format(f, c)
+ io.WriteString(f, unit)
+ case 'd':
+ b.formatInt(f, c, f.Flag('#'))
+ default:
+ if f.Flag('#') {
+ fmt.Fprintf(f, "bytes(%d)", int64(b))
+ } else {
+ fmt.Fprintf(f, "%g", b)
+ }
+ }
+}
+
+func (b Bytes) formatInt(f fmt.State, c rune, withUnit bool) {
+ big.NewInt(int64(b)).Format(f, c)
+ if withUnit {
+ io.WriteString(f, "B")
+ }
+}
+
+func (b Bytes) floatValue(binary bool) (float64, string, bool) {
+ i := 0
+ var baseUnit Bytes = 1
+ if b < 0 {
+ baseUnit *= -1
+ }
+ for {
+ next := baseUnit
+ if binary {
+ next *= 1 << 10
+ } else {
+ next *= 1e3
+ }
+ if (baseUnit > 0 && b >= next) || (baseUnit < 0 && b <= next) {
+ i++
+ baseUnit = next
+ continue
+ }
+ if i == 0 {
+ return 0, "", false
+ }
+
+ return float64(b) / math.Abs(float64(baseUnit)), units[binary][i], true
+ }
+}
+
+type noPrecision struct {
+ fmt.State
+}
+
+func (*noPrecision) Precision() (prec int, ok bool) {
+ return 0, false
+}
diff --git a/vendor/github.com/tonistiigi/units/readme.md b/vendor/github.com/tonistiigi/units/readme.md
new file mode 100644
index 0000000..5c67d30
--- /dev/null
+++ b/vendor/github.com/tonistiigi/units/readme.md
@@ -0,0 +1,29 @@
+#### Simple byte size formatting.
+
+This package implements types that can be used in stdlib formatting functions
+like `fmt.Printf` to control the output of the expected printed string.
+
+Floating point flags `%f` and %g print the value in using the correct unit
+suffix. Decimal units are default, `#` switches to binary units. If a value is
+best represented as full bytes, integer bytes are printed instead.
+
+##### Examples:
+
+```
+fmt.Printf("%.2f", 123 * B) => "123B"
+fmt.Printf("%.2f", 1234 * B) => "1.23kB"
+fmt.Printf("%g", 1200 * B) => "1.2kB"
+fmt.Printf("%#g", 1024 * B) => "1KiB"
+```
+
+
+Integer flag `%d` always prints the value in bytes. `#` flag adds an unit prefix.
+
+##### Examples:
+
+```
+fmt.Printf("%d", 1234 * B) => "1234"
+fmt.Printf("%#d", 1234 * B) => "1234B"
+```
+
+`%v` is equal to `%g`
\ No newline at end of file
diff --git a/vendor/golang.org/x/crypto/nacl/sign/sign.go b/vendor/golang.org/x/crypto/nacl/sign/sign.go
new file mode 100644
index 0000000..d076270
--- /dev/null
+++ b/vendor/golang.org/x/crypto/nacl/sign/sign.go
@@ -0,0 +1,90 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Package sign signs small messages using public-key cryptography.
+//
+// Sign uses Ed25519 to sign messages. The length of messages is not hidden.
+// Messages should be small because:
+// 1. The whole message needs to be held in memory to be processed.
+// 2. Using large messages pressures implementations on small machines to process
+// plaintext without verifying the signature. This is very dangerous, and this API
+// discourages it, but a protocol that uses excessive message sizes might present
+// some implementations with no other choice.
+// 3. Performance may be improved by working with messages that fit into data caches.
+// Thus large amounts of data should be chunked so that each message is small.
+//
+// This package is not interoperable with the current release of NaCl
+// (https://nacl.cr.yp.to/sign.html), which does not support Ed25519 yet. However,
+// it is compatible with the NaCl fork libsodium (https://www.libsodium.org), as well
+// as TweetNaCl (https://tweetnacl.cr.yp.to/).
+package sign
+
+import (
+ "io"
+
+ "golang.org/x/crypto/ed25519"
+ "golang.org/x/crypto/internal/subtle"
+)
+
+// Overhead is the number of bytes of overhead when signing a message.
+const Overhead = 64
+
+// GenerateKey generates a new public/private key pair suitable for use with
+// Sign and Open.
+func GenerateKey(rand io.Reader) (publicKey *[32]byte, privateKey *[64]byte, err error) {
+ pub, priv, err := ed25519.GenerateKey(rand)
+ if err != nil {
+ return nil, nil, err
+ }
+ publicKey, privateKey = new([32]byte), new([64]byte)
+ copy((*publicKey)[:], pub)
+ copy((*privateKey)[:], priv)
+ return publicKey, privateKey, nil
+}
+
+// Sign appends a signed copy of message to out, which will be Overhead bytes
+// longer than the original and must not overlap it.
+func Sign(out, message []byte, privateKey *[64]byte) []byte {
+ sig := ed25519.Sign(ed25519.PrivateKey((*privateKey)[:]), message)
+ ret, out := sliceForAppend(out, Overhead+len(message))
+ if subtle.AnyOverlap(out, message) {
+ panic("nacl: invalid buffer overlap")
+ }
+ copy(out, sig)
+ copy(out[Overhead:], message)
+ return ret
+}
+
+// Open verifies a signed message produced by Sign and appends the message to
+// out, which must not overlap the signed message. The output will be Overhead
+// bytes smaller than the signed message.
+func Open(out, signedMessage []byte, publicKey *[32]byte) ([]byte, bool) {
+ if len(signedMessage) < Overhead {
+ return nil, false
+ }
+ if !ed25519.Verify(ed25519.PublicKey((*publicKey)[:]), signedMessage[Overhead:], signedMessage[:Overhead]) {
+ return nil, false
+ }
+ ret, out := sliceForAppend(out, len(signedMessage)-Overhead)
+ if subtle.AnyOverlap(out, signedMessage) {
+ panic("nacl: invalid buffer overlap")
+ }
+ copy(out, signedMessage[Overhead:])
+ return ret, true
+}
+
+// sliceForAppend takes a slice and a requested number of bytes. It returns a
+// slice with the contents of the given slice followed by that many bytes and a
+// second slice that aliases into it and contains only the extra bytes. If the
+// original slice has sufficient capacity then no allocation is performed.
+func sliceForAppend(in []byte, n int) (head, tail []byte) {
+ if total := len(in) + n; cap(in) >= total {
+ head = in[:total]
+ } else {
+ head = make([]byte, total)
+ copy(head, in)
+ }
+ tail = head[len(in):]
+ return
+}
diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go
index 5cce25e..f77701f 100644
--- a/vendor/golang.org/x/sys/cpu/cpu.go
+++ b/vendor/golang.org/x/sys/cpu/cpu.go
@@ -29,26 +29,46 @@
// and HasAVX2 are only set if the OS supports XMM and YMM
// registers in addition to the CPUID feature bit being set.
var X86 struct {
- _ CacheLinePad
- HasAES bool // AES hardware implementation (AES NI)
- HasADX bool // Multi-precision add-carry instruction extensions
- HasAVX bool // Advanced vector extension
- HasAVX2 bool // Advanced vector extension 2
- HasBMI1 bool // Bit manipulation instruction set 1
- HasBMI2 bool // Bit manipulation instruction set 2
- HasERMS bool // Enhanced REP for MOVSB and STOSB
- HasFMA bool // Fused-multiply-add instructions
- HasOSXSAVE bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers.
- HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM
- HasPOPCNT bool // Hamming weight instruction POPCNT.
- HasRDRAND bool // RDRAND instruction (on-chip random number generator)
- HasRDSEED bool // RDSEED instruction (on-chip random number generator)
- HasSSE2 bool // Streaming SIMD extension 2 (always available on amd64)
- HasSSE3 bool // Streaming SIMD extension 3
- HasSSSE3 bool // Supplemental streaming SIMD extension 3
- HasSSE41 bool // Streaming SIMD extension 4 and 4.1
- HasSSE42 bool // Streaming SIMD extension 4 and 4.2
- _ CacheLinePad
+ _ CacheLinePad
+ HasAES bool // AES hardware implementation (AES NI)
+ HasADX bool // Multi-precision add-carry instruction extensions
+ HasAVX bool // Advanced vector extension
+ HasAVX2 bool // Advanced vector extension 2
+ HasAVX512 bool // Advanced vector extension 512
+ HasAVX512F bool // Advanced vector extension 512 Foundation Instructions
+ HasAVX512CD bool // Advanced vector extension 512 Conflict Detection Instructions
+ HasAVX512ER bool // Advanced vector extension 512 Exponential and Reciprocal Instructions
+ HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions Instructions
+ HasAVX512VL bool // Advanced vector extension 512 Vector Length Extensions
+ HasAVX512BW bool // Advanced vector extension 512 Byte and Word Instructions
+ HasAVX512DQ bool // Advanced vector extension 512 Doubleword and Quadword Instructions
+ HasAVX512IFMA bool // Advanced vector extension 512 Integer Fused Multiply Add
+ HasAVX512VBMI bool // Advanced vector extension 512 Vector Byte Manipulation Instructions
+ HasAVX5124VNNIW bool // Advanced vector extension 512 Vector Neural Network Instructions Word variable precision
+ HasAVX5124FMAPS bool // Advanced vector extension 512 Fused Multiply Accumulation Packed Single precision
+ HasAVX512VPOPCNTDQ bool // Advanced vector extension 512 Double and quad word population count instructions
+ HasAVX512VPCLMULQDQ bool // Advanced vector extension 512 Vector carry-less multiply operations
+ HasAVX512VNNI bool // Advanced vector extension 512 Vector Neural Network Instructions
+ HasAVX512GFNI bool // Advanced vector extension 512 Galois field New Instructions
+ HasAVX512VAES bool // Advanced vector extension 512 Vector AES instructions
+ HasAVX512VBMI2 bool // Advanced vector extension 512 Vector Byte Manipulation Instructions 2
+ HasAVX512BITALG bool // Advanced vector extension 512 Bit Algorithms
+ HasAVX512BF16 bool // Advanced vector extension 512 BFloat16 Instructions
+ HasBMI1 bool // Bit manipulation instruction set 1
+ HasBMI2 bool // Bit manipulation instruction set 2
+ HasERMS bool // Enhanced REP for MOVSB and STOSB
+ HasFMA bool // Fused-multiply-add instructions
+ HasOSXSAVE bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers.
+ HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM
+ HasPOPCNT bool // Hamming weight instruction POPCNT.
+ HasRDRAND bool // RDRAND instruction (on-chip random number generator)
+ HasRDSEED bool // RDSEED instruction (on-chip random number generator)
+ HasSSE2 bool // Streaming SIMD extension 2 (always available on amd64)
+ HasSSE3 bool // Streaming SIMD extension 3
+ HasSSSE3 bool // Supplemental streaming SIMD extension 3
+ HasSSE41 bool // Streaming SIMD extension 4 and 4.1
+ HasSSE42 bool // Streaming SIMD extension 4 and 4.2
+ _ CacheLinePad
}
// ARM64 contains the supported CPU features of the
diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_arm64.go
index 2d90024..2f64d3b 100644
--- a/vendor/golang.org/x/sys/cpu/cpu_arm64.go
+++ b/vendor/golang.org/x/sys/cpu/cpu_arm64.go
@@ -39,7 +39,7 @@
func archInit() {
switch runtime.GOOS {
- case "android", "darwin", "netbsd":
+ case "android", "darwin", "ios", "netbsd", "openbsd":
// Android and iOS don't seem to allow reading these registers.
//
// NetBSD:
@@ -47,6 +47,9 @@
// It can be read via sysctl(3). Example for future implementers:
// https://nxr.netbsd.org/xref/src/usr.sbin/cpuctl/arch/aarch64.c
//
+ // OpenBSD:
+ // See https://golang.org/issue/31746
+ //
// Fake the minimal features expected by
// TestARM64minimalFeatures.
ARM64.HasASIMD = true
diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.go b/vendor/golang.org/x/sys/cpu/cpu_x86.go
index 2ad039d..48d4293 100644
--- a/vendor/golang.org/x/sys/cpu/cpu_x86.go
+++ b/vendor/golang.org/x/sys/cpu/cpu_x86.go
@@ -16,6 +16,26 @@
{Name: "aes", Feature: &X86.HasAES},
{Name: "avx", Feature: &X86.HasAVX},
{Name: "avx2", Feature: &X86.HasAVX2},
+ {Name: "avx512", Feature: &X86.HasAVX512},
+ {Name: "avx512f", Feature: &X86.HasAVX512F},
+ {Name: "avx512cd", Feature: &X86.HasAVX512CD},
+ {Name: "avx512er", Feature: &X86.HasAVX512ER},
+ {Name: "avx512pf", Feature: &X86.HasAVX512PF},
+ {Name: "avx512vl", Feature: &X86.HasAVX512VL},
+ {Name: "avx512bw", Feature: &X86.HasAVX512BW},
+ {Name: "avx512dq", Feature: &X86.HasAVX512DQ},
+ {Name: "avx512ifma", Feature: &X86.HasAVX512IFMA},
+ {Name: "avx512vbmi", Feature: &X86.HasAVX512VBMI},
+ {Name: "avx512vnniw", Feature: &X86.HasAVX5124VNNIW},
+ {Name: "avx5124fmaps", Feature: &X86.HasAVX5124FMAPS},
+ {Name: "avx512vpopcntdq", Feature: &X86.HasAVX512VPOPCNTDQ},
+ {Name: "avx512vpclmulqdq", Feature: &X86.HasAVX512VPCLMULQDQ},
+ {Name: "avx512vnni", Feature: &X86.HasAVX512VNNI},
+ {Name: "avx512gfni", Feature: &X86.HasAVX512GFNI},
+ {Name: "avx512vaes", Feature: &X86.HasAVX512VAES},
+ {Name: "avx512vbmi2", Feature: &X86.HasAVX512VBMI2},
+ {Name: "avx512bitalg", Feature: &X86.HasAVX512BITALG},
+ {Name: "avx512bf16", Feature: &X86.HasAVX512BF16},
{Name: "bmi1", Feature: &X86.HasBMI1},
{Name: "bmi2", Feature: &X86.HasBMI2},
{Name: "erms", Feature: &X86.HasERMS},
@@ -59,12 +79,15 @@
X86.HasOSXSAVE = isSet(27, ecx1)
X86.HasRDRAND = isSet(30, ecx1)
- osSupportsAVX := false
+ var osSupportsAVX, osSupportsAVX512 bool
// For XGETBV, OSXSAVE bit is required and sufficient.
if X86.HasOSXSAVE {
eax, _ := xgetbv()
// Check if XMM and YMM registers have OS support.
osSupportsAVX = isSet(1, eax) && isSet(2, eax)
+
+ // Check if OPMASK and ZMM registers have OS support.
+ osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax)
}
X86.HasAVX = isSet(28, ecx1) && osSupportsAVX
@@ -73,7 +96,7 @@
return
}
- _, ebx7, _, _ := cpuid(7, 0)
+ _, ebx7, ecx7, edx7 := cpuid(7, 0)
X86.HasBMI1 = isSet(3, ebx7)
X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX
X86.HasBMI2 = isSet(8, ebx7)
@@ -81,6 +104,30 @@
X86.HasRDSEED = isSet(18, ebx7)
X86.HasADX = isSet(19, ebx7)
+ X86.HasAVX512 = isSet(16, ebx7) && osSupportsAVX512 // Because avx-512 foundation is the core required extension
+ if X86.HasAVX512 {
+ X86.HasAVX512F = true
+ X86.HasAVX512CD = isSet(28, ebx7)
+ X86.HasAVX512ER = isSet(27, ebx7)
+ X86.HasAVX512PF = isSet(26, ebx7)
+ X86.HasAVX512VL = isSet(31, ebx7)
+ X86.HasAVX512BW = isSet(30, ebx7)
+ X86.HasAVX512DQ = isSet(17, ebx7)
+ X86.HasAVX512IFMA = isSet(21, ebx7)
+ X86.HasAVX512VBMI = isSet(1, ecx7)
+ X86.HasAVX5124VNNIW = isSet(2, edx7)
+ X86.HasAVX5124FMAPS = isSet(3, edx7)
+ X86.HasAVX512VPOPCNTDQ = isSet(14, ecx7)
+ X86.HasAVX512VPCLMULQDQ = isSet(10, ecx7)
+ X86.HasAVX512VNNI = isSet(11, ecx7)
+ X86.HasAVX512GFNI = isSet(8, ecx7)
+ X86.HasAVX512VAES = isSet(9, ecx7)
+ X86.HasAVX512VBMI2 = isSet(6, ecx7)
+ X86.HasAVX512BITALG = isSet(12, ecx7)
+
+ eax71, _, _, _ := cpuid(7, 1)
+ X86.HasAVX512BF16 = isSet(5, eax71)
+ }
}
func isSet(bitpos uint, value uint32) bool {
diff --git a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
index fc0e50e..8db48e5 100644
--- a/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
+++ b/vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
@@ -1,9 +1,9 @@
-// +build linux,386 linux,arm linux,mips linux,mipsle
-
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+// +build linux,386 linux,arm linux,mips linux,mipsle
+
package unix
func init() {
diff --git a/vendor/golang.org/x/sys/unix/gccgo.go b/vendor/golang.org/x/sys/unix/gccgo.go
index cd6f5a6..86032c1 100644
--- a/vendor/golang.org/x/sys/unix/gccgo.go
+++ b/vendor/golang.org/x/sys/unix/gccgo.go
@@ -12,10 +12,8 @@
// We can't use the gc-syntax .s files for gccgo. On the plus side
// much of the functionality can be written directly in Go.
-//extern gccgoRealSyscallNoError
func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
-//extern gccgoRealSyscall
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
diff --git a/vendor/golang.org/x/sys/unix/gccgo_c.c b/vendor/golang.org/x/sys/unix/gccgo_c.c
index c44730c..2cb1fef 100644
--- a/vendor/golang.org/x/sys/unix/gccgo_c.c
+++ b/vendor/golang.org/x/sys/unix/gccgo_c.c
@@ -21,6 +21,9 @@
uintptr_t err;
};
+struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
+ __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall");
+
struct ret
gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
{
@@ -32,6 +35,9 @@
return r;
}
+uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
+ __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError");
+
uintptr_t
gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
{
diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go
index 7d08dae..57a0021 100644
--- a/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go
+++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go
@@ -20,7 +20,7 @@
case "aix":
// There is no alignment on AIX.
salign = 1
- case "darwin", "illumos", "solaris":
+ case "darwin", "ios", "illumos", "solaris":
// NOTE: It seems like 64-bit Darwin, Illumos and Solaris
// kernels still require 32-bit aligned access to network
// subsystem.
@@ -32,6 +32,10 @@
if runtime.GOARCH == "arm" {
salign = 8
}
+ // NetBSD aarch64 requires 128-bit alignment.
+ if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" {
+ salign = 16
+ }
}
return (salen + salign - 1) & ^(salign - 1)
diff --git a/vendor/golang.org/x/sys/unix/syscall_aix.go b/vendor/golang.org/x/sys/unix/syscall_aix.go
index 9ad8a0d..4408153 100644
--- a/vendor/golang.org/x/sys/unix/syscall_aix.go
+++ b/vendor/golang.org/x/sys/unix/syscall_aix.go
@@ -19,6 +19,22 @@
* Wrapped
*/
+func Access(path string, mode uint32) (err error) {
+ return Faccessat(AT_FDCWD, path, mode, 0)
+}
+
+func Chmod(path string, mode uint32) (err error) {
+ return Fchmodat(AT_FDCWD, path, mode, 0)
+}
+
+func Chown(path string, uid int, gid int) (err error) {
+ return Fchownat(AT_FDCWD, path, uid, gid, 0)
+}
+
+func Creat(path string, mode uint32) (fd int, err error) {
+ return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode)
+}
+
//sys utimes(path string, times *[2]Timeval) (err error)
func Utimes(path string, tv []Timeval) error {
if len(tv) != 2 {
diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go
index 60bbe10..123536a 100644
--- a/vendor/golang.org/x/sys/unix/syscall_bsd.go
+++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go
@@ -18,6 +18,21 @@
"unsafe"
)
+const ImplementsGetwd = true
+
+func Getwd() (string, error) {
+ var buf [PathMax]byte
+ _, err := Getcwd(buf[0:])
+ if err != nil {
+ return "", err
+ }
+ n := clen(buf[:])
+ if n < 1 {
+ return "", EINVAL
+ }
+ return string(buf[:n]), nil
+}
+
/*
* Wrapped
*/
@@ -272,7 +287,7 @@
if err != nil {
return
}
- if runtime.GOOS == "darwin" && len == 0 {
+ if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && len == 0 {
// Accepted socket has no address.
// This is likely due to a bug in xnu kernels,
// where instead of ECONNABORTED error socket
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go
index eddcf3a..5b0e831 100644
--- a/vendor/golang.org/x/sys/unix/syscall_darwin.go
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go
@@ -13,29 +13,11 @@
package unix
import (
- "errors"
+ "runtime"
"syscall"
"unsafe"
)
-const ImplementsGetwd = true
-
-func Getwd() (string, error) {
- buf := make([]byte, 2048)
- attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
- if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
- wd := string(attrs[0])
- // Sanity check that it's an absolute path and ends
- // in a null byte, which we then strip.
- if wd[0] == '/' && wd[len(wd)-1] == 0 {
- return wd[:len(wd)-1], nil
- }
- }
- // If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
- // slow algorithm.
- return "", ENOTSUP
-}
-
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
type SockaddrDatalink struct {
Len uint8
@@ -97,11 +79,6 @@
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
-const (
- attrBitMapCount = 5
- attrCmnFullpath = 0x08000000
-)
-
type attrList struct {
bitmapCount uint16
_ uint16
@@ -112,54 +89,6 @@
Forkattr uint32
}
-func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
- if len(attrBuf) < 4 {
- return nil, errors.New("attrBuf too small")
- }
- attrList.bitmapCount = attrBitMapCount
-
- var _p0 *byte
- _p0, err = BytePtrFromString(path)
- if err != nil {
- return nil, err
- }
-
- if err := getattrlist(_p0, unsafe.Pointer(&attrList), unsafe.Pointer(&attrBuf[0]), uintptr(len(attrBuf)), int(options)); err != nil {
- return nil, err
- }
- size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
-
- // dat is the section of attrBuf that contains valid data,
- // without the 4 byte length header. All attribute offsets
- // are relative to dat.
- dat := attrBuf
- if int(size) < len(attrBuf) {
- dat = dat[:size]
- }
- dat = dat[4:] // remove length prefix
-
- for i := uint32(0); int(i) < len(dat); {
- header := dat[i:]
- if len(header) < 8 {
- return attrs, errors.New("truncated attribute header")
- }
- datOff := *(*int32)(unsafe.Pointer(&header[0]))
- attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
- if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
- return attrs, errors.New("truncated results; attrBuf too small")
- }
- end := uint32(datOff) + attrLen
- attrs = append(attrs, dat[datOff:end])
- i = end
- if r := i % 4; r != 0 {
- i += (4 - r)
- }
- }
- return
-}
-
-//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
-
//sysnb pipe() (r int, w int, err error)
func Pipe(p []int) (err error) {
@@ -329,6 +258,12 @@
//sys ioctl(fd int, req uint, arg uintptr) (err error)
+func IoctlCtlInfo(fd int, ctlInfo *CtlInfo) error {
+ err := ioctl(fd, CTLIOCGINFO, uintptr(unsafe.Pointer(ctlInfo)))
+ runtime.KeepAlive(ctlInfo)
+ return err
+}
+
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
func Uname(uname *Utsname) error {
@@ -419,6 +354,7 @@
//sys Fpathconf(fd int, name int) (val int, err error)
//sys Fsync(fd int) (err error)
//sys Ftruncate(fd int, length int64) (err error)
+//sys Getcwd(buf []byte) (n int, err error)
//sys Getdtablesize() (size int)
//sysnb Getegid() (egid int)
//sysnb Geteuid() (uid int)
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_386.go b/vendor/golang.org/x/sys/unix/syscall_darwin_386.go
index ea0be1e..6c1f4ab 100644
--- a/vendor/golang.org/x/sys/unix/syscall_darwin_386.go
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin_386.go
@@ -6,11 +6,7 @@
package unix
-import (
- "syscall"
-)
-
-//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
+import "syscall"
func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
@@ -49,5 +45,6 @@
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
+//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
index 5862404..0582ae2 100644
--- a/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
@@ -6,11 +6,7 @@
package unix
-import (
- "syscall"
-)
-
-//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
+import "syscall"
func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
@@ -49,5 +45,6 @@
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
+//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
index b8b3141..c6a9733 100644
--- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
@@ -4,9 +4,7 @@
package unix
-import (
- "syscall"
-)
+import "syscall"
func ptrace(request int, pid int, addr uintptr, data uintptr) error {
return ENOTSUP
diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
index 6741398..253afa4 100644
--- a/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
+++ b/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
@@ -6,13 +6,7 @@
package unix
-import (
- "syscall"
-)
-
-func ptrace(request int, pid int, addr uintptr, data uintptr) error {
- return ENOTSUP
-}
+import "syscall"
func setTimespec(sec, nsec int64) Timespec {
return Timespec{Sec: sec, Nsec: nsec}
@@ -51,5 +45,6 @@
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
//sys Lstat(path string, stat *Stat_t) (err error)
+//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
//sys Stat(path string, stat *Stat_t) (err error)
//sys Statfs(path string, stat *Statfs_t) (err error)
diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
index 8a195ae..bed7dcf 100644
--- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
+++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go
@@ -129,23 +129,8 @@
return
}
-const ImplementsGetwd = true
-
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
-func Getwd() (string, error) {
- var buf [PathMax]byte
- _, err := Getcwd(buf[0:])
- if err != nil {
- return "", err
- }
- n := clen(buf[:])
- if n < 1 {
- return "", EINVAL
- }
- return string(buf[:n]), nil
-}
-
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
var _p0 unsafe.Pointer
var bufsize uintptr
diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go
index 6932e7c..f6db02a 100644
--- a/vendor/golang.org/x/sys/unix/syscall_freebsd.go
+++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go
@@ -140,23 +140,8 @@
return
}
-const ImplementsGetwd = true
-
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
-func Getwd() (string, error) {
- var buf [PathMax]byte
- _, err := Getcwd(buf[0:])
- if err != nil {
- return "", err
- }
- n := clen(buf[:])
- if n < 1 {
- return "", EINVAL
- }
- return string(buf[:n]), nil
-}
-
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
var (
_p0 unsafe.Pointer
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go
index 94dafa4..84a9e52 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux.go
@@ -106,15 +106,24 @@
return &value, err
}
+// IoctlGetWatchdogInfo fetches information about a watchdog device from the
+// Linux watchdog API. For more information, see:
+// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
+func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) {
+ var value WatchdogInfo
+ err := ioctl(fd, WDIOC_GETSUPPORT, uintptr(unsafe.Pointer(&value)))
+ return &value, err
+}
+
func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
var value RTCWkAlrm
err := ioctl(fd, RTC_WKALM_RD, uintptr(unsafe.Pointer(&value)))
return &value, err
}
-// IoctlFileClone performs an FICLONERANGE ioctl operation to clone the range of
-// data conveyed in value to the file associated with the file descriptor
-// destFd. See the ioctl_ficlonerange(2) man page for details.
+// IoctlFileCloneRange performs an FICLONERANGE ioctl operation to clone the
+// range of data conveyed in value to the file associated with the file
+// descriptor destFd. See the ioctl_ficlonerange(2) man page for details.
func IoctlFileCloneRange(destFd int, value *FileCloneRange) error {
err := ioctl(destFd, FICLONERANGE, uintptr(unsafe.Pointer(value)))
runtime.KeepAlive(value)
@@ -128,15 +137,22 @@
return ioctl(destFd, FICLONE, uintptr(srcFd))
}
-// IoctlFileClone performs an FIDEDUPERANGE ioctl operation to share the range of
-// data conveyed in value with the file associated with the file descriptor
-// destFd. See the ioctl_fideduperange(2) man page for details.
+// IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the
+// range of data conveyed in value with the file associated with the file
+// descriptor destFd. See the ioctl_fideduperange(2) man page for details.
func IoctlFileDedupeRange(destFd int, value *FileDedupeRange) error {
err := ioctl(destFd, FIDEDUPERANGE, uintptr(unsafe.Pointer(value)))
runtime.KeepAlive(value)
return err
}
+// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
+// more information, see:
+// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
+func IoctlWatchdogKeepalive(fd int) error {
+ return ioctl(fd, WDIOC_KEEPALIVE, 0)
+}
+
//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
func Link(oldpath string, newpath string) (err error) {
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux_386.go b/vendor/golang.org/x/sys/unix/syscall_linux_386.go
index 048d18e..c97c2ee 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux_386.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux_386.go
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
-// so that go vet can check that they are correct.
-
// +build 386,linux
package unix
diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go
index 45b50a6..dbd5e03 100644
--- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go
+++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go
@@ -141,23 +141,8 @@
return
}
-const ImplementsGetwd = true
-
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
-func Getwd() (string, error) {
- var buf [PathMax]byte
- _, err := Getcwd(buf[0:])
- if err != nil {
- return "", err
- }
- n := clen(buf[:])
- if n < 1 {
- return "", EINVAL
- }
- return string(buf[:n]), nil
-}
-
// TODO
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
return -1, ENOSYS
diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go
index a266e92..2c1f46e 100644
--- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go
+++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go
@@ -114,23 +114,8 @@
return
}
-const ImplementsGetwd = true
-
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
-func Getwd() (string, error) {
- var buf [PathMax]byte
- _, err := Getcwd(buf[0:])
- if err != nil {
- return "", err
- }
- n := clen(buf[:])
- if n < 1 {
- return "", EINVAL
- }
- return string(buf[:n]), nil
-}
-
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
if raceenabled {
raceReleaseMerge(unsafe.Pointer(&ioSync))
diff --git a/vendor/golang.org/x/sys/unix/syscall_solaris.go b/vendor/golang.org/x/sys/unix/syscall_solaris.go
index 0e2a696..fee6e99 100644
--- a/vendor/golang.org/x/sys/unix/syscall_solaris.go
+++ b/vendor/golang.org/x/sys/unix/syscall_solaris.go
@@ -13,6 +13,7 @@
package unix
import (
+ "runtime"
"syscall"
"unsafe"
)
@@ -553,8 +554,10 @@
//sys ioctl(fd int, req uint, arg uintptr) (err error)
-func IoctlSetTermio(fd int, req uint, value *Termio) (err error) {
- return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
+func IoctlSetTermio(fd int, req uint, value *Termio) error {
+ err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
+ runtime.KeepAlive(value)
+ return err
}
func IoctlGetTermio(fd int, req uint) (*Termio, error) {
diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go
index 6f33359..c8f9f7a 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_386.go
@@ -251,6 +251,7 @@
CSTOP = 0x13
CSTOPB = 0x400
CSUSP = 0x1a
+ CTLIOCGINFO = 0xc0644e03
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc
diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go
index db767eb..7180064 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go
@@ -251,6 +251,7 @@
CSTOP = 0x13
CSTOPB = 0x400
CSUSP = 0x1a
+ CTLIOCGINFO = 0xc0644e03
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc
diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go
index ddc5d00..3b9ca75 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm.go
@@ -251,6 +251,7 @@
CSTOP = 0x13
CSTOPB = 0x400
CSUSP = 0x1a
+ CTLIOCGINFO = 0xc0644e03
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc
diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go
index 0614d26..4687c73 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go
@@ -251,6 +251,7 @@
CSTOP = 0x13
CSTOPB = 0x400
CSUSP = 0x1a
+ CTLIOCGINFO = 0xc0644e03
CTL_HW = 0x6
CTL_KERN = 0x1
CTL_MAXNAME = 0xc
diff --git a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go
index 6130471..f5e91b7 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_dragonfly_amd64.go
@@ -62,6 +62,7 @@
B28800 = 0x7080
B300 = 0x12c
B38400 = 0x9600
+ B460800 = 0x70800
B4800 = 0x12c0
B50 = 0x32
B57600 = 0xe100
@@ -69,12 +70,15 @@
B7200 = 0x1c20
B75 = 0x4b
B76800 = 0x12c00
+ B921600 = 0xe1000
B9600 = 0x2580
+ BIOCFEEDBACK = 0x8004427d
BIOCFLUSH = 0x20004268
BIOCGBLEN = 0x40044266
BIOCGDLT = 0x4004426a
BIOCGDLTLIST = 0xc0104279
BIOCGETIF = 0x4020426b
+ BIOCGFEEDBACK = 0x4004427c
BIOCGHDRCMPLT = 0x40044274
BIOCGRSIG = 0x40044272
BIOCGRTIMEOUT = 0x4010426e
@@ -88,6 +92,7 @@
BIOCSETF = 0x80104267
BIOCSETIF = 0x8020426c
BIOCSETWF = 0x8010427b
+ BIOCSFEEDBACK = 0x8004427d
BIOCSHDRCMPLT = 0x80044275
BIOCSRSIG = 0x80044273
BIOCSRTIMEOUT = 0x8010426d
@@ -125,6 +130,7 @@
BPF_MINBUFSIZE = 0x20
BPF_MINOR_VERSION = 0x1
BPF_MISC = 0x7
+ BPF_MOD = 0x90
BPF_MSH = 0xa0
BPF_MUL = 0x20
BPF_NEG = 0x80
@@ -139,6 +145,7 @@
BPF_TXA = 0x80
BPF_W = 0x0
BPF_X = 0x8
+ BPF_XOR = 0xa0
BRKINT = 0x2
CFLUSH = 0xf
CLOCAL = 0x8000
@@ -156,6 +163,12 @@
CLOCK_UPTIME_FAST = 0x8
CLOCK_UPTIME_PRECISE = 0x7
CLOCK_VIRTUAL = 0x1
+ CPUSTATES = 0x5
+ CP_IDLE = 0x4
+ CP_INTR = 0x3
+ CP_NICE = 0x1
+ CP_SYS = 0x2
+ CP_USER = 0x0
CREAD = 0x800
CRTSCTS = 0x30000
CS5 = 0x0
@@ -175,6 +188,7 @@
DLT_A429 = 0xb8
DLT_A653_ICM = 0xb9
DLT_AIRONET_HEADER = 0x78
+ DLT_AOS = 0xde
DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
DLT_ARCNET = 0x7
DLT_ARCNET_LINUX = 0x81
@@ -184,22 +198,33 @@
DLT_AX25 = 0x3
DLT_AX25_KISS = 0xca
DLT_BACNET_MS_TP = 0xa5
+ DLT_BLUETOOTH_BREDR_BB = 0xff
DLT_BLUETOOTH_HCI_H4 = 0xbb
DLT_BLUETOOTH_HCI_H4_WITH_PHDR = 0xc9
+ DLT_BLUETOOTH_LE_LL = 0xfb
+ DLT_BLUETOOTH_LE_LL_WITH_PHDR = 0x100
+ DLT_BLUETOOTH_LINUX_MONITOR = 0xfe
DLT_CAN20B = 0xbe
+ DLT_CAN_SOCKETCAN = 0xe3
DLT_CHAOS = 0x5
DLT_CHDLC = 0x68
DLT_CISCO_IOS = 0x76
DLT_C_HDLC = 0x68
DLT_C_HDLC_WITH_DIR = 0xcd
+ DLT_DBUS = 0xe7
+ DLT_DECT = 0xdd
DLT_DOCSIS = 0x8f
+ DLT_DVB_CI = 0xeb
DLT_ECONET = 0x73
DLT_EN10MB = 0x1
DLT_EN3MB = 0x2
DLT_ENC = 0x6d
+ DLT_EPON = 0x103
DLT_ERF = 0xc5
DLT_ERF_ETH = 0xaf
DLT_ERF_POS = 0xb0
+ DLT_FC_2 = 0xe0
+ DLT_FC_2_WITH_FRAME_DELIMS = 0xe1
DLT_FDDI = 0xa
DLT_FLEXRAY = 0xd2
DLT_FRELAY = 0x6b
@@ -209,6 +234,8 @@
DLT_GPF_F = 0xab
DLT_GPF_T = 0xaa
DLT_GPRS_LLC = 0xa9
+ DLT_GSMTAP_ABIS = 0xda
+ DLT_GSMTAP_UM = 0xd9
DLT_HHDLC = 0x79
DLT_IBM_SN = 0x92
DLT_IBM_SP = 0x91
@@ -218,18 +245,28 @@
DLT_IEEE802_11_RADIO_AVS = 0xa3
DLT_IEEE802_15_4 = 0xc3
DLT_IEEE802_15_4_LINUX = 0xbf
+ DLT_IEEE802_15_4_NOFCS = 0xe6
DLT_IEEE802_15_4_NONASK_PHY = 0xd7
DLT_IEEE802_16_MAC_CPS = 0xbc
DLT_IEEE802_16_MAC_CPS_RADIO = 0xc1
+ DLT_INFINIBAND = 0xf7
DLT_IPFILTER = 0x74
DLT_IPMB = 0xc7
DLT_IPMB_LINUX = 0xd1
+ DLT_IPMI_HPM_2 = 0x104
+ DLT_IPNET = 0xe2
+ DLT_IPOIB = 0xf2
+ DLT_IPV4 = 0xe4
+ DLT_IPV6 = 0xe5
DLT_IP_OVER_FC = 0x7a
+ DLT_ISO_14443 = 0x108
DLT_JUNIPER_ATM1 = 0x89
DLT_JUNIPER_ATM2 = 0x87
+ DLT_JUNIPER_ATM_CEMIC = 0xee
DLT_JUNIPER_CHDLC = 0xb5
DLT_JUNIPER_ES = 0x84
DLT_JUNIPER_ETHER = 0xb2
+ DLT_JUNIPER_FIBRECHANNEL = 0xea
DLT_JUNIPER_FRELAY = 0xb4
DLT_JUNIPER_GGSN = 0x85
DLT_JUNIPER_ISM = 0xc2
@@ -242,25 +279,40 @@
DLT_JUNIPER_PPPOE = 0xa7
DLT_JUNIPER_PPPOE_ATM = 0xa8
DLT_JUNIPER_SERVICES = 0x88
+ DLT_JUNIPER_SRX_E2E = 0xe9
DLT_JUNIPER_ST = 0xc8
DLT_JUNIPER_VP = 0xb7
+ DLT_JUNIPER_VS = 0xe8
DLT_LAPB_WITH_DIR = 0xcf
DLT_LAPD = 0xcb
DLT_LIN = 0xd4
+ DLT_LINUX_EVDEV = 0xd8
DLT_LINUX_IRDA = 0x90
DLT_LINUX_LAPD = 0xb1
DLT_LINUX_SLL = 0x71
DLT_LOOP = 0x6c
DLT_LTALK = 0x72
+ DLT_MATCHING_MAX = 0x109
+ DLT_MATCHING_MIN = 0x68
DLT_MFR = 0xb6
DLT_MOST = 0xd3
+ DLT_MPEG_2_TS = 0xf3
+ DLT_MPLS = 0xdb
DLT_MTP2 = 0x8c
DLT_MTP2_WITH_PHDR = 0x8b
DLT_MTP3 = 0x8d
+ DLT_MUX27010 = 0xec
+ DLT_NETANALYZER = 0xf0
+ DLT_NETANALYZER_TRANSPARENT = 0xf1
+ DLT_NETLINK = 0xfd
+ DLT_NFC_LLCP = 0xf5
+ DLT_NFLOG = 0xef
+ DLT_NG40 = 0xf4
DLT_NULL = 0x0
DLT_PCI_EXP = 0x7d
DLT_PFLOG = 0x75
DLT_PFSYNC = 0x12
+ DLT_PKTAP = 0x102
DLT_PPI = 0xc0
DLT_PPP = 0x9
DLT_PPP_BSDOS = 0x10
@@ -269,22 +321,51 @@
DLT_PPP_SERIAL = 0x32
DLT_PPP_WITH_DIR = 0xcc
DLT_PRISM_HEADER = 0x77
+ DLT_PROFIBUS_DL = 0x101
DLT_PRONET = 0x4
DLT_RAIF1 = 0xc6
DLT_RAW = 0xc
+ DLT_RDS = 0x109
DLT_REDBACK_SMARTEDGE = 0x20
DLT_RIO = 0x7c
+ DLT_RTAC_SERIAL = 0xfa
DLT_SCCP = 0x8e
+ DLT_SCTP = 0xf8
DLT_SITA = 0xc4
DLT_SLIP = 0x8
DLT_SLIP_BSDOS = 0xf
+ DLT_STANAG_5066_D_PDU = 0xed
DLT_SUNATM = 0x7b
DLT_SYMANTEC_FIREWALL = 0x63
DLT_TZSP = 0x80
DLT_USB = 0xba
+ DLT_USBPCAP = 0xf9
+ DLT_USB_FREEBSD = 0xba
DLT_USB_LINUX = 0xbd
+ DLT_USB_LINUX_MMAPPED = 0xdc
+ DLT_USER0 = 0x93
+ DLT_USER1 = 0x94
+ DLT_USER10 = 0x9d
+ DLT_USER11 = 0x9e
+ DLT_USER12 = 0x9f
+ DLT_USER13 = 0xa0
+ DLT_USER14 = 0xa1
+ DLT_USER15 = 0xa2
+ DLT_USER2 = 0x95
+ DLT_USER3 = 0x96
+ DLT_USER4 = 0x97
+ DLT_USER5 = 0x98
+ DLT_USER6 = 0x99
+ DLT_USER7 = 0x9a
+ DLT_USER8 = 0x9b
+ DLT_USER9 = 0x9c
+ DLT_WATTSTOPPER_DLM = 0x107
+ DLT_WIHART = 0xdf
+ DLT_WIRESHARK_UPPER_PDU = 0xfc
DLT_X2E_SERIAL = 0xd5
DLT_X2E_XORAYA = 0xd6
+ DLT_ZWAVE_R1_R2 = 0x105
+ DLT_ZWAVE_R3 = 0x106
DT_BLK = 0x6
DT_CHR = 0x2
DT_DBF = 0xf
@@ -323,10 +404,11 @@
EV_EOF = 0x8000
EV_ERROR = 0x4000
EV_FLAG1 = 0x2000
+ EV_HUP = 0x800
EV_NODATA = 0x1000
EV_ONESHOT = 0x10
EV_RECEIPT = 0x40
- EV_SYSFLAGS = 0xf000
+ EV_SYSFLAGS = 0xf800
EXTA = 0x4b00
EXTB = 0x9600
EXTEXIT_LWP = 0x10000
@@ -365,8 +447,9 @@
IFF_ALLMULTI = 0x200
IFF_ALTPHYS = 0x4000
IFF_BROADCAST = 0x2
- IFF_CANTCHANGE = 0x118e72
+ IFF_CANTCHANGE = 0x318e72
IFF_DEBUG = 0x4
+ IFF_IDIRECT = 0x200000
IFF_LINK0 = 0x1000
IFF_LINK1 = 0x2000
IFF_LINK2 = 0x4000
@@ -441,7 +524,6 @@
IFT_EPLRS = 0x57
IFT_ESCON = 0x49
IFT_ETHER = 0x6
- IFT_FAITH = 0xf2
IFT_FAST = 0x7d
IFT_FASTETHER = 0x3e
IFT_FASTETHERFX = 0x45
@@ -614,6 +696,7 @@
IN_CLASSD_NET = 0xf0000000
IN_CLASSD_NSHIFT = 0x1c
IN_LOOPBACKNET = 0x7f
+ IN_RFC3021_MASK = 0xfffffffe
IPPROTO_3PC = 0x22
IPPROTO_ADFS = 0x44
IPPROTO_AH = 0x33
@@ -735,7 +818,6 @@
IPV6_DEFHLIM = 0x40
IPV6_DONTFRAG = 0x3e
IPV6_DSTOPTS = 0x32
- IPV6_FAITH = 0x1d
IPV6_FLOWINFO_MASK = 0xffffff0f
IPV6_FLOWLABEL_MASK = 0xffff0f00
IPV6_FRAGTTL = 0x78
@@ -747,7 +829,6 @@
IPV6_HLIMDEC = 0x1
IPV6_HOPLIMIT = 0x2f
IPV6_HOPOPTS = 0x31
- IPV6_IPSEC_POLICY = 0x1c
IPV6_JOIN_GROUP = 0xc
IPV6_LEAVE_GROUP = 0xd
IPV6_MAXHLIM = 0xff
@@ -795,16 +876,22 @@
IP_DUMMYNET_DEL = 0x3d
IP_DUMMYNET_FLUSH = 0x3e
IP_DUMMYNET_GET = 0x40
- IP_FAITH = 0x16
IP_FW_ADD = 0x32
IP_FW_DEL = 0x33
IP_FW_FLUSH = 0x34
IP_FW_GET = 0x36
IP_FW_RESETLOG = 0x37
+ IP_FW_TBL_ADD = 0x2a
+ IP_FW_TBL_CREATE = 0x28
+ IP_FW_TBL_DEL = 0x2b
+ IP_FW_TBL_DESTROY = 0x29
+ IP_FW_TBL_EXPIRE = 0x2f
+ IP_FW_TBL_FLUSH = 0x2c
+ IP_FW_TBL_GET = 0x2d
+ IP_FW_TBL_ZERO = 0x2e
IP_FW_X = 0x31
IP_FW_ZERO = 0x35
IP_HDRINCL = 0x2
- IP_IPSEC_POLICY = 0x15
IP_MAXPACKET = 0xffff
IP_MAX_MEMBERSHIPS = 0x14
IP_MF = 0x2000
@@ -1080,12 +1167,10 @@
RTM_MISS = 0x7
RTM_NEWADDR = 0xc
RTM_NEWMADDR = 0xf
- RTM_OLDADD = 0x9
- RTM_OLDDEL = 0xa
RTM_REDIRECT = 0x6
RTM_RESOLVE = 0xb
RTM_RTTUNIT = 0xf4240
- RTM_VERSION = 0x6
+ RTM_VERSION = 0x7
RTV_EXPIRE = 0x4
RTV_HOPCOUNT = 0x2
RTV_IWCAPSEGS = 0x400
@@ -1106,13 +1191,13 @@
SHUT_RDWR = 0x2
SHUT_WR = 0x1
SIOCADDMULTI = 0x80206931
- SIOCADDRT = 0x8040720a
SIOCAIFADDR = 0x8040691a
+ SIOCAIFGROUP = 0x80286987
SIOCALIFADDR = 0x8118691b
SIOCATMARK = 0x40047307
SIOCDELMULTI = 0x80206932
- SIOCDELRT = 0x8040720b
SIOCDIFADDR = 0x80206919
+ SIOCDIFGROUP = 0x80286989
SIOCDIFPHYADDR = 0x80206949
SIOCDLIFADDR = 0x8118691d
SIOCGDRVSPEC = 0xc028697b
@@ -1120,6 +1205,7 @@
SIOCGETVIFCNT = 0xc028720f
SIOCGHIWAT = 0x40047301
SIOCGIFADDR = 0xc0206921
+ SIOCGIFALIAS = 0xc0406929
SIOCGIFBRDADDR = 0xc0206923
SIOCGIFCAP = 0xc020691f
SIOCGIFCONF = 0xc0106924
@@ -1128,6 +1214,7 @@
SIOCGIFFLAGS = 0xc0206911
SIOCGIFGENERIC = 0xc020693a
SIOCGIFGMEMB = 0xc028698a
+ SIOCGIFGROUP = 0xc0286988
SIOCGIFINDEX = 0xc0206920
SIOCGIFMEDIA = 0xc0306938
SIOCGIFMETRIC = 0xc0206917
@@ -1194,6 +1281,7 @@
SO_RCVBUF = 0x1002
SO_RCVLOWAT = 0x1004
SO_RCVTIMEO = 0x1006
+ SO_RERROR = 0x2000
SO_REUSEADDR = 0x4
SO_REUSEPORT = 0x200
SO_SNDBUF = 0x1001
@@ -1233,6 +1321,9 @@
S_IXGRP = 0x8
S_IXOTH = 0x1
S_IXUSR = 0x40
+ TAB0 = 0x0
+ TAB3 = 0x4
+ TABDLY = 0x4
TCIFLUSH = 0x1
TCIOFF = 0x3
TCIOFLUSH = 0x3
@@ -1259,6 +1350,8 @@
TCP_NOPUSH = 0x4
TCP_SIGNATURE_ENABLE = 0x10
TCSAFLUSH = 0x2
+ TIMER_ABSTIME = 0x1
+ TIMER_RELTIME = 0x0
TIOCCBRK = 0x2000747a
TIOCCDTR = 0x20007478
TIOCCONS = 0x80047462
@@ -1272,7 +1365,6 @@
TIOCGETD = 0x4004741a
TIOCGPGRP = 0x40047477
TIOCGSID = 0x40047463
- TIOCGSIZE = 0x40087468
TIOCGWINSZ = 0x40087468
TIOCISPTMASTER = 0x20007455
TIOCMBIC = 0x8004746b
@@ -1317,7 +1409,6 @@
TIOCSETD = 0x8004741b
TIOCSIG = 0x2000745f
TIOCSPGRP = 0x80047476
- TIOCSSIZE = 0x80087467
TIOCSTART = 0x2000746e
TIOCSTAT = 0x20007465
TIOCSTI = 0x80017472
@@ -1326,6 +1417,8 @@
TIOCTIMESTAMP = 0x40107459
TIOCUCNTL = 0x80047466
TOSTOP = 0x400000
+ UTIME_NOW = -0x1
+ UTIME_OMIT = -0x2
VCHECKPT = 0x13
VDISCARD = 0xf
VDSUSP = 0xb
@@ -1350,9 +1443,12 @@
VWERASE = 0x4
WCONTINUED = 0x4
WCOREFLAG = 0x80
+ WEXITED = 0x10
WLINUXCLONE = 0x80000000
WNOHANG = 0x1
- WSTOPPED = 0x7f
+ WNOWAIT = 0x8
+ WSTOPPED = 0x2
+ WTRAPPED = 0x20
WUNTRACED = 0x2
)
@@ -1452,11 +1548,6 @@
ETIMEDOUT = syscall.Errno(0x3c)
ETOOMANYREFS = syscall.Errno(0x3b)
ETXTBSY = syscall.Errno(0x1a)
- EUNUSED94 = syscall.Errno(0x5e)
- EUNUSED95 = syscall.Errno(0x5f)
- EUNUSED96 = syscall.Errno(0x60)
- EUNUSED97 = syscall.Errno(0x61)
- EUNUSED98 = syscall.Errno(0x62)
EUSERS = syscall.Errno(0x44)
EWOULDBLOCK = syscall.Errno(0x23)
EXDEV = syscall.Errno(0x12)
@@ -1600,12 +1691,7 @@
{91, "ENOLINK", "link has been severed"},
{92, "EPROTO", "protocol error"},
{93, "ENOMEDIUM", "no medium found"},
- {94, "EUNUSED94", "unknown error: 94"},
- {95, "EUNUSED95", "unknown error: 95"},
- {96, "EUNUSED96", "unknown error: 96"},
- {97, "EUNUSED97", "unknown error: 97"},
- {98, "EUNUSED98", "unknown error: 98"},
- {99, "ELAST", "unknown error: 99"},
+ {99, "EASYNC", "unknown error: 99"},
}
// Signal table
diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go
index 79e032f..2069fb8 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_linux.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go
@@ -324,6 +324,7 @@
CAP_AUDIT_WRITE = 0x1d
CAP_BLOCK_SUSPEND = 0x24
CAP_BPF = 0x27
+ CAP_CHECKPOINT_RESTORE = 0x28
CAP_CHOWN = 0x0
CAP_DAC_OVERRIDE = 0x1
CAP_DAC_READ_SEARCH = 0x2
@@ -332,7 +333,7 @@
CAP_IPC_LOCK = 0xe
CAP_IPC_OWNER = 0xf
CAP_KILL = 0x5
- CAP_LAST_CAP = 0x27
+ CAP_LAST_CAP = 0x28
CAP_LEASE = 0x1c
CAP_LINUX_IMMUTABLE = 0x9
CAP_MAC_ADMIN = 0x21
@@ -650,8 +651,8 @@
FAN_DELETE = 0x200
FAN_DELETE_SELF = 0x400
FAN_DENY = 0x2
- FAN_DIR_MODIFY = 0x80000
FAN_ENABLE_AUDIT = 0x40
+ FAN_EVENT_INFO_TYPE_DFID = 0x3
FAN_EVENT_INFO_TYPE_DFID_NAME = 0x2
FAN_EVENT_INFO_TYPE_FID = 0x1
FAN_EVENT_METADATA_LEN = 0x18
@@ -679,7 +680,10 @@
FAN_OPEN_EXEC_PERM = 0x40000
FAN_OPEN_PERM = 0x10000
FAN_Q_OVERFLOW = 0x4000
+ FAN_REPORT_DFID_NAME = 0xc00
+ FAN_REPORT_DIR_FID = 0x400
FAN_REPORT_FID = 0x200
+ FAN_REPORT_NAME = 0x800
FAN_REPORT_TID = 0x100
FAN_UNLIMITED_MARKS = 0x20
FAN_UNLIMITED_QUEUE = 0x10
@@ -1508,6 +1512,92 @@
PARITY_DEFAULT = 0x0
PARITY_NONE = 0x1
PARMRK = 0x8
+ PERF_ATTR_SIZE_VER0 = 0x40
+ PERF_ATTR_SIZE_VER1 = 0x48
+ PERF_ATTR_SIZE_VER2 = 0x50
+ PERF_ATTR_SIZE_VER3 = 0x60
+ PERF_ATTR_SIZE_VER4 = 0x68
+ PERF_ATTR_SIZE_VER5 = 0x70
+ PERF_ATTR_SIZE_VER6 = 0x78
+ PERF_AUX_FLAG_COLLISION = 0x8
+ PERF_AUX_FLAG_OVERWRITE = 0x2
+ PERF_AUX_FLAG_PARTIAL = 0x4
+ PERF_AUX_FLAG_TRUNCATED = 0x1
+ PERF_FLAG_FD_CLOEXEC = 0x8
+ PERF_FLAG_FD_NO_GROUP = 0x1
+ PERF_FLAG_FD_OUTPUT = 0x2
+ PERF_FLAG_PID_CGROUP = 0x4
+ PERF_MAX_CONTEXTS_PER_STACK = 0x8
+ PERF_MAX_STACK_DEPTH = 0x7f
+ PERF_MEM_LOCK_LOCKED = 0x2
+ PERF_MEM_LOCK_NA = 0x1
+ PERF_MEM_LOCK_SHIFT = 0x18
+ PERF_MEM_LVLNUM_ANY_CACHE = 0xb
+ PERF_MEM_LVLNUM_L1 = 0x1
+ PERF_MEM_LVLNUM_L2 = 0x2
+ PERF_MEM_LVLNUM_L3 = 0x3
+ PERF_MEM_LVLNUM_L4 = 0x4
+ PERF_MEM_LVLNUM_LFB = 0xc
+ PERF_MEM_LVLNUM_NA = 0xf
+ PERF_MEM_LVLNUM_PMEM = 0xe
+ PERF_MEM_LVLNUM_RAM = 0xd
+ PERF_MEM_LVLNUM_SHIFT = 0x21
+ PERF_MEM_LVL_HIT = 0x2
+ PERF_MEM_LVL_IO = 0x1000
+ PERF_MEM_LVL_L1 = 0x8
+ PERF_MEM_LVL_L2 = 0x20
+ PERF_MEM_LVL_L3 = 0x40
+ PERF_MEM_LVL_LFB = 0x10
+ PERF_MEM_LVL_LOC_RAM = 0x80
+ PERF_MEM_LVL_MISS = 0x4
+ PERF_MEM_LVL_NA = 0x1
+ PERF_MEM_LVL_REM_CCE1 = 0x400
+ PERF_MEM_LVL_REM_CCE2 = 0x800
+ PERF_MEM_LVL_REM_RAM1 = 0x100
+ PERF_MEM_LVL_REM_RAM2 = 0x200
+ PERF_MEM_LVL_SHIFT = 0x5
+ PERF_MEM_LVL_UNC = 0x2000
+ PERF_MEM_OP_EXEC = 0x10
+ PERF_MEM_OP_LOAD = 0x2
+ PERF_MEM_OP_NA = 0x1
+ PERF_MEM_OP_PFETCH = 0x8
+ PERF_MEM_OP_SHIFT = 0x0
+ PERF_MEM_OP_STORE = 0x4
+ PERF_MEM_REMOTE_REMOTE = 0x1
+ PERF_MEM_REMOTE_SHIFT = 0x25
+ PERF_MEM_SNOOPX_FWD = 0x1
+ PERF_MEM_SNOOPX_SHIFT = 0x25
+ PERF_MEM_SNOOP_HIT = 0x4
+ PERF_MEM_SNOOP_HITM = 0x10
+ PERF_MEM_SNOOP_MISS = 0x8
+ PERF_MEM_SNOOP_NA = 0x1
+ PERF_MEM_SNOOP_NONE = 0x2
+ PERF_MEM_SNOOP_SHIFT = 0x13
+ PERF_MEM_TLB_HIT = 0x2
+ PERF_MEM_TLB_L1 = 0x8
+ PERF_MEM_TLB_L2 = 0x10
+ PERF_MEM_TLB_MISS = 0x4
+ PERF_MEM_TLB_NA = 0x1
+ PERF_MEM_TLB_OS = 0x40
+ PERF_MEM_TLB_SHIFT = 0x1a
+ PERF_MEM_TLB_WK = 0x20
+ PERF_RECORD_KSYMBOL_FLAGS_UNREGISTER = 0x1
+ PERF_RECORD_MISC_COMM_EXEC = 0x2000
+ PERF_RECORD_MISC_CPUMODE_MASK = 0x7
+ PERF_RECORD_MISC_CPUMODE_UNKNOWN = 0x0
+ PERF_RECORD_MISC_EXACT_IP = 0x4000
+ PERF_RECORD_MISC_EXT_RESERVED = 0x8000
+ PERF_RECORD_MISC_FORK_EXEC = 0x2000
+ PERF_RECORD_MISC_GUEST_KERNEL = 0x4
+ PERF_RECORD_MISC_GUEST_USER = 0x5
+ PERF_RECORD_MISC_HYPERVISOR = 0x3
+ PERF_RECORD_MISC_KERNEL = 0x1
+ PERF_RECORD_MISC_MMAP_DATA = 0x2000
+ PERF_RECORD_MISC_PROC_MAP_PARSE_TIMEOUT = 0x1000
+ PERF_RECORD_MISC_SWITCH_OUT = 0x2000
+ PERF_RECORD_MISC_SWITCH_OUT_PREEMPT = 0x4000
+ PERF_RECORD_MISC_USER = 0x2
+ PERF_SAMPLE_BRANCH_PLM_ALL = 0x7
PIPEFS_MAGIC = 0x50495045
PPC_CMM_MAGIC = 0xc7571590
PPPIOCGNPMODE = 0xc008744c
@@ -1894,6 +1984,7 @@
RTPROT_EIGRP = 0xc0
RTPROT_GATED = 0x8
RTPROT_ISIS = 0xbb
+ RTPROT_KEEPALIVED = 0x12
RTPROT_KERNEL = 0x2
RTPROT_MROUTED = 0x11
RTPROT_MRT = 0xa
@@ -2084,6 +2175,7 @@
SO_EE_ORIGIN_TXSTATUS = 0x4
SO_EE_ORIGIN_TXTIME = 0x6
SO_EE_ORIGIN_ZEROCOPY = 0x5
+ SO_EE_RFC4884_FLAG_INVALID = 0x1
SO_GET_FILTER = 0x1a
SO_NO_CHECK = 0xb
SO_PEERNAME = 0x1c
@@ -2357,6 +2449,23 @@
WCONTINUED = 0x8
WDIOC_SETPRETIMEOUT = 0xc0045708
WDIOC_SETTIMEOUT = 0xc0045706
+ WDIOF_ALARMONLY = 0x400
+ WDIOF_CARDRESET = 0x20
+ WDIOF_EXTERN1 = 0x4
+ WDIOF_EXTERN2 = 0x8
+ WDIOF_FANFAULT = 0x2
+ WDIOF_KEEPALIVEPING = 0x8000
+ WDIOF_MAGICCLOSE = 0x100
+ WDIOF_OVERHEAT = 0x1
+ WDIOF_POWEROVER = 0x40
+ WDIOF_POWERUNDER = 0x10
+ WDIOF_PRETIMEOUT = 0x200
+ WDIOF_SETTIMEOUT = 0x80
+ WDIOF_UNKNOWN = -0x1
+ WDIOS_DISABLECARD = 0x1
+ WDIOS_ENABLECARD = 0x2
+ WDIOS_TEMPPANIC = 0x4
+ WDIOS_UNKNOWN = -0x1
WEXITED = 0x4
WIN_ACKMEDIACHANGE = 0xdb
WIN_CHECKPOWERMODE1 = 0xe5
diff --git a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go
index 46e054c..5312c36 100644
--- a/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zerrors_solaris_amd64.go
@@ -192,6 +192,12 @@
CSTOPB = 0x40
CSUSP = 0x1a
CSWTCH = 0x1a
+ DIOC = 0x6400
+ DIOCGETB = 0x6402
+ DIOCGETC = 0x6401
+ DIOCGETP = 0x6408
+ DIOCSETE = 0x6403
+ DIOCSETP = 0x6409
DLT_AIRONET_HEADER = 0x78
DLT_APPLE_IP_OVER_IEEE1394 = 0x8a
DLT_ARCNET = 0x7
@@ -290,6 +296,7 @@
FF0 = 0x0
FF1 = 0x8000
FFDLY = 0x8000
+ FIORDCHK = 0x6603
FLUSHALL = 0x1
FLUSHDATA = 0x0
FLUSHO = 0x2000
@@ -645,6 +652,14 @@
MAP_SHARED = 0x1
MAP_TEXT = 0x400
MAP_TYPE = 0xf
+ MCAST_BLOCK_SOURCE = 0x2b
+ MCAST_EXCLUDE = 0x2
+ MCAST_INCLUDE = 0x1
+ MCAST_JOIN_GROUP = 0x29
+ MCAST_JOIN_SOURCE_GROUP = 0x2d
+ MCAST_LEAVE_GROUP = 0x2a
+ MCAST_LEAVE_SOURCE_GROUP = 0x2e
+ MCAST_UNBLOCK_SOURCE = 0x2c
MCL_CURRENT = 0x1
MCL_FUTURE = 0x2
MSG_CTRUNC = 0x10
@@ -653,6 +668,7 @@
MSG_DUPCTRL = 0x800
MSG_EOR = 0x8
MSG_MAXIOVLEN = 0x10
+ MSG_NOSIGNAL = 0x200
MSG_NOTIFICATION = 0x100
MSG_OOB = 0x1
MSG_PEEK = 0x2
@@ -687,6 +703,7 @@
O_APPEND = 0x8
O_CLOEXEC = 0x800000
O_CREAT = 0x100
+ O_DIRECTORY = 0x1000000
O_DSYNC = 0x40
O_EXCL = 0x400
O_EXEC = 0x400000
@@ -725,7 +742,7 @@
RLIMIT_FSIZE = 0x1
RLIMIT_NOFILE = 0x5
RLIMIT_STACK = 0x3
- RLIM_INFINITY = -0x3
+ RLIM_INFINITY = 0xfffffffffffffffd
RTAX_AUTHOR = 0x6
RTAX_BRD = 0x7
RTAX_DST = 0x0
@@ -1047,6 +1064,7 @@
TCOON = 0x1
TCP_ABORT_THRESHOLD = 0x11
TCP_ANONPRIVBIND = 0x20
+ TCP_CONGESTION = 0x25
TCP_CONN_ABORT_THRESHOLD = 0x13
TCP_CONN_NOTIFY_THRESHOLD = 0x12
TCP_CORK = 0x18
@@ -1076,6 +1094,8 @@
TCSETSF = 0x5410
TCSETSW = 0x540f
TCXONC = 0x5406
+ TIMER_ABSTIME = 0x1
+ TIMER_RELTIME = 0x0
TIOC = 0x5400
TIOCCBRK = 0x747a
TIOCCDTR = 0x7478
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
index 3976147..6eb4579 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go
@@ -490,21 +490,6 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
- _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-func libc_getattrlist_trampoline()
-
-//go:linkname libc_getattrlist libc_getattrlist
-//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib"
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func pipe() (r int, w int, err error) {
r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0)
r = int(r0)
@@ -1277,6 +1262,28 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Getcwd(buf []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := syscall_syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getcwd_trampoline()
+
+//go:linkname libc_getcwd libc_getcwd
+//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Getdtablesize() (size int) {
r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0)
size = int(r0)
@@ -2427,21 +2434,6 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-func libc_ptrace_trampoline()
-
-//go:linkname libc_ptrace libc_ptrace
-//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func Fstat(fd int, stat *Stat_t) (err error) {
_, _, e1 := syscall_syscall(funcPC(libc_fstat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
@@ -2528,6 +2520,21 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Stat(path string, stat *Stat_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s
index 961058d..1c53979 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s
@@ -60,8 +60,6 @@
JMP libc_munlock(SB)
TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
JMP libc_munlockall(SB)
-TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
- JMP libc_getattrlist(SB)
TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
JMP libc_pipe(SB)
TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
@@ -146,6 +144,8 @@
JMP libc_fsync(SB)
TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
JMP libc_ftruncate(SB)
+TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getcwd(SB)
TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
JMP libc_getdtablesize(SB)
TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
@@ -272,8 +272,6 @@
JMP libc_mmap(SB)
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_munmap(SB)
-TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
- JMP libc_ptrace(SB)
TEXT ·libc_fstat64_trampoline(SB),NOSPLIT,$0-0
JMP libc_fstat64(SB)
TEXT ·libc_fstatat64_trampoline(SB),NOSPLIT,$0-0
@@ -284,6 +282,8 @@
JMP libc_getfsstat64(SB)
TEXT ·libc_lstat64_trampoline(SB),NOSPLIT,$0-0
JMP libc_lstat64(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
TEXT ·libc_stat64_trampoline(SB),NOSPLIT,$0-0
JMP libc_stat64(SB)
TEXT ·libc_statfs64_trampoline(SB),NOSPLIT,$0-0
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
index e253f43..889c140 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go
@@ -490,21 +490,6 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
- _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-func libc_getattrlist_trampoline()
-
-//go:linkname libc_getattrlist libc_getattrlist
-//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib"
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func pipe() (r int, w int, err error) {
r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0)
r = int(r0)
@@ -1277,6 +1262,28 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Getcwd(buf []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := syscall_syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getcwd_trampoline()
+
+//go:linkname libc_getcwd libc_getcwd
+//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Getdtablesize() (size int) {
r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0)
size = int(r0)
@@ -2427,21 +2434,6 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
- _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-func libc_ptrace_trampoline()
-
-//go:linkname libc_ptrace libc_ptrace
-//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func Fstat(fd int, stat *Stat_t) (err error) {
_, _, e1 := syscall_syscall(funcPC(libc_fstat64_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
if e1 != 0 {
@@ -2528,6 +2520,21 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Stat(path string, stat *Stat_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
index b8be24c..c77bd6e 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s
@@ -60,8 +60,6 @@
JMP libc_munlock(SB)
TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
JMP libc_munlockall(SB)
-TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
- JMP libc_getattrlist(SB)
TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
JMP libc_pipe(SB)
TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
@@ -146,6 +144,8 @@
JMP libc_fsync(SB)
TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
JMP libc_ftruncate(SB)
+TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getcwd(SB)
TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
JMP libc_getdtablesize(SB)
TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
@@ -272,8 +272,6 @@
JMP libc_mmap(SB)
TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
JMP libc_munmap(SB)
-TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
- JMP libc_ptrace(SB)
TEXT ·libc_fstat64_trampoline(SB),NOSPLIT,$0-0
JMP libc_fstat64(SB)
TEXT ·libc_fstatat64_trampoline(SB),NOSPLIT,$0-0
@@ -284,6 +282,8 @@
JMP libc_getfsstat64(SB)
TEXT ·libc_lstat64_trampoline(SB),NOSPLIT,$0-0
JMP libc_lstat64(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
TEXT ·libc_stat64_trampoline(SB),NOSPLIT,$0-0
JMP libc_stat64(SB)
TEXT ·libc_statfs64_trampoline(SB),NOSPLIT,$0-0
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go
index be2e283..d6b5249 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go
@@ -490,21 +490,6 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
- _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-func libc_getattrlist_trampoline()
-
-//go:linkname libc_getattrlist libc_getattrlist
-//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib"
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func pipe() (r int, w int, err error) {
r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0)
r = int(r0)
@@ -1277,6 +1262,28 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Getcwd(buf []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := syscall_syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getcwd_trampoline()
+
+//go:linkname libc_getcwd libc_getcwd
+//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Getdtablesize() (size int) {
r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0)
size = int(r0)
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s
index 403c21f..5eec5f1 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s
@@ -60,8 +60,6 @@
JMP libc_munlock(SB)
TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
JMP libc_munlockall(SB)
-TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
- JMP libc_getattrlist(SB)
TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
JMP libc_pipe(SB)
TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
@@ -146,6 +144,8 @@
JMP libc_fsync(SB)
TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
JMP libc_ftruncate(SB)
+TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getcwd(SB)
TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
JMP libc_getdtablesize(SB)
TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
index 34976a4..23b65a5 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go
@@ -490,21 +490,6 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) {
- _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-func libc_getattrlist_trampoline()
-
-//go:linkname libc_getattrlist libc_getattrlist
-//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib"
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func pipe() (r int, w int, err error) {
r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0)
r = int(r0)
@@ -1277,6 +1262,28 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func Getcwd(buf []byte) (n int, err error) {
+ var _p0 unsafe.Pointer
+ if len(buf) > 0 {
+ _p0 = unsafe.Pointer(&buf[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ r0, _, e1 := syscall_syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0)
+ n = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_getcwd_trampoline()
+
+//go:linkname libc_getcwd libc_getcwd
+//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Getdtablesize() (size int) {
r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0)
size = int(r0)
@@ -2513,6 +2520,21 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+ _, _, e1 := syscall_syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Stat(path string, stat *Stat_t) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s
index abe7b6e..53c402b 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s
+++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s
@@ -60,8 +60,6 @@
JMP libc_munlock(SB)
TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0
JMP libc_munlockall(SB)
-TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0
- JMP libc_getattrlist(SB)
TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0
JMP libc_pipe(SB)
TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0
@@ -146,6 +144,8 @@
JMP libc_fsync(SB)
TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
JMP libc_ftruncate(SB)
+TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_getcwd(SB)
TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0
JMP libc_getdtablesize(SB)
TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
@@ -282,6 +282,8 @@
JMP libc_getfsstat(SB)
TEXT ·libc_lstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_lstat(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
TEXT ·libc_stat_trampoline(SB),NOSPLIT,$0-0
JMP libc_stat(SB)
TEXT ·libc_statfs_trampoline(SB),NOSPLIT,$0-0
diff --git a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
index fe1fdd7..aebfe51 100644
--- a/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsyscall_dragonfly_amd64.go
@@ -214,22 +214,6 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
- var _p0 unsafe.Pointer
- if len(mib) > 0 {
- _p0 = unsafe.Pointer(&mib[0])
- } else {
- _p0 = unsafe.Pointer(&_zero)
- }
- _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
-
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
-
func utimes(path string, timeval *[2]Timeval) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
@@ -439,6 +423,22 @@
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
+ var _p0 unsafe.Pointer
+ if len(mib) > 0 {
+ _p0 = unsafe.Pointer(&mib[0])
+ } else {
+ _p0 = unsafe.Pointer(&_zero)
+ }
+ _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Access(path string, mode uint32) (err error) {
var _p0 *byte
_p0, err = BytePtrFromString(path)
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go
index 464c9a9..9912c6e 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_dragonfly_amd64.go
@@ -6,129 +6,125 @@
package unix
const (
- // SYS_NOSYS = 0; // { int nosys(void); } syscall nosys_args int
- SYS_EXIT = 1 // { void exit(int rval); }
- SYS_FORK = 2 // { int fork(void); }
- SYS_READ = 3 // { ssize_t read(int fd, void *buf, size_t nbyte); }
- SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, size_t nbyte); }
- SYS_OPEN = 5 // { int open(char *path, int flags, int mode); }
- SYS_CLOSE = 6 // { int close(int fd); }
- SYS_WAIT4 = 7 // { int wait4(int pid, int *status, int options, struct rusage *rusage); } wait4 wait_args int
- SYS_LINK = 9 // { int link(char *path, char *link); }
- SYS_UNLINK = 10 // { int unlink(char *path); }
- SYS_CHDIR = 12 // { int chdir(char *path); }
- SYS_FCHDIR = 13 // { int fchdir(int fd); }
- SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); }
- SYS_CHMOD = 15 // { int chmod(char *path, int mode); }
- SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); }
- SYS_OBREAK = 17 // { int obreak(char *nsize); } break obreak_args int
- SYS_GETFSSTAT = 18 // { int getfsstat(struct statfs *buf, long bufsize, int flags); }
- SYS_GETPID = 20 // { pid_t getpid(void); }
- SYS_MOUNT = 21 // { int mount(char *type, char *path, int flags, caddr_t data); }
- SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); }
- SYS_SETUID = 23 // { int setuid(uid_t uid); }
- SYS_GETUID = 24 // { uid_t getuid(void); }
- SYS_GETEUID = 25 // { uid_t geteuid(void); }
- SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, caddr_t addr, int data); }
- SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, int flags); }
- SYS_SENDMSG = 28 // { int sendmsg(int s, caddr_t msg, int flags); }
- SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, size_t len, int flags, caddr_t from, int *fromlenaddr); }
- SYS_ACCEPT = 30 // { int accept(int s, caddr_t name, int *anamelen); }
- SYS_GETPEERNAME = 31 // { int getpeername(int fdes, caddr_t asa, int *alen); }
- SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, caddr_t asa, int *alen); }
- SYS_ACCESS = 33 // { int access(char *path, int flags); }
- SYS_CHFLAGS = 34 // { int chflags(char *path, int flags); }
- SYS_FCHFLAGS = 35 // { int fchflags(int fd, int flags); }
- SYS_SYNC = 36 // { int sync(void); }
- SYS_KILL = 37 // { int kill(int pid, int signum); }
- SYS_GETPPID = 39 // { pid_t getppid(void); }
- SYS_DUP = 41 // { int dup(int fd); }
- SYS_PIPE = 42 // { int pipe(void); }
- SYS_GETEGID = 43 // { gid_t getegid(void); }
- SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, size_t offset, u_int scale); }
- SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, int facs, int pid); }
- SYS_GETGID = 47 // { gid_t getgid(void); }
- SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, u_int namelen); }
- SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); }
- SYS_ACCT = 51 // { int acct(char *path); }
- SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, stack_t *oss); }
- SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, caddr_t data); }
- SYS_REBOOT = 55 // { int reboot(int opt); }
- SYS_REVOKE = 56 // { int revoke(char *path); }
- SYS_SYMLINK = 57 // { int symlink(char *path, char *link); }
- SYS_READLINK = 58 // { int readlink(char *path, char *buf, int count); }
- SYS_EXECVE = 59 // { int execve(char *fname, char **argv, char **envv); }
- SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args int
- SYS_CHROOT = 61 // { int chroot(char *path); }
- SYS_MSYNC = 65 // { int msync(void *addr, size_t len, int flags); }
- SYS_VFORK = 66 // { pid_t vfork(void); }
- SYS_SBRK = 69 // { int sbrk(int incr); }
- SYS_SSTK = 70 // { int sstk(int incr); }
- SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); }
- SYS_MPROTECT = 74 // { int mprotect(void *addr, size_t len, int prot); }
- SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, int behav); }
- SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, char *vec); }
- SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, gid_t *gidset); }
- SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, gid_t *gidset); }
- SYS_GETPGRP = 81 // { int getpgrp(void); }
- SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); }
- SYS_SETITIMER = 83 // { int setitimer(u_int which, struct itimerval *itv, struct itimerval *oitv); }
- SYS_SWAPON = 85 // { int swapon(char *name); }
- SYS_GETITIMER = 86 // { int getitimer(u_int which, struct itimerval *itv); }
- SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); }
- SYS_DUP2 = 90 // { int dup2(int from, int to); }
- SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); }
- SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); }
- SYS_FSYNC = 95 // { int fsync(int fd); }
- SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, int prio); }
- SYS_SOCKET = 97 // { int socket(int domain, int type, int protocol); }
- SYS_CONNECT = 98 // { int connect(int s, caddr_t name, int namelen); }
- SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); }
- SYS_BIND = 104 // { int bind(int s, caddr_t name, int namelen); }
- SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, caddr_t val, int valsize); }
- SYS_LISTEN = 106 // { int listen(int s, int backlog); }
- SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, struct timezone *tzp); }
- SYS_GETRUSAGE = 117 // { int getrusage(int who, struct rusage *rusage); }
- SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, caddr_t val, int *avalsize); }
- SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, u_int iovcnt); }
- SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, u_int iovcnt); }
- SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, struct timezone *tzp); }
- SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); }
- SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); }
- SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); }
- SYS_SETREGID = 127 // { int setregid(int rgid, int egid); }
- SYS_RENAME = 128 // { int rename(char *from, char *to); }
- SYS_FLOCK = 131 // { int flock(int fd, int how); }
- SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); }
- SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, int flags, caddr_t to, int tolen); }
- SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); }
- SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, int protocol, int *rsv); }
- SYS_MKDIR = 136 // { int mkdir(char *path, int mode); }
- SYS_RMDIR = 137 // { int rmdir(char *path); }
- SYS_UTIMES = 138 // { int utimes(char *path, struct timeval *tptr); }
- SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, struct timeval *olddelta); }
- SYS_SETSID = 147 // { int setsid(void); }
- SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, caddr_t arg); }
- SYS_STATFS = 157 // { int statfs(char *path, struct statfs *buf); }
- SYS_FSTATFS = 158 // { int fstatfs(int fd, struct statfs *buf); }
- SYS_GETFH = 161 // { int getfh(char *fname, struct fhandle *fhp); }
- SYS_GETDOMAINNAME = 162 // { int getdomainname(char *domainname, int len); }
- SYS_SETDOMAINNAME = 163 // { int setdomainname(char *domainname, int len); }
- SYS_UNAME = 164 // { int uname(struct utsname *name); }
- SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); }
- SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, struct rtprio *rtp); }
- SYS_EXTPREAD = 173 // { ssize_t extpread(int fd, void *buf, size_t nbyte, int flags, off_t offset); }
- SYS_EXTPWRITE = 174 // { ssize_t extpwrite(int fd, const void *buf, size_t nbyte, int flags, off_t offset); }
- SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); }
- SYS_SETGID = 181 // { int setgid(gid_t gid); }
- SYS_SETEGID = 182 // { int setegid(gid_t egid); }
- SYS_SETEUID = 183 // { int seteuid(uid_t euid); }
- SYS_PATHCONF = 191 // { int pathconf(char *path, int name); }
- SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); }
- SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, struct rlimit *rlp); } getrlimit __getrlimit_args int
- SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, struct rlimit *rlp); } setrlimit __setrlimit_args int
- SYS_MMAP = 197 // { caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, int pad, off_t pos); }
- // SYS_NOSYS = 198; // { int nosys(void); } __syscall __syscall_args int
+ SYS_EXIT = 1 // { void exit(int rval); }
+ SYS_FORK = 2 // { int fork(void); }
+ SYS_READ = 3 // { ssize_t read(int fd, void *buf, size_t nbyte); }
+ SYS_WRITE = 4 // { ssize_t write(int fd, const void *buf, size_t nbyte); }
+ SYS_OPEN = 5 // { int open(char *path, int flags, int mode); }
+ SYS_CLOSE = 6 // { int close(int fd); }
+ SYS_WAIT4 = 7 // { int wait4(int pid, int *status, int options, struct rusage *rusage); } wait4 wait_args int
+ // SYS_NOSYS = 8; // { int nosys(void); } __nosys nosys_args int
+ SYS_LINK = 9 // { int link(char *path, char *link); }
+ SYS_UNLINK = 10 // { int unlink(char *path); }
+ SYS_CHDIR = 12 // { int chdir(char *path); }
+ SYS_FCHDIR = 13 // { int fchdir(int fd); }
+ SYS_MKNOD = 14 // { int mknod(char *path, int mode, int dev); }
+ SYS_CHMOD = 15 // { int chmod(char *path, int mode); }
+ SYS_CHOWN = 16 // { int chown(char *path, int uid, int gid); }
+ SYS_OBREAK = 17 // { int obreak(char *nsize); } break obreak_args int
+ SYS_GETFSSTAT = 18 // { int getfsstat(struct statfs *buf, long bufsize, int flags); }
+ SYS_GETPID = 20 // { pid_t getpid(void); }
+ SYS_MOUNT = 21 // { int mount(char *type, char *path, int flags, caddr_t data); }
+ SYS_UNMOUNT = 22 // { int unmount(char *path, int flags); }
+ SYS_SETUID = 23 // { int setuid(uid_t uid); }
+ SYS_GETUID = 24 // { uid_t getuid(void); }
+ SYS_GETEUID = 25 // { uid_t geteuid(void); }
+ SYS_PTRACE = 26 // { int ptrace(int req, pid_t pid, caddr_t addr, int data); }
+ SYS_RECVMSG = 27 // { int recvmsg(int s, struct msghdr *msg, int flags); }
+ SYS_SENDMSG = 28 // { int sendmsg(int s, caddr_t msg, int flags); }
+ SYS_RECVFROM = 29 // { int recvfrom(int s, caddr_t buf, size_t len, int flags, caddr_t from, int *fromlenaddr); }
+ SYS_ACCEPT = 30 // { int accept(int s, caddr_t name, int *anamelen); }
+ SYS_GETPEERNAME = 31 // { int getpeername(int fdes, caddr_t asa, int *alen); }
+ SYS_GETSOCKNAME = 32 // { int getsockname(int fdes, caddr_t asa, int *alen); }
+ SYS_ACCESS = 33 // { int access(char *path, int flags); }
+ SYS_CHFLAGS = 34 // { int chflags(const char *path, u_long flags); }
+ SYS_FCHFLAGS = 35 // { int fchflags(int fd, u_long flags); }
+ SYS_SYNC = 36 // { int sync(void); }
+ SYS_KILL = 37 // { int kill(int pid, int signum); }
+ SYS_GETPPID = 39 // { pid_t getppid(void); }
+ SYS_DUP = 41 // { int dup(int fd); }
+ SYS_PIPE = 42 // { int pipe(void); }
+ SYS_GETEGID = 43 // { gid_t getegid(void); }
+ SYS_PROFIL = 44 // { int profil(caddr_t samples, size_t size, u_long offset, u_int scale); }
+ SYS_KTRACE = 45 // { int ktrace(const char *fname, int ops, int facs, int pid); }
+ SYS_GETGID = 47 // { gid_t getgid(void); }
+ SYS_GETLOGIN = 49 // { int getlogin(char *namebuf, size_t namelen); }
+ SYS_SETLOGIN = 50 // { int setlogin(char *namebuf); }
+ SYS_ACCT = 51 // { int acct(char *path); }
+ SYS_SIGALTSTACK = 53 // { int sigaltstack(stack_t *ss, stack_t *oss); }
+ SYS_IOCTL = 54 // { int ioctl(int fd, u_long com, caddr_t data); }
+ SYS_REBOOT = 55 // { int reboot(int opt); }
+ SYS_REVOKE = 56 // { int revoke(char *path); }
+ SYS_SYMLINK = 57 // { int symlink(char *path, char *link); }
+ SYS_READLINK = 58 // { int readlink(char *path, char *buf, int count); }
+ SYS_EXECVE = 59 // { int execve(char *fname, char **argv, char **envv); }
+ SYS_UMASK = 60 // { int umask(int newmask); } umask umask_args int
+ SYS_CHROOT = 61 // { int chroot(char *path); }
+ SYS_MSYNC = 65 // { int msync(void *addr, size_t len, int flags); }
+ SYS_VFORK = 66 // { pid_t vfork(void); }
+ SYS_SBRK = 69 // { caddr_t sbrk(size_t incr); }
+ SYS_SSTK = 70 // { int sstk(size_t incr); }
+ SYS_MUNMAP = 73 // { int munmap(void *addr, size_t len); }
+ SYS_MPROTECT = 74 // { int mprotect(void *addr, size_t len, int prot); }
+ SYS_MADVISE = 75 // { int madvise(void *addr, size_t len, int behav); }
+ SYS_MINCORE = 78 // { int mincore(const void *addr, size_t len, char *vec); }
+ SYS_GETGROUPS = 79 // { int getgroups(u_int gidsetsize, gid_t *gidset); }
+ SYS_SETGROUPS = 80 // { int setgroups(u_int gidsetsize, gid_t *gidset); }
+ SYS_GETPGRP = 81 // { int getpgrp(void); }
+ SYS_SETPGID = 82 // { int setpgid(int pid, int pgid); }
+ SYS_SETITIMER = 83 // { int setitimer(u_int which, struct itimerval *itv, struct itimerval *oitv); }
+ SYS_SWAPON = 85 // { int swapon(char *name); }
+ SYS_GETITIMER = 86 // { int getitimer(u_int which, struct itimerval *itv); }
+ SYS_GETDTABLESIZE = 89 // { int getdtablesize(void); }
+ SYS_DUP2 = 90 // { int dup2(int from, int to); }
+ SYS_FCNTL = 92 // { int fcntl(int fd, int cmd, long arg); }
+ SYS_SELECT = 93 // { int select(int nd, fd_set *in, fd_set *ou, fd_set *ex, struct timeval *tv); }
+ SYS_FSYNC = 95 // { int fsync(int fd); }
+ SYS_SETPRIORITY = 96 // { int setpriority(int which, int who, int prio); }
+ SYS_SOCKET = 97 // { int socket(int domain, int type, int protocol); }
+ SYS_CONNECT = 98 // { int connect(int s, caddr_t name, int namelen); }
+ SYS_GETPRIORITY = 100 // { int getpriority(int which, int who); }
+ SYS_BIND = 104 // { int bind(int s, caddr_t name, int namelen); }
+ SYS_SETSOCKOPT = 105 // { int setsockopt(int s, int level, int name, caddr_t val, int valsize); }
+ SYS_LISTEN = 106 // { int listen(int s, int backlog); }
+ SYS_GETTIMEOFDAY = 116 // { int gettimeofday(struct timeval *tp, struct timezone *tzp); }
+ SYS_GETRUSAGE = 117 // { int getrusage(int who, struct rusage *rusage); }
+ SYS_GETSOCKOPT = 118 // { int getsockopt(int s, int level, int name, caddr_t val, int *avalsize); }
+ SYS_READV = 120 // { int readv(int fd, struct iovec *iovp, u_int iovcnt); }
+ SYS_WRITEV = 121 // { int writev(int fd, struct iovec *iovp, u_int iovcnt); }
+ SYS_SETTIMEOFDAY = 122 // { int settimeofday(struct timeval *tv, struct timezone *tzp); }
+ SYS_FCHOWN = 123 // { int fchown(int fd, int uid, int gid); }
+ SYS_FCHMOD = 124 // { int fchmod(int fd, int mode); }
+ SYS_SETREUID = 126 // { int setreuid(int ruid, int euid); }
+ SYS_SETREGID = 127 // { int setregid(int rgid, int egid); }
+ SYS_RENAME = 128 // { int rename(char *from, char *to); }
+ SYS_FLOCK = 131 // { int flock(int fd, int how); }
+ SYS_MKFIFO = 132 // { int mkfifo(char *path, int mode); }
+ SYS_SENDTO = 133 // { int sendto(int s, caddr_t buf, size_t len, int flags, caddr_t to, int tolen); }
+ SYS_SHUTDOWN = 134 // { int shutdown(int s, int how); }
+ SYS_SOCKETPAIR = 135 // { int socketpair(int domain, int type, int protocol, int *rsv); }
+ SYS_MKDIR = 136 // { int mkdir(char *path, int mode); }
+ SYS_RMDIR = 137 // { int rmdir(char *path); }
+ SYS_UTIMES = 138 // { int utimes(char *path, struct timeval *tptr); }
+ SYS_ADJTIME = 140 // { int adjtime(struct timeval *delta, struct timeval *olddelta); }
+ SYS_SETSID = 147 // { int setsid(void); }
+ SYS_QUOTACTL = 148 // { int quotactl(char *path, int cmd, int uid, caddr_t arg); }
+ SYS_STATFS = 157 // { int statfs(char *path, struct statfs *buf); }
+ SYS_FSTATFS = 158 // { int fstatfs(int fd, struct statfs *buf); }
+ SYS_GETFH = 161 // { int getfh(char *fname, struct fhandle *fhp); }
+ SYS_SYSARCH = 165 // { int sysarch(int op, char *parms); }
+ SYS_RTPRIO = 166 // { int rtprio(int function, pid_t pid, struct rtprio *rtp); }
+ SYS_EXTPREAD = 173 // { ssize_t extpread(int fd, void *buf, size_t nbyte, int flags, off_t offset); }
+ SYS_EXTPWRITE = 174 // { ssize_t extpwrite(int fd, const void *buf, size_t nbyte, int flags, off_t offset); }
+ SYS_NTP_ADJTIME = 176 // { int ntp_adjtime(struct timex *tp); }
+ SYS_SETGID = 181 // { int setgid(gid_t gid); }
+ SYS_SETEGID = 182 // { int setegid(gid_t egid); }
+ SYS_SETEUID = 183 // { int seteuid(uid_t euid); }
+ SYS_PATHCONF = 191 // { int pathconf(char *path, int name); }
+ SYS_FPATHCONF = 192 // { int fpathconf(int fd, int name); }
+ SYS_GETRLIMIT = 194 // { int getrlimit(u_int which, struct rlimit *rlp); } getrlimit __getrlimit_args int
+ SYS_SETRLIMIT = 195 // { int setrlimit(u_int which, struct rlimit *rlp); } setrlimit __setrlimit_args int
+ SYS_MMAP = 197 // { caddr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, int pad, off_t pos); }
SYS_LSEEK = 199 // { off_t lseek(int fd, int pad, off_t offset, int whence); }
SYS_TRUNCATE = 200 // { int truncate(char *path, int pad, off_t length); }
SYS_FTRUNCATE = 201 // { int ftruncate(int fd, int pad, off_t length); }
@@ -161,8 +157,8 @@
SYS_LCHOWN = 254 // { int lchown(char *path, int uid, int gid); }
SYS_LCHMOD = 274 // { int lchmod(char *path, mode_t mode); }
SYS_LUTIMES = 276 // { int lutimes(char *path, struct timeval *tptr); }
- SYS_EXTPREADV = 289 // { ssize_t extpreadv(int fd, struct iovec *iovp, u_int iovcnt, int flags, off_t offset); }
- SYS_EXTPWRITEV = 290 // { ssize_t extpwritev(int fd, struct iovec *iovp,u_int iovcnt, int flags, off_t offset); }
+ SYS_EXTPREADV = 289 // { ssize_t extpreadv(int fd, const struct iovec *iovp, int iovcnt, int flags, off_t offset); }
+ SYS_EXTPWRITEV = 290 // { ssize_t extpwritev(int fd, const struct iovec *iovp, int iovcnt, int flags, off_t offset); }
SYS_FHSTATFS = 297 // { int fhstatfs(const struct fhandle *u_fhp, struct statfs *buf); }
SYS_FHOPEN = 298 // { int fhopen(const struct fhandle *u_fhp, int flags); }
SYS_MODNEXT = 300 // { int modnext(int modid); }
@@ -225,7 +221,7 @@
SYS_KQUEUE = 362 // { int kqueue(void); }
SYS_KEVENT = 363 // { int kevent(int fd, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); }
SYS_KENV = 390 // { int kenv(int what, const char *name, char *value, int len); }
- SYS_LCHFLAGS = 391 // { int lchflags(char *path, int flags); }
+ SYS_LCHFLAGS = 391 // { int lchflags(const char *path, u_long flags); }
SYS_UUIDGEN = 392 // { int uuidgen(struct uuid *store, int count); }
SYS_SENDFILE = 393 // { int sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr *hdtr, off_t *sbytes, int flags); }
SYS_VARSYM_SET = 450 // { int varsym_set(int level, const char *name, const char *data); }
@@ -302,7 +298,7 @@
SYS_VMM_GUEST_CTL = 534 // { int vmm_guest_ctl(int op, struct vmm_guest_options *options); }
SYS_VMM_GUEST_SYNC_ADDR = 535 // { int vmm_guest_sync_addr(long *dstaddr, long *srcaddr); }
SYS_PROCCTL = 536 // { int procctl(idtype_t idtype, id_t id, int cmd, void *data); }
- SYS_CHFLAGSAT = 537 // { int chflagsat(int fd, const char *path, int flags, int atflags);}
+ SYS_CHFLAGSAT = 537 // { int chflagsat(int fd, const char *path, u_long flags, int atflags);}
SYS_PIPE2 = 538 // { int pipe2(int *fildes, int flags); }
SYS_UTIMENSAT = 539 // { int utimensat(int fd, const char *path, const struct timespec *ts, int flags); }
SYS_FUTIMENS = 540 // { int futimens(int fd, const struct timespec *ts); }
@@ -312,4 +308,9 @@
SYS_LWP_SETAFFINITY = 544 // { int lwp_setaffinity(pid_t pid, lwpid_t tid, const cpumask_t *mask); }
SYS_LWP_GETAFFINITY = 545 // { int lwp_getaffinity(pid_t pid, lwpid_t tid, cpumask_t *mask); }
SYS_LWP_CREATE2 = 546 // { int lwp_create2(struct lwp_params *params, const cpumask_t *mask); }
+ SYS_GETCPUCLOCKID = 547 // { int getcpuclockid(pid_t pid, lwpid_t lwp_id, clockid_t *clock_id); }
+ SYS_WAIT6 = 548 // { int wait6(idtype_t idtype, id_t id, int *status, int options, struct __wrusage *wrusage, siginfo_t *info); }
+ SYS_LWP_GETNAME = 549 // { int lwp_getname(lwpid_t tid, char *name, size_t len); }
+ SYS_GETRANDOM = 550 // { ssize_t getrandom(void *buf, size_t len, unsigned flags); }
+ SYS___REALPATH = 551 // { ssize_t __realpath(const char *path, char *buf, size_t len); }
)
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
index a597e06..0f5a3f6 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_386.go
@@ -431,6 +431,7 @@
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
index 8c102e5..36d5219 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_amd64.go
@@ -353,6 +353,7 @@
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
index 98f9b68..3622ba1 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm.go
@@ -395,6 +395,7 @@
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
index 4dabc33..6193c3d 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_arm64.go
@@ -298,6 +298,7 @@
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go
index d5724e5..640b974 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips.go
@@ -416,6 +416,7 @@
SYS_FSPICK = 4433
SYS_PIDFD_OPEN = 4434
SYS_CLONE3 = 4435
+ SYS_CLOSE_RANGE = 4436
SYS_OPENAT2 = 4437
SYS_PIDFD_GETFD = 4438
SYS_FACCESSAT2 = 4439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
index c1d824a..3467fbb 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64.go
@@ -346,6 +346,7 @@
SYS_FSPICK = 5433
SYS_PIDFD_OPEN = 5434
SYS_CLONE3 = 5435
+ SYS_CLOSE_RANGE = 5436
SYS_OPENAT2 = 5437
SYS_PIDFD_GETFD = 5438
SYS_FACCESSAT2 = 5439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
index 598dd5d..0fc38d5 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mips64le.go
@@ -346,6 +346,7 @@
SYS_FSPICK = 5433
SYS_PIDFD_OPEN = 5434
SYS_CLONE3 = 5435
+ SYS_CLOSE_RANGE = 5436
SYS_OPENAT2 = 5437
SYS_PIDFD_GETFD = 5438
SYS_FACCESSAT2 = 5439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go
index c36782d..999fd55 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_mipsle.go
@@ -416,6 +416,7 @@
SYS_FSPICK = 4433
SYS_PIDFD_OPEN = 4434
SYS_CLONE3 = 4435
+ SYS_CLOSE_RANGE = 4436
SYS_OPENAT2 = 4437
SYS_PIDFD_GETFD = 4438
SYS_FACCESSAT2 = 4439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
index 9287538..1df0d79 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64.go
@@ -395,6 +395,7 @@
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
index 4dafad8..4db39cc 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_ppc64le.go
@@ -395,6 +395,7 @@
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
index 6642cfc..e692740 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_riscv64.go
@@ -297,6 +297,7 @@
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
index 23367b9..a585aec 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_s390x.go
@@ -360,6 +360,7 @@
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
SYS_CLONE3 = 435
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
index 083aa02..d047e56 100644
--- a/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
+++ b/vendor/golang.org/x/sys/unix/zsysnum_linux_sparc64.go
@@ -374,6 +374,7 @@
SYS_FSMOUNT = 432
SYS_FSPICK = 433
SYS_PIDFD_OPEN = 434
+ SYS_CLOSE_RANGE = 436
SYS_OPENAT2 = 437
SYS_PIDFD_GETFD = 438
SYS_FACCESSAT2 = 439
diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go
index 9f47b87..9ea0293 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go
@@ -92,9 +92,9 @@
Type uint32
Flags uint32
Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
+ Fstypename [16]byte
+ Mntonname [1024]byte
+ Mntfromname [1024]byte
Reserved [8]uint32
}
@@ -145,6 +145,10 @@
_ [3]byte
}
+const (
+ PathMax = 0x400
+)
+
type RawSockaddrInet4 struct {
Len uint8
Family uint8
@@ -301,7 +305,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Data IfData
}
@@ -344,7 +347,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Metric int32
}
@@ -365,7 +367,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Refcount int32
}
@@ -374,7 +375,6 @@
Version uint8
Type uint8
Index uint16
- _ [2]byte
Flags int32
Addrs int32
Pid int32
@@ -396,7 +396,8 @@
Rtt uint32
Rttvar uint32
Pksent uint32
- Filler [4]uint32
+ State uint32
+ Filler [3]uint32
}
const (
@@ -497,3 +498,8 @@
Stathz int32
Profhz int32
}
+
+type CtlInfo struct {
+ Id uint32
+ Name [96]byte
+}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
index 966798a..255e6cb 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go
@@ -70,7 +70,6 @@
Uid uint32
Gid uint32
Rdev int32
- _ [4]byte
Atim Timespec
Mtim Timespec
Ctim Timespec
@@ -97,10 +96,11 @@
Type uint32
Flags uint32
Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
+ Fstypename [16]byte
+ Mntonname [1024]byte
+ Mntfromname [1024]byte
+ Flags_ext uint32
+ Reserved [7]uint32
}
type Flock_t struct {
@@ -133,8 +133,7 @@
type Log2phys_t struct {
Flags uint32
- _ [8]byte
- _ [8]byte
+ _ [16]byte
}
type Fsid struct {
@@ -151,6 +150,10 @@
_ [3]byte
}
+const (
+ PathMax = 0x400
+)
+
type RawSockaddrInet4 struct {
Len uint8
Family uint8
@@ -221,10 +224,8 @@
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen int32
- _ [4]byte
Control *byte
Controllen uint32
Flags int32
@@ -309,7 +310,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Data IfData
}
@@ -352,7 +352,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Metric int32
}
@@ -373,7 +372,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Refcount int32
}
@@ -382,7 +380,6 @@
Version uint8
Type uint8
Index uint16
- _ [2]byte
Flags int32
Addrs int32
Pid int32
@@ -404,7 +401,8 @@
Rtt uint32
Rttvar uint32
Pksent uint32
- Filler [4]uint32
+ State uint32
+ Filler [3]uint32
}
const (
@@ -427,7 +425,6 @@
type BpfProgram struct {
Len uint32
- _ [4]byte
Insns *BpfInsn
}
@@ -452,7 +449,6 @@
Cflag uint64
Lflag uint64
Cc [20]uint8
- _ [4]byte
Ispeed uint64
Ospeed uint64
}
@@ -507,3 +503,8 @@
Stathz int32
Profhz int32
}
+
+type CtlInfo struct {
+ Id uint32
+ Name [96]byte
+}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go
index 4fe4c9c..e21c828 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go
@@ -1,6 +1,5 @@
-// NOTE: cgo can't generate struct Stat_t and struct Statfs_t yet
-// Created by cgo -godefs - DO NOT EDIT
-// cgo -godefs types_darwin.go
+// cgo -godefs types_darwin.go | go run mkpost.go
+// Code generated by the command above; see README.md. DO NOT EDIT.
// +build arm,darwin
@@ -31,7 +30,7 @@
Usec int32
}
-type Timeval32 [0]byte
+type Timeval32 struct{}
type Rusage struct {
Utime Timeval
@@ -93,9 +92,9 @@
Type uint32
Flags uint32
Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
+ Fstypename [16]byte
+ Mntonname [1024]byte
+ Mntfromname [1024]byte
Reserved [8]uint32
}
@@ -146,6 +145,10 @@
_ [3]byte
}
+const (
+ PathMax = 0x400
+)
+
type RawSockaddrInet4 struct {
Len uint8
Family uint8
@@ -302,7 +305,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Data IfData
}
@@ -345,7 +347,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Metric int32
}
@@ -366,7 +367,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Refcount int32
}
@@ -375,7 +375,6 @@
Version uint8
Type uint8
Index uint16
- _ [2]byte
Flags int32
Addrs int32
Pid int32
@@ -397,7 +396,8 @@
Rtt uint32
Rttvar uint32
Pksent uint32
- Filler [4]uint32
+ State uint32
+ Filler [3]uint32
}
const (
@@ -498,3 +498,8 @@
Stathz int32
Profhz int32
}
+
+type CtlInfo struct {
+ Id uint32
+ Name [96]byte
+}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
index 21999e4..5eff2c1 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go
@@ -70,7 +70,6 @@
Uid uint32
Gid uint32
Rdev int32
- _ [4]byte
Atim Timespec
Mtim Timespec
Ctim Timespec
@@ -97,10 +96,11 @@
Type uint32
Flags uint32
Fssubtype uint32
- Fstypename [16]int8
- Mntonname [1024]int8
- Mntfromname [1024]int8
- Reserved [8]uint32
+ Fstypename [16]byte
+ Mntonname [1024]byte
+ Mntfromname [1024]byte
+ Flags_ext uint32
+ Reserved [7]uint32
}
type Flock_t struct {
@@ -133,8 +133,7 @@
type Log2phys_t struct {
Flags uint32
- _ [8]byte
- _ [8]byte
+ _ [16]byte
}
type Fsid struct {
@@ -151,6 +150,10 @@
_ [3]byte
}
+const (
+ PathMax = 0x400
+)
+
type RawSockaddrInet4 struct {
Len uint8
Family uint8
@@ -221,10 +224,8 @@
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen int32
- _ [4]byte
Control *byte
Controllen uint32
Flags int32
@@ -309,7 +310,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Data IfData
}
@@ -352,7 +352,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Metric int32
}
@@ -373,7 +372,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Refcount int32
}
@@ -382,7 +380,6 @@
Version uint8
Type uint8
Index uint16
- _ [2]byte
Flags int32
Addrs int32
Pid int32
@@ -404,7 +401,8 @@
Rtt uint32
Rttvar uint32
Pksent uint32
- Filler [4]uint32
+ State uint32
+ Filler [3]uint32
}
const (
@@ -427,7 +425,6 @@
type BpfProgram struct {
Len uint32
- _ [4]byte
Insns *BpfInsn
}
@@ -452,7 +449,6 @@
Cflag uint64
Lflag uint64
Cc [20]uint8
- _ [4]byte
Ispeed uint64
Ospeed uint64
}
@@ -507,3 +503,8 @@
Stathz int32
Profhz int32
}
+
+type CtlInfo struct {
+ Id uint32
+ Name [96]byte
+}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go
index 71ea1d6..c4772df 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_dragonfly_amd64.go
@@ -70,11 +70,11 @@
Ctim Timespec
Size int64
Blocks int64
- Blksize uint32
+ _ uint32
Flags uint32
Gen uint32
Lspare int32
- Qspare1 int64
+ Blksize int64
Qspare2 int64
}
@@ -91,17 +91,15 @@
Owner uint32
Type int32
Flags int32
- _ [4]byte
Syncwrites int64
Asyncwrites int64
- Fstypename [16]int8
- Mntonname [80]int8
+ Fstypename [16]byte
+ Mntonname [80]byte
Syncreads int64
Asyncreads int64
Spares1 int16
- Mntfromname [80]int8
+ Mntfromname [80]byte
Spares2 int16
- _ [4]byte
Spare [2]int64
}
@@ -202,10 +200,8 @@
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen int32
- _ [4]byte
Control *byte
Controllen uint32
Flags int32
@@ -269,7 +265,7 @@
const (
SizeofIfMsghdr = 0xb0
SizeofIfData = 0xa0
- SizeofIfaMsghdr = 0x14
+ SizeofIfaMsghdr = 0x18
SizeofIfmaMsghdr = 0x10
SizeofIfAnnounceMsghdr = 0x18
SizeofRtMsghdr = 0x98
@@ -280,10 +276,9 @@
Msglen uint16
Version uint8
Type uint8
- Addrs int32
- Flags int32
Index uint16
- _ [2]byte
+ Flags int32
+ Addrs int32
Data IfData
}
@@ -294,7 +289,6 @@
Hdrlen uint8
Recvquota uint8
Xmitquota uint8
- _ [2]byte
Mtu uint64
Metric uint64
Link_state uint64
@@ -316,24 +310,23 @@
}
type IfaMsghdr struct {
- Msglen uint16
- Version uint8
- Type uint8
- Addrs int32
- Flags int32
- Index uint16
- _ [2]byte
- Metric int32
+ Msglen uint16
+ Version uint8
+ Type uint8
+ Index uint16
+ Flags int32
+ Addrs int32
+ Addrflags int32
+ Metric int32
}
type IfmaMsghdr struct {
Msglen uint16
Version uint8
Type uint8
- Addrs int32
- Flags int32
Index uint16
- _ [2]byte
+ Flags int32
+ Addrs int32
}
type IfAnnounceMsghdr struct {
@@ -350,7 +343,6 @@
Version uint8
Type uint8
Index uint16
- _ [2]byte
Flags int32
Addrs int32
Pid int32
@@ -374,7 +366,6 @@
Hopcount uint64
Mssopt uint16
Pad uint16
- _ [4]byte
Msl uint64
Iwmaxsegs uint64
Iwcapsegs uint64
@@ -400,7 +391,6 @@
type BpfProgram struct {
Len uint32
- _ [4]byte
Insns *BpfInsn
}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go
index a92a501..773fc32 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go
@@ -554,7 +554,11 @@
IFLA_NEW_IFINDEX = 0x31
IFLA_MIN_MTU = 0x32
IFLA_MAX_MTU = 0x33
- IFLA_MAX = 0x36
+ IFLA_PROP_LIST = 0x34
+ IFLA_ALT_IFNAME = 0x35
+ IFLA_PERM_ADDRESS = 0x36
+ IFLA_PROTO_DOWN_REASON = 0x37
+ IFLA_MAX = 0x37
IFLA_INFO_KIND = 0x1
IFLA_INFO_DATA = 0x2
IFLA_INFO_XSTATS = 0x3
@@ -823,8 +827,6 @@
_ [28]uint8
}
-const PERF_IOC_FLAG_GROUP = 0x1
-
type Winsize struct {
Row uint16
Col uint16
@@ -948,7 +950,10 @@
Time_offset uint64
Time_zero uint64
Size uint32
- _ [948]uint8
+ _ uint32
+ Time_cycles uint64
+ Time_mask uint64
+ _ [928]uint8
Data_head uint64
Data_tail uint64
Data_offset uint64
@@ -990,13 +995,13 @@
)
const (
- PERF_TYPE_HARDWARE = 0x0
- PERF_TYPE_SOFTWARE = 0x1
- PERF_TYPE_TRACEPOINT = 0x2
- PERF_TYPE_HW_CACHE = 0x3
- PERF_TYPE_RAW = 0x4
- PERF_TYPE_BREAKPOINT = 0x5
-
+ PERF_TYPE_HARDWARE = 0x0
+ PERF_TYPE_SOFTWARE = 0x1
+ PERF_TYPE_TRACEPOINT = 0x2
+ PERF_TYPE_HW_CACHE = 0x3
+ PERF_TYPE_RAW = 0x4
+ PERF_TYPE_BREAKPOINT = 0x5
+ PERF_TYPE_MAX = 0x6
PERF_COUNT_HW_CPU_CYCLES = 0x0
PERF_COUNT_HW_INSTRUCTIONS = 0x1
PERF_COUNT_HW_CACHE_REFERENCES = 0x2
@@ -1007,106 +1012,163 @@
PERF_COUNT_HW_STALLED_CYCLES_FRONTEND = 0x7
PERF_COUNT_HW_STALLED_CYCLES_BACKEND = 0x8
PERF_COUNT_HW_REF_CPU_CYCLES = 0x9
-
- PERF_COUNT_HW_CACHE_L1D = 0x0
- PERF_COUNT_HW_CACHE_L1I = 0x1
- PERF_COUNT_HW_CACHE_LL = 0x2
- PERF_COUNT_HW_CACHE_DTLB = 0x3
- PERF_COUNT_HW_CACHE_ITLB = 0x4
- PERF_COUNT_HW_CACHE_BPU = 0x5
- PERF_COUNT_HW_CACHE_NODE = 0x6
-
- PERF_COUNT_HW_CACHE_OP_READ = 0x0
- PERF_COUNT_HW_CACHE_OP_WRITE = 0x1
- PERF_COUNT_HW_CACHE_OP_PREFETCH = 0x2
-
- PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0x0
- PERF_COUNT_HW_CACHE_RESULT_MISS = 0x1
-
- PERF_COUNT_SW_CPU_CLOCK = 0x0
- PERF_COUNT_SW_TASK_CLOCK = 0x1
- PERF_COUNT_SW_PAGE_FAULTS = 0x2
- PERF_COUNT_SW_CONTEXT_SWITCHES = 0x3
- PERF_COUNT_SW_CPU_MIGRATIONS = 0x4
- PERF_COUNT_SW_PAGE_FAULTS_MIN = 0x5
- PERF_COUNT_SW_PAGE_FAULTS_MAJ = 0x6
- PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
- PERF_COUNT_SW_EMULATION_FAULTS = 0x8
- PERF_COUNT_SW_DUMMY = 0x9
- PERF_COUNT_SW_BPF_OUTPUT = 0xa
-
- PERF_SAMPLE_IP = 0x1
- PERF_SAMPLE_TID = 0x2
- PERF_SAMPLE_TIME = 0x4
- PERF_SAMPLE_ADDR = 0x8
- PERF_SAMPLE_READ = 0x10
- PERF_SAMPLE_CALLCHAIN = 0x20
- PERF_SAMPLE_ID = 0x40
- PERF_SAMPLE_CPU = 0x80
- PERF_SAMPLE_PERIOD = 0x100
- PERF_SAMPLE_STREAM_ID = 0x200
- PERF_SAMPLE_RAW = 0x400
- PERF_SAMPLE_BRANCH_STACK = 0x800
- PERF_SAMPLE_REGS_USER = 0x1000
- PERF_SAMPLE_STACK_USER = 0x2000
- PERF_SAMPLE_WEIGHT = 0x4000
- PERF_SAMPLE_DATA_SRC = 0x8000
- PERF_SAMPLE_IDENTIFIER = 0x10000
- PERF_SAMPLE_TRANSACTION = 0x20000
- PERF_SAMPLE_REGS_INTR = 0x40000
-
- PERF_SAMPLE_BRANCH_USER = 0x1
- PERF_SAMPLE_BRANCH_KERNEL = 0x2
- PERF_SAMPLE_BRANCH_HV = 0x4
- PERF_SAMPLE_BRANCH_ANY = 0x8
- PERF_SAMPLE_BRANCH_ANY_CALL = 0x10
- PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
- PERF_SAMPLE_BRANCH_IND_CALL = 0x40
- PERF_SAMPLE_BRANCH_ABORT_TX = 0x80
- PERF_SAMPLE_BRANCH_IN_TX = 0x100
- PERF_SAMPLE_BRANCH_NO_TX = 0x200
- PERF_SAMPLE_BRANCH_COND = 0x400
- PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
- PERF_SAMPLE_BRANCH_IND_JUMP = 0x1000
- PERF_SAMPLE_BRANCH_CALL = 0x2000
- PERF_SAMPLE_BRANCH_NO_FLAGS = 0x4000
- PERF_SAMPLE_BRANCH_NO_CYCLES = 0x8000
- PERF_SAMPLE_BRANCH_TYPE_SAVE = 0x10000
-
- PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
- PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
- PERF_FORMAT_ID = 0x4
- PERF_FORMAT_GROUP = 0x8
-
- PERF_RECORD_MMAP = 0x1
- PERF_RECORD_LOST = 0x2
- PERF_RECORD_COMM = 0x3
- PERF_RECORD_EXIT = 0x4
- PERF_RECORD_THROTTLE = 0x5
- PERF_RECORD_UNTHROTTLE = 0x6
- PERF_RECORD_FORK = 0x7
- PERF_RECORD_READ = 0x8
- PERF_RECORD_SAMPLE = 0x9
- PERF_RECORD_MMAP2 = 0xa
- PERF_RECORD_AUX = 0xb
- PERF_RECORD_ITRACE_START = 0xc
- PERF_RECORD_LOST_SAMPLES = 0xd
- PERF_RECORD_SWITCH = 0xe
- PERF_RECORD_SWITCH_CPU_WIDE = 0xf
- PERF_RECORD_NAMESPACES = 0x10
-
- PERF_CONTEXT_HV = -0x20
- PERF_CONTEXT_KERNEL = -0x80
- PERF_CONTEXT_USER = -0x200
-
- PERF_CONTEXT_GUEST = -0x800
- PERF_CONTEXT_GUEST_KERNEL = -0x880
- PERF_CONTEXT_GUEST_USER = -0xa00
-
- PERF_FLAG_FD_NO_GROUP = 0x1
- PERF_FLAG_FD_OUTPUT = 0x2
- PERF_FLAG_PID_CGROUP = 0x4
- PERF_FLAG_FD_CLOEXEC = 0x8
+ PERF_COUNT_HW_MAX = 0xa
+ PERF_COUNT_HW_CACHE_L1D = 0x0
+ PERF_COUNT_HW_CACHE_L1I = 0x1
+ PERF_COUNT_HW_CACHE_LL = 0x2
+ PERF_COUNT_HW_CACHE_DTLB = 0x3
+ PERF_COUNT_HW_CACHE_ITLB = 0x4
+ PERF_COUNT_HW_CACHE_BPU = 0x5
+ PERF_COUNT_HW_CACHE_NODE = 0x6
+ PERF_COUNT_HW_CACHE_MAX = 0x7
+ PERF_COUNT_HW_CACHE_OP_READ = 0x0
+ PERF_COUNT_HW_CACHE_OP_WRITE = 0x1
+ PERF_COUNT_HW_CACHE_OP_PREFETCH = 0x2
+ PERF_COUNT_HW_CACHE_OP_MAX = 0x3
+ PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0x0
+ PERF_COUNT_HW_CACHE_RESULT_MISS = 0x1
+ PERF_COUNT_HW_CACHE_RESULT_MAX = 0x2
+ PERF_COUNT_SW_CPU_CLOCK = 0x0
+ PERF_COUNT_SW_TASK_CLOCK = 0x1
+ PERF_COUNT_SW_PAGE_FAULTS = 0x2
+ PERF_COUNT_SW_CONTEXT_SWITCHES = 0x3
+ PERF_COUNT_SW_CPU_MIGRATIONS = 0x4
+ PERF_COUNT_SW_PAGE_FAULTS_MIN = 0x5
+ PERF_COUNT_SW_PAGE_FAULTS_MAJ = 0x6
+ PERF_COUNT_SW_ALIGNMENT_FAULTS = 0x7
+ PERF_COUNT_SW_EMULATION_FAULTS = 0x8
+ PERF_COUNT_SW_DUMMY = 0x9
+ PERF_COUNT_SW_BPF_OUTPUT = 0xa
+ PERF_COUNT_SW_MAX = 0xb
+ PERF_SAMPLE_IP = 0x1
+ PERF_SAMPLE_TID = 0x2
+ PERF_SAMPLE_TIME = 0x4
+ PERF_SAMPLE_ADDR = 0x8
+ PERF_SAMPLE_READ = 0x10
+ PERF_SAMPLE_CALLCHAIN = 0x20
+ PERF_SAMPLE_ID = 0x40
+ PERF_SAMPLE_CPU = 0x80
+ PERF_SAMPLE_PERIOD = 0x100
+ PERF_SAMPLE_STREAM_ID = 0x200
+ PERF_SAMPLE_RAW = 0x400
+ PERF_SAMPLE_BRANCH_STACK = 0x800
+ PERF_SAMPLE_REGS_USER = 0x1000
+ PERF_SAMPLE_STACK_USER = 0x2000
+ PERF_SAMPLE_WEIGHT = 0x4000
+ PERF_SAMPLE_DATA_SRC = 0x8000
+ PERF_SAMPLE_IDENTIFIER = 0x10000
+ PERF_SAMPLE_TRANSACTION = 0x20000
+ PERF_SAMPLE_REGS_INTR = 0x40000
+ PERF_SAMPLE_PHYS_ADDR = 0x80000
+ PERF_SAMPLE_AUX = 0x100000
+ PERF_SAMPLE_CGROUP = 0x200000
+ PERF_SAMPLE_MAX = 0x400000
+ PERF_SAMPLE_BRANCH_USER_SHIFT = 0x0
+ PERF_SAMPLE_BRANCH_KERNEL_SHIFT = 0x1
+ PERF_SAMPLE_BRANCH_HV_SHIFT = 0x2
+ PERF_SAMPLE_BRANCH_ANY_SHIFT = 0x3
+ PERF_SAMPLE_BRANCH_ANY_CALL_SHIFT = 0x4
+ PERF_SAMPLE_BRANCH_ANY_RETURN_SHIFT = 0x5
+ PERF_SAMPLE_BRANCH_IND_CALL_SHIFT = 0x6
+ PERF_SAMPLE_BRANCH_ABORT_TX_SHIFT = 0x7
+ PERF_SAMPLE_BRANCH_IN_TX_SHIFT = 0x8
+ PERF_SAMPLE_BRANCH_NO_TX_SHIFT = 0x9
+ PERF_SAMPLE_BRANCH_COND_SHIFT = 0xa
+ PERF_SAMPLE_BRANCH_CALL_STACK_SHIFT = 0xb
+ PERF_SAMPLE_BRANCH_IND_JUMP_SHIFT = 0xc
+ PERF_SAMPLE_BRANCH_CALL_SHIFT = 0xd
+ PERF_SAMPLE_BRANCH_NO_FLAGS_SHIFT = 0xe
+ PERF_SAMPLE_BRANCH_NO_CYCLES_SHIFT = 0xf
+ PERF_SAMPLE_BRANCH_TYPE_SAVE_SHIFT = 0x10
+ PERF_SAMPLE_BRANCH_HW_INDEX_SHIFT = 0x11
+ PERF_SAMPLE_BRANCH_MAX_SHIFT = 0x12
+ PERF_SAMPLE_BRANCH_USER = 0x1
+ PERF_SAMPLE_BRANCH_KERNEL = 0x2
+ PERF_SAMPLE_BRANCH_HV = 0x4
+ PERF_SAMPLE_BRANCH_ANY = 0x8
+ PERF_SAMPLE_BRANCH_ANY_CALL = 0x10
+ PERF_SAMPLE_BRANCH_ANY_RETURN = 0x20
+ PERF_SAMPLE_BRANCH_IND_CALL = 0x40
+ PERF_SAMPLE_BRANCH_ABORT_TX = 0x80
+ PERF_SAMPLE_BRANCH_IN_TX = 0x100
+ PERF_SAMPLE_BRANCH_NO_TX = 0x200
+ PERF_SAMPLE_BRANCH_COND = 0x400
+ PERF_SAMPLE_BRANCH_CALL_STACK = 0x800
+ PERF_SAMPLE_BRANCH_IND_JUMP = 0x1000
+ PERF_SAMPLE_BRANCH_CALL = 0x2000
+ PERF_SAMPLE_BRANCH_NO_FLAGS = 0x4000
+ PERF_SAMPLE_BRANCH_NO_CYCLES = 0x8000
+ PERF_SAMPLE_BRANCH_TYPE_SAVE = 0x10000
+ PERF_SAMPLE_BRANCH_HW_INDEX = 0x20000
+ PERF_SAMPLE_BRANCH_MAX = 0x40000
+ PERF_BR_UNKNOWN = 0x0
+ PERF_BR_COND = 0x1
+ PERF_BR_UNCOND = 0x2
+ PERF_BR_IND = 0x3
+ PERF_BR_CALL = 0x4
+ PERF_BR_IND_CALL = 0x5
+ PERF_BR_RET = 0x6
+ PERF_BR_SYSCALL = 0x7
+ PERF_BR_SYSRET = 0x8
+ PERF_BR_COND_CALL = 0x9
+ PERF_BR_COND_RET = 0xa
+ PERF_BR_MAX = 0xb
+ PERF_SAMPLE_REGS_ABI_NONE = 0x0
+ PERF_SAMPLE_REGS_ABI_32 = 0x1
+ PERF_SAMPLE_REGS_ABI_64 = 0x2
+ PERF_TXN_ELISION = 0x1
+ PERF_TXN_TRANSACTION = 0x2
+ PERF_TXN_SYNC = 0x4
+ PERF_TXN_ASYNC = 0x8
+ PERF_TXN_RETRY = 0x10
+ PERF_TXN_CONFLICT = 0x20
+ PERF_TXN_CAPACITY_WRITE = 0x40
+ PERF_TXN_CAPACITY_READ = 0x80
+ PERF_TXN_MAX = 0x100
+ PERF_TXN_ABORT_MASK = -0x100000000
+ PERF_TXN_ABORT_SHIFT = 0x20
+ PERF_FORMAT_TOTAL_TIME_ENABLED = 0x1
+ PERF_FORMAT_TOTAL_TIME_RUNNING = 0x2
+ PERF_FORMAT_ID = 0x4
+ PERF_FORMAT_GROUP = 0x8
+ PERF_FORMAT_MAX = 0x10
+ PERF_IOC_FLAG_GROUP = 0x1
+ PERF_RECORD_MMAP = 0x1
+ PERF_RECORD_LOST = 0x2
+ PERF_RECORD_COMM = 0x3
+ PERF_RECORD_EXIT = 0x4
+ PERF_RECORD_THROTTLE = 0x5
+ PERF_RECORD_UNTHROTTLE = 0x6
+ PERF_RECORD_FORK = 0x7
+ PERF_RECORD_READ = 0x8
+ PERF_RECORD_SAMPLE = 0x9
+ PERF_RECORD_MMAP2 = 0xa
+ PERF_RECORD_AUX = 0xb
+ PERF_RECORD_ITRACE_START = 0xc
+ PERF_RECORD_LOST_SAMPLES = 0xd
+ PERF_RECORD_SWITCH = 0xe
+ PERF_RECORD_SWITCH_CPU_WIDE = 0xf
+ PERF_RECORD_NAMESPACES = 0x10
+ PERF_RECORD_KSYMBOL = 0x11
+ PERF_RECORD_BPF_EVENT = 0x12
+ PERF_RECORD_CGROUP = 0x13
+ PERF_RECORD_TEXT_POKE = 0x14
+ PERF_RECORD_MAX = 0x15
+ PERF_RECORD_KSYMBOL_TYPE_UNKNOWN = 0x0
+ PERF_RECORD_KSYMBOL_TYPE_BPF = 0x1
+ PERF_RECORD_KSYMBOL_TYPE_OOL = 0x2
+ PERF_RECORD_KSYMBOL_TYPE_MAX = 0x3
+ PERF_BPF_EVENT_UNKNOWN = 0x0
+ PERF_BPF_EVENT_PROG_LOAD = 0x1
+ PERF_BPF_EVENT_PROG_UNLOAD = 0x2
+ PERF_BPF_EVENT_MAX = 0x3
+ PERF_CONTEXT_HV = -0x20
+ PERF_CONTEXT_KERNEL = -0x80
+ PERF_CONTEXT_USER = -0x200
+ PERF_CONTEXT_GUEST = -0x800
+ PERF_CONTEXT_GUEST_KERNEL = -0x880
+ PERF_CONTEXT_GUEST_USER = -0xa00
+ PERF_CONTEXT_MAX = -0xfff
)
type TCPMD5Sig struct {
@@ -1412,7 +1474,7 @@
NFT_MSG_DELOBJ = 0x14
NFT_MSG_GETOBJ_RESET = 0x15
NFT_MSG_MAX = 0x19
- NFTA_LIST_UNPEC = 0x0
+ NFTA_LIST_UNSPEC = 0x0
NFTA_LIST_ELEM = 0x1
NFTA_HOOK_UNSPEC = 0x0
NFTA_HOOK_HOOKNUM = 0x1
@@ -1851,9 +1913,12 @@
}
type XDPStatistics struct {
- Rx_dropped uint64
- Rx_invalid_descs uint64
- Tx_invalid_descs uint64
+ Rx_dropped uint64
+ Rx_invalid_descs uint64
+ Tx_invalid_descs uint64
+ Rx_ring_full uint64
+ Rx_fill_ring_empty_descs uint64
+ Tx_ring_empty_descs uint64
}
type XDPDesc struct {
@@ -2500,7 +2565,7 @@
DEVLINK_ATTR_DPIPE_FIELD_MAPPING_TYPE = 0x3c
DEVLINK_ATTR_PAD = 0x3d
DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 0x3e
- DEVLINK_ATTR_MAX = 0x90
+ DEVLINK_ATTR_MAX = 0x94
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_NONE = 0x0
DEVLINK_DPIPE_FIELD_MAPPING_TYPE_IFINDEX = 0x1
DEVLINK_DPIPE_MATCH_TYPE_FIELD_EXACT = 0x0
@@ -2567,3 +2632,9 @@
CAN_RAW_FD_FRAMES = 0x5
CAN_RAW_JOIN_FILTERS = 0x6
)
+
+type WatchdogInfo struct {
+ Options uint32
+ Version uint32
+ Identity [32]uint8
+}
diff --git a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go
index 23ed9fe..db817f3 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_solaris_amd64.go
@@ -88,7 +88,6 @@
Mtim Timespec
Ctim Timespec
Blksize int32
- _ [4]byte
Blocks int64
Fstype [16]int8
}
@@ -96,7 +95,6 @@
type Flock_t struct {
Type int16
Whence int16
- _ [4]byte
Start int64
Len int64
Sysid int32
@@ -138,12 +136,12 @@
}
type RawSockaddrInet6 struct {
- Family uint16
- Port uint16
- Flowinfo uint32
- Addr [16]byte /* in6_addr */
- Scope_id uint32
- X__sin6_src_id uint32
+ Family uint16
+ Port uint16
+ Flowinfo uint32
+ Addr [16]byte /* in6_addr */
+ Scope_id uint32
+ _ uint32
}
type RawSockaddrUnix struct {
@@ -196,10 +194,8 @@
type Msghdr struct {
Name *byte
Namelen uint32
- _ [4]byte
Iov *Iovec
Iovlen int32
- _ [4]byte
Accrights *int8
Accrightslen int32
_ [4]byte
@@ -228,7 +224,7 @@
}
type ICMPv6Filter struct {
- X__icmp6_filt [8]uint32
+ Filt [8]uint32
}
const (
@@ -291,7 +287,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Data IfData
}
@@ -299,7 +294,6 @@
Type uint8
Addrlen uint8
Hdrlen uint8
- _ [1]byte
Mtu uint32
Metric uint32
Baudrate uint32
@@ -324,7 +318,6 @@
Addrs int32
Flags int32
Index uint16
- _ [2]byte
Metric int32
}
@@ -333,7 +326,6 @@
Version uint8
Type uint8
Index uint16
- _ [2]byte
Flags int32
Addrs int32
Pid int32
@@ -371,15 +363,14 @@
}
type BpfStat struct {
- Recv uint64
- Drop uint64
- Capt uint64
- Padding [13]uint64
+ Recv uint64
+ Drop uint64
+ Capt uint64
+ _ [13]uint64
}
type BpfProgram struct {
Len uint32
- _ [4]byte
Insns *BpfInsn
}
diff --git a/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go
index 3778075..5b02df2 100644
--- a/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go
+++ b/vendor/golang.org/x/sys/windows/registry/zsyscall_windows.go
@@ -26,7 +26,7 @@
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
- return nil
+ return syscall.EINVAL
case errnoERROR_IO_PENDING:
return errERROR_IO_PENDING
}
@@ -40,16 +40,24 @@
modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
+ procRegConnectRegistryW = modadvapi32.NewProc("RegConnectRegistryW")
procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW")
procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW")
- procRegSetValueExW = modadvapi32.NewProc("RegSetValueExW")
- procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW")
procRegDeleteValueW = modadvapi32.NewProc("RegDeleteValueW")
+ procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW")
procRegLoadMUIStringW = modadvapi32.NewProc("RegLoadMUIStringW")
- procRegConnectRegistryW = modadvapi32.NewProc("RegConnectRegistryW")
+ procRegSetValueExW = modadvapi32.NewProc("RegSetValueExW")
procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW")
)
+func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) {
+ r0, _, _ := syscall.Syscall(procRegConnectRegistryW.Addr(), 3, uintptr(unsafe.Pointer(machinename)), uintptr(key), uintptr(unsafe.Pointer(result)))
+ if r0 != 0 {
+ regerrno = syscall.Errno(r0)
+ }
+ return
+}
+
func regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) {
r0, _, _ := syscall.Syscall9(procRegCreateKeyExW.Addr(), 9, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(reserved), uintptr(unsafe.Pointer(class)), uintptr(options), uintptr(desired), uintptr(unsafe.Pointer(sa)), uintptr(unsafe.Pointer(result)), uintptr(unsafe.Pointer(disposition)))
if r0 != 0 {
@@ -66,8 +74,8 @@
return
}
-func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) {
- r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize))
+func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) {
+ r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0)
if r0 != 0 {
regerrno = syscall.Errno(r0)
}
@@ -82,14 +90,6 @@
return
}
-func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) {
- r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0)
- if r0 != 0 {
- regerrno = syscall.Errno(r0)
- }
- return
-}
-
func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) {
r0, _, _ := syscall.Syscall9(procRegLoadMUIStringW.Addr(), 7, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(unsafe.Pointer(buflenCopied)), uintptr(flags), uintptr(unsafe.Pointer(dir)), 0, 0)
if r0 != 0 {
@@ -98,8 +98,8 @@
return
}
-func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) {
- r0, _, _ := syscall.Syscall(procRegConnectRegistryW.Addr(), 3, uintptr(unsafe.Pointer(machinename)), uintptr(key), uintptr(unsafe.Pointer(result)))
+func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) {
+ r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize))
if r0 != 0 {
regerrno = syscall.Errno(r0)
}
@@ -110,11 +110,7 @@
r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size))
n = uint32(r0)
if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
diff --git a/vendor/golang.org/x/sys/windows/svc/security.go b/vendor/golang.org/x/sys/windows/svc/security.go
index 6502599..da6df1d 100644
--- a/vendor/golang.org/x/sys/windows/svc/security.go
+++ b/vendor/golang.org/x/sys/windows/svc/security.go
@@ -7,6 +7,10 @@
package svc
import (
+ "errors"
+ "syscall"
+ "unsafe"
+
"golang.org/x/sys/windows"
)
@@ -23,6 +27,8 @@
// IsAnInteractiveSession determines if calling process is running interactively.
// It queries the process token for membership in the Interactive group.
// http://stackoverflow.com/questions/2668851/how-do-i-detect-that-my-application-is-running-as-service-or-in-an-interactive-s
+//
+// Deprecated: Use IsWindowsService instead.
func IsAnInteractiveSession() (bool, error) {
interSid, err := allocSid(windows.SECURITY_INTERACTIVE_RID)
if err != nil {
@@ -57,3 +63,95 @@
}
return false, nil
}
+
+var (
+ ntdll = windows.NewLazySystemDLL("ntdll.dll")
+ _NtQueryInformationProcess = ntdll.NewProc("NtQueryInformationProcess")
+
+ kernel32 = windows.NewLazySystemDLL("kernel32.dll")
+ _QueryFullProcessImageNameA = kernel32.NewProc("QueryFullProcessImageNameA")
+)
+
+// IsWindowsService reports whether the process is currently executing
+// as a Windows service.
+func IsWindowsService() (bool, error) {
+ // This code was copied from runtime.isWindowsService function.
+
+ // The below technique looks a bit hairy, but it's actually
+ // exactly what the .NET framework does for the similarly named function:
+ // https://github.com/dotnet/extensions/blob/f4066026ca06984b07e90e61a6390ac38152ba93/src/Hosting/WindowsServices/src/WindowsServiceHelpers.cs#L26-L31
+ // Specifically, it looks up whether the parent process has session ID zero
+ // and is called "services".
+ const _CURRENT_PROCESS = ^uintptr(0)
+ // pbi is a PROCESS_BASIC_INFORMATION struct, where we just care about
+ // the 6th pointer inside of it, which contains the pid of the process
+ // parent:
+ // https://github.com/wine-mirror/wine/blob/42cb7d2ad1caba08de235e6319b9967296b5d554/include/winternl.h#L1294
+ var pbi [6]uintptr
+ var pbiLen uint32
+ r0, _, _ := syscall.Syscall6(_NtQueryInformationProcess.Addr(), 5, _CURRENT_PROCESS, 0, uintptr(unsafe.Pointer(&pbi[0])), uintptr(unsafe.Sizeof(pbi)), uintptr(unsafe.Pointer(&pbiLen)), 0)
+ if r0 != 0 {
+ return false, errors.New("NtQueryInformationProcess failed: error=" + itoa(int(r0)))
+ }
+ var psid uint32
+ err := windows.ProcessIdToSessionId(uint32(pbi[5]), &psid)
+ if err != nil {
+ return false, err
+ }
+ if psid != 0 {
+ // parent session id should be 0 for service process
+ return false, nil
+ }
+
+ pproc, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pbi[5]))
+ if err != nil {
+ return false, err
+ }
+ defer windows.CloseHandle(pproc)
+
+ // exeName gets the path to the executable image of the parent process
+ var exeName [261]byte
+ exeNameLen := uint32(len(exeName) - 1)
+ r0, _, e0 := syscall.Syscall6(_QueryFullProcessImageNameA.Addr(), 4, uintptr(pproc), 0, uintptr(unsafe.Pointer(&exeName[0])), uintptr(unsafe.Pointer(&exeNameLen)), 0, 0)
+ if r0 == 0 {
+ if e0 != 0 {
+ return false, e0
+ } else {
+ return false, syscall.EINVAL
+ }
+ }
+ const (
+ servicesLower = "services.exe"
+ servicesUpper = "SERVICES.EXE"
+ )
+ i := int(exeNameLen) - 1
+ j := len(servicesLower) - 1
+ if i < j {
+ return false, nil
+ }
+ for {
+ if j == -1 {
+ return i == -1 || exeName[i] == '\\', nil
+ }
+ if exeName[i] != servicesLower[j] && exeName[i] != servicesUpper[j] {
+ return false, nil
+ }
+ i--
+ j--
+ }
+}
+
+func itoa(val int) string { // do it here rather than with fmt to avoid dependency
+ if val < 0 {
+ return "-" + itoa(-val)
+ }
+ var buf [32]byte // big enough for int64
+ i := len(buf) - 1
+ for val >= 10 {
+ buf[i] = byte(val%10 + '0')
+ i--
+ val /= 10
+ }
+ buf[i] = byte(val + '0')
+ return string(buf[i:])
+}
diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go
index 2aa29e8..bbd075d 100644
--- a/vendor/golang.org/x/sys/windows/syscall_windows.go
+++ b/vendor/golang.org/x/sys/windows/syscall_windows.go
@@ -270,9 +270,11 @@
//sys RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) = advapi32.RegEnumKeyExW
//sys RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) = advapi32.RegQueryValueExW
//sys GetCurrentProcessId() (pid uint32) = kernel32.GetCurrentProcessId
+//sys ProcessIdToSessionId(pid uint32, sessionid *uint32) (err error) = kernel32.ProcessIdToSessionId
//sys GetConsoleMode(console Handle, mode *uint32) (err error) = kernel32.GetConsoleMode
//sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode
//sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo
+//sys SetConsoleCursorPosition(console Handle, position Coord) (err error) = kernel32.SetConsoleCursorPosition
//sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW
//sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW
//sys CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) [failretval==InvalidHandle] = kernel32.CreateToolhelp32Snapshot
@@ -388,11 +390,7 @@
r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), ordinal, 0)
proc = uintptr(r0)
if proc == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
@@ -1089,11 +1087,7 @@
}
r1, _, e1 := syscall.Syscall6(sendRecvMsgFunc.sendAddr, 6, uintptr(fd), uintptr(unsafe.Pointer(msg)), uintptr(flags), uintptr(unsafe.Pointer(bytesSent)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return err
}
@@ -1105,11 +1099,7 @@
}
r1, _, e1 := syscall.Syscall6(sendRecvMsgFunc.recvAddr, 5, uintptr(fd), uintptr(unsafe.Pointer(msg)), uintptr(unsafe.Pointer(bytesReceived)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0)
if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return err
}
diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go
index 347f13d..a25f096 100644
--- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go
+++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go
@@ -24,7 +24,7 @@
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
- return nil
+ return syscall.EINVAL
case errnoERROR_IO_PENDING:
return errERROR_IO_PENDING
}
@@ -36,375 +36,391 @@
var (
modadvapi32 = NewLazySystemDLL("advapi32.dll")
- modkernel32 = NewLazySystemDLL("kernel32.dll")
- modshell32 = NewLazySystemDLL("shell32.dll")
- moduserenv = NewLazySystemDLL("userenv.dll")
- modmswsock = NewLazySystemDLL("mswsock.dll")
modcrypt32 = NewLazySystemDLL("crypt32.dll")
- moduser32 = NewLazySystemDLL("user32.dll")
- modole32 = NewLazySystemDLL("ole32.dll")
- modntdll = NewLazySystemDLL("ntdll.dll")
- modpsapi = NewLazySystemDLL("psapi.dll")
- modws2_32 = NewLazySystemDLL("ws2_32.dll")
moddnsapi = NewLazySystemDLL("dnsapi.dll")
modiphlpapi = NewLazySystemDLL("iphlpapi.dll")
- modsecur32 = NewLazySystemDLL("secur32.dll")
+ modkernel32 = NewLazySystemDLL("kernel32.dll")
+ modmswsock = NewLazySystemDLL("mswsock.dll")
modnetapi32 = NewLazySystemDLL("netapi32.dll")
+ modntdll = NewLazySystemDLL("ntdll.dll")
+ modole32 = NewLazySystemDLL("ole32.dll")
+ modpsapi = NewLazySystemDLL("psapi.dll")
+ modsecur32 = NewLazySystemDLL("secur32.dll")
+ modshell32 = NewLazySystemDLL("shell32.dll")
+ moduser32 = NewLazySystemDLL("user32.dll")
+ moduserenv = NewLazySystemDLL("userenv.dll")
+ modws2_32 = NewLazySystemDLL("ws2_32.dll")
modwtsapi32 = NewLazySystemDLL("wtsapi32.dll")
- procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
- procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
- procReportEventW = modadvapi32.NewProc("ReportEventW")
- procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
- procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
- procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
- procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
- procDeleteService = modadvapi32.NewProc("DeleteService")
- procStartServiceW = modadvapi32.NewProc("StartServiceW")
- procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
- procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW")
- procControlService = modadvapi32.NewProc("ControlService")
- procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
- procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
- procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
- procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
+ procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups")
+ procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
+ procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
+ procBuildSecurityDescriptorW = modadvapi32.NewProc("BuildSecurityDescriptorW")
procChangeServiceConfig2W = modadvapi32.NewProc("ChangeServiceConfig2W")
- procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
- procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
- procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
- procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW")
- procGetLastError = modkernel32.NewProc("GetLastError")
- procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
- procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
- procFreeLibrary = modkernel32.NewProc("FreeLibrary")
- procGetProcAddress = modkernel32.NewProc("GetProcAddress")
- procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
- procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
- procGetVersion = modkernel32.NewProc("GetVersion")
- procFormatMessageW = modkernel32.NewProc("FormatMessageW")
- procExitProcess = modkernel32.NewProc("ExitProcess")
- procIsWow64Process = modkernel32.NewProc("IsWow64Process")
- procCreateFileW = modkernel32.NewProc("CreateFileW")
- procReadFile = modkernel32.NewProc("ReadFile")
- procWriteFile = modkernel32.NewProc("WriteFile")
- procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
- procSetFilePointer = modkernel32.NewProc("SetFilePointer")
- procCloseHandle = modkernel32.NewProc("CloseHandle")
- procGetStdHandle = modkernel32.NewProc("GetStdHandle")
- procSetStdHandle = modkernel32.NewProc("SetStdHandle")
- procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
- procFindNextFileW = modkernel32.NewProc("FindNextFileW")
- procFindClose = modkernel32.NewProc("FindClose")
- procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
- procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
- procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
- procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
- procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
- procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
- procDeleteFileW = modkernel32.NewProc("DeleteFileW")
- procMoveFileW = modkernel32.NewProc("MoveFileW")
- procMoveFileExW = modkernel32.NewProc("MoveFileExW")
- procLockFileEx = modkernel32.NewProc("LockFileEx")
- procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
- procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
- procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
- procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
- procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
- procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
- procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
- procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
- procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
- procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
- procCancelIo = modkernel32.NewProc("CancelIo")
- procCancelIoEx = modkernel32.NewProc("CancelIoEx")
- procCreateProcessW = modkernel32.NewProc("CreateProcessW")
- procOpenProcess = modkernel32.NewProc("OpenProcess")
- procShellExecuteW = modshell32.NewProc("ShellExecuteW")
- procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
- procTerminateProcess = modkernel32.NewProc("TerminateProcess")
- procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
- procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
- procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
- procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
- procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
- procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
- procGetTempPathW = modkernel32.NewProc("GetTempPathW")
- procCreatePipe = modkernel32.NewProc("CreatePipe")
- procGetFileType = modkernel32.NewProc("GetFileType")
+ procChangeServiceConfigW = modadvapi32.NewProc("ChangeServiceConfigW")
+ procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
+ procCloseServiceHandle = modadvapi32.NewProc("CloseServiceHandle")
+ procControlService = modadvapi32.NewProc("ControlService")
+ procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
+ procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
+ procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
+ procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
+ procCopySid = modadvapi32.NewProc("CopySid")
+ procCreateServiceW = modadvapi32.NewProc("CreateServiceW")
+ procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
procCryptAcquireContextW = modadvapi32.NewProc("CryptAcquireContextW")
- procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
procCryptGenRandom = modadvapi32.NewProc("CryptGenRandom")
- procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
- procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
- procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
- procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
- procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
- procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
- procGetTickCount64 = modkernel32.NewProc("GetTickCount64")
- procSetFileTime = modkernel32.NewProc("SetFileTime")
- procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
- procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
- procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
- procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
- procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
- procLocalFree = modkernel32.NewProc("LocalFree")
- procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
- procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
- procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
- procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
- procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
- procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
- procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
- procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
- procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
- procVirtualLock = modkernel32.NewProc("VirtualLock")
- procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
- procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
- procVirtualFree = modkernel32.NewProc("VirtualFree")
- procVirtualProtect = modkernel32.NewProc("VirtualProtect")
- procTransmitFile = modmswsock.NewProc("TransmitFile")
- procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
- procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
- procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
- procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
+ procCryptReleaseContext = modadvapi32.NewProc("CryptReleaseContext")
+ procDeleteService = modadvapi32.NewProc("DeleteService")
+ procDeregisterEventSource = modadvapi32.NewProc("DeregisterEventSource")
+ procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
+ procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW")
+ procEqualSid = modadvapi32.NewProc("EqualSid")
+ procFreeSid = modadvapi32.NewProc("FreeSid")
+ procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
+ procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW")
+ procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl")
+ procGetSecurityDescriptorDacl = modadvapi32.NewProc("GetSecurityDescriptorDacl")
+ procGetSecurityDescriptorGroup = modadvapi32.NewProc("GetSecurityDescriptorGroup")
+ procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength")
+ procGetSecurityDescriptorOwner = modadvapi32.NewProc("GetSecurityDescriptorOwner")
+ procGetSecurityDescriptorRMControl = modadvapi32.NewProc("GetSecurityDescriptorRMControl")
+ procGetSecurityDescriptorSacl = modadvapi32.NewProc("GetSecurityDescriptorSacl")
+ procGetSecurityInfo = modadvapi32.NewProc("GetSecurityInfo")
+ procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority")
+ procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority")
+ procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount")
+ procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
+ procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
+ procInitializeSecurityDescriptor = modadvapi32.NewProc("InitializeSecurityDescriptor")
+ procInitiateSystemShutdownExW = modadvapi32.NewProc("InitiateSystemShutdownExW")
+ procIsValidSecurityDescriptor = modadvapi32.NewProc("IsValidSecurityDescriptor")
+ procIsValidSid = modadvapi32.NewProc("IsValidSid")
+ procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid")
+ procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
+ procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
+ procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
+ procMakeAbsoluteSD = modadvapi32.NewProc("MakeAbsoluteSD")
+ procMakeSelfRelativeSD = modadvapi32.NewProc("MakeSelfRelativeSD")
+ procNotifyServiceStatusChangeW = modadvapi32.NewProc("NotifyServiceStatusChangeW")
+ procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
+ procOpenSCManagerW = modadvapi32.NewProc("OpenSCManagerW")
+ procOpenServiceW = modadvapi32.NewProc("OpenServiceW")
+ procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
+ procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
+ procQueryServiceConfigW = modadvapi32.NewProc("QueryServiceConfigW")
+ procQueryServiceLockStatusW = modadvapi32.NewProc("QueryServiceLockStatusW")
+ procQueryServiceStatus = modadvapi32.NewProc("QueryServiceStatus")
+ procQueryServiceStatusEx = modadvapi32.NewProc("QueryServiceStatusEx")
+ procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
+ procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
+ procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
+ procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
+ procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
+ procRegisterEventSourceW = modadvapi32.NewProc("RegisterEventSourceW")
+ procReportEventW = modadvapi32.NewProc("ReportEventW")
+ procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
+ procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW")
+ procSetNamedSecurityInfoW = modadvapi32.NewProc("SetNamedSecurityInfoW")
+ procSetSecurityDescriptorControl = modadvapi32.NewProc("SetSecurityDescriptorControl")
+ procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl")
+ procSetSecurityDescriptorGroup = modadvapi32.NewProc("SetSecurityDescriptorGroup")
+ procSetSecurityDescriptorOwner = modadvapi32.NewProc("SetSecurityDescriptorOwner")
+ procSetSecurityDescriptorRMControl = modadvapi32.NewProc("SetSecurityDescriptorRMControl")
+ procSetSecurityDescriptorSacl = modadvapi32.NewProc("SetSecurityDescriptorSacl")
+ procSetSecurityInfo = modadvapi32.NewProc("SetSecurityInfo")
+ procSetServiceStatus = modadvapi32.NewProc("SetServiceStatus")
+ procSetThreadToken = modadvapi32.NewProc("SetThreadToken")
+ procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
+ procStartServiceCtrlDispatcherW = modadvapi32.NewProc("StartServiceCtrlDispatcherW")
+ procStartServiceW = modadvapi32.NewProc("StartServiceW")
procCertAddCertificateContextToStore = modcrypt32.NewProc("CertAddCertificateContextToStore")
procCertCloseStore = modcrypt32.NewProc("CertCloseStore")
- procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
- procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
procCertCreateCertificateContext = modcrypt32.NewProc("CertCreateCertificateContext")
+ procCertEnumCertificatesInStore = modcrypt32.NewProc("CertEnumCertificatesInStore")
+ procCertFreeCertificateChain = modcrypt32.NewProc("CertFreeCertificateChain")
procCertFreeCertificateContext = modcrypt32.NewProc("CertFreeCertificateContext")
+ procCertGetCertificateChain = modcrypt32.NewProc("CertGetCertificateChain")
+ procCertOpenStore = modcrypt32.NewProc("CertOpenStore")
+ procCertOpenSystemStoreW = modcrypt32.NewProc("CertOpenSystemStoreW")
procCertVerifyCertificateChainPolicy = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
- procRegOpenKeyExW = modadvapi32.NewProc("RegOpenKeyExW")
- procRegCloseKey = modadvapi32.NewProc("RegCloseKey")
- procRegQueryInfoKeyW = modadvapi32.NewProc("RegQueryInfoKeyW")
- procRegEnumKeyExW = modadvapi32.NewProc("RegEnumKeyExW")
- procRegQueryValueExW = modadvapi32.NewProc("RegQueryValueExW")
- procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
- procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
- procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
- procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
- procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
- procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
- procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
- procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
- procProcess32NextW = modkernel32.NewProc("Process32NextW")
- procThread32First = modkernel32.NewProc("Thread32First")
- procThread32Next = modkernel32.NewProc("Thread32Next")
- procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
- procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
- procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
- procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
- procCreateEventW = modkernel32.NewProc("CreateEventW")
- procCreateEventExW = modkernel32.NewProc("CreateEventExW")
- procOpenEventW = modkernel32.NewProc("OpenEventW")
- procSetEvent = modkernel32.NewProc("SetEvent")
- procResetEvent = modkernel32.NewProc("ResetEvent")
- procPulseEvent = modkernel32.NewProc("PulseEvent")
- procCreateMutexW = modkernel32.NewProc("CreateMutexW")
- procCreateMutexExW = modkernel32.NewProc("CreateMutexExW")
- procOpenMutexW = modkernel32.NewProc("OpenMutexW")
- procReleaseMutex = modkernel32.NewProc("ReleaseMutex")
- procSleepEx = modkernel32.NewProc("SleepEx")
- procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
+ procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
+ procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
+ procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
+ procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
+ procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
+ procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
- procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
- procSetErrorMode = modkernel32.NewProc("SetErrorMode")
- procResumeThread = modkernel32.NewProc("ResumeThread")
- procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
- procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
- procQueryInformationJobObject = modkernel32.NewProc("QueryInformationJobObject")
- procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
- procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
- procGetProcessId = modkernel32.NewProc("GetProcessId")
- procOpenThread = modkernel32.NewProc("OpenThread")
- procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost")
- procGetProcessWorkingSetSizeEx = modkernel32.NewProc("GetProcessWorkingSetSizeEx")
- procSetProcessWorkingSetSizeEx = modkernel32.NewProc("SetProcessWorkingSetSizeEx")
+ procCancelIo = modkernel32.NewProc("CancelIo")
+ procCancelIoEx = modkernel32.NewProc("CancelIoEx")
+ procCloseHandle = modkernel32.NewProc("CloseHandle")
+ procCreateDirectoryW = modkernel32.NewProc("CreateDirectoryW")
+ procCreateEventExW = modkernel32.NewProc("CreateEventExW")
+ procCreateEventW = modkernel32.NewProc("CreateEventW")
+ procCreateFileMappingW = modkernel32.NewProc("CreateFileMappingW")
+ procCreateFileW = modkernel32.NewProc("CreateFileW")
+ procCreateHardLinkW = modkernel32.NewProc("CreateHardLinkW")
+ procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
+ procCreateJobObjectW = modkernel32.NewProc("CreateJobObjectW")
+ procCreateMutexExW = modkernel32.NewProc("CreateMutexExW")
+ procCreateMutexW = modkernel32.NewProc("CreateMutexW")
+ procCreatePipe = modkernel32.NewProc("CreatePipe")
+ procCreateProcessW = modkernel32.NewProc("CreateProcessW")
+ procCreateSymbolicLinkW = modkernel32.NewProc("CreateSymbolicLinkW")
+ procCreateToolhelp32Snapshot = modkernel32.NewProc("CreateToolhelp32Snapshot")
procDefineDosDeviceW = modkernel32.NewProc("DefineDosDeviceW")
+ procDeleteFileW = modkernel32.NewProc("DeleteFileW")
procDeleteVolumeMountPointW = modkernel32.NewProc("DeleteVolumeMountPointW")
- procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
+ procDeviceIoControl = modkernel32.NewProc("DeviceIoControl")
+ procDuplicateHandle = modkernel32.NewProc("DuplicateHandle")
+ procExitProcess = modkernel32.NewProc("ExitProcess")
+ procFindClose = modkernel32.NewProc("FindClose")
+ procFindFirstFileW = modkernel32.NewProc("FindFirstFileW")
procFindFirstVolumeMountPointW = modkernel32.NewProc("FindFirstVolumeMountPointW")
- procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
+ procFindFirstVolumeW = modkernel32.NewProc("FindFirstVolumeW")
+ procFindNextFileW = modkernel32.NewProc("FindNextFileW")
procFindNextVolumeMountPointW = modkernel32.NewProc("FindNextVolumeMountPointW")
+ procFindNextVolumeW = modkernel32.NewProc("FindNextVolumeW")
procFindVolumeClose = modkernel32.NewProc("FindVolumeClose")
procFindVolumeMountPointClose = modkernel32.NewProc("FindVolumeMountPointClose")
+ procFlushFileBuffers = modkernel32.NewProc("FlushFileBuffers")
+ procFlushViewOfFile = modkernel32.NewProc("FlushViewOfFile")
+ procFormatMessageW = modkernel32.NewProc("FormatMessageW")
+ procFreeEnvironmentStringsW = modkernel32.NewProc("FreeEnvironmentStringsW")
+ procFreeLibrary = modkernel32.NewProc("FreeLibrary")
+ procGenerateConsoleCtrlEvent = modkernel32.NewProc("GenerateConsoleCtrlEvent")
+ procGetACP = modkernel32.NewProc("GetACP")
+ procGetCommandLineW = modkernel32.NewProc("GetCommandLineW")
+ procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
+ procGetComputerNameW = modkernel32.NewProc("GetComputerNameW")
+ procGetConsoleMode = modkernel32.NewProc("GetConsoleMode")
+ procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo")
+ procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW")
+ procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId")
+ procGetCurrentThreadId = modkernel32.NewProc("GetCurrentThreadId")
procGetDiskFreeSpaceExW = modkernel32.NewProc("GetDiskFreeSpaceExW")
procGetDriveTypeW = modkernel32.NewProc("GetDriveTypeW")
- procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
+ procGetEnvironmentStringsW = modkernel32.NewProc("GetEnvironmentStringsW")
+ procGetEnvironmentVariableW = modkernel32.NewProc("GetEnvironmentVariableW")
+ procGetExitCodeProcess = modkernel32.NewProc("GetExitCodeProcess")
+ procGetFileAttributesExW = modkernel32.NewProc("GetFileAttributesExW")
+ procGetFileAttributesW = modkernel32.NewProc("GetFileAttributesW")
+ procGetFileInformationByHandle = modkernel32.NewProc("GetFileInformationByHandle")
+ procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
+ procGetFileType = modkernel32.NewProc("GetFileType")
+ procGetFullPathNameW = modkernel32.NewProc("GetFullPathNameW")
+ procGetLastError = modkernel32.NewProc("GetLastError")
procGetLogicalDriveStringsW = modkernel32.NewProc("GetLogicalDriveStringsW")
- procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
+ procGetLogicalDrives = modkernel32.NewProc("GetLogicalDrives")
+ procGetLongPathNameW = modkernel32.NewProc("GetLongPathNameW")
+ procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
+ procGetModuleHandleExW = modkernel32.NewProc("GetModuleHandleExW")
+ procGetOverlappedResult = modkernel32.NewProc("GetOverlappedResult")
+ procGetPriorityClass = modkernel32.NewProc("GetPriorityClass")
+ procGetProcAddress = modkernel32.NewProc("GetProcAddress")
+ procGetProcessId = modkernel32.NewProc("GetProcessId")
+ procGetProcessPreferredUILanguages = modkernel32.NewProc("GetProcessPreferredUILanguages")
+ procGetProcessShutdownParameters = modkernel32.NewProc("GetProcessShutdownParameters")
+ procGetProcessTimes = modkernel32.NewProc("GetProcessTimes")
+ procGetProcessWorkingSetSizeEx = modkernel32.NewProc("GetProcessWorkingSetSizeEx")
+ procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
+ procGetShortPathNameW = modkernel32.NewProc("GetShortPathNameW")
+ procGetStartupInfoW = modkernel32.NewProc("GetStartupInfoW")
+ procGetStdHandle = modkernel32.NewProc("GetStdHandle")
+ procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
+ procGetSystemPreferredUILanguages = modkernel32.NewProc("GetSystemPreferredUILanguages")
+ procGetSystemTimeAsFileTime = modkernel32.NewProc("GetSystemTimeAsFileTime")
+ procGetSystemTimePreciseAsFileTime = modkernel32.NewProc("GetSystemTimePreciseAsFileTime")
+ procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW")
+ procGetTempPathW = modkernel32.NewProc("GetTempPathW")
+ procGetThreadPreferredUILanguages = modkernel32.NewProc("GetThreadPreferredUILanguages")
+ procGetTickCount64 = modkernel32.NewProc("GetTickCount64")
+ procGetTimeZoneInformation = modkernel32.NewProc("GetTimeZoneInformation")
+ procGetUserPreferredUILanguages = modkernel32.NewProc("GetUserPreferredUILanguages")
+ procGetVersion = modkernel32.NewProc("GetVersion")
procGetVolumeInformationByHandleW = modkernel32.NewProc("GetVolumeInformationByHandleW")
+ procGetVolumeInformationW = modkernel32.NewProc("GetVolumeInformationW")
procGetVolumeNameForVolumeMountPointW = modkernel32.NewProc("GetVolumeNameForVolumeMountPointW")
procGetVolumePathNameW = modkernel32.NewProc("GetVolumePathNameW")
procGetVolumePathNamesForVolumeNameW = modkernel32.NewProc("GetVolumePathNamesForVolumeNameW")
+ procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW")
+ procIsWow64Process = modkernel32.NewProc("IsWow64Process")
+ procLoadLibraryExW = modkernel32.NewProc("LoadLibraryExW")
+ procLoadLibraryW = modkernel32.NewProc("LoadLibraryW")
+ procLocalFree = modkernel32.NewProc("LocalFree")
+ procLockFileEx = modkernel32.NewProc("LockFileEx")
+ procMapViewOfFile = modkernel32.NewProc("MapViewOfFile")
+ procMoveFileExW = modkernel32.NewProc("MoveFileExW")
+ procMoveFileW = modkernel32.NewProc("MoveFileW")
+ procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
+ procOpenEventW = modkernel32.NewProc("OpenEventW")
+ procOpenMutexW = modkernel32.NewProc("OpenMutexW")
+ procOpenProcess = modkernel32.NewProc("OpenProcess")
+ procOpenThread = modkernel32.NewProc("OpenThread")
+ procPostQueuedCompletionStatus = modkernel32.NewProc("PostQueuedCompletionStatus")
+ procProcess32FirstW = modkernel32.NewProc("Process32FirstW")
+ procProcess32NextW = modkernel32.NewProc("Process32NextW")
+ procProcessIdToSessionId = modkernel32.NewProc("ProcessIdToSessionId")
+ procPulseEvent = modkernel32.NewProc("PulseEvent")
procQueryDosDeviceW = modkernel32.NewProc("QueryDosDeviceW")
+ procQueryInformationJobObject = modkernel32.NewProc("QueryInformationJobObject")
+ procReadConsoleW = modkernel32.NewProc("ReadConsoleW")
+ procReadDirectoryChangesW = modkernel32.NewProc("ReadDirectoryChangesW")
+ procReadFile = modkernel32.NewProc("ReadFile")
+ procReleaseMutex = modkernel32.NewProc("ReleaseMutex")
+ procRemoveDirectoryW = modkernel32.NewProc("RemoveDirectoryW")
+ procResetEvent = modkernel32.NewProc("ResetEvent")
+ procResumeThread = modkernel32.NewProc("ResumeThread")
+ procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition")
+ procSetConsoleMode = modkernel32.NewProc("SetConsoleMode")
+ procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW")
+ procSetEndOfFile = modkernel32.NewProc("SetEndOfFile")
+ procSetEnvironmentVariableW = modkernel32.NewProc("SetEnvironmentVariableW")
+ procSetErrorMode = modkernel32.NewProc("SetErrorMode")
+ procSetEvent = modkernel32.NewProc("SetEvent")
+ procSetFileAttributesW = modkernel32.NewProc("SetFileAttributesW")
+ procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
+ procSetFilePointer = modkernel32.NewProc("SetFilePointer")
+ procSetFileTime = modkernel32.NewProc("SetFileTime")
+ procSetHandleInformation = modkernel32.NewProc("SetHandleInformation")
+ procSetInformationJobObject = modkernel32.NewProc("SetInformationJobObject")
+ procSetPriorityClass = modkernel32.NewProc("SetPriorityClass")
+ procSetProcessPriorityBoost = modkernel32.NewProc("SetProcessPriorityBoost")
+ procSetProcessShutdownParameters = modkernel32.NewProc("SetProcessShutdownParameters")
+ procSetProcessWorkingSetSizeEx = modkernel32.NewProc("SetProcessWorkingSetSizeEx")
+ procSetStdHandle = modkernel32.NewProc("SetStdHandle")
procSetVolumeLabelW = modkernel32.NewProc("SetVolumeLabelW")
procSetVolumeMountPointW = modkernel32.NewProc("SetVolumeMountPointW")
- procMessageBoxW = moduser32.NewProc("MessageBoxW")
- procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
- procInitiateSystemShutdownExW = modadvapi32.NewProc("InitiateSystemShutdownExW")
- procSetProcessShutdownParameters = modkernel32.NewProc("SetProcessShutdownParameters")
- procGetProcessShutdownParameters = modkernel32.NewProc("GetProcessShutdownParameters")
- procCLSIDFromString = modole32.NewProc("CLSIDFromString")
- procStringFromGUID2 = modole32.NewProc("StringFromGUID2")
- procCoCreateGuid = modole32.NewProc("CoCreateGuid")
- procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
- procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
- procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers")
- procGetProcessPreferredUILanguages = modkernel32.NewProc("GetProcessPreferredUILanguages")
- procGetThreadPreferredUILanguages = modkernel32.NewProc("GetThreadPreferredUILanguages")
- procGetUserPreferredUILanguages = modkernel32.NewProc("GetUserPreferredUILanguages")
- procGetSystemPreferredUILanguages = modkernel32.NewProc("GetSystemPreferredUILanguages")
- procEnumProcesses = modpsapi.NewProc("EnumProcesses")
- procWSAStartup = modws2_32.NewProc("WSAStartup")
- procWSACleanup = modws2_32.NewProc("WSACleanup")
- procWSAIoctl = modws2_32.NewProc("WSAIoctl")
- procsocket = modws2_32.NewProc("socket")
- procsendto = modws2_32.NewProc("sendto")
- procrecvfrom = modws2_32.NewProc("recvfrom")
- procsetsockopt = modws2_32.NewProc("setsockopt")
- procgetsockopt = modws2_32.NewProc("getsockopt")
- procbind = modws2_32.NewProc("bind")
- procconnect = modws2_32.NewProc("connect")
- procgetsockname = modws2_32.NewProc("getsockname")
- procgetpeername = modws2_32.NewProc("getpeername")
- proclisten = modws2_32.NewProc("listen")
- procshutdown = modws2_32.NewProc("shutdown")
- procclosesocket = modws2_32.NewProc("closesocket")
+ procSleepEx = modkernel32.NewProc("SleepEx")
+ procTerminateJobObject = modkernel32.NewProc("TerminateJobObject")
+ procTerminateProcess = modkernel32.NewProc("TerminateProcess")
+ procThread32First = modkernel32.NewProc("Thread32First")
+ procThread32Next = modkernel32.NewProc("Thread32Next")
+ procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
+ procUnmapViewOfFile = modkernel32.NewProc("UnmapViewOfFile")
+ procVirtualAlloc = modkernel32.NewProc("VirtualAlloc")
+ procVirtualFree = modkernel32.NewProc("VirtualFree")
+ procVirtualLock = modkernel32.NewProc("VirtualLock")
+ procVirtualProtect = modkernel32.NewProc("VirtualProtect")
+ procVirtualUnlock = modkernel32.NewProc("VirtualUnlock")
+ procWaitForMultipleObjects = modkernel32.NewProc("WaitForMultipleObjects")
+ procWaitForSingleObject = modkernel32.NewProc("WaitForSingleObject")
+ procWriteConsoleW = modkernel32.NewProc("WriteConsoleW")
+ procWriteFile = modkernel32.NewProc("WriteFile")
procAcceptEx = modmswsock.NewProc("AcceptEx")
procGetAcceptExSockaddrs = modmswsock.NewProc("GetAcceptExSockaddrs")
- procWSARecv = modws2_32.NewProc("WSARecv")
- procWSASend = modws2_32.NewProc("WSASend")
- procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
- procWSASendTo = modws2_32.NewProc("WSASendTo")
- procgethostbyname = modws2_32.NewProc("gethostbyname")
- procgetservbyname = modws2_32.NewProc("getservbyname")
- procntohs = modws2_32.NewProc("ntohs")
- procgetprotobyname = modws2_32.NewProc("getprotobyname")
- procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
- procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
- procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
- procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
- procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
- procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
- procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
- procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
- procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
- procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
- procGetACP = modkernel32.NewProc("GetACP")
- procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
- procTranslateNameW = modsecur32.NewProc("TranslateNameW")
- procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
- procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
- procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
+ procTransmitFile = modmswsock.NewProc("TransmitFile")
procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree")
- procLookupAccountSidW = modadvapi32.NewProc("LookupAccountSidW")
- procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
- procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
- procConvertStringSidToSidW = modadvapi32.NewProc("ConvertStringSidToSidW")
- procGetLengthSid = modadvapi32.NewProc("GetLengthSid")
- procCopySid = modadvapi32.NewProc("CopySid")
- procAllocateAndInitializeSid = modadvapi32.NewProc("AllocateAndInitializeSid")
- procCreateWellKnownSid = modadvapi32.NewProc("CreateWellKnownSid")
- procIsWellKnownSid = modadvapi32.NewProc("IsWellKnownSid")
- procFreeSid = modadvapi32.NewProc("FreeSid")
- procEqualSid = modadvapi32.NewProc("EqualSid")
- procGetSidIdentifierAuthority = modadvapi32.NewProc("GetSidIdentifierAuthority")
- procGetSidSubAuthorityCount = modadvapi32.NewProc("GetSidSubAuthorityCount")
- procGetSidSubAuthority = modadvapi32.NewProc("GetSidSubAuthority")
- procIsValidSid = modadvapi32.NewProc("IsValidSid")
- procCheckTokenMembership = modadvapi32.NewProc("CheckTokenMembership")
- procOpenProcessToken = modadvapi32.NewProc("OpenProcessToken")
- procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
- procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
- procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
- procSetThreadToken = modadvapi32.NewProc("SetThreadToken")
- procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
- procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
- procAdjustTokenGroups = modadvapi32.NewProc("AdjustTokenGroups")
- procGetTokenInformation = modadvapi32.NewProc("GetTokenInformation")
- procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
- procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
+ procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation")
+ procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo")
+ procRtlGetNtVersionNumbers = modntdll.NewProc("RtlGetNtVersionNumbers")
+ procRtlGetVersion = modntdll.NewProc("RtlGetVersion")
+ procCLSIDFromString = modole32.NewProc("CLSIDFromString")
+ procCoCreateGuid = modole32.NewProc("CoCreateGuid")
+ procCoTaskMemFree = modole32.NewProc("CoTaskMemFree")
+ procStringFromGUID2 = modole32.NewProc("StringFromGUID2")
+ procEnumProcesses = modpsapi.NewProc("EnumProcesses")
+ procGetUserNameExW = modsecur32.NewProc("GetUserNameExW")
+ procTranslateNameW = modsecur32.NewProc("TranslateNameW")
+ procCommandLineToArgvW = modshell32.NewProc("CommandLineToArgvW")
+ procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath")
+ procShellExecuteW = modshell32.NewProc("ShellExecuteW")
+ procExitWindowsEx = moduser32.NewProc("ExitWindowsEx")
+ procMessageBoxW = moduser32.NewProc("MessageBoxW")
+ procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
+ procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
procGetUserProfileDirectoryW = moduserenv.NewProc("GetUserProfileDirectoryW")
- procGetSystemDirectoryW = modkernel32.NewProc("GetSystemDirectoryW")
- procGetWindowsDirectoryW = modkernel32.NewProc("GetWindowsDirectoryW")
- procGetSystemWindowsDirectoryW = modkernel32.NewProc("GetSystemWindowsDirectoryW")
- procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken")
+ procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
+ procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
+ procWSACleanup = modws2_32.NewProc("WSACleanup")
+ procWSAEnumProtocolsW = modws2_32.NewProc("WSAEnumProtocolsW")
+ procWSAIoctl = modws2_32.NewProc("WSAIoctl")
+ procWSARecv = modws2_32.NewProc("WSARecv")
+ procWSARecvFrom = modws2_32.NewProc("WSARecvFrom")
+ procWSASend = modws2_32.NewProc("WSASend")
+ procWSASendTo = modws2_32.NewProc("WSASendTo")
+ procWSAStartup = modws2_32.NewProc("WSAStartup")
+ procbind = modws2_32.NewProc("bind")
+ procclosesocket = modws2_32.NewProc("closesocket")
+ procconnect = modws2_32.NewProc("connect")
+ procgethostbyname = modws2_32.NewProc("gethostbyname")
+ procgetpeername = modws2_32.NewProc("getpeername")
+ procgetprotobyname = modws2_32.NewProc("getprotobyname")
+ procgetservbyname = modws2_32.NewProc("getservbyname")
+ procgetsockname = modws2_32.NewProc("getsockname")
+ procgetsockopt = modws2_32.NewProc("getsockopt")
+ proclisten = modws2_32.NewProc("listen")
+ procntohs = modws2_32.NewProc("ntohs")
+ procrecvfrom = modws2_32.NewProc("recvfrom")
+ procsendto = modws2_32.NewProc("sendto")
+ procsetsockopt = modws2_32.NewProc("setsockopt")
+ procshutdown = modws2_32.NewProc("shutdown")
+ procsocket = modws2_32.NewProc("socket")
procWTSEnumerateSessionsW = modwtsapi32.NewProc("WTSEnumerateSessionsW")
procWTSFreeMemory = modwtsapi32.NewProc("WTSFreeMemory")
- procGetSecurityInfo = modadvapi32.NewProc("GetSecurityInfo")
- procSetSecurityInfo = modadvapi32.NewProc("SetSecurityInfo")
- procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW")
- procSetNamedSecurityInfoW = modadvapi32.NewProc("SetNamedSecurityInfoW")
- procBuildSecurityDescriptorW = modadvapi32.NewProc("BuildSecurityDescriptorW")
- procInitializeSecurityDescriptor = modadvapi32.NewProc("InitializeSecurityDescriptor")
- procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl")
- procGetSecurityDescriptorDacl = modadvapi32.NewProc("GetSecurityDescriptorDacl")
- procGetSecurityDescriptorSacl = modadvapi32.NewProc("GetSecurityDescriptorSacl")
- procGetSecurityDescriptorOwner = modadvapi32.NewProc("GetSecurityDescriptorOwner")
- procGetSecurityDescriptorGroup = modadvapi32.NewProc("GetSecurityDescriptorGroup")
- procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength")
- procGetSecurityDescriptorRMControl = modadvapi32.NewProc("GetSecurityDescriptorRMControl")
- procIsValidSecurityDescriptor = modadvapi32.NewProc("IsValidSecurityDescriptor")
- procSetSecurityDescriptorControl = modadvapi32.NewProc("SetSecurityDescriptorControl")
- procSetSecurityDescriptorDacl = modadvapi32.NewProc("SetSecurityDescriptorDacl")
- procSetSecurityDescriptorSacl = modadvapi32.NewProc("SetSecurityDescriptorSacl")
- procSetSecurityDescriptorOwner = modadvapi32.NewProc("SetSecurityDescriptorOwner")
- procSetSecurityDescriptorGroup = modadvapi32.NewProc("SetSecurityDescriptorGroup")
- procSetSecurityDescriptorRMControl = modadvapi32.NewProc("SetSecurityDescriptorRMControl")
- procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
- procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
- procMakeAbsoluteSD = modadvapi32.NewProc("MakeAbsoluteSD")
- procMakeSelfRelativeSD = modadvapi32.NewProc("MakeSelfRelativeSD")
- procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW")
+ procWTSQueryUserToken = modwtsapi32.NewProc("WTSQueryUserToken")
)
-func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) {
+ var _p0 uint32
+ if resetToDefault {
+ _p0 = 1
}
- return
-}
-
-func DeregisterEventSource(handle Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
+ r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
- r1, _, e1 := syscall.Syscall9(procReportEventW.Addr(), 9, uintptr(log), uintptr(etype), uintptr(category), uintptr(eventId), uintptr(usrSId), uintptr(numStrings), uintptr(dataSize), uintptr(unsafe.Pointer(strings)), uintptr(unsafe.Pointer(rawData)))
+func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) {
+ var _p0 uint32
+ if disableAllPrivileges {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) {
+ r1, _, e1 := syscall.Syscall12(procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identAuth)), uintptr(subAuth), uintptr(subAuth0), uintptr(subAuth1), uintptr(subAuth2), uintptr(subAuth3), uintptr(subAuth4), uintptr(subAuth5), uintptr(subAuth6), uintptr(subAuth7), uintptr(unsafe.Pointer(sid)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func buildSecurityDescriptor(owner *TRUSTEE, group *TRUSTEE, countAccessEntries uint32, accessEntries *EXPLICIT_ACCESS, countAuditEntries uint32, auditEntries *EXPLICIT_ACCESS, oldSecurityDescriptor *SECURITY_DESCRIPTOR, sizeNewSecurityDescriptor *uint32, newSecurityDescriptor **SECURITY_DESCRIPTOR) (ret error) {
+ r0, _, _ := syscall.Syscall9(procBuildSecurityDescriptorW.Addr(), 9, uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(countAccessEntries), uintptr(unsafe.Pointer(accessEntries)), uintptr(countAuditEntries), uintptr(unsafe.Pointer(auditEntries)), uintptr(unsafe.Pointer(oldSecurityDescriptor)), uintptr(unsafe.Pointer(sizeNewSecurityDescriptor)), uintptr(unsafe.Pointer(newSecurityDescriptor)))
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
+ r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall12(procChangeServiceConfigW.Addr(), 11, uintptr(service), uintptr(serviceType), uintptr(startType), uintptr(errorControl), uintptr(unsafe.Pointer(binaryPathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), uintptr(unsafe.Pointer(displayName)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
+ r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
@@ -412,11 +428,64 @@
func CloseServiceHandle(handle Handle) (err error) {
r1, _, e1 := syscall.Syscall(procCloseServiceHandle.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
+ r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func convertSecurityDescriptorToStringSecurityDescriptor(sd *SECURITY_DESCRIPTOR, revision uint32, securityInformation SECURITY_INFORMATION, str **uint16, strLen *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(securityInformation), uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(strLen)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
+ var _p0 *uint16
+ _p0, err = syscall.UTF16PtrFromString(str)
+ if err != nil {
+ return
+ }
+ return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
+}
+
+func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
+ r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
+ r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
@@ -425,24 +494,39 @@
r0, _, e1 := syscall.Syscall15(procCreateServiceW.Addr(), 13, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(unsafe.Pointer(displayName)), uintptr(access), uintptr(srvType), uintptr(startType), uintptr(errCtl), uintptr(unsafe.Pointer(pathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), 0, 0)
handle = Handle(r0)
if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
+ r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
@@ -450,131 +534,23 @@
func DeleteService(service Handle) (err error) {
r1, _, e1 := syscall.Syscall(procDeleteService.Addr(), 1, uintptr(service), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
+func DeregisterEventSource(handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procDeregisterEventSource.Addr(), 1, uintptr(handle), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
- r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
+func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) {
+ r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken)))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) {
- r1, _, e1 := syscall.Syscall(procControlService.Addr(), 3, uintptr(service), uintptr(control), uintptr(unsafe.Pointer(status)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
- r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
- r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) (err error) {
- r1, _, e1 := syscall.Syscall12(procChangeServiceConfigW.Addr(), 11, uintptr(service), uintptr(serviceType), uintptr(startType), uintptr(errorControl), uintptr(unsafe.Pointer(binaryPathName)), uintptr(unsafe.Pointer(loadOrderGroup)), uintptr(unsafe.Pointer(tagId)), uintptr(unsafe.Pointer(dependencies)), uintptr(unsafe.Pointer(serviceStartName)), uintptr(unsafe.Pointer(password)), uintptr(unsafe.Pointer(displayName)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) {
- r1, _, e1 := syscall.Syscall(procChangeServiceConfig2W.Addr(), 3, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(info)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
@@ -582,23 +558,252 @@
func EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) {
r1, _, e1 := syscall.Syscall12(procEnumServicesStatusExW.Addr(), 10, uintptr(mgr), uintptr(infoLevel), uintptr(serviceType), uintptr(serviceState), uintptr(unsafe.Pointer(services)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), uintptr(unsafe.Pointer(servicesReturned)), uintptr(unsafe.Pointer(resumeHandle)), uintptr(unsafe.Pointer(groupName)), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
+func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
+ r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
+ isEqual = r0 != 0
+ return
+}
+
+func FreeSid(sid *SID) (err error) {
+ r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
+ if r1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetLengthSid(sid *SID) (len uint32) {
+ r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
+ len = uint32(r0)
+ return
+}
+
+func getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
+ var _p0 *uint16
+ _p0, ret = syscall.UTF16PtrFromString(objectName)
+ if ret != nil {
+ return
+ }
+ return _getNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl, sd)
+}
+
+func _getNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
+ r0, _, _ := syscall.Syscall9(procGetNamedSecurityInfoW.Addr(), 8, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(sd)), 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func getSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, control *SECURITY_DESCRIPTOR_CONTROL, revision *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(control)), uintptr(unsafe.Pointer(revision)))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl **ACL, daclDefaulted *bool) (err error) {
+ var _p0 uint32
+ if *daclPresent {
+ _p0 = 1
+ }
+ var _p1 uint32
+ if *daclDefaulted {
+ _p1 = 1
+ }
+ r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
+ *daclPresent = _p0 != 0
+ *daclDefaulted = _p1 != 0
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefaulted *bool) (err error) {
+ var _p0 uint32
+ if *groupDefaulted {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0)))
+ *groupDefaulted = _p0 != 0
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getSecurityDescriptorLength(sd *SECURITY_DESCRIPTOR) (len uint32) {
+ r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
+ len = uint32(r0)
+ return
+}
+
+func getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefaulted *bool) (err error) {
+ var _p0 uint32
+ if *ownerDefaulted {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0)))
+ *ownerDefaulted = _p0 != 0
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) (ret error) {
+ r0, _, _ := syscall.Syscall(procGetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl **ACL, saclDefaulted *bool) (err error) {
+ var _p0 uint32
+ if *saclPresent {
+ _p0 = 1
+ }
+ var _p1 uint32
+ if *saclDefaulted {
+ _p1 = 1
+ }
+ r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
+ *saclPresent = _p0 != 0
+ *saclDefaulted = _p1 != 0
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
+ r0, _, _ := syscall.Syscall9(procGetSecurityInfo.Addr(), 8, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(sd)), 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) {
+ r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
+ authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0))
+ return
+}
+
+func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) {
+ r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0)
+ subAuthority = (*uint32)(unsafe.Pointer(r0))
+ return
+}
+
+func getSidSubAuthorityCount(sid *SID) (count *uint8) {
+ r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
+ count = (*uint8)(unsafe.Pointer(r0))
+ return
+}
+
+func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ImpersonateSelf(impersonationlevel uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procInitializeSecurityDescriptor.Addr(), 2, uintptr(unsafe.Pointer(absoluteSD)), uintptr(revision), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) {
+ var _p0 uint32
+ if forceAppsClosed {
+ _p0 = 1
+ }
+ var _p1 uint32
+ if rebootAfterShutdown {
+ _p1 = 1
+ }
+ r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) {
+ r0, _, _ := syscall.Syscall(procIsValidSecurityDescriptor.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
+ isValid = r0 != 0
+ return
+}
+
+func isValidSid(sid *SID) (isValid bool) {
+ r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
+ isValid = r0 != 0
+ return
+}
+
+func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) {
+ r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0)
+ isWellKnown = r0 != 0
+ return
+}
+
+func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
+ r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func makeAbsoluteSD(selfRelativeSD *SECURITY_DESCRIPTOR, absoluteSD *SECURITY_DESCRIPTOR, absoluteSDSize *uint32, dacl *ACL, daclSize *uint32, sacl *ACL, saclSize *uint32, owner *SID, ownerSize *uint32, group *SID, groupSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall12(procMakeAbsoluteSD.Addr(), 11, uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(absoluteSDSize)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(daclSize)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(saclSize)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(ownerSize)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(groupSize)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procMakeSelfRelativeSD.Addr(), 3, uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(selfRelativeSDSize)))
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
@@ -611,1295 +816,80 @@
return
}
-func GetLastError() (lasterr error) {
- r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
- if r0 != 0 {
- lasterr = syscall.Errno(r0)
+func OpenProcessToken(process Handle, access uint32, token *Token) (err error) {
+ r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token)))
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
-func LoadLibrary(libname string) (handle Handle, err error) {
- var _p0 *uint16
- _p0, err = syscall.UTF16PtrFromString(libname)
- if err != nil {
- return
- }
- return _LoadLibrary(_p0)
-}
-
-func _LoadLibrary(libname *uint16) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
+func OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procOpenSCManagerW.Addr(), 3, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(databaseName)), uintptr(access))
handle = Handle(r0)
if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
- var _p0 *uint16
- _p0, err = syscall.UTF16PtrFromString(libname)
- if err != nil {
- return
- }
- return _LoadLibraryEx(_p0, zero, flags)
-}
-
-func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
+func OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procOpenServiceW.Addr(), 3, uintptr(mgr), uintptr(unsafe.Pointer(serviceName)), uintptr(access))
handle = Handle(r0)
if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func FreeLibrary(handle Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
- var _p0 *byte
- _p0, err = syscall.BytePtrFromString(procname)
- if err != nil {
- return
- }
- return _GetProcAddress(module, _p0)
-}
-
-func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
- r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
- proc = uintptr(r0)
- if proc == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size))
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procGetModuleHandleExW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(moduleName)), uintptr(unsafe.Pointer(module)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetVersion() (ver uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
- ver = uint32(r0)
- if ver == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
- var _p0 *uint16
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- r0, _, e1 := syscall.Syscall9(procFormatMessageW.Addr(), 7, uintptr(flags), uintptr(msgsrc), uintptr(msgid), uintptr(langid), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(args)), 0, 0)
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ExitProcess(exitcode uint32) {
- syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
- return
-}
-
-func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
+func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) {
var _p0 uint32
- if *isWow64 {
+ if openAsSelf {
_p0 = 1
- } else {
- _p0 = 0
}
- r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0)
- *isWow64 = _p0 != 0
+ r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0)
- handle = Handle(r0)
- if handle == InvalidHandle {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
- var _p0 *byte
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- r1, _, e1 := syscall.Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
+func QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
- var _p0 *byte
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- r1, _, e1 := syscall.Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
+func QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procQueryServiceConfigW.Addr(), 4, uintptr(service), uintptr(unsafe.Pointer(serviceConfig)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
- var _p0 uint32
- if wait {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
+func QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procQueryServiceLockStatusW.Addr(), 4, uintptr(mgr), uintptr(unsafe.Pointer(lockStatus)), uintptr(bufSize), uintptr(unsafe.Pointer(bytesNeeded)), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
- r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
- newlowoffset = uint32(r0)
- if newlowoffset == 0xffffffff {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CloseHandle(handle Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
+func QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) {
+ r1, _, e1 := syscall.Syscall(procQueryServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(status)), 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
- handle = Handle(r0)
- if handle == InvalidHandle {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
+func QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procQueryServiceStatusEx.Addr(), 5, uintptr(service), uintptr(infoLevel), uintptr(unsafe.Pointer(buff)), uintptr(buffSize), uintptr(unsafe.Pointer(bytesNeeded)), 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
- handle = Handle(r0)
- if handle == InvalidHandle {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func findNextFile1(handle Handle, data *win32finddata1) (err error) {
- r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FindClose(handle Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
- r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetCurrentDirectory(path *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
- r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func RemoveDirectory(path *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func DeleteFile(path *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func MoveFile(from *uint16, to *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
- r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
- r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetComputerName(buf *uint16, n *uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetEndOfFile(handle Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetSystemTimeAsFileTime(time *Filetime) {
- syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
- return
-}
-
-func GetSystemTimePreciseAsFileTime(time *Filetime) {
- syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
- return
-}
-
-func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
- rc = uint32(r0)
- if rc == 0xffffffff {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
- r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CancelIo(s Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CancelIoEx(s Handle, o *Overlapped) (err error) {
- r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
- var _p0 uint32
- if inheritHandles {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) {
- var _p0 uint32
- if inheritHandle {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) {
- r1, _, e1 := syscall.Syscall6(procShellExecuteW.Addr(), 6, uintptr(hwnd), uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(args)), uintptr(unsafe.Pointer(cwd)), uintptr(showCmd))
- if r1 <= 32 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) {
- r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
- }
- return
-}
-
-func TerminateProcess(handle Handle, exitcode uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetStartupInfo(startupInfo *StartupInfo) (err error) {
- r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
- var _p0 uint32
- if bInheritHandle {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
- r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
- event = uint32(r0)
- if event == 0xffffffff {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
- var _p0 uint32
- if waitAll {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
- event = uint32(r0)
- if event == 0xffffffff {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetFileType(filehandle Handle) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
- r1, _, e1 := syscall.Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetEnvironmentStrings() (envs *uint16, err error) {
- r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
- envs = (*uint16)(unsafe.Pointer(r0))
- if envs == nil {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FreeEnvironmentStrings(envs *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
- var _p0 uint32
- if inheritExisting {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func DestroyEnvironmentBlock(block *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getTickCount64() (ms uint64) {
- r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
- ms = uint64(r0)
- return
-}
-
-func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
- r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetFileAttributes(name *uint16) (attrs uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
- attrs = uint32(r0)
- if attrs == INVALID_FILE_ATTRIBUTES {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetFileAttributes(name *uint16, attrs uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
- r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetCommandLine() (cmd *uint16) {
- r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
- cmd = (*uint16)(unsafe.Pointer(r0))
- return
-}
-
-func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
- r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
- argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
- if argv == nil {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func LocalFree(hmem Handle) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
- handle = Handle(r0)
- if handle != 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FlushFileBuffers(handle Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
- r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
- addr = uintptr(r0)
- if addr == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func UnmapViewOfFile(addr uintptr) (err error) {
- r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
- r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func VirtualLock(addr uintptr, length uintptr) (err error) {
- r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func VirtualUnlock(addr uintptr, length uintptr) (err error) {
- r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
- r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
- value = uintptr(r0)
- if value == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
- var _p0 uint32
- if watchSubTree {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
- r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
- store = Handle(r0)
- if store == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
- handle = Handle(r0)
- if handle == InvalidHandle {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
- r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
- context = (*CertContext)(unsafe.Pointer(r0))
- if context == nil {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
- r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertCloseStore(store Handle, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
- r1, _, e1 := syscall.Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertFreeCertificateChain(ctx *CertChainContext) {
- syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
- return
-}
-
-func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
- r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
- context = (*CertContext)(unsafe.Pointer(r0))
- if context == nil {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertFreeCertificateContext(ctx *CertContext) (err error) {
- r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
- r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
- r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
- if r0 != 0 {
- regerrno = syscall.Errno(r0)
+ err = errnoErr(e1)
}
return
}
@@ -1912,14 +902,6 @@
return
}
-func RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) {
- r0, _, _ := syscall.Syscall12(procRegQueryInfoKeyW.Addr(), 12, uintptr(key), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(subkeysLen)), uintptr(unsafe.Pointer(maxSubkeyLen)), uintptr(unsafe.Pointer(maxClassLen)), uintptr(unsafe.Pointer(valuesLen)), uintptr(unsafe.Pointer(maxValueNameLen)), uintptr(unsafe.Pointer(maxValueLen)), uintptr(unsafe.Pointer(saLen)), uintptr(unsafe.Pointer(lastWriteTime)))
- if r0 != 0 {
- regerrno = syscall.Errno(r0)
- }
- return
-}
-
func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
r0, _, _ := syscall.Syscall9(procRegEnumKeyExW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(lastWriteTime)), 0)
if r0 != 0 {
@@ -1928,6 +910,22 @@
return
}
+func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
+ r0, _, _ := syscall.Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
+ if r0 != 0 {
+ regerrno = syscall.Errno(r0)
+ }
+ return
+}
+
+func RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) {
+ r0, _, _ := syscall.Syscall12(procRegQueryInfoKeyW.Addr(), 12, uintptr(key), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(subkeysLen)), uintptr(unsafe.Pointer(maxSubkeyLen)), uintptr(unsafe.Pointer(maxClassLen)), uintptr(unsafe.Pointer(valuesLen)), uintptr(unsafe.Pointer(maxValueNameLen)), uintptr(unsafe.Pointer(maxValueLen)), uintptr(unsafe.Pointer(saLen)), uintptr(unsafe.Pointer(lastWriteTime)))
+ if r0 != 0 {
+ regerrno = syscall.Errno(r0)
+ }
+ return
+}
+
func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
r0, _, _ := syscall.Syscall6(procRegQueryValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen)))
if r0 != 0 {
@@ -1936,1257 +934,254 @@
return
}
-func GetCurrentProcessId() (pid uint32) {
- r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
- pid = uint32(r0)
- return
-}
-
-func GetConsoleMode(console Handle, mode *uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetConsoleMode(console Handle, mode uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
- r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
- r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
- r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
- handle = Handle(r0)
- if handle == InvalidHandle {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
- r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
- r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
- r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
- r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
- r1, _, e1 := syscall.Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), uintptr(ioControlCode), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferSize), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferSize), uintptr(unsafe.Pointer(bytesReturned)), uintptr(unsafe.Pointer(overlapped)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
- if r1&0xff == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
- r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
- if r1&0xff == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetCurrentThreadId() (id uint32) {
- r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
- id = uint32(r0)
- return
-}
-
-func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
+func RegisterEventSource(uncServerName *uint16, sourceName *uint16) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procRegisterEventSourceW.Addr(), 2, uintptr(unsafe.Pointer(uncServerName)), uintptr(unsafe.Pointer(sourceName)), 0)
handle = Handle(r0)
if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func ReportEvent(log Handle, etype uint16, category uint16, eventId uint32, usrSId uintptr, numStrings uint16, dataSize uint32, strings **uint16, rawData *byte) (err error) {
+ r1, _, e1 := syscall.Syscall9(procReportEventW.Addr(), 9, uintptr(log), uintptr(etype), uintptr(category), uintptr(eventId), uintptr(usrSId), uintptr(numStrings), uintptr(dataSize), uintptr(unsafe.Pointer(strings)), uintptr(unsafe.Pointer(rawData)))
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
-func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
+func RevertToSelf() (err error) {
+ r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) {
+ r0, _, _ := syscall.Syscall6(procSetEntriesInAclW.Addr(), 4, uintptr(countExplicitEntries), uintptr(unsafe.Pointer(explicitEntries)), uintptr(unsafe.Pointer(oldACL)), uintptr(unsafe.Pointer(newACL)), 0, 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
+ var _p0 *uint16
+ _p0, ret = syscall.UTF16PtrFromString(objectName)
+ if ret != nil {
+ return
+ }
+ return _SetNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl)
+}
+
+func _SetNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
+ r0, _, _ := syscall.Syscall9(procSetNamedSecurityInfoW.Addr(), 7, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func setSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(controlBitsOfInterest), uintptr(controlBitsToSet))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *ACL, daclDefaulted bool) (err error) {
var _p0 uint32
- if inheritHandle {
+ if daclPresent {
_p0 = 1
- } else {
- _p0 = 0
- }
- r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetEvent(event Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ResetEvent(event Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func PulseEvent(event Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) {
- var _p0 uint32
- if initialOwner {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
- var _p0 uint32
- if inheritHandle {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ReleaseMutex(mutex Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
- var _p0 uint32
- if alertable {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
- ret = uint32(r0)
- return
-}
-
-func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0)
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func AssignProcessToJobObject(job Handle, process Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func TerminateJobObject(job Handle, exitCode uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetErrorMode(mode uint32) (ret uint32) {
- r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0)
- ret = uint32(r0)
- return
-}
-
-func ResumeThread(thread Handle) (ret uint32, err error) {
- r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0)
- ret = uint32(r0)
- if ret == 0xffffffff {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetPriorityClass(process Handle) (ret uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
- ret = uint32(r0)
- if ret == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func QueryInformationJobObject(job Handle, JobObjectInformationClass int32, JobObjectInformation uintptr, JobObjectInformationLength uint32, retlen *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procQueryInformationJobObject.Addr(), 5, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), uintptr(unsafe.Pointer(retlen)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
- r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
- ret = int(r0)
- if ret == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetProcessId(process Handle) (id uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0)
- id = uint32(r0)
- if id == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) {
- var _p0 uint32
- if inheritHandle {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
- handle = Handle(r0)
- if handle == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetProcessPriorityBoost(process Handle, disable bool) (err error) {
- var _p0 uint32
- if disable {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32) {
- syscall.Syscall6(procGetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(unsafe.Pointer(lpMinimumWorkingSetSize)), uintptr(unsafe.Pointer(lpMaximumWorkingSetSize)), uintptr(unsafe.Pointer(flags)), 0, 0)
- return
-}
-
-func SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procSetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(dwMinimumWorkingSetSize), uintptr(dwMaximumWorkingSetSize), uintptr(flags), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
- handle = Handle(r0)
- if handle == InvalidHandle {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
- handle = Handle(r0)
- if handle == InvalidHandle {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FindVolumeClose(findVolume Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailableToCaller *uint64, totalNumberOfBytes *uint64, totalNumberOfFreeBytes *uint64) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetDiskFreeSpaceExW.Addr(), 4, uintptr(unsafe.Pointer(directoryName)), uintptr(unsafe.Pointer(freeBytesAvailableToCaller)), uintptr(unsafe.Pointer(totalNumberOfBytes)), uintptr(unsafe.Pointer(totalNumberOfFreeBytes)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetDriveType(rootPathName *uint16) (driveType uint32) {
- r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
- driveType = uint32(r0)
- return
-}
-
-func GetLogicalDrives() (drivesBitMask uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
- drivesBitMask = uint32(r0)
- if drivesBitMask == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
- r1, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
- r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
- r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
- n = uint32(r0)
- if n == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
- r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
- ret = int32(r0)
- if ret == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func ExitWindowsEx(flags uint32, reason uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func InitiateSystemShutdownEx(machineName *uint16, message *uint16, timeout uint32, forceAppsClosed bool, rebootAfterShutdown bool, reason uint32) (err error) {
- var _p0 uint32
- if forceAppsClosed {
- _p0 = 1
- } else {
- _p0 = 0
}
var _p1 uint32
- if rebootAfterShutdown {
+ if daclDefaulted {
_p1 = 1
- } else {
- _p1 = 0
}
- r1, _, e1 := syscall.Syscall6(procInitiateSystemShutdownExW.Addr(), 6, uintptr(unsafe.Pointer(machineName)), uintptr(unsafe.Pointer(message)), uintptr(timeout), uintptr(_p0), uintptr(_p1), uintptr(reason))
+ r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func SetProcessShutdownParameters(level uint32, flags uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procSetProcessShutdownParameters.Addr(), 2, uintptr(level), uintptr(flags), 0)
+func setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaulted bool) (err error) {
+ var _p0 uint32
+ if groupDefaulted {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(_p0))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetProcessShutdownParameters.Addr(), 2, uintptr(unsafe.Pointer(level)), uintptr(unsafe.Pointer(flags)), 0)
+func setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaulted bool) (err error) {
+ var _p0 uint32
+ if ownerDefaulted {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) {
- r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
+func setSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) {
+ syscall.Syscall(procSetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
+ return
+}
+
+func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *ACL, saclDefaulted bool) (err error) {
+ var _p0 uint32
+ if saclPresent {
+ _p0 = 1
}
- return
-}
-
-func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) {
- r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax))
- chars = int32(r0)
- return
-}
-
-func coCreateGuid(pguid *GUID) (ret error) {
- r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
+ var _p1 uint32
+ if saclDefaulted {
+ _p1 = 1
}
- return
-}
-
-func CoTaskMemFree(address unsafe.Pointer) {
- syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0)
- return
-}
-
-func rtlGetVersion(info *OsVersionInfoEx) (ret error) {
- r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
- }
- return
-}
-
-func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) {
- syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber)))
- return
-}
-
-func getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetProcessPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
+ r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetThreadPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
+func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) {
+ syscall.Syscall9(procSetSecurityInfo.Addr(), 7, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0)
+ return
+}
+
+func SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetServiceStatus.Addr(), 2, uintptr(service), uintptr(unsafe.Pointer(serviceStatus)), 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetUserPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
+func SetThreadToken(thread *Handle, token Token) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetSystemPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
+func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) {
- var _p0 *uint32
- if len(processIds) > 0 {
- _p0 = &processIds[0]
- }
- r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(processIds)), uintptr(unsafe.Pointer(bytesReturned)))
+func StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) {
+ r1, _, e1 := syscall.Syscall(procStartServiceCtrlDispatcherW.Addr(), 1, uintptr(unsafe.Pointer(serviceTable)), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
- r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
- if r0 != 0 {
- sockerr = syscall.Errno(r0)
+func StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procStartServiceW.Addr(), 3, uintptr(service), uintptr(numArgs), uintptr(unsafe.Pointer(argVectors)))
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
-func WSACleanup() (err error) {
- r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
+ r1, _, e1 := syscall.Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
-func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
- r1, _, e1 := syscall.Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine))
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func CertCloseStore(store Handle, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
}
return
}
-func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
- r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
+func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
+ r0, _, e1 := syscall.Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
+ context = (*CertContext)(unsafe.Pointer(r0))
+ if context == nil {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
+ r0, _, e1 := syscall.Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
+ context = (*CertContext)(unsafe.Pointer(r0))
+ if context == nil {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CertFreeCertificateChain(ctx *CertChainContext) {
+ syscall.Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
+ return
+}
+
+func CertFreeCertificateContext(ctx *CertContext) (err error) {
+ r1, _, e1 := syscall.Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
+ r1, _, e1 := syscall.Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
handle = Handle(r0)
if handle == InvalidHandle {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func sendto(s Handle, buf []byte, flags int32, to unsafe.Pointer, tolen int32) (err error) {
- var _p0 *byte
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- r1, _, e1 := syscall.Syscall6(procsendto.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(tolen))
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
+ store = Handle(r0)
+ if store == 0 {
+ err = errnoErr(e1)
}
return
}
-func recvfrom(s Handle, buf []byte, flags int32, from *RawSockaddrAny, fromlen *int32) (n int32, err error) {
- var _p0 *byte
- if len(buf) > 0 {
- _p0 = &buf[0]
- }
- r0, _, e1 := syscall.Syscall6(procrecvfrom.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
- n = int32(r0)
- if n == -1 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
- r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
- r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
- r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
- r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
- r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
- r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func listen(s Handle, backlog int32) (err error) {
- r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func shutdown(s Handle, how int32) (err error) {
- r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func Closesocket(s Handle) (err error) {
- r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
- r1, _, e1 := syscall.Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0)
+func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
+ r1, _, e1 := syscall.Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
- syscall.Syscall9(procGetAcceptExSockaddrs.Addr(), 8, uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(lrsa)), uintptr(unsafe.Pointer(lrsalen)), uintptr(unsafe.Pointer(rrsa)), uintptr(unsafe.Pointer(rrsalen)), 0)
- return
-}
-
-func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
- r1, _, e1 := syscall.Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
- r1, _, e1 := syscall.Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
- r1, _, e1 := syscall.Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
- r1, _, e1 := syscall.Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
- if r1 == socket_error {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetHostByName(name string) (h *Hostent, err error) {
- var _p0 *byte
- _p0, err = syscall.BytePtrFromString(name)
- if err != nil {
- return
- }
- return _GetHostByName(_p0)
-}
-
-func _GetHostByName(name *byte) (h *Hostent, err error) {
- r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
- h = (*Hostent)(unsafe.Pointer(r0))
- if h == nil {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetServByName(name string, proto string) (s *Servent, err error) {
- var _p0 *byte
- _p0, err = syscall.BytePtrFromString(name)
- if err != nil {
- return
- }
- var _p1 *byte
- _p1, err = syscall.BytePtrFromString(proto)
- if err != nil {
- return
- }
- return _GetServByName(_p0, _p1)
-}
-
-func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
- r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
- s = (*Servent)(unsafe.Pointer(r0))
- if s == nil {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func Ntohs(netshort uint16) (u uint16) {
- r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
- u = uint16(r0)
- return
-}
-
-func GetProtoByName(name string) (p *Protoent, err error) {
- var _p0 *byte
- _p0, err = syscall.BytePtrFromString(name)
- if err != nil {
- return
- }
- return _GetProtoByName(_p0)
-}
-
-func _GetProtoByName(name *byte) (p *Protoent, err error) {
- r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
- p = (*Protoent)(unsafe.Pointer(r0))
- if p == nil {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
+func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
+ r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
+ same = r0 != 0
return
}
@@ -3212,27 +1207,8 @@
return
}
-func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
- r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
- same = r0 != 0
- return
-}
-
-func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
- r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
- if r0 != 0 {
- sockerr = syscall.Errno(r0)
- }
- return
-}
-
-func FreeAddrInfoW(addrinfo *AddrinfoW) {
- syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
- return
-}
-
-func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
- r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
+func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
+ r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
if r0 != 0 {
errcode = syscall.Errno(r0)
}
@@ -3247,84 +1223,1407 @@
return
}
-func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
- r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
- r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
- n = int32(r0)
- if n == -1 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
- r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
+func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
+ r0, _, _ := syscall.Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
if r0 != 0 {
errcode = syscall.Errno(r0)
}
return
}
+func AssignProcessToJobObject(job Handle, process Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procAssignProcessToJobObject.Addr(), 2, uintptr(job), uintptr(process), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CancelIo(s Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CancelIoEx(s Handle, o *Overlapped) (err error) {
+ r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CloseHandle(handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
+ r1, _, e1 := syscall.Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateEventEx(eventAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall6(procCreateEventExW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateEvent(eventAttrs *SecurityAttributes, manualReset uint32, initialState uint32, name *uint16) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall6(procCreateEventW.Addr(), 4, uintptr(unsafe.Pointer(eventAttrs)), uintptr(manualReset), uintptr(initialState), uintptr(unsafe.Pointer(name)), 0, 0)
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile Handle) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0)
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
+ r1, _, e1 := syscall.Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
+ if r1&0xff == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateIoCompletionPort(filehandle Handle, cphandle Handle, key uint32, threadcnt uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateJobObject(jobAttr *SecurityAttributes, name *uint16) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procCreateJobObjectW.Addr(), 2, uintptr(unsafe.Pointer(jobAttr)), uintptr(unsafe.Pointer(name)), 0)
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateMutexEx(mutexAttrs *SecurityAttributes, name *uint16, flags uint32, desiredAccess uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall6(procCreateMutexExW.Addr(), 4, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(desiredAccess), 0, 0)
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateMutex(mutexAttrs *SecurityAttributes, initialOwner bool, name *uint16) (handle Handle, err error) {
+ var _p0 uint32
+ if initialOwner {
+ _p0 = 1
+ }
+ r0, _, e1 := syscall.Syscall(procCreateMutexW.Addr(), 3, uintptr(unsafe.Pointer(mutexAttrs)), uintptr(_p0), uintptr(unsafe.Pointer(name)))
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
+ var _p0 uint32
+ if inheritHandles {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
+ if r1&0xff == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func DefineDosDevice(flags uint32, deviceName *uint16, targetPath *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procDefineDosDeviceW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func DeleteFile(path *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func DeleteVolumeMountPoint(volumeMountPoint *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procDeleteVolumeMountPointW.Addr(), 1, uintptr(unsafe.Pointer(volumeMountPoint)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
+ r1, _, e1 := syscall.Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), uintptr(ioControlCode), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferSize), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferSize), uintptr(unsafe.Pointer(bytesReturned)), uintptr(unsafe.Pointer(overlapped)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
+ var _p0 uint32
+ if bInheritHandle {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ExitProcess(exitcode uint32) {
+ syscall.Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
+ return
+}
+
+func FindClose(handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FindFirstVolumeMountPoint(rootPathName *uint16, volumeMountPoint *uint16, bufferLength uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procFindFirstVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FindFirstVolume(volumeName *uint16, bufferLength uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procFindFirstVolumeW.Addr(), 2, uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength), 0)
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func findNextFile1(handle Handle, data *win32finddata1) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FindNextVolumeMountPoint(findVolumeMountPoint Handle, volumeMountPoint *uint16, bufferLength uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindNextVolumeMountPointW.Addr(), 3, uintptr(findVolumeMountPoint), uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(bufferLength))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FindNextVolume(findVolume Handle, volumeName *uint16, bufferLength uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindNextVolumeW.Addr(), 3, uintptr(findVolume), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferLength))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FindVolumeClose(findVolume Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindVolumeClose.Addr(), 1, uintptr(findVolume), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FindVolumeMountPointClose(findVolumeMountPoint Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procFindVolumeMountPointClose.Addr(), 1, uintptr(findVolumeMountPoint), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FlushFileBuffers(handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
+ r1, _, e1 := syscall.Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FormatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
+ var _p0 *uint16
+ if len(buf) > 0 {
+ _p0 = &buf[0]
+ }
+ r0, _, e1 := syscall.Syscall9(procFormatMessageW.Addr(), 7, uintptr(flags), uintptr(msgsrc), uintptr(msgid), uintptr(langid), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(args)), 0, 0)
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FreeEnvironmentStrings(envs *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func FreeLibrary(handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GenerateConsoleCtrlEvent(ctrlEvent uint32, processGroupID uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGenerateConsoleCtrlEvent.Addr(), 2, uintptr(ctrlEvent), uintptr(processGroupID), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func GetACP() (acp uint32) {
r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
acp = uint32(r0)
return
}
+func GetCommandLine() (cmd *uint16) {
+ r0, _, _ := syscall.Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
+ cmd = (*uint16)(unsafe.Pointer(r0))
+ return
+}
+
+func GetComputerNameEx(nametype uint32, buf *uint16, n *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nametype), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetComputerName(buf *uint16, n *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetConsoleMode(console Handle, mode *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetCurrentProcessId() (pid uint32) {
+ r0, _, _ := syscall.Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
+ pid = uint32(r0)
+ return
+}
+
+func GetCurrentThreadId() (id uint32) {
+ r0, _, _ := syscall.Syscall(procGetCurrentThreadId.Addr(), 0, 0, 0, 0)
+ id = uint32(r0)
+ return
+}
+
+func GetDiskFreeSpaceEx(directoryName *uint16, freeBytesAvailableToCaller *uint64, totalNumberOfBytes *uint64, totalNumberOfFreeBytes *uint64) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetDiskFreeSpaceExW.Addr(), 4, uintptr(unsafe.Pointer(directoryName)), uintptr(unsafe.Pointer(freeBytesAvailableToCaller)), uintptr(unsafe.Pointer(totalNumberOfBytes)), uintptr(unsafe.Pointer(totalNumberOfFreeBytes)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetDriveType(rootPathName *uint16) (driveType uint32) {
+ r0, _, _ := syscall.Syscall(procGetDriveTypeW.Addr(), 1, uintptr(unsafe.Pointer(rootPathName)), 0, 0)
+ driveType = uint32(r0)
+ return
+}
+
+func GetEnvironmentStrings() (envs *uint16, err error) {
+ r0, _, e1 := syscall.Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
+ envs = (*uint16)(unsafe.Pointer(r0))
+ if envs == nil {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetFileAttributes(name *uint16) (attrs uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
+ attrs = uint32(r0)
+ if attrs == INVALID_FILE_ATTRIBUTES {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetFileInformationByHandleEx(handle Handle, class uint32, outBuffer *byte, outBufferLen uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferLen), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetFileType(filehandle Handle) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetLastError() (lasterr error) {
+ r0, _, _ := syscall.Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
+ if r0 != 0 {
+ lasterr = syscall.Errno(r0)
+ }
+ return
+}
+
+func GetLogicalDriveStrings(bufferLength uint32, buffer *uint16) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetLogicalDriveStringsW.Addr(), 2, uintptr(bufferLength), uintptr(unsafe.Pointer(buffer)), 0)
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetLogicalDrives() (drivesBitMask uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetLogicalDrives.Addr(), 0, 0, 0, 0)
+ drivesBitMask = uint32(r0)
+ if drivesBitMask == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetModuleFileName(module Handle, filename *uint16, size uint32) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(filename)), uintptr(size))
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetModuleHandleEx(flags uint32, moduleName *uint16, module *Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetModuleHandleExW.Addr(), 3, uintptr(flags), uintptr(unsafe.Pointer(moduleName)), uintptr(unsafe.Pointer(module)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetOverlappedResult(handle Handle, overlapped *Overlapped, done *uint32, wait bool) (err error) {
+ var _p0 uint32
+ if wait {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall6(procGetOverlappedResult.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(done)), uintptr(_p0), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetPriorityClass(process Handle) (ret uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetPriorityClass.Addr(), 1, uintptr(process), 0, 0)
+ ret = uint32(r0)
+ if ret == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
+ var _p0 *byte
+ _p0, err = syscall.BytePtrFromString(procname)
+ if err != nil {
+ return
+ }
+ return _GetProcAddress(module, _p0)
+}
+
+func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
+ r0, _, e1 := syscall.Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
+ proc = uintptr(r0)
+ if proc == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetProcessId(process Handle) (id uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetProcessId.Addr(), 1, uintptr(process), 0, 0)
+ id = uint32(r0)
+ if id == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getProcessPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetProcessPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetProcessShutdownParameters(level *uint32, flags *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetProcessShutdownParameters.Addr(), 2, uintptr(unsafe.Pointer(level)), uintptr(unsafe.Pointer(flags)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetProcessWorkingSetSizeEx(hProcess Handle, lpMinimumWorkingSetSize *uintptr, lpMaximumWorkingSetSize *uintptr, flags *uint32) {
+ syscall.Syscall6(procGetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(unsafe.Pointer(lpMinimumWorkingSetSize)), uintptr(unsafe.Pointer(lpMaximumWorkingSetSize)), uintptr(unsafe.Pointer(flags)), 0, 0)
+ return
+}
+
+func GetQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uint32, overlapped **Overlapped, timeout uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetStartupInfo(startupInfo *StartupInfo) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetStdHandle(stdhandle uint32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
+ len = uint32(r0)
+ if len == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getSystemPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetSystemPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetSystemTimeAsFileTime(time *Filetime) {
+ syscall.Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
+ return
+}
+
+func GetSystemTimePreciseAsFileTime(time *Filetime) {
+ syscall.Syscall(procGetSystemTimePreciseAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
+ return
+}
+
+func getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
+ len = uint32(r0)
+ if len == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getThreadPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetThreadPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getTickCount64() (ms uint64) {
+ r0, _, _ := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
+ ms = uint64(r0)
+ return
+}
+
+func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
+ rc = uint32(r0)
+ if rc == 0xffffffff {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getUserPreferredUILanguages(flags uint32, numLanguages *uint32, buf *uint16, bufSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetUserPreferredUILanguages.Addr(), 4, uintptr(flags), uintptr(unsafe.Pointer(numLanguages)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(bufSize)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetVersion() (ver uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
+ ver = uint32(r0)
+ if ver == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetVolumeInformationByHandle(file Handle, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
+ r1, _, e1 := syscall.Syscall9(procGetVolumeInformationByHandleW.Addr(), 8, uintptr(file), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetVolumeInformation(rootPathName *uint16, volumeNameBuffer *uint16, volumeNameSize uint32, volumeNameSerialNumber *uint32, maximumComponentLength *uint32, fileSystemFlags *uint32, fileSystemNameBuffer *uint16, fileSystemNameSize uint32) (err error) {
+ r1, _, e1 := syscall.Syscall9(procGetVolumeInformationW.Addr(), 8, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeNameBuffer)), uintptr(volumeNameSize), uintptr(unsafe.Pointer(volumeNameSerialNumber)), uintptr(unsafe.Pointer(maximumComponentLength)), uintptr(unsafe.Pointer(fileSystemFlags)), uintptr(unsafe.Pointer(fileSystemNameBuffer)), uintptr(fileSystemNameSize), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetVolumeNameForVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16, bufferlength uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetVolumeNameForVolumeMountPointW.Addr(), 3, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), uintptr(bufferlength))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetVolumePathName(fileName *uint16, volumePathName *uint16, bufferLength uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetVolumePathNameW.Addr(), 3, uintptr(unsafe.Pointer(fileName)), uintptr(unsafe.Pointer(volumePathName)), uintptr(bufferLength))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetVolumePathNamesForVolumeName(volumeName *uint16, volumePathNames *uint16, bufferLength uint32, returnLength *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procGetVolumePathNamesForVolumeNameW.Addr(), 4, uintptr(unsafe.Pointer(volumeName)), uintptr(unsafe.Pointer(volumePathNames)), uintptr(bufferLength), uintptr(unsafe.Pointer(returnLength)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
+ len = uint32(r0)
+ if len == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func IsWow64Process(handle Handle, isWow64 *bool) (err error) {
+ var _p0 uint32
+ if *isWow64 {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall(procIsWow64Process.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(&_p0)), 0)
+ *isWow64 = _p0 != 0
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func LoadLibraryEx(libname string, zero Handle, flags uintptr) (handle Handle, err error) {
+ var _p0 *uint16
+ _p0, err = syscall.UTF16PtrFromString(libname)
+ if err != nil {
+ return
+ }
+ return _LoadLibraryEx(_p0, zero, flags)
+}
+
+func _LoadLibraryEx(libname *uint16, zero Handle, flags uintptr) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procLoadLibraryExW.Addr(), 3, uintptr(unsafe.Pointer(libname)), uintptr(zero), uintptr(flags))
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func LoadLibrary(libname string) (handle Handle, err error) {
+ var _p0 *uint16
+ _p0, err = syscall.UTF16PtrFromString(libname)
+ if err != nil {
+ return
+ }
+ return _LoadLibrary(_p0)
+}
+
+func _LoadLibrary(libname *uint16) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func LocalFree(hmem Handle) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
+ handle = Handle(r0)
+ if handle != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func LockFileEx(file Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
+ r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
+ r0, _, e1 := syscall.Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
+ addr = uintptr(r0)
+ if addr == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func MoveFile(from *uint16, to *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
nwrite = int32(r0)
if nwrite == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
- if r1&0xff == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func OpenEvent(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
+ var _p0 uint32
+ if inheritHandle {
+ _p0 = 1
+ }
+ r0, _, e1 := syscall.Syscall(procOpenEventW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
}
return
}
-func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
- if r1&0xff == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func OpenMutex(desiredAccess uint32, inheritHandle bool, name *uint16) (handle Handle, err error) {
+ var _p0 uint32
+ if inheritHandle {
+ _p0 = 1
+ }
+ r0, _, e1 := syscall.Syscall(procOpenMutexW.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(unsafe.Pointer(name)))
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
}
return
}
-func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
- r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
+func OpenProcess(desiredAccess uint32, inheritHandle bool, processId uint32) (handle Handle, err error) {
+ var _p0 uint32
+ if inheritHandle {
+ _p0 = 1
+ }
+ r0, _, e1 := syscall.Syscall(procOpenProcess.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(processId))
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func OpenThread(desiredAccess uint32, inheritHandle bool, threadId uint32) (handle Handle, err error) {
+ var _p0 uint32
+ if inheritHandle {
+ _p0 = 1
+ }
+ r0, _, e1 := syscall.Syscall(procOpenThread.Addr(), 3, uintptr(desiredAccess), uintptr(_p0), uintptr(threadId))
+ handle = Handle(r0)
+ if handle == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func PostQueuedCompletionStatus(cphandle Handle, qty uint32, key uint32, overlapped *Overlapped) (err error) {
+ r1, _, e1 := syscall.Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
+ r1, _, e1 := syscall.Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
+ r1, _, e1 := syscall.Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ProcessIdToSessionId(pid uint32, sessionid *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procProcessIdToSessionId.Addr(), 2, uintptr(pid), uintptr(unsafe.Pointer(sessionid)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func PulseEvent(event Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procPulseEvent.Addr(), 1, uintptr(event), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func QueryDosDevice(deviceName *uint16, targetPath *uint16, max uint32) (n uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procQueryDosDeviceW.Addr(), 3, uintptr(unsafe.Pointer(deviceName)), uintptr(unsafe.Pointer(targetPath)), uintptr(max))
+ n = uint32(r0)
+ if n == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func QueryInformationJobObject(job Handle, JobObjectInformationClass int32, JobObjectInformation uintptr, JobObjectInformationLength uint32, retlen *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procQueryInformationJobObject.Addr(), 5, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), uintptr(unsafe.Pointer(retlen)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
+ r1, _, e1 := syscall.Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
+ var _p0 uint32
+ if watchSubTree {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ReadFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
+ var _p0 *byte
+ if len(buf) > 0 {
+ _p0 = &buf[0]
+ }
+ r1, _, e1 := syscall.Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ReleaseMutex(mutex Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procReleaseMutex.Addr(), 1, uintptr(mutex), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func RemoveDirectory(path *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ResetEvent(event Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procResetEvent.Addr(), 1, uintptr(event), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ResumeThread(thread Handle) (ret uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procResumeThread.Addr(), 1, uintptr(thread), 0, 0)
+ ret = uint32(r0)
+ if ret == 0xffffffff {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetConsoleCursorPosition(console Handle, position Coord) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(*((*uint32)(unsafe.Pointer(&position)))), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetConsoleMode(console Handle, mode uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetConsoleMode.Addr(), 2, uintptr(console), uintptr(mode), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetCurrentDirectory(path *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetEndOfFile(handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetErrorMode(mode uint32) (ret uint32) {
+ r0, _, _ := syscall.Syscall(procSetErrorMode.Addr(), 1, uintptr(mode), 0, 0)
+ ret = uint32(r0)
+ return
+}
+
+func SetEvent(event Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetEvent.Addr(), 1, uintptr(event), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetFileAttributes(name *uint16, attrs uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
+ r0, _, e1 := syscall.Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
+ newlowoffset = uint32(r0)
+ if newlowoffset == 0xffffffff {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
+ r1, _, e1 := syscall.Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetInformationJobObject(job Handle, JobObjectInformationClass uint32, JobObjectInformation uintptr, JobObjectInformationLength uint32) (ret int, err error) {
+ r0, _, e1 := syscall.Syscall6(procSetInformationJobObject.Addr(), 4, uintptr(job), uintptr(JobObjectInformationClass), uintptr(JobObjectInformation), uintptr(JobObjectInformationLength), 0, 0)
+ ret = int(r0)
+ if ret == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetPriorityClass(process Handle, priorityClass uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetPriorityClass.Addr(), 2, uintptr(process), uintptr(priorityClass), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetProcessPriorityBoost(process Handle, disable bool) (err error) {
+ var _p0 uint32
+ if disable {
+ _p0 = 1
+ }
+ r1, _, e1 := syscall.Syscall(procSetProcessPriorityBoost.Addr(), 2, uintptr(process), uintptr(_p0), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetProcessShutdownParameters(level uint32, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetProcessShutdownParameters.Addr(), 2, uintptr(level), uintptr(flags), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetProcessWorkingSetSizeEx(hProcess Handle, dwMinimumWorkingSetSize uintptr, dwMaximumWorkingSetSize uintptr, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procSetProcessWorkingSetSizeEx.Addr(), 4, uintptr(hProcess), uintptr(dwMinimumWorkingSetSize), uintptr(dwMaximumWorkingSetSize), uintptr(flags), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetStdHandle(stdhandle uint32, handle Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetStdHandle.Addr(), 2, uintptr(stdhandle), uintptr(handle), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetVolumeLabel(rootPathName *uint16, volumeName *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetVolumeLabelW.Addr(), 2, uintptr(unsafe.Pointer(rootPathName)), uintptr(unsafe.Pointer(volumeName)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SetVolumeMountPoint(volumeMountPoint *uint16, volumeName *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procSetVolumeMountPointW.Addr(), 2, uintptr(unsafe.Pointer(volumeMountPoint)), uintptr(unsafe.Pointer(volumeName)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func SleepEx(milliseconds uint32, alertable bool) (ret uint32) {
+ var _p0 uint32
+ if alertable {
+ _p0 = 1
+ }
+ r0, _, _ := syscall.Syscall(procSleepEx.Addr(), 2, uintptr(milliseconds), uintptr(_p0), 0)
+ ret = uint32(r0)
+ return
+}
+
+func TerminateJobObject(job Handle, exitCode uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procTerminateJobObject.Addr(), 2, uintptr(job), uintptr(exitCode), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func TerminateProcess(handle Handle, exitcode uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func Thread32First(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
+ r1, _, e1 := syscall.Syscall(procThread32First.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func Thread32Next(snapshot Handle, threadEntry *ThreadEntry32) (err error) {
+ r1, _, e1 := syscall.Syscall(procThread32Next.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(threadEntry)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func UnlockFileEx(file Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *Overlapped) (err error) {
+ r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func UnmapViewOfFile(addr uintptr) (err error) {
+ r1, _, e1 := syscall.Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func VirtualAlloc(address uintptr, size uintptr, alloctype uint32, protect uint32) (value uintptr, err error) {
+ r0, _, e1 := syscall.Syscall6(procVirtualAlloc.Addr(), 4, uintptr(address), uintptr(size), uintptr(alloctype), uintptr(protect), 0, 0)
+ value = uintptr(r0)
+ if value == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func VirtualFree(address uintptr, size uintptr, freetype uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procVirtualFree.Addr(), 3, uintptr(address), uintptr(size), uintptr(freetype))
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func VirtualLock(addr uintptr, length uintptr) (err error) {
+ r1, _, e1 := syscall.Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func VirtualProtect(address uintptr, size uintptr, newprotect uint32, oldprotect *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procVirtualProtect.Addr(), 4, uintptr(address), uintptr(size), uintptr(newprotect), uintptr(unsafe.Pointer(oldprotect)), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func VirtualUnlock(addr uintptr, length uintptr) (err error) {
+ r1, _, e1 := syscall.Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func waitForMultipleObjects(count uint32, handles uintptr, waitAll bool, waitMilliseconds uint32) (event uint32, err error) {
+ var _p0 uint32
+ if waitAll {
+ _p0 = 1
+ }
+ r0, _, e1 := syscall.Syscall6(procWaitForMultipleObjects.Addr(), 4, uintptr(count), uintptr(handles), uintptr(_p0), uintptr(waitMilliseconds), 0, 0)
+ event = uint32(r0)
+ if event == 0xffffffff {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
+ r0, _, e1 := syscall.Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
+ event = uint32(r0)
+ if event == 0xffffffff {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
+ r1, _, e1 := syscall.Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func WriteFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
+ var _p0 *byte
+ if len(buf) > 0 {
+ _p0 = &buf[0]
+ }
+ r1, _, e1 := syscall.Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
+ r1, _, e1 := syscall.Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
+ syscall.Syscall9(procGetAcceptExSockaddrs.Addr(), 8, uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(lrsa)), uintptr(unsafe.Pointer(lrsalen)), uintptr(unsafe.Pointer(rrsa)), uintptr(unsafe.Pointer(rrsalen)), 0)
+ return
+}
+
+func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
+ r1, _, e1 := syscall.Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0)
+ if r1 == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func NetApiBufferFree(buf *byte) (neterr error) {
+ r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
if r0 != 0 {
neterr = syscall.Errno(r0)
}
@@ -3339,310 +2638,140 @@
return
}
-func NetApiBufferFree(buf *byte) (neterr error) {
- r0, _, _ := syscall.Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
+func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
+ r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
if r0 != 0 {
neterr = syscall.Errno(r0)
}
return
}
-func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
- r1, _, e1 := syscall.Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
+func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) {
+ syscall.Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber)))
+ return
+}
+
+func rtlGetVersion(info *OsVersionInfoEx) (ret error) {
+ r0, _, _ := syscall.Syscall(procRtlGetVersion.Addr(), 1, uintptr(unsafe.Pointer(info)), 0, 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func clsidFromString(lpsz *uint16, pclsid *GUID) (ret error) {
+ r0, _, _ := syscall.Syscall(procCLSIDFromString.Addr(), 2, uintptr(unsafe.Pointer(lpsz)), uintptr(unsafe.Pointer(pclsid)), 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func coCreateGuid(pguid *GUID) (ret error) {
+ r0, _, _ := syscall.Syscall(procCoCreateGuid.Addr(), 1, uintptr(unsafe.Pointer(pguid)), 0, 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func CoTaskMemFree(address unsafe.Pointer) {
+ syscall.Syscall(procCoTaskMemFree.Addr(), 1, uintptr(address), 0, 0)
+ return
+}
+
+func stringFromGUID2(rguid *GUID, lpsz *uint16, cchMax int32) (chars int32) {
+ r0, _, _ := syscall.Syscall(procStringFromGUID2.Addr(), 3, uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lpsz)), uintptr(cchMax))
+ chars = int32(r0)
+ return
+}
+
+func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) {
+ var _p0 *uint32
+ if len(processIds) > 0 {
+ _p0 = &processIds[0]
+ }
+ r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(processIds)), uintptr(unsafe.Pointer(bytesReturned)))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
- r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
+func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
+ if r1&0xff == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
+ if r1&0xff == 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
+ r0, _, e1 := syscall.Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
+ argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
+ if argv == nil {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func shGetKnownFolderPath(id *KNOWNFOLDERID, flags uint32, token Token, path **uint16) (ret error) {
+ r0, _, _ := syscall.Syscall6(procSHGetKnownFolderPath.Addr(), 4, uintptr(unsafe.Pointer(id)), uintptr(flags), uintptr(token), uintptr(unsafe.Pointer(path)), 0, 0)
+ if r0 != 0 {
+ ret = syscall.Errno(r0)
+ }
+ return
+}
+
+func ShellExecute(hwnd Handle, verb *uint16, file *uint16, args *uint16, cwd *uint16, showCmd int32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procShellExecuteW.Addr(), 6, uintptr(hwnd), uintptr(unsafe.Pointer(verb)), uintptr(unsafe.Pointer(file)), uintptr(unsafe.Pointer(args)), uintptr(unsafe.Pointer(cwd)), uintptr(showCmd))
+ if r1 <= 32 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func ExitWindowsEx(flags uint32, reason uint32) (err error) {
+ r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
- r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func MessageBox(hwnd Handle, text *uint16, caption *uint16, boxtype uint32) (ret int32, err error) {
+ r0, _, e1 := syscall.Syscall6(procMessageBoxW.Addr(), 4, uintptr(hwnd), uintptr(unsafe.Pointer(text)), uintptr(unsafe.Pointer(caption)), uintptr(boxtype), 0, 0)
+ ret = int32(r0)
+ if ret == 0 {
+ err = errnoErr(e1)
}
return
}
-func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
- r1, _, e1 := syscall.Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetLengthSid(sid *SID) (len uint32) {
- r0, _, _ := syscall.Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
- len = uint32(r0)
- return
-}
-
-func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
- r1, _, e1 := syscall.Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func AllocateAndInitializeSid(identAuth *SidIdentifierAuthority, subAuth byte, subAuth0 uint32, subAuth1 uint32, subAuth2 uint32, subAuth3 uint32, subAuth4 uint32, subAuth5 uint32, subAuth6 uint32, subAuth7 uint32, sid **SID) (err error) {
- r1, _, e1 := syscall.Syscall12(procAllocateAndInitializeSid.Addr(), 11, uintptr(unsafe.Pointer(identAuth)), uintptr(subAuth), uintptr(subAuth0), uintptr(subAuth1), uintptr(subAuth2), uintptr(subAuth3), uintptr(subAuth4), uintptr(subAuth5), uintptr(subAuth6), uintptr(subAuth7), uintptr(unsafe.Pointer(sid)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func createWellKnownSid(sidType WELL_KNOWN_SID_TYPE, domainSid *SID, sid *SID, sizeSid *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procCreateWellKnownSid.Addr(), 4, uintptr(sidType), uintptr(unsafe.Pointer(domainSid)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sizeSid)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func isWellKnownSid(sid *SID, sidType WELL_KNOWN_SID_TYPE) (isWellKnown bool) {
- r0, _, _ := syscall.Syscall(procIsWellKnownSid.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(sidType), 0)
- isWellKnown = r0 != 0
- return
-}
-
-func FreeSid(sid *SID) (err error) {
- r1, _, e1 := syscall.Syscall(procFreeSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
- if r1 != 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func EqualSid(sid1 *SID, sid2 *SID) (isEqual bool) {
- r0, _, _ := syscall.Syscall(procEqualSid.Addr(), 2, uintptr(unsafe.Pointer(sid1)), uintptr(unsafe.Pointer(sid2)), 0)
- isEqual = r0 != 0
- return
-}
-
-func getSidIdentifierAuthority(sid *SID) (authority *SidIdentifierAuthority) {
- r0, _, _ := syscall.Syscall(procGetSidIdentifierAuthority.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
- authority = (*SidIdentifierAuthority)(unsafe.Pointer(r0))
- return
-}
-
-func getSidSubAuthorityCount(sid *SID) (count *uint8) {
- r0, _, _ := syscall.Syscall(procGetSidSubAuthorityCount.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
- count = (*uint8)(unsafe.Pointer(r0))
- return
-}
-
-func getSidSubAuthority(sid *SID, index uint32) (subAuthority *uint32) {
- r0, _, _ := syscall.Syscall(procGetSidSubAuthority.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(index), 0)
- subAuthority = (*uint32)(unsafe.Pointer(r0))
- return
-}
-
-func isValidSid(sid *SID) (isValid bool) {
- r0, _, _ := syscall.Syscall(procIsValidSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
- isValid = r0 != 0
- return
-}
-
-func checkTokenMembership(tokenHandle Token, sidToCheck *SID, isMember *int32) (err error) {
- r1, _, e1 := syscall.Syscall(procCheckTokenMembership.Addr(), 3, uintptr(tokenHandle), uintptr(unsafe.Pointer(sidToCheck)), uintptr(unsafe.Pointer(isMember)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func OpenProcessToken(process Handle, access uint32, token *Token) (err error) {
- r1, _, e1 := syscall.Syscall(procOpenProcessToken.Addr(), 3, uintptr(process), uintptr(access), uintptr(unsafe.Pointer(token)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func OpenThreadToken(thread Handle, access uint32, openAsSelf bool, token *Token) (err error) {
+func CreateEnvironmentBlock(block **uint16, token Token, inheritExisting bool) (err error) {
var _p0 uint32
- if openAsSelf {
+ if inheritExisting {
_p0 = 1
- } else {
- _p0 = 0
}
- r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
+ r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func ImpersonateSelf(impersonationlevel uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
+func DestroyEnvironmentBlock(block *uint16) (err error) {
+ r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func RevertToSelf() (err error) {
- r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetThreadToken(thread *Handle, token Token) (err error) {
- r1, _, e1 := syscall.Syscall(procSetThreadToken.Addr(), 2, uintptr(unsafe.Pointer(thread)), uintptr(token), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
- r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func AdjustTokenPrivileges(token Token, disableAllPrivileges bool, newstate *Tokenprivileges, buflen uint32, prevstate *Tokenprivileges, returnlen *uint32) (err error) {
- var _p0 uint32
- if disableAllPrivileges {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func AdjustTokenGroups(token Token, resetToDefault bool, newstate *Tokengroups, buflen uint32, prevstate *Tokengroups, returnlen *uint32) (err error) {
- var _p0 uint32
- if resetToDefault {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall6(procAdjustTokenGroups.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func GetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procGetTokenInformation.Addr(), 5, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func SetTokenInformation(token Token, infoClass uint32, info *byte, infoLen uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(token), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func DuplicateTokenEx(existingToken Token, desiredAccess uint32, tokenAttributes *SecurityAttributes, impersonationLevel uint32, tokenType uint32, newToken *Token) (err error) {
- r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(existingToken), uintptr(desiredAccess), uintptr(unsafe.Pointer(tokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(newToken)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
@@ -3650,62 +2779,256 @@
func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
r1, _, e1 := syscall.Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
-func getSystemDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetSystemDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
- len = uint32(r0)
- if len == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func FreeAddrInfoW(addrinfo *AddrinfoW) {
+ syscall.Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
+ return
+}
+
+func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
+ r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
+ if r0 != 0 {
+ sockerr = syscall.Errno(r0)
}
return
}
-func getWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
- len = uint32(r0)
- if len == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func WSACleanup() (err error) {
+ r1, _, e1 := syscall.Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
+ if r1 == socket_error {
+ err = errnoErr(e1)
}
return
}
-func getSystemWindowsDirectory(dir *uint16, dirLen uint32) (len uint32, err error) {
- r0, _, e1 := syscall.Syscall(procGetSystemWindowsDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(dirLen), 0)
- len = uint32(r0)
- if len == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
+ r0, _, e1 := syscall.Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
+ n = int32(r0)
+ if n == -1 {
+ err = errnoErr(e1)
}
return
}
-func WTSQueryUserToken(session uint32, token *Token) (err error) {
- r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
+ r1, _, e1 := syscall.Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine))
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
+ r1, _, e1 := syscall.Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
+ r1, _, e1 := syscall.Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
+ r1, _, e1 := syscall.Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
+ r1, _, e1 := syscall.Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
+ r0, _, _ := syscall.Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
+ if r0 != 0 {
+ sockerr = syscall.Errno(r0)
+ }
+ return
+}
+
+func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
+ r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func Closesocket(s Handle) (err error) {
+ r1, _, e1 := syscall.Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
+ r1, _, e1 := syscall.Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetHostByName(name string) (h *Hostent, err error) {
+ var _p0 *byte
+ _p0, err = syscall.BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ return _GetHostByName(_p0)
+}
+
+func _GetHostByName(name *byte) (h *Hostent, err error) {
+ r0, _, e1 := syscall.Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
+ h = (*Hostent)(unsafe.Pointer(r0))
+ if h == nil {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
+ r1, _, e1 := syscall.Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetProtoByName(name string) (p *Protoent, err error) {
+ var _p0 *byte
+ _p0, err = syscall.BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ return _GetProtoByName(_p0)
+}
+
+func _GetProtoByName(name *byte) (p *Protoent, err error) {
+ r0, _, e1 := syscall.Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
+ p = (*Protoent)(unsafe.Pointer(r0))
+ if p == nil {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func GetServByName(name string, proto string) (s *Servent, err error) {
+ var _p0 *byte
+ _p0, err = syscall.BytePtrFromString(name)
+ if err != nil {
+ return
+ }
+ var _p1 *byte
+ _p1, err = syscall.BytePtrFromString(proto)
+ if err != nil {
+ return
+ }
+ return _GetServByName(_p0, _p1)
+}
+
+func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
+ r0, _, e1 := syscall.Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
+ s = (*Servent)(unsafe.Pointer(r0))
+ if s == nil {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
+ r1, _, e1 := syscall.Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func listen(s Handle, backlog int32) (err error) {
+ r1, _, e1 := syscall.Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func Ntohs(netshort uint16) (u uint16) {
+ r0, _, _ := syscall.Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
+ u = uint16(r0)
+ return
+}
+
+func recvfrom(s Handle, buf []byte, flags int32, from *RawSockaddrAny, fromlen *int32) (n int32, err error) {
+ var _p0 *byte
+ if len(buf) > 0 {
+ _p0 = &buf[0]
+ }
+ r0, _, e1 := syscall.Syscall6(procrecvfrom.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+ n = int32(r0)
+ if n == -1 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func sendto(s Handle, buf []byte, flags int32, to unsafe.Pointer, tolen int32) (err error) {
+ var _p0 *byte
+ if len(buf) > 0 {
+ _p0 = &buf[0]
+ }
+ r1, _, e1 := syscall.Syscall6(procsendto.Addr(), 6, uintptr(s), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(tolen))
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
+ r1, _, e1 := syscall.Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func shutdown(s Handle, how int32) (err error) {
+ r1, _, e1 := syscall.Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
+ if r1 == socket_error {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
+ r0, _, e1 := syscall.Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
+ handle = Handle(r0)
+ if handle == InvalidHandle {
+ err = errnoErr(e1)
}
return
}
@@ -3713,11 +3036,7 @@
func WTSEnumerateSessions(handle Handle, reserved uint32, version uint32, sessions **WTS_SESSION_INFO, count *uint32) (err error) {
r1, _, e1 := syscall.Syscall6(procWTSEnumerateSessionsW.Addr(), 5, uintptr(handle), uintptr(reserved), uintptr(version), uintptr(unsafe.Pointer(sessions)), uintptr(unsafe.Pointer(count)), 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
+ err = errnoErr(e1)
}
return
}
@@ -3727,357 +3046,10 @@
return
}
-func getSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
- r0, _, _ := syscall.Syscall9(procGetSecurityInfo.Addr(), 8, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(sd)), 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
- }
- return
-}
-
-func SetSecurityInfo(handle Handle, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) {
- syscall.Syscall9(procSetSecurityInfo.Addr(), 7, uintptr(handle), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0)
- return
-}
-
-func getNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
- var _p0 *uint16
- _p0, ret = syscall.UTF16PtrFromString(objectName)
- if ret != nil {
- return
- }
- return _getNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl, sd)
-}
-
-func _getNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner **SID, group **SID, dacl **ACL, sacl **ACL, sd **SECURITY_DESCRIPTOR) (ret error) {
- r0, _, _ := syscall.Syscall9(procGetNamedSecurityInfoW.Addr(), 8, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(sd)), 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
- }
- return
-}
-
-func SetNamedSecurityInfo(objectName string, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
- var _p0 *uint16
- _p0, ret = syscall.UTF16PtrFromString(objectName)
- if ret != nil {
- return
- }
- return _SetNamedSecurityInfo(_p0, objectType, securityInformation, owner, group, dacl, sacl)
-}
-
-func _SetNamedSecurityInfo(objectName *uint16, objectType SE_OBJECT_TYPE, securityInformation SECURITY_INFORMATION, owner *SID, group *SID, dacl *ACL, sacl *ACL) (ret error) {
- r0, _, _ := syscall.Syscall9(procSetNamedSecurityInfoW.Addr(), 7, uintptr(unsafe.Pointer(objectName)), uintptr(objectType), uintptr(securityInformation), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(sacl)), 0, 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
- }
- return
-}
-
-func buildSecurityDescriptor(owner *TRUSTEE, group *TRUSTEE, countAccessEntries uint32, accessEntries *EXPLICIT_ACCESS, countAuditEntries uint32, auditEntries *EXPLICIT_ACCESS, oldSecurityDescriptor *SECURITY_DESCRIPTOR, sizeNewSecurityDescriptor *uint32, newSecurityDescriptor **SECURITY_DESCRIPTOR) (ret error) {
- r0, _, _ := syscall.Syscall9(procBuildSecurityDescriptorW.Addr(), 9, uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(group)), uintptr(countAccessEntries), uintptr(unsafe.Pointer(accessEntries)), uintptr(countAuditEntries), uintptr(unsafe.Pointer(auditEntries)), uintptr(unsafe.Pointer(oldSecurityDescriptor)), uintptr(unsafe.Pointer(sizeNewSecurityDescriptor)), uintptr(unsafe.Pointer(newSecurityDescriptor)))
- if r0 != 0 {
- ret = syscall.Errno(r0)
- }
- return
-}
-
-func initializeSecurityDescriptor(absoluteSD *SECURITY_DESCRIPTOR, revision uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procInitializeSecurityDescriptor.Addr(), 2, uintptr(unsafe.Pointer(absoluteSD)), uintptr(revision), 0)
+func WTSQueryUserToken(session uint32, token *Token) (err error) {
+ r1, _, e1 := syscall.Syscall(procWTSQueryUserToken.Addr(), 2, uintptr(session), uintptr(unsafe.Pointer(token)), 0)
if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, control *SECURITY_DESCRIPTOR_CONTROL, revision *uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(control)), uintptr(unsafe.Pointer(revision)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent *bool, dacl **ACL, daclDefaulted *bool) (err error) {
- var _p0 uint32
- if *daclPresent {
- _p0 = 1
- } else {
- _p0 = 0
- }
- var _p1 uint32
- if *daclDefaulted {
- _p1 = 1
- } else {
- _p1 = 0
- }
- r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
- *daclPresent = _p0 != 0
- *daclDefaulted = _p1 != 0
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent *bool, sacl **ACL, saclDefaulted *bool) (err error) {
- var _p0 uint32
- if *saclPresent {
- _p0 = 1
- } else {
- _p0 = 0
- }
- var _p1 uint32
- if *saclDefaulted {
- _p1 = 1
- } else {
- _p1 = 0
- }
- r1, _, e1 := syscall.Syscall6(procGetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(&_p0)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(&_p1)), 0, 0)
- *saclPresent = _p0 != 0
- *saclDefaulted = _p1 != 0
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner **SID, ownerDefaulted *bool) (err error) {
- var _p0 uint32
- if *ownerDefaulted {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(&_p0)))
- *ownerDefaulted = _p0 != 0
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group **SID, groupDefaulted *bool) (err error) {
- var _p0 uint32
- if *groupDefaulted {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall(procGetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(&_p0)))
- *groupDefaulted = _p0 != 0
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func getSecurityDescriptorLength(sd *SECURITY_DESCRIPTOR) (len uint32) {
- r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
- len = uint32(r0)
- return
-}
-
-func getSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) (ret error) {
- r0, _, _ := syscall.Syscall(procGetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
- }
- return
-}
-
-func isValidSecurityDescriptor(sd *SECURITY_DESCRIPTOR) (isValid bool) {
- r0, _, _ := syscall.Syscall(procIsValidSecurityDescriptor.Addr(), 1, uintptr(unsafe.Pointer(sd)), 0, 0)
- isValid = r0 != 0
- return
-}
-
-func setSecurityDescriptorControl(sd *SECURITY_DESCRIPTOR, controlBitsOfInterest SECURITY_DESCRIPTOR_CONTROL, controlBitsToSet SECURITY_DESCRIPTOR_CONTROL) (err error) {
- r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorControl.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(controlBitsOfInterest), uintptr(controlBitsToSet))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func setSecurityDescriptorDacl(sd *SECURITY_DESCRIPTOR, daclPresent bool, dacl *ACL, daclDefaulted bool) (err error) {
- var _p0 uint32
- if daclPresent {
- _p0 = 1
- } else {
- _p0 = 0
- }
- var _p1 uint32
- if daclDefaulted {
- _p1 = 1
- } else {
- _p1 = 0
- }
- r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorDacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(dacl)), uintptr(_p1), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func setSecurityDescriptorSacl(sd *SECURITY_DESCRIPTOR, saclPresent bool, sacl *ACL, saclDefaulted bool) (err error) {
- var _p0 uint32
- if saclPresent {
- _p0 = 1
- } else {
- _p0 = 0
- }
- var _p1 uint32
- if saclDefaulted {
- _p1 = 1
- } else {
- _p1 = 0
- }
- r1, _, e1 := syscall.Syscall6(procSetSecurityDescriptorSacl.Addr(), 4, uintptr(unsafe.Pointer(sd)), uintptr(_p0), uintptr(unsafe.Pointer(sacl)), uintptr(_p1), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func setSecurityDescriptorOwner(sd *SECURITY_DESCRIPTOR, owner *SID, ownerDefaulted bool) (err error) {
- var _p0 uint32
- if ownerDefaulted {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorOwner.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(owner)), uintptr(_p0))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func setSecurityDescriptorGroup(sd *SECURITY_DESCRIPTOR, group *SID, groupDefaulted bool) (err error) {
- var _p0 uint32
- if groupDefaulted {
- _p0 = 1
- } else {
- _p0 = 0
- }
- r1, _, e1 := syscall.Syscall(procSetSecurityDescriptorGroup.Addr(), 3, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(group)), uintptr(_p0))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func setSecurityDescriptorRMControl(sd *SECURITY_DESCRIPTOR, rmControl *uint8) {
- syscall.Syscall(procSetSecurityDescriptorRMControl.Addr(), 2, uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(rmControl)), 0)
- return
-}
-
-func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
- var _p0 *uint16
- _p0, err = syscall.UTF16PtrFromString(str)
- if err != nil {
- return
- }
- return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
-}
-
-func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd **SECURITY_DESCRIPTOR, size *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func convertSecurityDescriptorToStringSecurityDescriptor(sd *SECURITY_DESCRIPTOR, revision uint32, securityInformation SECURITY_INFORMATION, str **uint16, strLen *uint32) (err error) {
- r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(securityInformation), uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(strLen)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func makeAbsoluteSD(selfRelativeSD *SECURITY_DESCRIPTOR, absoluteSD *SECURITY_DESCRIPTOR, absoluteSDSize *uint32, dacl *ACL, daclSize *uint32, sacl *ACL, saclSize *uint32, owner *SID, ownerSize *uint32, group *SID, groupSize *uint32) (err error) {
- r1, _, e1 := syscall.Syscall12(procMakeAbsoluteSD.Addr(), 11, uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(absoluteSDSize)), uintptr(unsafe.Pointer(dacl)), uintptr(unsafe.Pointer(daclSize)), uintptr(unsafe.Pointer(sacl)), uintptr(unsafe.Pointer(saclSize)), uintptr(unsafe.Pointer(owner)), uintptr(unsafe.Pointer(ownerSize)), uintptr(unsafe.Pointer(group)), uintptr(unsafe.Pointer(groupSize)), 0)
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) {
- r1, _, e1 := syscall.Syscall(procMakeSelfRelativeSD.Addr(), 3, uintptr(unsafe.Pointer(absoluteSD)), uintptr(unsafe.Pointer(selfRelativeSD)), uintptr(unsafe.Pointer(selfRelativeSDSize)))
- if r1 == 0 {
- if e1 != 0 {
- err = errnoErr(e1)
- } else {
- err = syscall.EINVAL
- }
- }
- return
-}
-
-func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) {
- r0, _, _ := syscall.Syscall6(procSetEntriesInAclW.Addr(), 4, uintptr(countExplicitEntries), uintptr(unsafe.Pointer(explicitEntries)), uintptr(unsafe.Pointer(oldACL)), uintptr(unsafe.Pointer(newACL)), 0, 0)
- if r0 != 0 {
- ret = syscall.Errno(r0)
+ err = errnoErr(e1)
}
return
}
diff --git a/volume/local/local.go b/volume/local/local.go
index bf97e18..89252cf 100644
--- a/volume/local/local.go
+++ b/volume/local/local.go
@@ -18,8 +18,6 @@
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/quota"
"github.com/docker/docker/volume"
- "github.com/moby/sys/mount"
- "github.com/moby/sys/mountinfo"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -96,9 +94,9 @@
if !reflect.DeepEqual(opts, optsConfig{}) {
v.opts = &opts
}
-
- // unmount anything that may still be mounted (for example, from an unclean shutdown)
- mount.Unmount(v.path)
+ // unmount anything that may still be mounted (for example, from an
+ // unclean shutdown). This is a no-op on windows
+ unmount(v.path)
}
}
@@ -347,18 +345,6 @@
return v.unmount()
}
-func (v *localVolume) unmount() error {
- if v.needsMount() {
- if err := mount.Unmount(v.path); err != nil {
- if mounted, mErr := mountinfo.Mounted(v.path); mounted || mErr != nil {
- return errdefs.System(err)
- }
- }
- v.active.mounted = false
- }
- return nil
-}
-
func (v *localVolume) Status() map[string]interface{} {
return nil
}
diff --git a/volume/local/local_test.go b/volume/local/local_test.go
index ec5cecb..8045e87 100644
--- a/volume/local/local_test.go
+++ b/volume/local/local_test.go
@@ -221,17 +221,17 @@
info := mountInfos[0]
t.Logf("%+v", info)
- if info.Fstype != "tmpfs" {
- t.Fatalf("expected tmpfs mount, got %q", info.Fstype)
+ if info.FSType != "tmpfs" {
+ t.Fatalf("expected tmpfs mount, got %q", info.FSType)
}
if info.Source != "tmpfs" {
t.Fatalf("expected tmpfs mount, got %q", info.Source)
}
- if !strings.Contains(info.VfsOpts, "uid=1000") {
- t.Fatalf("expected mount info to have uid=1000: %q", info.VfsOpts)
+ if !strings.Contains(info.VFSOptions, "uid=1000") {
+ t.Fatalf("expected mount info to have uid=1000: %q", info.VFSOptions)
}
- if !strings.Contains(info.VfsOpts, "size=1024k") {
- t.Fatalf("expected mount info to have size=1024k: %q", info.VfsOpts)
+ if !strings.Contains(info.VFSOptions, "size=1024k") {
+ t.Fatalf("expected mount info to have size=1024k: %q", info.VFSOptions)
}
if v.active.count != 1 {
diff --git a/volume/local/local_unix.go b/volume/local/local_unix.go
index 9d4b37f..c8163cc 100644
--- a/volume/local/local_unix.go
+++ b/volume/local/local_unix.go
@@ -18,6 +18,7 @@
"github.com/docker/docker/quota"
units "github.com/docker/go-units"
"github.com/moby/sys/mount"
+ "github.com/moby/sys/mountinfo"
"github.com/pkg/errors"
)
@@ -111,6 +112,10 @@
return nil
}
+func unmount(path string) {
+ _ = mount.Unmount(path)
+}
+
func (v *localVolume) needsMount() bool {
if v.opts == nil {
return false
@@ -157,6 +162,18 @@
return nil
}
+func (v *localVolume) unmount() error {
+ if v.needsMount() {
+ if err := mount.Unmount(v.path); err != nil {
+ if mounted, mErr := mountinfo.Mounted(v.path); mounted || mErr != nil {
+ return errdefs.System(err)
+ }
+ }
+ v.active.mounted = false
+ }
+ return nil
+}
+
func (v *localVolume) CreatedAt() (time.Time, error) {
fileInfo, err := os.Stat(v.path)
if err != nil {
diff --git a/volume/local/local_windows.go b/volume/local/local_windows.go
index b05510d..9fc2092 100644
--- a/volume/local/local_windows.go
+++ b/volume/local/local_windows.go
@@ -39,6 +39,11 @@
func (v *localVolume) mount() error {
return nil
}
+func (v *localVolume) unmount() error {
+ return nil
+}
+
+func unmount(_ string) {}
func (v *localVolume) postMount() error {
return nil