Merge pull request #735 from rhatdan/vendor
Move to new github.com/sirupsen/logrus.
This commit is contained in:
commit
efce63bdf2
366 changed files with 7104 additions and 2749 deletions
|
@ -3,8 +3,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
systemdDaemon "github.com/coreos/go-systemd/daemon"
|
systemdDaemon "github.com/coreos/go-systemd/daemon"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func sdNotify() {
|
func sdNotify() {
|
||||||
|
|
|
@ -10,11 +10,11 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/storage/pkg/reexec"
|
"github.com/containers/storage/pkg/reexec"
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod"
|
"github.com/kubernetes-incubator/cri-o/libkpod"
|
||||||
"github.com/kubernetes-incubator/cri-o/server"
|
"github.com/kubernetes-incubator/cri-o/server"
|
||||||
"github.com/opencontainers/selinux/go-selinux"
|
"github.com/opencontainers/selinux/go-selinux"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
|
|
@ -11,12 +11,12 @@ import (
|
||||||
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
is "github.com/containers/image/storage"
|
is "github.com/containers/image/storage"
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
units "github.com/docker/go-units"
|
units "github.com/docker/go-units"
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod/common"
|
"github.com/kubernetes-incubator/cri-o/libkpod/common"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/storage/pkg/reexec"
|
"github.com/containers/storage/pkg/reexec"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod/common"
|
"github.com/kubernetes-incubator/cri-o/libkpod/common"
|
||||||
libkpodimage "github.com/kubernetes-incubator/cri-o/libkpod/image"
|
libkpodimage "github.com/kubernetes-incubator/cri-o/libkpod/image"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
libkpodimage "github.com/kubernetes-incubator/cri-o/libkpod/image"
|
libkpodimage "github.com/kubernetes-incubator/cri-o/libkpod/image"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
cstorage "github.com/containers/storage"
|
cstorage "github.com/containers/storage"
|
||||||
"github.com/docker/docker/pkg/registrar"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/kubernetes-incubator/cri-o/pkg/registrar"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -8,19 +8,19 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
cstorage "github.com/containers/storage"
|
cstorage "github.com/containers/storage"
|
||||||
"github.com/docker/docker/pkg/ioutils"
|
"github.com/docker/docker/pkg/ioutils"
|
||||||
"github.com/docker/docker/pkg/registrar"
|
|
||||||
"github.com/docker/docker/pkg/truncindex"
|
"github.com/docker/docker/pkg/truncindex"
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
"github.com/kubernetes-incubator/cri-o/pkg/annotations"
|
"github.com/kubernetes-incubator/cri-o/pkg/annotations"
|
||||||
|
"github.com/kubernetes-incubator/cri-o/pkg/registrar"
|
||||||
"github.com/kubernetes-incubator/cri-o/pkg/storage"
|
"github.com/kubernetes-incubator/cri-o/pkg/storage"
|
||||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -9,7 +10,6 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/image"
|
"github.com/containers/image/image"
|
||||||
is "github.com/containers/image/storage"
|
is "github.com/containers/image/storage"
|
||||||
|
@ -22,6 +22,7 @@ import (
|
||||||
specs "github.com/opencontainers/image-spec/specs-go"
|
specs "github.com/opencontainers/image-spec/specs-go"
|
||||||
"github.com/opencontainers/image-spec/specs-go/v1"
|
"github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CopyRef handles image references used for copying images to/from remotes
|
// CopyRef handles image references used for copying images to/from remotes
|
||||||
|
@ -415,7 +416,7 @@ func (cs *copySource) Reference() types.ImageReference {
|
||||||
return cs.ref
|
return cs.ref
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cs *copySource) GetSignatures() ([][]byte, error) {
|
func (cs *copySource) GetSignatures(context.Context) ([][]byte, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,11 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containernetworking/cni/pkg/ns"
|
"github.com/containernetworking/cni/pkg/ns"
|
||||||
"github.com/docker/docker/pkg/mount"
|
"github.com/docker/docker/pkg/mount"
|
||||||
"github.com/docker/docker/pkg/symlink"
|
"github.com/docker/docker/pkg/symlink"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
|
|
@ -13,9 +13,9 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/utils"
|
"github.com/kubernetes-incubator/cri-o/utils"
|
||||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containernetworking/cni/libcni"
|
"github.com/containernetworking/cni/libcni"
|
||||||
cnitypes "github.com/containernetworking/cni/pkg/types"
|
cnitypes "github.com/containernetworking/cni/pkg/types"
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cniNetworkPlugin struct {
|
type cniNetworkPlugin struct {
|
||||||
|
|
119
pkg/registrar/registrar_test.go
Normal file
119
pkg/registrar/registrar_test.go
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
package registrar
|
||||||
|
|
||||||
|
import (
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestReserve(t *testing.T) {
|
||||||
|
r := NewRegistrar()
|
||||||
|
|
||||||
|
obj := "test1"
|
||||||
|
if err := r.Reserve("test", obj); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := r.Reserve("test", obj); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
obj2 := "test2"
|
||||||
|
err := r.Reserve("test", obj2)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatalf("expected error when reserving an already reserved name to another object")
|
||||||
|
}
|
||||||
|
if err != ErrNameReserved {
|
||||||
|
t.Fatal("expected `ErrNameReserved` error when attempting to reserve an already reserved name")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRelease(t *testing.T) {
|
||||||
|
r := NewRegistrar()
|
||||||
|
obj := "testing"
|
||||||
|
|
||||||
|
if err := r.Reserve("test", obj); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
r.Release("test")
|
||||||
|
r.Release("test") // Ensure there is no panic here
|
||||||
|
|
||||||
|
if err := r.Reserve("test", obj); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetNames(t *testing.T) {
|
||||||
|
r := NewRegistrar()
|
||||||
|
obj := "testing"
|
||||||
|
names := []string{"test1", "test2"}
|
||||||
|
|
||||||
|
for _, name := range names {
|
||||||
|
if err := r.Reserve(name, obj); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r.Reserve("test3", "other")
|
||||||
|
|
||||||
|
names2, err := r.GetNames(obj)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reflect.DeepEqual(names, names2) {
|
||||||
|
t.Fatalf("Exepected: %v, Got: %v", names, names2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDelete(t *testing.T) {
|
||||||
|
r := NewRegistrar()
|
||||||
|
obj := "testing"
|
||||||
|
names := []string{"test1", "test2"}
|
||||||
|
for _, name := range names {
|
||||||
|
if err := r.Reserve(name, obj); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r.Reserve("test3", "other")
|
||||||
|
r.Delete(obj)
|
||||||
|
|
||||||
|
_, err := r.GetNames(obj)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected error getting names for deleted key")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != ErrNoSuchKey {
|
||||||
|
t.Fatal("expected `ErrNoSuchKey`")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGet(t *testing.T) {
|
||||||
|
r := NewRegistrar()
|
||||||
|
obj := "testing"
|
||||||
|
name := "test"
|
||||||
|
|
||||||
|
_, err := r.Get(name)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected error when key does not exist")
|
||||||
|
}
|
||||||
|
if err != ErrNameNotReserved {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := r.Reserve(name, obj); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = r.Get(name); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
r.Delete(obj)
|
||||||
|
_, err = r.Get(name)
|
||||||
|
if err == nil {
|
||||||
|
t.Fatal("expected error when key does not exist")
|
||||||
|
}
|
||||||
|
if err != ErrNameNotReserved {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/copy"
|
"github.com/containers/image/copy"
|
||||||
istorage "github.com/containers/image/storage"
|
istorage "github.com/containers/image/storage"
|
||||||
"github.com/containers/image/transports/alltransports"
|
"github.com/containers/image/transports/alltransports"
|
||||||
|
@ -13,6 +12,7 @@ import (
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/opencontainers/image-spec/specs-go/v1"
|
"github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
"github.com/kubernetes-incubator/cri-o/utils"
|
"github.com/kubernetes-incubator/cri-o/utils"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
"github.com/docker/docker/pkg/symlink"
|
"github.com/docker/docker/pkg/symlink"
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod"
|
"github.com/kubernetes-incubator/cri-o/libkpod"
|
||||||
|
@ -28,6 +27,7 @@ import (
|
||||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/opencontainers/runtime-tools/generate"
|
"github.com/opencontainers/runtime-tools/generate"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
|
|
@ -6,9 +6,9 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/docker/docker/pkg/pools"
|
"github.com/docker/docker/pkg/pools"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
|
|
|
@ -3,8 +3,8 @@ package server
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
|
|
@ -7,9 +7,9 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/docker/docker/pkg/pools"
|
"github.com/docker/docker/pkg/pools"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,8 +3,8 @@ package server
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,8 +3,8 @@ package server
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,10 +4,10 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
rspec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,8 +3,8 @@ package server
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/copy"
|
"github.com/containers/image/copy"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,9 +4,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
|
|
@ -3,12 +3,12 @@ package server
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
pkgstorage "github.com/kubernetes-incubator/cri-o/pkg/storage"
|
pkgstorage "github.com/kubernetes-incubator/cri-o/pkg/storage"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -11,7 +11,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
@ -20,6 +19,7 @@ import (
|
||||||
"github.com/opencontainers/runtime-tools/generate"
|
"github.com/opencontainers/runtime-tools/generate"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
"k8s.io/kubernetes/pkg/api/v1"
|
"k8s.io/kubernetes/pkg/api/v1"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/storage"
|
"github.com/containers/storage"
|
||||||
"github.com/docker/docker/pkg/mount"
|
"github.com/docker/docker/pkg/mount"
|
||||||
"github.com/docker/docker/pkg/symlink"
|
"github.com/docker/docker/pkg/symlink"
|
||||||
|
@ -12,6 +11,7 @@ import (
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
"github.com/opencontainers/selinux/go-selinux/label"
|
"github.com/opencontainers/selinux/go-selinux/label"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod"
|
"github.com/kubernetes-incubator/cri-o/libkpod"
|
||||||
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
||||||
"github.com/kubernetes-incubator/cri-o/oci"
|
"github.com/kubernetes-incubator/cri-o/oci"
|
||||||
|
@ -17,6 +16,7 @@ import (
|
||||||
"github.com/kubernetes-incubator/cri-o/server/apparmor"
|
"github.com/kubernetes-incubator/cri-o/server/apparmor"
|
||||||
"github.com/kubernetes-incubator/cri-o/server/seccomp"
|
"github.com/kubernetes-incubator/cri-o/server/seccomp"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
knet "k8s.io/apimachinery/pkg/util/net"
|
knet "k8s.io/apimachinery/pkg/util/net"
|
||||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/network/hostport"
|
"k8s.io/kubernetes/pkg/kubelet/network/hostport"
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/storage"
|
"github.com/containers/image/storage"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
sstorage "github.com/containers/storage"
|
sstorage "github.com/containers/storage"
|
||||||
|
@ -16,6 +15,7 @@ import (
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
specs "github.com/opencontainers/image-spec/specs-go"
|
specs "github.com/opencontainers/image-spec/specs-go"
|
||||||
"github.com/opencontainers/image-spec/specs-go/v1"
|
"github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/copy"
|
"github.com/containers/image/copy"
|
||||||
"github.com/containers/image/signature"
|
"github.com/containers/image/signature"
|
||||||
"github.com/containers/image/storage"
|
"github.com/containers/image/storage"
|
||||||
|
@ -11,6 +10,7 @@ import (
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
sstorage "github.com/containers/storage"
|
sstorage "github.com/containers/storage"
|
||||||
"github.com/containers/storage/pkg/reexec"
|
"github.com/containers/storage/pkg/reexec"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
22
vendor.conf
22
vendor.conf
|
@ -4,16 +4,16 @@ k8s.io/client-go v3.0.0-beta.0 https://github.com/kubernetes/client-go
|
||||||
k8s.io/apimachinery release-1.6 https://github.com/kubernetes/apimachinery
|
k8s.io/apimachinery release-1.6 https://github.com/kubernetes/apimachinery
|
||||||
k8s.io/apiserver release-1.6 https://github.com/kubernetes/apiserver
|
k8s.io/apiserver release-1.6 https://github.com/kubernetes/apiserver
|
||||||
#
|
#
|
||||||
github.com/Sirupsen/logrus v0.11.5
|
github.com/sirupsen/logrus v1.0.0
|
||||||
github.com/containers/image 106607808da3cff168be56821e994611c919d283
|
github.com/containers/image 74e359348c7ce9e0caf4fa75aa8de3809cf41c46
|
||||||
github.com/ostreedev/ostree-go master
|
github.com/ostreedev/ostree-go master
|
||||||
github.com/containers/storage 5d8c2f87387fa5be9fa526ae39fbd79b8bdf27be
|
github.com/containers/storage f8cff0727cf0802f0752ca58d2c05ec5270a47d5
|
||||||
github.com/containernetworking/cni v0.4.0
|
github.com/containernetworking/cni v0.4.0
|
||||||
google.golang.org/grpc v1.0.1-GA https://github.com/grpc/grpc-go
|
google.golang.org/grpc v1.0.1-GA https://github.com/grpc/grpc-go
|
||||||
github.com/opencontainers/selinux v1.0.0-rc1
|
github.com/opencontainers/selinux v1.0.0-rc1
|
||||||
github.com/opencontainers/go-digest v1.0.0-rc0
|
github.com/opencontainers/go-digest v1.0.0-rc0
|
||||||
github.com/opencontainers/runtime-tools 20db5990713e97e64bc2d340531d61f2edf4cccb
|
github.com/opencontainers/runtime-tools 6bcd3b417fd6962ea04dafdbc2c07444e750572d
|
||||||
github.com/opencontainers/runc c5ec25487693612aed95673800863e134785f946
|
github.com/opencontainers/runc 45bde006ca8c90e089894508708bcf0e2cdf9e13
|
||||||
github.com/opencontainers/image-spec v1.0.0
|
github.com/opencontainers/image-spec v1.0.0
|
||||||
github.com/opencontainers/runtime-spec v1.0.0
|
github.com/opencontainers/runtime-spec v1.0.0
|
||||||
github.com/juju/ratelimit acf38b000a03e4ab89e40f20f1e548f4e6ac7f72
|
github.com/juju/ratelimit acf38b000a03e4ab89e40f20f1e548f4e6ac7f72
|
||||||
|
@ -21,11 +21,11 @@ github.com/tchap/go-patricia v2.2.6
|
||||||
gopkg.in/cheggaaa/pb.v1 v1.0.7
|
gopkg.in/cheggaaa/pb.v1 v1.0.7
|
||||||
gopkg.in/inf.v0 v0.9.0
|
gopkg.in/inf.v0 v0.9.0
|
||||||
gopkg.in/yaml.v2 v2
|
gopkg.in/yaml.v2 v2
|
||||||
github.com/docker/docker v1.13.1
|
github.com/docker/docker d4f6db83c21cfc6af54fffb1f13e8acb7199f96a
|
||||||
github.com/docker/spdystream ed496381df8283605c435b86d4fdd6f4f20b8c6e
|
github.com/docker/spdystream ed496381df8283605c435b86d4fdd6f4f20b8c6e
|
||||||
github.com/docker/distribution fb0bebc4b64e3881cc52a2478d749845ed76d2a8
|
github.com/docker/distribution 7a8efe719e55bbfaff7bc5718cdf0ed51ca821df
|
||||||
github.com/docker/go-units v0.3.1
|
github.com/docker/go-units v0.3.1
|
||||||
github.com/docker/go-connections e15c02316c12de00874640cd76311849de2aeed5
|
github.com/docker/go-connections 3ede32e2033de7505e6500d6c868c2b9ed9f169d
|
||||||
github.com/docker/libtrust aabc10ec26b754e797f9028f4589c5b7bd90dc20
|
github.com/docker/libtrust aabc10ec26b754e797f9028f4589c5b7bd90dc20
|
||||||
github.com/mistifyio/go-zfs v2.1.1
|
github.com/mistifyio/go-zfs v2.1.1
|
||||||
github.com/ghodss/yaml 04f313413ffd65ce25f2541bfd2b2ceec5c0908c
|
github.com/ghodss/yaml 04f313413ffd65ce25f2541bfd2b2ceec5c0908c
|
||||||
|
@ -63,9 +63,9 @@ github.com/coreos/pkg v3
|
||||||
github.com/golang/groupcache b710c8433bd175204919eb38776e944233235d03
|
github.com/golang/groupcache b710c8433bd175204919eb38776e944233235d03
|
||||||
github.com/fsnotify/fsnotify 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1
|
github.com/fsnotify/fsnotify 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1
|
||||||
github.com/emicklei/go-restful 09691a3b6378b740595c1002f40c34dd5f218a22
|
github.com/emicklei/go-restful 09691a3b6378b740595c1002f40c34dd5f218a22
|
||||||
github.com/Azure/go-ansiterm fa152c58bc15761d0200cb75fe958b89a9d4888e
|
github.com/Azure/go-ansiterm 19f72df4d05d31cbe1c56bfc8045c96babff6c7e
|
||||||
github.com/Microsoft/go-winio v0.3.7
|
github.com/Microsoft/go-winio 78439966b38d69bf38227fbf57ac8a6fee70f69a
|
||||||
github.com/Microsoft/hcsshim v0.5.11
|
github.com/Microsoft/hcsshim 43f9725307998e09f2e3816c2c0c36dc98f0c982
|
||||||
github.com/pkg/errors v0.8.0
|
github.com/pkg/errors v0.8.0
|
||||||
github.com/godbus/dbus v4.0.0
|
github.com/godbus/dbus v4.0.0
|
||||||
github.com/urfave/cli v1.19.1
|
github.com/urfave/cli v1.19.1
|
||||||
|
|
2
vendor/github.com/Azure/go-ansiterm/parser.go
generated
vendored
2
vendor/github.com/Azure/go-ansiterm/parser.go
generated
vendored
|
@ -5,7 +5,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var logger *logrus.Logger
|
var logger *logrus.Logger
|
||||||
|
|
2
vendor/github.com/Azure/go-ansiterm/winterm/win_event_handler.go
generated
vendored
2
vendor/github.com/Azure/go-ansiterm/winterm/win_event_handler.go
generated
vendored
|
@ -9,7 +9,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/Azure/go-ansiterm"
|
"github.com/Azure/go-ansiterm"
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var logger *logrus.Logger
|
var logger *logrus.Logger
|
||||||
|
|
20
vendor/github.com/Microsoft/go-winio/backup.go
generated
vendored
20
vendor/github.com/Microsoft/go-winio/backup.go
generated
vendored
|
@ -68,10 +68,20 @@ func NewBackupStreamReader(r io.Reader) *BackupStreamReader {
|
||||||
return &BackupStreamReader{r, 0}
|
return &BackupStreamReader{r, 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next returns the next backup stream and prepares for calls to Write(). It skips the remainder of the current stream if
|
// Next returns the next backup stream and prepares for calls to Read(). It skips the remainder of the current stream if
|
||||||
// it was not completely read.
|
// it was not completely read.
|
||||||
func (r *BackupStreamReader) Next() (*BackupHeader, error) {
|
func (r *BackupStreamReader) Next() (*BackupHeader, error) {
|
||||||
if r.bytesLeft > 0 {
|
if r.bytesLeft > 0 {
|
||||||
|
if s, ok := r.r.(io.Seeker); ok {
|
||||||
|
// Make sure Seek on io.SeekCurrent sometimes succeeds
|
||||||
|
// before trying the actual seek.
|
||||||
|
if _, err := s.Seek(0, io.SeekCurrent); err == nil {
|
||||||
|
if _, err = s.Seek(r.bytesLeft, io.SeekCurrent); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
r.bytesLeft = 0
|
||||||
|
}
|
||||||
|
}
|
||||||
if _, err := io.Copy(ioutil.Discard, r); err != nil {
|
if _, err := io.Copy(ioutil.Discard, r); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -185,7 +195,6 @@ type BackupFileReader struct {
|
||||||
// Read will attempt to read the security descriptor of the file.
|
// Read will attempt to read the security descriptor of the file.
|
||||||
func NewBackupFileReader(f *os.File, includeSecurity bool) *BackupFileReader {
|
func NewBackupFileReader(f *os.File, includeSecurity bool) *BackupFileReader {
|
||||||
r := &BackupFileReader{f, includeSecurity, 0}
|
r := &BackupFileReader{f, includeSecurity, 0}
|
||||||
runtime.SetFinalizer(r, func(r *BackupFileReader) { r.Close() })
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +205,7 @@ func (r *BackupFileReader) Read(b []byte) (int, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, &os.PathError{"BackupRead", r.f.Name(), err}
|
return 0, &os.PathError{"BackupRead", r.f.Name(), err}
|
||||||
}
|
}
|
||||||
|
runtime.KeepAlive(r.f)
|
||||||
if bytesRead == 0 {
|
if bytesRead == 0 {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
|
@ -207,6 +217,7 @@ func (r *BackupFileReader) Read(b []byte) (int, error) {
|
||||||
func (r *BackupFileReader) Close() error {
|
func (r *BackupFileReader) Close() error {
|
||||||
if r.ctx != 0 {
|
if r.ctx != 0 {
|
||||||
backupRead(syscall.Handle(r.f.Fd()), nil, nil, true, false, &r.ctx)
|
backupRead(syscall.Handle(r.f.Fd()), nil, nil, true, false, &r.ctx)
|
||||||
|
runtime.KeepAlive(r.f)
|
||||||
r.ctx = 0
|
r.ctx = 0
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -219,11 +230,10 @@ type BackupFileWriter struct {
|
||||||
ctx uintptr
|
ctx uintptr
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBackupFileWrtier returns a new BackupFileWriter from a file handle. If includeSecurity is true,
|
// NewBackupFileWriter returns a new BackupFileWriter from a file handle. If includeSecurity is true,
|
||||||
// Write() will attempt to restore the security descriptor from the stream.
|
// Write() will attempt to restore the security descriptor from the stream.
|
||||||
func NewBackupFileWriter(f *os.File, includeSecurity bool) *BackupFileWriter {
|
func NewBackupFileWriter(f *os.File, includeSecurity bool) *BackupFileWriter {
|
||||||
w := &BackupFileWriter{f, includeSecurity, 0}
|
w := &BackupFileWriter{f, includeSecurity, 0}
|
||||||
runtime.SetFinalizer(w, func(w *BackupFileWriter) { w.Close() })
|
|
||||||
return w
|
return w
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +244,7 @@ func (w *BackupFileWriter) Write(b []byte) (int, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, &os.PathError{"BackupWrite", w.f.Name(), err}
|
return 0, &os.PathError{"BackupWrite", w.f.Name(), err}
|
||||||
}
|
}
|
||||||
|
runtime.KeepAlive(w.f)
|
||||||
if int(bytesWritten) != len(b) {
|
if int(bytesWritten) != len(b) {
|
||||||
return int(bytesWritten), errors.New("not all bytes could be written")
|
return int(bytesWritten), errors.New("not all bytes could be written")
|
||||||
}
|
}
|
||||||
|
@ -245,6 +256,7 @@ func (w *BackupFileWriter) Write(b []byte) (int, error) {
|
||||||
func (w *BackupFileWriter) Close() error {
|
func (w *BackupFileWriter) Close() error {
|
||||||
if w.ctx != 0 {
|
if w.ctx != 0 {
|
||||||
backupWrite(syscall.Handle(w.f.Fd()), nil, nil, true, false, &w.ctx)
|
backupWrite(syscall.Handle(w.f.Fd()), nil, nil, true, false, &w.ctx)
|
||||||
|
runtime.KeepAlive(w.f)
|
||||||
w.ctx = 0
|
w.ctx = 0
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
94
vendor/github.com/Microsoft/go-winio/backuptar/tar.go
generated
vendored
94
vendor/github.com/Microsoft/go-winio/backuptar/tar.go
generated
vendored
|
@ -36,6 +36,7 @@ const (
|
||||||
hdrSecurityDescriptor = "sd"
|
hdrSecurityDescriptor = "sd"
|
||||||
hdrRawSecurityDescriptor = "rawsd"
|
hdrRawSecurityDescriptor = "rawsd"
|
||||||
hdrMountPoint = "mountpoint"
|
hdrMountPoint = "mountpoint"
|
||||||
|
hdrEaPrefix = "xattr."
|
||||||
)
|
)
|
||||||
|
|
||||||
func writeZeroes(w io.Writer, count int64) error {
|
func writeZeroes(w io.Writer, count int64) error {
|
||||||
|
@ -118,6 +119,21 @@ func BasicInfoHeader(name string, size int64, fileInfo *winio.FileBasicInfo) *ta
|
||||||
func WriteTarFileFromBackupStream(t *tar.Writer, r io.Reader, name string, size int64, fileInfo *winio.FileBasicInfo) error {
|
func WriteTarFileFromBackupStream(t *tar.Writer, r io.Reader, name string, size int64, fileInfo *winio.FileBasicInfo) error {
|
||||||
name = filepath.ToSlash(name)
|
name = filepath.ToSlash(name)
|
||||||
hdr := BasicInfoHeader(name, size, fileInfo)
|
hdr := BasicInfoHeader(name, size, fileInfo)
|
||||||
|
|
||||||
|
// If r can be seeked, then this function is two-pass: pass 1 collects the
|
||||||
|
// tar header data, and pass 2 copies the data stream. If r cannot be
|
||||||
|
// seeked, then some header data (in particular EAs) will be silently lost.
|
||||||
|
var (
|
||||||
|
restartPos int64
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
sr, readTwice := r.(io.Seeker)
|
||||||
|
if readTwice {
|
||||||
|
if restartPos, err = sr.Seek(0, io.SeekCurrent); err != nil {
|
||||||
|
readTwice = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
br := winio.NewBackupStreamReader(r)
|
br := winio.NewBackupStreamReader(r)
|
||||||
var dataHdr *winio.BackupHeader
|
var dataHdr *winio.BackupHeader
|
||||||
for dataHdr == nil {
|
for dataHdr == nil {
|
||||||
|
@ -131,7 +147,9 @@ func WriteTarFileFromBackupStream(t *tar.Writer, r io.Reader, name string, size
|
||||||
switch bhdr.Id {
|
switch bhdr.Id {
|
||||||
case winio.BackupData:
|
case winio.BackupData:
|
||||||
hdr.Mode |= c_ISREG
|
hdr.Mode |= c_ISREG
|
||||||
dataHdr = bhdr
|
if !readTwice {
|
||||||
|
dataHdr = bhdr
|
||||||
|
}
|
||||||
case winio.BackupSecurity:
|
case winio.BackupSecurity:
|
||||||
sd, err := ioutil.ReadAll(br)
|
sd, err := ioutil.ReadAll(br)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -151,18 +169,54 @@ func WriteTarFileFromBackupStream(t *tar.Writer, r io.Reader, name string, size
|
||||||
hdr.Winheaders[hdrMountPoint] = "1"
|
hdr.Winheaders[hdrMountPoint] = "1"
|
||||||
}
|
}
|
||||||
hdr.Linkname = rp.Target
|
hdr.Linkname = rp.Target
|
||||||
case winio.BackupEaData, winio.BackupLink, winio.BackupPropertyData, winio.BackupObjectId, winio.BackupTxfsData:
|
|
||||||
|
case winio.BackupEaData:
|
||||||
|
eab, err := ioutil.ReadAll(br)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
eas, err := winio.DecodeExtendedAttributes(eab)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, ea := range eas {
|
||||||
|
// Use base64 encoding for the binary value. Note that there
|
||||||
|
// is no way to encode the EA's flags, since their use doesn't
|
||||||
|
// make any sense for persisted EAs.
|
||||||
|
hdr.Winheaders[hdrEaPrefix+ea.Name] = base64.StdEncoding.EncodeToString(ea.Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
case winio.BackupAlternateData, winio.BackupLink, winio.BackupPropertyData, winio.BackupObjectId, winio.BackupTxfsData:
|
||||||
// ignore these streams
|
// ignore these streams
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("%s: unknown stream ID %d", name, bhdr.Id)
|
return fmt.Errorf("%s: unknown stream ID %d", name, bhdr.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := t.WriteHeader(hdr)
|
err = t.WriteHeader(hdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if readTwice {
|
||||||
|
// Get back to the data stream.
|
||||||
|
if _, err = sr.Seek(restartPos, io.SeekStart); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for dataHdr == nil {
|
||||||
|
bhdr, err := br.Next()
|
||||||
|
if err == io.EOF {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if bhdr.Id == winio.BackupData {
|
||||||
|
dataHdr = bhdr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if dataHdr != nil {
|
if dataHdr != nil {
|
||||||
// A data stream was found. Copy the data.
|
// A data stream was found. Copy the data.
|
||||||
if (dataHdr.Attributes & winio.StreamSparseAttributes) == 0 {
|
if (dataHdr.Attributes & winio.StreamSparseAttributes) == 0 {
|
||||||
|
@ -293,6 +347,38 @@ func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) (
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var eas []winio.ExtendedAttribute
|
||||||
|
for k, v := range hdr.Winheaders {
|
||||||
|
if !strings.HasPrefix(k, hdrEaPrefix) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
data, err := base64.StdEncoding.DecodeString(v)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
eas = append(eas, winio.ExtendedAttribute{
|
||||||
|
Name: k[len(hdrEaPrefix):],
|
||||||
|
Value: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if len(eas) != 0 {
|
||||||
|
eadata, err := winio.EncodeExtendedAttributes(eas)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
bhdr := winio.BackupHeader{
|
||||||
|
Id: winio.BackupEaData,
|
||||||
|
Size: int64(len(eadata)),
|
||||||
|
}
|
||||||
|
err = bw.WriteHeader(&bhdr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, err = bw.Write(eadata)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
if hdr.Typeflag == tar.TypeSymlink {
|
if hdr.Typeflag == tar.TypeSymlink {
|
||||||
_, isMountPoint := hdr.Winheaders[hdrMountPoint]
|
_, isMountPoint := hdr.Winheaders[hdrMountPoint]
|
||||||
rp := winio.ReparsePoint{
|
rp := winio.ReparsePoint{
|
||||||
|
@ -339,7 +425,7 @@ func WriteBackupStreamFromTarFile(w io.Writer, t *tar.Reader, hdr *tar.Header) (
|
||||||
bhdr := winio.BackupHeader{
|
bhdr := winio.BackupHeader{
|
||||||
Id: winio.BackupAlternateData,
|
Id: winio.BackupAlternateData,
|
||||||
Size: ahdr.Size,
|
Size: ahdr.Size,
|
||||||
Name: ahdr.Name[len(hdr.Name)+1:] + ":$DATA",
|
Name: ahdr.Name[len(hdr.Name):] + ":$DATA",
|
||||||
}
|
}
|
||||||
err = bw.WriteHeader(&bhdr)
|
err = bw.WriteHeader(&bhdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
137
vendor/github.com/Microsoft/go-winio/ea.go
generated
vendored
Normal file
137
vendor/github.com/Microsoft/go-winio/ea.go
generated
vendored
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
package winio
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type fileFullEaInformation struct {
|
||||||
|
NextEntryOffset uint32
|
||||||
|
Flags uint8
|
||||||
|
NameLength uint8
|
||||||
|
ValueLength uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
fileFullEaInformationSize = binary.Size(&fileFullEaInformation{})
|
||||||
|
|
||||||
|
errInvalidEaBuffer = errors.New("invalid extended attribute buffer")
|
||||||
|
errEaNameTooLarge = errors.New("extended attribute name too large")
|
||||||
|
errEaValueTooLarge = errors.New("extended attribute value too large")
|
||||||
|
)
|
||||||
|
|
||||||
|
// ExtendedAttribute represents a single Windows EA.
|
||||||
|
type ExtendedAttribute struct {
|
||||||
|
Name string
|
||||||
|
Value []byte
|
||||||
|
Flags uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseEa(b []byte) (ea ExtendedAttribute, nb []byte, err error) {
|
||||||
|
var info fileFullEaInformation
|
||||||
|
err = binary.Read(bytes.NewReader(b), binary.LittleEndian, &info)
|
||||||
|
if err != nil {
|
||||||
|
err = errInvalidEaBuffer
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
nameOffset := fileFullEaInformationSize
|
||||||
|
nameLen := int(info.NameLength)
|
||||||
|
valueOffset := nameOffset + int(info.NameLength) + 1
|
||||||
|
valueLen := int(info.ValueLength)
|
||||||
|
nextOffset := int(info.NextEntryOffset)
|
||||||
|
if valueLen+valueOffset > len(b) || nextOffset < 0 || nextOffset > len(b) {
|
||||||
|
err = errInvalidEaBuffer
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ea.Name = string(b[nameOffset : nameOffset+nameLen])
|
||||||
|
ea.Value = b[valueOffset : valueOffset+valueLen]
|
||||||
|
ea.Flags = info.Flags
|
||||||
|
if info.NextEntryOffset != 0 {
|
||||||
|
nb = b[info.NextEntryOffset:]
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DecodeExtendedAttributes decodes a list of EAs from a FILE_FULL_EA_INFORMATION
|
||||||
|
// buffer retrieved from BackupRead, ZwQueryEaFile, etc.
|
||||||
|
func DecodeExtendedAttributes(b []byte) (eas []ExtendedAttribute, err error) {
|
||||||
|
for len(b) != 0 {
|
||||||
|
ea, nb, err := parseEa(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
eas = append(eas, ea)
|
||||||
|
b = nb
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeEa(buf *bytes.Buffer, ea *ExtendedAttribute, last bool) error {
|
||||||
|
if int(uint8(len(ea.Name))) != len(ea.Name) {
|
||||||
|
return errEaNameTooLarge
|
||||||
|
}
|
||||||
|
if int(uint16(len(ea.Value))) != len(ea.Value) {
|
||||||
|
return errEaValueTooLarge
|
||||||
|
}
|
||||||
|
entrySize := uint32(fileFullEaInformationSize + len(ea.Name) + 1 + len(ea.Value))
|
||||||
|
withPadding := (entrySize + 3) &^ 3
|
||||||
|
nextOffset := uint32(0)
|
||||||
|
if !last {
|
||||||
|
nextOffset = withPadding
|
||||||
|
}
|
||||||
|
info := fileFullEaInformation{
|
||||||
|
NextEntryOffset: nextOffset,
|
||||||
|
Flags: ea.Flags,
|
||||||
|
NameLength: uint8(len(ea.Name)),
|
||||||
|
ValueLength: uint16(len(ea.Value)),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := binary.Write(buf, binary.LittleEndian, &info)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = buf.Write([]byte(ea.Name))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = buf.WriteByte(0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = buf.Write(ea.Value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = buf.Write([]byte{0, 0, 0}[0 : withPadding-entrySize])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EncodeExtendedAttributes encodes a list of EAs into a FILE_FULL_EA_INFORMATION
|
||||||
|
// buffer for use with BackupWrite, ZwSetEaFile, etc.
|
||||||
|
func EncodeExtendedAttributes(eas []ExtendedAttribute) ([]byte, error) {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
for i := range eas {
|
||||||
|
last := false
|
||||||
|
if i == len(eas)-1 {
|
||||||
|
last = true
|
||||||
|
}
|
||||||
|
|
||||||
|
err := writeEa(&buf, &eas[i], last)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf.Bytes(), nil
|
||||||
|
}
|
189
vendor/github.com/Microsoft/go-winio/file.go
generated
vendored
189
vendor/github.com/Microsoft/go-winio/file.go
generated
vendored
|
@ -7,6 +7,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -17,6 +18,19 @@ import (
|
||||||
//sys setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) = SetFileCompletionNotificationModes
|
//sys setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) = SetFileCompletionNotificationModes
|
||||||
//sys timeBeginPeriod(period uint32) (n int32) = winmm.timeBeginPeriod
|
//sys timeBeginPeriod(period uint32) (n int32) = winmm.timeBeginPeriod
|
||||||
|
|
||||||
|
type atomicBool int32
|
||||||
|
|
||||||
|
func (b *atomicBool) isSet() bool { return atomic.LoadInt32((*int32)(b)) != 0 }
|
||||||
|
func (b *atomicBool) setFalse() { atomic.StoreInt32((*int32)(b), 0) }
|
||||||
|
func (b *atomicBool) setTrue() { atomic.StoreInt32((*int32)(b), 1) }
|
||||||
|
func (b *atomicBool) swap(new bool) bool {
|
||||||
|
var newInt int32
|
||||||
|
if new {
|
||||||
|
newInt = 1
|
||||||
|
}
|
||||||
|
return atomic.SwapInt32((*int32)(b), newInt) == 1
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
cFILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
|
cFILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
|
||||||
cFILE_SKIP_SET_EVENT_ON_HANDLE = 2
|
cFILE_SKIP_SET_EVENT_ON_HANDLE = 2
|
||||||
|
@ -33,6 +47,8 @@ func (e *timeoutError) Error() string { return "i/o timeout" }
|
||||||
func (e *timeoutError) Timeout() bool { return true }
|
func (e *timeoutError) Timeout() bool { return true }
|
||||||
func (e *timeoutError) Temporary() bool { return true }
|
func (e *timeoutError) Temporary() bool { return true }
|
||||||
|
|
||||||
|
type timeoutChan chan struct{}
|
||||||
|
|
||||||
var ioInitOnce sync.Once
|
var ioInitOnce sync.Once
|
||||||
var ioCompletionPort syscall.Handle
|
var ioCompletionPort syscall.Handle
|
||||||
|
|
||||||
|
@ -62,9 +78,18 @@ func initIo() {
|
||||||
type win32File struct {
|
type win32File struct {
|
||||||
handle syscall.Handle
|
handle syscall.Handle
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
closing bool
|
wgLock sync.RWMutex
|
||||||
readDeadline time.Time
|
closing atomicBool
|
||||||
writeDeadline time.Time
|
readDeadline deadlineHandler
|
||||||
|
writeDeadline deadlineHandler
|
||||||
|
}
|
||||||
|
|
||||||
|
type deadlineHandler struct {
|
||||||
|
setLock sync.Mutex
|
||||||
|
channel timeoutChan
|
||||||
|
channelLock sync.RWMutex
|
||||||
|
timer *time.Timer
|
||||||
|
timedout atomicBool
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeWin32File makes a new win32File from an existing file handle
|
// makeWin32File makes a new win32File from an existing file handle
|
||||||
|
@ -79,7 +104,8 @@ func makeWin32File(h syscall.Handle) (*win32File, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
runtime.SetFinalizer(f, (*win32File).closeHandle)
|
f.readDeadline.channel = make(timeoutChan)
|
||||||
|
f.writeDeadline.channel = make(timeoutChan)
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,30 +115,37 @@ func MakeOpenFile(h syscall.Handle) (io.ReadWriteCloser, error) {
|
||||||
|
|
||||||
// closeHandle closes the resources associated with a Win32 handle
|
// closeHandle closes the resources associated with a Win32 handle
|
||||||
func (f *win32File) closeHandle() {
|
func (f *win32File) closeHandle() {
|
||||||
if !f.closing {
|
f.wgLock.Lock()
|
||||||
|
// Atomically set that we are closing, releasing the resources only once.
|
||||||
|
if !f.closing.swap(true) {
|
||||||
|
f.wgLock.Unlock()
|
||||||
// cancel all IO and wait for it to complete
|
// cancel all IO and wait for it to complete
|
||||||
f.closing = true
|
|
||||||
cancelIoEx(f.handle, nil)
|
cancelIoEx(f.handle, nil)
|
||||||
f.wg.Wait()
|
f.wg.Wait()
|
||||||
// at this point, no new IO can start
|
// at this point, no new IO can start
|
||||||
syscall.Close(f.handle)
|
syscall.Close(f.handle)
|
||||||
f.handle = 0
|
f.handle = 0
|
||||||
|
} else {
|
||||||
|
f.wgLock.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close closes a win32File.
|
// Close closes a win32File.
|
||||||
func (f *win32File) Close() error {
|
func (f *win32File) Close() error {
|
||||||
f.closeHandle()
|
f.closeHandle()
|
||||||
runtime.SetFinalizer(f, nil)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepareIo prepares for a new IO operation
|
// prepareIo prepares for a new IO operation.
|
||||||
|
// The caller must call f.wg.Done() when the IO is finished, prior to Close() returning.
|
||||||
func (f *win32File) prepareIo() (*ioOperation, error) {
|
func (f *win32File) prepareIo() (*ioOperation, error) {
|
||||||
f.wg.Add(1)
|
f.wgLock.RLock()
|
||||||
if f.closing {
|
if f.closing.isSet() {
|
||||||
|
f.wgLock.RUnlock()
|
||||||
return nil, ErrFileClosed
|
return nil, ErrFileClosed
|
||||||
}
|
}
|
||||||
|
f.wg.Add(1)
|
||||||
|
f.wgLock.RUnlock()
|
||||||
c := &ioOperation{}
|
c := &ioOperation{}
|
||||||
c.ch = make(chan ioResult)
|
c.ch = make(chan ioResult)
|
||||||
return c, nil
|
return c, nil
|
||||||
|
@ -136,47 +169,45 @@ func ioCompletionProcessor(h syscall.Handle) {
|
||||||
|
|
||||||
// asyncIo processes the return value from ReadFile or WriteFile, blocking until
|
// asyncIo processes the return value from ReadFile or WriteFile, blocking until
|
||||||
// the operation has actually completed.
|
// the operation has actually completed.
|
||||||
func (f *win32File) asyncIo(c *ioOperation, deadline time.Time, bytes uint32, err error) (int, error) {
|
func (f *win32File) asyncIo(c *ioOperation, d *deadlineHandler, bytes uint32, err error) (int, error) {
|
||||||
if err != syscall.ERROR_IO_PENDING {
|
if err != syscall.ERROR_IO_PENDING {
|
||||||
f.wg.Done()
|
|
||||||
return int(bytes), err
|
return int(bytes), err
|
||||||
} else {
|
}
|
||||||
var r ioResult
|
|
||||||
wait := true
|
if f.closing.isSet() {
|
||||||
timedout := false
|
cancelIoEx(f.handle, &c.o)
|
||||||
if f.closing {
|
}
|
||||||
cancelIoEx(f.handle, &c.o)
|
|
||||||
} else if !deadline.IsZero() {
|
var timeout timeoutChan
|
||||||
now := time.Now()
|
if d != nil {
|
||||||
if !deadline.After(now) {
|
d.channelLock.Lock()
|
||||||
timedout = true
|
timeout = d.channel
|
||||||
} else {
|
d.channelLock.Unlock()
|
||||||
timeout := time.After(deadline.Sub(now))
|
}
|
||||||
select {
|
|
||||||
case r = <-c.ch:
|
var r ioResult
|
||||||
wait = false
|
select {
|
||||||
case <-timeout:
|
case r = <-c.ch:
|
||||||
timedout = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if timedout {
|
|
||||||
cancelIoEx(f.handle, &c.o)
|
|
||||||
}
|
|
||||||
if wait {
|
|
||||||
r = <-c.ch
|
|
||||||
}
|
|
||||||
err = r.err
|
err = r.err
|
||||||
if err == syscall.ERROR_OPERATION_ABORTED {
|
if err == syscall.ERROR_OPERATION_ABORTED {
|
||||||
if f.closing {
|
if f.closing.isSet() {
|
||||||
err = ErrFileClosed
|
err = ErrFileClosed
|
||||||
} else if timedout {
|
|
||||||
err = ErrTimeout
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.wg.Done()
|
case <-timeout:
|
||||||
return int(r.bytes), err
|
cancelIoEx(f.handle, &c.o)
|
||||||
|
r = <-c.ch
|
||||||
|
err = r.err
|
||||||
|
if err == syscall.ERROR_OPERATION_ABORTED {
|
||||||
|
err = ErrTimeout
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// runtime.KeepAlive is needed, as c is passed via native
|
||||||
|
// code to ioCompletionProcessor, c must remain alive
|
||||||
|
// until the channel read is complete.
|
||||||
|
runtime.KeepAlive(c)
|
||||||
|
return int(r.bytes), err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read reads from a file handle.
|
// Read reads from a file handle.
|
||||||
|
@ -185,9 +216,16 @@ func (f *win32File) Read(b []byte) (int, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
defer f.wg.Done()
|
||||||
|
|
||||||
|
if f.readDeadline.timedout.isSet() {
|
||||||
|
return 0, ErrTimeout
|
||||||
|
}
|
||||||
|
|
||||||
var bytes uint32
|
var bytes uint32
|
||||||
err = syscall.ReadFile(f.handle, b, &bytes, &c.o)
|
err = syscall.ReadFile(f.handle, b, &bytes, &c.o)
|
||||||
n, err := f.asyncIo(c, f.readDeadline, bytes, err)
|
n, err := f.asyncIo(c, &f.readDeadline, bytes, err)
|
||||||
|
runtime.KeepAlive(b)
|
||||||
|
|
||||||
// Handle EOF conditions.
|
// Handle EOF conditions.
|
||||||
if err == nil && n == 0 && len(b) != 0 {
|
if err == nil && n == 0 && len(b) != 0 {
|
||||||
|
@ -205,17 +243,68 @@ func (f *win32File) Write(b []byte) (int, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
defer f.wg.Done()
|
||||||
|
|
||||||
|
if f.writeDeadline.timedout.isSet() {
|
||||||
|
return 0, ErrTimeout
|
||||||
|
}
|
||||||
|
|
||||||
var bytes uint32
|
var bytes uint32
|
||||||
err = syscall.WriteFile(f.handle, b, &bytes, &c.o)
|
err = syscall.WriteFile(f.handle, b, &bytes, &c.o)
|
||||||
return f.asyncIo(c, f.writeDeadline, bytes, err)
|
n, err := f.asyncIo(c, &f.writeDeadline, bytes, err)
|
||||||
|
runtime.KeepAlive(b)
|
||||||
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *win32File) SetReadDeadline(t time.Time) error {
|
func (f *win32File) SetReadDeadline(deadline time.Time) error {
|
||||||
f.readDeadline = t
|
return f.readDeadline.set(deadline)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *win32File) SetWriteDeadline(t time.Time) error {
|
func (f *win32File) SetWriteDeadline(deadline time.Time) error {
|
||||||
f.writeDeadline = t
|
return f.writeDeadline.set(deadline)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *win32File) Flush() error {
|
||||||
|
return syscall.FlushFileBuffers(f.handle)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *deadlineHandler) set(deadline time.Time) error {
|
||||||
|
d.setLock.Lock()
|
||||||
|
defer d.setLock.Unlock()
|
||||||
|
|
||||||
|
if d.timer != nil {
|
||||||
|
if !d.timer.Stop() {
|
||||||
|
<-d.channel
|
||||||
|
}
|
||||||
|
d.timer = nil
|
||||||
|
}
|
||||||
|
d.timedout.setFalse()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-d.channel:
|
||||||
|
d.channelLock.Lock()
|
||||||
|
d.channel = make(chan struct{})
|
||||||
|
d.channelLock.Unlock()
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
if deadline.IsZero() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
timeoutIO := func() {
|
||||||
|
d.timedout.setTrue()
|
||||||
|
close(d.channel)
|
||||||
|
}
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
|
duration := deadline.Sub(now)
|
||||||
|
if deadline.After(now) {
|
||||||
|
// Deadline is in the future, set a timer to wait
|
||||||
|
d.timer = time.AfterFunc(duration, timeoutIO)
|
||||||
|
} else {
|
||||||
|
// Deadline is in the past. Cancel all pending IO now.
|
||||||
|
timeoutIO()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
4
vendor/github.com/Microsoft/go-winio/fileinfo.go
generated
vendored
4
vendor/github.com/Microsoft/go-winio/fileinfo.go
generated
vendored
|
@ -4,6 +4,7 @@ package winio
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
@ -28,6 +29,7 @@ func GetFileBasicInfo(f *os.File) (*FileBasicInfo, error) {
|
||||||
if err := getFileInformationByHandleEx(syscall.Handle(f.Fd()), fileBasicInfo, (*byte)(unsafe.Pointer(bi)), uint32(unsafe.Sizeof(*bi))); err != nil {
|
if err := getFileInformationByHandleEx(syscall.Handle(f.Fd()), fileBasicInfo, (*byte)(unsafe.Pointer(bi)), uint32(unsafe.Sizeof(*bi))); err != nil {
|
||||||
return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err}
|
return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err}
|
||||||
}
|
}
|
||||||
|
runtime.KeepAlive(f)
|
||||||
return bi, nil
|
return bi, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +38,7 @@ func SetFileBasicInfo(f *os.File, bi *FileBasicInfo) error {
|
||||||
if err := setFileInformationByHandle(syscall.Handle(f.Fd()), fileBasicInfo, (*byte)(unsafe.Pointer(bi)), uint32(unsafe.Sizeof(*bi))); err != nil {
|
if err := setFileInformationByHandle(syscall.Handle(f.Fd()), fileBasicInfo, (*byte)(unsafe.Pointer(bi)), uint32(unsafe.Sizeof(*bi))); err != nil {
|
||||||
return &os.PathError{Op: "SetFileInformationByHandle", Path: f.Name(), Err: err}
|
return &os.PathError{Op: "SetFileInformationByHandle", Path: f.Name(), Err: err}
|
||||||
}
|
}
|
||||||
|
runtime.KeepAlive(f)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,5 +55,6 @@ func GetFileID(f *os.File) (*FileIDInfo, error) {
|
||||||
if err := getFileInformationByHandleEx(syscall.Handle(f.Fd()), fileIDInfo, (*byte)(unsafe.Pointer(fileID)), uint32(unsafe.Sizeof(*fileID))); err != nil {
|
if err := getFileInformationByHandleEx(syscall.Handle(f.Fd()), fileIDInfo, (*byte)(unsafe.Pointer(fileID)), uint32(unsafe.Sizeof(*fileID))); err != nil {
|
||||||
return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err}
|
return nil, &os.PathError{Op: "GetFileInformationByHandleEx", Path: f.Name(), Err: err}
|
||||||
}
|
}
|
||||||
|
runtime.KeepAlive(f)
|
||||||
return fileID, nil
|
return fileID, nil
|
||||||
}
|
}
|
||||||
|
|
36
vendor/github.com/Microsoft/go-winio/pipe.go
generated
vendored
36
vendor/github.com/Microsoft/go-winio/pipe.go
generated
vendored
|
@ -13,17 +13,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
//sys connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) = ConnectNamedPipe
|
//sys connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) = ConnectNamedPipe
|
||||||
//sys createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *securityAttributes) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateNamedPipeW
|
//sys createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateNamedPipeW
|
||||||
//sys createFile(name string, access uint32, mode uint32, sa *securityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateFileW
|
//sys createFile(name string, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) [failretval==syscall.InvalidHandle] = CreateFileW
|
||||||
//sys waitNamedPipe(name string, timeout uint32) (err error) = WaitNamedPipeW
|
//sys waitNamedPipe(name string, timeout uint32) (err error) = WaitNamedPipeW
|
||||||
//sys getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) = GetNamedPipeInfo
|
//sys getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) = GetNamedPipeInfo
|
||||||
//sys getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
|
//sys getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) = GetNamedPipeHandleStateW
|
||||||
|
//sys localAlloc(uFlags uint32, length uint32) (ptr uintptr) = LocalAlloc
|
||||||
type securityAttributes struct {
|
|
||||||
Length uint32
|
|
||||||
SecurityDescriptor *byte
|
|
||||||
InheritHandle uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
cERROR_PIPE_BUSY = syscall.Errno(231)
|
cERROR_PIPE_BUSY = syscall.Errno(231)
|
||||||
|
@ -87,7 +82,11 @@ func (f *win32MessageBytePipe) CloseWrite() error {
|
||||||
if f.writeClosed {
|
if f.writeClosed {
|
||||||
return errPipeWriteClosed
|
return errPipeWriteClosed
|
||||||
}
|
}
|
||||||
_, err := f.win32File.Write(nil)
|
err := f.win32File.Flush()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err = f.win32File.Write(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -227,12 +226,15 @@ func makeServerPipeHandle(path string, securityDescriptor []byte, c *PipeConfig,
|
||||||
mode |= cPIPE_TYPE_MESSAGE
|
mode |= cPIPE_TYPE_MESSAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
var sa securityAttributes
|
sa := &syscall.SecurityAttributes{}
|
||||||
sa.Length = uint32(unsafe.Sizeof(sa))
|
sa.Length = uint32(unsafe.Sizeof(*sa))
|
||||||
if securityDescriptor != nil {
|
if securityDescriptor != nil {
|
||||||
sa.SecurityDescriptor = &securityDescriptor[0]
|
len := uint32(len(securityDescriptor))
|
||||||
|
sa.SecurityDescriptor = localAlloc(0, len)
|
||||||
|
defer localFree(sa.SecurityDescriptor)
|
||||||
|
copy((*[0xffff]byte)(unsafe.Pointer(sa.SecurityDescriptor))[:], securityDescriptor)
|
||||||
}
|
}
|
||||||
h, err := createNamedPipe(path, flags, mode, cPIPE_UNLIMITED_INSTANCES, uint32(c.OutputBufferSize), uint32(c.InputBufferSize), 0, &sa)
|
h, err := createNamedPipe(path, flags, mode, cPIPE_UNLIMITED_INSTANCES, uint32(c.OutputBufferSize), uint32(c.InputBufferSize), 0, sa)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, &os.PathError{Op: "open", Path: path, Err: err}
|
return 0, &os.PathError{Op: "open", Path: path, Err: err}
|
||||||
}
|
}
|
||||||
|
@ -263,9 +265,9 @@ func (l *win32PipeListener) listenerRoutine() {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Wait for the client to connect.
|
// Wait for the client to connect.
|
||||||
ch := make(chan error)
|
ch := make(chan error)
|
||||||
go func() {
|
go func(p *win32File) {
|
||||||
ch <- connectPipe(p)
|
ch <- connectPipe(p)
|
||||||
}()
|
}(p)
|
||||||
select {
|
select {
|
||||||
case err = <-ch:
|
case err = <-ch:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -358,8 +360,10 @@ func connectPipe(p *win32File) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
defer p.wg.Done()
|
||||||
|
|
||||||
err = connectNamedPipe(p.handle, &c.o)
|
err = connectNamedPipe(p.handle, &c.o)
|
||||||
_, err = p.asyncIo(c, time.Time{}, 0, err)
|
_, err = p.asyncIo(c, nil, 0, err)
|
||||||
if err != nil && err != cERROR_PIPE_CONNECTED {
|
if err != nil && err != cERROR_PIPE_CONNECTED {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
90
vendor/github.com/Microsoft/go-winio/zsyscall_windows.go
generated
vendored
90
vendor/github.com/Microsoft/go-winio/zsyscall_windows.go
generated
vendored
|
@ -11,6 +11,31 @@ import (
|
||||||
|
|
||||||
var _ unsafe.Pointer
|
var _ unsafe.Pointer
|
||||||
|
|
||||||
|
// Do the interface allocations only once for common
|
||||||
|
// Errno values.
|
||||||
|
const (
|
||||||
|
errnoERROR_IO_PENDING = 997
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
|
||||||
|
)
|
||||||
|
|
||||||
|
// errnoErr returns common boxed Errno values, to prevent
|
||||||
|
// allocations at runtime.
|
||||||
|
func errnoErr(e syscall.Errno) error {
|
||||||
|
switch e {
|
||||||
|
case 0:
|
||||||
|
return nil
|
||||||
|
case errnoERROR_IO_PENDING:
|
||||||
|
return errERROR_IO_PENDING
|
||||||
|
}
|
||||||
|
// TODO: add more here, after collecting data on the common
|
||||||
|
// error values see on Windows. (perhaps when running
|
||||||
|
// all.bat?)
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
|
||||||
modwinmm = windows.NewLazySystemDLL("winmm.dll")
|
modwinmm = windows.NewLazySystemDLL("winmm.dll")
|
||||||
|
@ -27,6 +52,7 @@ var (
|
||||||
procWaitNamedPipeW = modkernel32.NewProc("WaitNamedPipeW")
|
procWaitNamedPipeW = modkernel32.NewProc("WaitNamedPipeW")
|
||||||
procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
|
procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
|
||||||
procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
|
procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
|
||||||
|
procLocalAlloc = modkernel32.NewProc("LocalAlloc")
|
||||||
procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
|
procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
|
||||||
procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
|
procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
|
||||||
procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
|
procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
|
||||||
|
@ -51,7 +77,7 @@ func cancelIoEx(file syscall.Handle, o *syscall.Overlapped) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(file), uintptr(unsafe.Pointer(o)), 0)
|
r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(file), uintptr(unsafe.Pointer(o)), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -64,7 +90,7 @@ func createIoCompletionPort(file syscall.Handle, port syscall.Handle, key uintpt
|
||||||
newport = syscall.Handle(r0)
|
newport = syscall.Handle(r0)
|
||||||
if newport == 0 {
|
if newport == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -76,7 +102,7 @@ func getQueuedCompletionStatus(port syscall.Handle, bytes *uint32, key *uintptr,
|
||||||
r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(port), uintptr(unsafe.Pointer(bytes)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(o)), uintptr(timeout), 0)
|
r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(port), uintptr(unsafe.Pointer(bytes)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(o)), uintptr(timeout), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -88,7 +114,7 @@ func setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err erro
|
||||||
r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(h), uintptr(flags), 0)
|
r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(h), uintptr(flags), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -106,7 +132,7 @@ func connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(o)), 0)
|
r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(o)), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -114,7 +140,7 @@ func connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *securityAttributes) (handle syscall.Handle, err error) {
|
func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
|
||||||
var _p0 *uint16
|
var _p0 *uint16
|
||||||
_p0, err = syscall.UTF16PtrFromString(name)
|
_p0, err = syscall.UTF16PtrFromString(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -123,12 +149,12 @@ func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances ui
|
||||||
return _createNamedPipe(_p0, flags, pipeMode, maxInstances, outSize, inSize, defaultTimeout, sa)
|
return _createNamedPipe(_p0, flags, pipeMode, maxInstances, outSize, inSize, defaultTimeout, sa)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *securityAttributes) (handle syscall.Handle, err error) {
|
func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
|
||||||
r0, _, e1 := syscall.Syscall9(procCreateNamedPipeW.Addr(), 8, uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)), 0)
|
r0, _, e1 := syscall.Syscall9(procCreateNamedPipeW.Addr(), 8, uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)), 0)
|
||||||
handle = syscall.Handle(r0)
|
handle = syscall.Handle(r0)
|
||||||
if handle == syscall.InvalidHandle {
|
if handle == syscall.InvalidHandle {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -136,7 +162,7 @@ func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func createFile(name string, access uint32, mode uint32, sa *securityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) {
|
func createFile(name string, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) {
|
||||||
var _p0 *uint16
|
var _p0 *uint16
|
||||||
_p0, err = syscall.UTF16PtrFromString(name)
|
_p0, err = syscall.UTF16PtrFromString(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -145,12 +171,12 @@ func createFile(name string, access uint32, mode uint32, sa *securityAttributes,
|
||||||
return _createFile(_p0, access, mode, sa, createmode, attrs, templatefile)
|
return _createFile(_p0, access, mode, sa, createmode, attrs, templatefile)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _createFile(name *uint16, access uint32, mode uint32, sa *securityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) {
|
func _createFile(name *uint16, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.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)
|
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 = syscall.Handle(r0)
|
handle = syscall.Handle(r0)
|
||||||
if handle == syscall.InvalidHandle {
|
if handle == syscall.InvalidHandle {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -171,7 +197,7 @@ func _waitNamedPipe(name *uint16, timeout uint32) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procWaitNamedPipeW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(timeout), 0)
|
r1, _, e1 := syscall.Syscall(procWaitNamedPipeW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(timeout), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -183,7 +209,7 @@ func getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSiz
|
||||||
r1, _, e1 := syscall.Syscall6(procGetNamedPipeInfo.Addr(), 5, uintptr(pipe), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(outSize)), uintptr(unsafe.Pointer(inSize)), uintptr(unsafe.Pointer(maxInstances)), 0)
|
r1, _, e1 := syscall.Syscall6(procGetNamedPipeInfo.Addr(), 5, uintptr(pipe), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(outSize)), uintptr(unsafe.Pointer(inSize)), uintptr(unsafe.Pointer(maxInstances)), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -195,7 +221,7 @@ func getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *u
|
||||||
r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
|
r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -203,6 +229,12 @@ func getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *u
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func localAlloc(uFlags uint32, length uint32) (ptr uintptr) {
|
||||||
|
r0, _, _ := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(uFlags), uintptr(length), 0)
|
||||||
|
ptr = uintptr(r0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
|
func lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
|
||||||
var _p0 *uint16
|
var _p0 *uint16
|
||||||
_p0, err = syscall.UTF16PtrFromString(accountName)
|
_p0, err = syscall.UTF16PtrFromString(accountName)
|
||||||
|
@ -216,7 +248,7 @@ func _lookupAccountName(systemName *uint16, accountName *uint16, sid *byte, sidS
|
||||||
r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidSize)), uintptr(unsafe.Pointer(refDomain)), uintptr(unsafe.Pointer(refDomainSize)), uintptr(unsafe.Pointer(sidNameUse)), 0, 0)
|
r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidSize)), uintptr(unsafe.Pointer(refDomain)), uintptr(unsafe.Pointer(refDomainSize)), uintptr(unsafe.Pointer(sidNameUse)), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -228,7 +260,7 @@ func convertSidToStringSid(sid *byte, str **uint16) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(str)), 0)
|
r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(str)), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -249,7 +281,7 @@ func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision
|
||||||
r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
|
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 r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -261,7 +293,7 @@ func convertSecurityDescriptorToStringSecurityDescriptor(sd *byte, revision uint
|
||||||
r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(secInfo), uintptr(unsafe.Pointer(sddl)), uintptr(unsafe.Pointer(sddlSize)), 0)
|
r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(secInfo), uintptr(unsafe.Pointer(sddl)), uintptr(unsafe.Pointer(sddlSize)), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -284,7 +316,7 @@ func getFileInformationByHandleEx(h syscall.Handle, class uint32, buffer *byte,
|
||||||
r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0)
|
r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -296,7 +328,7 @@ func setFileInformationByHandle(h syscall.Handle, class uint32, buffer *byte, si
|
||||||
r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0)
|
r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -315,7 +347,7 @@ func adjustTokenPrivileges(token windows.Token, releaseAll bool, input *byte, ou
|
||||||
success = r0 != 0
|
success = r0 != 0
|
||||||
if true {
|
if true {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -327,7 +359,7 @@ func impersonateSelf(level uint32) (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(level), 0, 0)
|
r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(level), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -339,7 +371,7 @@ func revertToSelf() (err error) {
|
||||||
r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
|
r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -357,7 +389,7 @@ func openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool,
|
||||||
r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(accessMask), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
|
r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(accessMask), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -389,7 +421,7 @@ func _lookupPrivilegeValue(systemName *uint16, name *uint16, luid *uint64) (err
|
||||||
r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
|
r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -410,7 +442,7 @@ func _lookupPrivilegeName(systemName *uint16, luid *uint64, buffer *uint16, size
|
||||||
r1, _, e1 := syscall.Syscall6(procLookupPrivilegeNameW.Addr(), 4, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(luid)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), 0, 0)
|
r1, _, e1 := syscall.Syscall6(procLookupPrivilegeNameW.Addr(), 4, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(luid)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -431,7 +463,7 @@ func _lookupPrivilegeDisplayName(systemName *uint16, name *uint16, buffer *uint1
|
||||||
r1, _, e1 := syscall.Syscall6(procLookupPrivilegeDisplayNameW.Addr(), 5, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(languageId)), 0)
|
r1, _, e1 := syscall.Syscall6(procLookupPrivilegeDisplayNameW.Addr(), 5, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(languageId)), 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -459,7 +491,7 @@ func backupRead(h syscall.Handle, b []byte, bytesRead *uint32, abort bool, proce
|
||||||
r1, _, e1 := syscall.Syscall9(procBackupRead.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesRead)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0)
|
r1, _, e1 := syscall.Syscall9(procBackupRead.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesRead)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
@ -487,7 +519,7 @@ func backupWrite(h syscall.Handle, b []byte, bytesWritten *uint32, abort bool, p
|
||||||
r1, _, e1 := syscall.Syscall9(procBackupWrite.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesWritten)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0)
|
r1, _, e1 := syscall.Syscall9(procBackupWrite.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesWritten)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = error(e1)
|
err = errnoErr(e1)
|
||||||
} else {
|
} else {
|
||||||
err = syscall.EINVAL
|
err = syscall.EINVAL
|
||||||
}
|
}
|
||||||
|
|
3
vendor/github.com/Microsoft/hcsshim/LICENSE
generated
vendored
3
vendor/github.com/Microsoft/hcsshim/LICENSE
generated
vendored
|
@ -18,5 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/activatelayer.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/activatelayer.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// ActivateLayer will find the layer with the given id and mount it's filesystem.
|
// ActivateLayer will find the layer with the given id and mount it's filesystem.
|
||||||
// For a read/write layer, the mounted filesystem will appear as a volume on the
|
// For a read/write layer, the mounted filesystem will appear as a volume on the
|
||||||
|
|
230
vendor/github.com/Microsoft/hcsshim/container.go
generated
vendored
230
vendor/github.com/Microsoft/hcsshim/container.go
generated
vendored
|
@ -2,12 +2,13 @@ package hcsshim
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"runtime"
|
"fmt"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -15,9 +16,10 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
pendingUpdatesQuery = `{ "PropertyTypes" : ["PendingUpdates"]}`
|
pendingUpdatesQuery = `{ "PropertyTypes" : ["PendingUpdates"]}`
|
||||||
statisticsQuery = `{ "PropertyTypes" : ["Statistics"]}`
|
statisticsQuery = `{ "PropertyTypes" : ["Statistics"]}`
|
||||||
processListQuery = `{ "PropertyTypes" : ["ProcessList"]}`
|
processListQuery = `{ "PropertyTypes" : ["ProcessList"]}`
|
||||||
|
mappedVirtualDiskQuery = `{ "PropertyTypes" : ["MappedVirtualDisk"]}`
|
||||||
)
|
)
|
||||||
|
|
||||||
type container struct {
|
type container struct {
|
||||||
|
@ -29,21 +31,21 @@ type container struct {
|
||||||
|
|
||||||
// ContainerProperties holds the properties for a container and the processes running in that container
|
// ContainerProperties holds the properties for a container and the processes running in that container
|
||||||
type ContainerProperties struct {
|
type ContainerProperties struct {
|
||||||
ID string `json:"Id"`
|
ID string `json:"Id"`
|
||||||
Name string
|
Name string
|
||||||
SystemType string
|
SystemType string
|
||||||
Owner string
|
Owner string
|
||||||
SiloGUID string `json:"SiloGuid,omitempty"`
|
SiloGUID string `json:"SiloGuid,omitempty"`
|
||||||
IsDummy bool `json:",omitempty"`
|
RuntimeID string `json:"RuntimeId,omitempty"`
|
||||||
RuntimeID string `json:"RuntimeId,omitempty"`
|
IsRuntimeTemplate bool `json:",omitempty"`
|
||||||
IsRuntimeTemplate bool `json:",omitempty"`
|
RuntimeImagePath string `json:",omitempty"`
|
||||||
RuntimeImagePath string `json:",omitempty"`
|
Stopped bool `json:",omitempty"`
|
||||||
Stopped bool `json:",omitempty"`
|
ExitType string `json:",omitempty"`
|
||||||
ExitType string `json:",omitempty"`
|
AreUpdatesPending bool `json:",omitempty"`
|
||||||
AreUpdatesPending bool `json:",omitempty"`
|
ObRoot string `json:",omitempty"`
|
||||||
ObRoot string `json:",omitempty"`
|
Statistics Statistics `json:",omitempty"`
|
||||||
Statistics Statistics `json:",omitempty"`
|
ProcessList []ProcessListItem `json:",omitempty"`
|
||||||
ProcessList []ProcessListItem `json:",omitempty"`
|
MappedVirtualDiskControllers map[int]MappedVirtualDiskController `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MemoryStats holds the memory statistics for a container
|
// MemoryStats holds the memory statistics for a container
|
||||||
|
@ -103,8 +105,53 @@ type ProcessListItem struct {
|
||||||
UserTime100ns uint64 `json:",omitempty"`
|
UserTime100ns uint64 `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MappedVirtualDiskController is the structure of an item returned by a MappedVirtualDiskList call on a container
|
||||||
|
type MappedVirtualDiskController struct {
|
||||||
|
MappedVirtualDisks map[int]MappedVirtualDisk `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type of Request Support in ModifySystem
|
||||||
|
type RequestType string
|
||||||
|
|
||||||
|
// Type of Resource Support in ModifySystem
|
||||||
|
type ResourceType string
|
||||||
|
|
||||||
|
// RequestType const
|
||||||
|
const (
|
||||||
|
Add RequestType = "Add"
|
||||||
|
Remove RequestType = "Remove"
|
||||||
|
Network ResourceType = "Network"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ResourceModificationRequestResponse is the structure used to send request to the container to modify the system
|
||||||
|
// Supported resource types are Network and Request Types are Add/Remove
|
||||||
|
type ResourceModificationRequestResponse struct {
|
||||||
|
Resource ResourceType `json:"ResourceType"`
|
||||||
|
Data interface{} `json:"Settings"`
|
||||||
|
Request RequestType `json:"RequestType,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// createContainerAdditionalJSON is read from the environment at initialisation
|
||||||
|
// time. It allows an environment variable to define additional JSON which
|
||||||
|
// is merged in the CreateContainer call to HCS.
|
||||||
|
var createContainerAdditionalJSON string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
createContainerAdditionalJSON = os.Getenv("HCSSHIM_CREATECONTAINER_ADDITIONALJSON")
|
||||||
|
}
|
||||||
|
|
||||||
// CreateContainer creates a new container with the given configuration but does not start it.
|
// CreateContainer creates a new container with the given configuration but does not start it.
|
||||||
func CreateContainer(id string, c *ContainerConfig) (Container, error) {
|
func CreateContainer(id string, c *ContainerConfig) (Container, error) {
|
||||||
|
return createContainerWithJSON(id, c, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateContainerWithJSON creates a new container with the given configuration but does not start it.
|
||||||
|
// It is identical to CreateContainer except that optional additional JSON can be merged before passing to HCS.
|
||||||
|
func CreateContainerWithJSON(id string, c *ContainerConfig, additionalJSON string) (Container, error) {
|
||||||
|
return createContainerWithJSON(id, c, additionalJSON)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createContainerWithJSON(id string, c *ContainerConfig, additionalJSON string) (Container, error) {
|
||||||
operation := "CreateContainer"
|
operation := "CreateContainer"
|
||||||
title := "HCSShim::" + operation
|
title := "HCSShim::" + operation
|
||||||
|
|
||||||
|
@ -120,6 +167,32 @@ func CreateContainer(id string, c *ContainerConfig) (Container, error) {
|
||||||
configuration := string(configurationb)
|
configuration := string(configurationb)
|
||||||
logrus.Debugf(title+" id=%s config=%s", id, configuration)
|
logrus.Debugf(title+" id=%s config=%s", id, configuration)
|
||||||
|
|
||||||
|
// Merge any additional JSON. Priority is given to what is passed in explicitly,
|
||||||
|
// falling back to what's set in the environment.
|
||||||
|
if additionalJSON == "" && createContainerAdditionalJSON != "" {
|
||||||
|
additionalJSON = createContainerAdditionalJSON
|
||||||
|
}
|
||||||
|
if additionalJSON != "" {
|
||||||
|
configurationMap := map[string]interface{}{}
|
||||||
|
if err := json.Unmarshal([]byte(configuration), &configurationMap); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to unmarshal %s: %s", configuration, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
additionalMap := map[string]interface{}{}
|
||||||
|
if err := json.Unmarshal([]byte(additionalJSON), &additionalMap); err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to unmarshal %s: %s", additionalJSON, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
mergedMap := mergeMaps(additionalMap, configurationMap)
|
||||||
|
mergedJSON, err := json.Marshal(mergedMap)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to marshal merged configuration map %+v: %s", mergedMap, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
configuration = string(mergedJSON)
|
||||||
|
logrus.Debugf(title+" id=%s merged config=%s", id, configuration)
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
resultp *uint16
|
resultp *uint16
|
||||||
identity syscall.Handle
|
identity syscall.Handle
|
||||||
|
@ -138,10 +211,36 @@ func CreateContainer(id string, c *ContainerConfig) (Container, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf(title+" succeeded id=%s handle=%d", id, container.handle)
|
logrus.Debugf(title+" succeeded id=%s handle=%d", id, container.handle)
|
||||||
runtime.SetFinalizer(container, closeContainer)
|
|
||||||
return container, nil
|
return container, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mergeMaps recursively merges map `fromMap` into map `ToMap`. Any pre-existing values
|
||||||
|
// in ToMap are overwritten. Values in fromMap are added to ToMap.
|
||||||
|
// From http://stackoverflow.com/questions/40491438/merging-two-json-strings-in-golang
|
||||||
|
func mergeMaps(fromMap, ToMap interface{}) interface{} {
|
||||||
|
switch fromMap := fromMap.(type) {
|
||||||
|
case map[string]interface{}:
|
||||||
|
ToMap, ok := ToMap.(map[string]interface{})
|
||||||
|
if !ok {
|
||||||
|
return fromMap
|
||||||
|
}
|
||||||
|
for keyToMap, valueToMap := range ToMap {
|
||||||
|
if valueFromMap, ok := fromMap[keyToMap]; ok {
|
||||||
|
fromMap[keyToMap] = mergeMaps(valueFromMap, valueToMap)
|
||||||
|
} else {
|
||||||
|
fromMap[keyToMap] = valueToMap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case nil:
|
||||||
|
// merge(nil, map[string]interface{...}) -> map[string]interface{...}
|
||||||
|
ToMap, ok := ToMap.(map[string]interface{})
|
||||||
|
if ok {
|
||||||
|
return ToMap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fromMap
|
||||||
|
}
|
||||||
|
|
||||||
// OpenContainer opens an existing container by ID.
|
// OpenContainer opens an existing container by ID.
|
||||||
func OpenContainer(id string) (Container, error) {
|
func OpenContainer(id string) (Container, error) {
|
||||||
operation := "OpenContainer"
|
operation := "OpenContainer"
|
||||||
|
@ -169,7 +268,6 @@ func OpenContainer(id string) (Container, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf(title+" succeeded id=%s handle=%d", id, handle)
|
logrus.Debugf(title+" succeeded id=%s handle=%d", id, handle)
|
||||||
runtime.SetFinalizer(container, closeContainer)
|
|
||||||
return container, nil
|
return container, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,6 +494,55 @@ func (container *container) ProcessList() ([]ProcessListItem, error) {
|
||||||
return properties.ProcessList, nil
|
return properties.ProcessList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MappedVirtualDisks returns a map of the controllers and the disks mapped
|
||||||
|
// to a container.
|
||||||
|
//
|
||||||
|
// Example of JSON returned by the query.
|
||||||
|
//{
|
||||||
|
// "Id":"1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3_svm",
|
||||||
|
// "SystemType":"Container",
|
||||||
|
// "RuntimeOsType":"Linux",
|
||||||
|
// "RuntimeId":"00000000-0000-0000-0000-000000000000",
|
||||||
|
// "State":"Running",
|
||||||
|
// "MappedVirtualDiskControllers":{
|
||||||
|
// "0":{
|
||||||
|
// "MappedVirtualDisks":{
|
||||||
|
// "2":{
|
||||||
|
// "HostPath":"C:\\lcow\\lcow\\scratch\\1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3.vhdx",
|
||||||
|
// "ContainerPath":"/mnt/gcs/LinuxServiceVM/scratch",
|
||||||
|
// "Lun":2,
|
||||||
|
// "CreateInUtilityVM":true
|
||||||
|
// },
|
||||||
|
// "3":{
|
||||||
|
// "HostPath":"C:\\lcow\\lcow\\1126e8d7d279c707a666972a15976371d365eaf622c02cea2c442b84f6f550a3\\sandbox.vhdx",
|
||||||
|
// "Lun":3,
|
||||||
|
// "CreateInUtilityVM":true,
|
||||||
|
// "AttachOnly":true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
func (container *container) MappedVirtualDisks() (map[int]MappedVirtualDiskController, error) {
|
||||||
|
container.handleLock.RLock()
|
||||||
|
defer container.handleLock.RUnlock()
|
||||||
|
operation := "MappedVirtualDiskList"
|
||||||
|
title := "HCSShim::Container::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", container.id)
|
||||||
|
|
||||||
|
if container.handle == 0 {
|
||||||
|
return nil, makeContainerError(container, operation, "", ErrAlreadyClosed)
|
||||||
|
}
|
||||||
|
|
||||||
|
properties, err := container.properties(mappedVirtualDiskQuery)
|
||||||
|
if err != nil {
|
||||||
|
return nil, makeContainerError(container, operation, "", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.Debugf(title+" succeeded id=%s", container.id)
|
||||||
|
return properties.MappedVirtualDiskControllers, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Pause pauses the execution of the container. This feature is not enabled in TP5.
|
// Pause pauses the execution of the container. This feature is not enabled in TP5.
|
||||||
func (container *container) Pause() error {
|
func (container *container) Pause() error {
|
||||||
container.handleLock.RLock()
|
container.handleLock.RLock()
|
||||||
|
@ -493,8 +640,7 @@ func (container *container) CreateProcess(c *ProcessConfig) (Process, error) {
|
||||||
return nil, makeContainerError(container, operation, "", err)
|
return nil, makeContainerError(container, operation, "", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf(title+" succeeded id=%s processid=%s", container.id, process.processID)
|
logrus.Debugf(title+" succeeded id=%s processid=%d", container.id, process.processID)
|
||||||
runtime.SetFinalizer(process, closeProcess)
|
|
||||||
return process, nil
|
return process, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +677,6 @@ func (container *container) OpenProcess(pid int) (Process, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf(title+" succeeded id=%s processid=%s", container.id, process.processID)
|
logrus.Debugf(title+" succeeded id=%s processid=%s", container.id, process.processID)
|
||||||
runtime.SetFinalizer(process, closeProcess)
|
|
||||||
return process, nil
|
return process, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,17 +702,11 @@ func (container *container) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
container.handle = 0
|
container.handle = 0
|
||||||
runtime.SetFinalizer(container, nil)
|
|
||||||
|
|
||||||
logrus.Debugf(title+" succeeded id=%s", container.id)
|
logrus.Debugf(title+" succeeded id=%s", container.id)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// closeContainer wraps container.Close for use by a finalizer
|
|
||||||
func closeContainer(container *container) {
|
|
||||||
container.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (container *container) registerCallback() error {
|
func (container *container) registerCallback() error {
|
||||||
context := ¬ifcationWatcherContext{
|
context := ¬ifcationWatcherContext{
|
||||||
channels: newChannels(),
|
channels: newChannels(),
|
||||||
|
@ -624,3 +763,32 @@ func (container *container) unregisterCallback() error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modifies the System by sending a request to HCS
|
||||||
|
func (container *container) Modify(config *ResourceModificationRequestResponse) error {
|
||||||
|
container.handleLock.RLock()
|
||||||
|
defer container.handleLock.RUnlock()
|
||||||
|
operation := "Modify"
|
||||||
|
title := "HCSShim::Container::" + operation
|
||||||
|
|
||||||
|
if container.handle == 0 {
|
||||||
|
return makeContainerError(container, operation, "", ErrAlreadyClosed)
|
||||||
|
}
|
||||||
|
|
||||||
|
requestJSON, err := json.Marshal(config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
requestString := string(requestJSON)
|
||||||
|
logrus.Debugf(title+" id=%s request=%s", container.id, requestString)
|
||||||
|
|
||||||
|
var resultp *uint16
|
||||||
|
err = hcsModifyComputeSystem(container.handle, requestString, &resultp)
|
||||||
|
err = processHcsResult(err, resultp)
|
||||||
|
if err != nil {
|
||||||
|
return makeContainerError(container, operation, "", err)
|
||||||
|
}
|
||||||
|
logrus.Debugf(title+" succeeded id=%s", container.id)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/createlayer.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/createlayer.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// CreateLayer creates a new, empty, read-only layer on the filesystem based on
|
// CreateLayer creates a new, empty, read-only layer on the filesystem based on
|
||||||
// the parent layer provided.
|
// the parent layer provided.
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/createsandboxlayer.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/createsandboxlayer.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// CreateSandboxLayer creates and populates new read-write layer for use by a container.
|
// CreateSandboxLayer creates and populates new read-write layer for use by a container.
|
||||||
// This requires both the id of the direct parent layer, as well as the full list
|
// This requires both the id of the direct parent layer, as well as the full list
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/deactivatelayer.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/deactivatelayer.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// DeactivateLayer will dismount a layer that was mounted via ActivateLayer.
|
// DeactivateLayer will dismount a layer that was mounted via ActivateLayer.
|
||||||
func DeactivateLayer(info DriverInfo, id string) error {
|
func DeactivateLayer(info DriverInfo, id string) error {
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/destroylayer.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/destroylayer.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// DestroyLayer will remove the on-disk files representing the layer with the given
|
// DestroyLayer will remove the on-disk files representing the layer with the given
|
||||||
// id, including that layer's containing folder, if any.
|
// id, including that layer's containing folder, if any.
|
||||||
|
|
34
vendor/github.com/Microsoft/hcsshim/errors.go
generated
vendored
34
vendor/github.com/Microsoft/hcsshim/errors.go
generated
vendored
|
@ -13,6 +13,13 @@ var (
|
||||||
// ErrElementNotFound is an error encountered when the object being referenced does not exist
|
// ErrElementNotFound is an error encountered when the object being referenced does not exist
|
||||||
ErrElementNotFound = syscall.Errno(0x490)
|
ErrElementNotFound = syscall.Errno(0x490)
|
||||||
|
|
||||||
|
// ErrElementNotFound is an error encountered when the object being referenced does not exist
|
||||||
|
ErrNotSupported = syscall.Errno(0x32)
|
||||||
|
|
||||||
|
// ErrInvalidData is an error encountered when the request being sent to hcs is invalid/unsupported
|
||||||
|
// decimal -2147024883 / hex 0x8007000d
|
||||||
|
ErrInvalidData = syscall.Errno(0xd)
|
||||||
|
|
||||||
// ErrHandleClose is an error encountered when the handle generating the notification being waited on has been closed
|
// ErrHandleClose is an error encountered when the handle generating the notification being waited on has been closed
|
||||||
ErrHandleClose = errors.New("hcsshim: the handle generating this notification has been closed")
|
ErrHandleClose = errors.New("hcsshim: the handle generating this notification has been closed")
|
||||||
|
|
||||||
|
@ -50,6 +57,19 @@ var (
|
||||||
|
|
||||||
// ErrProcNotFound is an error encountered when the the process cannot be found
|
// ErrProcNotFound is an error encountered when the the process cannot be found
|
||||||
ErrProcNotFound = syscall.Errno(0x7f)
|
ErrProcNotFound = syscall.Errno(0x7f)
|
||||||
|
|
||||||
|
// ErrVmcomputeOperationAccessIsDenied is an error which can be encountered when enumerating compute systems in RS1/RS2
|
||||||
|
// builds when the underlying silo might be in the process of terminating. HCS was fixed in RS3.
|
||||||
|
ErrVmcomputeOperationAccessIsDenied = syscall.Errno(0x5)
|
||||||
|
|
||||||
|
// ErrVmcomputeInvalidJSON is an error encountered when the compute system does not support/understand the messages sent by management
|
||||||
|
ErrVmcomputeInvalidJSON = syscall.Errno(0xc037010d)
|
||||||
|
|
||||||
|
// ErrVmcomputeUnknownMessage is an error encountered guest compute system doesn't support the message
|
||||||
|
ErrVmcomputeUnknownMessage = syscall.Errno(0xc037010b)
|
||||||
|
|
||||||
|
// ErrNotSupported is an error encountered when hcs doesn't support the request
|
||||||
|
ErrPlatformNotSupported = errors.New("unsupported platform request")
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProcessError is an error encountered in HCS during an operation on a Process object
|
// ProcessError is an error encountered in HCS during an operation on a Process object
|
||||||
|
@ -192,6 +212,20 @@ func IsAlreadyStopped(err error) bool {
|
||||||
err == ErrProcNotFound
|
err == ErrProcNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsNotSupported returns a boolean indicating whether the error is caused by
|
||||||
|
// unsupported platform requests
|
||||||
|
// Note: Currently Unsupported platform requests can be mean either
|
||||||
|
// ErrVmcomputeInvalidJSON, ErrInvalidData, ErrNotSupported or ErrVmcomputeUnknownMessage
|
||||||
|
// is thrown from the Platform
|
||||||
|
func IsNotSupported(err error) bool {
|
||||||
|
err = getInnerError(err)
|
||||||
|
// If Platform doesn't recognize or support the request sent, below errors are seen
|
||||||
|
return err == ErrVmcomputeInvalidJSON ||
|
||||||
|
err == ErrInvalidData ||
|
||||||
|
err == ErrNotSupported ||
|
||||||
|
err == ErrVmcomputeUnknownMessage
|
||||||
|
}
|
||||||
|
|
||||||
func getInnerError(err error) error {
|
func getInnerError(err error) error {
|
||||||
switch pe := err.(type) {
|
switch pe := err.(type) {
|
||||||
case nil:
|
case nil:
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/expandsandboxsize.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/expandsandboxsize.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// ExpandSandboxSize expands the size of a layer to at least size bytes.
|
// ExpandSandboxSize expands the size of a layer to at least size bytes.
|
||||||
func ExpandSandboxSize(info DriverInfo, layerId string, size uint64) error {
|
func ExpandSandboxSize(info DriverInfo, layerId string, size uint64) error {
|
||||||
|
|
4
vendor/github.com/Microsoft/hcsshim/exportlayer.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/exportlayer.go
generated
vendored
|
@ -4,11 +4,10 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/Microsoft/go-winio"
|
"github.com/Microsoft/go-winio"
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ExportLayer will create a folder at exportFolderPath and fill that folder with
|
// ExportLayer will create a folder at exportFolderPath and fill that folder with
|
||||||
|
@ -143,7 +142,6 @@ func NewLayerReader(info DriverInfo, layerID string, parentLayerPaths []string)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, makeError(err, "ExportLayerBegin", "")
|
return nil, makeError(err, "ExportLayerBegin", "")
|
||||||
}
|
}
|
||||||
runtime.SetFinalizer(r, func(r *FilterLayerReader) { r.Close() })
|
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/getlayermountpath.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/getlayermountpath.go
generated
vendored
|
@ -3,7 +3,7 @@ package hcsshim
|
||||||
import (
|
import (
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetLayerMountPath will look for a mounted layer with the given id and return
|
// GetLayerMountPath will look for a mounted layer with the given id and return
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/getsharedbaseimages.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/getsharedbaseimages.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// GetSharedBaseImages will enumerate the images stored in the common central
|
// GetSharedBaseImages will enumerate the images stored in the common central
|
||||||
// image store and return descriptive info about those images for the purpose
|
// image store and return descriptive info about those images for the purpose
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/hcsshim.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/hcsshim.go
generated
vendored
|
@ -8,7 +8,7 @@ import (
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate go run mksyscall_windows.go -output zhcsshim.go hcsshim.go
|
//go:generate go run mksyscall_windows.go -output zhcsshim.go hcsshim.go
|
||||||
|
|
318
vendor/github.com/Microsoft/hcsshim/hnsendpoint.go
generated
vendored
Normal file
318
vendor/github.com/Microsoft/hcsshim/hnsendpoint.go
generated
vendored
Normal file
|
@ -0,0 +1,318 @@
|
||||||
|
package hcsshim
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// HNSEndpoint represents a network endpoint in HNS
|
||||||
|
type HNSEndpoint struct {
|
||||||
|
Id string `json:"ID,omitempty"`
|
||||||
|
Name string `json:",omitempty"`
|
||||||
|
VirtualNetwork string `json:",omitempty"`
|
||||||
|
VirtualNetworkName string `json:",omitempty"`
|
||||||
|
Policies []json.RawMessage `json:",omitempty"`
|
||||||
|
MacAddress string `json:",omitempty"`
|
||||||
|
IPAddress net.IP `json:",omitempty"`
|
||||||
|
DNSSuffix string `json:",omitempty"`
|
||||||
|
DNSServerList string `json:",omitempty"`
|
||||||
|
GatewayAddress string `json:",omitempty"`
|
||||||
|
EnableInternalDNS bool `json:",omitempty"`
|
||||||
|
DisableICC bool `json:",omitempty"`
|
||||||
|
PrefixLength uint8 `json:",omitempty"`
|
||||||
|
IsRemoteEndpoint bool `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//SystemType represents the type of the system on which actions are done
|
||||||
|
type SystemType string
|
||||||
|
|
||||||
|
// SystemType const
|
||||||
|
const (
|
||||||
|
ContainerType SystemType = "Container"
|
||||||
|
VirtualMachineType SystemType = "VirtualMachine"
|
||||||
|
HostType SystemType = "Host"
|
||||||
|
)
|
||||||
|
|
||||||
|
// EndpointAttachDetachRequest is the structure used to send request to the container to modify the system
|
||||||
|
// Supported resource types are Network and Request Types are Add/Remove
|
||||||
|
type EndpointAttachDetachRequest struct {
|
||||||
|
ContainerID string `json:"ContainerId,omitempty"`
|
||||||
|
SystemType SystemType `json:"SystemType"`
|
||||||
|
CompartmentID uint16 `json:"CompartmentId,omitempty"`
|
||||||
|
VirtualNICName string `json:"VirtualNicName,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// EndpointResquestResponse is object to get the endpoint request response
|
||||||
|
type EndpointResquestResponse struct {
|
||||||
|
Success bool
|
||||||
|
Error string
|
||||||
|
}
|
||||||
|
|
||||||
|
// HNSEndpointRequest makes a HNS call to modify/query a network endpoint
|
||||||
|
func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
|
||||||
|
endpoint := &HNSEndpoint{}
|
||||||
|
err := hnsCall(method, "/endpoints/"+path, request, &endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return endpoint, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HNSListEndpointRequest makes a HNS call to query the list of available endpoints
|
||||||
|
func HNSListEndpointRequest() ([]HNSEndpoint, error) {
|
||||||
|
var endpoint []HNSEndpoint
|
||||||
|
err := hnsCall("GET", "/endpoints/", "", &endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return endpoint, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HotAttachEndpoint makes a HCS Call to attach the endpoint to the container
|
||||||
|
func HotAttachEndpoint(containerID string, endpointID string) error {
|
||||||
|
return modifyNetworkEndpoint(containerID, endpointID, Add)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HotDetachEndpoint makes a HCS Call to detach the endpoint from the container
|
||||||
|
func HotDetachEndpoint(containerID string, endpointID string) error {
|
||||||
|
return modifyNetworkEndpoint(containerID, endpointID, Remove)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModifyContainer corresponding to the container id, by sending a request
|
||||||
|
func modifyContainer(id string, request *ResourceModificationRequestResponse) error {
|
||||||
|
container, err := OpenContainer(id)
|
||||||
|
if err != nil {
|
||||||
|
if IsNotExist(err) {
|
||||||
|
return ErrComputeSystemDoesNotExist
|
||||||
|
}
|
||||||
|
return getInnerError(err)
|
||||||
|
}
|
||||||
|
defer container.Close()
|
||||||
|
err = container.Modify(request)
|
||||||
|
if err != nil {
|
||||||
|
if IsNotSupported(err) {
|
||||||
|
return ErrPlatformNotSupported
|
||||||
|
}
|
||||||
|
return getInnerError(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func modifyNetworkEndpoint(containerID string, endpointID string, request RequestType) error {
|
||||||
|
requestMessage := &ResourceModificationRequestResponse{
|
||||||
|
Resource: Network,
|
||||||
|
Request: request,
|
||||||
|
Data: endpointID,
|
||||||
|
}
|
||||||
|
err := modifyContainer(containerID, requestMessage)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHNSEndpointByID get the Endpoint by ID
|
||||||
|
func GetHNSEndpointByID(endpointID string) (*HNSEndpoint, error) {
|
||||||
|
return HNSEndpointRequest("GET", endpointID, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHNSEndpointByName gets the endpoint filtered by Name
|
||||||
|
func GetHNSEndpointByName(endpointName string) (*HNSEndpoint, error) {
|
||||||
|
hnsResponse, err := HNSListEndpointRequest()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, hnsEndpoint := range hnsResponse {
|
||||||
|
if hnsEndpoint.Name == endpointName {
|
||||||
|
return &hnsEndpoint, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Endpoint %v not found", endpointName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create Endpoint by sending EndpointRequest to HNS. TODO: Create a separate HNS interface to place all these methods
|
||||||
|
func (endpoint *HNSEndpoint) Create() (*HNSEndpoint, error) {
|
||||||
|
operation := "Create"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return HNSEndpointRequest("POST", "", string(jsonString))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete Endpoint by sending EndpointRequest to HNS
|
||||||
|
func (endpoint *HNSEndpoint) Delete() (*HNSEndpoint, error) {
|
||||||
|
operation := "Delete"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
|
||||||
|
return HNSEndpointRequest("DELETE", endpoint.Id, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Endpoint
|
||||||
|
func (endpoint *HNSEndpoint) Update() (*HNSEndpoint, error) {
|
||||||
|
operation := "Update"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
jsonString, err := json.Marshal(endpoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
err = hnsCall("POST", "/endpoints/"+endpoint.Id, string(jsonString), &endpoint)
|
||||||
|
|
||||||
|
return endpoint, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainerHotAttach attaches an endpoint to a running container
|
||||||
|
func (endpoint *HNSEndpoint) ContainerHotAttach(containerID string) error {
|
||||||
|
operation := "ContainerHotAttach"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s, containerId=%s", endpoint.Id, containerID)
|
||||||
|
|
||||||
|
return modifyNetworkEndpoint(containerID, endpoint.Id, Add)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainerHotDetach detaches an endpoint from a running container
|
||||||
|
func (endpoint *HNSEndpoint) ContainerHotDetach(containerID string) error {
|
||||||
|
operation := "ContainerHotDetach"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s, containerId=%s", endpoint.Id, containerID)
|
||||||
|
|
||||||
|
return modifyNetworkEndpoint(containerID, endpoint.Id, Remove)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApplyACLPolicy applies Acl Policy on the Endpoint
|
||||||
|
func (endpoint *HNSEndpoint) ApplyACLPolicy(policy *ACLPolicy) error {
|
||||||
|
operation := "ApplyACLPolicy"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(policy)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
endpoint.Policies[0] = jsonString
|
||||||
|
_, err = endpoint.Update()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainerAttach attaches an endpoint to container
|
||||||
|
func (endpoint *HNSEndpoint) ContainerAttach(containerID string, compartmentID uint16) error {
|
||||||
|
operation := "ContainerAttach"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
|
||||||
|
requestMessage := &EndpointAttachDetachRequest{
|
||||||
|
ContainerID: containerID,
|
||||||
|
CompartmentID: compartmentID,
|
||||||
|
SystemType: ContainerType,
|
||||||
|
}
|
||||||
|
response := &EndpointResquestResponse{}
|
||||||
|
jsonString, err := json.Marshal(requestMessage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContainerDetach detaches an endpoint from container
|
||||||
|
func (endpoint *HNSEndpoint) ContainerDetach(containerID string) error {
|
||||||
|
operation := "ContainerDetach"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
|
||||||
|
requestMessage := &EndpointAttachDetachRequest{
|
||||||
|
ContainerID: containerID,
|
||||||
|
SystemType: ContainerType,
|
||||||
|
}
|
||||||
|
response := &EndpointResquestResponse{}
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(requestMessage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return hnsCall("POST", "/endpoints/"+endpoint.Id+"/detach", string(jsonString), &response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// HostAttach attaches a nic on the host
|
||||||
|
func (endpoint *HNSEndpoint) HostAttach(compartmentID uint16) error {
|
||||||
|
operation := "HostAttach"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
requestMessage := &EndpointAttachDetachRequest{
|
||||||
|
CompartmentID: compartmentID,
|
||||||
|
SystemType: HostType,
|
||||||
|
}
|
||||||
|
response := &EndpointResquestResponse{}
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(requestMessage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// HostDetach detaches a nic on the host
|
||||||
|
func (endpoint *HNSEndpoint) HostDetach() error {
|
||||||
|
operation := "HostDetach"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
requestMessage := &EndpointAttachDetachRequest{
|
||||||
|
SystemType: HostType,
|
||||||
|
}
|
||||||
|
response := &EndpointResquestResponse{}
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(requestMessage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return hnsCall("POST", "/endpoints/"+endpoint.Id+"/detach", string(jsonString), &response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// VirtualMachineNICAttach attaches a endpoint to a virtual machine
|
||||||
|
func (endpoint *HNSEndpoint) VirtualMachineNICAttach(virtualMachineNICName string) error {
|
||||||
|
operation := "VirtualMachineNicAttach"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
requestMessage := &EndpointAttachDetachRequest{
|
||||||
|
VirtualNICName: virtualMachineNICName,
|
||||||
|
SystemType: VirtualMachineType,
|
||||||
|
}
|
||||||
|
response := &EndpointResquestResponse{}
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(requestMessage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return hnsCall("POST", "/endpoints/"+endpoint.Id+"/attach", string(jsonString), &response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// VirtualMachineNICDetach detaches a endpoint from a virtual machine
|
||||||
|
func (endpoint *HNSEndpoint) VirtualMachineNICDetach() error {
|
||||||
|
operation := "VirtualMachineNicDetach"
|
||||||
|
title := "HCSShim::HNSEndpoint::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", endpoint.Id)
|
||||||
|
|
||||||
|
requestMessage := &EndpointAttachDetachRequest{
|
||||||
|
SystemType: VirtualMachineType,
|
||||||
|
}
|
||||||
|
response := &EndpointResquestResponse{}
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(requestMessage)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return hnsCall("POST", "/endpoints/"+endpoint.Id+"/detach", string(jsonString), &response)
|
||||||
|
}
|
126
vendor/github.com/Microsoft/hcsshim/hnsfuncs.go
generated
vendored
126
vendor/github.com/Microsoft/hcsshim/hnsfuncs.go
generated
vendored
|
@ -3,101 +3,14 @@ package hcsshim
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type NatPolicy struct {
|
|
||||||
Type string
|
|
||||||
Protocol string
|
|
||||||
InternalPort uint16
|
|
||||||
ExternalPort uint16
|
|
||||||
}
|
|
||||||
|
|
||||||
type QosPolicy struct {
|
|
||||||
Type string
|
|
||||||
MaximumOutgoingBandwidthInBytes uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
type VlanPolicy struct {
|
|
||||||
Type string
|
|
||||||
VLAN uint
|
|
||||||
}
|
|
||||||
|
|
||||||
type VsidPolicy struct {
|
|
||||||
Type string
|
|
||||||
VSID uint
|
|
||||||
}
|
|
||||||
|
|
||||||
type PaPolicy struct {
|
|
||||||
Type string
|
|
||||||
PA string
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subnet is assoicated with a network and represents a list
|
|
||||||
// of subnets available to the network
|
|
||||||
type Subnet struct {
|
|
||||||
AddressPrefix string `json:",omitempty"`
|
|
||||||
GatewayAddress string `json:",omitempty"`
|
|
||||||
Policies []json.RawMessage `json:",omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// MacPool is assoicated with a network and represents a list
|
|
||||||
// of macaddresses available to the network
|
|
||||||
type MacPool struct {
|
|
||||||
StartMacAddress string `json:",omitempty"`
|
|
||||||
EndMacAddress string `json:",omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// HNSNetwork represents a network in HNS
|
|
||||||
type HNSNetwork struct {
|
|
||||||
Id string `json:"ID,omitempty"`
|
|
||||||
Name string `json:",omitempty"`
|
|
||||||
Type string `json:",omitempty"`
|
|
||||||
NetworkAdapterName string `json:",omitempty"`
|
|
||||||
SourceMac string `json:",omitempty"`
|
|
||||||
Policies []json.RawMessage `json:",omitempty"`
|
|
||||||
MacPools []MacPool `json:",omitempty"`
|
|
||||||
Subnets []Subnet `json:",omitempty"`
|
|
||||||
DNSSuffix string `json:",omitempty"`
|
|
||||||
DNSServerList string `json:",omitempty"`
|
|
||||||
DNSServerCompartment uint32 `json:",omitempty"`
|
|
||||||
ManagementIP string `json:",omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// HNSEndpoint represents a network endpoint in HNS
|
|
||||||
type HNSEndpoint struct {
|
|
||||||
Id string `json:"ID,omitempty"`
|
|
||||||
Name string `json:",omitempty"`
|
|
||||||
VirtualNetwork string `json:",omitempty"`
|
|
||||||
VirtualNetworkName string `json:",omitempty"`
|
|
||||||
Policies []json.RawMessage `json:",omitempty"`
|
|
||||||
MacAddress string `json:",omitempty"`
|
|
||||||
IPAddress net.IP `json:",omitempty"`
|
|
||||||
DNSSuffix string `json:",omitempty"`
|
|
||||||
DNSServerList string `json:",omitempty"`
|
|
||||||
GatewayAddress string `json:",omitempty"`
|
|
||||||
EnableInternalDNS bool `json:",omitempty"`
|
|
||||||
DisableICC bool `json:",omitempty"`
|
|
||||||
PrefixLength uint8 `json:",omitempty"`
|
|
||||||
IsRemoteEndpoint bool `json:",omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type hnsNetworkResponse struct {
|
|
||||||
Success bool
|
|
||||||
Error string
|
|
||||||
Output HNSNetwork
|
|
||||||
}
|
|
||||||
|
|
||||||
type hnsResponse struct {
|
|
||||||
Success bool
|
|
||||||
Error string
|
|
||||||
Output json.RawMessage
|
|
||||||
}
|
|
||||||
|
|
||||||
func hnsCall(method, path, request string, returnResponse interface{}) error {
|
func hnsCall(method, path, request string, returnResponse interface{}) error {
|
||||||
var responseBuffer *uint16
|
var responseBuffer *uint16
|
||||||
|
logrus.Debugf("[%s]=>[%s] Request : %s", method, path, request)
|
||||||
|
|
||||||
err := _hnsCall(method, path, request, &responseBuffer)
|
err := _hnsCall(method, path, request, &responseBuffer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return makeError(err, "hnsCall ", "")
|
return makeError(err, "hnsCall ", "")
|
||||||
|
@ -125,36 +38,3 @@ func hnsCall(method, path, request string, returnResponse interface{}) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// HNSNetworkRequest makes a call into HNS to update/query a single network
|
|
||||||
func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
|
|
||||||
var network HNSNetwork
|
|
||||||
err := hnsCall(method, "/networks/"+path, request, &network)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &network, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// HNSListNetworkRequest makes a HNS call to query the list of available networks
|
|
||||||
func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
|
|
||||||
var network []HNSNetwork
|
|
||||||
err := hnsCall(method, "/networks/"+path, request, &network)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return network, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// HNSEndpointRequest makes a HNS call to modify/query a network endpoint
|
|
||||||
func HNSEndpointRequest(method, path, request string) (*HNSEndpoint, error) {
|
|
||||||
endpoint := &HNSEndpoint{}
|
|
||||||
err := hnsCall(method, "/endpoints/"+path, request, &endpoint)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return endpoint, nil
|
|
||||||
}
|
|
||||||
|
|
142
vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
generated
vendored
Normal file
142
vendor/github.com/Microsoft/hcsshim/hnsnetwork.go
generated
vendored
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
package hcsshim
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Subnet is assoicated with a network and represents a list
|
||||||
|
// of subnets available to the network
|
||||||
|
type Subnet struct {
|
||||||
|
AddressPrefix string `json:",omitempty"`
|
||||||
|
GatewayAddress string `json:",omitempty"`
|
||||||
|
Policies []json.RawMessage `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MacPool is assoicated with a network and represents a list
|
||||||
|
// of macaddresses available to the network
|
||||||
|
type MacPool struct {
|
||||||
|
StartMacAddress string `json:",omitempty"`
|
||||||
|
EndMacAddress string `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// HNSNetwork represents a network in HNS
|
||||||
|
type HNSNetwork struct {
|
||||||
|
Id string `json:"ID,omitempty"`
|
||||||
|
Name string `json:",omitempty"`
|
||||||
|
Type string `json:",omitempty"`
|
||||||
|
NetworkAdapterName string `json:",omitempty"`
|
||||||
|
SourceMac string `json:",omitempty"`
|
||||||
|
Policies []json.RawMessage `json:",omitempty"`
|
||||||
|
MacPools []MacPool `json:",omitempty"`
|
||||||
|
Subnets []Subnet `json:",omitempty"`
|
||||||
|
DNSSuffix string `json:",omitempty"`
|
||||||
|
DNSServerList string `json:",omitempty"`
|
||||||
|
DNSServerCompartment uint32 `json:",omitempty"`
|
||||||
|
ManagementIP string `json:",omitempty"`
|
||||||
|
AutomaticDNS bool `json:",omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type hnsNetworkResponse struct {
|
||||||
|
Success bool
|
||||||
|
Error string
|
||||||
|
Output HNSNetwork
|
||||||
|
}
|
||||||
|
|
||||||
|
type hnsResponse struct {
|
||||||
|
Success bool
|
||||||
|
Error string
|
||||||
|
Output json.RawMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
// HNSNetworkRequest makes a call into HNS to update/query a single network
|
||||||
|
func HNSNetworkRequest(method, path, request string) (*HNSNetwork, error) {
|
||||||
|
var network HNSNetwork
|
||||||
|
err := hnsCall(method, "/networks/"+path, request, &network)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &network, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HNSListNetworkRequest makes a HNS call to query the list of available networks
|
||||||
|
func HNSListNetworkRequest(method, path, request string) ([]HNSNetwork, error) {
|
||||||
|
var network []HNSNetwork
|
||||||
|
err := hnsCall(method, "/networks/"+path, request, &network)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return network, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHNSNetworkByID
|
||||||
|
func GetHNSNetworkByID(networkID string) (*HNSNetwork, error) {
|
||||||
|
return HNSNetworkRequest("GET", networkID, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetHNSNetworkName filtered by Name
|
||||||
|
func GetHNSNetworkByName(networkName string) (*HNSNetwork, error) {
|
||||||
|
hsnnetworks, err := HNSListNetworkRequest("GET", "", "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for _, hnsnetwork := range hsnnetworks {
|
||||||
|
if hnsnetwork.Name == networkName {
|
||||||
|
return &hnsnetwork, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Network %v not found", networkName)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create Network by sending NetworkRequest to HNS.
|
||||||
|
func (network *HNSNetwork) Create() (*HNSNetwork, error) {
|
||||||
|
operation := "Create"
|
||||||
|
title := "HCSShim::HNSNetwork::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", network.Id)
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(network)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return HNSNetworkRequest("POST", "", string(jsonString))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete Network by sending NetworkRequest to HNS
|
||||||
|
func (network *HNSNetwork) Delete() (*HNSNetwork, error) {
|
||||||
|
operation := "Delete"
|
||||||
|
title := "HCSShim::HNSNetwork::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", network.Id)
|
||||||
|
|
||||||
|
return HNSNetworkRequest("DELETE", network.Id, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creates an endpoint on the Network.
|
||||||
|
func (network *HNSNetwork) NewEndpoint(ipAddress net.IP, macAddress net.HardwareAddr) *HNSEndpoint {
|
||||||
|
return &HNSEndpoint{
|
||||||
|
VirtualNetwork: network.Id,
|
||||||
|
IPAddress: ipAddress,
|
||||||
|
MacAddress: string(macAddress),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (network *HNSNetwork) CreateEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
|
||||||
|
operation := "CreateEndpoint"
|
||||||
|
title := "HCSShim::HNSNetwork::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s, endpointId=%s", network.Id, endpoint.Id)
|
||||||
|
|
||||||
|
endpoint.VirtualNetwork = network.Id
|
||||||
|
return endpoint.Create()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (network *HNSNetwork) CreateRemoteEndpoint(endpoint *HNSEndpoint) (*HNSEndpoint, error) {
|
||||||
|
operation := "CreateRemoteEndpoint"
|
||||||
|
title := "HCSShim::HNSNetwork::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", network.Id)
|
||||||
|
endpoint.IsRemoteEndpoint = true
|
||||||
|
return network.CreateEndpoint(endpoint)
|
||||||
|
}
|
95
vendor/github.com/Microsoft/hcsshim/hnspolicy.go
generated
vendored
Normal file
95
vendor/github.com/Microsoft/hcsshim/hnspolicy.go
generated
vendored
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
package hcsshim
|
||||||
|
|
||||||
|
// Type of Request Support in ModifySystem
|
||||||
|
type PolicyType string
|
||||||
|
|
||||||
|
// RequestType const
|
||||||
|
const (
|
||||||
|
Nat PolicyType = "NAT"
|
||||||
|
ACL PolicyType = "ACL"
|
||||||
|
PA PolicyType = "PA"
|
||||||
|
VLAN PolicyType = "VLAN"
|
||||||
|
VSID PolicyType = "VSID"
|
||||||
|
VNet PolicyType = "VNET"
|
||||||
|
L2Driver PolicyType = "L2Driver"
|
||||||
|
Isolation PolicyType = "Isolation"
|
||||||
|
QOS PolicyType = "QOS"
|
||||||
|
OutboundNat PolicyType = "OutBoundNAT"
|
||||||
|
ExternalLoadBalancer PolicyType = "ELB"
|
||||||
|
Route PolicyType = "ROUTE"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NatPolicy struct {
|
||||||
|
Type PolicyType `json:"Type"`
|
||||||
|
Protocol string
|
||||||
|
InternalPort uint16
|
||||||
|
ExternalPort uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
type QosPolicy struct {
|
||||||
|
Type PolicyType `json:"Type"`
|
||||||
|
MaximumOutgoingBandwidthInBytes uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
type IsolationPolicy struct {
|
||||||
|
Type PolicyType `json:"Type"`
|
||||||
|
VLAN uint
|
||||||
|
VSID uint
|
||||||
|
InDefaultIsolation bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type VlanPolicy struct {
|
||||||
|
Type PolicyType `json:"Type"`
|
||||||
|
VLAN uint
|
||||||
|
}
|
||||||
|
|
||||||
|
type VsidPolicy struct {
|
||||||
|
Type PolicyType `json:"Type"`
|
||||||
|
VSID uint
|
||||||
|
}
|
||||||
|
|
||||||
|
type PaPolicy struct {
|
||||||
|
Type PolicyType `json:"Type"`
|
||||||
|
PA string `json:"PA"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OutboundNatPolicy struct {
|
||||||
|
Policy
|
||||||
|
VIP string `json:"VIP,omitempty"`
|
||||||
|
Exceptions []string `json:"ExceptionList,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ActionType string
|
||||||
|
type DirectionType string
|
||||||
|
type RuleType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
Allow ActionType = "Allow"
|
||||||
|
Block ActionType = "Block"
|
||||||
|
|
||||||
|
In DirectionType = "In"
|
||||||
|
Out DirectionType = "Out"
|
||||||
|
|
||||||
|
Host RuleType = "Host"
|
||||||
|
Switch RuleType = "Switch"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ACLPolicy struct {
|
||||||
|
Type PolicyType `json:"Type"`
|
||||||
|
Protocol uint16
|
||||||
|
InternalPort uint16
|
||||||
|
Action ActionType
|
||||||
|
Direction DirectionType
|
||||||
|
LocalAddress string
|
||||||
|
RemoteAddress string
|
||||||
|
LocalPort uint16
|
||||||
|
RemotePort uint16
|
||||||
|
RuleType RuleType `json:"RuleType,omitempty"`
|
||||||
|
|
||||||
|
Priority uint16
|
||||||
|
ServiceName string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Policy struct {
|
||||||
|
Type PolicyType `json:"Type"`
|
||||||
|
}
|
196
vendor/github.com/Microsoft/hcsshim/hnspolicylist.go
generated
vendored
Normal file
196
vendor/github.com/Microsoft/hcsshim/hnspolicylist.go
generated
vendored
Normal file
|
@ -0,0 +1,196 @@
|
||||||
|
package hcsshim
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoutePolicy is a structure defining schema for Route based Policy
|
||||||
|
type RoutePolicy struct {
|
||||||
|
Policy
|
||||||
|
DestinationPrefix string `json:"DestinationPrefix,omitempty"`
|
||||||
|
NextHop string `json:"NextHop,omitempty"`
|
||||||
|
EncapEnabled bool `json:"NeedEncap,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ELBPolicy is a structure defining schema for ELB LoadBalancing based Policy
|
||||||
|
type ELBPolicy struct {
|
||||||
|
LBPolicy
|
||||||
|
SourceVIP string `json:"SourceVIP,omitempty"`
|
||||||
|
VIPs []string `json:"VIPs,omitempty"`
|
||||||
|
ILB bool `json:"ILB,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LBPolicy is a structure defining schema for LoadBalancing based Policy
|
||||||
|
type LBPolicy struct {
|
||||||
|
Policy
|
||||||
|
Protocol uint16 `json:"Protocol,omitempty"`
|
||||||
|
InternalPort uint16
|
||||||
|
ExternalPort uint16
|
||||||
|
}
|
||||||
|
|
||||||
|
// PolicyList is a structure defining schema for Policy list request
|
||||||
|
type PolicyList struct {
|
||||||
|
ID string `json:"ID,omitempty"`
|
||||||
|
EndpointReferences []string `json:"References,omitempty"`
|
||||||
|
Policies []json.RawMessage `json:"Policies,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// HNSPolicyListRequest makes a call into HNS to update/query a single network
|
||||||
|
func HNSPolicyListRequest(method, path, request string) (*PolicyList, error) {
|
||||||
|
var policy PolicyList
|
||||||
|
err := hnsCall(method, "/policylists/"+path, request, &policy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &policy, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// HNSListPolicyListRequest gets all the policy list
|
||||||
|
func HNSListPolicyListRequest() ([]PolicyList, error) {
|
||||||
|
var plist []PolicyList
|
||||||
|
err := hnsCall("GET", "/policylists/", "", &plist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return plist, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PolicyListRequest makes a HNS call to modify/query a network policy list
|
||||||
|
func PolicyListRequest(method, path, request string) (*PolicyList, error) {
|
||||||
|
policylist := &PolicyList{}
|
||||||
|
err := hnsCall(method, "/policylists/"+path, request, &policylist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return policylist, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPolicyListByID get the policy list by ID
|
||||||
|
func GetPolicyListByID(policyListID string) (*PolicyList, error) {
|
||||||
|
return PolicyListRequest("GET", policyListID, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create PolicyList by sending PolicyListRequest to HNS.
|
||||||
|
func (policylist *PolicyList) Create() (*PolicyList, error) {
|
||||||
|
operation := "Create"
|
||||||
|
title := "HCSShim::PolicyList::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", policylist.ID)
|
||||||
|
jsonString, err := json.Marshal(policylist)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return PolicyListRequest("POST", "", string(jsonString))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes PolicyList
|
||||||
|
func (policylist *PolicyList) Delete() (*PolicyList, error) {
|
||||||
|
operation := "Delete"
|
||||||
|
title := "HCSShim::PolicyList::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s", policylist.ID)
|
||||||
|
|
||||||
|
return PolicyListRequest("DELETE", policylist.ID, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEndpoint add an endpoint to a Policy List
|
||||||
|
func (policylist *PolicyList) AddEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
|
||||||
|
operation := "AddEndpoint"
|
||||||
|
title := "HCSShim::PolicyList::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s, endpointId:%s", policylist.ID, endpoint.Id)
|
||||||
|
|
||||||
|
_, err := policylist.Delete()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Endpoint to the Existing List
|
||||||
|
policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
|
||||||
|
|
||||||
|
return policylist.Create()
|
||||||
|
}
|
||||||
|
|
||||||
|
// RemoveEndpoint removes an endpoint from the Policy List
|
||||||
|
func (policylist *PolicyList) RemoveEndpoint(endpoint *HNSEndpoint) (*PolicyList, error) {
|
||||||
|
operation := "RemoveEndpoint"
|
||||||
|
title := "HCSShim::PolicyList::" + operation
|
||||||
|
logrus.Debugf(title+" id=%s, endpointId:%s", policylist.ID, endpoint.Id)
|
||||||
|
|
||||||
|
_, err := policylist.Delete()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
elementToRemove := "/endpoints/" + endpoint.Id
|
||||||
|
|
||||||
|
var references []string
|
||||||
|
|
||||||
|
for _, endpointReference := range policylist.EndpointReferences {
|
||||||
|
if endpointReference == elementToRemove {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
references = append(references, endpointReference)
|
||||||
|
}
|
||||||
|
policylist.EndpointReferences = references
|
||||||
|
return policylist.Create()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddLoadBalancer policy list for the specified endpoints
|
||||||
|
func AddLoadBalancer(endpoints []HNSEndpoint, isILB bool, vip string, protocol uint16, internalPort uint16, externalPort uint16) (*PolicyList, error) {
|
||||||
|
operation := "AddLoadBalancer"
|
||||||
|
title := "HCSShim::PolicyList::" + operation
|
||||||
|
logrus.Debugf(title+" Vip:%s", vip)
|
||||||
|
|
||||||
|
policylist := &PolicyList{}
|
||||||
|
|
||||||
|
elbPolicy := &ELBPolicy{
|
||||||
|
VIPs: []string{vip},
|
||||||
|
ILB: isILB,
|
||||||
|
}
|
||||||
|
elbPolicy.Type = ExternalLoadBalancer
|
||||||
|
elbPolicy.Protocol = protocol
|
||||||
|
elbPolicy.InternalPort = internalPort
|
||||||
|
elbPolicy.ExternalPort = externalPort
|
||||||
|
|
||||||
|
for _, endpoint := range endpoints {
|
||||||
|
policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(elbPolicy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
policylist.Policies = append(policylist.Policies, jsonString)
|
||||||
|
return policylist.Create()
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddRoute adds route policy list for the specified endpoints
|
||||||
|
func AddRoute(endpoints []HNSEndpoint, destinationPrefix string, nextHop string, encapEnabled bool) (*PolicyList, error) {
|
||||||
|
operation := "AddRoute"
|
||||||
|
title := "HCSShim::PolicyList::" + operation
|
||||||
|
logrus.Debugf(title+" destinationPrefix:%s", destinationPrefix)
|
||||||
|
|
||||||
|
policylist := &PolicyList{}
|
||||||
|
|
||||||
|
rPolicy := &RoutePolicy{
|
||||||
|
DestinationPrefix: destinationPrefix,
|
||||||
|
NextHop: nextHop,
|
||||||
|
EncapEnabled: encapEnabled,
|
||||||
|
}
|
||||||
|
rPolicy.Type = Route
|
||||||
|
|
||||||
|
for _, endpoint := range endpoints {
|
||||||
|
policylist.EndpointReferences = append(policylist.EndpointReferences, "/endpoints/"+endpoint.Id)
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonString, err := json.Marshal(rPolicy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
policylist.Policies = append(policylist.Policies, jsonString)
|
||||||
|
return policylist.Create()
|
||||||
|
}
|
4
vendor/github.com/Microsoft/hcsshim/importlayer.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/importlayer.go
generated
vendored
|
@ -5,10 +5,9 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
|
|
||||||
"github.com/Microsoft/go-winio"
|
"github.com/Microsoft/go-winio"
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImportLayer will take the contents of the folder at importFolderPath and import
|
// ImportLayer will take the contents of the folder at importFolderPath and import
|
||||||
|
@ -209,6 +208,5 @@ func NewLayerWriter(info DriverInfo, layerID string, parentLayerPaths []string)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, makeError(err, "ImportLayerStart", "")
|
return nil, makeError(err, "ImportLayerStart", "")
|
||||||
}
|
}
|
||||||
runtime.SetFinalizer(w, func(w *FilterLayerWriter) { w.Close() })
|
|
||||||
return w, nil
|
return w, nil
|
||||||
}
|
}
|
||||||
|
|
107
vendor/github.com/Microsoft/hcsshim/interface.go
generated
vendored
107
vendor/github.com/Microsoft/hcsshim/interface.go
generated
vendored
|
@ -1,6 +1,7 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -8,16 +9,19 @@ import (
|
||||||
// ProcessConfig is used as both the input of Container.CreateProcess
|
// ProcessConfig is used as both the input of Container.CreateProcess
|
||||||
// and to convert the parameters to JSON for passing onto the HCS
|
// and to convert the parameters to JSON for passing onto the HCS
|
||||||
type ProcessConfig struct {
|
type ProcessConfig struct {
|
||||||
ApplicationName string
|
ApplicationName string `json:",omitempty"`
|
||||||
CommandLine string
|
CommandLine string `json:",omitempty"`
|
||||||
User string
|
CommandArgs []string `json:",omitempty"` // Used by Linux Containers on Windows
|
||||||
WorkingDirectory string
|
User string `json:",omitempty"`
|
||||||
Environment map[string]string
|
WorkingDirectory string `json:",omitempty"`
|
||||||
EmulateConsole bool
|
Environment map[string]string `json:",omitempty"`
|
||||||
CreateStdInPipe bool
|
EmulateConsole bool `json:",omitempty"`
|
||||||
CreateStdOutPipe bool
|
CreateStdInPipe bool `json:",omitempty"`
|
||||||
CreateStdErrPipe bool
|
CreateStdOutPipe bool `json:",omitempty"`
|
||||||
ConsoleSize [2]uint
|
CreateStdErrPipe bool `json:",omitempty"`
|
||||||
|
ConsoleSize [2]uint `json:",omitempty"`
|
||||||
|
CreateInUtilityVm bool `json:",omitempty"` // Used by Linux Containers on Windows
|
||||||
|
OCISpecification *json.RawMessage `json:",omitempty"` // Used by Linux Containers on Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
type Layer struct {
|
type Layer struct {
|
||||||
|
@ -33,40 +37,61 @@ type MappedDir struct {
|
||||||
IOPSMaximum uint64
|
IOPSMaximum uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MappedPipe struct {
|
||||||
|
HostPath string
|
||||||
|
ContainerPipeName string
|
||||||
|
}
|
||||||
|
|
||||||
type HvRuntime struct {
|
type HvRuntime struct {
|
||||||
ImagePath string `json:",omitempty"`
|
ImagePath string `json:",omitempty"`
|
||||||
SkipTemplate bool `json:",omitempty"`
|
SkipTemplate bool `json:",omitempty"`
|
||||||
|
LinuxInitrdFile string `json:",omitempty"` // File under ImagePath on host containing an initrd image for starting a Linux utility VM
|
||||||
|
LinuxKernelFile string `json:",omitempty"` // File under ImagePath on host containing a kernel for starting a Linux utility VM
|
||||||
|
LinuxBootParameters string `json:",omitempty"` // Additional boot parameters for starting a Linux Utility VM in initrd mode
|
||||||
|
BootSource string `json:",omitempty"` // "Vhd" for Linux Utility VM booting from VHD
|
||||||
|
WritableBootSource bool `json:",omitempty"` // Linux Utility VM booting from VHD
|
||||||
|
}
|
||||||
|
|
||||||
|
type MappedVirtualDisk struct {
|
||||||
|
HostPath string `json:",omitempty"` // Path to VHD on the host
|
||||||
|
ContainerPath string // Platform-specific mount point path in the container
|
||||||
|
CreateInUtilityVM bool `json:",omitempty"`
|
||||||
|
ReadOnly bool `json:",omitempty"`
|
||||||
|
Cache string `json:",omitempty"` // "" (Unspecified); "Disabled"; "Enabled"; "Private"; "PrivateAllowSharing"
|
||||||
|
AttachOnly bool `json:",omitempty:`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerConfig is used as both the input of CreateContainer
|
// ContainerConfig is used as both the input of CreateContainer
|
||||||
// and to convert the parameters to JSON for passing onto the HCS
|
// and to convert the parameters to JSON for passing onto the HCS
|
||||||
type ContainerConfig struct {
|
type ContainerConfig struct {
|
||||||
SystemType string // HCS requires this to be hard-coded to "Container"
|
SystemType string // HCS requires this to be hard-coded to "Container"
|
||||||
Name string // Name of the container. We use the docker ID.
|
Name string // Name of the container. We use the docker ID.
|
||||||
Owner string // The management platform that created this container
|
Owner string `json:",omitempty"` // The management platform that created this container
|
||||||
IsDummy bool // Used for development purposes.
|
VolumePath string `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID}
|
||||||
VolumePath string `json:",omitempty"` // Windows volume path for scratch space. Used by Windows Server Containers only. Format \\?\\Volume{GUID}
|
IgnoreFlushesDuringBoot bool `json:",omitempty"` // Optimization hint for container startup in Windows
|
||||||
IgnoreFlushesDuringBoot bool // Optimization hint for container startup in Windows
|
LayerFolderPath string `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format %root%\windowsfilter\containerID
|
||||||
LayerFolderPath string `json:",omitempty"` // Where the layer folders are located. Used by Windows Server Containers only. Format %root%\windowsfilter\containerID
|
Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID
|
||||||
Layers []Layer // List of storage layers. Required for Windows Server and Hyper-V Containers. Format ID=GUID;Path=%root%\windowsfilter\layerID
|
Credentials string `json:",omitempty"` // Credentials information
|
||||||
Credentials string `json:",omitempty"` // Credentials information
|
ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container.
|
||||||
ProcessorCount uint32 `json:",omitempty"` // Number of processors to assign to the container.
|
ProcessorWeight uint64 `json:",omitempty"` // CPU shares (relative weight to other containers with cpu shares). Range is from 1 to 10000. A value of 0 results in default shares.
|
||||||
ProcessorWeight uint64 `json:",omitempty"` // CPU Shares 0..10000 on Windows; where 0 will be omitted and HCS will default.
|
ProcessorMaximum int64 `json:",omitempty"` // Specifies the portion of processor cycles that this container can use as a percentage times 100. Range is from 1 to 10000. A value of 0 results in no limit.
|
||||||
ProcessorMaximum int64 `json:",omitempty"` // CPU maximum usage percent 1..100
|
StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS
|
||||||
StorageIOPSMaximum uint64 `json:",omitempty"` // Maximum Storage IOPS
|
StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second
|
||||||
StorageBandwidthMaximum uint64 `json:",omitempty"` // Maximum Storage Bandwidth in bytes per second
|
StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller
|
||||||
StorageSandboxSize uint64 `json:",omitempty"` // Size in bytes that the container system drive should be expanded to if smaller
|
MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes
|
||||||
MemoryMaximumInMB int64 `json:",omitempty"` // Maximum memory available to the container in Megabytes
|
HostName string `json:",omitempty"` // Hostname
|
||||||
HostName string // Hostname
|
MappedDirectories []MappedDir `json:",omitempty"` // List of mapped directories (volumes/mounts)
|
||||||
MappedDirectories []MappedDir // List of mapped directories (volumes/mounts)
|
MappedPipes []MappedPipe `json:",omitempty"` // List of mapped Windows named pipes
|
||||||
SandboxPath string `json:",omitempty"` // Location of unmounted sandbox. Used by Hyper-V containers only. Format %root%\windowsfilter
|
HvPartition bool // True if it a Hyper-V Container
|
||||||
HvPartition bool // True if it a Hyper-V Container
|
NetworkSharedContainerName string `json:",omitempty"` // Name (ID) of the container that we will share the network stack with.
|
||||||
EndpointList []string // List of networking endpoints to be attached to container
|
EndpointList []string `json:",omitempty"` // List of networking endpoints to be attached to container
|
||||||
NetworkSharedContainerName string `json:",omitempty"` // Name (ID) of the container that we will share the network stack with.
|
HvRuntime *HvRuntime `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM
|
||||||
HvRuntime *HvRuntime `json:",omitempty"` // Hyper-V container settings. Used by Hyper-V containers only. Format ImagePath=%root%\BaseLayerID\UtilityVM
|
Servicing bool `json:",omitempty"` // True if this container is for servicing
|
||||||
Servicing bool // True if this container is for servicing
|
AllowUnqualifiedDNSQuery bool `json:",omitempty"` // True to allow unqualified DNS name resolution
|
||||||
AllowUnqualifiedDNSQuery bool // True to allow unqualified DNS name resolution
|
DNSSearchList string `json:",omitempty"` // Comma seperated list of DNS suffixes to use for name resolution
|
||||||
DNSSearchList string `json:",omitempty"` // Comma seperated list of DNS suffixes to use for name resolution
|
ContainerType string `json:",omitempty"` // "Linux" for Linux containers on Windows. Omitted otherwise.
|
||||||
|
TerminateOnLastHandleClosed bool `json:",omitempty"` // Should HCS terminate the container once all handles have been closed
|
||||||
|
MappedVirtualDisks []MappedVirtualDisk `json:",omitempty"` // Array of virtual disks to mount at start
|
||||||
}
|
}
|
||||||
|
|
||||||
type ComputeSystemQuery struct {
|
type ComputeSystemQuery struct {
|
||||||
|
@ -109,6 +134,9 @@ type Container interface {
|
||||||
// ProcessList returns details for the processes in a container.
|
// ProcessList returns details for the processes in a container.
|
||||||
ProcessList() ([]ProcessListItem, error)
|
ProcessList() ([]ProcessListItem, error)
|
||||||
|
|
||||||
|
// MappedVirtualDisks returns virtual disks mapped to a utility VM, indexed by controller
|
||||||
|
MappedVirtualDisks() (map[int]MappedVirtualDiskController, error)
|
||||||
|
|
||||||
// CreateProcess launches a new process within the container.
|
// CreateProcess launches a new process within the container.
|
||||||
CreateProcess(c *ProcessConfig) (Process, error)
|
CreateProcess(c *ProcessConfig) (Process, error)
|
||||||
|
|
||||||
|
@ -117,6 +145,9 @@ type Container interface {
|
||||||
|
|
||||||
// Close cleans up any state associated with the container but does not terminate or wait for it.
|
// Close cleans up any state associated with the container but does not terminate or wait for it.
|
||||||
Close() error
|
Close() error
|
||||||
|
|
||||||
|
// Modify the System
|
||||||
|
Modify(config *ResourceModificationRequestResponse) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process represents a running or exited process.
|
// Process represents a running or exited process.
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/layerexists.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/layerexists.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// LayerExists will return true if a layer with the given id exists and is known
|
// LayerExists will return true if a layer with the given id exists and is known
|
||||||
// to the system.
|
// to the system.
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/layerutils.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/layerutils.go
generated
vendored
|
@ -7,7 +7,7 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
/* To pass into syscall, we need a struct matching the following:
|
/* To pass into syscall, we need a struct matching the following:
|
||||||
|
|
58
vendor/github.com/Microsoft/hcsshim/legacy.go
generated
vendored
58
vendor/github.com/Microsoft/hcsshim/legacy.go
generated
vendored
|
@ -23,6 +23,13 @@ var mutatedUtilityVMFiles = map[string]bool{
|
||||||
`EFI\Microsoft\Boot\BCD.LOG2`: true,
|
`EFI\Microsoft\Boot\BCD.LOG2`: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
filesPath = `Files`
|
||||||
|
hivesPath = `Hives`
|
||||||
|
utilityVMPath = `UtilityVM`
|
||||||
|
utilityVMFilesPath = `UtilityVM\Files`
|
||||||
|
)
|
||||||
|
|
||||||
func openFileOrDir(path string, mode uint32, createDisposition uint32) (file *os.File, err error) {
|
func openFileOrDir(path string, mode uint32, createDisposition uint32) (file *os.File, err error) {
|
||||||
return winio.OpenForBackup(path, mode, syscall.FILE_SHARE_READ, createDisposition)
|
return winio.OpenForBackup(path, mode, syscall.FILE_SHARE_READ, createDisposition)
|
||||||
}
|
}
|
||||||
|
@ -44,6 +51,10 @@ func makeLongAbsPath(path string) (string, error) {
|
||||||
return `\\?\` + path, nil
|
return `\\?\` + path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hasPathPrefix(p, prefix string) bool {
|
||||||
|
return strings.HasPrefix(p, prefix) && len(p) > len(prefix) && p[len(prefix)] == '\\'
|
||||||
|
}
|
||||||
|
|
||||||
type fileEntry struct {
|
type fileEntry struct {
|
||||||
path string
|
path string
|
||||||
fi os.FileInfo
|
fi os.FileInfo
|
||||||
|
@ -83,7 +94,7 @@ func readTombstones(path string) (map[string]([]string), error) {
|
||||||
|
|
||||||
ts := make(map[string]([]string))
|
ts := make(map[string]([]string))
|
||||||
for s.Scan() {
|
for s.Scan() {
|
||||||
t := filepath.Join("Files", s.Text()[1:]) // skip leading `\`
|
t := filepath.Join(filesPath, s.Text()[1:]) // skip leading `\`
|
||||||
dir := filepath.Dir(t)
|
dir := filepath.Dir(t)
|
||||||
ts[dir] = append(ts[dir], t)
|
ts[dir] = append(ts[dir], t)
|
||||||
}
|
}
|
||||||
|
@ -212,7 +223,7 @@ func (r *legacyLayerReader) Next() (path string, size int64, fileInfo *winio.Fil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if fe.fi.IsDir() && strings.HasPrefix(path, `Files\`) {
|
if fe.fi.IsDir() && hasPathPrefix(path, filesPath) {
|
||||||
fe.path += ".$wcidirs$"
|
fe.path += ".$wcidirs$"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,14 +242,14 @@ func (r *legacyLayerReader) Next() (path string, size int64, fileInfo *winio.Fil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(path, `Files\`) {
|
if !hasPathPrefix(path, filesPath) {
|
||||||
size = fe.fi.Size()
|
size = fe.fi.Size()
|
||||||
r.backupReader = winio.NewBackupFileReader(f, false)
|
r.backupReader = winio.NewBackupFileReader(f, false)
|
||||||
if path == "Hives" || path == "Files" {
|
if path == hivesPath || path == filesPath {
|
||||||
// The Hives directory has a non-deterministic file time because of the
|
// The Hives directory has a non-deterministic file time because of the
|
||||||
// nature of the import process. Use the times from System_Delta.
|
// nature of the import process. Use the times from System_Delta.
|
||||||
var g *os.File
|
var g *os.File
|
||||||
g, err = os.Open(filepath.Join(r.root, `Hives\System_Delta`))
|
g, err = os.Open(filepath.Join(r.root, hivesPath, `System_Delta`))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -296,6 +307,16 @@ func (r *legacyLayerReader) Read(b []byte) (int, error) {
|
||||||
return r.backupReader.Read(b)
|
return r.backupReader.Read(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *legacyLayerReader) Seek(offset int64, whence int) (int64, error) {
|
||||||
|
if r.backupReader == nil {
|
||||||
|
if r.currentFile == nil {
|
||||||
|
return 0, errors.New("no current file")
|
||||||
|
}
|
||||||
|
return r.currentFile.Seek(offset, whence)
|
||||||
|
}
|
||||||
|
return 0, errors.New("seek not supported on this stream")
|
||||||
|
}
|
||||||
|
|
||||||
func (r *legacyLayerReader) Close() error {
|
func (r *legacyLayerReader) Close() error {
|
||||||
r.proceed <- false
|
r.proceed <- false
|
||||||
<-r.result
|
<-r.result
|
||||||
|
@ -357,7 +378,7 @@ func (w *legacyLayerWriter) init() error {
|
||||||
|
|
||||||
func (w *legacyLayerWriter) initUtilityVM() error {
|
func (w *legacyLayerWriter) initUtilityVM() error {
|
||||||
if !w.HasUtilityVM {
|
if !w.HasUtilityVM {
|
||||||
err := os.Mkdir(filepath.Join(w.destRoot, `UtilityVM`), 0)
|
err := os.Mkdir(filepath.Join(w.destRoot, utilityVMPath), 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -365,7 +386,7 @@ func (w *legacyLayerWriter) initUtilityVM() error {
|
||||||
// clone the utility VM from the parent layer into this layer. Use hard
|
// clone the utility VM from the parent layer into this layer. Use hard
|
||||||
// links to avoid unnecessary copying, since most of the files are
|
// links to avoid unnecessary copying, since most of the files are
|
||||||
// immutable.
|
// immutable.
|
||||||
err = cloneTree(filepath.Join(w.parentRoots[0], `UtilityVM\Files`), filepath.Join(w.destRoot, `UtilityVM\Files`), mutatedUtilityVMFiles)
|
err = cloneTree(filepath.Join(w.parentRoots[0], utilityVMFilesPath), filepath.Join(w.destRoot, utilityVMFilesPath), mutatedUtilityVMFiles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cloning the parent utility VM image failed: %s", err)
|
return fmt.Errorf("cloning the parent utility VM image failed: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -490,15 +511,15 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if name == `UtilityVM` {
|
if name == utilityVMPath {
|
||||||
return w.initUtilityVM()
|
return w.initUtilityVM()
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(name, `UtilityVM\`) {
|
if hasPathPrefix(name, utilityVMPath) {
|
||||||
if !w.HasUtilityVM {
|
if !w.HasUtilityVM {
|
||||||
return errors.New("missing UtilityVM directory")
|
return errors.New("missing UtilityVM directory")
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(name, `UtilityVM\Files\`) && name != `UtilityVM\Files` {
|
if !hasPathPrefix(name, utilityVMFilesPath) && name != utilityVMFilesPath {
|
||||||
return errors.New("invalid UtilityVM layer")
|
return errors.New("invalid UtilityVM layer")
|
||||||
}
|
}
|
||||||
path := filepath.Join(w.destRoot, name)
|
path := filepath.Join(w.destRoot, name)
|
||||||
|
@ -585,7 +606,7 @@ func (w *legacyLayerWriter) Add(name string, fileInfo *winio.FileBasicInfo) erro
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(name, `Hives\`) {
|
if hasPathPrefix(name, hivesPath) {
|
||||||
w.backupWriter = winio.NewBackupFileWriter(f, false)
|
w.backupWriter = winio.NewBackupFileWriter(f, false)
|
||||||
} else {
|
} else {
|
||||||
// The file attributes are written before the stream.
|
// The file attributes are written before the stream.
|
||||||
|
@ -608,22 +629,19 @@ func (w *legacyLayerWriter) AddLink(name string, target string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
var requiredPrefix string
|
|
||||||
var roots []string
|
var roots []string
|
||||||
if prefix := `Files\`; strings.HasPrefix(name, prefix) {
|
if hasPathPrefix(target, filesPath) {
|
||||||
requiredPrefix = prefix
|
|
||||||
// Look for cross-layer hard link targets in the parent layers, since
|
// Look for cross-layer hard link targets in the parent layers, since
|
||||||
// nothing is in the destination path yet.
|
// nothing is in the destination path yet.
|
||||||
roots = w.parentRoots
|
roots = w.parentRoots
|
||||||
} else if prefix := `UtilityVM\Files\`; strings.HasPrefix(name, prefix) {
|
} else if hasPathPrefix(target, utilityVMFilesPath) {
|
||||||
requiredPrefix = prefix
|
|
||||||
// Since the utility VM is fully cloned into the destination path
|
// Since the utility VM is fully cloned into the destination path
|
||||||
// already, look for cross-layer hard link targets directly in the
|
// already, look for cross-layer hard link targets directly in the
|
||||||
// destination path.
|
// destination path.
|
||||||
roots = []string{w.destRoot}
|
roots = []string{w.destRoot}
|
||||||
}
|
}
|
||||||
|
|
||||||
if requiredPrefix == "" || !strings.HasPrefix(target, requiredPrefix) {
|
if roots == nil || (!hasPathPrefix(name, filesPath) && !hasPathPrefix(name, utilityVMFilesPath)) {
|
||||||
return errors.New("invalid hard link in layer")
|
return errors.New("invalid hard link in layer")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -657,9 +675,9 @@ func (w *legacyLayerWriter) AddLink(name string, target string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *legacyLayerWriter) Remove(name string) error {
|
func (w *legacyLayerWriter) Remove(name string) error {
|
||||||
if strings.HasPrefix(name, `Files\`) {
|
if hasPathPrefix(name, filesPath) {
|
||||||
w.tombstones = append(w.tombstones, name[len(`Files\`):])
|
w.tombstones = append(w.tombstones, name[len(filesPath)+1:])
|
||||||
} else if strings.HasPrefix(name, `UtilityVM\Files\`) {
|
} else if hasPathPrefix(name, utilityVMFilesPath) {
|
||||||
err := w.initUtilityVM()
|
err := w.initUtilityVM()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
934
vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go
generated
vendored
Normal file
934
vendor/github.com/Microsoft/hcsshim/mksyscall_windows.go
generated
vendored
Normal file
|
@ -0,0 +1,934 @@
|
||||||
|
// Copyright 2013 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 ignore
|
||||||
|
|
||||||
|
/*
|
||||||
|
mksyscall_windows generates windows system call bodies
|
||||||
|
|
||||||
|
It parses all files specified on command line containing function
|
||||||
|
prototypes (like syscall_windows.go) and prints system call bodies
|
||||||
|
to standard output.
|
||||||
|
|
||||||
|
The prototypes are marked by lines beginning with "//sys" and read
|
||||||
|
like func declarations if //sys is replaced by func, but:
|
||||||
|
|
||||||
|
* The parameter lists must give a name for each argument. This
|
||||||
|
includes return parameters.
|
||||||
|
|
||||||
|
* The parameter lists must give a type for each argument:
|
||||||
|
the (x, y, z int) shorthand is not allowed.
|
||||||
|
|
||||||
|
* If the return parameter is an error number, it must be named err.
|
||||||
|
|
||||||
|
* If go func name needs to be different from it's winapi dll name,
|
||||||
|
the winapi name could be specified at the end, after "=" sign, like
|
||||||
|
//sys LoadLibrary(libname string) (handle uint32, err error) = LoadLibraryA
|
||||||
|
|
||||||
|
* Each function that returns err needs to supply a condition, that
|
||||||
|
return value of winapi will be tested against to detect failure.
|
||||||
|
This would set err to windows "last-error", otherwise it will be nil.
|
||||||
|
The value can be provided at end of //sys declaration, like
|
||||||
|
//sys LoadLibrary(libname string) (handle uint32, err error) [failretval==-1] = LoadLibraryA
|
||||||
|
and is [failretval==0] by default.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
mksyscall_windows [flags] [path ...]
|
||||||
|
|
||||||
|
The flags are:
|
||||||
|
-output
|
||||||
|
Specify output file name (outputs to console if blank).
|
||||||
|
-trace
|
||||||
|
Generate print statement after every syscall.
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"go/format"
|
||||||
|
"go/parser"
|
||||||
|
"go/token"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"text/template"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
filename = flag.String("output", "", "output file name (standard output if omitted)")
|
||||||
|
printTraceFlag = flag.Bool("trace", false, "generate print statement after every syscall")
|
||||||
|
systemDLL = flag.Bool("systemdll", true, "whether all DLLs should be loaded from the Windows system directory")
|
||||||
|
)
|
||||||
|
|
||||||
|
func trim(s string) string {
|
||||||
|
return strings.Trim(s, " \t")
|
||||||
|
}
|
||||||
|
|
||||||
|
var packageName string
|
||||||
|
|
||||||
|
func packagename() string {
|
||||||
|
return packageName
|
||||||
|
}
|
||||||
|
|
||||||
|
func syscalldot() string {
|
||||||
|
if packageName == "syscall" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return "syscall."
|
||||||
|
}
|
||||||
|
|
||||||
|
// Param is function parameter
|
||||||
|
type Param struct {
|
||||||
|
Name string
|
||||||
|
Type string
|
||||||
|
fn *Fn
|
||||||
|
tmpVarIdx int
|
||||||
|
}
|
||||||
|
|
||||||
|
// tmpVar returns temp variable name that will be used to represent p during syscall.
|
||||||
|
func (p *Param) tmpVar() string {
|
||||||
|
if p.tmpVarIdx < 0 {
|
||||||
|
p.tmpVarIdx = p.fn.curTmpVarIdx
|
||||||
|
p.fn.curTmpVarIdx++
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("_p%d", p.tmpVarIdx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BoolTmpVarCode returns source code for bool temp variable.
|
||||||
|
func (p *Param) BoolTmpVarCode() string {
|
||||||
|
const code = `var %s uint32
|
||||||
|
if %s {
|
||||||
|
%s = 1
|
||||||
|
} else {
|
||||||
|
%s = 0
|
||||||
|
}`
|
||||||
|
tmp := p.tmpVar()
|
||||||
|
return fmt.Sprintf(code, tmp, p.Name, tmp, tmp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SliceTmpVarCode returns source code for slice temp variable.
|
||||||
|
func (p *Param) SliceTmpVarCode() string {
|
||||||
|
const code = `var %s *%s
|
||||||
|
if len(%s) > 0 {
|
||||||
|
%s = &%s[0]
|
||||||
|
}`
|
||||||
|
tmp := p.tmpVar()
|
||||||
|
return fmt.Sprintf(code, tmp, p.Type[2:], p.Name, tmp, p.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// StringTmpVarCode returns source code for string temp variable.
|
||||||
|
func (p *Param) StringTmpVarCode() string {
|
||||||
|
errvar := p.fn.Rets.ErrorVarName()
|
||||||
|
if errvar == "" {
|
||||||
|
errvar = "_"
|
||||||
|
}
|
||||||
|
tmp := p.tmpVar()
|
||||||
|
const code = `var %s %s
|
||||||
|
%s, %s = %s(%s)`
|
||||||
|
s := fmt.Sprintf(code, tmp, p.fn.StrconvType(), tmp, errvar, p.fn.StrconvFunc(), p.Name)
|
||||||
|
if errvar == "-" {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
const morecode = `
|
||||||
|
if %s != nil {
|
||||||
|
return
|
||||||
|
}`
|
||||||
|
return s + fmt.Sprintf(morecode, errvar)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TmpVarCode returns source code for temp variable.
|
||||||
|
func (p *Param) TmpVarCode() string {
|
||||||
|
switch {
|
||||||
|
case p.Type == "bool":
|
||||||
|
return p.BoolTmpVarCode()
|
||||||
|
case strings.HasPrefix(p.Type, "[]"):
|
||||||
|
return p.SliceTmpVarCode()
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TmpVarHelperCode returns source code for helper's temp variable.
|
||||||
|
func (p *Param) TmpVarHelperCode() string {
|
||||||
|
if p.Type != "string" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return p.StringTmpVarCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyscallArgList returns source code fragments representing p parameter
|
||||||
|
// in syscall. Slices are translated into 2 syscall parameters: pointer to
|
||||||
|
// the first element and length.
|
||||||
|
func (p *Param) SyscallArgList() []string {
|
||||||
|
t := p.HelperType()
|
||||||
|
var s string
|
||||||
|
switch {
|
||||||
|
case t[0] == '*':
|
||||||
|
s = fmt.Sprintf("unsafe.Pointer(%s)", p.Name)
|
||||||
|
case t == "bool":
|
||||||
|
s = p.tmpVar()
|
||||||
|
case strings.HasPrefix(t, "[]"):
|
||||||
|
return []string{
|
||||||
|
fmt.Sprintf("uintptr(unsafe.Pointer(%s))", p.tmpVar()),
|
||||||
|
fmt.Sprintf("uintptr(len(%s))", p.Name),
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
s = p.Name
|
||||||
|
}
|
||||||
|
return []string{fmt.Sprintf("uintptr(%s)", s)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsError determines if p parameter is used to return error.
|
||||||
|
func (p *Param) IsError() bool {
|
||||||
|
return p.Name == "err" && p.Type == "error"
|
||||||
|
}
|
||||||
|
|
||||||
|
// HelperType returns type of parameter p used in helper function.
|
||||||
|
func (p *Param) HelperType() string {
|
||||||
|
if p.Type == "string" {
|
||||||
|
return p.fn.StrconvType()
|
||||||
|
}
|
||||||
|
return p.Type
|
||||||
|
}
|
||||||
|
|
||||||
|
// join concatenates parameters ps into a string with sep separator.
|
||||||
|
// Each parameter is converted into string by applying fn to it
|
||||||
|
// before conversion.
|
||||||
|
func join(ps []*Param, fn func(*Param) string, sep string) string {
|
||||||
|
if len(ps) == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
a := make([]string, 0)
|
||||||
|
for _, p := range ps {
|
||||||
|
a = append(a, fn(p))
|
||||||
|
}
|
||||||
|
return strings.Join(a, sep)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rets describes function return parameters.
|
||||||
|
type Rets struct {
|
||||||
|
Name string
|
||||||
|
Type string
|
||||||
|
ReturnsError bool
|
||||||
|
FailCond string
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrorVarName returns error variable name for r.
|
||||||
|
func (r *Rets) ErrorVarName() string {
|
||||||
|
if r.ReturnsError {
|
||||||
|
return "err"
|
||||||
|
}
|
||||||
|
if r.Type == "error" {
|
||||||
|
return r.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToParams converts r into slice of *Param.
|
||||||
|
func (r *Rets) ToParams() []*Param {
|
||||||
|
ps := make([]*Param, 0)
|
||||||
|
if len(r.Name) > 0 {
|
||||||
|
ps = append(ps, &Param{Name: r.Name, Type: r.Type})
|
||||||
|
}
|
||||||
|
if r.ReturnsError {
|
||||||
|
ps = append(ps, &Param{Name: "err", Type: "error"})
|
||||||
|
}
|
||||||
|
return ps
|
||||||
|
}
|
||||||
|
|
||||||
|
// List returns source code of syscall return parameters.
|
||||||
|
func (r *Rets) List() string {
|
||||||
|
s := join(r.ToParams(), func(p *Param) string { return p.Name + " " + p.Type }, ", ")
|
||||||
|
if len(s) > 0 {
|
||||||
|
s = "(" + s + ")"
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintList returns source code of trace printing part correspondent
|
||||||
|
// to syscall return values.
|
||||||
|
func (r *Rets) PrintList() string {
|
||||||
|
return join(r.ToParams(), func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetReturnValuesCode returns source code that accepts syscall return values.
|
||||||
|
func (r *Rets) SetReturnValuesCode() string {
|
||||||
|
if r.Name == "" && !r.ReturnsError {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
retvar := "r0"
|
||||||
|
if r.Name == "" {
|
||||||
|
retvar = "r1"
|
||||||
|
}
|
||||||
|
errvar := "_"
|
||||||
|
if r.ReturnsError {
|
||||||
|
errvar = "e1"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s, _, %s := ", retvar, errvar)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Rets) useLongHandleErrorCode(retvar string) string {
|
||||||
|
const code = `if %s {
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
} else {
|
||||||
|
err = %sEINVAL
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
cond := retvar + " == 0"
|
||||||
|
if r.FailCond != "" {
|
||||||
|
cond = strings.Replace(r.FailCond, "failretval", retvar, 1)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf(code, cond, syscalldot())
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetErrorCode returns source code that sets return parameters.
|
||||||
|
func (r *Rets) SetErrorCode() string {
|
||||||
|
const code = `if r0 != 0 {
|
||||||
|
%s = %sErrno(r0)
|
||||||
|
}`
|
||||||
|
const hrCode = `if int32(r0) < 0 {
|
||||||
|
%s = %sErrno(win32FromHresult(r0))
|
||||||
|
}`
|
||||||
|
if r.Name == "" && !r.ReturnsError {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if r.Name == "" {
|
||||||
|
return r.useLongHandleErrorCode("r1")
|
||||||
|
}
|
||||||
|
if r.Type == "error" {
|
||||||
|
if r.Name == "hr" {
|
||||||
|
return fmt.Sprintf(hrCode, r.Name, syscalldot())
|
||||||
|
} else {
|
||||||
|
return fmt.Sprintf(code, r.Name, syscalldot())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s := ""
|
||||||
|
switch {
|
||||||
|
case r.Type[0] == '*':
|
||||||
|
s = fmt.Sprintf("%s = (%s)(unsafe.Pointer(r0))", r.Name, r.Type)
|
||||||
|
case r.Type == "bool":
|
||||||
|
s = fmt.Sprintf("%s = r0 != 0", r.Name)
|
||||||
|
default:
|
||||||
|
s = fmt.Sprintf("%s = %s(r0)", r.Name, r.Type)
|
||||||
|
}
|
||||||
|
if !r.ReturnsError {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
return s + "\n\t" + r.useLongHandleErrorCode(r.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fn describes syscall function.
|
||||||
|
type Fn struct {
|
||||||
|
Name string
|
||||||
|
Params []*Param
|
||||||
|
Rets *Rets
|
||||||
|
PrintTrace bool
|
||||||
|
confirmproc bool
|
||||||
|
dllname string
|
||||||
|
dllfuncname string
|
||||||
|
src string
|
||||||
|
// TODO: get rid of this field and just use parameter index instead
|
||||||
|
curTmpVarIdx int // insure tmp variables have uniq names
|
||||||
|
}
|
||||||
|
|
||||||
|
// extractParams parses s to extract function parameters.
|
||||||
|
func extractParams(s string, f *Fn) ([]*Param, error) {
|
||||||
|
s = trim(s)
|
||||||
|
if s == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
a := strings.Split(s, ",")
|
||||||
|
ps := make([]*Param, len(a))
|
||||||
|
for i := range ps {
|
||||||
|
s2 := trim(a[i])
|
||||||
|
b := strings.Split(s2, " ")
|
||||||
|
if len(b) != 2 {
|
||||||
|
b = strings.Split(s2, "\t")
|
||||||
|
if len(b) != 2 {
|
||||||
|
return nil, errors.New("Could not extract function parameter from \"" + s2 + "\"")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ps[i] = &Param{
|
||||||
|
Name: trim(b[0]),
|
||||||
|
Type: trim(b[1]),
|
||||||
|
fn: f,
|
||||||
|
tmpVarIdx: -1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ps, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// extractSection extracts text out of string s starting after start
|
||||||
|
// and ending just before end. found return value will indicate success,
|
||||||
|
// and prefix, body and suffix will contain correspondent parts of string s.
|
||||||
|
func extractSection(s string, start, end rune) (prefix, body, suffix string, found bool) {
|
||||||
|
s = trim(s)
|
||||||
|
if strings.HasPrefix(s, string(start)) {
|
||||||
|
// no prefix
|
||||||
|
body = s[1:]
|
||||||
|
} else {
|
||||||
|
a := strings.SplitN(s, string(start), 2)
|
||||||
|
if len(a) != 2 {
|
||||||
|
return "", "", s, false
|
||||||
|
}
|
||||||
|
prefix = a[0]
|
||||||
|
body = a[1]
|
||||||
|
}
|
||||||
|
a := strings.SplitN(body, string(end), 2)
|
||||||
|
if len(a) != 2 {
|
||||||
|
return "", "", "", false
|
||||||
|
}
|
||||||
|
return prefix, a[0], a[1], true
|
||||||
|
}
|
||||||
|
|
||||||
|
// newFn parses string s and return created function Fn.
|
||||||
|
func newFn(s string) (*Fn, error) {
|
||||||
|
s = trim(s)
|
||||||
|
f := &Fn{
|
||||||
|
Rets: &Rets{},
|
||||||
|
src: s,
|
||||||
|
PrintTrace: *printTraceFlag,
|
||||||
|
}
|
||||||
|
// function name and args
|
||||||
|
prefix, body, s, found := extractSection(s, '(', ')')
|
||||||
|
if !found || prefix == "" {
|
||||||
|
return nil, errors.New("Could not extract function name and parameters from \"" + f.src + "\"")
|
||||||
|
}
|
||||||
|
f.Name = prefix
|
||||||
|
var err error
|
||||||
|
f.Params, err = extractParams(body, f)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
// return values
|
||||||
|
_, body, s, found = extractSection(s, '(', ')')
|
||||||
|
if found {
|
||||||
|
r, err := extractParams(body, f)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
switch len(r) {
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
if r[0].IsError() {
|
||||||
|
f.Rets.ReturnsError = true
|
||||||
|
} else {
|
||||||
|
f.Rets.Name = r[0].Name
|
||||||
|
f.Rets.Type = r[0].Type
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
if !r[1].IsError() {
|
||||||
|
return nil, errors.New("Only last windows error is allowed as second return value in \"" + f.src + "\"")
|
||||||
|
}
|
||||||
|
f.Rets.ReturnsError = true
|
||||||
|
f.Rets.Name = r[0].Name
|
||||||
|
f.Rets.Type = r[0].Type
|
||||||
|
default:
|
||||||
|
return nil, errors.New("Too many return values in \"" + f.src + "\"")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// fail condition
|
||||||
|
_, body, s, found = extractSection(s, '[', ']')
|
||||||
|
if found {
|
||||||
|
f.Rets.FailCond = body
|
||||||
|
}
|
||||||
|
// dll and dll function names
|
||||||
|
s = trim(s)
|
||||||
|
if s == "" {
|
||||||
|
return f, nil
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(s, "=") {
|
||||||
|
return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
|
||||||
|
}
|
||||||
|
s = trim(s[1:])
|
||||||
|
a := strings.Split(s, ".")
|
||||||
|
switch len(a) {
|
||||||
|
case 1:
|
||||||
|
f.dllfuncname = a[0]
|
||||||
|
case 2:
|
||||||
|
f.dllname = a[0]
|
||||||
|
f.dllfuncname = a[1]
|
||||||
|
default:
|
||||||
|
return nil, errors.New("Could not extract dll name from \"" + f.src + "\"")
|
||||||
|
}
|
||||||
|
if f.dllfuncname[len(f.dllfuncname)-1] == '?' {
|
||||||
|
f.confirmproc = true
|
||||||
|
f.dllfuncname = f.dllfuncname[0 : len(f.dllfuncname)-1]
|
||||||
|
}
|
||||||
|
return f, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DLLName returns DLL name for function f.
|
||||||
|
func (f *Fn) DLLName() string {
|
||||||
|
if f.dllname == "" {
|
||||||
|
return "kernel32"
|
||||||
|
}
|
||||||
|
return f.dllname
|
||||||
|
}
|
||||||
|
|
||||||
|
// DLLName returns DLL function name for function f.
|
||||||
|
func (f *Fn) DLLFuncName() string {
|
||||||
|
if f.dllfuncname == "" {
|
||||||
|
return f.Name
|
||||||
|
}
|
||||||
|
return f.dllfuncname
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *Fn) ConfirmProc() bool {
|
||||||
|
return f.confirmproc
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParamList returns source code for function f parameters.
|
||||||
|
func (f *Fn) ParamList() string {
|
||||||
|
return join(f.Params, func(p *Param) string { return p.Name + " " + p.Type }, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// HelperParamList returns source code for helper function f parameters.
|
||||||
|
func (f *Fn) HelperParamList() string {
|
||||||
|
return join(f.Params, func(p *Param) string { return p.Name + " " + p.HelperType() }, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParamPrintList returns source code of trace printing part correspondent
|
||||||
|
// to syscall input parameters.
|
||||||
|
func (f *Fn) ParamPrintList() string {
|
||||||
|
return join(f.Params, func(p *Param) string { return fmt.Sprintf(`"%s=", %s, `, p.Name, p.Name) }, `", ", `)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParamCount return number of syscall parameters for function f.
|
||||||
|
func (f *Fn) ParamCount() int {
|
||||||
|
n := 0
|
||||||
|
for _, p := range f.Params {
|
||||||
|
n += len(p.SyscallArgList())
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyscallParamCount determines which version of Syscall/Syscall6/Syscall9/...
|
||||||
|
// to use. It returns parameter count for correspondent SyscallX function.
|
||||||
|
func (f *Fn) SyscallParamCount() int {
|
||||||
|
n := f.ParamCount()
|
||||||
|
switch {
|
||||||
|
case n <= 3:
|
||||||
|
return 3
|
||||||
|
case n <= 6:
|
||||||
|
return 6
|
||||||
|
case n <= 9:
|
||||||
|
return 9
|
||||||
|
case n <= 12:
|
||||||
|
return 12
|
||||||
|
case n <= 15:
|
||||||
|
return 15
|
||||||
|
default:
|
||||||
|
panic("too many arguments to system call")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Syscall determines which SyscallX function to use for function f.
|
||||||
|
func (f *Fn) Syscall() string {
|
||||||
|
c := f.SyscallParamCount()
|
||||||
|
if c == 3 {
|
||||||
|
return syscalldot() + "Syscall"
|
||||||
|
}
|
||||||
|
return syscalldot() + "Syscall" + strconv.Itoa(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyscallParamList returns source code for SyscallX parameters for function f.
|
||||||
|
func (f *Fn) SyscallParamList() string {
|
||||||
|
a := make([]string, 0)
|
||||||
|
for _, p := range f.Params {
|
||||||
|
a = append(a, p.SyscallArgList()...)
|
||||||
|
}
|
||||||
|
for len(a) < f.SyscallParamCount() {
|
||||||
|
a = append(a, "0")
|
||||||
|
}
|
||||||
|
return strings.Join(a, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// HelperCallParamList returns source code of call into function f helper.
|
||||||
|
func (f *Fn) HelperCallParamList() string {
|
||||||
|
a := make([]string, 0, len(f.Params))
|
||||||
|
for _, p := range f.Params {
|
||||||
|
s := p.Name
|
||||||
|
if p.Type == "string" {
|
||||||
|
s = p.tmpVar()
|
||||||
|
}
|
||||||
|
a = append(a, s)
|
||||||
|
}
|
||||||
|
return strings.Join(a, ", ")
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsUTF16 is true, if f is W (utf16) function. It is false
|
||||||
|
// for all A (ascii) functions.
|
||||||
|
func (_ *Fn) IsUTF16() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// StrconvFunc returns name of Go string to OS string function for f.
|
||||||
|
func (f *Fn) StrconvFunc() string {
|
||||||
|
if f.IsUTF16() {
|
||||||
|
return syscalldot() + "UTF16PtrFromString"
|
||||||
|
}
|
||||||
|
return syscalldot() + "BytePtrFromString"
|
||||||
|
}
|
||||||
|
|
||||||
|
// StrconvType returns Go type name used for OS string for f.
|
||||||
|
func (f *Fn) StrconvType() string {
|
||||||
|
if f.IsUTF16() {
|
||||||
|
return "*uint16"
|
||||||
|
}
|
||||||
|
return "*byte"
|
||||||
|
}
|
||||||
|
|
||||||
|
// HasStringParam is true, if f has at least one string parameter.
|
||||||
|
// Otherwise it is false.
|
||||||
|
func (f *Fn) HasStringParam() bool {
|
||||||
|
for _, p := range f.Params {
|
||||||
|
if p.Type == "string" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
var uniqDllFuncName = make(map[string]bool)
|
||||||
|
|
||||||
|
// IsNotDuplicate is true if f is not a duplicated function
|
||||||
|
func (f *Fn) IsNotDuplicate() bool {
|
||||||
|
funcName := f.DLLFuncName()
|
||||||
|
if uniqDllFuncName[funcName] == false {
|
||||||
|
uniqDllFuncName[funcName] = true
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// HelperName returns name of function f helper.
|
||||||
|
func (f *Fn) HelperName() string {
|
||||||
|
if !f.HasStringParam() {
|
||||||
|
return f.Name
|
||||||
|
}
|
||||||
|
return "_" + f.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Source files and functions.
|
||||||
|
type Source struct {
|
||||||
|
Funcs []*Fn
|
||||||
|
Files []string
|
||||||
|
StdLibImports []string
|
||||||
|
ExternalImports []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (src *Source) Import(pkg string) {
|
||||||
|
src.StdLibImports = append(src.StdLibImports, pkg)
|
||||||
|
sort.Strings(src.StdLibImports)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (src *Source) ExternalImport(pkg string) {
|
||||||
|
src.ExternalImports = append(src.ExternalImports, pkg)
|
||||||
|
sort.Strings(src.ExternalImports)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseFiles parses files listed in fs and extracts all syscall
|
||||||
|
// functions listed in sys comments. It returns source files
|
||||||
|
// and functions collection *Source if successful.
|
||||||
|
func ParseFiles(fs []string) (*Source, error) {
|
||||||
|
src := &Source{
|
||||||
|
Funcs: make([]*Fn, 0),
|
||||||
|
Files: make([]string, 0),
|
||||||
|
StdLibImports: []string{
|
||||||
|
"unsafe",
|
||||||
|
},
|
||||||
|
ExternalImports: make([]string, 0),
|
||||||
|
}
|
||||||
|
for _, file := range fs {
|
||||||
|
if err := src.ParseFile(file); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return src, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DLLs return dll names for a source set src.
|
||||||
|
func (src *Source) DLLs() []string {
|
||||||
|
uniq := make(map[string]bool)
|
||||||
|
r := make([]string, 0)
|
||||||
|
for _, f := range src.Funcs {
|
||||||
|
name := f.DLLName()
|
||||||
|
if _, found := uniq[name]; !found {
|
||||||
|
uniq[name] = true
|
||||||
|
r = append(r, name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseFile adds additional file path to a source set src.
|
||||||
|
func (src *Source) ParseFile(path string) error {
|
||||||
|
file, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
s := bufio.NewScanner(file)
|
||||||
|
for s.Scan() {
|
||||||
|
t := trim(s.Text())
|
||||||
|
if len(t) < 7 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(t, "//sys") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
t = t[5:]
|
||||||
|
if !(t[0] == ' ' || t[0] == '\t') {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
f, err := newFn(t[1:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
src.Funcs = append(src.Funcs, f)
|
||||||
|
}
|
||||||
|
if err := s.Err(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
src.Files = append(src.Files, path)
|
||||||
|
|
||||||
|
// get package name
|
||||||
|
fset := token.NewFileSet()
|
||||||
|
_, err = file.Seek(0, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
pkg, err := parser.ParseFile(fset, "", file, parser.PackageClauseOnly)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
packageName = pkg.Name.Name
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsStdRepo returns true if src is part of standard library.
|
||||||
|
func (src *Source) IsStdRepo() (bool, error) {
|
||||||
|
if len(src.Files) == 0 {
|
||||||
|
return false, errors.New("no input files provided")
|
||||||
|
}
|
||||||
|
abspath, err := filepath.Abs(src.Files[0])
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
goroot := runtime.GOROOT()
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
abspath = strings.ToLower(abspath)
|
||||||
|
goroot = strings.ToLower(goroot)
|
||||||
|
}
|
||||||
|
sep := string(os.PathSeparator)
|
||||||
|
if !strings.HasSuffix(goroot, sep) {
|
||||||
|
goroot += sep
|
||||||
|
}
|
||||||
|
return strings.HasPrefix(abspath, goroot), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate output source file from a source set src.
|
||||||
|
func (src *Source) Generate(w io.Writer) error {
|
||||||
|
const (
|
||||||
|
pkgStd = iota // any package in std library
|
||||||
|
pkgXSysWindows // x/sys/windows package
|
||||||
|
pkgOther
|
||||||
|
)
|
||||||
|
isStdRepo, err := src.IsStdRepo()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var pkgtype int
|
||||||
|
switch {
|
||||||
|
case isStdRepo:
|
||||||
|
pkgtype = pkgStd
|
||||||
|
case packageName == "windows":
|
||||||
|
// TODO: this needs better logic than just using package name
|
||||||
|
pkgtype = pkgXSysWindows
|
||||||
|
default:
|
||||||
|
pkgtype = pkgOther
|
||||||
|
}
|
||||||
|
if *systemDLL {
|
||||||
|
switch pkgtype {
|
||||||
|
case pkgStd:
|
||||||
|
src.Import("internal/syscall/windows/sysdll")
|
||||||
|
case pkgXSysWindows:
|
||||||
|
default:
|
||||||
|
src.ExternalImport("golang.org/x/sys/windows")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
src.ExternalImport("github.com/Microsoft/go-winio")
|
||||||
|
if packageName != "syscall" {
|
||||||
|
src.Import("syscall")
|
||||||
|
}
|
||||||
|
funcMap := template.FuncMap{
|
||||||
|
"packagename": packagename,
|
||||||
|
"syscalldot": syscalldot,
|
||||||
|
"newlazydll": func(dll string) string {
|
||||||
|
arg := "\"" + dll + ".dll\""
|
||||||
|
if !*systemDLL {
|
||||||
|
return syscalldot() + "NewLazyDLL(" + arg + ")"
|
||||||
|
}
|
||||||
|
switch pkgtype {
|
||||||
|
case pkgStd:
|
||||||
|
return syscalldot() + "NewLazyDLL(sysdll.Add(" + arg + "))"
|
||||||
|
case pkgXSysWindows:
|
||||||
|
return "NewLazySystemDLL(" + arg + ")"
|
||||||
|
default:
|
||||||
|
return "windows.NewLazySystemDLL(" + arg + ")"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
t := template.Must(template.New("main").Funcs(funcMap).Parse(srcTemplate))
|
||||||
|
err = t.Execute(w, src)
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("Failed to execute template: " + err.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func usage() {
|
||||||
|
fmt.Fprintf(os.Stderr, "usage: mksyscall_windows [flags] [path ...]\n")
|
||||||
|
flag.PrintDefaults()
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Usage = usage
|
||||||
|
flag.Parse()
|
||||||
|
if len(flag.Args()) <= 0 {
|
||||||
|
fmt.Fprintf(os.Stderr, "no files to parse provided\n")
|
||||||
|
usage()
|
||||||
|
}
|
||||||
|
|
||||||
|
src, err := ParseFiles(flag.Args())
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var buf bytes.Buffer
|
||||||
|
if err := src.Generate(&buf); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := format.Source(buf.Bytes())
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
if *filename == "" {
|
||||||
|
_, err = os.Stdout.Write(data)
|
||||||
|
} else {
|
||||||
|
err = ioutil.WriteFile(*filename, data, 0644)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: use println instead to print in the following template
|
||||||
|
const srcTemplate = `
|
||||||
|
|
||||||
|
{{define "main"}}// MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
|
||||||
|
|
||||||
|
package {{packagename}}
|
||||||
|
|
||||||
|
import (
|
||||||
|
{{range .StdLibImports}}"{{.}}"
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{range .ExternalImports}}"{{.}}"
|
||||||
|
{{end}}
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ unsafe.Pointer
|
||||||
|
|
||||||
|
// Do the interface allocations only once for common
|
||||||
|
// Errno values.
|
||||||
|
const (
|
||||||
|
errnoERROR_IO_PENDING = 997
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
errERROR_IO_PENDING error = {{syscalldot}}Errno(errnoERROR_IO_PENDING)
|
||||||
|
)
|
||||||
|
|
||||||
|
// errnoErr returns common boxed Errno values, to prevent
|
||||||
|
// allocations at runtime.
|
||||||
|
func errnoErr(e {{syscalldot}}Errno) error {
|
||||||
|
switch e {
|
||||||
|
case 0:
|
||||||
|
return nil
|
||||||
|
case errnoERROR_IO_PENDING:
|
||||||
|
return errERROR_IO_PENDING
|
||||||
|
}
|
||||||
|
// TODO: add more here, after collecting data on the common
|
||||||
|
// error values see on Windows. (perhaps when running
|
||||||
|
// all.bat?)
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
{{template "dlls" .}}
|
||||||
|
{{template "funcnames" .}})
|
||||||
|
{{range .Funcs}}{{if .HasStringParam}}{{template "helperbody" .}}{{end}}{{template "funcbody" .}}{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{/* help functions */}}
|
||||||
|
|
||||||
|
{{define "dlls"}}{{range .DLLs}} mod{{.}} = {{newlazydll .}}
|
||||||
|
{{end}}{{end}}
|
||||||
|
|
||||||
|
{{define "funcnames"}}{{range .Funcs}}{{if .IsNotDuplicate}} proc{{.DLLFuncName}} = mod{{.DLLName}}.NewProc("{{.DLLFuncName}}"){{end}}
|
||||||
|
{{end}}{{end}}
|
||||||
|
|
||||||
|
{{define "helperbody"}}
|
||||||
|
func {{.Name}}({{.ParamList}}) {{template "results" .}}{
|
||||||
|
{{template "helpertmpvars" .}} return {{.HelperName}}({{.HelperCallParamList}})
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "funcbody"}}
|
||||||
|
func {{.HelperName}}({{.HelperParamList}}) {{template "results" .}}{
|
||||||
|
{{template "tmpvars" .}} {{template "syscallcheck" .}}{{template "syscall" .}}
|
||||||
|
{{template "seterror" .}}{{template "printtrace" .}} return
|
||||||
|
}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{define "helpertmpvars"}}{{range .Params}}{{if .TmpVarHelperCode}} {{.TmpVarHelperCode}}
|
||||||
|
{{end}}{{end}}{{end}}
|
||||||
|
|
||||||
|
{{define "tmpvars"}}{{range .Params}}{{if .TmpVarCode}} {{.TmpVarCode}}
|
||||||
|
{{end}}{{end}}{{end}}
|
||||||
|
|
||||||
|
{{define "results"}}{{if .Rets.List}}{{.Rets.List}} {{end}}{{end}}
|
||||||
|
|
||||||
|
{{define "syscall"}}{{.Rets.SetReturnValuesCode}}{{.Syscall}}(proc{{.DLLFuncName}}.Addr(), {{.ParamCount}}, {{.SyscallParamList}}){{end}}
|
||||||
|
|
||||||
|
{{define "syscallcheck"}}{{if .ConfirmProc}}if {{.Rets.ErrorVarName}} = proc{{.DLLFuncName}}.Find(); {{.Rets.ErrorVarName}} != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
{{end}}{{end}}
|
||||||
|
|
||||||
|
|
||||||
|
{{define "seterror"}}{{if .Rets.SetErrorCode}} {{.Rets.SetErrorCode}}
|
||||||
|
{{end}}{{end}}
|
||||||
|
|
||||||
|
{{define "printtrace"}}{{if .PrintTrace}} print("SYSCALL: {{.Name}}(", {{.ParamPrintList}}") (", {{.Rets.PrintList}}")\n")
|
||||||
|
{{end}}{{end}}
|
||||||
|
|
||||||
|
`
|
2
vendor/github.com/Microsoft/hcsshim/nametoguid.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/nametoguid.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// NameToGuid converts the given string into a GUID using the algorithm in the
|
// NameToGuid converts the given string into a GUID using the algorithm in the
|
||||||
// Host Compute Service, ensuring GUIDs generated with the same string are common
|
// Host Compute Service, ensuring GUIDs generated with the same string are common
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/preparelayer.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/preparelayer.go
generated
vendored
|
@ -3,7 +3,7 @@ package hcsshim
|
||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var prepareLayerLock sync.Mutex
|
var prepareLayerLock sync.Mutex
|
||||||
|
|
9
vendor/github.com/Microsoft/hcsshim/process.go
generated
vendored
9
vendor/github.com/Microsoft/hcsshim/process.go
generated
vendored
|
@ -3,12 +3,11 @@ package hcsshim
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"runtime"
|
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContainerError is an error encountered in HCS
|
// ContainerError is an error encountered in HCS
|
||||||
|
@ -322,17 +321,11 @@ func (process *process) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
process.handle = 0
|
process.handle = 0
|
||||||
runtime.SetFinalizer(process, nil)
|
|
||||||
|
|
||||||
logrus.Debugf(title+" succeeded processid=%d", process.processID)
|
logrus.Debugf(title+" succeeded processid=%d", process.processID)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// closeProcess wraps process.Close for use by a finalizer
|
|
||||||
func closeProcess(process *process) {
|
|
||||||
process.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (process *process) registerCallback() error {
|
func (process *process) registerCallback() error {
|
||||||
context := ¬ifcationWatcherContext{
|
context := ¬ifcationWatcherContext{
|
||||||
channels: newChannels(),
|
channels: newChannels(),
|
||||||
|
|
2
vendor/github.com/Microsoft/hcsshim/unpreparelayer.go
generated
vendored
2
vendor/github.com/Microsoft/hcsshim/unpreparelayer.go
generated
vendored
|
@ -1,6 +1,6 @@
|
||||||
package hcsshim
|
package hcsshim
|
||||||
|
|
||||||
import "github.com/Sirupsen/logrus"
|
import "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
// UnprepareLayer disables the filesystem filter for the read-write layer with
|
// UnprepareLayer disables the filesystem filter for the read-write layer with
|
||||||
// the given id.
|
// the given id.
|
||||||
|
|
3
vendor/github.com/Microsoft/hcsshim/waithelper.go
generated
vendored
3
vendor/github.com/Microsoft/hcsshim/waithelper.go
generated
vendored
|
@ -3,7 +3,7 @@ package hcsshim
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func processAsyncHcsResult(err error, resultp *uint16, callbackNumber uintptr, expectedNotification hcsNotification, timeout *time.Duration) error {
|
func processAsyncHcsResult(err error, resultp *uint16, callbackNumber uintptr, expectedNotification hcsNotification, timeout *time.Duration) error {
|
||||||
|
@ -59,4 +59,5 @@ func waitForNotification(callbackNumber uintptr, expectedNotification hcsNotific
|
||||||
case <-c:
|
case <-c:
|
||||||
return ErrTimeout
|
return ErrTimeout
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
33
vendor/github.com/Sirupsen/logrus/terminal_windows.go
generated
vendored
33
vendor/github.com/Sirupsen/logrus/terminal_windows.go
generated
vendored
|
@ -1,33 +0,0 @@
|
||||||
// Based on ssh/terminal:
|
|
||||||
// Copyright 2011 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 windows,!appengine
|
|
||||||
|
|
||||||
package logrus
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"os"
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
var kernel32 = syscall.NewLazyDLL("kernel32.dll")
|
|
||||||
|
|
||||||
var (
|
|
||||||
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
|
|
||||||
)
|
|
||||||
|
|
||||||
// IsTerminal returns true if stderr's file descriptor is a terminal.
|
|
||||||
func IsTerminal(f io.Writer) bool {
|
|
||||||
switch v := f.(type) {
|
|
||||||
case *os.File:
|
|
||||||
var st uint32
|
|
||||||
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(v.Fd()), uintptr(unsafe.Pointer(&st)), 0)
|
|
||||||
return r != 0 && e == 0
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
5
vendor/github.com/containers/image/copy/copy.go
generated
vendored
5
vendor/github.com/containers/image/copy/copy.go
generated
vendored
|
@ -3,6 +3,7 @@ package copy
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -13,7 +14,6 @@ import (
|
||||||
|
|
||||||
pb "gopkg.in/cheggaaa/pb.v1"
|
pb "gopkg.in/cheggaaa/pb.v1"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/image"
|
"github.com/containers/image/image"
|
||||||
"github.com/containers/image/pkg/compression"
|
"github.com/containers/image/pkg/compression"
|
||||||
"github.com/containers/image/signature"
|
"github.com/containers/image/signature"
|
||||||
|
@ -21,6 +21,7 @@ import (
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type digestingReader struct {
|
type digestingReader struct {
|
||||||
|
@ -171,7 +172,7 @@ func Image(policyContext *signature.PolicyContext, destRef, srcRef types.ImageRe
|
||||||
sigs = [][]byte{}
|
sigs = [][]byte{}
|
||||||
} else {
|
} else {
|
||||||
writeReport("Getting image source signatures\n")
|
writeReport("Getting image source signatures\n")
|
||||||
s, err := src.Signatures()
|
s, err := src.Signatures(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "Error reading signatures")
|
return errors.Wrap(err, "Error reading signatures")
|
||||||
}
|
}
|
||||||
|
|
2
vendor/github.com/containers/image/copy/manifest.go
generated
vendored
2
vendor/github.com/containers/image/copy/manifest.go
generated
vendored
|
@ -3,10 +3,10 @@ package copy
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// preferredManifestMIMETypes lists manifest MIME types in order of our preference, if we can't use the original manifest and need to convert.
|
// preferredManifestMIMETypes lists manifest MIME types in order of our preference, if we can't use the original manifest and need to convert.
|
||||||
|
|
3
vendor/github.com/containers/image/directory/directory_src.go
generated
vendored
3
vendor/github.com/containers/image/directory/directory_src.go
generated
vendored
|
@ -1,6 +1,7 @@
|
||||||
package directory
|
package directory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
@ -59,7 +60,7 @@ func (s *dirImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, err
|
||||||
return r, fi.Size(), nil
|
return r, fi.Size(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *dirImageSource) GetSignatures() ([][]byte, error) {
|
func (s *dirImageSource) GetSignatures(ctx context.Context) ([][]byte, error) {
|
||||||
signatures := [][]byte{}
|
signatures := [][]byte{}
|
||||||
for i := 0; ; i++ {
|
for i := 0; ; i++ {
|
||||||
signature, err := ioutil.ReadFile(s.ref.signaturePath(i))
|
signature, err := ioutil.ReadFile(s.ref.signaturePath(i))
|
||||||
|
|
2
vendor/github.com/containers/image/docker/archive/src.go
generated
vendored
2
vendor/github.com/containers/image/docker/archive/src.go
generated
vendored
|
@ -1,9 +1,9 @@
|
||||||
package archive
|
package archive
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/tarfile"
|
"github.com/containers/image/docker/tarfile"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type archiveImageSource struct {
|
type archiveImageSource struct {
|
||||||
|
|
2
vendor/github.com/containers/image/docker/daemon/daemon_dest.go
generated
vendored
2
vendor/github.com/containers/image/docker/daemon/daemon_dest.go
generated
vendored
|
@ -3,12 +3,12 @@ package daemon
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/docker/tarfile"
|
"github.com/containers/image/docker/tarfile"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
27
vendor/github.com/containers/image/docker/docker_client.go
generated
vendored
27
vendor/github.com/containers/image/docker/docker_client.go
generated
vendored
|
@ -1,6 +1,7 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
@ -14,7 +15,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/containers/storage/pkg/homedir"
|
"github.com/containers/storage/pkg/homedir"
|
||||||
|
@ -23,6 +23,7 @@ import (
|
||||||
"github.com/docker/go-connections/tlsconfig"
|
"github.com/docker/go-connections/tlsconfig"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -254,24 +255,25 @@ func newDockerClient(ctx *types.SystemContext, ref dockerReference, write bool,
|
||||||
|
|
||||||
// makeRequest creates and executes a http.Request with the specified parameters, adding authentication and TLS options for the Docker client.
|
// makeRequest creates and executes a http.Request with the specified parameters, adding authentication and TLS options for the Docker client.
|
||||||
// The host name and schema is taken from the client or autodetected, and the path is relative to it, i.e. the path usually starts with /v2/.
|
// The host name and schema is taken from the client or autodetected, and the path is relative to it, i.e. the path usually starts with /v2/.
|
||||||
func (c *dockerClient) makeRequest(method, path string, headers map[string][]string, stream io.Reader) (*http.Response, error) {
|
func (c *dockerClient) makeRequest(ctx context.Context, method, path string, headers map[string][]string, stream io.Reader) (*http.Response, error) {
|
||||||
if err := c.detectProperties(); err != nil {
|
if err := c.detectProperties(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
url := fmt.Sprintf("%s://%s%s", c.scheme, c.registry, path)
|
url := fmt.Sprintf("%s://%s%s", c.scheme, c.registry, path)
|
||||||
return c.makeRequestToResolvedURL(method, url, headers, stream, -1, true)
|
return c.makeRequestToResolvedURL(ctx, method, url, headers, stream, -1, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeRequestToResolvedURL creates and executes a http.Request with the specified parameters, adding authentication and TLS options for the Docker client.
|
// makeRequestToResolvedURL creates and executes a http.Request with the specified parameters, adding authentication and TLS options for the Docker client.
|
||||||
// streamLen, if not -1, specifies the length of the data expected on stream.
|
// streamLen, if not -1, specifies the length of the data expected on stream.
|
||||||
// makeRequest should generally be preferred.
|
// makeRequest should generally be preferred.
|
||||||
// TODO(runcom): too many arguments here, use a struct
|
// TODO(runcom): too many arguments here, use a struct
|
||||||
func (c *dockerClient) makeRequestToResolvedURL(method, url string, headers map[string][]string, stream io.Reader, streamLen int64, sendAuth bool) (*http.Response, error) {
|
func (c *dockerClient) makeRequestToResolvedURL(ctx context.Context, method, url string, headers map[string][]string, stream io.Reader, streamLen int64, sendAuth bool) (*http.Response, error) {
|
||||||
req, err := http.NewRequest(method, url, stream)
|
req, err := http.NewRequest(method, url, stream)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
req = req.WithContext(ctx)
|
||||||
if streamLen != -1 { // Do not blindly overwrite if streamLen == -1, http.NewRequest above can figure out the length of bytes.Reader and similar objects without us having to compute it.
|
if streamLen != -1 { // Do not blindly overwrite if streamLen == -1, http.NewRequest above can figure out the length of bytes.Reader and similar objects without us having to compute it.
|
||||||
req.ContentLength = streamLen
|
req.ContentLength = streamLen
|
||||||
}
|
}
|
||||||
|
@ -323,7 +325,7 @@ func (c *dockerClient) setupRequestAuth(req *http.Request) error {
|
||||||
}
|
}
|
||||||
service, _ := challenge.Parameters["service"] // Will be "" if not present
|
service, _ := challenge.Parameters["service"] // Will be "" if not present
|
||||||
scope := fmt.Sprintf("repository:%s:%s", c.scope.remoteName, c.scope.actions)
|
scope := fmt.Sprintf("repository:%s:%s", c.scope.remoteName, c.scope.actions)
|
||||||
token, err := c.getBearerToken(realm, service, scope)
|
token, err := c.getBearerToken(req.Context(), realm, service, scope)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -340,11 +342,12 @@ func (c *dockerClient) setupRequestAuth(req *http.Request) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *dockerClient) getBearerToken(realm, service, scope string) (*bearerToken, error) {
|
func (c *dockerClient) getBearerToken(ctx context.Context, realm, service, scope string) (*bearerToken, error) {
|
||||||
authReq, err := http.NewRequest("GET", realm, nil)
|
authReq, err := http.NewRequest("GET", realm, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
authReq = authReq.WithContext(ctx)
|
||||||
getParams := authReq.URL.Query()
|
getParams := authReq.URL.Query()
|
||||||
if service != "" {
|
if service != "" {
|
||||||
getParams.Add("service", service)
|
getParams.Add("service", service)
|
||||||
|
@ -447,14 +450,14 @@ func getAuth(ctx *types.SystemContext, registry string) (string, string, error)
|
||||||
|
|
||||||
// detectProperties detects various properties of the registry.
|
// detectProperties detects various properties of the registry.
|
||||||
// See the dockerClient documentation for members which are affected by this.
|
// See the dockerClient documentation for members which are affected by this.
|
||||||
func (c *dockerClient) detectProperties() error {
|
func (c *dockerClient) detectProperties(ctx context.Context) error {
|
||||||
if c.scheme != "" {
|
if c.scheme != "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
ping := func(scheme string) error {
|
ping := func(scheme string) error {
|
||||||
url := fmt.Sprintf(resolvedPingV2URL, scheme, c.registry)
|
url := fmt.Sprintf(resolvedPingV2URL, scheme, c.registry)
|
||||||
resp, err := c.makeRequestToResolvedURL("GET", url, nil, nil, -1, true)
|
resp, err := c.makeRequestToResolvedURL(ctx, "GET", url, nil, nil, -1, true)
|
||||||
logrus.Debugf("Ping %s err %#v", url, err)
|
logrus.Debugf("Ping %s err %#v", url, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -481,7 +484,7 @@ func (c *dockerClient) detectProperties() error {
|
||||||
// best effort to understand if we're talking to a V1 registry
|
// best effort to understand if we're talking to a V1 registry
|
||||||
pingV1 := func(scheme string) bool {
|
pingV1 := func(scheme string) bool {
|
||||||
url := fmt.Sprintf(resolvedPingV1URL, scheme, c.registry)
|
url := fmt.Sprintf(resolvedPingV1URL, scheme, c.registry)
|
||||||
resp, err := c.makeRequestToResolvedURL("GET", url, nil, nil, -1, true)
|
resp, err := c.makeRequestToResolvedURL(ctx, "GET", url, nil, nil, -1, true)
|
||||||
logrus.Debugf("Ping %s err %#v", url, err)
|
logrus.Debugf("Ping %s err %#v", url, err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
@ -506,9 +509,9 @@ func (c *dockerClient) detectProperties() error {
|
||||||
|
|
||||||
// getExtensionsSignatures returns signatures from the X-Registry-Supports-Signatures API extension,
|
// getExtensionsSignatures returns signatures from the X-Registry-Supports-Signatures API extension,
|
||||||
// using the original data structures.
|
// using the original data structures.
|
||||||
func (c *dockerClient) getExtensionsSignatures(ref dockerReference, manifestDigest digest.Digest) (*extensionSignatureList, error) {
|
func (c *dockerClient) getExtensionsSignatures(ctx context.Context, ref dockerReference, manifestDigest digest.Digest) (*extensionSignatureList, error) {
|
||||||
path := fmt.Sprintf(extensionsSignaturePath, reference.Path(ref.ref), manifestDigest)
|
path := fmt.Sprintf(extensionsSignaturePath, reference.Path(ref.ref), manifestDigest)
|
||||||
res, err := c.makeRequest("GET", path, nil, nil)
|
res, err := c.makeRequest(ctx, "GET", path, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
4
vendor/github.com/containers/image/docker/docker_image.go
generated
vendored
4
vendor/github.com/containers/image/docker/docker_image.go
generated
vendored
|
@ -1,6 +1,7 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -41,7 +42,8 @@ func (i *Image) SourceRefFullName() string {
|
||||||
// GetRepositoryTags list all tags available in the repository. Note that this has no connection with the tag(s) used for this specific image, if any.
|
// GetRepositoryTags list all tags available in the repository. Note that this has no connection with the tag(s) used for this specific image, if any.
|
||||||
func (i *Image) GetRepositoryTags() ([]string, error) {
|
func (i *Image) GetRepositoryTags() ([]string, error) {
|
||||||
path := fmt.Sprintf(tagsPath, reference.Path(i.src.ref.ref))
|
path := fmt.Sprintf(tagsPath, reference.Path(i.src.ref.ref))
|
||||||
res, err := i.src.c.makeRequest("GET", path, nil, nil)
|
// FIXME: Pass the context.Context
|
||||||
|
res, err := i.src.c.makeRequest(context.TODO(), "GET", path, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
21
vendor/github.com/containers/image/docker/docker_image_dest.go
generated
vendored
21
vendor/github.com/containers/image/docker/docker_image_dest.go
generated
vendored
|
@ -2,6 +2,7 @@ package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -12,7 +13,6 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
|
@ -21,6 +21,7 @@ import (
|
||||||
"github.com/docker/distribution/registry/client"
|
"github.com/docker/distribution/registry/client"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var manifestMIMETypes = []string{
|
var manifestMIMETypes = []string{
|
||||||
|
@ -75,7 +76,7 @@ func (d *dockerImageDestination) SupportedManifestMIMETypes() []string {
|
||||||
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
|
// SupportsSignatures returns an error (to be displayed to the user) if the destination certainly can't store signatures.
|
||||||
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
|
// Note: It is still possible for PutSignatures to fail if SupportsSignatures returns nil.
|
||||||
func (d *dockerImageDestination) SupportsSignatures() error {
|
func (d *dockerImageDestination) SupportsSignatures() error {
|
||||||
if err := d.c.detectProperties(); err != nil {
|
if err := d.c.detectProperties(context.TODO()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
|
@ -132,7 +133,7 @@ func (d *dockerImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobI
|
||||||
// FIXME? Chunked upload, progress reporting, etc.
|
// FIXME? Chunked upload, progress reporting, etc.
|
||||||
uploadPath := fmt.Sprintf(blobUploadPath, reference.Path(d.ref.ref))
|
uploadPath := fmt.Sprintf(blobUploadPath, reference.Path(d.ref.ref))
|
||||||
logrus.Debugf("Uploading %s", uploadPath)
|
logrus.Debugf("Uploading %s", uploadPath)
|
||||||
res, err := d.c.makeRequest("POST", uploadPath, nil, nil)
|
res, err := d.c.makeRequest(context.TODO(), "POST", uploadPath, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.BlobInfo{}, err
|
return types.BlobInfo{}, err
|
||||||
}
|
}
|
||||||
|
@ -149,7 +150,7 @@ func (d *dockerImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobI
|
||||||
digester := digest.Canonical.Digester()
|
digester := digest.Canonical.Digester()
|
||||||
sizeCounter := &sizeCounter{}
|
sizeCounter := &sizeCounter{}
|
||||||
tee := io.TeeReader(stream, io.MultiWriter(digester.Hash(), sizeCounter))
|
tee := io.TeeReader(stream, io.MultiWriter(digester.Hash(), sizeCounter))
|
||||||
res, err = d.c.makeRequestToResolvedURL("PATCH", uploadLocation.String(), map[string][]string{"Content-Type": {"application/octet-stream"}}, tee, inputInfo.Size, true)
|
res, err = d.c.makeRequestToResolvedURL(context.TODO(), "PATCH", uploadLocation.String(), map[string][]string{"Content-Type": {"application/octet-stream"}}, tee, inputInfo.Size, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debugf("Error uploading layer chunked, response %#v", res)
|
logrus.Debugf("Error uploading layer chunked, response %#v", res)
|
||||||
return types.BlobInfo{}, err
|
return types.BlobInfo{}, err
|
||||||
|
@ -168,7 +169,7 @@ func (d *dockerImageDestination) PutBlob(stream io.Reader, inputInfo types.BlobI
|
||||||
// TODO: check inputInfo.Digest == computedDigest https://github.com/containers/image/pull/70#discussion_r77646717
|
// TODO: check inputInfo.Digest == computedDigest https://github.com/containers/image/pull/70#discussion_r77646717
|
||||||
locationQuery.Set("digest", computedDigest.String())
|
locationQuery.Set("digest", computedDigest.String())
|
||||||
uploadLocation.RawQuery = locationQuery.Encode()
|
uploadLocation.RawQuery = locationQuery.Encode()
|
||||||
res, err = d.c.makeRequestToResolvedURL("PUT", uploadLocation.String(), map[string][]string{"Content-Type": {"application/octet-stream"}}, nil, -1, true)
|
res, err = d.c.makeRequestToResolvedURL(context.TODO(), "PUT", uploadLocation.String(), map[string][]string{"Content-Type": {"application/octet-stream"}}, nil, -1, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.BlobInfo{}, err
|
return types.BlobInfo{}, err
|
||||||
}
|
}
|
||||||
|
@ -193,7 +194,7 @@ func (d *dockerImageDestination) HasBlob(info types.BlobInfo) (bool, int64, erro
|
||||||
checkPath := fmt.Sprintf(blobsPath, reference.Path(d.ref.ref), info.Digest.String())
|
checkPath := fmt.Sprintf(blobsPath, reference.Path(d.ref.ref), info.Digest.String())
|
||||||
|
|
||||||
logrus.Debugf("Checking %s", checkPath)
|
logrus.Debugf("Checking %s", checkPath)
|
||||||
res, err := d.c.makeRequest("HEAD", checkPath, nil, nil)
|
res, err := d.c.makeRequest(context.TODO(), "HEAD", checkPath, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, -1, err
|
return false, -1, err
|
||||||
}
|
}
|
||||||
|
@ -239,7 +240,7 @@ func (d *dockerImageDestination) PutManifest(m []byte) error {
|
||||||
if mimeType != "" {
|
if mimeType != "" {
|
||||||
headers["Content-Type"] = []string{mimeType}
|
headers["Content-Type"] = []string{mimeType}
|
||||||
}
|
}
|
||||||
res, err := d.c.makeRequest("PUT", path, headers, bytes.NewReader(m))
|
res, err := d.c.makeRequest(context.TODO(), "PUT", path, headers, bytes.NewReader(m))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -275,7 +276,7 @@ func (d *dockerImageDestination) PutSignatures(signatures [][]byte) error {
|
||||||
if len(signatures) == 0 {
|
if len(signatures) == 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := d.c.detectProperties(); err != nil {
|
if err := d.c.detectProperties(context.TODO()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
|
@ -396,7 +397,7 @@ func (d *dockerImageDestination) putSignaturesToAPIExtension(signatures [][]byte
|
||||||
// always adds signatures. Eventually we should also allow removing signatures,
|
// always adds signatures. Eventually we should also allow removing signatures,
|
||||||
// but the X-Registry-Supports-Signatures API extension does not support that yet.
|
// but the X-Registry-Supports-Signatures API extension does not support that yet.
|
||||||
|
|
||||||
existingSignatures, err := d.c.getExtensionsSignatures(d.ref, d.manifestDigest)
|
existingSignatures, err := d.c.getExtensionsSignatures(context.TODO(), d.ref, d.manifestDigest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -438,7 +439,7 @@ sigExists:
|
||||||
}
|
}
|
||||||
|
|
||||||
path := fmt.Sprintf(extensionsSignaturePath, reference.Path(d.ref.ref), d.manifestDigest.String())
|
path := fmt.Sprintf(extensionsSignaturePath, reference.Path(d.ref.ref), d.manifestDigest.String())
|
||||||
res, err := d.c.makeRequest("PUT", path, nil, bytes.NewReader(body))
|
res, err := d.c.makeRequest(context.TODO(), "PUT", path, nil, bytes.NewReader(body))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
72
vendor/github.com/containers/image/docker/docker_image_src.go
generated
vendored
72
vendor/github.com/containers/image/docker/docker_image_src.go
generated
vendored
|
@ -1,6 +1,7 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -10,13 +11,13 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/docker/distribution/registry/client"
|
"github.com/docker/distribution/registry/client"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type dockerImageSource struct {
|
type dockerImageSource struct {
|
||||||
|
@ -85,18 +86,18 @@ func simplifyContentType(contentType string) string {
|
||||||
// GetManifest returns the image's manifest along with its MIME type (which may be empty when it can't be determined but the manifest is available).
|
// GetManifest returns the image's manifest along with its MIME type (which may be empty when it can't be determined but the manifest is available).
|
||||||
// It may use a remote (= slow) service.
|
// It may use a remote (= slow) service.
|
||||||
func (s *dockerImageSource) GetManifest() ([]byte, string, error) {
|
func (s *dockerImageSource) GetManifest() ([]byte, string, error) {
|
||||||
err := s.ensureManifestIsLoaded()
|
err := s.ensureManifestIsLoaded(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
return s.cachedManifest, s.cachedManifestMIMEType, nil
|
return s.cachedManifest, s.cachedManifestMIMEType, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *dockerImageSource) fetchManifest(tagOrDigest string) ([]byte, string, error) {
|
func (s *dockerImageSource) fetchManifest(ctx context.Context, tagOrDigest string) ([]byte, string, error) {
|
||||||
path := fmt.Sprintf(manifestPath, reference.Path(s.ref.ref), tagOrDigest)
|
path := fmt.Sprintf(manifestPath, reference.Path(s.ref.ref), tagOrDigest)
|
||||||
headers := make(map[string][]string)
|
headers := make(map[string][]string)
|
||||||
headers["Accept"] = s.requestedManifestMIMETypes
|
headers["Accept"] = s.requestedManifestMIMETypes
|
||||||
res, err := s.c.makeRequest("GET", path, headers, nil)
|
res, err := s.c.makeRequest(ctx, "GET", path, headers, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
|
@ -114,7 +115,7 @@ func (s *dockerImageSource) fetchManifest(tagOrDigest string) ([]byte, string, e
|
||||||
// GetTargetManifest returns an image's manifest given a digest.
|
// GetTargetManifest returns an image's manifest given a digest.
|
||||||
// This is mainly used to retrieve a single image's manifest out of a manifest list.
|
// This is mainly used to retrieve a single image's manifest out of a manifest list.
|
||||||
func (s *dockerImageSource) GetTargetManifest(digest digest.Digest) ([]byte, string, error) {
|
func (s *dockerImageSource) GetTargetManifest(digest digest.Digest) ([]byte, string, error) {
|
||||||
return s.fetchManifest(digest.String())
|
return s.fetchManifest(context.TODO(), digest.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensureManifestIsLoaded sets s.cachedManifest and s.cachedManifestMIMEType
|
// ensureManifestIsLoaded sets s.cachedManifest and s.cachedManifestMIMEType
|
||||||
|
@ -124,7 +125,7 @@ func (s *dockerImageSource) GetTargetManifest(digest digest.Digest) ([]byte, str
|
||||||
// we need to ensure that the digest of the manifest returned by GetManifest
|
// we need to ensure that the digest of the manifest returned by GetManifest
|
||||||
// and used by GetSignatures are consistent, otherwise we would get spurious
|
// and used by GetSignatures are consistent, otherwise we would get spurious
|
||||||
// signature verification failures when pulling while a tag is being updated.
|
// signature verification failures when pulling while a tag is being updated.
|
||||||
func (s *dockerImageSource) ensureManifestIsLoaded() error {
|
func (s *dockerImageSource) ensureManifestIsLoaded(ctx context.Context) error {
|
||||||
if s.cachedManifest != nil {
|
if s.cachedManifest != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -134,7 +135,7 @@ func (s *dockerImageSource) ensureManifestIsLoaded() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
manblob, mt, err := s.fetchManifest(reference)
|
manblob, mt, err := s.fetchManifest(ctx, reference)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -150,7 +151,7 @@ func (s *dockerImageSource) getExternalBlob(urls []string) (io.ReadCloser, int64
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
for _, url := range urls {
|
for _, url := range urls {
|
||||||
resp, err = s.c.makeRequestToResolvedURL("GET", url, nil, nil, -1, false)
|
resp, err = s.c.makeRequestToResolvedURL(context.TODO(), "GET", url, nil, nil, -1, false)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
err = errors.Errorf("error fetching external blob from %q: %d", url, resp.StatusCode)
|
err = errors.Errorf("error fetching external blob from %q: %d", url, resp.StatusCode)
|
||||||
|
@ -181,7 +182,7 @@ func (s *dockerImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64,
|
||||||
|
|
||||||
path := fmt.Sprintf(blobsPath, reference.Path(s.ref.ref), info.Digest.String())
|
path := fmt.Sprintf(blobsPath, reference.Path(s.ref.ref), info.Digest.String())
|
||||||
logrus.Debugf("Downloading %s", path)
|
logrus.Debugf("Downloading %s", path)
|
||||||
res, err := s.c.makeRequest("GET", path, nil, nil)
|
res, err := s.c.makeRequest(context.TODO(), "GET", path, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
@ -192,27 +193,38 @@ func (s *dockerImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64,
|
||||||
return res.Body, getBlobSize(res), nil
|
return res.Body, getBlobSize(res), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *dockerImageSource) GetSignatures() ([][]byte, error) {
|
func (s *dockerImageSource) GetSignatures(ctx context.Context) ([][]byte, error) {
|
||||||
if err := s.c.detectProperties(); err != nil {
|
if err := s.c.detectProperties(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
switch {
|
switch {
|
||||||
case s.c.signatureBase != nil:
|
case s.c.signatureBase != nil:
|
||||||
return s.getSignaturesFromLookaside()
|
return s.getSignaturesFromLookaside(ctx)
|
||||||
case s.c.supportsSignatures:
|
case s.c.supportsSignatures:
|
||||||
return s.getSignaturesFromAPIExtension()
|
return s.getSignaturesFromAPIExtension(ctx)
|
||||||
default:
|
default:
|
||||||
return [][]byte{}, nil
|
return [][]byte{}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// manifestDigest returns a digest of the manifest, either from the supplied reference or from a fetched manifest.
|
||||||
|
func (s *dockerImageSource) manifestDigest(ctx context.Context) (digest.Digest, error) {
|
||||||
|
if digested, ok := s.ref.ref.(reference.Digested); ok {
|
||||||
|
d := digested.Digest()
|
||||||
|
if d.Algorithm() == digest.Canonical {
|
||||||
|
return d, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := s.ensureManifestIsLoaded(ctx); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return manifest.Digest(s.cachedManifest)
|
||||||
|
}
|
||||||
|
|
||||||
// getSignaturesFromLookaside implements GetSignatures() from the lookaside location configured in s.c.signatureBase,
|
// getSignaturesFromLookaside implements GetSignatures() from the lookaside location configured in s.c.signatureBase,
|
||||||
// which is not nil.
|
// which is not nil.
|
||||||
func (s *dockerImageSource) getSignaturesFromLookaside() ([][]byte, error) {
|
func (s *dockerImageSource) getSignaturesFromLookaside(ctx context.Context) ([][]byte, error) {
|
||||||
if err := s.ensureManifestIsLoaded(); err != nil {
|
manifestDigest, err := s.manifestDigest(ctx)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
manifestDigest, err := manifest.Digest(s.cachedManifest)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -224,7 +236,7 @@ func (s *dockerImageSource) getSignaturesFromLookaside() ([][]byte, error) {
|
||||||
if url == nil {
|
if url == nil {
|
||||||
return nil, errors.Errorf("Internal error: signatureStorageURL with non-nil base returned nil")
|
return nil, errors.Errorf("Internal error: signatureStorageURL with non-nil base returned nil")
|
||||||
}
|
}
|
||||||
signature, missing, err := s.getOneSignature(url)
|
signature, missing, err := s.getOneSignature(ctx, url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -239,7 +251,7 @@ func (s *dockerImageSource) getSignaturesFromLookaside() ([][]byte, error) {
|
||||||
// getOneSignature downloads one signature from url.
|
// getOneSignature downloads one signature from url.
|
||||||
// If it successfully determines that the signature does not exist, returns with missing set to true and error set to nil.
|
// If it successfully determines that the signature does not exist, returns with missing set to true and error set to nil.
|
||||||
// NOTE: Keep this in sync with docs/signature-protocols.md!
|
// NOTE: Keep this in sync with docs/signature-protocols.md!
|
||||||
func (s *dockerImageSource) getOneSignature(url *url.URL) (signature []byte, missing bool, err error) {
|
func (s *dockerImageSource) getOneSignature(ctx context.Context, url *url.URL) (signature []byte, missing bool, err error) {
|
||||||
switch url.Scheme {
|
switch url.Scheme {
|
||||||
case "file":
|
case "file":
|
||||||
logrus.Debugf("Reading %s", url.Path)
|
logrus.Debugf("Reading %s", url.Path)
|
||||||
|
@ -254,7 +266,12 @@ func (s *dockerImageSource) getOneSignature(url *url.URL) (signature []byte, mis
|
||||||
|
|
||||||
case "http", "https":
|
case "http", "https":
|
||||||
logrus.Debugf("GET %s", url)
|
logrus.Debugf("GET %s", url)
|
||||||
res, err := s.c.client.Get(url.String())
|
req, err := http.NewRequest("GET", url.String(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, false, err
|
||||||
|
}
|
||||||
|
req = req.WithContext(ctx)
|
||||||
|
res, err := s.c.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, false, err
|
return nil, false, err
|
||||||
}
|
}
|
||||||
|
@ -276,16 +293,13 @@ func (s *dockerImageSource) getOneSignature(url *url.URL) (signature []byte, mis
|
||||||
}
|
}
|
||||||
|
|
||||||
// getSignaturesFromAPIExtension implements GetSignatures() using the X-Registry-Supports-Signatures API extension.
|
// getSignaturesFromAPIExtension implements GetSignatures() using the X-Registry-Supports-Signatures API extension.
|
||||||
func (s *dockerImageSource) getSignaturesFromAPIExtension() ([][]byte, error) {
|
func (s *dockerImageSource) getSignaturesFromAPIExtension(ctx context.Context) ([][]byte, error) {
|
||||||
if err := s.ensureManifestIsLoaded(); err != nil {
|
manifestDigest, err := s.manifestDigest(ctx)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
manifestDigest, err := manifest.Digest(s.cachedManifest)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
parsedBody, err := s.c.getExtensionsSignatures(s.ref, manifestDigest)
|
parsedBody, err := s.c.getExtensionsSignatures(ctx, s.ref, manifestDigest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -316,7 +330,7 @@ func deleteImage(ctx *types.SystemContext, ref dockerReference) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
getPath := fmt.Sprintf(manifestPath, reference.Path(ref.ref), refTail)
|
getPath := fmt.Sprintf(manifestPath, reference.Path(ref.ref), refTail)
|
||||||
get, err := c.makeRequest("GET", getPath, headers, nil)
|
get, err := c.makeRequest(context.TODO(), "GET", getPath, headers, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -338,7 +352,7 @@ func deleteImage(ctx *types.SystemContext, ref dockerReference) error {
|
||||||
|
|
||||||
// When retrieving the digest from a registry >= 2.3 use the following header:
|
// When retrieving the digest from a registry >= 2.3 use the following header:
|
||||||
// "Accept": "application/vnd.docker.distribution.manifest.v2+json"
|
// "Accept": "application/vnd.docker.distribution.manifest.v2+json"
|
||||||
delete, err := c.makeRequest("DELETE", deletePath, headers, nil)
|
delete, err := c.makeRequest(context.TODO(), "DELETE", deletePath, headers, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
2
vendor/github.com/containers/image/docker/lookaside.go
generated
vendored
2
vendor/github.com/containers/image/docker/lookaside.go
generated
vendored
|
@ -9,12 +9,12 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// systemRegistriesDirPath is the path to registries.d, used for locating lookaside Docker signature storage.
|
// systemRegistriesDirPath is the path to registries.d, used for locating lookaside Docker signature storage.
|
||||||
|
|
2
vendor/github.com/containers/image/docker/tarfile/dest.go
generated
vendored
2
vendor/github.com/containers/image/docker/tarfile/dest.go
generated
vendored
|
@ -10,12 +10,12 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
const temporaryDirectoryForBigFiles = "/var/tmp" // Do not use the system default of os.TempDir(), usually /tmp, because with systemd it could be a tmpfs.
|
const temporaryDirectoryForBigFiles = "/var/tmp" // Do not use the system default of os.TempDir(), usually /tmp, because with systemd it could be a tmpfs.
|
||||||
|
|
3
vendor/github.com/containers/image/docker/tarfile/src.go
generated
vendored
3
vendor/github.com/containers/image/docker/tarfile/src.go
generated
vendored
|
@ -3,6 +3,7 @@ package tarfile
|
||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -354,6 +355,6 @@ func (s *Source) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSignatures returns the image's signatures. It may use a remote (= slow) service.
|
// GetSignatures returns the image's signatures. It may use a remote (= slow) service.
|
||||||
func (s *Source) GetSignatures() ([][]byte, error) {
|
func (s *Source) GetSignatures(ctx context.Context) ([][]byte, error) {
|
||||||
return [][]byte{}, nil
|
return [][]byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
2
vendor/github.com/containers/image/image/docker_schema2.go
generated
vendored
2
vendor/github.com/containers/image/image/docker_schema2.go
generated
vendored
|
@ -8,13 +8,13 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
imgspecv1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// gzippedEmptyLayer is a gzip-compressed version of an empty tar file (1024 NULL bytes)
|
// gzippedEmptyLayer is a gzip-compressed version of an empty tar file (1024 NULL bytes)
|
||||||
|
|
4
vendor/github.com/containers/image/image/memory.go
generated
vendored
4
vendor/github.com/containers/image/image/memory.go
generated
vendored
|
@ -1,6 +1,8 @@
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
|
@ -54,7 +56,7 @@ func (i *memoryImage) Manifest() ([]byte, string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need.
|
// Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need.
|
||||||
func (i *memoryImage) Signatures() ([][]byte, error) {
|
func (i *memoryImage) Signatures(ctx context.Context) ([][]byte, error) {
|
||||||
// Modifying an image invalidates signatures; a caller asking the updated image for signatures
|
// Modifying an image invalidates signatures; a caller asking the updated image for signatures
|
||||||
// is probably confused.
|
// is probably confused.
|
||||||
return nil, errors.New("Internal error: Image.Signatures() is not supported for images modified in memory")
|
return nil, errors.New("Internal error: Image.Signatures() is not supported for images modified in memory")
|
||||||
|
|
6
vendor/github.com/containers/image/image/unparsed.go
generated
vendored
6
vendor/github.com/containers/image/image/unparsed.go
generated
vendored
|
@ -1,6 +1,8 @@
|
||||||
package image
|
package image
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
|
@ -71,9 +73,9 @@ func (i *UnparsedImage) Manifest() ([]byte, string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need.
|
// Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need.
|
||||||
func (i *UnparsedImage) Signatures() ([][]byte, error) {
|
func (i *UnparsedImage) Signatures(ctx context.Context) ([][]byte, error) {
|
||||||
if i.cachedSignatures == nil {
|
if i.cachedSignatures == nil {
|
||||||
sigs, err := i.src.GetSignatures()
|
sigs, err := i.src.GetSignatures(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
3
vendor/github.com/containers/image/oci/layout/oci_src.go
generated
vendored
3
vendor/github.com/containers/image/oci/layout/oci_src.go
generated
vendored
|
@ -1,6 +1,7 @@
|
||||||
package layout
|
package layout
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
@ -85,6 +86,6 @@ func (s *ociImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, err
|
||||||
return r, fi.Size(), nil
|
return r, fi.Size(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ociImageSource) GetSignatures() ([][]byte, error) {
|
func (s *ociImageSource) GetSignatures(context.Context) ([][]byte, error) {
|
||||||
return [][]byte{}, nil
|
return [][]byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
30
vendor/github.com/containers/image/openshift/openshift.go
generated
vendored
30
vendor/github.com/containers/image/openshift/openshift.go
generated
vendored
|
@ -2,6 +2,7 @@ package openshift
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -11,7 +12,6 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/docker"
|
"github.com/containers/image/docker"
|
||||||
"github.com/containers/image/docker/reference"
|
"github.com/containers/image/docker/reference"
|
||||||
"github.com/containers/image/manifest"
|
"github.com/containers/image/manifest"
|
||||||
|
@ -19,6 +19,7 @@ import (
|
||||||
"github.com/containers/image/version"
|
"github.com/containers/image/version"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// openshiftClient is configuration for dealing with a single image stream, for reading or writing.
|
// openshiftClient is configuration for dealing with a single image stream, for reading or writing.
|
||||||
|
@ -70,7 +71,7 @@ func newOpenshiftClient(ref openshiftReference) (*openshiftClient, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// doRequest performs a correctly authenticated request to a specified path, and returns response body or an error object.
|
// doRequest performs a correctly authenticated request to a specified path, and returns response body or an error object.
|
||||||
func (c *openshiftClient) doRequest(method, path string, requestBody []byte) ([]byte, error) {
|
func (c *openshiftClient) doRequest(ctx context.Context, method, path string, requestBody []byte) ([]byte, error) {
|
||||||
url := *c.baseURL
|
url := *c.baseURL
|
||||||
url.Path = path
|
url.Path = path
|
||||||
var requestBodyReader io.Reader
|
var requestBodyReader io.Reader
|
||||||
|
@ -82,6 +83,7 @@ func (c *openshiftClient) doRequest(method, path string, requestBody []byte) ([]
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
req = req.WithContext(ctx)
|
||||||
|
|
||||||
if len(c.bearerToken) != 0 {
|
if len(c.bearerToken) != 0 {
|
||||||
req.Header.Set("Authorization", "Bearer "+c.bearerToken)
|
req.Header.Set("Authorization", "Bearer "+c.bearerToken)
|
||||||
|
@ -132,10 +134,10 @@ func (c *openshiftClient) doRequest(method, path string, requestBody []byte) ([]
|
||||||
}
|
}
|
||||||
|
|
||||||
// getImage loads the specified image object.
|
// getImage loads the specified image object.
|
||||||
func (c *openshiftClient) getImage(imageStreamImageName string) (*image, error) {
|
func (c *openshiftClient) getImage(ctx context.Context, imageStreamImageName string) (*image, error) {
|
||||||
// FIXME: validate components per validation.IsValidPathSegmentName?
|
// FIXME: validate components per validation.IsValidPathSegmentName?
|
||||||
path := fmt.Sprintf("/oapi/v1/namespaces/%s/imagestreamimages/%s@%s", c.ref.namespace, c.ref.stream, imageStreamImageName)
|
path := fmt.Sprintf("/oapi/v1/namespaces/%s/imagestreamimages/%s@%s", c.ref.namespace, c.ref.stream, imageStreamImageName)
|
||||||
body, err := c.doRequest("GET", path, nil)
|
body, err := c.doRequest(ctx, "GET", path, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -203,7 +205,7 @@ func (s *openshiftImageSource) Close() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *openshiftImageSource) GetTargetManifest(digest digest.Digest) ([]byte, string, error) {
|
func (s *openshiftImageSource) GetTargetManifest(digest digest.Digest) ([]byte, string, error) {
|
||||||
if err := s.ensureImageIsResolved(); err != nil {
|
if err := s.ensureImageIsResolved(context.TODO()); err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
return s.docker.GetTargetManifest(digest)
|
return s.docker.GetTargetManifest(digest)
|
||||||
|
@ -212,7 +214,7 @@ func (s *openshiftImageSource) GetTargetManifest(digest digest.Digest) ([]byte,
|
||||||
// GetManifest returns the image's manifest along with its MIME type (which may be empty when it can't be determined but the manifest is available).
|
// GetManifest returns the image's manifest along with its MIME type (which may be empty when it can't be determined but the manifest is available).
|
||||||
// It may use a remote (= slow) service.
|
// It may use a remote (= slow) service.
|
||||||
func (s *openshiftImageSource) GetManifest() ([]byte, string, error) {
|
func (s *openshiftImageSource) GetManifest() ([]byte, string, error) {
|
||||||
if err := s.ensureImageIsResolved(); err != nil {
|
if err := s.ensureImageIsResolved(context.TODO()); err != nil {
|
||||||
return nil, "", err
|
return nil, "", err
|
||||||
}
|
}
|
||||||
return s.docker.GetManifest()
|
return s.docker.GetManifest()
|
||||||
|
@ -220,18 +222,18 @@ func (s *openshiftImageSource) GetManifest() ([]byte, string, error) {
|
||||||
|
|
||||||
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown).
|
// GetBlob returns a stream for the specified blob, and the blob’s size (or -1 if unknown).
|
||||||
func (s *openshiftImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
|
func (s *openshiftImageSource) GetBlob(info types.BlobInfo) (io.ReadCloser, int64, error) {
|
||||||
if err := s.ensureImageIsResolved(); err != nil {
|
if err := s.ensureImageIsResolved(context.TODO()); err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
return s.docker.GetBlob(info)
|
return s.docker.GetBlob(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *openshiftImageSource) GetSignatures() ([][]byte, error) {
|
func (s *openshiftImageSource) GetSignatures(ctx context.Context) ([][]byte, error) {
|
||||||
if err := s.ensureImageIsResolved(); err != nil {
|
if err := s.ensureImageIsResolved(ctx); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
image, err := s.client.getImage(s.imageStreamImageName)
|
image, err := s.client.getImage(ctx, s.imageStreamImageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -245,14 +247,14 @@ func (s *openshiftImageSource) GetSignatures() ([][]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensureImageIsResolved sets up s.docker and s.imageStreamImageName
|
// ensureImageIsResolved sets up s.docker and s.imageStreamImageName
|
||||||
func (s *openshiftImageSource) ensureImageIsResolved() error {
|
func (s *openshiftImageSource) ensureImageIsResolved(ctx context.Context) error {
|
||||||
if s.docker != nil {
|
if s.docker != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: validate components per validation.IsValidPathSegmentName?
|
// FIXME: validate components per validation.IsValidPathSegmentName?
|
||||||
path := fmt.Sprintf("/oapi/v1/namespaces/%s/imagestreams/%s", s.client.ref.namespace, s.client.ref.stream)
|
path := fmt.Sprintf("/oapi/v1/namespaces/%s/imagestreams/%s", s.client.ref.namespace, s.client.ref.stream)
|
||||||
body, err := s.client.doRequest("GET", path, nil)
|
body, err := s.client.doRequest(ctx, "GET", path, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -410,7 +412,7 @@ func (d *openshiftImageDestination) PutSignatures(signatures [][]byte) error {
|
||||||
return nil // No need to even read the old state.
|
return nil // No need to even read the old state.
|
||||||
}
|
}
|
||||||
|
|
||||||
image, err := d.client.getImage(d.imageStreamImageName)
|
image, err := d.client.getImage(context.TODO(), d.imageStreamImageName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -451,7 +453,7 @@ sigExists:
|
||||||
Content: newSig,
|
Content: newSig,
|
||||||
}
|
}
|
||||||
body, err := json.Marshal(sig)
|
body, err := json.Marshal(sig)
|
||||||
_, err = d.client.doRequest("POST", "/oapi/v1/imagesignatures", body)
|
_, err = d.client.doRequest(context.TODO(), "POST", "/oapi/v1/imagesignatures", body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
2
vendor/github.com/containers/image/pkg/compression/compression.go
generated
vendored
2
vendor/github.com/containers/image/pkg/compression/compression.go
generated
vendored
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DecompressorFunc returns the decompressed stream, given a compressed stream.
|
// DecompressorFunc returns the decompressed stream, given a compressed stream.
|
||||||
|
|
14
vendor/github.com/containers/image/signature/mechanism_openpgp.go
generated
vendored
14
vendor/github.com/containers/image/signature/mechanism_openpgp.go
generated
vendored
|
@ -132,11 +132,17 @@ func (m *openpgpSigningMechanism) Verify(unverifiedSignature []byte) (contents [
|
||||||
if md.SignedBy == nil {
|
if md.SignedBy == nil {
|
||||||
return nil, "", InvalidSignatureError{msg: fmt.Sprintf("Invalid GPG signature: %#v", md.Signature)}
|
return nil, "", InvalidSignatureError{msg: fmt.Sprintf("Invalid GPG signature: %#v", md.Signature)}
|
||||||
}
|
}
|
||||||
if md.Signature.SigLifetimeSecs != nil {
|
if md.Signature != nil {
|
||||||
expiry := md.Signature.CreationTime.Add(time.Duration(*md.Signature.SigLifetimeSecs) * time.Second)
|
if md.Signature.SigLifetimeSecs != nil {
|
||||||
if time.Now().After(expiry) {
|
expiry := md.Signature.CreationTime.Add(time.Duration(*md.Signature.SigLifetimeSecs) * time.Second)
|
||||||
return nil, "", InvalidSignatureError{msg: fmt.Sprintf("Signature expired on %s", expiry)}
|
if time.Now().After(expiry) {
|
||||||
|
return nil, "", InvalidSignatureError{msg: fmt.Sprintf("Signature expired on %s", expiry)}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else if md.SignatureV3 == nil {
|
||||||
|
// Coverage: If md.SignedBy != nil, the final md.UnverifiedBody.Read() either sets one of md.Signature or md.SignatureV3,
|
||||||
|
// or sets md.SignatureError.
|
||||||
|
return nil, "", InvalidSignatureError{msg: "Unexpected openpgp.MessageDetails: neither Signature nor SignatureV3 is set"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uppercase the fingerprint to be compatible with gpgme
|
// Uppercase the fingerprint to be compatible with gpgme
|
||||||
|
|
7
vendor/github.com/containers/image/signature/policy_eval.go
generated
vendored
7
vendor/github.com/containers/image/signature/policy_eval.go
generated
vendored
|
@ -6,9 +6,11 @@
|
||||||
package signature
|
package signature
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
"context"
|
||||||
|
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PolicyRequirementError is an explanatory text for rejecting a signature or an image.
|
// PolicyRequirementError is an explanatory text for rejecting a signature or an image.
|
||||||
|
@ -188,7 +190,8 @@ func (pc *PolicyContext) GetSignaturesWithAcceptedAuthor(image types.UnparsedIma
|
||||||
reqs := pc.requirementsForImageRef(image.Reference())
|
reqs := pc.requirementsForImageRef(image.Reference())
|
||||||
|
|
||||||
// FIXME: rename Signatures to UnverifiedSignatures
|
// FIXME: rename Signatures to UnverifiedSignatures
|
||||||
unverifiedSignatures, err := image.Signatures()
|
// FIXME: pass context.Context
|
||||||
|
unverifiedSignatures, err := image.Signatures(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
2
vendor/github.com/containers/image/signature/policy_eval_baselayer.go
generated
vendored
2
vendor/github.com/containers/image/signature/policy_eval_baselayer.go
generated
vendored
|
@ -3,8 +3,8 @@
|
||||||
package signature
|
package signature
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/Sirupsen/logrus"
|
|
||||||
"github.com/containers/image/types"
|
"github.com/containers/image/types"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (pr *prSignedBaseLayer) isSignatureAuthorAccepted(image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
|
func (pr *prSignedBaseLayer) isSignatureAuthorAccepted(image types.UnparsedImage, sig []byte) (signatureAcceptanceResult, *Signature, error) {
|
||||||
|
|
4
vendor/github.com/containers/image/signature/policy_eval_signedby.go
generated
vendored
4
vendor/github.com/containers/image/signature/policy_eval_signedby.go
generated
vendored
|
@ -3,6 +3,7 @@
|
||||||
package signature
|
package signature
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -90,7 +91,8 @@ func (pr *prSignedBy) isSignatureAuthorAccepted(image types.UnparsedImage, sig [
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *prSignedBy) isRunningImageAllowed(image types.UnparsedImage) (bool, error) {
|
func (pr *prSignedBy) isRunningImageAllowed(image types.UnparsedImage) (bool, error) {
|
||||||
sigs, err := image.Signatures()
|
// FIXME: pass context.Context
|
||||||
|
sigs, err := image.Signatures(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue