Update godeps
This commit is contained in:
parent
ffe6baa14c
commit
9b142b56f8
1137 changed files with 22773 additions and 189176 deletions
597
Godeps/Godeps.json
generated
597
Godeps/Godeps.json
generated
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/contrib/ingress",
|
"ImportPath": "k8s.io/contrib/ingress",
|
||||||
"GoVersion": "go1.5.3",
|
"GoVersion": "go1.5",
|
||||||
"Packages": [
|
"Packages": [
|
||||||
"./..."
|
"./..."
|
||||||
],
|
],
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
{
|
{
|
||||||
"ImportPath": "bitbucket.org/ww/goautoneg",
|
"ImportPath": "bitbucket.org/ww/goautoneg",
|
||||||
"Comment": "null-5",
|
"Comment": "null-5",
|
||||||
"Rev": "75cd24fc2f2c2a2088577d12123ddee5f54e0675"
|
"Rev": "'75cd24fc2f2c2a2088577d12123ddee5f54e0675'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/beorn7/perks/quantile",
|
"ImportPath": "github.com/beorn7/perks/quantile",
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/cpuguy83/go-md2man/md2man",
|
"ImportPath": "github.com/cpuguy83/go-md2man/md2man",
|
||||||
"Comment": "v1.0.3-2-g71acacd",
|
"Comment": "v1.0.4",
|
||||||
"Rev": "71acacd42f85e5e82f70a55327789582a5200a90"
|
"Rev": "71acacd42f85e5e82f70a55327789582a5200a90"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -48,17 +48,95 @@
|
||||||
"Comment": "v1.2",
|
"Comment": "v1.2",
|
||||||
"Rev": "777bb3f19bcafe2575ffb2a3e46af92509ae9594"
|
"Rev": "777bb3f19bcafe2575ffb2a3e46af92509ae9594"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/emicklei/go-restful/log",
|
||||||
|
"Comment": "v1.2",
|
||||||
|
"Rev": "777bb3f19bcafe2575ffb2a3e46af92509ae9594"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/emicklei/go-restful/swagger",
|
||||||
|
"Comment": "v1.2",
|
||||||
|
"Rev": "777bb3f19bcafe2575ffb2a3e46af92509ae9594"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/evanphx/json-patch",
|
"ImportPath": "github.com/evanphx/json-patch",
|
||||||
"Rev": "7dd4489c2eb6073e5a9d7746c3274c5b5f0387df"
|
"Rev": "7dd4489c2eb6073e5a9d7746c3274c5b5f0387df"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/fatih/structs",
|
"ImportPath": "github.com/fatih/structs",
|
||||||
"Rev": "d2e1722acaab51fc7fc55686706d08bbf9e4fafb"
|
"Rev": "a924a2250d1033753512e95dce41dca3fd793ad9"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/fsouza/go-dockerclient",
|
"ImportPath": "github.com/fsouza/go-dockerclient",
|
||||||
"Rev": "25bc220b299845ae5489fd19bf89c5278864b050"
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/Sirupsen/logrus",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/opts",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/archive",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/fileutils",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/homedir",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/idtools",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/ioutils",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/longpath",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/pools",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/promise",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/stdcopy",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/docker/pkg/system",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/docker/go-units",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/hashicorp/go-cleanhttp",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/github.com/opencontainers/runc/libcontainer/user",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/golang.org/x/net/context",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/fsouza/go-dockerclient/external/golang.org/x/sys/unix",
|
||||||
|
"Rev": "0099401a7342ad77e71ca9f9a57c5e72fb80f6b2"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/ghodss/yaml",
|
"ImportPath": "github.com/ghodss/yaml",
|
||||||
|
@ -74,12 +152,12 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/golang/protobuf/proto",
|
"ImportPath": "github.com/golang/protobuf/proto",
|
||||||
"Rev": "7f07925444bb51fa4cf9dfe6f7661876f8852275"
|
"Rev": "b982704f8bb716bb608144408cff30e15fbde841"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/google/cadvisor/info/v1",
|
"ImportPath": "github.com/google/cadvisor/info/v1",
|
||||||
"Comment": "v0.21.1",
|
"Comment": "v0.22.2",
|
||||||
"Rev": "49a08d5139ae0111757a110ea3b55fe9a607873d"
|
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/google/gofuzz",
|
"ImportPath": "github.com/google/gofuzz",
|
||||||
|
@ -107,6 +185,11 @@
|
||||||
"Comment": "v0.0.7",
|
"Comment": "v0.0.7",
|
||||||
"Rev": "7ca2aa4873aea7cb4265b1726acb24b90d8726c6"
|
"Rev": "7ca2aa4873aea7cb4265b1726acb24b90d8726c6"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/opencontainers/runc/libcontainer/cgroups/fs",
|
||||||
|
"Comment": "v0.0.7",
|
||||||
|
"Rev": "7ca2aa4873aea7cb4265b1726acb24b90d8726c6"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/configs",
|
"ImportPath": "github.com/opencontainers/runc/libcontainer/configs",
|
||||||
"Comment": "v0.0.7",
|
"Comment": "v0.0.7",
|
||||||
|
@ -152,6 +235,18 @@
|
||||||
"ImportPath": "github.com/scalingdata/gcfg",
|
"ImportPath": "github.com/scalingdata/gcfg",
|
||||||
"Rev": "37aabad69cfd3d20b8390d902a8b10e245c615ff"
|
"Rev": "37aabad69cfd3d20b8390d902a8b10e245c615ff"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/scalingdata/gcfg/scanner",
|
||||||
|
"Rev": "37aabad69cfd3d20b8390d902a8b10e245c615ff"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/scalingdata/gcfg/token",
|
||||||
|
"Rev": "37aabad69cfd3d20b8390d902a8b10e245c615ff"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/scalingdata/gcfg/types",
|
||||||
|
"Rev": "37aabad69cfd3d20b8390d902a8b10e245c615ff"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/shurcooL/sanitized_anchor_name",
|
"ImportPath": "github.com/shurcooL/sanitized_anchor_name",
|
||||||
"Rev": "9a8b7d4e8f347bfa230879db9d7d4e4d9e19f962"
|
"Rev": "9a8b7d4e8f347bfa230879db9d7d4e4d9e19f962"
|
||||||
|
@ -166,16 +261,36 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/ugorji/go/codec",
|
"ImportPath": "github.com/ugorji/go/codec",
|
||||||
"Rev": "f1f1a805ed361a0e078bb537e4ea78cd37dcf065"
|
"Rev": "f4485b318aadd133842532f841dc205a8e339d74"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "golang.org/x/net/context",
|
"ImportPath": "golang.org/x/net/context",
|
||||||
"Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e"
|
"Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "golang.org/x/net/context/ctxhttp",
|
||||||
|
"Rev": "c2528b2dd8352441850638a8bb678c2ad056fd3e"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "golang.org/x/oauth2",
|
"ImportPath": "golang.org/x/oauth2",
|
||||||
"Rev": "b5adcc2dcdf009d0391547edc6ecbaff889f5bb9"
|
"Rev": "b5adcc2dcdf009d0391547edc6ecbaff889f5bb9"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "golang.org/x/oauth2/google",
|
||||||
|
"Rev": "b5adcc2dcdf009d0391547edc6ecbaff889f5bb9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "golang.org/x/oauth2/internal",
|
||||||
|
"Rev": "b5adcc2dcdf009d0391547edc6ecbaff889f5bb9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "golang.org/x/oauth2/jws",
|
||||||
|
"Rev": "b5adcc2dcdf009d0391547edc6ecbaff889f5bb9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "golang.org/x/oauth2/jwt",
|
||||||
|
"Rev": "b5adcc2dcdf009d0391547edc6ecbaff889f5bb9"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "google.golang.org/api/compute/v1",
|
"ImportPath": "google.golang.org/api/compute/v1",
|
||||||
"Rev": "77e7d383beb96054547729f49c372b3d01e196ff"
|
"Rev": "77e7d383beb96054547729f49c372b3d01e196ff"
|
||||||
|
@ -192,6 +307,10 @@
|
||||||
"ImportPath": "google.golang.org/api/googleapi",
|
"ImportPath": "google.golang.org/api/googleapi",
|
||||||
"Rev": "77e7d383beb96054547729f49c372b3d01e196ff"
|
"Rev": "77e7d383beb96054547729f49c372b3d01e196ff"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "google.golang.org/api/googleapi/internal/uritemplates",
|
||||||
|
"Rev": "77e7d383beb96054547729f49c372b3d01e196ff"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "google.golang.org/cloud/compute/metadata",
|
"ImportPath": "google.golang.org/cloud/compute/metadata",
|
||||||
"Rev": "2e43671e4ad874a7bca65746ff3edb38e6e93762"
|
"Rev": "2e43671e4ad874a7bca65746ff3edb38e6e93762"
|
||||||
|
@ -206,178 +325,498 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/api",
|
"ImportPath": "k8s.io/kubernetes/pkg/api",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/endpoints",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/errors",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/install",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/meta",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/pod",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/resource",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/service",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/testapi",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/unversioned",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/util",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/v1",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/api/validation",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/apimachinery",
|
"ImportPath": "k8s.io/kubernetes/pkg/apimachinery",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apimachinery/registered",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/apis/authorization",
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/authorization",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/authorization/install",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/authorization/v1beta1",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/apis/autoscaling",
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/autoscaling",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/autoscaling/install",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/autoscaling/v1",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/batch",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/batch/install",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/batch/v1",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/apis/componentconfig",
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/componentconfig",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/componentconfig/install",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/componentconfig/v1alpha1",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/apis/extensions",
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/extensions",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/extensions/install",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/extensions/v1beta1",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/apis/metrics",
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/metrics",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/metrics/install",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/apis/metrics/v1alpha1",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/auth/user",
|
"ImportPath": "k8s.io/kubernetes/pkg/auth/user",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/capabilities",
|
"ImportPath": "k8s.io/kubernetes/pkg/capabilities",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/client/cache",
|
"ImportPath": "k8s.io/kubernetes/pkg/client/cache",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset",
|
"ImportPath": "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/client/metrics",
|
"ImportPath": "k8s.io/kubernetes/pkg/client/metrics",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/client/record",
|
"ImportPath": "k8s.io/kubernetes/pkg/client/record",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/client/restclient",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/client/transport",
|
"ImportPath": "k8s.io/kubernetes/pkg/client/transport",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/client/typed/discovery",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned",
|
"ImportPath": "k8s.io/kubernetes/pkg/client/typed/generated/core/unversioned",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned",
|
"ImportPath": "k8s.io/kubernetes/pkg/client/typed/generated/extensions/unversioned",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/client/unversioned",
|
"ImportPath": "k8s.io/kubernetes/pkg/client/unversioned",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/client/unversioned/auth",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/client/unversioned/clientcmd",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api/latest",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/client/unversioned/clientcmd/api/v1",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/cloudprovider",
|
"ImportPath": "k8s.io/kubernetes/pkg/cloudprovider",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/cloudprovider/providers/gce",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/controller",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/controller/framework",
|
"ImportPath": "k8s.io/kubernetes/pkg/controller/framework",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/conversion",
|
"ImportPath": "k8s.io/kubernetes/pkg/conversion",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/conversion/queryparams",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/credentialprovider",
|
"ImportPath": "k8s.io/kubernetes/pkg/credentialprovider",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/fieldpath",
|
"ImportPath": "k8s.io/kubernetes/pkg/fieldpath",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/fields",
|
"ImportPath": "k8s.io/kubernetes/pkg/fields",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/kubectl",
|
"ImportPath": "k8s.io/kubernetes/pkg/kubectl",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/kubectl/cmd/util",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/kubectl/resource",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/kubelet/qos",
|
"ImportPath": "k8s.io/kubernetes/pkg/kubelet/qos",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/kubelet/qos/util",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/labels",
|
"ImportPath": "k8s.io/kubernetes/pkg/labels",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/master/ports",
|
"ImportPath": "k8s.io/kubernetes/pkg/master/ports",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/runtime",
|
"ImportPath": "k8s.io/kubernetes/pkg/runtime",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/runtime/serializer",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/runtime/serializer/json",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/runtime/serializer/recognizer",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/runtime/serializer/versioning",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/types",
|
"ImportPath": "k8s.io/kubernetes/pkg/types",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/util",
|
"ImportPath": "k8s.io/kubernetes/pkg/util",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/deployment",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/errors",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/hash",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/integer",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/intstr",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/jsonpath",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/labels",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/net",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/net/sets",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/parsers",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/pod",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/rand",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/runtime",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/sets",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/strategicpatch",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/validation",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/validation/field",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/wait",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/workqueue",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/util/yaml",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/version",
|
"ImportPath": "k8s.io/kubernetes/pkg/version",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/pkg/watch",
|
"ImportPath": "k8s.io/kubernetes/pkg/watch",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "k8s.io/kubernetes/pkg/watch/json",
|
||||||
|
"Comment": "v1.2.1-beta.0",
|
||||||
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/third_party/forked/json",
|
"ImportPath": "k8s.io/kubernetes/third_party/forked/json",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/third_party/forked/reflect",
|
"ImportPath": "k8s.io/kubernetes/third_party/forked/reflect",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/kubernetes/third_party/golang/template",
|
"ImportPath": "k8s.io/kubernetes/third_party/golang/template",
|
||||||
"Comment": "v1.2.0-alpha.8-71-g1ce188e",
|
"Comment": "v1.2.1-beta.0",
|
||||||
"Rev": "1ce188e557769353063dc2233c89f4fa02133ecc"
|
"Rev": "fd557a2c9f47c655f9c07d9cf9dee2539e935703"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "speter.net/go/exp/math/dec/inf",
|
"ImportPath": "speter.net/go/exp/math/dec/inf",
|
||||||
|
|
33
Godeps/_workspace/src/bitbucket.org/ww/goautoneg/autoneg_test.go
generated
vendored
33
Godeps/_workspace/src/bitbucket.org/ww/goautoneg/autoneg_test.go
generated
vendored
|
@ -1,33 +0,0 @@
|
||||||
package goautoneg
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
var chrome = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
|
|
||||||
|
|
||||||
func TestParseAccept(t *testing.T) {
|
|
||||||
alternatives := []string{"text/html", "image/png"}
|
|
||||||
content_type := Negotiate(chrome, alternatives)
|
|
||||||
if content_type != "image/png" {
|
|
||||||
t.Errorf("got %s expected image/png", content_type)
|
|
||||||
}
|
|
||||||
|
|
||||||
alternatives = []string{"text/html", "text/plain", "text/n3"}
|
|
||||||
content_type = Negotiate(chrome, alternatives)
|
|
||||||
if content_type != "text/html" {
|
|
||||||
t.Errorf("got %s expected text/html", content_type)
|
|
||||||
}
|
|
||||||
|
|
||||||
alternatives = []string{"text/n3", "text/plain"}
|
|
||||||
content_type = Negotiate(chrome, alternatives)
|
|
||||||
if content_type != "text/plain" {
|
|
||||||
t.Errorf("got %s expected text/plain", content_type)
|
|
||||||
}
|
|
||||||
|
|
||||||
alternatives = []string{"text/n3", "application/rdf+xml"}
|
|
||||||
content_type = Negotiate(chrome, alternatives)
|
|
||||||
if content_type != "text/n3" {
|
|
||||||
t.Errorf("got %s expected text/n3", content_type)
|
|
||||||
}
|
|
||||||
}
|
|
63
Godeps/_workspace/src/github.com/beorn7/perks/quantile/bench_test.go
generated
vendored
63
Godeps/_workspace/src/github.com/beorn7/perks/quantile/bench_test.go
generated
vendored
|
@ -1,63 +0,0 @@
|
||||||
package quantile
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func BenchmarkInsertTargeted(b *testing.B) {
|
|
||||||
b.ReportAllocs()
|
|
||||||
|
|
||||||
s := NewTargeted(Targets)
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := float64(0); i < float64(b.N); i++ {
|
|
||||||
s.Insert(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkInsertTargetedSmallEpsilon(b *testing.B) {
|
|
||||||
s := NewTargeted(TargetsSmallEpsilon)
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := float64(0); i < float64(b.N); i++ {
|
|
||||||
s.Insert(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkInsertBiased(b *testing.B) {
|
|
||||||
s := NewLowBiased(0.01)
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := float64(0); i < float64(b.N); i++ {
|
|
||||||
s.Insert(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkInsertBiasedSmallEpsilon(b *testing.B) {
|
|
||||||
s := NewLowBiased(0.0001)
|
|
||||||
b.ResetTimer()
|
|
||||||
for i := float64(0); i < float64(b.N); i++ {
|
|
||||||
s.Insert(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkQuery(b *testing.B) {
|
|
||||||
s := NewTargeted(Targets)
|
|
||||||
for i := float64(0); i < 1e6; i++ {
|
|
||||||
s.Insert(i)
|
|
||||||
}
|
|
||||||
b.ResetTimer()
|
|
||||||
n := float64(b.N)
|
|
||||||
for i := float64(0); i < n; i++ {
|
|
||||||
s.Query(i / n)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkQuerySmallEpsilon(b *testing.B) {
|
|
||||||
s := NewTargeted(TargetsSmallEpsilon)
|
|
||||||
for i := float64(0); i < 1e6; i++ {
|
|
||||||
s.Insert(i)
|
|
||||||
}
|
|
||||||
b.ResetTimer()
|
|
||||||
n := float64(b.N)
|
|
||||||
for i := float64(0); i < n; i++ {
|
|
||||||
s.Query(i / n)
|
|
||||||
}
|
|
||||||
}
|
|
121
Godeps/_workspace/src/github.com/beorn7/perks/quantile/example_test.go
generated
vendored
121
Godeps/_workspace/src/github.com/beorn7/perks/quantile/example_test.go
generated
vendored
|
@ -1,121 +0,0 @@
|
||||||
// +build go1.1
|
|
||||||
|
|
||||||
package quantile_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/beorn7/perks/quantile"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Example_simple() {
|
|
||||||
ch := make(chan float64)
|
|
||||||
go sendFloats(ch)
|
|
||||||
|
|
||||||
// Compute the 50th, 90th, and 99th percentile.
|
|
||||||
q := quantile.NewTargeted(map[float64]float64{
|
|
||||||
0.50: 0.005,
|
|
||||||
0.90: 0.001,
|
|
||||||
0.99: 0.0001,
|
|
||||||
})
|
|
||||||
for v := range ch {
|
|
||||||
q.Insert(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("perc50:", q.Query(0.50))
|
|
||||||
fmt.Println("perc90:", q.Query(0.90))
|
|
||||||
fmt.Println("perc99:", q.Query(0.99))
|
|
||||||
fmt.Println("count:", q.Count())
|
|
||||||
// Output:
|
|
||||||
// perc50: 5
|
|
||||||
// perc90: 16
|
|
||||||
// perc99: 223
|
|
||||||
// count: 2388
|
|
||||||
}
|
|
||||||
|
|
||||||
func Example_mergeMultipleStreams() {
|
|
||||||
// Scenario:
|
|
||||||
// We have multiple database shards. On each shard, there is a process
|
|
||||||
// collecting query response times from the database logs and inserting
|
|
||||||
// them into a Stream (created via NewTargeted(0.90)), much like the
|
|
||||||
// Simple example. These processes expose a network interface for us to
|
|
||||||
// ask them to serialize and send us the results of their
|
|
||||||
// Stream.Samples so we may Merge and Query them.
|
|
||||||
//
|
|
||||||
// NOTES:
|
|
||||||
// * These sample sets are small, allowing us to get them
|
|
||||||
// across the network much faster than sending the entire list of data
|
|
||||||
// points.
|
|
||||||
//
|
|
||||||
// * For this to work correctly, we must supply the same quantiles
|
|
||||||
// a priori the process collecting the samples supplied to NewTargeted,
|
|
||||||
// even if we do not plan to query them all here.
|
|
||||||
ch := make(chan quantile.Samples)
|
|
||||||
getDBQuerySamples(ch)
|
|
||||||
q := quantile.NewTargeted(map[float64]float64{0.90: 0.001})
|
|
||||||
for samples := range ch {
|
|
||||||
q.Merge(samples)
|
|
||||||
}
|
|
||||||
fmt.Println("perc90:", q.Query(0.90))
|
|
||||||
}
|
|
||||||
|
|
||||||
func Example_window() {
|
|
||||||
// Scenario: We want the 90th, 95th, and 99th percentiles for each
|
|
||||||
// minute.
|
|
||||||
|
|
||||||
ch := make(chan float64)
|
|
||||||
go sendStreamValues(ch)
|
|
||||||
|
|
||||||
tick := time.NewTicker(1 * time.Minute)
|
|
||||||
q := quantile.NewTargeted(map[float64]float64{
|
|
||||||
0.90: 0.001,
|
|
||||||
0.95: 0.0005,
|
|
||||||
0.99: 0.0001,
|
|
||||||
})
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case t := <-tick.C:
|
|
||||||
flushToDB(t, q.Samples())
|
|
||||||
q.Reset()
|
|
||||||
case v := <-ch:
|
|
||||||
q.Insert(v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func sendStreamValues(ch chan float64) {
|
|
||||||
// Use your imagination
|
|
||||||
}
|
|
||||||
|
|
||||||
func flushToDB(t time.Time, samples quantile.Samples) {
|
|
||||||
// Use your imagination
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a stub for the above example. In reality this would hit the remote
|
|
||||||
// servers via http or something like it.
|
|
||||||
func getDBQuerySamples(ch chan quantile.Samples) {}
|
|
||||||
|
|
||||||
func sendFloats(ch chan<- float64) {
|
|
||||||
f, err := os.Open("exampledata.txt")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
sc := bufio.NewScanner(f)
|
|
||||||
for sc.Scan() {
|
|
||||||
b := sc.Bytes()
|
|
||||||
v, err := strconv.ParseFloat(string(b), 64)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
ch <- v
|
|
||||||
}
|
|
||||||
if sc.Err() != nil {
|
|
||||||
log.Fatal(sc.Err())
|
|
||||||
}
|
|
||||||
close(ch)
|
|
||||||
}
|
|
188
Godeps/_workspace/src/github.com/beorn7/perks/quantile/stream_test.go
generated
vendored
188
Godeps/_workspace/src/github.com/beorn7/perks/quantile/stream_test.go
generated
vendored
|
@ -1,188 +0,0 @@
|
||||||
package quantile
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math"
|
|
||||||
"math/rand"
|
|
||||||
"sort"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
Targets = map[float64]float64{
|
|
||||||
0.01: 0.001,
|
|
||||||
0.10: 0.01,
|
|
||||||
0.50: 0.05,
|
|
||||||
0.90: 0.01,
|
|
||||||
0.99: 0.001,
|
|
||||||
}
|
|
||||||
TargetsSmallEpsilon = map[float64]float64{
|
|
||||||
0.01: 0.0001,
|
|
||||||
0.10: 0.001,
|
|
||||||
0.50: 0.005,
|
|
||||||
0.90: 0.001,
|
|
||||||
0.99: 0.0001,
|
|
||||||
}
|
|
||||||
LowQuantiles = []float64{0.01, 0.1, 0.5}
|
|
||||||
HighQuantiles = []float64{0.99, 0.9, 0.5}
|
|
||||||
)
|
|
||||||
|
|
||||||
const RelativeEpsilon = 0.01
|
|
||||||
|
|
||||||
func verifyPercsWithAbsoluteEpsilon(t *testing.T, a []float64, s *Stream) {
|
|
||||||
sort.Float64s(a)
|
|
||||||
for quantile, epsilon := range Targets {
|
|
||||||
n := float64(len(a))
|
|
||||||
k := int(quantile * n)
|
|
||||||
lower := int((quantile - epsilon) * n)
|
|
||||||
if lower < 1 {
|
|
||||||
lower = 1
|
|
||||||
}
|
|
||||||
upper := int(math.Ceil((quantile + epsilon) * n))
|
|
||||||
if upper > len(a) {
|
|
||||||
upper = len(a)
|
|
||||||
}
|
|
||||||
w, min, max := a[k-1], a[lower-1], a[upper-1]
|
|
||||||
if g := s.Query(quantile); g < min || g > max {
|
|
||||||
t.Errorf("q=%f: want %v [%f,%f], got %v", quantile, w, min, max, g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func verifyLowPercsWithRelativeEpsilon(t *testing.T, a []float64, s *Stream) {
|
|
||||||
sort.Float64s(a)
|
|
||||||
for _, qu := range LowQuantiles {
|
|
||||||
n := float64(len(a))
|
|
||||||
k := int(qu * n)
|
|
||||||
|
|
||||||
lowerRank := int((1 - RelativeEpsilon) * qu * n)
|
|
||||||
upperRank := int(math.Ceil((1 + RelativeEpsilon) * qu * n))
|
|
||||||
w, min, max := a[k-1], a[lowerRank-1], a[upperRank-1]
|
|
||||||
if g := s.Query(qu); g < min || g > max {
|
|
||||||
t.Errorf("q=%f: want %v [%f,%f], got %v", qu, w, min, max, g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func verifyHighPercsWithRelativeEpsilon(t *testing.T, a []float64, s *Stream) {
|
|
||||||
sort.Float64s(a)
|
|
||||||
for _, qu := range HighQuantiles {
|
|
||||||
n := float64(len(a))
|
|
||||||
k := int(qu * n)
|
|
||||||
|
|
||||||
lowerRank := int((1 - (1+RelativeEpsilon)*(1-qu)) * n)
|
|
||||||
upperRank := int(math.Ceil((1 - (1-RelativeEpsilon)*(1-qu)) * n))
|
|
||||||
w, min, max := a[k-1], a[lowerRank-1], a[upperRank-1]
|
|
||||||
if g := s.Query(qu); g < min || g > max {
|
|
||||||
t.Errorf("q=%f: want %v [%f,%f], got %v", qu, w, min, max, g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func populateStream(s *Stream) []float64 {
|
|
||||||
a := make([]float64, 0, 1e5+100)
|
|
||||||
for i := 0; i < cap(a); i++ {
|
|
||||||
v := rand.NormFloat64()
|
|
||||||
// Add 5% asymmetric outliers.
|
|
||||||
if i%20 == 0 {
|
|
||||||
v = v*v + 1
|
|
||||||
}
|
|
||||||
s.Insert(v)
|
|
||||||
a = append(a, v)
|
|
||||||
}
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTargetedQuery(t *testing.T) {
|
|
||||||
rand.Seed(42)
|
|
||||||
s := NewTargeted(Targets)
|
|
||||||
a := populateStream(s)
|
|
||||||
verifyPercsWithAbsoluteEpsilon(t, a, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLowBiasedQuery(t *testing.T) {
|
|
||||||
rand.Seed(42)
|
|
||||||
s := NewLowBiased(RelativeEpsilon)
|
|
||||||
a := populateStream(s)
|
|
||||||
verifyLowPercsWithRelativeEpsilon(t, a, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHighBiasedQuery(t *testing.T) {
|
|
||||||
rand.Seed(42)
|
|
||||||
s := NewHighBiased(RelativeEpsilon)
|
|
||||||
a := populateStream(s)
|
|
||||||
verifyHighPercsWithRelativeEpsilon(t, a, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BrokenTestTargetedMerge is broken, see Merge doc comment.
|
|
||||||
func BrokenTestTargetedMerge(t *testing.T) {
|
|
||||||
rand.Seed(42)
|
|
||||||
s1 := NewTargeted(Targets)
|
|
||||||
s2 := NewTargeted(Targets)
|
|
||||||
a := populateStream(s1)
|
|
||||||
a = append(a, populateStream(s2)...)
|
|
||||||
s1.Merge(s2.Samples())
|
|
||||||
verifyPercsWithAbsoluteEpsilon(t, a, s1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BrokenTestLowBiasedMerge is broken, see Merge doc comment.
|
|
||||||
func BrokenTestLowBiasedMerge(t *testing.T) {
|
|
||||||
rand.Seed(42)
|
|
||||||
s1 := NewLowBiased(RelativeEpsilon)
|
|
||||||
s2 := NewLowBiased(RelativeEpsilon)
|
|
||||||
a := populateStream(s1)
|
|
||||||
a = append(a, populateStream(s2)...)
|
|
||||||
s1.Merge(s2.Samples())
|
|
||||||
verifyLowPercsWithRelativeEpsilon(t, a, s2)
|
|
||||||
}
|
|
||||||
|
|
||||||
// BrokenTestHighBiasedMerge is broken, see Merge doc comment.
|
|
||||||
func BrokenTestHighBiasedMerge(t *testing.T) {
|
|
||||||
rand.Seed(42)
|
|
||||||
s1 := NewHighBiased(RelativeEpsilon)
|
|
||||||
s2 := NewHighBiased(RelativeEpsilon)
|
|
||||||
a := populateStream(s1)
|
|
||||||
a = append(a, populateStream(s2)...)
|
|
||||||
s1.Merge(s2.Samples())
|
|
||||||
verifyHighPercsWithRelativeEpsilon(t, a, s2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUncompressed(t *testing.T) {
|
|
||||||
q := NewTargeted(Targets)
|
|
||||||
for i := 100; i > 0; i-- {
|
|
||||||
q.Insert(float64(i))
|
|
||||||
}
|
|
||||||
if g := q.Count(); g != 100 {
|
|
||||||
t.Errorf("want count 100, got %d", g)
|
|
||||||
}
|
|
||||||
// Before compression, Query should have 100% accuracy.
|
|
||||||
for quantile := range Targets {
|
|
||||||
w := quantile * 100
|
|
||||||
if g := q.Query(quantile); g != w {
|
|
||||||
t.Errorf("want %f, got %f", w, g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUncompressedSamples(t *testing.T) {
|
|
||||||
q := NewTargeted(map[float64]float64{0.99: 0.001})
|
|
||||||
for i := 1; i <= 100; i++ {
|
|
||||||
q.Insert(float64(i))
|
|
||||||
}
|
|
||||||
if g := q.Samples().Len(); g != 100 {
|
|
||||||
t.Errorf("want count 100, got %d", g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUncompressedOne(t *testing.T) {
|
|
||||||
q := NewTargeted(map[float64]float64{0.99: 0.01})
|
|
||||||
q.Insert(3.14)
|
|
||||||
if g := q.Query(0.90); g != 3.14 {
|
|
||||||
t.Error("want PI, got", g)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDefaults(t *testing.T) {
|
|
||||||
if g := NewTargeted(map[float64]float64{0.99: 0.001}).Query(0.99); g != 0 {
|
|
||||||
t.Errorf("want 0, got %f", g)
|
|
||||||
}
|
|
||||||
}
|
|
83
Godeps/_workspace/src/github.com/blang/semver/examples/main.go
generated
vendored
83
Godeps/_workspace/src/github.com/blang/semver/examples/main.go
generated
vendored
|
@ -1,83 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/blang/semver"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
v, err := semver.Parse("0.0.1-alpha.preview.222+123.github")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Error while parsing (not valid): %q", err)
|
|
||||||
}
|
|
||||||
fmt.Printf("Version to string: %q\n", v)
|
|
||||||
|
|
||||||
fmt.Printf("Major: %d\n", v.Major)
|
|
||||||
fmt.Printf("Minor: %d\n", v.Minor)
|
|
||||||
fmt.Printf("Patch: %d\n", v.Patch)
|
|
||||||
|
|
||||||
// Prerelease versions
|
|
||||||
if len(v.Pre) > 0 {
|
|
||||||
fmt.Println("Prerelease versions:")
|
|
||||||
for i, pre := range v.Pre {
|
|
||||||
fmt.Printf("%d: %q\n", i, pre)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Build meta data
|
|
||||||
if len(v.Build) > 0 {
|
|
||||||
fmt.Println("Build meta data:")
|
|
||||||
for i, build := range v.Build {
|
|
||||||
fmt.Printf("%d: %q\n", i, build)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make == Parse (Value), New for Pointer
|
|
||||||
v001, err := semver.Make("0.0.1")
|
|
||||||
|
|
||||||
fmt.Println("\nUse Version.Compare for comparisons (-1, 0, 1):")
|
|
||||||
fmt.Printf("%q is greater than %q: Compare == %d\n", v001, v, v001.Compare(v))
|
|
||||||
fmt.Printf("%q is less than %q: Compare == %d\n", v, v001, v.Compare(v001))
|
|
||||||
fmt.Printf("%q is equal to %q: Compare == %d\n", v, v, v.Compare(v))
|
|
||||||
|
|
||||||
fmt.Println("\nUse comparison helpers returning booleans:")
|
|
||||||
fmt.Printf("%q is greater than %q: %t\n", v001, v, v001.GT(v))
|
|
||||||
fmt.Printf("%q is greater than equal %q: %t\n", v001, v, v001.GTE(v))
|
|
||||||
fmt.Printf("%q is greater than equal %q: %t\n", v, v, v.GTE(v))
|
|
||||||
fmt.Printf("%q is less than %q: %t\n", v, v001, v.LT(v001))
|
|
||||||
fmt.Printf("%q is less than equal %q: %t\n", v, v001, v.LTE(v001))
|
|
||||||
fmt.Printf("%q is less than equal %q: %t\n", v, v, v.LTE(v))
|
|
||||||
|
|
||||||
fmt.Println("\nManipulate Version in place:")
|
|
||||||
v.Pre[0], err = semver.NewPRVersion("beta")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Error parsing pre release version: %q", err)
|
|
||||||
}
|
|
||||||
fmt.Printf("Version to string: %q\n", v)
|
|
||||||
|
|
||||||
fmt.Println("\nCompare Prerelease versions:")
|
|
||||||
pre1, _ := semver.NewPRVersion("123")
|
|
||||||
pre2, _ := semver.NewPRVersion("alpha")
|
|
||||||
pre3, _ := semver.NewPRVersion("124")
|
|
||||||
fmt.Printf("%q is less than %q: Compare == %d\n", pre1, pre2, pre1.Compare(pre2))
|
|
||||||
fmt.Printf("%q is greater than %q: Compare == %d\n", pre3, pre1, pre3.Compare(pre1))
|
|
||||||
fmt.Printf("%q is equal to %q: Compare == %d\n", pre1, pre1, pre1.Compare(pre1))
|
|
||||||
|
|
||||||
fmt.Println("\nValidate versions:")
|
|
||||||
v.Build[0] = "?"
|
|
||||||
|
|
||||||
err = v.Validate()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Validation failed: %s\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Create valid build meta data:")
|
|
||||||
b1, _ := semver.NewBuildVersion("build123")
|
|
||||||
v.Build[0] = b1
|
|
||||||
fmt.Printf("Version with new build version %q\n", v)
|
|
||||||
|
|
||||||
_, err = semver.NewBuildVersion("build?123")
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Create build version failed: %s\n", err)
|
|
||||||
}
|
|
||||||
}
|
|
45
Godeps/_workspace/src/github.com/blang/semver/json_test.go
generated
vendored
45
Godeps/_workspace/src/github.com/blang/semver/json_test.go
generated
vendored
|
@ -1,45 +0,0 @@
|
||||||
package semver
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"strconv"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestJSONMarshal(t *testing.T) {
|
|
||||||
versionString := "3.1.4-alpha.1.5.9+build.2.6.5"
|
|
||||||
v, err := Parse(versionString)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
versionJSON, err := json.Marshal(v)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
quotedVersionString := strconv.Quote(versionString)
|
|
||||||
|
|
||||||
if string(versionJSON) != quotedVersionString {
|
|
||||||
t.Fatalf("JSON marshaled semantic version not equal: expected %q, got %q", quotedVersionString, string(versionJSON))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestJSONUnmarshal(t *testing.T) {
|
|
||||||
versionString := "3.1.4-alpha.1.5.9+build.2.6.5"
|
|
||||||
quotedVersionString := strconv.Quote(versionString)
|
|
||||||
|
|
||||||
var v Version
|
|
||||||
if err := json.Unmarshal([]byte(quotedVersionString), &v); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if v.String() != versionString {
|
|
||||||
t.Fatalf("JSON unmarshaled semantic version not equal: expected %q, got %q", versionString, v.String())
|
|
||||||
}
|
|
||||||
|
|
||||||
badVersionString := strconv.Quote("3.1.4.1.5.9.2.6.5-other-digits-of-pi")
|
|
||||||
if err := json.Unmarshal([]byte(badVersionString), &v); err == nil {
|
|
||||||
t.Fatal("expected JSON unmarshal error, got nil")
|
|
||||||
}
|
|
||||||
}
|
|
417
Godeps/_workspace/src/github.com/blang/semver/semver_test.go
generated
vendored
417
Godeps/_workspace/src/github.com/blang/semver/semver_test.go
generated
vendored
|
@ -1,417 +0,0 @@
|
||||||
package semver
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func prstr(s string) PRVersion {
|
|
||||||
return PRVersion{s, 0, false}
|
|
||||||
}
|
|
||||||
|
|
||||||
func prnum(i uint64) PRVersion {
|
|
||||||
return PRVersion{"", i, true}
|
|
||||||
}
|
|
||||||
|
|
||||||
type formatTest struct {
|
|
||||||
v Version
|
|
||||||
result string
|
|
||||||
}
|
|
||||||
|
|
||||||
var formatTests = []formatTest{
|
|
||||||
{Version{1, 2, 3, nil, nil}, "1.2.3"},
|
|
||||||
{Version{0, 0, 1, nil, nil}, "0.0.1"},
|
|
||||||
{Version{0, 0, 1, []PRVersion{prstr("alpha"), prstr("preview")}, []string{"123", "456"}}, "0.0.1-alpha.preview+123.456"},
|
|
||||||
{Version{1, 2, 3, []PRVersion{prstr("alpha"), prnum(1)}, []string{"123", "456"}}, "1.2.3-alpha.1+123.456"},
|
|
||||||
{Version{1, 2, 3, []PRVersion{prstr("alpha"), prnum(1)}, nil}, "1.2.3-alpha.1"},
|
|
||||||
{Version{1, 2, 3, nil, []string{"123", "456"}}, "1.2.3+123.456"},
|
|
||||||
// Prereleases and build metadata hyphens
|
|
||||||
{Version{1, 2, 3, []PRVersion{prstr("alpha"), prstr("b-eta")}, []string{"123", "b-uild"}}, "1.2.3-alpha.b-eta+123.b-uild"},
|
|
||||||
{Version{1, 2, 3, nil, []string{"123", "b-uild"}}, "1.2.3+123.b-uild"},
|
|
||||||
{Version{1, 2, 3, []PRVersion{prstr("alpha"), prstr("b-eta")}, nil}, "1.2.3-alpha.b-eta"},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestStringer(t *testing.T) {
|
|
||||||
for _, test := range formatTests {
|
|
||||||
if res := test.v.String(); res != test.result {
|
|
||||||
t.Errorf("Stringer, expected %q but got %q", test.result, res)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParse(t *testing.T) {
|
|
||||||
for _, test := range formatTests {
|
|
||||||
if v, err := Parse(test.result); err != nil {
|
|
||||||
t.Errorf("Error parsing %q: %q", test.result, err)
|
|
||||||
} else if comp := v.Compare(test.v); comp != 0 {
|
|
||||||
t.Errorf("Parsing, expected %q but got %q, comp: %d ", test.v, v, comp)
|
|
||||||
} else if err := v.Validate(); err != nil {
|
|
||||||
t.Errorf("Error validating parsed version %q: %q", test.v, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMustParse(t *testing.T) {
|
|
||||||
_ = MustParse("32.2.1-alpha")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMustParse_panic(t *testing.T) {
|
|
||||||
defer func() {
|
|
||||||
if recover() == nil {
|
|
||||||
t.Errorf("Should have panicked")
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
_ = MustParse("invalid version")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestValidate(t *testing.T) {
|
|
||||||
for _, test := range formatTests {
|
|
||||||
if err := test.v.Validate(); err != nil {
|
|
||||||
t.Errorf("Error validating %q: %q", test.v, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type compareTest struct {
|
|
||||||
v1 Version
|
|
||||||
v2 Version
|
|
||||||
result int
|
|
||||||
}
|
|
||||||
|
|
||||||
var compareTests = []compareTest{
|
|
||||||
{Version{1, 0, 0, nil, nil}, Version{1, 0, 0, nil, nil}, 0},
|
|
||||||
{Version{2, 0, 0, nil, nil}, Version{1, 0, 0, nil, nil}, 1},
|
|
||||||
{Version{0, 1, 0, nil, nil}, Version{0, 1, 0, nil, nil}, 0},
|
|
||||||
{Version{0, 2, 0, nil, nil}, Version{0, 1, 0, nil, nil}, 1},
|
|
||||||
{Version{0, 0, 1, nil, nil}, Version{0, 0, 1, nil, nil}, 0},
|
|
||||||
{Version{0, 0, 2, nil, nil}, Version{0, 0, 1, nil, nil}, 1},
|
|
||||||
{Version{1, 2, 3, nil, nil}, Version{1, 2, 3, nil, nil}, 0},
|
|
||||||
{Version{2, 2, 4, nil, nil}, Version{1, 2, 4, nil, nil}, 1},
|
|
||||||
{Version{1, 3, 3, nil, nil}, Version{1, 2, 3, nil, nil}, 1},
|
|
||||||
{Version{1, 2, 4, nil, nil}, Version{1, 2, 3, nil, nil}, 1},
|
|
||||||
|
|
||||||
// Spec Examples #11
|
|
||||||
{Version{1, 0, 0, nil, nil}, Version{2, 0, 0, nil, nil}, -1},
|
|
||||||
{Version{2, 0, 0, nil, nil}, Version{2, 1, 0, nil, nil}, -1},
|
|
||||||
{Version{2, 1, 0, nil, nil}, Version{2, 1, 1, nil, nil}, -1},
|
|
||||||
|
|
||||||
// Spec Examples #9
|
|
||||||
{Version{1, 0, 0, nil, nil}, Version{1, 0, 0, []PRVersion{prstr("alpha")}, nil}, 1},
|
|
||||||
{Version{1, 0, 0, []PRVersion{prstr("alpha")}, nil}, Version{1, 0, 0, []PRVersion{prstr("alpha"), prnum(1)}, nil}, -1},
|
|
||||||
{Version{1, 0, 0, []PRVersion{prstr("alpha"), prnum(1)}, nil}, Version{1, 0, 0, []PRVersion{prstr("alpha"), prstr("beta")}, nil}, -1},
|
|
||||||
{Version{1, 0, 0, []PRVersion{prstr("alpha"), prstr("beta")}, nil}, Version{1, 0, 0, []PRVersion{prstr("beta")}, nil}, -1},
|
|
||||||
{Version{1, 0, 0, []PRVersion{prstr("beta")}, nil}, Version{1, 0, 0, []PRVersion{prstr("beta"), prnum(2)}, nil}, -1},
|
|
||||||
{Version{1, 0, 0, []PRVersion{prstr("beta"), prnum(2)}, nil}, Version{1, 0, 0, []PRVersion{prstr("beta"), prnum(11)}, nil}, -1},
|
|
||||||
{Version{1, 0, 0, []PRVersion{prstr("beta"), prnum(11)}, nil}, Version{1, 0, 0, []PRVersion{prstr("rc"), prnum(1)}, nil}, -1},
|
|
||||||
{Version{1, 0, 0, []PRVersion{prstr("rc"), prnum(1)}, nil}, Version{1, 0, 0, nil, nil}, -1},
|
|
||||||
|
|
||||||
// Ignore Build metadata
|
|
||||||
{Version{1, 0, 0, nil, []string{"1", "2", "3"}}, Version{1, 0, 0, nil, nil}, 0},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCompare(t *testing.T) {
|
|
||||||
for _, test := range compareTests {
|
|
||||||
if res := test.v1.Compare(test.v2); res != test.result {
|
|
||||||
t.Errorf("Comparing %q : %q, expected %d but got %d", test.v1, test.v2, test.result, res)
|
|
||||||
}
|
|
||||||
//Test counterpart
|
|
||||||
if res := test.v2.Compare(test.v1); res != -test.result {
|
|
||||||
t.Errorf("Comparing %q : %q, expected %d but got %d", test.v2, test.v1, -test.result, res)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type wrongformatTest struct {
|
|
||||||
v *Version
|
|
||||||
str string
|
|
||||||
}
|
|
||||||
|
|
||||||
var wrongformatTests = []wrongformatTest{
|
|
||||||
{nil, ""},
|
|
||||||
{nil, "."},
|
|
||||||
{nil, "1."},
|
|
||||||
{nil, ".1"},
|
|
||||||
{nil, "a.b.c"},
|
|
||||||
{nil, "1.a.b"},
|
|
||||||
{nil, "1.1.a"},
|
|
||||||
{nil, "1.a.1"},
|
|
||||||
{nil, "a.1.1"},
|
|
||||||
{nil, ".."},
|
|
||||||
{nil, "1.."},
|
|
||||||
{nil, "1.1."},
|
|
||||||
{nil, "1..1"},
|
|
||||||
{nil, "1.1.+123"},
|
|
||||||
{nil, "1.1.-beta"},
|
|
||||||
{nil, "-1.1.1"},
|
|
||||||
{nil, "1.-1.1"},
|
|
||||||
{nil, "1.1.-1"},
|
|
||||||
// giant numbers
|
|
||||||
{nil, "20000000000000000000.1.1"},
|
|
||||||
{nil, "1.20000000000000000000.1"},
|
|
||||||
{nil, "1.1.20000000000000000000"},
|
|
||||||
{nil, "1.1.1-20000000000000000000"},
|
|
||||||
// Leading zeroes
|
|
||||||
{nil, "01.1.1"},
|
|
||||||
{nil, "001.1.1"},
|
|
||||||
{nil, "1.01.1"},
|
|
||||||
{nil, "1.001.1"},
|
|
||||||
{nil, "1.1.01"},
|
|
||||||
{nil, "1.1.001"},
|
|
||||||
{nil, "1.1.1-01"},
|
|
||||||
{nil, "1.1.1-001"},
|
|
||||||
{nil, "1.1.1-beta.01"},
|
|
||||||
{nil, "1.1.1-beta.001"},
|
|
||||||
{&Version{0, 0, 0, []PRVersion{prstr("!")}, nil}, "0.0.0-!"},
|
|
||||||
{&Version{0, 0, 0, nil, []string{"!"}}, "0.0.0+!"},
|
|
||||||
// empty prversion
|
|
||||||
{&Version{0, 0, 0, []PRVersion{prstr(""), prstr("alpha")}, nil}, "0.0.0-.alpha"},
|
|
||||||
// empty build meta data
|
|
||||||
{&Version{0, 0, 0, []PRVersion{prstr("alpha")}, []string{""}}, "0.0.0-alpha+"},
|
|
||||||
{&Version{0, 0, 0, []PRVersion{prstr("alpha")}, []string{"test", ""}}, "0.0.0-alpha+test."},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWrongFormat(t *testing.T) {
|
|
||||||
for _, test := range wrongformatTests {
|
|
||||||
|
|
||||||
if res, err := Parse(test.str); err == nil {
|
|
||||||
t.Errorf("Parsing wrong format version %q, expected error but got %q", test.str, res)
|
|
||||||
}
|
|
||||||
|
|
||||||
if test.v != nil {
|
|
||||||
if err := test.v.Validate(); err == nil {
|
|
||||||
t.Errorf("Validating wrong format version %q (%q), expected error", test.v, test.str)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCompareHelper(t *testing.T) {
|
|
||||||
v := Version{1, 0, 0, []PRVersion{prstr("alpha")}, nil}
|
|
||||||
v1 := Version{1, 0, 0, nil, nil}
|
|
||||||
if !v.EQ(v) {
|
|
||||||
t.Errorf("%q should be equal to %q", v, v)
|
|
||||||
}
|
|
||||||
if !v.Equals(v) {
|
|
||||||
t.Errorf("%q should be equal to %q", v, v)
|
|
||||||
}
|
|
||||||
if !v1.NE(v) {
|
|
||||||
t.Errorf("%q should not be equal to %q", v1, v)
|
|
||||||
}
|
|
||||||
if !v.GTE(v) {
|
|
||||||
t.Errorf("%q should be greater than or equal to %q", v, v)
|
|
||||||
}
|
|
||||||
if !v.LTE(v) {
|
|
||||||
t.Errorf("%q should be less than or equal to %q", v, v)
|
|
||||||
}
|
|
||||||
if !v.LT(v1) {
|
|
||||||
t.Errorf("%q should be less than %q", v, v1)
|
|
||||||
}
|
|
||||||
if !v.LTE(v1) {
|
|
||||||
t.Errorf("%q should be less than or equal %q", v, v1)
|
|
||||||
}
|
|
||||||
if !v.LE(v1) {
|
|
||||||
t.Errorf("%q should be less than or equal %q", v, v1)
|
|
||||||
}
|
|
||||||
if !v1.GT(v) {
|
|
||||||
t.Errorf("%q should be greater than %q", v1, v)
|
|
||||||
}
|
|
||||||
if !v1.GTE(v) {
|
|
||||||
t.Errorf("%q should be greater than or equal %q", v1, v)
|
|
||||||
}
|
|
||||||
if !v1.GE(v) {
|
|
||||||
t.Errorf("%q should be greater than or equal %q", v1, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPreReleaseVersions(t *testing.T) {
|
|
||||||
p1, err := NewPRVersion("123")
|
|
||||||
if !p1.IsNumeric() {
|
|
||||||
t.Errorf("Expected numeric prversion, got %q", p1)
|
|
||||||
}
|
|
||||||
if p1.VersionNum != 123 {
|
|
||||||
t.Error("Wrong prversion number")
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Not expected error %q", err)
|
|
||||||
}
|
|
||||||
p2, err := NewPRVersion("alpha")
|
|
||||||
if p2.IsNumeric() {
|
|
||||||
t.Errorf("Expected non-numeric prversion, got %q", p2)
|
|
||||||
}
|
|
||||||
if p2.VersionStr != "alpha" {
|
|
||||||
t.Error("Wrong prversion string")
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Not expected error %q", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBuildMetaDataVersions(t *testing.T) {
|
|
||||||
_, err := NewBuildVersion("123")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error %q", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = NewBuildVersion("build")
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error %q", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = NewBuildVersion("test?")
|
|
||||||
if err == nil {
|
|
||||||
t.Error("Expected error, got none")
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = NewBuildVersion("")
|
|
||||||
if err == nil {
|
|
||||||
t.Error("Expected error, got none")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewHelper(t *testing.T) {
|
|
||||||
v, err := New("1.2.3")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Unexpected error %q", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns pointer
|
|
||||||
if v == nil {
|
|
||||||
t.Fatal("Version is nil")
|
|
||||||
}
|
|
||||||
if v.Compare(Version{1, 2, 3, nil, nil}) != 0 {
|
|
||||||
t.Fatal("Unexpected comparison problem")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMakeHelper(t *testing.T) {
|
|
||||||
v, err := Make("1.2.3")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Unexpected error %q", err)
|
|
||||||
}
|
|
||||||
if v.Compare(Version{1, 2, 3, nil, nil}) != 0 {
|
|
||||||
t.Fatal("Unexpected comparison problem")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkParseSimple(b *testing.B) {
|
|
||||||
const VERSION = "0.0.1"
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
Parse(VERSION)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkParseComplex(b *testing.B) {
|
|
||||||
const VERSION = "0.0.1-alpha.preview+123.456"
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
Parse(VERSION)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkParseAverage(b *testing.B) {
|
|
||||||
l := len(formatTests)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
Parse(formatTests[n%l].result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkStringSimple(b *testing.B) {
|
|
||||||
const VERSION = "0.0.1"
|
|
||||||
v, _ := Parse(VERSION)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
v.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkStringLarger(b *testing.B) {
|
|
||||||
const VERSION = "11.15.2012"
|
|
||||||
v, _ := Parse(VERSION)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
v.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkStringComplex(b *testing.B) {
|
|
||||||
const VERSION = "0.0.1-alpha.preview+123.456"
|
|
||||||
v, _ := Parse(VERSION)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
v.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkStringAverage(b *testing.B) {
|
|
||||||
l := len(formatTests)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
formatTests[n%l].v.String()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkValidateSimple(b *testing.B) {
|
|
||||||
const VERSION = "0.0.1"
|
|
||||||
v, _ := Parse(VERSION)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
v.Validate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkValidateComplex(b *testing.B) {
|
|
||||||
const VERSION = "0.0.1-alpha.preview+123.456"
|
|
||||||
v, _ := Parse(VERSION)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
v.Validate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkValidateAverage(b *testing.B) {
|
|
||||||
l := len(formatTests)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
formatTests[n%l].v.Validate()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkCompareSimple(b *testing.B) {
|
|
||||||
const VERSION = "0.0.1"
|
|
||||||
v, _ := Parse(VERSION)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
v.Compare(v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkCompareComplex(b *testing.B) {
|
|
||||||
const VERSION = "0.0.1-alpha.preview+123.456"
|
|
||||||
v, _ := Parse(VERSION)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
v.Compare(v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkCompareAverage(b *testing.B) {
|
|
||||||
l := len(compareTests)
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
compareTests[n%l].v1.Compare((compareTests[n%l].v2))
|
|
||||||
}
|
|
||||||
}
|
|
30
Godeps/_workspace/src/github.com/blang/semver/sort_test.go
generated
vendored
30
Godeps/_workspace/src/github.com/blang/semver/sort_test.go
generated
vendored
|
@ -1,30 +0,0 @@
|
||||||
package semver
|
|
||||||
|
|
||||||
import (
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSort(t *testing.T) {
|
|
||||||
v100, _ := Parse("1.0.0")
|
|
||||||
v010, _ := Parse("0.1.0")
|
|
||||||
v001, _ := Parse("0.0.1")
|
|
||||||
versions := []Version{v010, v100, v001}
|
|
||||||
Sort(versions)
|
|
||||||
|
|
||||||
correct := []Version{v001, v010, v100}
|
|
||||||
if !reflect.DeepEqual(versions, correct) {
|
|
||||||
t.Fatalf("Sort returned wrong order: %s", versions)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkSort(b *testing.B) {
|
|
||||||
v100, _ := Parse("1.0.0")
|
|
||||||
v010, _ := Parse("0.1.0")
|
|
||||||
v001, _ := Parse("0.0.1")
|
|
||||||
b.ReportAllocs()
|
|
||||||
b.ResetTimer()
|
|
||||||
for n := 0; n < b.N; n++ {
|
|
||||||
Sort([]Version{v010, v100, v001})
|
|
||||||
}
|
|
||||||
}
|
|
38
Godeps/_workspace/src/github.com/blang/semver/sql_test.go
generated
vendored
38
Godeps/_workspace/src/github.com/blang/semver/sql_test.go
generated
vendored
|
@ -1,38 +0,0 @@
|
||||||
package semver
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
type scanTest struct {
|
|
||||||
val interface{}
|
|
||||||
shouldError bool
|
|
||||||
expected string
|
|
||||||
}
|
|
||||||
|
|
||||||
var scanTests = []scanTest{
|
|
||||||
{"1.2.3", false, "1.2.3"},
|
|
||||||
{[]byte("1.2.3"), false, "1.2.3"},
|
|
||||||
{7, true, ""},
|
|
||||||
{7e4, true, ""},
|
|
||||||
{true, true, ""},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestScanString(t *testing.T) {
|
|
||||||
for _, tc := range scanTests {
|
|
||||||
s := &Version{}
|
|
||||||
err := s.Scan(tc.val)
|
|
||||||
if tc.shouldError {
|
|
||||||
if err == nil {
|
|
||||||
t.Fatalf("Scan did not return an error on %v (%T)", tc.val, tc.val)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Scan returned an unexpected error: %s (%T) on %v (%T)", tc.val, tc.val, tc.val, tc.val)
|
|
||||||
}
|
|
||||||
if val, _ := s.Value(); val != tc.expected {
|
|
||||||
t.Errorf("Wrong Value returned, expected %q, got %q", tc.expected, val)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
21
Godeps/_workspace/src/github.com/cpuguy83/go-md2man/LICENSE.md
generated
vendored
Normal file
21
Godeps/_workspace/src/github.com/cpuguy83/go-md2man/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 Brian Goff
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
13
Godeps/_workspace/src/github.com/davecgh/go-spew/LICENSE
generated
vendored
Normal file
13
Godeps/_workspace/src/github.com/davecgh/go-spew/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
Copyright (c) 2012-2013 Dave Collins <dave@davec.name>
|
||||||
|
|
||||||
|
Permission to use, copy, modify, and distribute this software for any
|
||||||
|
purpose with or without fee is hereby granted, provided that the above
|
||||||
|
copyright notice and this permission notice appear in all copies.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
298
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/common_test.go
generated
vendored
298
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/common_test.go
generated
vendored
|
@ -1,298 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Dave Collins <dave@davec.name>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package spew_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
)
|
|
||||||
|
|
||||||
// custom type to test Stinger interface on non-pointer receiver.
|
|
||||||
type stringer string
|
|
||||||
|
|
||||||
// String implements the Stringer interface for testing invocation of custom
|
|
||||||
// stringers on types with non-pointer receivers.
|
|
||||||
func (s stringer) String() string {
|
|
||||||
return "stringer " + string(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// custom type to test Stinger interface on pointer receiver.
|
|
||||||
type pstringer string
|
|
||||||
|
|
||||||
// String implements the Stringer interface for testing invocation of custom
|
|
||||||
// stringers on types with only pointer receivers.
|
|
||||||
func (s *pstringer) String() string {
|
|
||||||
return "stringer " + string(*s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// xref1 and xref2 are cross referencing structs for testing circular reference
|
|
||||||
// detection.
|
|
||||||
type xref1 struct {
|
|
||||||
ps2 *xref2
|
|
||||||
}
|
|
||||||
type xref2 struct {
|
|
||||||
ps1 *xref1
|
|
||||||
}
|
|
||||||
|
|
||||||
// indirCir1, indirCir2, and indirCir3 are used to generate an indirect circular
|
|
||||||
// reference for testing detection.
|
|
||||||
type indirCir1 struct {
|
|
||||||
ps2 *indirCir2
|
|
||||||
}
|
|
||||||
type indirCir2 struct {
|
|
||||||
ps3 *indirCir3
|
|
||||||
}
|
|
||||||
type indirCir3 struct {
|
|
||||||
ps1 *indirCir1
|
|
||||||
}
|
|
||||||
|
|
||||||
// embed is used to test embedded structures.
|
|
||||||
type embed struct {
|
|
||||||
a string
|
|
||||||
}
|
|
||||||
|
|
||||||
// embedwrap is used to test embedded structures.
|
|
||||||
type embedwrap struct {
|
|
||||||
*embed
|
|
||||||
e *embed
|
|
||||||
}
|
|
||||||
|
|
||||||
// panicer is used to intentionally cause a panic for testing spew properly
|
|
||||||
// handles them
|
|
||||||
type panicer int
|
|
||||||
|
|
||||||
func (p panicer) String() string {
|
|
||||||
panic("test panic")
|
|
||||||
}
|
|
||||||
|
|
||||||
// customError is used to test custom error interface invocation.
|
|
||||||
type customError int
|
|
||||||
|
|
||||||
func (e customError) Error() string {
|
|
||||||
return fmt.Sprintf("error: %d", int(e))
|
|
||||||
}
|
|
||||||
|
|
||||||
// stringizeWants converts a slice of wanted test output into a format suitable
|
|
||||||
// for a test error message.
|
|
||||||
func stringizeWants(wants []string) string {
|
|
||||||
s := ""
|
|
||||||
for i, want := range wants {
|
|
||||||
if i > 0 {
|
|
||||||
s += fmt.Sprintf("want%d: %s", i+1, want)
|
|
||||||
} else {
|
|
||||||
s += "want: " + want
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
// testFailed returns whether or not a test failed by checking if the result
|
|
||||||
// of the test is in the slice of wanted strings.
|
|
||||||
func testFailed(result string, wants []string) bool {
|
|
||||||
for _, want := range wants {
|
|
||||||
if result == want {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
type sortableStruct struct {
|
|
||||||
x int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ss sortableStruct) String() string {
|
|
||||||
return fmt.Sprintf("ss.%d", ss.x)
|
|
||||||
}
|
|
||||||
|
|
||||||
type unsortableStruct struct {
|
|
||||||
x int
|
|
||||||
}
|
|
||||||
|
|
||||||
type sortTestCase struct {
|
|
||||||
input []reflect.Value
|
|
||||||
expected []reflect.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) {
|
|
||||||
getInterfaces := func(values []reflect.Value) []interface{} {
|
|
||||||
interfaces := []interface{}{}
|
|
||||||
for _, v := range values {
|
|
||||||
interfaces = append(interfaces, v.Interface())
|
|
||||||
}
|
|
||||||
return interfaces
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
spew.SortValues(test.input, cs)
|
|
||||||
// reflect.DeepEqual cannot really make sense of reflect.Value,
|
|
||||||
// probably because of all the pointer tricks. For instance,
|
|
||||||
// v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{}
|
|
||||||
// instead.
|
|
||||||
input := getInterfaces(test.input)
|
|
||||||
expected := getInterfaces(test.expected)
|
|
||||||
if !reflect.DeepEqual(input, expected) {
|
|
||||||
t.Errorf("Sort mismatch:\n %v != %v", input, expected)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestSortValues ensures the sort functionality for relect.Value based sorting
|
|
||||||
// works as intended.
|
|
||||||
func TestSortValues(t *testing.T) {
|
|
||||||
v := reflect.ValueOf
|
|
||||||
|
|
||||||
a := v("a")
|
|
||||||
b := v("b")
|
|
||||||
c := v("c")
|
|
||||||
embedA := v(embed{"a"})
|
|
||||||
embedB := v(embed{"b"})
|
|
||||||
embedC := v(embed{"c"})
|
|
||||||
tests := []sortTestCase{
|
|
||||||
// No values.
|
|
||||||
{
|
|
||||||
[]reflect.Value{},
|
|
||||||
[]reflect.Value{},
|
|
||||||
},
|
|
||||||
// Bools.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(false), v(true), v(false)},
|
|
||||||
[]reflect.Value{v(false), v(false), v(true)},
|
|
||||||
},
|
|
||||||
// Ints.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(2), v(1), v(3)},
|
|
||||||
[]reflect.Value{v(1), v(2), v(3)},
|
|
||||||
},
|
|
||||||
// Uints.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))},
|
|
||||||
[]reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))},
|
|
||||||
},
|
|
||||||
// Floats.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(2.0), v(1.0), v(3.0)},
|
|
||||||
[]reflect.Value{v(1.0), v(2.0), v(3.0)},
|
|
||||||
},
|
|
||||||
// Strings.
|
|
||||||
{
|
|
||||||
[]reflect.Value{b, a, c},
|
|
||||||
[]reflect.Value{a, b, c},
|
|
||||||
},
|
|
||||||
// Array
|
|
||||||
{
|
|
||||||
[]reflect.Value{v([3]int{3, 2, 1}), v([3]int{1, 3, 2}), v([3]int{1, 2, 3})},
|
|
||||||
[]reflect.Value{v([3]int{1, 2, 3}), v([3]int{1, 3, 2}), v([3]int{3, 2, 1})},
|
|
||||||
},
|
|
||||||
// Uintptrs.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))},
|
|
||||||
[]reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))},
|
|
||||||
},
|
|
||||||
// SortableStructs.
|
|
||||||
{
|
|
||||||
// Note: not sorted - DisableMethods is set.
|
|
||||||
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
|
|
||||||
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
|
|
||||||
},
|
|
||||||
// UnsortableStructs.
|
|
||||||
{
|
|
||||||
// Note: not sorted - SpewKeys is false.
|
|
||||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
|
||||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
|
||||||
},
|
|
||||||
// Invalid.
|
|
||||||
{
|
|
||||||
[]reflect.Value{embedB, embedA, embedC},
|
|
||||||
[]reflect.Value{embedB, embedA, embedC},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
cs := spew.ConfigState{DisableMethods: true, SpewKeys: false}
|
|
||||||
helpTestSortValues(tests, &cs, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestSortValuesWithMethods ensures the sort functionality for relect.Value
|
|
||||||
// based sorting works as intended when using string methods.
|
|
||||||
func TestSortValuesWithMethods(t *testing.T) {
|
|
||||||
v := reflect.ValueOf
|
|
||||||
|
|
||||||
a := v("a")
|
|
||||||
b := v("b")
|
|
||||||
c := v("c")
|
|
||||||
tests := []sortTestCase{
|
|
||||||
// Ints.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(2), v(1), v(3)},
|
|
||||||
[]reflect.Value{v(1), v(2), v(3)},
|
|
||||||
},
|
|
||||||
// Strings.
|
|
||||||
{
|
|
||||||
[]reflect.Value{b, a, c},
|
|
||||||
[]reflect.Value{a, b, c},
|
|
||||||
},
|
|
||||||
// SortableStructs.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
|
|
||||||
[]reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
|
|
||||||
},
|
|
||||||
// UnsortableStructs.
|
|
||||||
{
|
|
||||||
// Note: not sorted - SpewKeys is false.
|
|
||||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
|
||||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
cs := spew.ConfigState{DisableMethods: false, SpewKeys: false}
|
|
||||||
helpTestSortValues(tests, &cs, t)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestSortValuesWithSpew ensures the sort functionality for relect.Value
|
|
||||||
// based sorting works as intended when using spew to stringify keys.
|
|
||||||
func TestSortValuesWithSpew(t *testing.T) {
|
|
||||||
v := reflect.ValueOf
|
|
||||||
|
|
||||||
a := v("a")
|
|
||||||
b := v("b")
|
|
||||||
c := v("c")
|
|
||||||
tests := []sortTestCase{
|
|
||||||
// Ints.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(2), v(1), v(3)},
|
|
||||||
[]reflect.Value{v(1), v(2), v(3)},
|
|
||||||
},
|
|
||||||
// Strings.
|
|
||||||
{
|
|
||||||
[]reflect.Value{b, a, c},
|
|
||||||
[]reflect.Value{a, b, c},
|
|
||||||
},
|
|
||||||
// SortableStructs.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
|
|
||||||
[]reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
|
|
||||||
},
|
|
||||||
// UnsortableStructs.
|
|
||||||
{
|
|
||||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
|
||||||
[]reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
cs := spew.ConfigState{DisableMethods: true, SpewKeys: true}
|
|
||||||
helpTestSortValues(tests, &cs, t)
|
|
||||||
}
|
|
1021
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump_test.go
generated
vendored
1021
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump_test.go
generated
vendored
File diff suppressed because it is too large
Load diff
97
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dumpcgo_test.go
generated
vendored
97
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dumpcgo_test.go
generated
vendored
|
@ -1,97 +0,0 @@
|
||||||
// Copyright (c) 2013 Dave Collins <dave@davec.name>
|
|
||||||
//
|
|
||||||
// Permission to use, copy, modify, and distribute this software for any
|
|
||||||
// purpose with or without fee is hereby granted, provided that the above
|
|
||||||
// copyright notice and this permission notice appear in all copies.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
// NOTE: Due to the following build constraints, this file will only be compiled
|
|
||||||
// when both cgo is supported and "-tags testcgo" is added to the go test
|
|
||||||
// command line. This means the cgo tests are only added (and hence run) when
|
|
||||||
// specifially requested. This configuration is used because spew itself
|
|
||||||
// does not require cgo to run even though it does handle certain cgo types
|
|
||||||
// specially. Rather than forcing all clients to require cgo and an external
|
|
||||||
// C compiler just to run the tests, this scheme makes them optional.
|
|
||||||
// +build cgo,testcgo
|
|
||||||
|
|
||||||
package spew_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/davecgh/go-spew/spew/testdata"
|
|
||||||
)
|
|
||||||
|
|
||||||
func addCgoDumpTests() {
|
|
||||||
// C char pointer.
|
|
||||||
v := testdata.GetCgoCharPointer()
|
|
||||||
nv := testdata.GetCgoNullCharPointer()
|
|
||||||
pv := &v
|
|
||||||
vcAddr := fmt.Sprintf("%p", v)
|
|
||||||
vAddr := fmt.Sprintf("%p", pv)
|
|
||||||
pvAddr := fmt.Sprintf("%p", &pv)
|
|
||||||
vt := "*testdata._Ctype_char"
|
|
||||||
vs := "116"
|
|
||||||
addDumpTest(v, "("+vt+")("+vcAddr+")("+vs+")\n")
|
|
||||||
addDumpTest(pv, "(*"+vt+")("+vAddr+"->"+vcAddr+")("+vs+")\n")
|
|
||||||
addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+"->"+vcAddr+")("+vs+")\n")
|
|
||||||
addDumpTest(nv, "("+vt+")(<nil>)\n")
|
|
||||||
|
|
||||||
// C char array.
|
|
||||||
v2, v2l, v2c := testdata.GetCgoCharArray()
|
|
||||||
v2Len := fmt.Sprintf("%d", v2l)
|
|
||||||
v2Cap := fmt.Sprintf("%d", v2c)
|
|
||||||
v2t := "[6]testdata._Ctype_char"
|
|
||||||
v2s := "(len=" + v2Len + " cap=" + v2Cap + ") " +
|
|
||||||
"{\n 00000000 74 65 73 74 32 00 " +
|
|
||||||
" |test2.|\n}"
|
|
||||||
addDumpTest(v2, "("+v2t+") "+v2s+"\n")
|
|
||||||
|
|
||||||
// C unsigned char array.
|
|
||||||
v3, v3l, v3c := testdata.GetCgoUnsignedCharArray()
|
|
||||||
v3Len := fmt.Sprintf("%d", v3l)
|
|
||||||
v3Cap := fmt.Sprintf("%d", v3c)
|
|
||||||
v3t := "[6]testdata._Ctype_unsignedchar"
|
|
||||||
v3s := "(len=" + v3Len + " cap=" + v3Cap + ") " +
|
|
||||||
"{\n 00000000 74 65 73 74 33 00 " +
|
|
||||||
" |test3.|\n}"
|
|
||||||
addDumpTest(v3, "("+v3t+") "+v3s+"\n")
|
|
||||||
|
|
||||||
// C signed char array.
|
|
||||||
v4, v4l, v4c := testdata.GetCgoSignedCharArray()
|
|
||||||
v4Len := fmt.Sprintf("%d", v4l)
|
|
||||||
v4Cap := fmt.Sprintf("%d", v4c)
|
|
||||||
v4t := "[6]testdata._Ctype_schar"
|
|
||||||
v4t2 := "testdata._Ctype_schar"
|
|
||||||
v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " +
|
|
||||||
"{\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 101,\n (" + v4t2 +
|
|
||||||
") 115,\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 52,\n (" + v4t2 +
|
|
||||||
") 0\n}"
|
|
||||||
addDumpTest(v4, "("+v4t+") "+v4s+"\n")
|
|
||||||
|
|
||||||
// C uint8_t array.
|
|
||||||
v5, v5l, v5c := testdata.GetCgoUint8tArray()
|
|
||||||
v5Len := fmt.Sprintf("%d", v5l)
|
|
||||||
v5Cap := fmt.Sprintf("%d", v5c)
|
|
||||||
v5t := "[6]testdata._Ctype_uint8_t"
|
|
||||||
v5s := "(len=" + v5Len + " cap=" + v5Cap + ") " +
|
|
||||||
"{\n 00000000 74 65 73 74 35 00 " +
|
|
||||||
" |test5.|\n}"
|
|
||||||
addDumpTest(v5, "("+v5t+") "+v5s+"\n")
|
|
||||||
|
|
||||||
// C typedefed unsigned char array.
|
|
||||||
v6, v6l, v6c := testdata.GetCgoTypdefedUnsignedCharArray()
|
|
||||||
v6Len := fmt.Sprintf("%d", v6l)
|
|
||||||
v6Cap := fmt.Sprintf("%d", v6c)
|
|
||||||
v6t := "[6]testdata._Ctype_custom_uchar_t"
|
|
||||||
v6s := "(len=" + v6Len + " cap=" + v6Cap + ") " +
|
|
||||||
"{\n 00000000 74 65 73 74 36 00 " +
|
|
||||||
" |test6.|\n}"
|
|
||||||
addDumpTest(v6, "("+v6t+") "+v6s+"\n")
|
|
||||||
}
|
|
26
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dumpnocgo_test.go
generated
vendored
26
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dumpnocgo_test.go
generated
vendored
|
@ -1,26 +0,0 @@
|
||||||
// Copyright (c) 2013 Dave Collins <dave@davec.name>
|
|
||||||
//
|
|
||||||
// Permission to use, copy, modify, and distribute this software for any
|
|
||||||
// purpose with or without fee is hereby granted, provided that the above
|
|
||||||
// copyright notice and this permission notice appear in all copies.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
// NOTE: Due to the following build constraints, this file will only be compiled
|
|
||||||
// when either cgo is not supported or "-tags testcgo" is not added to the go
|
|
||||||
// test command line. This file intentionally does not setup any cgo tests in
|
|
||||||
// this scenario.
|
|
||||||
// +build !cgo !testcgo
|
|
||||||
|
|
||||||
package spew_test
|
|
||||||
|
|
||||||
func addCgoDumpTests() {
|
|
||||||
// Don't add any tests for cgo since this file is only compiled when
|
|
||||||
// there should not be any cgo tests.
|
|
||||||
}
|
|
230
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/example_test.go
generated
vendored
230
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/example_test.go
generated
vendored
|
@ -1,230 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Dave Collins <dave@davec.name>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package spew_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Flag int
|
|
||||||
|
|
||||||
const (
|
|
||||||
flagOne Flag = iota
|
|
||||||
flagTwo
|
|
||||||
)
|
|
||||||
|
|
||||||
var flagStrings = map[Flag]string{
|
|
||||||
flagOne: "flagOne",
|
|
||||||
flagTwo: "flagTwo",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f Flag) String() string {
|
|
||||||
if s, ok := flagStrings[f]; ok {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("Unknown flag (%d)", int(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
type Bar struct {
|
|
||||||
flag Flag
|
|
||||||
data uintptr
|
|
||||||
}
|
|
||||||
|
|
||||||
type Foo struct {
|
|
||||||
unexportedField Bar
|
|
||||||
ExportedField map[interface{}]interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This example demonstrates how to use Dump to dump variables to stdout.
|
|
||||||
func ExampleDump() {
|
|
||||||
// The following package level declarations are assumed for this example:
|
|
||||||
/*
|
|
||||||
type Flag int
|
|
||||||
|
|
||||||
const (
|
|
||||||
flagOne Flag = iota
|
|
||||||
flagTwo
|
|
||||||
)
|
|
||||||
|
|
||||||
var flagStrings = map[Flag]string{
|
|
||||||
flagOne: "flagOne",
|
|
||||||
flagTwo: "flagTwo",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f Flag) String() string {
|
|
||||||
if s, ok := flagStrings[f]; ok {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("Unknown flag (%d)", int(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
type Bar struct {
|
|
||||||
flag Flag
|
|
||||||
data uintptr
|
|
||||||
}
|
|
||||||
|
|
||||||
type Foo struct {
|
|
||||||
unexportedField Bar
|
|
||||||
ExportedField map[interface{}]interface{}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Setup some sample data structures for the example.
|
|
||||||
bar := Bar{Flag(flagTwo), uintptr(0)}
|
|
||||||
s1 := Foo{bar, map[interface{}]interface{}{"one": true}}
|
|
||||||
f := Flag(5)
|
|
||||||
b := []byte{
|
|
||||||
0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
|
|
||||||
0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
|
|
||||||
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
|
|
||||||
0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
|
|
||||||
0x31, 0x32,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dump!
|
|
||||||
spew.Dump(s1, f, b)
|
|
||||||
|
|
||||||
// Output:
|
|
||||||
// (spew_test.Foo) {
|
|
||||||
// unexportedField: (spew_test.Bar) {
|
|
||||||
// flag: (spew_test.Flag) flagTwo,
|
|
||||||
// data: (uintptr) <nil>
|
|
||||||
// },
|
|
||||||
// ExportedField: (map[interface {}]interface {}) (len=1) {
|
|
||||||
// (string) (len=3) "one": (bool) true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// (spew_test.Flag) Unknown flag (5)
|
|
||||||
// ([]uint8) (len=34 cap=34) {
|
|
||||||
// 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
|
|
||||||
// 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
|
|
||||||
// 00000020 31 32 |12|
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
// This example demonstrates how to use Printf to display a variable with a
|
|
||||||
// format string and inline formatting.
|
|
||||||
func ExamplePrintf() {
|
|
||||||
// Create a double pointer to a uint 8.
|
|
||||||
ui8 := uint8(5)
|
|
||||||
pui8 := &ui8
|
|
||||||
ppui8 := &pui8
|
|
||||||
|
|
||||||
// Create a circular data type.
|
|
||||||
type circular struct {
|
|
||||||
ui8 uint8
|
|
||||||
c *circular
|
|
||||||
}
|
|
||||||
c := circular{ui8: 1}
|
|
||||||
c.c = &c
|
|
||||||
|
|
||||||
// Print!
|
|
||||||
spew.Printf("ppui8: %v\n", ppui8)
|
|
||||||
spew.Printf("circular: %v\n", c)
|
|
||||||
|
|
||||||
// Output:
|
|
||||||
// ppui8: <**>5
|
|
||||||
// circular: {1 <*>{1 <*><shown>}}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This example demonstrates how to use a ConfigState.
|
|
||||||
func ExampleConfigState() {
|
|
||||||
// Modify the indent level of the ConfigState only. The global
|
|
||||||
// configuration is not modified.
|
|
||||||
scs := spew.ConfigState{Indent: "\t"}
|
|
||||||
|
|
||||||
// Output using the ConfigState instance.
|
|
||||||
v := map[string]int{"one": 1}
|
|
||||||
scs.Printf("v: %v\n", v)
|
|
||||||
scs.Dump(v)
|
|
||||||
|
|
||||||
// Output:
|
|
||||||
// v: map[one:1]
|
|
||||||
// (map[string]int) (len=1) {
|
|
||||||
// (string) (len=3) "one": (int) 1
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// This example demonstrates how to use ConfigState.Dump to dump variables to
|
|
||||||
// stdout
|
|
||||||
func ExampleConfigState_Dump() {
|
|
||||||
// See the top-level Dump example for details on the types used in this
|
|
||||||
// example.
|
|
||||||
|
|
||||||
// Create two ConfigState instances with different indentation.
|
|
||||||
scs := spew.ConfigState{Indent: "\t"}
|
|
||||||
scs2 := spew.ConfigState{Indent: " "}
|
|
||||||
|
|
||||||
// Setup some sample data structures for the example.
|
|
||||||
bar := Bar{Flag(flagTwo), uintptr(0)}
|
|
||||||
s1 := Foo{bar, map[interface{}]interface{}{"one": true}}
|
|
||||||
|
|
||||||
// Dump using the ConfigState instances.
|
|
||||||
scs.Dump(s1)
|
|
||||||
scs2.Dump(s1)
|
|
||||||
|
|
||||||
// Output:
|
|
||||||
// (spew_test.Foo) {
|
|
||||||
// unexportedField: (spew_test.Bar) {
|
|
||||||
// flag: (spew_test.Flag) flagTwo,
|
|
||||||
// data: (uintptr) <nil>
|
|
||||||
// },
|
|
||||||
// ExportedField: (map[interface {}]interface {}) (len=1) {
|
|
||||||
// (string) (len=3) "one": (bool) true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// (spew_test.Foo) {
|
|
||||||
// unexportedField: (spew_test.Bar) {
|
|
||||||
// flag: (spew_test.Flag) flagTwo,
|
|
||||||
// data: (uintptr) <nil>
|
|
||||||
// },
|
|
||||||
// ExportedField: (map[interface {}]interface {}) (len=1) {
|
|
||||||
// (string) (len=3) "one": (bool) true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
// This example demonstrates how to use ConfigState.Printf to display a variable
|
|
||||||
// with a format string and inline formatting.
|
|
||||||
func ExampleConfigState_Printf() {
|
|
||||||
// See the top-level Dump example for details on the types used in this
|
|
||||||
// example.
|
|
||||||
|
|
||||||
// Create two ConfigState instances and modify the method handling of the
|
|
||||||
// first ConfigState only.
|
|
||||||
scs := spew.NewDefaultConfig()
|
|
||||||
scs2 := spew.NewDefaultConfig()
|
|
||||||
scs.DisableMethods = true
|
|
||||||
|
|
||||||
// Alternatively
|
|
||||||
// scs := spew.ConfigState{Indent: " ", DisableMethods: true}
|
|
||||||
// scs2 := spew.ConfigState{Indent: " "}
|
|
||||||
|
|
||||||
// This is of type Flag which implements a Stringer and has raw value 1.
|
|
||||||
f := flagTwo
|
|
||||||
|
|
||||||
// Dump using the ConfigState instances.
|
|
||||||
scs.Printf("f: %v\n", f)
|
|
||||||
scs2.Printf("f: %v\n", f)
|
|
||||||
|
|
||||||
// Output:
|
|
||||||
// f: 1
|
|
||||||
// f: flagTwo
|
|
||||||
}
|
|
1535
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/format_test.go
generated
vendored
1535
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/format_test.go
generated
vendored
File diff suppressed because it is too large
Load diff
156
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/internal_test.go
generated
vendored
156
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/internal_test.go
generated
vendored
|
@ -1,156 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Dave Collins <dave@davec.name>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
This test file is part of the spew package rather than than the spew_test
|
|
||||||
package because it needs access to internals to properly test certain cases
|
|
||||||
which are not possible via the public interface since they should never happen.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package spew
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// dummyFmtState implements a fake fmt.State to use for testing invalid
|
|
||||||
// reflect.Value handling. This is necessary because the fmt package catches
|
|
||||||
// invalid values before invoking the formatter on them.
|
|
||||||
type dummyFmtState struct {
|
|
||||||
bytes.Buffer
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dfs *dummyFmtState) Flag(f int) bool {
|
|
||||||
if f == int('+') {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dfs *dummyFmtState) Precision() (int, bool) {
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dfs *dummyFmtState) Width() (int, bool) {
|
|
||||||
return 0, false
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestInvalidReflectValue ensures the dump and formatter code handles an
|
|
||||||
// invalid reflect value properly. This needs access to internal state since it
|
|
||||||
// should never happen in real code and therefore can't be tested via the public
|
|
||||||
// API.
|
|
||||||
func TestInvalidReflectValue(t *testing.T) {
|
|
||||||
i := 1
|
|
||||||
|
|
||||||
// Dump invalid reflect value.
|
|
||||||
v := new(reflect.Value)
|
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
d := dumpState{w: buf, cs: &Config}
|
|
||||||
d.dump(*v)
|
|
||||||
s := buf.String()
|
|
||||||
want := "<invalid>"
|
|
||||||
if s != want {
|
|
||||||
t.Errorf("InvalidReflectValue #%d\n got: %s want: %s", i, s, want)
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
|
|
||||||
// Formatter invalid reflect value.
|
|
||||||
buf2 := new(dummyFmtState)
|
|
||||||
f := formatState{value: *v, cs: &Config, fs: buf2}
|
|
||||||
f.format(*v)
|
|
||||||
s = buf2.String()
|
|
||||||
want = "<invalid>"
|
|
||||||
if s != want {
|
|
||||||
t.Errorf("InvalidReflectValue #%d got: %s want: %s", i, s, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// changeKind uses unsafe to intentionally change the kind of a reflect.Value to
|
|
||||||
// the maximum kind value which does not exist. This is needed to test the
|
|
||||||
// fallback code which punts to the standard fmt library for new types that
|
|
||||||
// might get added to the language.
|
|
||||||
func changeKind(v *reflect.Value, readOnly bool) {
|
|
||||||
rvf := (*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + offsetFlag))
|
|
||||||
*rvf = *rvf | ((1<<flagKindWidth - 1) << flagKindShift)
|
|
||||||
if readOnly {
|
|
||||||
*rvf |= flagRO
|
|
||||||
} else {
|
|
||||||
*rvf &= ^uintptr(flagRO)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestAddedReflectValue tests functionaly of the dump and formatter code which
|
|
||||||
// falls back to the standard fmt library for new types that might get added to
|
|
||||||
// the language.
|
|
||||||
func TestAddedReflectValue(t *testing.T) {
|
|
||||||
i := 1
|
|
||||||
|
|
||||||
// Dump using a reflect.Value that is exported.
|
|
||||||
v := reflect.ValueOf(int8(5))
|
|
||||||
changeKind(&v, false)
|
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
d := dumpState{w: buf, cs: &Config}
|
|
||||||
d.dump(v)
|
|
||||||
s := buf.String()
|
|
||||||
want := "(int8) 5"
|
|
||||||
if s != want {
|
|
||||||
t.Errorf("TestAddedReflectValue #%d\n got: %s want: %s", i, s, want)
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
|
|
||||||
// Dump using a reflect.Value that is not exported.
|
|
||||||
changeKind(&v, true)
|
|
||||||
buf.Reset()
|
|
||||||
d.dump(v)
|
|
||||||
s = buf.String()
|
|
||||||
want = "(int8) <int8 Value>"
|
|
||||||
if s != want {
|
|
||||||
t.Errorf("TestAddedReflectValue #%d\n got: %s want: %s", i, s, want)
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
|
|
||||||
// Formatter using a reflect.Value that is exported.
|
|
||||||
changeKind(&v, false)
|
|
||||||
buf2 := new(dummyFmtState)
|
|
||||||
f := formatState{value: v, cs: &Config, fs: buf2}
|
|
||||||
f.format(v)
|
|
||||||
s = buf2.String()
|
|
||||||
want = "5"
|
|
||||||
if s != want {
|
|
||||||
t.Errorf("TestAddedReflectValue #%d got: %s want: %s", i, s, want)
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
|
|
||||||
// Formatter using a reflect.Value that is not exported.
|
|
||||||
changeKind(&v, true)
|
|
||||||
buf2.Reset()
|
|
||||||
f = formatState{value: v, cs: &Config, fs: buf2}
|
|
||||||
f.format(v)
|
|
||||||
s = buf2.String()
|
|
||||||
want = "<int8 Value>"
|
|
||||||
if s != want {
|
|
||||||
t.Errorf("TestAddedReflectValue #%d got: %s want: %s", i, s, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SortValues makes the internal sortValues function available to the test
|
|
||||||
// package.
|
|
||||||
func SortValues(values []reflect.Value, cs *ConfigState) {
|
|
||||||
sortValues(values, cs)
|
|
||||||
}
|
|
308
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/spew_test.go
generated
vendored
308
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/spew_test.go
generated
vendored
|
@ -1,308 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2013 Dave Collins <dave@davec.name>
|
|
||||||
*
|
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
|
||||||
* copyright notice and this permission notice appear in all copies.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package spew_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// spewFunc is used to identify which public function of the spew package or
|
|
||||||
// ConfigState a test applies to.
|
|
||||||
type spewFunc int
|
|
||||||
|
|
||||||
const (
|
|
||||||
fCSFdump spewFunc = iota
|
|
||||||
fCSFprint
|
|
||||||
fCSFprintf
|
|
||||||
fCSFprintln
|
|
||||||
fCSPrint
|
|
||||||
fCSPrintln
|
|
||||||
fCSSdump
|
|
||||||
fCSSprint
|
|
||||||
fCSSprintf
|
|
||||||
fCSSprintln
|
|
||||||
fCSErrorf
|
|
||||||
fCSNewFormatter
|
|
||||||
fErrorf
|
|
||||||
fFprint
|
|
||||||
fFprintln
|
|
||||||
fPrint
|
|
||||||
fPrintln
|
|
||||||
fSdump
|
|
||||||
fSprint
|
|
||||||
fSprintf
|
|
||||||
fSprintln
|
|
||||||
)
|
|
||||||
|
|
||||||
// Map of spewFunc values to names for pretty printing.
|
|
||||||
var spewFuncStrings = map[spewFunc]string{
|
|
||||||
fCSFdump: "ConfigState.Fdump",
|
|
||||||
fCSFprint: "ConfigState.Fprint",
|
|
||||||
fCSFprintf: "ConfigState.Fprintf",
|
|
||||||
fCSFprintln: "ConfigState.Fprintln",
|
|
||||||
fCSSdump: "ConfigState.Sdump",
|
|
||||||
fCSPrint: "ConfigState.Print",
|
|
||||||
fCSPrintln: "ConfigState.Println",
|
|
||||||
fCSSprint: "ConfigState.Sprint",
|
|
||||||
fCSSprintf: "ConfigState.Sprintf",
|
|
||||||
fCSSprintln: "ConfigState.Sprintln",
|
|
||||||
fCSErrorf: "ConfigState.Errorf",
|
|
||||||
fCSNewFormatter: "ConfigState.NewFormatter",
|
|
||||||
fErrorf: "spew.Errorf",
|
|
||||||
fFprint: "spew.Fprint",
|
|
||||||
fFprintln: "spew.Fprintln",
|
|
||||||
fPrint: "spew.Print",
|
|
||||||
fPrintln: "spew.Println",
|
|
||||||
fSdump: "spew.Sdump",
|
|
||||||
fSprint: "spew.Sprint",
|
|
||||||
fSprintf: "spew.Sprintf",
|
|
||||||
fSprintln: "spew.Sprintln",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f spewFunc) String() string {
|
|
||||||
if s, ok := spewFuncStrings[f]; ok {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("Unknown spewFunc (%d)", int(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
// spewTest is used to describe a test to be performed against the public
|
|
||||||
// functions of the spew package or ConfigState.
|
|
||||||
type spewTest struct {
|
|
||||||
cs *spew.ConfigState
|
|
||||||
f spewFunc
|
|
||||||
format string
|
|
||||||
in interface{}
|
|
||||||
want string
|
|
||||||
}
|
|
||||||
|
|
||||||
// spewTests houses the tests to be performed against the public functions of
|
|
||||||
// the spew package and ConfigState.
|
|
||||||
//
|
|
||||||
// These tests are only intended to ensure the public functions are exercised
|
|
||||||
// and are intentionally not exhaustive of types. The exhaustive type
|
|
||||||
// tests are handled in the dump and format tests.
|
|
||||||
var spewTests []spewTest
|
|
||||||
|
|
||||||
// redirStdout is a helper function to return the standard output from f as a
|
|
||||||
// byte slice.
|
|
||||||
func redirStdout(f func()) ([]byte, error) {
|
|
||||||
tempFile, err := ioutil.TempFile("", "ss-test")
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
fileName := tempFile.Name()
|
|
||||||
defer os.Remove(fileName) // Ignore error
|
|
||||||
|
|
||||||
origStdout := os.Stdout
|
|
||||||
os.Stdout = tempFile
|
|
||||||
f()
|
|
||||||
os.Stdout = origStdout
|
|
||||||
tempFile.Close()
|
|
||||||
|
|
||||||
return ioutil.ReadFile(fileName)
|
|
||||||
}
|
|
||||||
|
|
||||||
func initSpewTests() {
|
|
||||||
// Config states with various settings.
|
|
||||||
scsDefault := spew.NewDefaultConfig()
|
|
||||||
scsNoMethods := &spew.ConfigState{Indent: " ", DisableMethods: true}
|
|
||||||
scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true}
|
|
||||||
scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1}
|
|
||||||
scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true}
|
|
||||||
|
|
||||||
// Variables for tests on types which implement Stringer interface with and
|
|
||||||
// without a pointer receiver.
|
|
||||||
ts := stringer("test")
|
|
||||||
tps := pstringer("test")
|
|
||||||
|
|
||||||
// depthTester is used to test max depth handling for structs, array, slices
|
|
||||||
// and maps.
|
|
||||||
type depthTester struct {
|
|
||||||
ic indirCir1
|
|
||||||
arr [1]string
|
|
||||||
slice []string
|
|
||||||
m map[string]int
|
|
||||||
}
|
|
||||||
dt := depthTester{indirCir1{nil}, [1]string{"arr"}, []string{"slice"},
|
|
||||||
map[string]int{"one": 1}}
|
|
||||||
|
|
||||||
// Variable for tests on types which implement error interface.
|
|
||||||
te := customError(10)
|
|
||||||
|
|
||||||
spewTests = []spewTest{
|
|
||||||
{scsDefault, fCSFdump, "", int8(127), "(int8) 127\n"},
|
|
||||||
{scsDefault, fCSFprint, "", int16(32767), "32767"},
|
|
||||||
{scsDefault, fCSFprintf, "%v", int32(2147483647), "2147483647"},
|
|
||||||
{scsDefault, fCSFprintln, "", int(2147483647), "2147483647\n"},
|
|
||||||
{scsDefault, fCSPrint, "", int64(9223372036854775807), "9223372036854775807"},
|
|
||||||
{scsDefault, fCSPrintln, "", uint8(255), "255\n"},
|
|
||||||
{scsDefault, fCSSdump, "", uint8(64), "(uint8) 64\n"},
|
|
||||||
{scsDefault, fCSSprint, "", complex(1, 2), "(1+2i)"},
|
|
||||||
{scsDefault, fCSSprintf, "%v", complex(float32(3), 4), "(3+4i)"},
|
|
||||||
{scsDefault, fCSSprintln, "", complex(float64(5), 6), "(5+6i)\n"},
|
|
||||||
{scsDefault, fCSErrorf, "%#v", uint16(65535), "(uint16)65535"},
|
|
||||||
{scsDefault, fCSNewFormatter, "%v", uint32(4294967295), "4294967295"},
|
|
||||||
{scsDefault, fErrorf, "%v", uint64(18446744073709551615), "18446744073709551615"},
|
|
||||||
{scsDefault, fFprint, "", float32(3.14), "3.14"},
|
|
||||||
{scsDefault, fFprintln, "", float64(6.28), "6.28\n"},
|
|
||||||
{scsDefault, fPrint, "", true, "true"},
|
|
||||||
{scsDefault, fPrintln, "", false, "false\n"},
|
|
||||||
{scsDefault, fSdump, "", complex(-10, -20), "(complex128) (-10-20i)\n"},
|
|
||||||
{scsDefault, fSprint, "", complex(-1, -2), "(-1-2i)"},
|
|
||||||
{scsDefault, fSprintf, "%v", complex(float32(-3), -4), "(-3-4i)"},
|
|
||||||
{scsDefault, fSprintln, "", complex(float64(-5), -6), "(-5-6i)\n"},
|
|
||||||
{scsNoMethods, fCSFprint, "", ts, "test"},
|
|
||||||
{scsNoMethods, fCSFprint, "", &ts, "<*>test"},
|
|
||||||
{scsNoMethods, fCSFprint, "", tps, "test"},
|
|
||||||
{scsNoMethods, fCSFprint, "", &tps, "<*>test"},
|
|
||||||
{scsNoPmethods, fCSFprint, "", ts, "stringer test"},
|
|
||||||
{scsNoPmethods, fCSFprint, "", &ts, "<*>stringer test"},
|
|
||||||
{scsNoPmethods, fCSFprint, "", tps, "test"},
|
|
||||||
{scsNoPmethods, fCSFprint, "", &tps, "<*>stringer test"},
|
|
||||||
{scsMaxDepth, fCSFprint, "", dt, "{{<max>} [<max>] [<max>] map[<max>]}"},
|
|
||||||
{scsMaxDepth, fCSFdump, "", dt, "(spew_test.depthTester) {\n" +
|
|
||||||
" ic: (spew_test.indirCir1) {\n <max depth reached>\n },\n" +
|
|
||||||
" arr: ([1]string) (len=1 cap=1) {\n <max depth reached>\n },\n" +
|
|
||||||
" slice: ([]string) (len=1 cap=1) {\n <max depth reached>\n },\n" +
|
|
||||||
" m: (map[string]int) (len=1) {\n <max depth reached>\n }\n}\n"},
|
|
||||||
{scsContinue, fCSFprint, "", ts, "(stringer test) test"},
|
|
||||||
{scsContinue, fCSFdump, "", ts, "(spew_test.stringer) " +
|
|
||||||
"(len=4) (stringer test) \"test\"\n"},
|
|
||||||
{scsContinue, fCSFprint, "", te, "(error: 10) 10"},
|
|
||||||
{scsContinue, fCSFdump, "", te, "(spew_test.customError) " +
|
|
||||||
"(error: 10) 10\n"},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TestSpew executes all of the tests described by spewTests.
|
|
||||||
func TestSpew(t *testing.T) {
|
|
||||||
initSpewTests()
|
|
||||||
|
|
||||||
t.Logf("Running %d tests", len(spewTests))
|
|
||||||
for i, test := range spewTests {
|
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
switch test.f {
|
|
||||||
case fCSFdump:
|
|
||||||
test.cs.Fdump(buf, test.in)
|
|
||||||
|
|
||||||
case fCSFprint:
|
|
||||||
test.cs.Fprint(buf, test.in)
|
|
||||||
|
|
||||||
case fCSFprintf:
|
|
||||||
test.cs.Fprintf(buf, test.format, test.in)
|
|
||||||
|
|
||||||
case fCSFprintln:
|
|
||||||
test.cs.Fprintln(buf, test.in)
|
|
||||||
|
|
||||||
case fCSPrint:
|
|
||||||
b, err := redirStdout(func() { test.cs.Print(test.in) })
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%v #%d %v", test.f, i, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
buf.Write(b)
|
|
||||||
|
|
||||||
case fCSPrintln:
|
|
||||||
b, err := redirStdout(func() { test.cs.Println(test.in) })
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%v #%d %v", test.f, i, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
buf.Write(b)
|
|
||||||
|
|
||||||
case fCSSdump:
|
|
||||||
str := test.cs.Sdump(test.in)
|
|
||||||
buf.WriteString(str)
|
|
||||||
|
|
||||||
case fCSSprint:
|
|
||||||
str := test.cs.Sprint(test.in)
|
|
||||||
buf.WriteString(str)
|
|
||||||
|
|
||||||
case fCSSprintf:
|
|
||||||
str := test.cs.Sprintf(test.format, test.in)
|
|
||||||
buf.WriteString(str)
|
|
||||||
|
|
||||||
case fCSSprintln:
|
|
||||||
str := test.cs.Sprintln(test.in)
|
|
||||||
buf.WriteString(str)
|
|
||||||
|
|
||||||
case fCSErrorf:
|
|
||||||
err := test.cs.Errorf(test.format, test.in)
|
|
||||||
buf.WriteString(err.Error())
|
|
||||||
|
|
||||||
case fCSNewFormatter:
|
|
||||||
fmt.Fprintf(buf, test.format, test.cs.NewFormatter(test.in))
|
|
||||||
|
|
||||||
case fErrorf:
|
|
||||||
err := spew.Errorf(test.format, test.in)
|
|
||||||
buf.WriteString(err.Error())
|
|
||||||
|
|
||||||
case fFprint:
|
|
||||||
spew.Fprint(buf, test.in)
|
|
||||||
|
|
||||||
case fFprintln:
|
|
||||||
spew.Fprintln(buf, test.in)
|
|
||||||
|
|
||||||
case fPrint:
|
|
||||||
b, err := redirStdout(func() { spew.Print(test.in) })
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%v #%d %v", test.f, i, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
buf.Write(b)
|
|
||||||
|
|
||||||
case fPrintln:
|
|
||||||
b, err := redirStdout(func() { spew.Println(test.in) })
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%v #%d %v", test.f, i, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
buf.Write(b)
|
|
||||||
|
|
||||||
case fSdump:
|
|
||||||
str := spew.Sdump(test.in)
|
|
||||||
buf.WriteString(str)
|
|
||||||
|
|
||||||
case fSprint:
|
|
||||||
str := spew.Sprint(test.in)
|
|
||||||
buf.WriteString(str)
|
|
||||||
|
|
||||||
case fSprintf:
|
|
||||||
str := spew.Sprintf(test.format, test.in)
|
|
||||||
buf.WriteString(str)
|
|
||||||
|
|
||||||
case fSprintln:
|
|
||||||
str := spew.Sprintln(test.in)
|
|
||||||
buf.WriteString(str)
|
|
||||||
|
|
||||||
default:
|
|
||||||
t.Errorf("%v #%d unrecognized function", test.f, i)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
s := buf.String()
|
|
||||||
if test.want != s {
|
|
||||||
t.Errorf("ConfigState #%d\n got: %s want: %s", i, s, test.want)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
82
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go
generated
vendored
82
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go
generated
vendored
|
@ -1,82 +0,0 @@
|
||||||
// Copyright (c) 2013 Dave Collins <dave@davec.name>
|
|
||||||
//
|
|
||||||
// Permission to use, copy, modify, and distribute this software for any
|
|
||||||
// purpose with or without fee is hereby granted, provided that the above
|
|
||||||
// copyright notice and this permission notice appear in all copies.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
|
|
||||||
// NOTE: Due to the following build constraints, this file will only be compiled
|
|
||||||
// when both cgo is supported and "-tags testcgo" is added to the go test
|
|
||||||
// command line. This code should really only be in the dumpcgo_test.go file,
|
|
||||||
// but unfortunately Go will not allow cgo in test files, so this is a
|
|
||||||
// workaround to allow cgo types to be tested. This configuration is used
|
|
||||||
// because spew itself does not require cgo to run even though it does handle
|
|
||||||
// certain cgo types specially. Rather than forcing all clients to require cgo
|
|
||||||
// and an external C compiler just to run the tests, this scheme makes them
|
|
||||||
// optional.
|
|
||||||
// +build cgo,testcgo
|
|
||||||
|
|
||||||
package testdata
|
|
||||||
|
|
||||||
/*
|
|
||||||
#include <stdint.h>
|
|
||||||
typedef unsigned char custom_uchar_t;
|
|
||||||
|
|
||||||
char *ncp = 0;
|
|
||||||
char *cp = "test";
|
|
||||||
char ca[6] = {'t', 'e', 's', 't', '2', '\0'};
|
|
||||||
unsigned char uca[6] = {'t', 'e', 's', 't', '3', '\0'};
|
|
||||||
signed char sca[6] = {'t', 'e', 's', 't', '4', '\0'};
|
|
||||||
uint8_t ui8ta[6] = {'t', 'e', 's', 't', '5', '\0'};
|
|
||||||
custom_uchar_t tuca[6] = {'t', 'e', 's', 't', '6', '\0'};
|
|
||||||
*/
|
|
||||||
import "C"
|
|
||||||
|
|
||||||
// GetCgoNullCharPointer returns a null char pointer via cgo. This is only
|
|
||||||
// used for tests.
|
|
||||||
func GetCgoNullCharPointer() interface{} {
|
|
||||||
return C.ncp
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCgoCharPointer returns a char pointer via cgo. This is only used for
|
|
||||||
// tests.
|
|
||||||
func GetCgoCharPointer() interface{} {
|
|
||||||
return C.cp
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCgoCharArray returns a char array via cgo and the array's len and cap.
|
|
||||||
// This is only used for tests.
|
|
||||||
func GetCgoCharArray() (interface{}, int, int) {
|
|
||||||
return C.ca, len(C.ca), cap(C.ca)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCgoUnsignedCharArray returns an unsigned char array via cgo and the
|
|
||||||
// array's len and cap. This is only used for tests.
|
|
||||||
func GetCgoUnsignedCharArray() (interface{}, int, int) {
|
|
||||||
return C.uca, len(C.uca), cap(C.uca)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCgoSignedCharArray returns a signed char array via cgo and the array's len
|
|
||||||
// and cap. This is only used for tests.
|
|
||||||
func GetCgoSignedCharArray() (interface{}, int, int) {
|
|
||||||
return C.sca, len(C.sca), cap(C.sca)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCgoUint8tArray returns a uint8_t array via cgo and the array's len and
|
|
||||||
// cap. This is only used for tests.
|
|
||||||
func GetCgoUint8tArray() (interface{}, int, int) {
|
|
||||||
return C.ui8ta, len(C.ui8ta), cap(C.ui8ta)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCgoTypdefedUnsignedCharArray returns a typedefed unsigned char array via
|
|
||||||
// cgo and the array's len and cap. This is only used for tests.
|
|
||||||
func GetCgoTypdefedUnsignedCharArray() (interface{}, int, int) {
|
|
||||||
return C.tuca, len(C.tuca), cap(C.tuca)
|
|
||||||
}
|
|
191
Godeps/_workspace/src/github.com/docker/docker/LICENSE
generated
vendored
Normal file
191
Godeps/_workspace/src/github.com/docker/docker/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,191 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
https://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
Copyright 2013-2015 Docker, Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
19
Godeps/_workspace/src/github.com/docker/docker/NOTICE
generated
vendored
Normal file
19
Godeps/_workspace/src/github.com/docker/docker/NOTICE
generated
vendored
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Docker
|
||||||
|
Copyright 2012-2015 Docker, Inc.
|
||||||
|
|
||||||
|
This product includes software developed at Docker, Inc. (https://www.docker.com).
|
||||||
|
|
||||||
|
This product contains software (https://github.com/kr/pty) developed
|
||||||
|
by Keith Rarick, licensed under the MIT License.
|
||||||
|
|
||||||
|
The following is courtesy of our legal counsel:
|
||||||
|
|
||||||
|
|
||||||
|
Use and transfer of Docker may be subject to certain restrictions by the
|
||||||
|
United States and other governments.
|
||||||
|
It is your responsibility to ensure that your use and/or transfer does not
|
||||||
|
violate applicable laws.
|
||||||
|
|
||||||
|
For more information, please see https://www.bis.doc.gov
|
||||||
|
|
||||||
|
See also https://www.apache.org/dev/crypto.html and/or seek legal counsel.
|
137
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mount_test.go
generated
vendored
137
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mount_test.go
generated
vendored
|
@ -1,137 +0,0 @@
|
||||||
package mount
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestMountOptionsParsing(t *testing.T) {
|
|
||||||
options := "noatime,ro,size=10k"
|
|
||||||
|
|
||||||
flag, data := parseOptions(options)
|
|
||||||
|
|
||||||
if data != "size=10k" {
|
|
||||||
t.Fatalf("Expected size=10 got %s", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedFlag := NOATIME | RDONLY
|
|
||||||
|
|
||||||
if flag != expectedFlag {
|
|
||||||
t.Fatalf("Expected %d got %d", expectedFlag, flag)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMounted(t *testing.T) {
|
|
||||||
tmp := path.Join(os.TempDir(), "mount-tests")
|
|
||||||
if err := os.MkdirAll(tmp, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
var (
|
|
||||||
sourceDir = path.Join(tmp, "source")
|
|
||||||
targetDir = path.Join(tmp, "target")
|
|
||||||
sourcePath = path.Join(sourceDir, "file.txt")
|
|
||||||
targetPath = path.Join(targetDir, "file.txt")
|
|
||||||
)
|
|
||||||
|
|
||||||
os.Mkdir(sourceDir, 0777)
|
|
||||||
os.Mkdir(targetDir, 0777)
|
|
||||||
|
|
||||||
f, err := os.Create(sourcePath)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
f.WriteString("hello")
|
|
||||||
f.Close()
|
|
||||||
|
|
||||||
f, err = os.Create(targetPath)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
f.Close()
|
|
||||||
|
|
||||||
if err := Mount(sourceDir, targetDir, "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
mounted, err := Mounted(targetDir)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !mounted {
|
|
||||||
t.Fatalf("Expected %s to be mounted", targetDir)
|
|
||||||
}
|
|
||||||
if _, err := os.Stat(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMountReadonly(t *testing.T) {
|
|
||||||
tmp := path.Join(os.TempDir(), "mount-tests")
|
|
||||||
if err := os.MkdirAll(tmp, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
var (
|
|
||||||
sourceDir = path.Join(tmp, "source")
|
|
||||||
targetDir = path.Join(tmp, "target")
|
|
||||||
sourcePath = path.Join(sourceDir, "file.txt")
|
|
||||||
targetPath = path.Join(targetDir, "file.txt")
|
|
||||||
)
|
|
||||||
|
|
||||||
os.Mkdir(sourceDir, 0777)
|
|
||||||
os.Mkdir(targetDir, 0777)
|
|
||||||
|
|
||||||
f, err := os.Create(sourcePath)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
f.WriteString("hello")
|
|
||||||
f.Close()
|
|
||||||
|
|
||||||
f, err = os.Create(targetPath)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
f.Close()
|
|
||||||
|
|
||||||
if err := Mount(sourceDir, targetDir, "none", "bind,ro"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
f, err = os.OpenFile(targetPath, os.O_RDWR, 0777)
|
|
||||||
if err == nil {
|
|
||||||
t.Fatal("Should not be able to open a ro file as rw")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetMounts(t *testing.T) {
|
|
||||||
mounts, err := GetMounts()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
root := false
|
|
||||||
for _, entry := range mounts {
|
|
||||||
if entry.Mountpoint == "/" {
|
|
||||||
root = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !root {
|
|
||||||
t.Fatal("/ should be mounted at least")
|
|
||||||
}
|
|
||||||
}
|
|
477
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_linux_test.go
generated
vendored
477
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/mountinfo_linux_test.go
generated
vendored
|
@ -1,477 +0,0 @@
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package mount
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
fedoraMountinfo = `15 35 0:3 / /proc rw,nosuid,nodev,noexec,relatime shared:5 - proc proc rw
|
|
||||||
16 35 0:14 / /sys rw,nosuid,nodev,noexec,relatime shared:6 - sysfs sysfs rw,seclabel
|
|
||||||
17 35 0:5 / /dev rw,nosuid shared:2 - devtmpfs devtmpfs rw,seclabel,size=8056484k,nr_inodes=2014121,mode=755
|
|
||||||
18 16 0:15 / /sys/kernel/security rw,nosuid,nodev,noexec,relatime shared:7 - securityfs securityfs rw
|
|
||||||
19 16 0:13 / /sys/fs/selinux rw,relatime shared:8 - selinuxfs selinuxfs rw
|
|
||||||
20 17 0:16 / /dev/shm rw,nosuid,nodev shared:3 - tmpfs tmpfs rw,seclabel
|
|
||||||
21 17 0:10 / /dev/pts rw,nosuid,noexec,relatime shared:4 - devpts devpts rw,seclabel,gid=5,mode=620,ptmxmode=000
|
|
||||||
22 35 0:17 / /run rw,nosuid,nodev shared:21 - tmpfs tmpfs rw,seclabel,mode=755
|
|
||||||
23 16 0:18 / /sys/fs/cgroup rw,nosuid,nodev,noexec shared:9 - tmpfs tmpfs rw,seclabel,mode=755
|
|
||||||
24 23 0:19 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime shared:10 - cgroup cgroup rw,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd
|
|
||||||
25 16 0:20 / /sys/fs/pstore rw,nosuid,nodev,noexec,relatime shared:20 - pstore pstore rw
|
|
||||||
26 23 0:21 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime shared:11 - cgroup cgroup rw,cpuset,clone_children
|
|
||||||
27 23 0:22 / /sys/fs/cgroup/cpu,cpuacct rw,nosuid,nodev,noexec,relatime shared:12 - cgroup cgroup rw,cpuacct,cpu,clone_children
|
|
||||||
28 23 0:23 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime shared:13 - cgroup cgroup rw,memory,clone_children
|
|
||||||
29 23 0:24 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime shared:14 - cgroup cgroup rw,devices,clone_children
|
|
||||||
30 23 0:25 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime shared:15 - cgroup cgroup rw,freezer,clone_children
|
|
||||||
31 23 0:26 / /sys/fs/cgroup/net_cls rw,nosuid,nodev,noexec,relatime shared:16 - cgroup cgroup rw,net_cls,clone_children
|
|
||||||
32 23 0:27 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime shared:17 - cgroup cgroup rw,blkio,clone_children
|
|
||||||
33 23 0:28 / /sys/fs/cgroup/perf_event rw,nosuid,nodev,noexec,relatime shared:18 - cgroup cgroup rw,perf_event,clone_children
|
|
||||||
34 23 0:29 / /sys/fs/cgroup/hugetlb rw,nosuid,nodev,noexec,relatime shared:19 - cgroup cgroup rw,hugetlb,clone_children
|
|
||||||
35 1 253:2 / / rw,relatime shared:1 - ext4 /dev/mapper/ssd-root--f20 rw,seclabel,data=ordered
|
|
||||||
36 15 0:30 / /proc/sys/fs/binfmt_misc rw,relatime shared:22 - autofs systemd-1 rw,fd=38,pgrp=1,timeout=300,minproto=5,maxproto=5,direct
|
|
||||||
37 17 0:12 / /dev/mqueue rw,relatime shared:23 - mqueue mqueue rw,seclabel
|
|
||||||
38 35 0:31 / /tmp rw shared:24 - tmpfs tmpfs rw,seclabel
|
|
||||||
39 17 0:32 / /dev/hugepages rw,relatime shared:25 - hugetlbfs hugetlbfs rw,seclabel
|
|
||||||
40 16 0:7 / /sys/kernel/debug rw,relatime shared:26 - debugfs debugfs rw
|
|
||||||
41 16 0:33 / /sys/kernel/config rw,relatime shared:27 - configfs configfs rw
|
|
||||||
42 35 0:34 / /var/lib/nfs/rpc_pipefs rw,relatime shared:28 - rpc_pipefs sunrpc rw
|
|
||||||
43 15 0:35 / /proc/fs/nfsd rw,relatime shared:29 - nfsd sunrpc rw
|
|
||||||
45 35 8:17 / /boot rw,relatime shared:30 - ext4 /dev/sdb1 rw,seclabel,data=ordered
|
|
||||||
46 35 253:4 / /home rw,relatime shared:31 - ext4 /dev/mapper/ssd-home rw,seclabel,data=ordered
|
|
||||||
47 35 253:5 / /var/lib/libvirt/images rw,noatime,nodiratime shared:32 - ext4 /dev/mapper/ssd-virt rw,seclabel,discard,data=ordered
|
|
||||||
48 35 253:12 / /mnt/old rw,relatime shared:33 - ext4 /dev/mapper/HelpDeskRHEL6-FedoraRoot rw,seclabel,data=ordered
|
|
||||||
121 22 0:36 / /run/user/1000/gvfs rw,nosuid,nodev,relatime shared:104 - fuse.gvfsd-fuse gvfsd-fuse rw,user_id=1000,group_id=1000
|
|
||||||
124 16 0:37 / /sys/fs/fuse/connections rw,relatime shared:107 - fusectl fusectl rw
|
|
||||||
165 38 253:3 / /tmp/mnt rw,relatime shared:147 - ext4 /dev/mapper/ssd-root rw,seclabel,data=ordered
|
|
||||||
167 35 253:15 / /var/lib/docker/devicemapper/mnt/aae4076022f0e2b80a2afbf8fc6df450c52080191fcef7fb679a73e6f073e5c2 rw,relatime shared:149 - ext4 /dev/mapper/docker-253:2-425882-aae4076022f0e2b80a2afbf8fc6df450c52080191fcef7fb679a73e6f073e5c2 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
171 35 253:16 / /var/lib/docker/devicemapper/mnt/c71be651f114db95180e472f7871b74fa597ee70a58ccc35cb87139ddea15373 rw,relatime shared:153 - ext4 /dev/mapper/docker-253:2-425882-c71be651f114db95180e472f7871b74fa597ee70a58ccc35cb87139ddea15373 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
175 35 253:17 / /var/lib/docker/devicemapper/mnt/1bac6ab72862d2d5626560df6197cf12036b82e258c53d981fa29adce6f06c3c rw,relatime shared:157 - ext4 /dev/mapper/docker-253:2-425882-1bac6ab72862d2d5626560df6197cf12036b82e258c53d981fa29adce6f06c3c rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
179 35 253:18 / /var/lib/docker/devicemapper/mnt/d710a357d77158e80d5b2c55710ae07c94e76d34d21ee7bae65ce5418f739b09 rw,relatime shared:161 - ext4 /dev/mapper/docker-253:2-425882-d710a357d77158e80d5b2c55710ae07c94e76d34d21ee7bae65ce5418f739b09 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
183 35 253:19 / /var/lib/docker/devicemapper/mnt/6479f52366114d5f518db6837254baab48fab39f2ac38d5099250e9a6ceae6c7 rw,relatime shared:165 - ext4 /dev/mapper/docker-253:2-425882-6479f52366114d5f518db6837254baab48fab39f2ac38d5099250e9a6ceae6c7 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
187 35 253:20 / /var/lib/docker/devicemapper/mnt/8d9df91c4cca5aef49eeb2725292aab324646f723a7feab56be34c2ad08268e1 rw,relatime shared:169 - ext4 /dev/mapper/docker-253:2-425882-8d9df91c4cca5aef49eeb2725292aab324646f723a7feab56be34c2ad08268e1 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
191 35 253:21 / /var/lib/docker/devicemapper/mnt/c8240b768603d32e920d365dc9d1dc2a6af46cd23e7ae819947f969e1b4ec661 rw,relatime shared:173 - ext4 /dev/mapper/docker-253:2-425882-c8240b768603d32e920d365dc9d1dc2a6af46cd23e7ae819947f969e1b4ec661 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
195 35 253:22 / /var/lib/docker/devicemapper/mnt/2eb3a01278380bbf3ed12d86ac629eaa70a4351301ee307a5cabe7b5f3b1615f rw,relatime shared:177 - ext4 /dev/mapper/docker-253:2-425882-2eb3a01278380bbf3ed12d86ac629eaa70a4351301ee307a5cabe7b5f3b1615f rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
199 35 253:23 / /var/lib/docker/devicemapper/mnt/37a17fb7c9d9b80821235d5f2662879bd3483915f245f9b49cdaa0e38779b70b rw,relatime shared:181 - ext4 /dev/mapper/docker-253:2-425882-37a17fb7c9d9b80821235d5f2662879bd3483915f245f9b49cdaa0e38779b70b rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
203 35 253:24 / /var/lib/docker/devicemapper/mnt/aea459ae930bf1de913e2f29428fd80ee678a1e962d4080019d9f9774331ee2b rw,relatime shared:185 - ext4 /dev/mapper/docker-253:2-425882-aea459ae930bf1de913e2f29428fd80ee678a1e962d4080019d9f9774331ee2b rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
207 35 253:25 / /var/lib/docker/devicemapper/mnt/928ead0bc06c454bd9f269e8585aeae0a6bd697f46dc8754c2a91309bc810882 rw,relatime shared:189 - ext4 /dev/mapper/docker-253:2-425882-928ead0bc06c454bd9f269e8585aeae0a6bd697f46dc8754c2a91309bc810882 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
211 35 253:26 / /var/lib/docker/devicemapper/mnt/0f284d18481d671644706e7a7244cbcf63d590d634cc882cb8721821929d0420 rw,relatime shared:193 - ext4 /dev/mapper/docker-253:2-425882-0f284d18481d671644706e7a7244cbcf63d590d634cc882cb8721821929d0420 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
215 35 253:27 / /var/lib/docker/devicemapper/mnt/d9dd16722ab34c38db2733e23f69e8f4803ce59658250dd63e98adff95d04919 rw,relatime shared:197 - ext4 /dev/mapper/docker-253:2-425882-d9dd16722ab34c38db2733e23f69e8f4803ce59658250dd63e98adff95d04919 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
219 35 253:28 / /var/lib/docker/devicemapper/mnt/bc4500479f18c2c08c21ad5282e5f826a016a386177d9874c2764751c031d634 rw,relatime shared:201 - ext4 /dev/mapper/docker-253:2-425882-bc4500479f18c2c08c21ad5282e5f826a016a386177d9874c2764751c031d634 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
223 35 253:29 / /var/lib/docker/devicemapper/mnt/7770c8b24eb3d5cc159a065910076938910d307ab2f5d94e1dc3b24c06ee2c8a rw,relatime shared:205 - ext4 /dev/mapper/docker-253:2-425882-7770c8b24eb3d5cc159a065910076938910d307ab2f5d94e1dc3b24c06ee2c8a rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
227 35 253:30 / /var/lib/docker/devicemapper/mnt/c280cd3d0bf0aa36b478b292279671624cceafc1a67eaa920fa1082601297adf rw,relatime shared:209 - ext4 /dev/mapper/docker-253:2-425882-c280cd3d0bf0aa36b478b292279671624cceafc1a67eaa920fa1082601297adf rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
231 35 253:31 / /var/lib/docker/devicemapper/mnt/8b59a7d9340279f09fea67fd6ad89ddef711e9e7050eb647984f8b5ef006335f rw,relatime shared:213 - ext4 /dev/mapper/docker-253:2-425882-8b59a7d9340279f09fea67fd6ad89ddef711e9e7050eb647984f8b5ef006335f rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
235 35 253:32 / /var/lib/docker/devicemapper/mnt/1a28059f29eda821578b1bb27a60cc71f76f846a551abefabce6efd0146dce9f rw,relatime shared:217 - ext4 /dev/mapper/docker-253:2-425882-1a28059f29eda821578b1bb27a60cc71f76f846a551abefabce6efd0146dce9f rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
239 35 253:33 / /var/lib/docker/devicemapper/mnt/e9aa60c60128cad1 rw,relatime shared:221 - ext4 /dev/mapper/docker-253:2-425882-e9aa60c60128cad1 rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
243 35 253:34 / /var/lib/docker/devicemapper/mnt/5fec11304b6f4713fea7b6ccdcc1adc0a1966187f590fe25a8227428a8df275d-init rw,relatime shared:225 - ext4 /dev/mapper/docker-253:2-425882-5fec11304b6f4713fea7b6ccdcc1adc0a1966187f590fe25a8227428a8df275d-init rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
247 35 253:35 / /var/lib/docker/devicemapper/mnt/5fec11304b6f4713fea7b6ccdcc1adc0a1966187f590fe25a8227428a8df275d rw,relatime shared:229 - ext4 /dev/mapper/docker-253:2-425882-5fec11304b6f4713fea7b6ccdcc1adc0a1966187f590fe25a8227428a8df275d rw,seclabel,discard,stripe=16,data=ordered
|
|
||||||
31 21 0:23 / /DATA/foo_bla_bla rw,relatime - cifs //foo/BLA\040BLA\040BLA/ rw,sec=ntlm,cache=loose,unc=\\foo\BLA BLA BLA,username=my_login,domain=mydomain.com,uid=12345678,forceuid,gid=12345678,forcegid,addr=10.1.30.10,file_mode=0755,dir_mode=0755,nounix,rsize=61440,wsize=65536,actimeo=1`
|
|
||||||
|
|
||||||
ubuntuMountInfo = `15 20 0:14 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
|
|
||||||
16 20 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
|
|
||||||
17 20 0:5 / /dev rw,relatime - devtmpfs udev rw,size=1015140k,nr_inodes=253785,mode=755
|
|
||||||
18 17 0:11 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
|
|
||||||
19 20 0:15 / /run rw,nosuid,noexec,relatime - tmpfs tmpfs rw,size=205044k,mode=755
|
|
||||||
20 1 253:0 / / rw,relatime - ext4 /dev/disk/by-label/DOROOT rw,errors=remount-ro,data=ordered
|
|
||||||
21 15 0:16 / /sys/fs/cgroup rw,relatime - tmpfs none rw,size=4k,mode=755
|
|
||||||
22 15 0:17 / /sys/fs/fuse/connections rw,relatime - fusectl none rw
|
|
||||||
23 15 0:6 / /sys/kernel/debug rw,relatime - debugfs none rw
|
|
||||||
24 15 0:10 / /sys/kernel/security rw,relatime - securityfs none rw
|
|
||||||
25 19 0:18 / /run/lock rw,nosuid,nodev,noexec,relatime - tmpfs none rw,size=5120k
|
|
||||||
26 21 0:19 / /sys/fs/cgroup/cpuset rw,relatime - cgroup cgroup rw,cpuset,clone_children
|
|
||||||
27 19 0:20 / /run/shm rw,nosuid,nodev,relatime - tmpfs none rw
|
|
||||||
28 21 0:21 / /sys/fs/cgroup/cpu rw,relatime - cgroup cgroup rw,cpu
|
|
||||||
29 19 0:22 / /run/user rw,nosuid,nodev,noexec,relatime - tmpfs none rw,size=102400k,mode=755
|
|
||||||
30 15 0:23 / /sys/fs/pstore rw,relatime - pstore none rw
|
|
||||||
31 21 0:24 / /sys/fs/cgroup/cpuacct rw,relatime - cgroup cgroup rw,cpuacct
|
|
||||||
32 21 0:25 / /sys/fs/cgroup/memory rw,relatime - cgroup cgroup rw,memory
|
|
||||||
33 21 0:26 / /sys/fs/cgroup/devices rw,relatime - cgroup cgroup rw,devices
|
|
||||||
34 21 0:27 / /sys/fs/cgroup/freezer rw,relatime - cgroup cgroup rw,freezer
|
|
||||||
35 21 0:28 / /sys/fs/cgroup/blkio rw,relatime - cgroup cgroup rw,blkio
|
|
||||||
36 21 0:29 / /sys/fs/cgroup/perf_event rw,relatime - cgroup cgroup rw,perf_event
|
|
||||||
37 21 0:30 / /sys/fs/cgroup/hugetlb rw,relatime - cgroup cgroup rw,hugetlb
|
|
||||||
38 21 0:31 / /sys/fs/cgroup/systemd rw,nosuid,nodev,noexec,relatime - cgroup systemd rw,name=systemd
|
|
||||||
39 20 0:32 / /var/lib/docker/aufs/mnt/b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc rw,relatime - aufs none rw,si=caafa54fdc06525
|
|
||||||
40 20 0:33 / /var/lib/docker/aufs/mnt/2eed44ac7ce7c75af04f088ed6cb4ce9d164801e91d78c6db65d7ef6d572bba8-init rw,relatime - aufs none rw,si=caafa54f882b525
|
|
||||||
41 20 0:34 / /var/lib/docker/aufs/mnt/2eed44ac7ce7c75af04f088ed6cb4ce9d164801e91d78c6db65d7ef6d572bba8 rw,relatime - aufs none rw,si=caafa54f8829525
|
|
||||||
42 20 0:35 / /var/lib/docker/aufs/mnt/16f4d7e96dd612903f425bfe856762f291ff2e36a8ecd55a2209b7d7cd81c30b rw,relatime - aufs none rw,si=caafa54f882d525
|
|
||||||
43 20 0:36 / /var/lib/docker/aufs/mnt/63ca08b75d7438a9469a5954e003f48ffede73541f6286ce1cb4d7dd4811da7e-init rw,relatime - aufs none rw,si=caafa54f882f525
|
|
||||||
44 20 0:37 / /var/lib/docker/aufs/mnt/63ca08b75d7438a9469a5954e003f48ffede73541f6286ce1cb4d7dd4811da7e rw,relatime - aufs none rw,si=caafa54f88ba525
|
|
||||||
45 20 0:38 / /var/lib/docker/aufs/mnt/283f35a910233c756409313be71ecd8fcfef0df57108b8d740b61b3e88860452 rw,relatime - aufs none rw,si=caafa54f88b8525
|
|
||||||
46 20 0:39 / /var/lib/docker/aufs/mnt/2c6c7253d4090faa3886871fb21bd660609daeb0206588c0602007f7d0f254b1-init rw,relatime - aufs none rw,si=caafa54f88be525
|
|
||||||
47 20 0:40 / /var/lib/docker/aufs/mnt/2c6c7253d4090faa3886871fb21bd660609daeb0206588c0602007f7d0f254b1 rw,relatime - aufs none rw,si=caafa54f882c525
|
|
||||||
48 20 0:41 / /var/lib/docker/aufs/mnt/de2b538c97d6366cc80e8658547c923ea1d042f85580df379846f36a4df7049d rw,relatime - aufs none rw,si=caafa54f85bb525
|
|
||||||
49 20 0:42 / /var/lib/docker/aufs/mnt/94a3d8ed7c27e5b0aa71eba46c736bfb2742afda038e74f2dd6035fb28415b49-init rw,relatime - aufs none rw,si=caafa54fdc00525
|
|
||||||
50 20 0:43 / /var/lib/docker/aufs/mnt/94a3d8ed7c27e5b0aa71eba46c736bfb2742afda038e74f2dd6035fb28415b49 rw,relatime - aufs none rw,si=caafa54fbaec525
|
|
||||||
51 20 0:44 / /var/lib/docker/aufs/mnt/6ac1cace985c9fc9bea32234de8b36dba49bdd5e29a2972b327ff939d78a6274 rw,relatime - aufs none rw,si=caafa54f8e1a525
|
|
||||||
52 20 0:45 / /var/lib/docker/aufs/mnt/dff147033e3a0ef061e1de1ad34256b523d4a8c1fa6bba71a0ab538e8628ff0b-init rw,relatime - aufs none rw,si=caafa54f8e1d525
|
|
||||||
53 20 0:46 / /var/lib/docker/aufs/mnt/dff147033e3a0ef061e1de1ad34256b523d4a8c1fa6bba71a0ab538e8628ff0b rw,relatime - aufs none rw,si=caafa54f8e1b525
|
|
||||||
54 20 0:47 / /var/lib/docker/aufs/mnt/cabb117d997f0f93519185aea58389a9762770b7496ed0b74a3e4a083fa45902 rw,relatime - aufs none rw,si=caafa54f810a525
|
|
||||||
55 20 0:48 / /var/lib/docker/aufs/mnt/e1c8a94ffaa9d532bbbdc6ef771ce8a6c2c06757806ecaf8b68e9108fec65f33-init rw,relatime - aufs none rw,si=caafa54f8529525
|
|
||||||
56 20 0:49 / /var/lib/docker/aufs/mnt/e1c8a94ffaa9d532bbbdc6ef771ce8a6c2c06757806ecaf8b68e9108fec65f33 rw,relatime - aufs none rw,si=caafa54f852f525
|
|
||||||
57 20 0:50 / /var/lib/docker/aufs/mnt/16a1526fa445b84ce84f89506d219e87fa488a814063baf045d88b02f21166b3 rw,relatime - aufs none rw,si=caafa54f9e1d525
|
|
||||||
58 20 0:51 / /var/lib/docker/aufs/mnt/57b9c92e1e368fa7dbe5079f7462e917777829caae732828b003c355fe49da9f-init rw,relatime - aufs none rw,si=caafa54f854d525
|
|
||||||
59 20 0:52 / /var/lib/docker/aufs/mnt/57b9c92e1e368fa7dbe5079f7462e917777829caae732828b003c355fe49da9f rw,relatime - aufs none rw,si=caafa54f854e525
|
|
||||||
60 20 0:53 / /var/lib/docker/aufs/mnt/e370c3e286bea027917baa0e4d251262681a472a87056e880dfd0513516dffd9 rw,relatime - aufs none rw,si=caafa54f840a525
|
|
||||||
61 20 0:54 / /var/lib/docker/aufs/mnt/6b00d3b4f32b41997ec07412b5e18204f82fbe643e7122251cdeb3582abd424e-init rw,relatime - aufs none rw,si=caafa54f8408525
|
|
||||||
62 20 0:55 / /var/lib/docker/aufs/mnt/6b00d3b4f32b41997ec07412b5e18204f82fbe643e7122251cdeb3582abd424e rw,relatime - aufs none rw,si=caafa54f8409525
|
|
||||||
63 20 0:56 / /var/lib/docker/aufs/mnt/abd0b5ea5d355a67f911475e271924a5388ee60c27185fcd60d095afc4a09dc7 rw,relatime - aufs none rw,si=caafa54f9eb1525
|
|
||||||
64 20 0:57 / /var/lib/docker/aufs/mnt/336222effc3f7b89867bb39ff7792ae5412c35c749f127c29159d046b6feedd2-init rw,relatime - aufs none rw,si=caafa54f85bf525
|
|
||||||
65 20 0:58 / /var/lib/docker/aufs/mnt/336222effc3f7b89867bb39ff7792ae5412c35c749f127c29159d046b6feedd2 rw,relatime - aufs none rw,si=caafa54f85b8525
|
|
||||||
66 20 0:59 / /var/lib/docker/aufs/mnt/912e1bf28b80a09644503924a8a1a4fb8ed10b808ca847bda27a369919aa52fa rw,relatime - aufs none rw,si=caafa54fbaea525
|
|
||||||
67 20 0:60 / /var/lib/docker/aufs/mnt/386f722875013b4a875118367abc783fc6617a3cb7cf08b2b4dcf550b4b9c576-init rw,relatime - aufs none rw,si=caafa54f8472525
|
|
||||||
68 20 0:61 / /var/lib/docker/aufs/mnt/386f722875013b4a875118367abc783fc6617a3cb7cf08b2b4dcf550b4b9c576 rw,relatime - aufs none rw,si=caafa54f8474525
|
|
||||||
69 20 0:62 / /var/lib/docker/aufs/mnt/5aaebb79ef3097dfca377889aeb61a0c9d5e3795117d2b08d0751473c671dfb2 rw,relatime - aufs none rw,si=caafa54f8c5e525
|
|
||||||
70 20 0:63 / /var/lib/docker/aufs/mnt/5ba3e493279d01277d583600b81c7c079e691b73c3a2bdea8e4b12a35a418be2-init rw,relatime - aufs none rw,si=caafa54f8c3b525
|
|
||||||
71 20 0:64 / /var/lib/docker/aufs/mnt/5ba3e493279d01277d583600b81c7c079e691b73c3a2bdea8e4b12a35a418be2 rw,relatime - aufs none rw,si=caafa54f8c3d525
|
|
||||||
72 20 0:65 / /var/lib/docker/aufs/mnt/2777f0763da4de93f8bebbe1595cc77f739806a158657b033eca06f827b6028a rw,relatime - aufs none rw,si=caafa54f8c3e525
|
|
||||||
73 20 0:66 / /var/lib/docker/aufs/mnt/5d7445562acf73c6f0ae34c3dd0921d7457de1ba92a587d9e06a44fa209eeb3e-init rw,relatime - aufs none rw,si=caafa54f8c39525
|
|
||||||
74 20 0:67 / /var/lib/docker/aufs/mnt/5d7445562acf73c6f0ae34c3dd0921d7457de1ba92a587d9e06a44fa209eeb3e rw,relatime - aufs none rw,si=caafa54f854f525
|
|
||||||
75 20 0:68 / /var/lib/docker/aufs/mnt/06400b526ec18b66639c96efc41a84f4ae0b117cb28dafd56be420651b4084a0 rw,relatime - aufs none rw,si=caafa54f840b525
|
|
||||||
76 20 0:69 / /var/lib/docker/aufs/mnt/e051d45ec42d8e3e1cc57bb39871a40de486dc123522e9c067fbf2ca6a357785-init rw,relatime - aufs none rw,si=caafa54fdddf525
|
|
||||||
77 20 0:70 / /var/lib/docker/aufs/mnt/e051d45ec42d8e3e1cc57bb39871a40de486dc123522e9c067fbf2ca6a357785 rw,relatime - aufs none rw,si=caafa54f854b525
|
|
||||||
78 20 0:71 / /var/lib/docker/aufs/mnt/1ff414fa93fd61ec81b0ab7b365a841ff6545accae03cceac702833aaeaf718f rw,relatime - aufs none rw,si=caafa54f8d85525
|
|
||||||
79 20 0:72 / /var/lib/docker/aufs/mnt/c661b2f871dd5360e46a2aebf8f970f6d39a2ff64e06979aa0361227c88128b8-init rw,relatime - aufs none rw,si=caafa54f8da3525
|
|
||||||
80 20 0:73 / /var/lib/docker/aufs/mnt/c661b2f871dd5360e46a2aebf8f970f6d39a2ff64e06979aa0361227c88128b8 rw,relatime - aufs none rw,si=caafa54f8da2525
|
|
||||||
81 20 0:74 / /var/lib/docker/aufs/mnt/b68b1d4fe4d30016c552398e78b379a39f651661d8e1fa5f2460c24a5e723420 rw,relatime - aufs none rw,si=caafa54f8d81525
|
|
||||||
82 20 0:75 / /var/lib/docker/aufs/mnt/c5c5979c936cd0153a4c626fa9d69ce4fce7d924cc74fa68b025d2f585031739-init rw,relatime - aufs none rw,si=caafa54f8da1525
|
|
||||||
83 20 0:76 / /var/lib/docker/aufs/mnt/c5c5979c936cd0153a4c626fa9d69ce4fce7d924cc74fa68b025d2f585031739 rw,relatime - aufs none rw,si=caafa54f8da0525
|
|
||||||
84 20 0:77 / /var/lib/docker/aufs/mnt/53e10b0329afc0e0d3322d31efaed4064139dc7027fe6ae445cffd7104bcc94f rw,relatime - aufs none rw,si=caafa54f8c35525
|
|
||||||
85 20 0:78 / /var/lib/docker/aufs/mnt/3bfafd09ff2603e2165efacc2215c1f51afabba6c42d04a68cc2df0e8cc31494-init rw,relatime - aufs none rw,si=caafa54f8db8525
|
|
||||||
86 20 0:79 / /var/lib/docker/aufs/mnt/3bfafd09ff2603e2165efacc2215c1f51afabba6c42d04a68cc2df0e8cc31494 rw,relatime - aufs none rw,si=caafa54f8dba525
|
|
||||||
87 20 0:80 / /var/lib/docker/aufs/mnt/90fdd2c03eeaf65311f88f4200e18aef6d2772482712d9aea01cd793c64781b5 rw,relatime - aufs none rw,si=caafa54f8315525
|
|
||||||
88 20 0:81 / /var/lib/docker/aufs/mnt/7bdf2591c06c154ceb23f5e74b1d03b18fbf6fe96e35fbf539b82d446922442f-init rw,relatime - aufs none rw,si=caafa54f8fc6525
|
|
||||||
89 20 0:82 / /var/lib/docker/aufs/mnt/7bdf2591c06c154ceb23f5e74b1d03b18fbf6fe96e35fbf539b82d446922442f rw,relatime - aufs none rw,si=caafa54f8468525
|
|
||||||
90 20 0:83 / /var/lib/docker/aufs/mnt/8cf9a993f50f3305abad3da268c0fc44ff78a1e7bba595ef9de963497496c3f9 rw,relatime - aufs none rw,si=caafa54f8c59525
|
|
||||||
91 20 0:84 / /var/lib/docker/aufs/mnt/ecc896fd74b21840a8d35e8316b92a08b1b9c83d722a12acff847e9f0ff17173-init rw,relatime - aufs none rw,si=caafa54f846a525
|
|
||||||
92 20 0:85 / /var/lib/docker/aufs/mnt/ecc896fd74b21840a8d35e8316b92a08b1b9c83d722a12acff847e9f0ff17173 rw,relatime - aufs none rw,si=caafa54f846b525
|
|
||||||
93 20 0:86 / /var/lib/docker/aufs/mnt/d8c8288ec920439a48b5796bab5883ee47a019240da65e8d8f33400c31bac5df rw,relatime - aufs none rw,si=caafa54f8dbf525
|
|
||||||
94 20 0:87 / /var/lib/docker/aufs/mnt/ecba66710bcd03199b9398e46c005cd6b68d0266ec81dc8b722a29cc417997c6-init rw,relatime - aufs none rw,si=caafa54f810f525
|
|
||||||
95 20 0:88 / /var/lib/docker/aufs/mnt/ecba66710bcd03199b9398e46c005cd6b68d0266ec81dc8b722a29cc417997c6 rw,relatime - aufs none rw,si=caafa54fbae9525
|
|
||||||
96 20 0:89 / /var/lib/docker/aufs/mnt/befc1c67600df449dddbe796c0d06da7caff1d2bbff64cde1f0ba82d224996b5 rw,relatime - aufs none rw,si=caafa54f8dab525
|
|
||||||
97 20 0:90 / /var/lib/docker/aufs/mnt/c9f470e73d2742629cdc4084a1b2c1a8302914f2aa0d0ec4542371df9a050562-init rw,relatime - aufs none rw,si=caafa54fdc02525
|
|
||||||
98 20 0:91 / /var/lib/docker/aufs/mnt/c9f470e73d2742629cdc4084a1b2c1a8302914f2aa0d0ec4542371df9a050562 rw,relatime - aufs none rw,si=caafa54f9eb0525
|
|
||||||
99 20 0:92 / /var/lib/docker/aufs/mnt/2a31f10029f04ff9d4381167a9b739609853d7220d55a56cb654779a700ee246 rw,relatime - aufs none rw,si=caafa54f8c37525
|
|
||||||
100 20 0:93 / /var/lib/docker/aufs/mnt/8c4261b8e3e4b21ebba60389bd64b6261217e7e6b9fd09e201d5a7f6760f6927-init rw,relatime - aufs none rw,si=caafa54fd173525
|
|
||||||
101 20 0:94 / /var/lib/docker/aufs/mnt/8c4261b8e3e4b21ebba60389bd64b6261217e7e6b9fd09e201d5a7f6760f6927 rw,relatime - aufs none rw,si=caafa54f8108525
|
|
||||||
102 20 0:95 / /var/lib/docker/aufs/mnt/eaa0f57403a3dc685268f91df3fbcd7a8423cee50e1a9ee5c3e1688d9d676bb4 rw,relatime - aufs none rw,si=caafa54f852d525
|
|
||||||
103 20 0:96 / /var/lib/docker/aufs/mnt/9cfe69a2cbffd9bfc7f396d4754f6fe5cc457ef417b277797be3762dfe955a6b-init rw,relatime - aufs none rw,si=caafa54f8d80525
|
|
||||||
104 20 0:97 / /var/lib/docker/aufs/mnt/9cfe69a2cbffd9bfc7f396d4754f6fe5cc457ef417b277797be3762dfe955a6b rw,relatime - aufs none rw,si=caafa54f8fc3525
|
|
||||||
105 20 0:98 / /var/lib/docker/aufs/mnt/d1b322ae17613c6adee84e709641a9244ac56675244a89a64dc0075075fcbb83 rw,relatime - aufs none rw,si=caafa54f8c58525
|
|
||||||
106 20 0:99 / /var/lib/docker/aufs/mnt/d46c2a8e9da7e91ab34fd9c192851c246a4e770a46720bda09e55c7554b9dbbd-init rw,relatime - aufs none rw,si=caafa54f8c63525
|
|
||||||
107 20 0:100 / /var/lib/docker/aufs/mnt/d46c2a8e9da7e91ab34fd9c192851c246a4e770a46720bda09e55c7554b9dbbd rw,relatime - aufs none rw,si=caafa54f8c67525
|
|
||||||
108 20 0:101 / /var/lib/docker/aufs/mnt/bc9d2a264158f83a617a069bf17cbbf2a2ba453db7d3951d9dc63cc1558b1c2b rw,relatime - aufs none rw,si=caafa54f8dbe525
|
|
||||||
109 20 0:102 / /var/lib/docker/aufs/mnt/9e6abb8d72bbeb4d5cf24b96018528015ba830ce42b4859965bd482cbd034e99-init rw,relatime - aufs none rw,si=caafa54f9e0d525
|
|
||||||
110 20 0:103 / /var/lib/docker/aufs/mnt/9e6abb8d72bbeb4d5cf24b96018528015ba830ce42b4859965bd482cbd034e99 rw,relatime - aufs none rw,si=caafa54f9e1b525
|
|
||||||
111 20 0:104 / /var/lib/docker/aufs/mnt/d4dca7b02569c732e740071e1c654d4ad282de5c41edb619af1f0aafa618be26 rw,relatime - aufs none rw,si=caafa54f8dae525
|
|
||||||
112 20 0:105 / /var/lib/docker/aufs/mnt/fea63da40fa1c5ffbad430dde0bc64a8fc2edab09a051fff55b673c40a08f6b7-init rw,relatime - aufs none rw,si=caafa54f8c5c525
|
|
||||||
113 20 0:106 / /var/lib/docker/aufs/mnt/fea63da40fa1c5ffbad430dde0bc64a8fc2edab09a051fff55b673c40a08f6b7 rw,relatime - aufs none rw,si=caafa54fd172525
|
|
||||||
114 20 0:107 / /var/lib/docker/aufs/mnt/e60c57499c0b198a6734f77f660cdbbd950a5b78aa23f470ca4f0cfcc376abef rw,relatime - aufs none rw,si=caafa54909c4525
|
|
||||||
115 20 0:108 / /var/lib/docker/aufs/mnt/099c78e7ccd9c8717471bb1bbfff838c0a9913321ba2f214fbeaf92c678e5b35-init rw,relatime - aufs none rw,si=caafa54909c3525
|
|
||||||
116 20 0:109 / /var/lib/docker/aufs/mnt/099c78e7ccd9c8717471bb1bbfff838c0a9913321ba2f214fbeaf92c678e5b35 rw,relatime - aufs none rw,si=caafa54909c7525
|
|
||||||
117 20 0:110 / /var/lib/docker/aufs/mnt/2997be666d58b9e71469759bcb8bd9608dad0e533a1a7570a896919ba3388825 rw,relatime - aufs none rw,si=caafa54f8557525
|
|
||||||
118 20 0:111 / /var/lib/docker/aufs/mnt/730694eff438ef20569df38dfb38a920969d7ff2170cc9aa7cb32a7ed8147a93-init rw,relatime - aufs none rw,si=caafa54c6e88525
|
|
||||||
119 20 0:112 / /var/lib/docker/aufs/mnt/730694eff438ef20569df38dfb38a920969d7ff2170cc9aa7cb32a7ed8147a93 rw,relatime - aufs none rw,si=caafa54c6e8e525
|
|
||||||
120 20 0:113 / /var/lib/docker/aufs/mnt/a672a1e2f2f051f6e19ed1dfbe80860a2d774174c49f7c476695f5dd1d5b2f67 rw,relatime - aufs none rw,si=caafa54c6e15525
|
|
||||||
121 20 0:114 / /var/lib/docker/aufs/mnt/aba3570e17859f76cf29d282d0d150659c6bd80780fdc52a465ba05245c2a420-init rw,relatime - aufs none rw,si=caafa54f8dad525
|
|
||||||
122 20 0:115 / /var/lib/docker/aufs/mnt/aba3570e17859f76cf29d282d0d150659c6bd80780fdc52a465ba05245c2a420 rw,relatime - aufs none rw,si=caafa54f8d84525
|
|
||||||
123 20 0:116 / /var/lib/docker/aufs/mnt/2abc86007aca46fb4a817a033e2a05ccacae40b78ea4b03f8ea616b9ada40e2e rw,relatime - aufs none rw,si=caafa54c6e8b525
|
|
||||||
124 20 0:117 / /var/lib/docker/aufs/mnt/36352f27f7878e648367a135bd1ec3ed497adcb8ac13577ee892a0bd921d2374-init rw,relatime - aufs none rw,si=caafa54c6e8d525
|
|
||||||
125 20 0:118 / /var/lib/docker/aufs/mnt/36352f27f7878e648367a135bd1ec3ed497adcb8ac13577ee892a0bd921d2374 rw,relatime - aufs none rw,si=caafa54f8c34525
|
|
||||||
126 20 0:119 / /var/lib/docker/aufs/mnt/2f95ca1a629cea8363b829faa727dd52896d5561f2c96ddee4f697ea2fc872c2 rw,relatime - aufs none rw,si=caafa54c6e8a525
|
|
||||||
127 20 0:120 / /var/lib/docker/aufs/mnt/f108c8291654f179ef143a3e07de2b5a34adbc0b28194a0ab17742b6db9a7fb2-init rw,relatime - aufs none rw,si=caafa54f8e19525
|
|
||||||
128 20 0:121 / /var/lib/docker/aufs/mnt/f108c8291654f179ef143a3e07de2b5a34adbc0b28194a0ab17742b6db9a7fb2 rw,relatime - aufs none rw,si=caafa54fa8c6525
|
|
||||||
129 20 0:122 / /var/lib/docker/aufs/mnt/c1d04dfdf8cccb3676d5a91e84e9b0781ce40623d127d038bcfbe4c761b27401 rw,relatime - aufs none rw,si=caafa54f8c30525
|
|
||||||
130 20 0:123 / /var/lib/docker/aufs/mnt/3f4898ffd0e1239aeebf1d1412590cdb7254207fa3883663e2c40cf772e5f05a-init rw,relatime - aufs none rw,si=caafa54c6e1a525
|
|
||||||
131 20 0:124 / /var/lib/docker/aufs/mnt/3f4898ffd0e1239aeebf1d1412590cdb7254207fa3883663e2c40cf772e5f05a rw,relatime - aufs none rw,si=caafa54c6e1c525
|
|
||||||
132 20 0:125 / /var/lib/docker/aufs/mnt/5ae3b6fccb1539fc02d420e86f3e9637bef5b711fed2ca31a2f426c8f5deddbf rw,relatime - aufs none rw,si=caafa54c4fea525
|
|
||||||
133 20 0:126 / /var/lib/docker/aufs/mnt/310bfaf80d57020f2e73b06aeffb0b9b0ca2f54895f88bf5e4d1529ccac58fe0-init rw,relatime - aufs none rw,si=caafa54c6e1e525
|
|
||||||
134 20 0:127 / /var/lib/docker/aufs/mnt/310bfaf80d57020f2e73b06aeffb0b9b0ca2f54895f88bf5e4d1529ccac58fe0 rw,relatime - aufs none rw,si=caafa54fa8c0525
|
|
||||||
135 20 0:128 / /var/lib/docker/aufs/mnt/f382bd5aaccaf2d04a59089ac7cb12ec87efd769fd0c14d623358fbfd2a3f896 rw,relatime - aufs none rw,si=caafa54c4fec525
|
|
||||||
136 20 0:129 / /var/lib/docker/aufs/mnt/50d45e9bb2d779bc6362824085564c7578c231af5ae3b3da116acf7e17d00735-init rw,relatime - aufs none rw,si=caafa54c4fef525
|
|
||||||
137 20 0:130 / /var/lib/docker/aufs/mnt/50d45e9bb2d779bc6362824085564c7578c231af5ae3b3da116acf7e17d00735 rw,relatime - aufs none rw,si=caafa54c4feb525
|
|
||||||
138 20 0:131 / /var/lib/docker/aufs/mnt/a9c5ee0854dc083b6bf62b7eb1e5291aefbb10702289a446471ce73aba0d5d7d rw,relatime - aufs none rw,si=caafa54909c6525
|
|
||||||
139 20 0:134 / /var/lib/docker/aufs/mnt/03a613e7bd5078819d1fd92df4e671c0127559a5e0b5a885cc8d5616875162f0-init rw,relatime - aufs none rw,si=caafa54804fe525
|
|
||||||
140 20 0:135 / /var/lib/docker/aufs/mnt/03a613e7bd5078819d1fd92df4e671c0127559a5e0b5a885cc8d5616875162f0 rw,relatime - aufs none rw,si=caafa54804fa525
|
|
||||||
141 20 0:136 / /var/lib/docker/aufs/mnt/7ec3277e5c04c907051caf9c9c35889f5fcd6463e5485971b25404566830bb70 rw,relatime - aufs none rw,si=caafa54804f9525
|
|
||||||
142 20 0:139 / /var/lib/docker/aufs/mnt/26b5b5d71d79a5b2bfcf8bc4b2280ee829f261eb886745dd90997ed410f7e8b8-init rw,relatime - aufs none rw,si=caafa54c6ef6525
|
|
||||||
143 20 0:140 / /var/lib/docker/aufs/mnt/26b5b5d71d79a5b2bfcf8bc4b2280ee829f261eb886745dd90997ed410f7e8b8 rw,relatime - aufs none rw,si=caafa54c6ef5525
|
|
||||||
144 20 0:356 / /var/lib/docker/aufs/mnt/e6ecde9e2c18cd3c75f424c67b6d89685cfee0fc67abf2cb6bdc0867eb998026 rw,relatime - aufs none rw,si=caafa548068e525`
|
|
||||||
|
|
||||||
gentooMountinfo = `15 1 8:6 / / rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered
|
|
||||||
16 15 0:3 / /proc rw,nosuid,nodev,noexec,relatime - proc proc rw
|
|
||||||
17 15 0:14 / /run rw,nosuid,nodev,relatime - tmpfs tmpfs rw,size=3292172k,mode=755
|
|
||||||
18 15 0:5 / /dev rw,nosuid,relatime - devtmpfs udev rw,size=10240k,nr_inodes=4106451,mode=755
|
|
||||||
19 18 0:12 / /dev/mqueue rw,nosuid,nodev,noexec,relatime - mqueue mqueue rw
|
|
||||||
20 18 0:10 / /dev/pts rw,nosuid,noexec,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
|
|
||||||
21 18 0:15 / /dev/shm rw,nosuid,nodev,noexec,relatime - tmpfs shm rw
|
|
||||||
22 15 0:16 / /sys rw,nosuid,nodev,noexec,relatime - sysfs sysfs rw
|
|
||||||
23 22 0:7 / /sys/kernel/debug rw,nosuid,nodev,noexec,relatime - debugfs debugfs rw
|
|
||||||
24 22 0:17 / /sys/fs/cgroup rw,nosuid,nodev,noexec,relatime - tmpfs cgroup_root rw,size=10240k,mode=755
|
|
||||||
25 24 0:18 / /sys/fs/cgroup/openrc rw,nosuid,nodev,noexec,relatime - cgroup openrc rw,release_agent=/lib64/rc/sh/cgroup-release-agent.sh,name=openrc
|
|
||||||
26 24 0:19 / /sys/fs/cgroup/cpuset rw,nosuid,nodev,noexec,relatime - cgroup cpuset rw,cpuset,clone_children
|
|
||||||
27 24 0:20 / /sys/fs/cgroup/cpu rw,nosuid,nodev,noexec,relatime - cgroup cpu rw,cpu,clone_children
|
|
||||||
28 24 0:21 / /sys/fs/cgroup/cpuacct rw,nosuid,nodev,noexec,relatime - cgroup cpuacct rw,cpuacct,clone_children
|
|
||||||
29 24 0:22 / /sys/fs/cgroup/memory rw,nosuid,nodev,noexec,relatime - cgroup memory rw,memory,clone_children
|
|
||||||
30 24 0:23 / /sys/fs/cgroup/devices rw,nosuid,nodev,noexec,relatime - cgroup devices rw,devices,clone_children
|
|
||||||
31 24 0:24 / /sys/fs/cgroup/freezer rw,nosuid,nodev,noexec,relatime - cgroup freezer rw,freezer,clone_children
|
|
||||||
32 24 0:25 / /sys/fs/cgroup/blkio rw,nosuid,nodev,noexec,relatime - cgroup blkio rw,blkio,clone_children
|
|
||||||
33 15 8:1 / /boot rw,noatime,nodiratime - vfat /dev/sda1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
|
|
||||||
34 15 8:18 / /mnt/xfs rw,noatime,nodiratime - xfs /dev/sdb2 rw,attr2,inode64,noquota
|
|
||||||
35 15 0:26 / /tmp rw,relatime - tmpfs tmpfs rw
|
|
||||||
36 16 0:27 / /proc/sys/fs/binfmt_misc rw,nosuid,nodev,noexec,relatime - binfmt_misc binfmt_misc rw
|
|
||||||
42 15 0:33 / /var/lib/nfs/rpc_pipefs rw,relatime - rpc_pipefs rpc_pipefs rw
|
|
||||||
43 16 0:34 / /proc/fs/nfsd rw,nosuid,nodev,noexec,relatime - nfsd nfsd rw
|
|
||||||
44 15 0:35 / /home/tianon/.gvfs rw,nosuid,nodev,relatime - fuse.gvfs-fuse-daemon gvfs-fuse-daemon rw,user_id=1000,group_id=1000
|
|
||||||
68 15 0:3336 / /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd rw,relatime - aufs none rw,si=9b4a7640128db39c
|
|
||||||
85 68 8:6 /var/lib/docker/init/dockerinit-0.7.2-dev//deleted /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/.dockerinit rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered
|
|
||||||
86 68 8:6 /var/lib/docker/containers/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/config.env /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/.dockerenv rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered
|
|
||||||
87 68 8:6 /etc/resolv.conf /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/etc/resolv.conf rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered
|
|
||||||
88 68 8:6 /var/lib/docker/containers/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/hostname /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/etc/hostname rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered
|
|
||||||
89 68 8:6 /var/lib/docker/containers/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/hosts /var/lib/docker/aufs/mnt/3597a1a6d6298c1decc339ebb90aad6f7d6ba2e15af3131b1f85e7ee4787a0cd/etc/hosts rw,noatime,nodiratime - ext4 /dev/sda6 rw,data=ordered
|
|
||||||
38 15 0:3384 / /var/lib/docker/aufs/mnt/0292005a9292401bb5197657f2b682d97d8edcb3b72b5e390d2a680139985b55 rw,relatime - aufs none rw,si=9b4a7642b584939c
|
|
||||||
39 15 0:3385 / /var/lib/docker/aufs/mnt/59db98c889de5f71b70cfb82c40cbe47b64332f0f56042a2987a9e5df6e5e3aa rw,relatime - aufs none rw,si=9b4a7642b584e39c
|
|
||||||
40 15 0:3386 / /var/lib/docker/aufs/mnt/0545f0f2b6548eb9601d08f35a08f5a0a385407d36027a28f58e06e9f61e0278 rw,relatime - aufs none rw,si=9b4a7642b584b39c
|
|
||||||
41 15 0:3387 / /var/lib/docker/aufs/mnt/d882cfa16d1aa8fe0331a36e79be3d80b151e49f24fc39a39c3fed1735d5feb5 rw,relatime - aufs none rw,si=9b4a76453040039c
|
|
||||||
45 15 0:3388 / /var/lib/docker/aufs/mnt/055ca3befcb1626e74f5344b3398724ff05c0de0e20021683d04305c9e70a3f6 rw,relatime - aufs none rw,si=9b4a76453040739c
|
|
||||||
46 15 0:3389 / /var/lib/docker/aufs/mnt/b899e4567a351745d4285e7f1c18fdece75d877deb3041981cd290be348b7aa6 rw,relatime - aufs none rw,si=9b4a7647def4039c
|
|
||||||
47 15 0:3390 / /var/lib/docker/aufs/mnt/067ca040292c58954c5129f953219accfae0d40faca26b4d05e76ca76a998f16 rw,relatime - aufs none rw,si=9b4a7647def4239c
|
|
||||||
48 15 0:3391 / /var/lib/docker/aufs/mnt/8c995e7cb6e5082742daeea720e340b021d288d25d92e0412c03d200df308a11 rw,relatime - aufs none rw,si=9b4a764479c1639c
|
|
||||||
49 15 0:3392 / /var/lib/docker/aufs/mnt/07cc54dfae5b45300efdacdd53cc72c01b9044956a86ce7bff42d087e426096d rw,relatime - aufs none rw,si=9b4a764479c1739c
|
|
||||||
50 15 0:3393 / /var/lib/docker/aufs/mnt/0a9c95cf4c589c05b06baa79150b0cc1d8e7102759fe3ce4afaabb8247ca4f85 rw,relatime - aufs none rw,si=9b4a7644059c839c
|
|
||||||
51 15 0:3394 / /var/lib/docker/aufs/mnt/468fa98cececcf4e226e8370f18f4f848d63faf287fb8321a07f73086441a3a0 rw,relatime - aufs none rw,si=9b4a7644059ca39c
|
|
||||||
52 15 0:3395 / /var/lib/docker/aufs/mnt/0b826192231c5ce066fffb5beff4397337b5fc19a377aa7c6282c7c0ce7f111f rw,relatime - aufs none rw,si=9b4a764479c1339c
|
|
||||||
53 15 0:3396 / /var/lib/docker/aufs/mnt/93b8ba1b772fbe79709b909c43ea4b2c30d712e53548f467db1ffdc7a384f196 rw,relatime - aufs none rw,si=9b4a7640798a739c
|
|
||||||
54 15 0:3397 / /var/lib/docker/aufs/mnt/0c0d0acfb506859b12ef18cdfef9ebed0b43a611482403564224bde9149d373c rw,relatime - aufs none rw,si=9b4a7640798a039c
|
|
||||||
55 15 0:3398 / /var/lib/docker/aufs/mnt/33648c39ab6c7c74af0243d6d6a81b052e9e25ad1e04b19892eb2dde013e358b rw,relatime - aufs none rw,si=9b4a7644b439b39c
|
|
||||||
56 15 0:3399 / /var/lib/docker/aufs/mnt/0c12bea97a1c958a3c739fb148536c1c89351d48e885ecda8f0499b5cc44407e rw,relatime - aufs none rw,si=9b4a7640798a239c
|
|
||||||
57 15 0:3400 / /var/lib/docker/aufs/mnt/ed443988ce125f172d7512e84a4de2627405990fd767a16adefa8ce700c19ce8 rw,relatime - aufs none rw,si=9b4a7644c8ed339c
|
|
||||||
59 15 0:3402 / /var/lib/docker/aufs/mnt/f61612c324ff3c924d3f7a82fb00a0f8d8f73c248c41897061949e9f5ab7e3b1 rw,relatime - aufs none rw,si=9b4a76442810c39c
|
|
||||||
60 15 0:3403 / /var/lib/docker/aufs/mnt/0f1ee55c6c4e25027b80de8e64b8b6fb542b3b41aa0caab9261da75752e22bfd rw,relatime - aufs none rw,si=9b4a76442810e39c
|
|
||||||
61 15 0:3404 / /var/lib/docker/aufs/mnt/956f6cc4af5785cb3ee6963dcbca668219437d9b28f513290b1453ac64a34f97 rw,relatime - aufs none rw,si=9b4a7644303ec39c
|
|
||||||
62 15 0:3405 / /var/lib/docker/aufs/mnt/1099769158c4b4773e2569e38024e8717e400f87a002c41d8cf47cb81b051ba6 rw,relatime - aufs none rw,si=9b4a7644303ee39c
|
|
||||||
63 15 0:3406 / /var/lib/docker/aufs/mnt/11890ceb98d4442595b676085cd7b21550ab85c5df841e0fba997ff54e3d522d rw,relatime - aufs none rw,si=9b4a7644303ed39c
|
|
||||||
64 15 0:3407 / /var/lib/docker/aufs/mnt/acdb90dc378e8ed2420b43a6d291f1c789a081cd1904018780cc038fcd7aae53 rw,relatime - aufs none rw,si=9b4a76434be2139c
|
|
||||||
65 15 0:3408 / /var/lib/docker/aufs/mnt/120e716f19d4714fbe63cc1ed246204f2c1106eefebc6537ba2587d7e7711959 rw,relatime - aufs none rw,si=9b4a76434be2339c
|
|
||||||
66 15 0:3409 / /var/lib/docker/aufs/mnt/b197b7fffb61d89e0ba1c40de9a9fc0d912e778b3c1bd828cf981ff37c1963bc rw,relatime - aufs none rw,si=9b4a76434be2039c
|
|
||||||
70 15 0:3412 / /var/lib/docker/aufs/mnt/1434b69d2e1bb18a9f0b96b9cdac30132b2688f5d1379f68a39a5e120c2f93eb rw,relatime - aufs none rw,si=9b4a76434be2639c
|
|
||||||
71 15 0:3413 / /var/lib/docker/aufs/mnt/16006e83caf33ab5eb0cd6afc92ea2ee8edeff897496b0bb3ec3a75b767374b3 rw,relatime - aufs none rw,si=9b4a7644d790439c
|
|
||||||
72 15 0:3414 / /var/lib/docker/aufs/mnt/55bfa5f44e94d27f91f79ba901b118b15098449165c87abf1b53ffff147ff164 rw,relatime - aufs none rw,si=9b4a7644d790239c
|
|
||||||
73 15 0:3415 / /var/lib/docker/aufs/mnt/1912b97a07ab21ccd98a2a27bc779bf3cf364a3138afa3c3e6f7f169a3c3eab5 rw,relatime - aufs none rw,si=9b4a76441822739c
|
|
||||||
76 15 0:3418 / /var/lib/docker/aufs/mnt/1a7c3292e8879bd91ffd9282e954f643b1db5683093574c248ff14a9609f2f56 rw,relatime - aufs none rw,si=9b4a76438cb7239c
|
|
||||||
77 15 0:3419 / /var/lib/docker/aufs/mnt/bb1faaf0d076ddba82c2318305a85f490dafa4e8a8640a8db8ed657c439120cc rw,relatime - aufs none rw,si=9b4a76438cb7339c
|
|
||||||
78 15 0:3420 / /var/lib/docker/aufs/mnt/1ab869f21d2241a73ac840c7f988490313f909ac642eba71d092204fec66dd7c rw,relatime - aufs none rw,si=9b4a76438cb7639c
|
|
||||||
79 15 0:3421 / /var/lib/docker/aufs/mnt/fd7245b2cfe3890fa5f5b452260e4edf9e7fb7746532ed9d83f7a0d7dbaa610e rw,relatime - aufs none rw,si=9b4a7644bdc0139c
|
|
||||||
80 15 0:3422 / /var/lib/docker/aufs/mnt/1e5686c5301f26b9b3cd24e322c608913465cc6c5d0dcd7c5e498d1314747d61 rw,relatime - aufs none rw,si=9b4a7644bdc0639c
|
|
||||||
81 15 0:3423 / /var/lib/docker/aufs/mnt/52edf6ee6e40bfec1e9301a4d4a92ab83d144e2ae4ce5099e99df6138cb844bf rw,relatime - aufs none rw,si=9b4a7644bdc0239c
|
|
||||||
82 15 0:3424 / /var/lib/docker/aufs/mnt/1ea10fb7085d28cda4904657dff0454e52598d28e1d77e4f2965bbc3666e808f rw,relatime - aufs none rw,si=9b4a76438cb7139c
|
|
||||||
83 15 0:3425 / /var/lib/docker/aufs/mnt/9c03e98c3593946dbd4087f8d83f9ca262f4a2efdc952ce60690838b9ba6c526 rw,relatime - aufs none rw,si=9b4a76443020639c
|
|
||||||
84 15 0:3426 / /var/lib/docker/aufs/mnt/220a2344d67437602c6d2cee9a98c46be13f82c2a8063919dd2fad52bf2fb7dd rw,relatime - aufs none rw,si=9b4a76434bff339c
|
|
||||||
94 15 0:3427 / /var/lib/docker/aufs/mnt/3b32876c5b200312c50baa476ff342248e88c8ea96e6a1032cd53a88738a1cf2 rw,relatime - aufs none rw,si=9b4a76434bff139c
|
|
||||||
95 15 0:3428 / /var/lib/docker/aufs/mnt/23ee2b8b0d4ae8db6f6d1e168e2c6f79f8a18f953b09f65e0d22cc1e67a3a6fa rw,relatime - aufs none rw,si=9b4a7646c305c39c
|
|
||||||
96 15 0:3429 / /var/lib/docker/aufs/mnt/e86e6daa70b61b57945fa178222615f3c3d6bcef12c9f28e9f8623d44dc2d429 rw,relatime - aufs none rw,si=9b4a7646c305f39c
|
|
||||||
97 15 0:3430 / /var/lib/docker/aufs/mnt/2413d07623e80860bb2e9e306fbdee699afd07525785c025c591231e864aa162 rw,relatime - aufs none rw,si=9b4a76434bff039c
|
|
||||||
98 15 0:3431 / /var/lib/docker/aufs/mnt/adfd622eb22340fc80b429e5564b125668e260bf9068096c46dd59f1386a4b7d rw,relatime - aufs none rw,si=9b4a7646a7a1039c
|
|
||||||
102 15 0:3435 / /var/lib/docker/aufs/mnt/27cd92e7a91d02e2d6b44d16679a00fb6d169b19b88822891084e7fd1a84882d rw,relatime - aufs none rw,si=9b4a7646f25ec39c
|
|
||||||
103 15 0:3436 / /var/lib/docker/aufs/mnt/27dfdaf94cfbf45055c748293c37dd68d9140240bff4c646cb09216015914a88 rw,relatime - aufs none rw,si=9b4a7646732f939c
|
|
||||||
104 15 0:3437 / /var/lib/docker/aufs/mnt/5ed7524aff68dfbf0fc601cbaeac01bab14391850a973dabf3653282a627920f rw,relatime - aufs none rw,si=9b4a7646732f839c
|
|
||||||
105 15 0:3438 / /var/lib/docker/aufs/mnt/2a0d4767e536beb5785b60e071e3ac8e5e812613ab143a9627bee77d0c9ab062 rw,relatime - aufs none rw,si=9b4a7646732fe39c
|
|
||||||
106 15 0:3439 / /var/lib/docker/aufs/mnt/dea3fc045d9f4ae51ba952450b948a822cf85c39411489ca5224f6d9a8d02bad rw,relatime - aufs none rw,si=9b4a764012ad839c
|
|
||||||
107 15 0:3440 / /var/lib/docker/aufs/mnt/2d140a787160798da60cb67c21b1210054ad4dafecdcf832f015995b9aa99cfd rw,relatime - aufs none rw,si=9b4a764012add39c
|
|
||||||
108 15 0:3441 / /var/lib/docker/aufs/mnt/cb190b2a8e984475914430fbad2382e0d20b9b659f8ef83ae8d170cc672e519c rw,relatime - aufs none rw,si=9b4a76454d9c239c
|
|
||||||
109 15 0:3442 / /var/lib/docker/aufs/mnt/2f4a012d5a7ffd90256a6e9aa479054b3dddbc3c6a343f26dafbf3196890223b rw,relatime - aufs none rw,si=9b4a76454d9c439c
|
|
||||||
110 15 0:3443 / /var/lib/docker/aufs/mnt/63cc77904b80c4ffbf49cb974c5d8733dc52ad7640d3ae87554b325d7312d87f rw,relatime - aufs none rw,si=9b4a76454d9c339c
|
|
||||||
111 15 0:3444 / /var/lib/docker/aufs/mnt/30333e872c451482ea2d235ff2192e875bd234006b238ae2bdde3b91a86d7522 rw,relatime - aufs none rw,si=9b4a76422cebf39c
|
|
||||||
112 15 0:3445 / /var/lib/docker/aufs/mnt/6c54fc1125da3925cae65b5c9a98f3be55b0a2c2666082e5094a4ba71beb5bff rw,relatime - aufs none rw,si=9b4a7646dd5a439c
|
|
||||||
113 15 0:3446 / /var/lib/docker/aufs/mnt/3087d48cb01cda9d0a83a9ca301e6ea40e8593d18c4921be4794c91a420ab9a3 rw,relatime - aufs none rw,si=9b4a7646dd5a739c
|
|
||||||
114 15 0:3447 / /var/lib/docker/aufs/mnt/cc2607462a8f55b179a749b144c3fdbb50678e1a4f3065ea04e283e9b1f1d8e2 rw,relatime - aufs none rw,si=9b4a7646dd5a239c
|
|
||||||
117 15 0:3450 / /var/lib/docker/aufs/mnt/310c5e8392b29e8658a22e08d96d63936633b7e2c38e8d220047928b00a03d24 rw,relatime - aufs none rw,si=9b4a7647932d739c
|
|
||||||
118 15 0:3451 / /var/lib/docker/aufs/mnt/38a1f0029406ba9c3b6058f2f406d8a1d23c855046cf355c91d87d446fcc1460 rw,relatime - aufs none rw,si=9b4a76445abc939c
|
|
||||||
119 15 0:3452 / /var/lib/docker/aufs/mnt/42e109ab7914ae997a11ccd860fd18e4d488c50c044c3240423ce15774b8b62e rw,relatime - aufs none rw,si=9b4a76445abca39c
|
|
||||||
120 15 0:3453 / /var/lib/docker/aufs/mnt/365d832af0402d052b389c1e9c0d353b48487533d20cd4351df8e24ec4e4f9d8 rw,relatime - aufs none rw,si=9b4a7644066aa39c
|
|
||||||
121 15 0:3454 / /var/lib/docker/aufs/mnt/d3fa8a24d695b6cda9b64f96188f701963d28bef0473343f8b212df1a2cf1d2b rw,relatime - aufs none rw,si=9b4a7644066af39c
|
|
||||||
122 15 0:3455 / /var/lib/docker/aufs/mnt/37d4f491919abc49a15d0c7a7cc8383f087573525d7d288accd14f0b4af9eae0 rw,relatime - aufs none rw,si=9b4a7644066ad39c
|
|
||||||
123 15 0:3456 / /var/lib/docker/aufs/mnt/93902707fe12cbdd0068ce73f2baad4b3a299189b1b19cb5f8a2025e106ae3f5 rw,relatime - aufs none rw,si=9b4a76444445f39c
|
|
||||||
126 15 0:3459 / /var/lib/docker/aufs/mnt/3b49291670a625b9bbb329ffba99bf7fa7abff80cefef040f8b89e2b3aad4f9f rw,relatime - aufs none rw,si=9b4a7640798a339c
|
|
||||||
127 15 0:3460 / /var/lib/docker/aufs/mnt/8d9c7b943cc8f854f4d0d4ec19f7c16c13b0cc4f67a41472a072648610cecb59 rw,relatime - aufs none rw,si=9b4a76427383039c
|
|
||||||
128 15 0:3461 / /var/lib/docker/aufs/mnt/3b6c90036526c376307df71d49c9f5fce334c01b926faa6a78186842de74beac rw,relatime - aufs none rw,si=9b4a7644badd439c
|
|
||||||
130 15 0:3463 / /var/lib/docker/aufs/mnt/7b24158eeddfb5d31b7e932e406ea4899fd728344335ff8e0765e89ddeb351dd rw,relatime - aufs none rw,si=9b4a7644badd539c
|
|
||||||
131 15 0:3464 / /var/lib/docker/aufs/mnt/3ead6dd5773765c74850cf6c769f21fe65c29d622ffa712664f9f5b80364ce27 rw,relatime - aufs none rw,si=9b4a7642f469939c
|
|
||||||
132 15 0:3465 / /var/lib/docker/aufs/mnt/3f825573b29547744a37b65597a9d6d15a8350be4429b7038d126a4c9a8e178f rw,relatime - aufs none rw,si=9b4a7642f469c39c
|
|
||||||
133 15 0:3466 / /var/lib/docker/aufs/mnt/f67aaaeb3681e5dcb99a41f847087370bd1c206680cb8c7b6a9819fd6c97a331 rw,relatime - aufs none rw,si=9b4a7647cc25939c
|
|
||||||
134 15 0:3467 / /var/lib/docker/aufs/mnt/41afe6cfb3c1fc2280b869db07699da88552786e28793f0bc048a265c01bd942 rw,relatime - aufs none rw,si=9b4a7647cc25c39c
|
|
||||||
135 15 0:3468 / /var/lib/docker/aufs/mnt/b8092ea59da34a40b120e8718c3ae9fa8436996edc4fc50e4b99c72dfd81e1af rw,relatime - aufs none rw,si=9b4a76445abc439c
|
|
||||||
136 15 0:3469 / /var/lib/docker/aufs/mnt/42c69d2cc179e2684458bb8596a9da6dad182c08eae9b74d5f0e615b399f75a5 rw,relatime - aufs none rw,si=9b4a76455ddbe39c
|
|
||||||
137 15 0:3470 / /var/lib/docker/aufs/mnt/ea0871954acd2d62a211ac60e05969622044d4c74597870c4f818fbb0c56b09b rw,relatime - aufs none rw,si=9b4a76455ddbf39c
|
|
||||||
138 15 0:3471 / /var/lib/docker/aufs/mnt/4307906b275ab3fc971786b3841ae3217ac85b6756ddeb7ad4ba09cd044c2597 rw,relatime - aufs none rw,si=9b4a76455ddb839c
|
|
||||||
139 15 0:3472 / /var/lib/docker/aufs/mnt/4390b872928c53500a5035634f3421622ed6299dc1472b631fc45de9f56dc180 rw,relatime - aufs none rw,si=9b4a76402f2fd39c
|
|
||||||
140 15 0:3473 / /var/lib/docker/aufs/mnt/6bb41e78863b85e4aa7da89455314855c8c3bda64e52a583bab15dc1fa2e80c2 rw,relatime - aufs none rw,si=9b4a76402f2fa39c
|
|
||||||
141 15 0:3474 / /var/lib/docker/aufs/mnt/4444f583c2a79c66608f4673a32c9c812154f027045fbd558c2d69920c53f835 rw,relatime - aufs none rw,si=9b4a764479dbd39c
|
|
||||||
142 15 0:3475 / /var/lib/docker/aufs/mnt/6f11883af4a05ea362e0c54df89058da4859f977efd07b6f539e1f55c1d2a668 rw,relatime - aufs none rw,si=9b4a76402f30b39c
|
|
||||||
143 15 0:3476 / /var/lib/docker/aufs/mnt/453490dd32e7c2e9ef906f995d8fb3c2753923d1a5e0ba3fd3296e2e4dc238e7 rw,relatime - aufs none rw,si=9b4a76402f30c39c
|
|
||||||
144 15 0:3477 / /var/lib/docker/aufs/mnt/45e5945735ee102b5e891c91650c57ec4b52bb53017d68f02d50ea8a6e230610 rw,relatime - aufs none rw,si=9b4a76423260739c
|
|
||||||
147 15 0:3480 / /var/lib/docker/aufs/mnt/4727a64a5553a1125f315b96bed10d3073d6988225a292cce732617c925b56ab rw,relatime - aufs none rw,si=9b4a76443030339c
|
|
||||||
150 15 0:3483 / /var/lib/docker/aufs/mnt/4e348b5187b9a567059306afc72d42e0ec5c893b0d4abd547526d5f9b6fb4590 rw,relatime - aufs none rw,si=9b4a7644f5d8c39c
|
|
||||||
151 15 0:3484 / /var/lib/docker/aufs/mnt/4efc616bfbc3f906718b052da22e4335f8e9f91ee9b15866ed3a8029645189ef rw,relatime - aufs none rw,si=9b4a7644f5d8939c
|
|
||||||
152 15 0:3485 / /var/lib/docker/aufs/mnt/83e730ae9754d5adb853b64735472d98dfa17136b8812ac9cfcd1eba7f4e7d2d rw,relatime - aufs none rw,si=9b4a76469aa7139c
|
|
||||||
153 15 0:3486 / /var/lib/docker/aufs/mnt/4fc5ba8a5b333be2b7eefacccb626772eeec0ae8a6975112b56c9fb36c0d342f rw,relatime - aufs none rw,si=9b4a7640128dc39c
|
|
||||||
154 15 0:3487 / /var/lib/docker/aufs/mnt/50200d5edff5dfe8d1ef3c78b0bbd709793ac6e936aa16d74ff66f7ea577b6f9 rw,relatime - aufs none rw,si=9b4a7640128da39c
|
|
||||||
155 15 0:3488 / /var/lib/docker/aufs/mnt/51e5e51604361448f0b9777f38329f414bc5ba9cf238f26d465ff479bd574b61 rw,relatime - aufs none rw,si=9b4a76444f68939c
|
|
||||||
156 15 0:3489 / /var/lib/docker/aufs/mnt/52a142149aa98bba83df8766bbb1c629a97b9799944ead90dd206c4bdf0b8385 rw,relatime - aufs none rw,si=9b4a76444f68b39c
|
|
||||||
157 15 0:3490 / /var/lib/docker/aufs/mnt/52dd21a94a00f58a1ed489312fcfffb91578089c76c5650364476f1d5de031bc rw,relatime - aufs none rw,si=9b4a76444f68f39c
|
|
||||||
158 15 0:3491 / /var/lib/docker/aufs/mnt/ee562415ddaad353ed22c88d0ca768a0c74bfba6333b6e25c46849ee22d990da rw,relatime - aufs none rw,si=9b4a7640128d839c
|
|
||||||
159 15 0:3492 / /var/lib/docker/aufs/mnt/db47a9e87173f7554f550c8a01891de79cf12acdd32e01f95c1a527a08bdfb2c rw,relatime - aufs none rw,si=9b4a764405a1d39c
|
|
||||||
160 15 0:3493 / /var/lib/docker/aufs/mnt/55e827bf6d44d930ec0b827c98356eb8b68c3301e2d60d1429aa72e05b4c17df rw,relatime - aufs none rw,si=9b4a764405a1a39c
|
|
||||||
162 15 0:3495 / /var/lib/docker/aufs/mnt/578dc4e0a87fc37ec081ca098430499a59639c09f6f12a8f48de29828a091aa6 rw,relatime - aufs none rw,si=9b4a76406d7d439c
|
|
||||||
163 15 0:3496 / /var/lib/docker/aufs/mnt/728cc1cb04fa4bc6f7bf7a90980beda6d8fc0beb71630874c0747b994efb0798 rw,relatime - aufs none rw,si=9b4a76444f20e39c
|
|
||||||
164 15 0:3497 / /var/lib/docker/aufs/mnt/5850cc4bd9b55aea46c7ad598f1785117607974084ea643580f58ce3222e683a rw,relatime - aufs none rw,si=9b4a7644a824239c
|
|
||||||
165 15 0:3498 / /var/lib/docker/aufs/mnt/89443b3f766d5a37bc8b84e29da8b84e6a3ea8486d3cf154e2aae1816516e4a8 rw,relatime - aufs none rw,si=9b4a7644a824139c
|
|
||||||
166 15 0:3499 / /var/lib/docker/aufs/mnt/f5ae8fd5a41a337907d16515bc3162525154b59c32314c695ecd092c3b47943d rw,relatime - aufs none rw,si=9b4a7644a824439c
|
|
||||||
167 15 0:3500 / /var/lib/docker/aufs/mnt/5a430854f2a03a9e5f7cbc9f3fb46a8ebca526a5b3f435236d8295e5998798f5 rw,relatime - aufs none rw,si=9b4a7647fc82439c
|
|
||||||
168 15 0:3501 / /var/lib/docker/aufs/mnt/eda16901ae4cead35070c39845cbf1e10bd6b8cb0ffa7879ae2d8a186e460f91 rw,relatime - aufs none rw,si=9b4a76441e0df39c
|
|
||||||
169 15 0:3502 / /var/lib/docker/aufs/mnt/5a593721430c2a51b119ff86a7e06ea2b37e3b4131f8f1344d402b61b0c8d868 rw,relatime - aufs none rw,si=9b4a764248bad39c
|
|
||||||
170 15 0:3503 / /var/lib/docker/aufs/mnt/d662ad0a30fbfa902e0962108685b9330597e1ee2abb16dc9462eb5a67fdd23f rw,relatime - aufs none rw,si=9b4a764248bae39c
|
|
||||||
171 15 0:3504 / /var/lib/docker/aufs/mnt/5bc9de5c79812843fb36eee96bef1ddba812407861f572e33242f4ee10da2c15 rw,relatime - aufs none rw,si=9b4a764248ba839c
|
|
||||||
172 15 0:3505 / /var/lib/docker/aufs/mnt/5e763de8e9b0f7d58d2e12a341e029ab4efb3b99788b175090d8209e971156c1 rw,relatime - aufs none rw,si=9b4a764248baa39c
|
|
||||||
173 15 0:3506 / /var/lib/docker/aufs/mnt/b4431dc2739936f1df6387e337f5a0c99cf051900c896bd7fd46a870ce61c873 rw,relatime - aufs none rw,si=9b4a76401263539c
|
|
||||||
174 15 0:3507 / /var/lib/docker/aufs/mnt/5f37830e5a02561ab8c67ea3113137ba69f67a60e41c05cb0e7a0edaa1925b24 rw,relatime - aufs none rw,si=9b4a76401263639c
|
|
||||||
184 15 0:3508 / /var/lib/docker/aufs/mnt/62ea10b957e6533538a4633a1e1d678502f50ddcdd354b2ca275c54dd7a7793a rw,relatime - aufs none rw,si=9b4a76401263039c
|
|
||||||
187 15 0:3509 / /var/lib/docker/aufs/mnt/d56ee9d44195fe390e042fda75ec15af5132adb6d5c69468fa8792f4e54a6953 rw,relatime - aufs none rw,si=9b4a76401263239c
|
|
||||||
188 15 0:3510 / /var/lib/docker/aufs/mnt/6a300930673174549c2b62f36c933f0332a20735978c007c805a301f897146c5 rw,relatime - aufs none rw,si=9b4a76455d4c539c
|
|
||||||
189 15 0:3511 / /var/lib/docker/aufs/mnt/64496c45c84d348c24d410015456d101601c30cab4d1998c395591caf7e57a70 rw,relatime - aufs none rw,si=9b4a76455d4c639c
|
|
||||||
190 15 0:3512 / /var/lib/docker/aufs/mnt/65a6a645883fe97a7422cd5e71ebe0bc17c8e6302a5361edf52e89747387e908 rw,relatime - aufs none rw,si=9b4a76455d4c039c
|
|
||||||
191 15 0:3513 / /var/lib/docker/aufs/mnt/672be40695f7b6e13b0a3ed9fc996c73727dede3481f58155950fcfad57ed616 rw,relatime - aufs none rw,si=9b4a76455d4c239c
|
|
||||||
192 15 0:3514 / /var/lib/docker/aufs/mnt/d42438acb2bfb2169e1c0d8e917fc824f7c85d336dadb0b0af36dfe0f001b3ba rw,relatime - aufs none rw,si=9b4a7642bfded39c
|
|
||||||
193 15 0:3515 / /var/lib/docker/aufs/mnt/b48a54abf26d01cb2ddd908b1ed6034d17397c1341bf0eb2b251a3e5b79be854 rw,relatime - aufs none rw,si=9b4a7642bfdee39c
|
|
||||||
194 15 0:3516 / /var/lib/docker/aufs/mnt/76f27134491f052bfb87f59092126e53ef875d6851990e59195a9da16a9412f8 rw,relatime - aufs none rw,si=9b4a7642bfde839c
|
|
||||||
195 15 0:3517 / /var/lib/docker/aufs/mnt/6bd626a5462b4f8a8e1cc7d10351326dca97a59b2758e5ea549a4f6350ce8a90 rw,relatime - aufs none rw,si=9b4a7642bfdea39c
|
|
||||||
196 15 0:3518 / /var/lib/docker/aufs/mnt/f1fe3549dbd6f5ca615e9139d9b53f0c83a3b825565df37628eacc13e70cbd6d rw,relatime - aufs none rw,si=9b4a7642bfdf539c
|
|
||||||
197 15 0:3519 / /var/lib/docker/aufs/mnt/6d0458c8426a9e93d58d0625737e6122e725c9408488ed9e3e649a9984e15c34 rw,relatime - aufs none rw,si=9b4a7642bfdf639c
|
|
||||||
198 15 0:3520 / /var/lib/docker/aufs/mnt/6e4c97db83aa82145c9cf2bafc20d500c0b5389643b689e3ae84188c270a48c5 rw,relatime - aufs none rw,si=9b4a7642bfdf039c
|
|
||||||
199 15 0:3521 / /var/lib/docker/aufs/mnt/eb94d6498f2c5969eaa9fa11ac2934f1ab90ef88e2d002258dca08e5ba74ea27 rw,relatime - aufs none rw,si=9b4a7642bfdf239c
|
|
||||||
200 15 0:3522 / /var/lib/docker/aufs/mnt/fe3f88f0c511608a2eec5f13a98703aa16e55dbf930309723d8a37101f539fe1 rw,relatime - aufs none rw,si=9b4a7642bfc3539c
|
|
||||||
201 15 0:3523 / /var/lib/docker/aufs/mnt/6f40c229fb9cad85fabf4b64a2640a5403ec03fe5ac1a57d0609fb8b606b9c83 rw,relatime - aufs none rw,si=9b4a7642bfc3639c
|
|
||||||
202 15 0:3524 / /var/lib/docker/aufs/mnt/7513e9131f7a8acf58ff15248237feb767c78732ca46e159f4d791e6ef031dbc rw,relatime - aufs none rw,si=9b4a7642bfc3039c
|
|
||||||
203 15 0:3525 / /var/lib/docker/aufs/mnt/79f48b00aa713cdf809c6bb7c7cb911b66e9a8076c81d6c9d2504139984ea2da rw,relatime - aufs none rw,si=9b4a7642bfc3239c
|
|
||||||
204 15 0:3526 / /var/lib/docker/aufs/mnt/c3680418350d11358f0a96c676bc5aa74fa00a7c89e629ef5909d3557b060300 rw,relatime - aufs none rw,si=9b4a7642f47cd39c
|
|
||||||
205 15 0:3527 / /var/lib/docker/aufs/mnt/7a1744dd350d7fcc0cccb6f1757ca4cbe5453f203a5888b0f1014d96ad5a5ef9 rw,relatime - aufs none rw,si=9b4a7642f47ce39c
|
|
||||||
206 15 0:3528 / /var/lib/docker/aufs/mnt/7fa99662db046be9f03c33c35251afda9ccdc0085636bbba1d90592cec3ff68d rw,relatime - aufs none rw,si=9b4a7642f47c839c
|
|
||||||
207 15 0:3529 / /var/lib/docker/aufs/mnt/f815021ef20da9c9b056bd1d52d8aaf6e2c0c19f11122fc793eb2b04eb995e35 rw,relatime - aufs none rw,si=9b4a7642f47ca39c
|
|
||||||
208 15 0:3530 / /var/lib/docker/aufs/mnt/801086ae3110192d601dfcebdba2db92e86ce6b6a9dba6678ea04488e4513669 rw,relatime - aufs none rw,si=9b4a7642dc6dd39c
|
|
||||||
209 15 0:3531 / /var/lib/docker/aufs/mnt/822ba7db69f21daddda87c01cfbfbf73013fc03a879daf96d16cdde6f9b1fbd6 rw,relatime - aufs none rw,si=9b4a7642dc6de39c
|
|
||||||
210 15 0:3532 / /var/lib/docker/aufs/mnt/834227c1a950fef8cae3827489129d0dd220541e60c6b731caaa765bf2e6a199 rw,relatime - aufs none rw,si=9b4a7642dc6d839c
|
|
||||||
211 15 0:3533 / /var/lib/docker/aufs/mnt/83dccbc385299bd1c7cf19326e791b33a544eea7b4cdfb6db70ea94eed4389fb rw,relatime - aufs none rw,si=9b4a7642dc6da39c
|
|
||||||
212 15 0:3534 / /var/lib/docker/aufs/mnt/f1b8e6f0e7c8928b5dcdab944db89306ebcae3e0b32f9ff40d2daa8329f21600 rw,relatime - aufs none rw,si=9b4a7645a126039c
|
|
||||||
213 15 0:3535 / /var/lib/docker/aufs/mnt/970efb262c7a020c2404cbcc5b3259efba0d110a786079faeef05bc2952abf3a rw,relatime - aufs none rw,si=9b4a7644c8ed139c
|
|
||||||
214 15 0:3536 / /var/lib/docker/aufs/mnt/84b6d73af7450f3117a77e15a5ca1255871fea6182cd8e8a7be6bc744be18c2c rw,relatime - aufs none rw,si=9b4a76406559139c
|
|
||||||
215 15 0:3537 / /var/lib/docker/aufs/mnt/88be2716e026bc681b5e63fe7942068773efbd0b6e901ca7ba441412006a96b6 rw,relatime - aufs none rw,si=9b4a76406559339c
|
|
||||||
216 15 0:3538 / /var/lib/docker/aufs/mnt/c81939aa166ce50cd8bca5cfbbcc420a78e0318dd5cd7c755209b9166a00a752 rw,relatime - aufs none rw,si=9b4a76406559239c
|
|
||||||
217 15 0:3539 / /var/lib/docker/aufs/mnt/e0f241645d64b7dc5ff6a8414087cca226be08fb54ce987d1d1f6350c57083aa rw,relatime - aufs none rw,si=9b4a7647cfc0f39c
|
|
||||||
218 15 0:3540 / /var/lib/docker/aufs/mnt/e10e2bf75234ed51d8a6a4bb39e465404fecbe318e54400d3879cdb2b0679c78 rw,relatime - aufs none rw,si=9b4a7647cfc0939c
|
|
||||||
219 15 0:3541 / /var/lib/docker/aufs/mnt/8f71d74c8cfc3228b82564aa9f09b2e576cff0083ddfb6aa5cb350346063f080 rw,relatime - aufs none rw,si=9b4a7647cfc0a39c
|
|
||||||
220 15 0:3542 / /var/lib/docker/aufs/mnt/9159f1eba2aef7f5205cc18d015cda7f5933cd29bba3b1b8aed5ccb5824c69ee rw,relatime - aufs none rw,si=9b4a76468cedd39c
|
|
||||||
221 15 0:3543 / /var/lib/docker/aufs/mnt/932cad71e652e048e500d9fbb5b8ea4fc9a269d42a3134ce527ceef42a2be56b rw,relatime - aufs none rw,si=9b4a76468cede39c
|
|
||||||
222 15 0:3544 / /var/lib/docker/aufs/mnt/bf1e1b5f529e8943cc0144ee86dbaaa37885c1ddffcef29537e0078ee7dd316a rw,relatime - aufs none rw,si=9b4a76468ced839c
|
|
||||||
223 15 0:3545 / /var/lib/docker/aufs/mnt/949d93ecf3322e09f858ce81d5f4b434068ec44ff84c375de03104f7b45ee955 rw,relatime - aufs none rw,si=9b4a76468ceda39c
|
|
||||||
224 15 0:3546 / /var/lib/docker/aufs/mnt/d65c6087f92dc2a3841b5251d2fe9ca07d4c6e5b021597692479740816e4e2a1 rw,relatime - aufs none rw,si=9b4a7645a126239c
|
|
||||||
225 15 0:3547 / /var/lib/docker/aufs/mnt/98a0153119d0651c193d053d254f6e16a68345a141baa80c87ae487e9d33f290 rw,relatime - aufs none rw,si=9b4a7640787cf39c
|
|
||||||
226 15 0:3548 / /var/lib/docker/aufs/mnt/99daf7fe5847c017392f6e59aa9706b3dfdd9e6d1ba11dae0f7fffde0a60b5e5 rw,relatime - aufs none rw,si=9b4a7640787c839c
|
|
||||||
227 15 0:3549 / /var/lib/docker/aufs/mnt/9ad1f2fe8a5599d4e10c5a6effa7f03d932d4e92ee13149031a372087a359079 rw,relatime - aufs none rw,si=9b4a7640787ca39c
|
|
||||||
228 15 0:3550 / /var/lib/docker/aufs/mnt/c26d64494da782ddac26f8370d86ac93e7c1666d88a7b99110fc86b35ea6a85d rw,relatime - aufs none rw,si=9b4a7642fc6b539c
|
|
||||||
229 15 0:3551 / /var/lib/docker/aufs/mnt/a49e4a8275133c230ec640997f35f172312eb0ea5bd2bbe10abf34aae98f30eb rw,relatime - aufs none rw,si=9b4a7642fc6b639c
|
|
||||||
230 15 0:3552 / /var/lib/docker/aufs/mnt/b5e2740c867ed843025f49d84e8d769de9e8e6039b3c8cb0735b5bf358994bc7 rw,relatime - aufs none rw,si=9b4a7642fc6b039c
|
|
||||||
231 15 0:3553 / /var/lib/docker/aufs/mnt/a826fdcf3a7039b30570054579b65763db605a314275d7aef31b872c13311b4b rw,relatime - aufs none rw,si=9b4a7642fc6b239c
|
|
||||||
232 15 0:3554 / /var/lib/docker/aufs/mnt/addf3025babf5e43b5a3f4a0da7ad863dda3c01fb8365c58fd8d28bb61dc11bc rw,relatime - aufs none rw,si=9b4a76407871d39c
|
|
||||||
233 15 0:3555 / /var/lib/docker/aufs/mnt/c5b6c6813ab3e5ebdc6d22cb2a3d3106a62095f2c298be52b07a3b0fa20ff690 rw,relatime - aufs none rw,si=9b4a76407871e39c
|
|
||||||
234 15 0:3556 / /var/lib/docker/aufs/mnt/af0609eaaf64e2392060cb46f5a9f3d681a219bb4c651d4f015bf573fbe6c4cf rw,relatime - aufs none rw,si=9b4a76407871839c
|
|
||||||
235 15 0:3557 / /var/lib/docker/aufs/mnt/e7f20e3c37ecad39cd90a97cd3549466d0d106ce4f0a930b8495442634fa4a1f rw,relatime - aufs none rw,si=9b4a76407871a39c
|
|
||||||
237 15 0:3559 / /var/lib/docker/aufs/mnt/b57a53d440ffd0c1295804fa68cdde35d2fed5409484627e71b9c37e4249fd5c rw,relatime - aufs none rw,si=9b4a76444445a39c
|
|
||||||
238 15 0:3560 / /var/lib/docker/aufs/mnt/b5e7d7b8f35e47efbba3d80c5d722f5e7bd43e54c824e54b4a4b351714d36d42 rw,relatime - aufs none rw,si=9b4a7647932d439c
|
|
||||||
239 15 0:3561 / /var/lib/docker/aufs/mnt/f1b136def157e9465640658f277f3347de593c6ae76412a2e79f7002f091cae2 rw,relatime - aufs none rw,si=9b4a76445abcd39c
|
|
||||||
240 15 0:3562 / /var/lib/docker/aufs/mnt/b750fe79269d2ec9a3c593ef05b4332b1d1a02a62b4accb2c21d589ff2f5f2dc rw,relatime - aufs none rw,si=9b4a7644403b339c
|
|
||||||
241 15 0:3563 / /var/lib/docker/aufs/mnt/b89b140cdbc95063761864e0a23346207fa27ee4c5c63a1ae85c9069a9d9cf1d rw,relatime - aufs none rw,si=9b4a7644aa19739c
|
|
||||||
242 15 0:3564 / /var/lib/docker/aufs/mnt/bc6a69ed51c07f5228f6b4f161c892e6a949c0e7e86a9c3432049d4c0e5cd298 rw,relatime - aufs none rw,si=9b4a7644aa19139c
|
|
||||||
243 15 0:3565 / /var/lib/docker/aufs/mnt/be4e2ba3f136933e239f7cf3d136f484fb9004f1fbdfee24a62a2c7b0ab30670 rw,relatime - aufs none rw,si=9b4a7644aa19339c
|
|
||||||
244 15 0:3566 / /var/lib/docker/aufs/mnt/e04ca1a4a5171e30d20f0c92f90a50b8b6f8600af5459c4b4fb25e42e864dfe1 rw,relatime - aufs none rw,si=9b4a7647932d139c
|
|
||||||
245 15 0:3567 / /var/lib/docker/aufs/mnt/be61576b31db893129aaffcd3dcb5ce35e49c4b71b30c392a78609a45c7323d8 rw,relatime - aufs none rw,si=9b4a7642d85f739c
|
|
||||||
246 15 0:3568 / /var/lib/docker/aufs/mnt/dda42c191e56becf672327658ab84fcb563322db3764b91c2fefe4aaef04c624 rw,relatime - aufs none rw,si=9b4a7642d85f139c
|
|
||||||
247 15 0:3569 / /var/lib/docker/aufs/mnt/c0a7995053330f3d88969247a2e72b07e2dd692133f5668a4a35ea3905561072 rw,relatime - aufs none rw,si=9b4a7642d85f339c
|
|
||||||
249 15 0:3571 / /var/lib/docker/aufs/mnt/c3594b2e5f08c59ff5ed338a1ba1eceeeb1f7fc5d180068338110c00b1eb8502 rw,relatime - aufs none rw,si=9b4a7642738c739c
|
|
||||||
250 15 0:3572 / /var/lib/docker/aufs/mnt/c58dce03a0ab0a7588393880379dc3bce9f96ec08ed3f99cf1555260ff0031e8 rw,relatime - aufs none rw,si=9b4a7642738c139c
|
|
||||||
251 15 0:3573 / /var/lib/docker/aufs/mnt/c73e9f1d109c9d14cb36e1c7489df85649be3911116d76c2fd3648ec8fd94e23 rw,relatime - aufs none rw,si=9b4a7642738c339c
|
|
||||||
252 15 0:3574 / /var/lib/docker/aufs/mnt/c9eef28c344877cd68aa09e543c0710ab2b305a0ff96dbb859bfa7808c3e8d01 rw,relatime - aufs none rw,si=9b4a7642d85f439c
|
|
||||||
253 15 0:3575 / /var/lib/docker/aufs/mnt/feb67148f548d70cb7484f2aaad2a86051cd6867a561741a2f13b552457d666e rw,relatime - aufs none rw,si=9b4a76468c55739c
|
|
||||||
254 15 0:3576 / /var/lib/docker/aufs/mnt/cdf1f96c36d35a96041a896bf398ec0f7dc3b0fb0643612a0f4b6ff96e04e1bb rw,relatime - aufs none rw,si=9b4a76468c55139c
|
|
||||||
255 15 0:3577 / /var/lib/docker/aufs/mnt/ec6e505872353268451ac4bc034c1df00f3bae4a3ea2261c6e48f7bd5417c1b3 rw,relatime - aufs none rw,si=9b4a76468c55339c
|
|
||||||
256 15 0:3578 / /var/lib/docker/aufs/mnt/d6dc8aca64efd90e0bc10274001882d0efb310d42ccbf5712b99b169053b8b1a rw,relatime - aufs none rw,si=9b4a7642738c439c
|
|
||||||
257 15 0:3579 / /var/lib/docker/aufs/mnt/d712594e2ff6eaeb895bfd150d694bd1305fb927e7a186b2dab7df2ea95f8f81 rw,relatime - aufs none rw,si=9b4a76401268f39c
|
|
||||||
259 15 0:3581 / /var/lib/docker/aufs/mnt/dbfa1174cd78cde2d7410eae442af0b416c4a0e6f87ed4ff1e9f169a0029abc0 rw,relatime - aufs none rw,si=9b4a76401268b39c
|
|
||||||
260 15 0:3582 / /var/lib/docker/aufs/mnt/e883f5a82316d7856fbe93ee8c0af5a920b7079619dd95c4ffd88bbd309d28dd rw,relatime - aufs none rw,si=9b4a76468c55439c
|
|
||||||
261 15 0:3583 / /var/lib/docker/aufs/mnt/fdec3eff581c4fc2b09f87befa2fa021f3f2d373bea636a87f1fb5b367d6347a rw,relatime - aufs none rw,si=9b4a7644aa1af39c
|
|
||||||
262 15 0:3584 / /var/lib/docker/aufs/mnt/ef764e26712184653067ecf7afea18a80854c41331ca0f0ef03e1bacf90a6ffc rw,relatime - aufs none rw,si=9b4a7644aa1a939c
|
|
||||||
263 15 0:3585 / /var/lib/docker/aufs/mnt/f3176b40c41fce8ce6942936359a2001a6f1b5c1bb40ee224186db0789ec2f76 rw,relatime - aufs none rw,si=9b4a7644aa1ab39c
|
|
||||||
264 15 0:3586 / /var/lib/docker/aufs/mnt/f5daf06785d3565c6dd18ea7d953d9a8b9606107781e63270fe0514508736e6a rw,relatime - aufs none rw,si=9b4a76401268c39c
|
|
||||||
58 15 0:3587 / /var/lib/docker/aufs/mnt/cde8c40f6524b7361af4f5ad05bb857dc9ee247c20852ba666195c0739e3a2b8-init rw,relatime - aufs none rw,si=9b4a76444445839c
|
|
||||||
67 15 0:3588 / /var/lib/docker/aufs/mnt/cde8c40f6524b7361af4f5ad05bb857dc9ee247c20852ba666195c0739e3a2b8 rw,relatime - aufs none rw,si=9b4a7644badd339c
|
|
||||||
265 15 0:3610 / /var/lib/docker/aufs/mnt/e812472cd2c8c4748d1ef71fac4e77e50d661b9349abe66ce3e23511ed44f414 rw,relatime - aufs none rw,si=9b4a76427937d39c
|
|
||||||
270 15 0:3615 / /var/lib/docker/aufs/mnt/997636e7c5c9d0d1376a217e295c14c205350b62bc12052804fb5f90abe6f183 rw,relatime - aufs none rw,si=9b4a76406540739c
|
|
||||||
273 15 0:3618 / /var/lib/docker/aufs/mnt/d5794d080417b6e52e69227c3873e0e4c1ff0d5a845ebe3860ec2f89a47a2a1e rw,relatime - aufs none rw,si=9b4a76454814039c
|
|
||||||
278 15 0:3623 / /var/lib/docker/aufs/mnt/586bdd48baced671bb19bc4d294ec325f26c55545ae267db426424f157d59c48 rw,relatime - aufs none rw,si=9b4a7644b439f39c
|
|
||||||
281 15 0:3626 / /var/lib/docker/aufs/mnt/69739d022f89f8586908bbd5edbbdd95ea5256356f177f9ffcc6ef9c0ea752d2 rw,relatime - aufs none rw,si=9b4a7644a0f1b39c
|
|
||||||
286 15 0:3631 / /var/lib/docker/aufs/mnt/ff28c27d5f894363993622de26d5dd352dba072f219e4691d6498c19bbbc15a9 rw,relatime - aufs none rw,si=9b4a7642265b339c
|
|
||||||
289 15 0:3634 / /var/lib/docker/aufs/mnt/aa128fe0e64fdede333aa48fd9de39530c91a9244a0f0649a3c411c61e372daa rw,relatime - aufs none rw,si=9b4a764012ada39c
|
|
||||||
99 15 8:33 / /media/REMOVE\040ME rw,nosuid,nodev,relatime - fuseblk /dev/sdc1 rw,user_id=0,group_id=0,allow_other,blksize=4096`
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestParseFedoraMountinfo(t *testing.T) {
|
|
||||||
r := bytes.NewBuffer([]byte(fedoraMountinfo))
|
|
||||||
_, err := parseInfoFile(r)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseUbuntuMountinfo(t *testing.T) {
|
|
||||||
r := bytes.NewBuffer([]byte(ubuntuMountInfo))
|
|
||||||
_, err := parseInfoFile(r)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseGentooMountinfo(t *testing.T) {
|
|
||||||
r := bytes.NewBuffer([]byte(gentooMountinfo))
|
|
||||||
_, err := parseInfoFile(r)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseFedoraMountinfoFields(t *testing.T) {
|
|
||||||
r := bytes.NewBuffer([]byte(fedoraMountinfo))
|
|
||||||
infos, err := parseInfoFile(r)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
expectedLength := 58
|
|
||||||
if len(infos) != expectedLength {
|
|
||||||
t.Fatalf("Expected %d entries, got %d", expectedLength, len(infos))
|
|
||||||
}
|
|
||||||
mi := Info{
|
|
||||||
ID: 15,
|
|
||||||
Parent: 35,
|
|
||||||
Major: 0,
|
|
||||||
Minor: 3,
|
|
||||||
Root: "/",
|
|
||||||
Mountpoint: "/proc",
|
|
||||||
Opts: "rw,nosuid,nodev,noexec,relatime",
|
|
||||||
Optional: "shared:5",
|
|
||||||
Fstype: "proc",
|
|
||||||
Source: "proc",
|
|
||||||
VfsOpts: "rw",
|
|
||||||
}
|
|
||||||
|
|
||||||
if *infos[0] != mi {
|
|
||||||
t.Fatalf("expected %#v, got %#v", mi, infos[0])
|
|
||||||
}
|
|
||||||
}
|
|
331
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/sharedsubtree_linux_test.go
generated
vendored
331
Godeps/_workspace/src/github.com/docker/docker/pkg/mount/sharedsubtree_linux_test.go
generated
vendored
|
@ -1,331 +0,0 @@
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package mount
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
"syscall"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// nothing is propagated in or out
|
|
||||||
func TestSubtreePrivate(t *testing.T) {
|
|
||||||
tmp := path.Join(os.TempDir(), "mount-tests")
|
|
||||||
if err := os.MkdirAll(tmp, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
var (
|
|
||||||
sourceDir = path.Join(tmp, "source")
|
|
||||||
targetDir = path.Join(tmp, "target")
|
|
||||||
outside1Dir = path.Join(tmp, "outside1")
|
|
||||||
outside2Dir = path.Join(tmp, "outside2")
|
|
||||||
|
|
||||||
outside1Path = path.Join(outside1Dir, "file.txt")
|
|
||||||
outside2Path = path.Join(outside2Dir, "file.txt")
|
|
||||||
outside1CheckPath = path.Join(targetDir, "a", "file.txt")
|
|
||||||
outside2CheckPath = path.Join(sourceDir, "b", "file.txt")
|
|
||||||
)
|
|
||||||
if err := os.MkdirAll(path.Join(sourceDir, "a"), 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.MkdirAll(path.Join(sourceDir, "b"), 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(targetDir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(outside1Dir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(outside2Dir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := createFile(outside1Path); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := createFile(outside2Path); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// mount the shared directory to a target
|
|
||||||
if err := Mount(sourceDir, targetDir, "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// next, make the target private
|
|
||||||
if err := MakePrivate(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// mount in an outside path to a mounted path inside the _source_
|
|
||||||
if err := Mount(outside1Dir, path.Join(sourceDir, "a"), "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(path.Join(sourceDir, "a")); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// check that this file _does_not_ show in the _target_
|
|
||||||
if _, err := os.Stat(outside1CheckPath); err != nil && !os.IsNotExist(err) {
|
|
||||||
t.Fatal(err)
|
|
||||||
} else if err == nil {
|
|
||||||
t.Fatalf("%q should not be visible, but is", outside1CheckPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// next mount outside2Dir into the _target_
|
|
||||||
if err := Mount(outside2Dir, path.Join(targetDir, "b"), "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(path.Join(targetDir, "b")); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// check that this file _does_not_ show in the _source_
|
|
||||||
if _, err := os.Stat(outside2CheckPath); err != nil && !os.IsNotExist(err) {
|
|
||||||
t.Fatal(err)
|
|
||||||
} else if err == nil {
|
|
||||||
t.Fatalf("%q should not be visible, but is", outside2CheckPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Testing that when a target is a shared mount,
|
|
||||||
// then child mounts propagate to the source
|
|
||||||
func TestSubtreeShared(t *testing.T) {
|
|
||||||
tmp := path.Join(os.TempDir(), "mount-tests")
|
|
||||||
if err := os.MkdirAll(tmp, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
var (
|
|
||||||
sourceDir = path.Join(tmp, "source")
|
|
||||||
targetDir = path.Join(tmp, "target")
|
|
||||||
outsideDir = path.Join(tmp, "outside")
|
|
||||||
|
|
||||||
outsidePath = path.Join(outsideDir, "file.txt")
|
|
||||||
sourceCheckPath = path.Join(sourceDir, "a", "file.txt")
|
|
||||||
)
|
|
||||||
|
|
||||||
if err := os.MkdirAll(path.Join(sourceDir, "a"), 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(targetDir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(outsideDir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := createFile(outsidePath); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// mount the source as shared
|
|
||||||
if err := MakeShared(sourceDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(sourceDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// mount the shared directory to a target
|
|
||||||
if err := Mount(sourceDir, targetDir, "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// mount in an outside path to a mounted path inside the target
|
|
||||||
if err := Mount(outsideDir, path.Join(targetDir, "a"), "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(path.Join(targetDir, "a")); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// NOW, check that the file from the outside directory is avaible in the source directory
|
|
||||||
if _, err := os.Stat(sourceCheckPath); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// testing that mounts to a shared source show up in the slave target,
|
|
||||||
// and that mounts into a slave target do _not_ show up in the shared source
|
|
||||||
func TestSubtreeSharedSlave(t *testing.T) {
|
|
||||||
tmp := path.Join(os.TempDir(), "mount-tests")
|
|
||||||
if err := os.MkdirAll(tmp, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
var (
|
|
||||||
sourceDir = path.Join(tmp, "source")
|
|
||||||
targetDir = path.Join(tmp, "target")
|
|
||||||
outside1Dir = path.Join(tmp, "outside1")
|
|
||||||
outside2Dir = path.Join(tmp, "outside2")
|
|
||||||
|
|
||||||
outside1Path = path.Join(outside1Dir, "file.txt")
|
|
||||||
outside2Path = path.Join(outside2Dir, "file.txt")
|
|
||||||
outside1CheckPath = path.Join(targetDir, "a", "file.txt")
|
|
||||||
outside2CheckPath = path.Join(sourceDir, "b", "file.txt")
|
|
||||||
)
|
|
||||||
if err := os.MkdirAll(path.Join(sourceDir, "a"), 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.MkdirAll(path.Join(sourceDir, "b"), 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(targetDir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(outside1Dir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.Mkdir(outside2Dir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := createFile(outside1Path); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := createFile(outside2Path); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// mount the source as shared
|
|
||||||
if err := MakeShared(sourceDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(sourceDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// mount the shared directory to a target
|
|
||||||
if err := Mount(sourceDir, targetDir, "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// next, make the target slave
|
|
||||||
if err := MakeSlave(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// mount in an outside path to a mounted path inside the _source_
|
|
||||||
if err := Mount(outside1Dir, path.Join(sourceDir, "a"), "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(path.Join(sourceDir, "a")); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// check that this file _does_ show in the _target_
|
|
||||||
if _, err := os.Stat(outside1CheckPath); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// next mount outside2Dir into the _target_
|
|
||||||
if err := Mount(outside2Dir, path.Join(targetDir, "b"), "none", "bind,rw"); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(path.Join(targetDir, "b")); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// check that this file _does_not_ show in the _source_
|
|
||||||
if _, err := os.Stat(outside2CheckPath); err != nil && !os.IsNotExist(err) {
|
|
||||||
t.Fatal(err)
|
|
||||||
} else if err == nil {
|
|
||||||
t.Fatalf("%q should not be visible, but is", outside2CheckPath)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSubtreeUnbindable(t *testing.T) {
|
|
||||||
tmp := path.Join(os.TempDir(), "mount-tests")
|
|
||||||
if err := os.MkdirAll(tmp, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tmp)
|
|
||||||
|
|
||||||
var (
|
|
||||||
sourceDir = path.Join(tmp, "source")
|
|
||||||
targetDir = path.Join(tmp, "target")
|
|
||||||
)
|
|
||||||
if err := os.MkdirAll(sourceDir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if err := os.MkdirAll(targetDir, 0777); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// next, make the source unbindable
|
|
||||||
if err := MakeUnbindable(sourceDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(sourceDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// then attempt to mount it to target. It should fail
|
|
||||||
if err := Mount(sourceDir, targetDir, "none", "bind,rw"); err != nil && err != syscall.EINVAL {
|
|
||||||
t.Fatal(err)
|
|
||||||
} else if err == nil {
|
|
||||||
t.Fatalf("%q should not have been bindable", sourceDir)
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err := Unmount(targetDir); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
func createFile(path string) error {
|
|
||||||
f, err := os.Create(path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
f.WriteString("hello world!")
|
|
||||||
return f.Close()
|
|
||||||
}
|
|
116
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/filters/parse.go
generated
vendored
116
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/filters/parse.go
generated
vendored
|
@ -1,116 +0,0 @@
|
||||||
package filters
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"errors"
|
|
||||||
"regexp"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Args map[string][]string
|
|
||||||
|
|
||||||
// Parse the argument to the filter flag. Like
|
|
||||||
//
|
|
||||||
// `docker ps -f 'created=today' -f 'image.name=ubuntu*'`
|
|
||||||
//
|
|
||||||
// If prev map is provided, then it is appended to, and returned. By default a new
|
|
||||||
// map is created.
|
|
||||||
func ParseFlag(arg string, prev Args) (Args, error) {
|
|
||||||
var filters Args = prev
|
|
||||||
if prev == nil {
|
|
||||||
filters = Args{}
|
|
||||||
}
|
|
||||||
if len(arg) == 0 {
|
|
||||||
return filters, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if !strings.Contains(arg, "=") {
|
|
||||||
return filters, ErrorBadFormat
|
|
||||||
}
|
|
||||||
|
|
||||||
f := strings.SplitN(arg, "=", 2)
|
|
||||||
name := strings.ToLower(strings.TrimSpace(f[0]))
|
|
||||||
value := strings.TrimSpace(f[1])
|
|
||||||
filters[name] = append(filters[name], value)
|
|
||||||
|
|
||||||
return filters, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var ErrorBadFormat = errors.New("bad format of filter (expected name=value)")
|
|
||||||
|
|
||||||
// packs the Args into an string for easy transport from client to server
|
|
||||||
func ToParam(a Args) (string, error) {
|
|
||||||
// this way we don't URL encode {}, just empty space
|
|
||||||
if len(a) == 0 {
|
|
||||||
return "", nil
|
|
||||||
}
|
|
||||||
|
|
||||||
buf, err := json.Marshal(a)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return string(buf), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// unpacks the filter Args
|
|
||||||
func FromParam(p string) (Args, error) {
|
|
||||||
args := Args{}
|
|
||||||
if len(p) == 0 {
|
|
||||||
return args, nil
|
|
||||||
}
|
|
||||||
if err := json.NewDecoder(strings.NewReader(p)).Decode(&args); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return args, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (filters Args) MatchKVList(field string, sources map[string]string) bool {
|
|
||||||
fieldValues := filters[field]
|
|
||||||
|
|
||||||
//do not filter if there is no filter set or cannot determine filter
|
|
||||||
if len(fieldValues) == 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if sources == nil || len(sources) == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
outer:
|
|
||||||
for _, name2match := range fieldValues {
|
|
||||||
testKV := strings.SplitN(name2match, "=", 2)
|
|
||||||
|
|
||||||
for k, v := range sources {
|
|
||||||
if len(testKV) == 1 {
|
|
||||||
if k == testKV[0] {
|
|
||||||
continue outer
|
|
||||||
}
|
|
||||||
} else if k == testKV[0] && v == testKV[1] {
|
|
||||||
continue outer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (filters Args) Match(field, source string) bool {
|
|
||||||
fieldValues := filters[field]
|
|
||||||
|
|
||||||
//do not filter if there is no filter set or cannot determine filter
|
|
||||||
if len(fieldValues) == 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
for _, name2match := range fieldValues {
|
|
||||||
match, err := regexp.MatchString(name2match, source)
|
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if match {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
218
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/filters/parse_test.go
generated
vendored
218
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/filters/parse_test.go
generated
vendored
|
@ -1,218 +0,0 @@
|
||||||
package filters
|
|
||||||
|
|
||||||
import (
|
|
||||||
"sort"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestParseArgs(t *testing.T) {
|
|
||||||
// equivalent of `docker ps -f 'created=today' -f 'image.name=ubuntu*' -f 'image.name=*untu'`
|
|
||||||
flagArgs := []string{
|
|
||||||
"created=today",
|
|
||||||
"image.name=ubuntu*",
|
|
||||||
"image.name=*untu",
|
|
||||||
}
|
|
||||||
var (
|
|
||||||
args = Args{}
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
for i := range flagArgs {
|
|
||||||
args, err = ParseFlag(flagArgs[i], args)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to parse %s: %s", flagArgs[i], err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(args["created"]) != 1 {
|
|
||||||
t.Errorf("failed to set this arg")
|
|
||||||
}
|
|
||||||
if len(args["image.name"]) != 2 {
|
|
||||||
t.Errorf("the args should have collapsed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseArgsEdgeCase(t *testing.T) {
|
|
||||||
var filters Args
|
|
||||||
args, err := ParseFlag("", filters)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if args == nil || len(args) != 0 {
|
|
||||||
t.Fatalf("Expected an empty Args (map), got %v", args)
|
|
||||||
}
|
|
||||||
if args, err = ParseFlag("anything", args); err == nil || err != ErrorBadFormat {
|
|
||||||
t.Fatalf("Expected ErrorBadFormat, got %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestToParam(t *testing.T) {
|
|
||||||
a := Args{
|
|
||||||
"created": []string{"today"},
|
|
||||||
"image.name": []string{"ubuntu*", "*untu"},
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err := ToParam(a)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to marshal the filters: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFromParam(t *testing.T) {
|
|
||||||
invalids := []string{
|
|
||||||
"anything",
|
|
||||||
"['a','list']",
|
|
||||||
"{'key': 'value'}",
|
|
||||||
`{"key": "value"}`,
|
|
||||||
}
|
|
||||||
valids := map[string]Args{
|
|
||||||
`{"key": ["value"]}`: {
|
|
||||||
"key": {"value"},
|
|
||||||
},
|
|
||||||
`{"key": ["value1", "value2"]}`: {
|
|
||||||
"key": {"value1", "value2"},
|
|
||||||
},
|
|
||||||
`{"key1": ["value1"], "key2": ["value2"]}`: {
|
|
||||||
"key1": {"value1"},
|
|
||||||
"key2": {"value2"},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, invalid := range invalids {
|
|
||||||
if _, err := FromParam(invalid); err == nil {
|
|
||||||
t.Fatalf("Expected an error with %v, got nothing", invalid)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for json, expectedArgs := range valids {
|
|
||||||
args, err := FromParam(json)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if len(args) != len(expectedArgs) {
|
|
||||||
t.Fatalf("Expected %v, go %v", expectedArgs, args)
|
|
||||||
}
|
|
||||||
for key, expectedValues := range expectedArgs {
|
|
||||||
values := args[key]
|
|
||||||
sort.Strings(values)
|
|
||||||
sort.Strings(expectedValues)
|
|
||||||
if len(values) != len(expectedValues) {
|
|
||||||
t.Fatalf("Expected %v, go %v", expectedArgs, args)
|
|
||||||
}
|
|
||||||
for index, expectedValue := range expectedValues {
|
|
||||||
if values[index] != expectedValue {
|
|
||||||
t.Fatalf("Expected %v, go %v", expectedArgs, args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestEmpty(t *testing.T) {
|
|
||||||
a := Args{}
|
|
||||||
v, err := ToParam(a)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("failed to marshal the filters: %s", err)
|
|
||||||
}
|
|
||||||
v1, err := FromParam(v)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("%s", err)
|
|
||||||
}
|
|
||||||
if len(a) != len(v1) {
|
|
||||||
t.Errorf("these should both be empty sets")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestArgsMatchKVList(t *testing.T) {
|
|
||||||
// empty sources
|
|
||||||
args := Args{
|
|
||||||
"created": []string{"today"},
|
|
||||||
}
|
|
||||||
if args.MatchKVList("created", map[string]string{}) {
|
|
||||||
t.Fatalf("Expected false for (%v,created), got true", args)
|
|
||||||
}
|
|
||||||
// Not empty sources
|
|
||||||
sources := map[string]string{
|
|
||||||
"key1": "value1",
|
|
||||||
"key2": "value2",
|
|
||||||
"key3": "value3",
|
|
||||||
}
|
|
||||||
matches := map[*Args]string{
|
|
||||||
&Args{}: "field",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"today"},
|
|
||||||
"labels": []string{"key1"},
|
|
||||||
}: "labels",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"today"},
|
|
||||||
"labels": []string{"key1=value1"},
|
|
||||||
}: "labels",
|
|
||||||
}
|
|
||||||
differs := map[*Args]string{
|
|
||||||
&Args{
|
|
||||||
"created": []string{"today"},
|
|
||||||
}: "created",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"today"},
|
|
||||||
"labels": []string{"key4"},
|
|
||||||
}: "labels",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"today"},
|
|
||||||
"labels": []string{"key1=value3"},
|
|
||||||
}: "labels",
|
|
||||||
}
|
|
||||||
for args, field := range matches {
|
|
||||||
if args.MatchKVList(field, sources) != true {
|
|
||||||
t.Fatalf("Expected true for %v on %v, got false", sources, args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for args, field := range differs {
|
|
||||||
if args.MatchKVList(field, sources) != false {
|
|
||||||
t.Fatalf("Expected false for %v on %v, got true", sources, args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestArgsMatch(t *testing.T) {
|
|
||||||
source := "today"
|
|
||||||
matches := map[*Args]string{
|
|
||||||
&Args{}: "field",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"today"},
|
|
||||||
"labels": []string{"key1"},
|
|
||||||
}: "today",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"to*"},
|
|
||||||
}: "created",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"to(.*)"},
|
|
||||||
}: "created",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"tod"},
|
|
||||||
}: "created",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"anything", "to*"},
|
|
||||||
}: "created",
|
|
||||||
}
|
|
||||||
differs := map[*Args]string{
|
|
||||||
&Args{
|
|
||||||
"created": []string{"tomorrow"},
|
|
||||||
}: "created",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"to(day"},
|
|
||||||
}: "created",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"tom(.*)"},
|
|
||||||
}: "created",
|
|
||||||
&Args{
|
|
||||||
"created": []string{"today1"},
|
|
||||||
"labels": []string{"today"},
|
|
||||||
}: "created",
|
|
||||||
}
|
|
||||||
for args, field := range matches {
|
|
||||||
if args.Match(field, source) != true {
|
|
||||||
t.Fatalf("Expected true for %v on %v, got false", source, args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for args, field := range differs {
|
|
||||||
if args.Match(field, source) != false {
|
|
||||||
t.Fatalf("Expected false for %v on %v, got true", source, args)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
95
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel.go
generated
vendored
95
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel.go
generated
vendored
|
@ -1,95 +0,0 @@
|
||||||
// +build !windows
|
|
||||||
|
|
||||||
package kernel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type KernelVersionInfo struct {
|
|
||||||
Kernel int
|
|
||||||
Major int
|
|
||||||
Minor int
|
|
||||||
Flavor string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k *KernelVersionInfo) String() string {
|
|
||||||
return fmt.Sprintf("%d.%d.%d%s", k.Kernel, k.Major, k.Minor, k.Flavor)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare two KernelVersionInfo struct.
|
|
||||||
// Returns -1 if a < b, 0 if a == b, 1 it a > b
|
|
||||||
func CompareKernelVersion(a, b *KernelVersionInfo) int {
|
|
||||||
if a.Kernel < b.Kernel {
|
|
||||||
return -1
|
|
||||||
} else if a.Kernel > b.Kernel {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if a.Major < b.Major {
|
|
||||||
return -1
|
|
||||||
} else if a.Major > b.Major {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if a.Minor < b.Minor {
|
|
||||||
return -1
|
|
||||||
} else if a.Minor > b.Minor {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetKernelVersion() (*KernelVersionInfo, error) {
|
|
||||||
var (
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
uts, err := uname()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
release := make([]byte, len(uts.Release))
|
|
||||||
|
|
||||||
i := 0
|
|
||||||
for _, c := range uts.Release {
|
|
||||||
release[i] = byte(c)
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove the \x00 from the release for Atoi to parse correctly
|
|
||||||
release = release[:bytes.IndexByte(release, 0)]
|
|
||||||
|
|
||||||
return ParseRelease(string(release))
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseRelease(release string) (*KernelVersionInfo, error) {
|
|
||||||
var (
|
|
||||||
kernel, major, minor, parsed int
|
|
||||||
flavor, partial string
|
|
||||||
)
|
|
||||||
|
|
||||||
// Ignore error from Sscanf to allow an empty flavor. Instead, just
|
|
||||||
// make sure we got all the version numbers.
|
|
||||||
parsed, _ = fmt.Sscanf(release, "%d.%d%s", &kernel, &major, &partial)
|
|
||||||
if parsed < 2 {
|
|
||||||
return nil, errors.New("Can't parse kernel version " + release)
|
|
||||||
}
|
|
||||||
|
|
||||||
// sometimes we have 3.12.25-gentoo, but sometimes we just have 3.12-1-amd64
|
|
||||||
parsed, _ = fmt.Sscanf(partial, ".%d%s", &minor, &flavor)
|
|
||||||
if parsed < 1 {
|
|
||||||
flavor = partial
|
|
||||||
}
|
|
||||||
|
|
||||||
return &KernelVersionInfo{
|
|
||||||
Kernel: kernel,
|
|
||||||
Major: major,
|
|
||||||
Minor: minor,
|
|
||||||
Flavor: flavor,
|
|
||||||
}, nil
|
|
||||||
}
|
|
92
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel_test.go
generated
vendored
92
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel_test.go
generated
vendored
|
@ -1,92 +0,0 @@
|
||||||
package kernel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func assertParseRelease(t *testing.T, release string, b *KernelVersionInfo, result int) {
|
|
||||||
var (
|
|
||||||
a *KernelVersionInfo
|
|
||||||
)
|
|
||||||
a, _ = ParseRelease(release)
|
|
||||||
|
|
||||||
if r := CompareKernelVersion(a, b); r != result {
|
|
||||||
t.Fatalf("Unexpected kernel version comparison result for (%v,%v). Found %d, expected %d", release, b, r, result)
|
|
||||||
}
|
|
||||||
if a.Flavor != b.Flavor {
|
|
||||||
t.Fatalf("Unexpected parsed kernel flavor. Found %s, expected %s", a.Flavor, b.Flavor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseRelease(t *testing.T) {
|
|
||||||
assertParseRelease(t, "3.8.0", &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0}, 0)
|
|
||||||
assertParseRelease(t, "3.4.54.longterm-1", &KernelVersionInfo{Kernel: 3, Major: 4, Minor: 54, Flavor: ".longterm-1"}, 0)
|
|
||||||
assertParseRelease(t, "3.4.54.longterm-1", &KernelVersionInfo{Kernel: 3, Major: 4, Minor: 54, Flavor: ".longterm-1"}, 0)
|
|
||||||
assertParseRelease(t, "3.8.0-19-generic", &KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0, Flavor: "-19-generic"}, 0)
|
|
||||||
assertParseRelease(t, "3.12.8tag", &KernelVersionInfo{Kernel: 3, Major: 12, Minor: 8, Flavor: "tag"}, 0)
|
|
||||||
assertParseRelease(t, "3.12-1-amd64", &KernelVersionInfo{Kernel: 3, Major: 12, Minor: 0, Flavor: "-1-amd64"}, 0)
|
|
||||||
assertParseRelease(t, "3.8.0", &KernelVersionInfo{Kernel: 4, Major: 8, Minor: 0}, -1)
|
|
||||||
// Errors
|
|
||||||
invalids := []string{
|
|
||||||
"3",
|
|
||||||
"a",
|
|
||||||
"a.a",
|
|
||||||
"a.a.a-a",
|
|
||||||
}
|
|
||||||
for _, invalid := range invalids {
|
|
||||||
expectedMessage := fmt.Sprintf("Can't parse kernel version %v", invalid)
|
|
||||||
if _, err := ParseRelease(invalid); err == nil || err.Error() != expectedMessage {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertKernelVersion(t *testing.T, a, b *KernelVersionInfo, result int) {
|
|
||||||
if r := CompareKernelVersion(a, b); r != result {
|
|
||||||
t.Fatalf("Unexpected kernel version comparison result. Found %d, expected %d", r, result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCompareKernelVersion(t *testing.T) {
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
0)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 2, Major: 6, Minor: 0},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
-1)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
&KernelVersionInfo{Kernel: 2, Major: 6, Minor: 0},
|
|
||||||
1)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
0)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 5},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
1)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 0, Minor: 20},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
-1)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 7, Minor: 20},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
-1)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 20},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 7, Minor: 0},
|
|
||||||
1)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 20},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
1)
|
|
||||||
assertKernelVersion(t,
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 0},
|
|
||||||
&KernelVersionInfo{Kernel: 3, Major: 8, Minor: 20},
|
|
||||||
-1)
|
|
||||||
}
|
|
65
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel_windows.go
generated
vendored
65
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/kernel_windows.go
generated
vendored
|
@ -1,65 +0,0 @@
|
||||||
package kernel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
type KernelVersionInfo struct {
|
|
||||||
kvi string
|
|
||||||
major int
|
|
||||||
minor int
|
|
||||||
build int
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k *KernelVersionInfo) String() string {
|
|
||||||
return fmt.Sprintf("%d.%d %d (%s)", k.major, k.minor, k.build, k.kvi)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetKernelVersion() (*KernelVersionInfo, error) {
|
|
||||||
|
|
||||||
var (
|
|
||||||
h syscall.Handle
|
|
||||||
dwVersion uint32
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
|
|
||||||
KVI := &KernelVersionInfo{"Unknown", 0, 0, 0}
|
|
||||||
|
|
||||||
if err = syscall.RegOpenKeyEx(syscall.HKEY_LOCAL_MACHINE,
|
|
||||||
syscall.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`),
|
|
||||||
0,
|
|
||||||
syscall.KEY_READ,
|
|
||||||
&h); err != nil {
|
|
||||||
return KVI, err
|
|
||||||
}
|
|
||||||
defer syscall.RegCloseKey(h)
|
|
||||||
|
|
||||||
var buf [1 << 10]uint16
|
|
||||||
var typ uint32
|
|
||||||
n := uint32(len(buf) * 2) // api expects array of bytes, not uint16
|
|
||||||
|
|
||||||
if err = syscall.RegQueryValueEx(h,
|
|
||||||
syscall.StringToUTF16Ptr("BuildLabEx"),
|
|
||||||
nil,
|
|
||||||
&typ,
|
|
||||||
(*byte)(unsafe.Pointer(&buf[0])),
|
|
||||||
&n); err != nil {
|
|
||||||
return KVI, err
|
|
||||||
}
|
|
||||||
|
|
||||||
KVI.kvi = syscall.UTF16ToString(buf[:])
|
|
||||||
|
|
||||||
// Important - docker.exe MUST be manifested for this API to return
|
|
||||||
// the correct information.
|
|
||||||
if dwVersion, err = syscall.GetVersion(); err != nil {
|
|
||||||
return KVI, err
|
|
||||||
}
|
|
||||||
|
|
||||||
KVI.major = int(dwVersion & 0xFF)
|
|
||||||
KVI.minor = int((dwVersion & 0XFF00) >> 8)
|
|
||||||
KVI.build = int((dwVersion & 0xFFFF0000) >> 16)
|
|
||||||
|
|
||||||
return KVI, nil
|
|
||||||
}
|
|
16
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_linux.go
generated
vendored
16
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_linux.go
generated
vendored
|
@ -1,16 +0,0 @@
|
||||||
package kernel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Utsname syscall.Utsname
|
|
||||||
|
|
||||||
func uname() (*syscall.Utsname, error) {
|
|
||||||
uts := &syscall.Utsname{}
|
|
||||||
|
|
||||||
if err := syscall.Uname(uts); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return uts, nil
|
|
||||||
}
|
|
15
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_unsupported.go
generated
vendored
15
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/kernel/uname_unsupported.go
generated
vendored
|
@ -1,15 +0,0 @@
|
||||||
// +build !linux
|
|
||||||
|
|
||||||
package kernel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Utsname struct {
|
|
||||||
Release [65]byte
|
|
||||||
}
|
|
||||||
|
|
||||||
func uname() (*Utsname, error) {
|
|
||||||
return nil, errors.New("Kernel version detection is available only on linux")
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
package operatingsystem
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"io/ioutil"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// file to use to detect if the daemon is running in a container
|
|
||||||
proc1Cgroup = "/proc/1/cgroup"
|
|
||||||
|
|
||||||
// file to check to determine Operating System
|
|
||||||
etcOsRelease = "/etc/os-release"
|
|
||||||
)
|
|
||||||
|
|
||||||
func GetOperatingSystem() (string, error) {
|
|
||||||
b, err := ioutil.ReadFile(etcOsRelease)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if i := bytes.Index(b, []byte("PRETTY_NAME")); i >= 0 {
|
|
||||||
b = b[i+13:]
|
|
||||||
return string(b[:bytes.IndexByte(b, '"')]), nil
|
|
||||||
}
|
|
||||||
return "", errors.New("PRETTY_NAME not found")
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsContainerized() (bool, error) {
|
|
||||||
b, err := ioutil.ReadFile(proc1Cgroup)
|
|
||||||
if err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
for _, line := range bytes.Split(b, []byte{'\n'}) {
|
|
||||||
if len(line) > 0 && !bytes.HasSuffix(line, []byte{'/'}) {
|
|
||||||
return true, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false, nil
|
|
||||||
}
|
|
|
@ -1,124 +0,0 @@
|
||||||
package operatingsystem
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestGetOperatingSystem(t *testing.T) {
|
|
||||||
var (
|
|
||||||
backup = etcOsRelease
|
|
||||||
ubuntuTrusty = []byte(`NAME="Ubuntu"
|
|
||||||
VERSION="14.04, Trusty Tahr"
|
|
||||||
ID=ubuntu
|
|
||||||
ID_LIKE=debian
|
|
||||||
PRETTY_NAME="Ubuntu 14.04 LTS"
|
|
||||||
VERSION_ID="14.04"
|
|
||||||
HOME_URL="http://www.ubuntu.com/"
|
|
||||||
SUPPORT_URL="http://help.ubuntu.com/"
|
|
||||||
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`)
|
|
||||||
gentoo = []byte(`NAME=Gentoo
|
|
||||||
ID=gentoo
|
|
||||||
PRETTY_NAME="Gentoo/Linux"
|
|
||||||
ANSI_COLOR="1;32"
|
|
||||||
HOME_URL="http://www.gentoo.org/"
|
|
||||||
SUPPORT_URL="http://www.gentoo.org/main/en/support.xml"
|
|
||||||
BUG_REPORT_URL="https://bugs.gentoo.org/"
|
|
||||||
`)
|
|
||||||
noPrettyName = []byte(`NAME="Ubuntu"
|
|
||||||
VERSION="14.04, Trusty Tahr"
|
|
||||||
ID=ubuntu
|
|
||||||
ID_LIKE=debian
|
|
||||||
VERSION_ID="14.04"
|
|
||||||
HOME_URL="http://www.ubuntu.com/"
|
|
||||||
SUPPORT_URL="http://help.ubuntu.com/"
|
|
||||||
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`)
|
|
||||||
)
|
|
||||||
|
|
||||||
dir := os.TempDir()
|
|
||||||
etcOsRelease = filepath.Join(dir, "etcOsRelease")
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
os.Remove(etcOsRelease)
|
|
||||||
etcOsRelease = backup
|
|
||||||
}()
|
|
||||||
|
|
||||||
for expect, osRelease := range map[string][]byte{
|
|
||||||
"Ubuntu 14.04 LTS": ubuntuTrusty,
|
|
||||||
"Gentoo/Linux": gentoo,
|
|
||||||
"": noPrettyName,
|
|
||||||
} {
|
|
||||||
if err := ioutil.WriteFile(etcOsRelease, osRelease, 0600); err != nil {
|
|
||||||
t.Fatalf("failed to write to %s: %v", etcOsRelease, err)
|
|
||||||
}
|
|
||||||
s, err := GetOperatingSystem()
|
|
||||||
if s != expect {
|
|
||||||
if expect == "" {
|
|
||||||
t.Fatalf("Expected error 'PRETTY_NAME not found', but got %v", err)
|
|
||||||
} else {
|
|
||||||
t.Fatalf("Expected '%s', but got '%s'. Err=%v", expect, s, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestIsContainerized(t *testing.T) {
|
|
||||||
var (
|
|
||||||
backup = proc1Cgroup
|
|
||||||
nonContainerizedProc1Cgroup = []byte(`14:name=systemd:/
|
|
||||||
13:hugetlb:/
|
|
||||||
12:net_prio:/
|
|
||||||
11:perf_event:/
|
|
||||||
10:bfqio:/
|
|
||||||
9:blkio:/
|
|
||||||
8:net_cls:/
|
|
||||||
7:freezer:/
|
|
||||||
6:devices:/
|
|
||||||
5:memory:/
|
|
||||||
4:cpuacct:/
|
|
||||||
3:cpu:/
|
|
||||||
2:cpuset:/
|
|
||||||
`)
|
|
||||||
containerizedProc1Cgroup = []byte(`9:perf_event:/docker/3cef1b53c50b0fa357d994f8a1a8cd783c76bbf4f5dd08b226e38a8bd331338d
|
|
||||||
8:blkio:/docker/3cef1b53c50b0fa357d994f8a1a8cd783c76bbf4f5dd08b226e38a8bd331338d
|
|
||||||
7:net_cls:/
|
|
||||||
6:freezer:/docker/3cef1b53c50b0fa357d994f8a1a8cd783c76bbf4f5dd08b226e38a8bd331338d
|
|
||||||
5:devices:/docker/3cef1b53c50b0fa357d994f8a1a8cd783c76bbf4f5dd08b226e38a8bd331338d
|
|
||||||
4:memory:/docker/3cef1b53c50b0fa357d994f8a1a8cd783c76bbf4f5dd08b226e38a8bd331338d
|
|
||||||
3:cpuacct:/docker/3cef1b53c50b0fa357d994f8a1a8cd783c76bbf4f5dd08b226e38a8bd331338d
|
|
||||||
2:cpu:/docker/3cef1b53c50b0fa357d994f8a1a8cd783c76bbf4f5dd08b226e38a8bd331338d
|
|
||||||
1:cpuset:/`)
|
|
||||||
)
|
|
||||||
|
|
||||||
dir := os.TempDir()
|
|
||||||
proc1Cgroup = filepath.Join(dir, "proc1Cgroup")
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
os.Remove(proc1Cgroup)
|
|
||||||
proc1Cgroup = backup
|
|
||||||
}()
|
|
||||||
|
|
||||||
if err := ioutil.WriteFile(proc1Cgroup, nonContainerizedProc1Cgroup, 0600); err != nil {
|
|
||||||
t.Fatalf("failed to write to %s: %v", proc1Cgroup, err)
|
|
||||||
}
|
|
||||||
inContainer, err := IsContainerized()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if inContainer {
|
|
||||||
t.Fatal("Wrongly assuming containerized")
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := ioutil.WriteFile(proc1Cgroup, containerizedProc1Cgroup, 0600); err != nil {
|
|
||||||
t.Fatalf("failed to write to %s: %v", proc1Cgroup, err)
|
|
||||||
}
|
|
||||||
inContainer, err = IsContainerized()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if !inContainer {
|
|
||||||
t.Fatal("Wrongly assuming non-containerized")
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
package operatingsystem
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
|
||||||
)
|
|
||||||
|
|
||||||
// See https://code.google.com/p/go/source/browse/src/pkg/mime/type_windows.go?r=d14520ac25bf6940785aabb71f5be453a286f58c
|
|
||||||
// for a similar sample
|
|
||||||
|
|
||||||
func GetOperatingSystem() (string, error) {
|
|
||||||
|
|
||||||
var h syscall.Handle
|
|
||||||
|
|
||||||
// Default return value
|
|
||||||
ret := "Unknown Operating System"
|
|
||||||
|
|
||||||
if err := syscall.RegOpenKeyEx(syscall.HKEY_LOCAL_MACHINE,
|
|
||||||
syscall.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`),
|
|
||||||
0,
|
|
||||||
syscall.KEY_READ,
|
|
||||||
&h); err != nil {
|
|
||||||
return ret, err
|
|
||||||
}
|
|
||||||
defer syscall.RegCloseKey(h)
|
|
||||||
|
|
||||||
var buf [1 << 10]uint16
|
|
||||||
var typ uint32
|
|
||||||
n := uint32(len(buf) * 2) // api expects array of bytes, not uint16
|
|
||||||
|
|
||||||
if err := syscall.RegQueryValueEx(h,
|
|
||||||
syscall.StringToUTF16Ptr("ProductName"),
|
|
||||||
nil,
|
|
||||||
&typ,
|
|
||||||
(*byte)(unsafe.Pointer(&buf[0])),
|
|
||||||
&n); err != nil {
|
|
||||||
return ret, err
|
|
||||||
}
|
|
||||||
ret = syscall.UTF16ToString(buf[:])
|
|
||||||
|
|
||||||
return ret, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// No-op on Windows
|
|
||||||
func IsContainerized() (bool, error) {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
210
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/parsers_test.go
generated
vendored
210
Godeps/_workspace/src/github.com/docker/docker/pkg/parsers/parsers_test.go
generated
vendored
|
@ -1,210 +0,0 @@
|
||||||
package parsers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestParseHost(t *testing.T) {
|
|
||||||
var (
|
|
||||||
defaultHttpHost = "127.0.0.1"
|
|
||||||
defaultUnix = "/var/run/docker.sock"
|
|
||||||
)
|
|
||||||
invalids := map[string]string{
|
|
||||||
"0.0.0.0": "Invalid bind address format: 0.0.0.0",
|
|
||||||
"tcp://": "Invalid proto, expected tcp: ",
|
|
||||||
"tcp:a.b.c.d": "Invalid bind address format: tcp:a.b.c.d",
|
|
||||||
"tcp:a.b.c.d/path": "Invalid bind address format: tcp:a.b.c.d/path",
|
|
||||||
"udp://127.0.0.1": "Invalid bind address format: udp://127.0.0.1",
|
|
||||||
"udp://127.0.0.1:2375": "Invalid bind address format: udp://127.0.0.1:2375",
|
|
||||||
}
|
|
||||||
valids := map[string]string{
|
|
||||||
"0.0.0.1:5555": "tcp://0.0.0.1:5555",
|
|
||||||
"0.0.0.1:5555/path": "tcp://0.0.0.1:5555/path",
|
|
||||||
":6666": "tcp://127.0.0.1:6666",
|
|
||||||
":6666/path": "tcp://127.0.0.1:6666/path",
|
|
||||||
"tcp://:7777": "tcp://127.0.0.1:7777",
|
|
||||||
"tcp://:7777/path": "tcp://127.0.0.1:7777/path",
|
|
||||||
"": "unix:///var/run/docker.sock",
|
|
||||||
"unix:///run/docker.sock": "unix:///run/docker.sock",
|
|
||||||
"unix://": "unix:///var/run/docker.sock",
|
|
||||||
"fd://": "fd://",
|
|
||||||
"fd://something": "fd://something",
|
|
||||||
}
|
|
||||||
for invalidAddr, expectedError := range invalids {
|
|
||||||
if addr, err := ParseHost(defaultHttpHost, defaultUnix, invalidAddr); err == nil || err.Error() != expectedError {
|
|
||||||
t.Errorf("tcp %v address expected error %v return, got %s and addr %v", invalidAddr, expectedError, err, addr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for validAddr, expectedAddr := range valids {
|
|
||||||
if addr, err := ParseHost(defaultHttpHost, defaultUnix, validAddr); err != nil || addr != expectedAddr {
|
|
||||||
t.Errorf("%v -> expected %v, got %v", validAddr, expectedAddr, addr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseInvalidUnixAddrInvalid(t *testing.T) {
|
|
||||||
if _, err := ParseUnixAddr("unix://tcp://127.0.0.1", "unix:///var/run/docker.sock"); err == nil || err.Error() != "Invalid proto, expected unix: tcp://127.0.0.1" {
|
|
||||||
t.Fatalf("Expected an error, got %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseRepositoryTag(t *testing.T) {
|
|
||||||
if repo, tag := ParseRepositoryTag("root"); repo != "root" || tag != "" {
|
|
||||||
t.Errorf("Expected repo: '%s' and tag: '%s', got '%s' and '%s'", "root", "", repo, tag)
|
|
||||||
}
|
|
||||||
if repo, tag := ParseRepositoryTag("root:tag"); repo != "root" || tag != "tag" {
|
|
||||||
t.Errorf("Expected repo: '%s' and tag: '%s', got '%s' and '%s'", "root", "tag", repo, tag)
|
|
||||||
}
|
|
||||||
if repo, digest := ParseRepositoryTag("root@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); repo != "root" || digest != "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" {
|
|
||||||
t.Errorf("Expected repo: '%s' and digest: '%s', got '%s' and '%s'", "root", "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", repo, digest)
|
|
||||||
}
|
|
||||||
if repo, tag := ParseRepositoryTag("user/repo"); repo != "user/repo" || tag != "" {
|
|
||||||
t.Errorf("Expected repo: '%s' and tag: '%s', got '%s' and '%s'", "user/repo", "", repo, tag)
|
|
||||||
}
|
|
||||||
if repo, tag := ParseRepositoryTag("user/repo:tag"); repo != "user/repo" || tag != "tag" {
|
|
||||||
t.Errorf("Expected repo: '%s' and tag: '%s', got '%s' and '%s'", "user/repo", "tag", repo, tag)
|
|
||||||
}
|
|
||||||
if repo, digest := ParseRepositoryTag("user/repo@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); repo != "user/repo" || digest != "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" {
|
|
||||||
t.Errorf("Expected repo: '%s' and digest: '%s', got '%s' and '%s'", "user/repo", "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", repo, digest)
|
|
||||||
}
|
|
||||||
if repo, tag := ParseRepositoryTag("url:5000/repo"); repo != "url:5000/repo" || tag != "" {
|
|
||||||
t.Errorf("Expected repo: '%s' and tag: '%s', got '%s' and '%s'", "url:5000/repo", "", repo, tag)
|
|
||||||
}
|
|
||||||
if repo, tag := ParseRepositoryTag("url:5000/repo:tag"); repo != "url:5000/repo" || tag != "tag" {
|
|
||||||
t.Errorf("Expected repo: '%s' and tag: '%s', got '%s' and '%s'", "url:5000/repo", "tag", repo, tag)
|
|
||||||
}
|
|
||||||
if repo, digest := ParseRepositoryTag("url:5000/repo@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); repo != "url:5000/repo" || digest != "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" {
|
|
||||||
t.Errorf("Expected repo: '%s' and digest: '%s', got '%s' and '%s'", "url:5000/repo", "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", repo, digest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParsePortMapping(t *testing.T) {
|
|
||||||
if _, err := PartParser("ip:public:private", "192.168.1.1:80"); err == nil {
|
|
||||||
t.Fatalf("Expected an error, got %v", err)
|
|
||||||
}
|
|
||||||
data, err := PartParser("ip:public:private", "192.168.1.1:80:8080")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(data) != 3 {
|
|
||||||
t.FailNow()
|
|
||||||
}
|
|
||||||
if data["ip"] != "192.168.1.1" {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
if data["public"] != "80" {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
if data["private"] != "8080" {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseKeyValueOpt(t *testing.T) {
|
|
||||||
invalids := map[string]string{
|
|
||||||
"": "Unable to parse key/value option: ",
|
|
||||||
"key": "Unable to parse key/value option: key",
|
|
||||||
}
|
|
||||||
for invalid, expectedError := range invalids {
|
|
||||||
if _, _, err := ParseKeyValueOpt(invalid); err == nil || err.Error() != expectedError {
|
|
||||||
t.Fatalf("Expected error %v for %v, got %v", expectedError, invalid, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
valids := map[string][]string{
|
|
||||||
"key=value": {"key", "value"},
|
|
||||||
" key = value ": {"key", "value"},
|
|
||||||
"key=value1=value2": {"key", "value1=value2"},
|
|
||||||
" key = value1 = value2 ": {"key", "value1 = value2"},
|
|
||||||
}
|
|
||||||
for valid, expectedKeyValue := range valids {
|
|
||||||
key, value, err := ParseKeyValueOpt(valid)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if key != expectedKeyValue[0] || value != expectedKeyValue[1] {
|
|
||||||
t.Fatalf("Expected {%v: %v} got {%v: %v}", expectedKeyValue[0], expectedKeyValue[1], key, value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParsePortRange(t *testing.T) {
|
|
||||||
if start, end, err := ParsePortRange("8000-8080"); err != nil || start != 8000 || end != 8080 {
|
|
||||||
t.Fatalf("Error: %s or Expecting {start,end} values {8000,8080} but found {%d,%d}.", err, start, end)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParsePortRangeEmpty(t *testing.T) {
|
|
||||||
if _, _, err := ParsePortRange(""); err == nil || err.Error() != "Empty string specified for ports." {
|
|
||||||
t.Fatalf("Expected error 'Empty string specified for ports.', got %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParsePortRangeWithNoRange(t *testing.T) {
|
|
||||||
start, end, err := ParsePortRange("8080")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if start != 8080 || end != 8080 {
|
|
||||||
t.Fatalf("Expected start and end to be the same and equal to 8080, but were %v and %v", start, end)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParsePortRangeIncorrectRange(t *testing.T) {
|
|
||||||
if _, _, err := ParsePortRange("9000-8080"); err == nil || !strings.Contains(err.Error(), "Invalid range specified for the Port") {
|
|
||||||
t.Fatalf("Expecting error 'Invalid range specified for the Port' but received %s.", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParsePortRangeIncorrectEndRange(t *testing.T) {
|
|
||||||
if _, _, err := ParsePortRange("8000-a"); err == nil || !strings.Contains(err.Error(), "invalid syntax") {
|
|
||||||
t.Fatalf("Expecting error 'Invalid range specified for the Port' but received %s.", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, _, err := ParsePortRange("8000-30a"); err == nil || !strings.Contains(err.Error(), "invalid syntax") {
|
|
||||||
t.Fatalf("Expecting error 'Invalid range specified for the Port' but received %s.", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParsePortRangeIncorrectStartRange(t *testing.T) {
|
|
||||||
if _, _, err := ParsePortRange("a-8000"); err == nil || !strings.Contains(err.Error(), "invalid syntax") {
|
|
||||||
t.Fatalf("Expecting error 'Invalid range specified for the Port' but received %s.", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, _, err := ParsePortRange("30a-8000"); err == nil || !strings.Contains(err.Error(), "invalid syntax") {
|
|
||||||
t.Fatalf("Expecting error 'Invalid range specified for the Port' but received %s.", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseLink(t *testing.T) {
|
|
||||||
name, alias, err := ParseLink("name:alias")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Expected not to error out on a valid name:alias format but got: %v", err)
|
|
||||||
}
|
|
||||||
if name != "name" {
|
|
||||||
t.Fatalf("Link name should have been name, got %s instead", name)
|
|
||||||
}
|
|
||||||
if alias != "alias" {
|
|
||||||
t.Fatalf("Link alias should have been alias, got %s instead", alias)
|
|
||||||
}
|
|
||||||
// short format definition
|
|
||||||
name, alias, err = ParseLink("name")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Expected not to error out on a valid name only format but got: %v", err)
|
|
||||||
}
|
|
||||||
if name != "name" {
|
|
||||||
t.Fatalf("Link name should have been name, got %s instead", name)
|
|
||||||
}
|
|
||||||
if alias != "name" {
|
|
||||||
t.Fatalf("Link alias should have been name, got %s instead", alias)
|
|
||||||
}
|
|
||||||
// empty string link definition is not allowed
|
|
||||||
if _, _, err := ParseLink(""); err == nil || !strings.Contains(err.Error(), "empty string specified for links") {
|
|
||||||
t.Fatalf("Expected error 'empty string specified for links' but got: %v", err)
|
|
||||||
}
|
|
||||||
// more than two colons are not allowed
|
|
||||||
if _, _, err := ParseLink("link:alias:wrong"); err == nil || !strings.Contains(err.Error(), "bad format for links: link:alias:wrong") {
|
|
||||||
t.Fatalf("Expected error 'bad format for links: link:alias:wrong' but got: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
81
Godeps/_workspace/src/github.com/docker/go-units/duration_test.go
generated
vendored
81
Godeps/_workspace/src/github.com/docker/go-units/duration_test.go
generated
vendored
|
@ -1,81 +0,0 @@
|
||||||
package units
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ExampleHumanDuration() {
|
|
||||||
fmt.Println(HumanDuration(450 * time.Millisecond))
|
|
||||||
fmt.Println(HumanDuration(47 * time.Second))
|
|
||||||
fmt.Println(HumanDuration(1 * time.Minute))
|
|
||||||
fmt.Println(HumanDuration(3 * time.Minute))
|
|
||||||
fmt.Println(HumanDuration(35 * time.Minute))
|
|
||||||
fmt.Println(HumanDuration(35*time.Minute + 40*time.Second))
|
|
||||||
fmt.Println(HumanDuration(1 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(1*time.Hour + 45*time.Minute))
|
|
||||||
fmt.Println(HumanDuration(3 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(3*time.Hour + 59*time.Minute))
|
|
||||||
fmt.Println(HumanDuration(3*time.Hour + 60*time.Minute))
|
|
||||||
fmt.Println(HumanDuration(24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(24*time.Hour + 12*time.Hour))
|
|
||||||
fmt.Println(HumanDuration(2 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(7 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(13*24*time.Hour + 5*time.Hour))
|
|
||||||
fmt.Println(HumanDuration(2 * 7 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(2*7*24*time.Hour + 4*24*time.Hour))
|
|
||||||
fmt.Println(HumanDuration(3 * 7 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(4 * 7 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(4*7*24*time.Hour + 3*24*time.Hour))
|
|
||||||
fmt.Println(HumanDuration(1 * 30 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(1*30*24*time.Hour + 2*7*24*time.Hour))
|
|
||||||
fmt.Println(HumanDuration(2 * 30 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(3*30*24*time.Hour + 1*7*24*time.Hour))
|
|
||||||
fmt.Println(HumanDuration(5*30*24*time.Hour + 2*7*24*time.Hour))
|
|
||||||
fmt.Println(HumanDuration(13 * 30 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(23 * 30 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(24 * 30 * 24 * time.Hour))
|
|
||||||
fmt.Println(HumanDuration(24*30*24*time.Hour + 2*7*24*time.Hour))
|
|
||||||
fmt.Println(HumanDuration(3*365*24*time.Hour + 2*30*24*time.Hour))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHumanDuration(t *testing.T) {
|
|
||||||
// Useful duration abstractions
|
|
||||||
day := 24 * time.Hour
|
|
||||||
week := 7 * day
|
|
||||||
month := 30 * day
|
|
||||||
year := 365 * day
|
|
||||||
|
|
||||||
assertEquals(t, "Less than a second", HumanDuration(450*time.Millisecond))
|
|
||||||
assertEquals(t, "47 seconds", HumanDuration(47*time.Second))
|
|
||||||
assertEquals(t, "About a minute", HumanDuration(1*time.Minute))
|
|
||||||
assertEquals(t, "3 minutes", HumanDuration(3*time.Minute))
|
|
||||||
assertEquals(t, "35 minutes", HumanDuration(35*time.Minute))
|
|
||||||
assertEquals(t, "35 minutes", HumanDuration(35*time.Minute+40*time.Second))
|
|
||||||
assertEquals(t, "About an hour", HumanDuration(1*time.Hour))
|
|
||||||
assertEquals(t, "About an hour", HumanDuration(1*time.Hour+45*time.Minute))
|
|
||||||
assertEquals(t, "3 hours", HumanDuration(3*time.Hour))
|
|
||||||
assertEquals(t, "3 hours", HumanDuration(3*time.Hour+59*time.Minute))
|
|
||||||
assertEquals(t, "4 hours", HumanDuration(3*time.Hour+60*time.Minute))
|
|
||||||
assertEquals(t, "24 hours", HumanDuration(24*time.Hour))
|
|
||||||
assertEquals(t, "36 hours", HumanDuration(1*day+12*time.Hour))
|
|
||||||
assertEquals(t, "2 days", HumanDuration(2*day))
|
|
||||||
assertEquals(t, "7 days", HumanDuration(7*day))
|
|
||||||
assertEquals(t, "13 days", HumanDuration(13*day+5*time.Hour))
|
|
||||||
assertEquals(t, "2 weeks", HumanDuration(2*week))
|
|
||||||
assertEquals(t, "2 weeks", HumanDuration(2*week+4*day))
|
|
||||||
assertEquals(t, "3 weeks", HumanDuration(3*week))
|
|
||||||
assertEquals(t, "4 weeks", HumanDuration(4*week))
|
|
||||||
assertEquals(t, "4 weeks", HumanDuration(4*week+3*day))
|
|
||||||
assertEquals(t, "4 weeks", HumanDuration(1*month))
|
|
||||||
assertEquals(t, "6 weeks", HumanDuration(1*month+2*week))
|
|
||||||
assertEquals(t, "8 weeks", HumanDuration(2*month))
|
|
||||||
assertEquals(t, "3 months", HumanDuration(3*month+1*week))
|
|
||||||
assertEquals(t, "5 months", HumanDuration(5*month+2*week))
|
|
||||||
assertEquals(t, "13 months", HumanDuration(13*month))
|
|
||||||
assertEquals(t, "23 months", HumanDuration(23*month))
|
|
||||||
assertEquals(t, "24 months", HumanDuration(24*month))
|
|
||||||
assertEquals(t, "2 years", HumanDuration(24*month+2*week))
|
|
||||||
assertEquals(t, "3 years", HumanDuration(3*year+2*month))
|
|
||||||
}
|
|
160
Godeps/_workspace/src/github.com/docker/go-units/size_test.go
generated
vendored
160
Godeps/_workspace/src/github.com/docker/go-units/size_test.go
generated
vendored
|
@ -1,160 +0,0 @@
|
||||||
package units
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"runtime"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ExampleBytesSize() {
|
|
||||||
fmt.Println(BytesSize(1024))
|
|
||||||
fmt.Println(BytesSize(1024 * 1024))
|
|
||||||
fmt.Println(BytesSize(1048576))
|
|
||||||
fmt.Println(BytesSize(2 * MiB))
|
|
||||||
fmt.Println(BytesSize(3.42 * GiB))
|
|
||||||
fmt.Println(BytesSize(5.372 * TiB))
|
|
||||||
fmt.Println(BytesSize(2.22 * PiB))
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExampleHumanSize() {
|
|
||||||
fmt.Println(HumanSize(1000))
|
|
||||||
fmt.Println(HumanSize(1024))
|
|
||||||
fmt.Println(HumanSize(1000000))
|
|
||||||
fmt.Println(HumanSize(1048576))
|
|
||||||
fmt.Println(HumanSize(2 * MB))
|
|
||||||
fmt.Println(HumanSize(float64(3.42 * GB)))
|
|
||||||
fmt.Println(HumanSize(float64(5.372 * TB)))
|
|
||||||
fmt.Println(HumanSize(float64(2.22 * PB)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExampleFromHumanSize() {
|
|
||||||
fmt.Println(FromHumanSize("32"))
|
|
||||||
fmt.Println(FromHumanSize("32b"))
|
|
||||||
fmt.Println(FromHumanSize("32B"))
|
|
||||||
fmt.Println(FromHumanSize("32k"))
|
|
||||||
fmt.Println(FromHumanSize("32K"))
|
|
||||||
fmt.Println(FromHumanSize("32kb"))
|
|
||||||
fmt.Println(FromHumanSize("32Kb"))
|
|
||||||
fmt.Println(FromHumanSize("32Mb"))
|
|
||||||
fmt.Println(FromHumanSize("32Gb"))
|
|
||||||
fmt.Println(FromHumanSize("32Tb"))
|
|
||||||
fmt.Println(FromHumanSize("32Pb"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExampleRAMInBytes() {
|
|
||||||
fmt.Println(RAMInBytes("32"))
|
|
||||||
fmt.Println(RAMInBytes("32b"))
|
|
||||||
fmt.Println(RAMInBytes("32B"))
|
|
||||||
fmt.Println(RAMInBytes("32k"))
|
|
||||||
fmt.Println(RAMInBytes("32K"))
|
|
||||||
fmt.Println(RAMInBytes("32kb"))
|
|
||||||
fmt.Println(RAMInBytes("32Kb"))
|
|
||||||
fmt.Println(RAMInBytes("32Mb"))
|
|
||||||
fmt.Println(RAMInBytes("32Gb"))
|
|
||||||
fmt.Println(RAMInBytes("32Tb"))
|
|
||||||
fmt.Println(RAMInBytes("32Pb"))
|
|
||||||
fmt.Println(RAMInBytes("32PB"))
|
|
||||||
fmt.Println(RAMInBytes("32P"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBytesSize(t *testing.T) {
|
|
||||||
assertEquals(t, "1 KiB", BytesSize(1024))
|
|
||||||
assertEquals(t, "1 MiB", BytesSize(1024*1024))
|
|
||||||
assertEquals(t, "1 MiB", BytesSize(1048576))
|
|
||||||
assertEquals(t, "2 MiB", BytesSize(2*MiB))
|
|
||||||
assertEquals(t, "3.42 GiB", BytesSize(3.42*GiB))
|
|
||||||
assertEquals(t, "5.372 TiB", BytesSize(5.372*TiB))
|
|
||||||
assertEquals(t, "2.22 PiB", BytesSize(2.22*PiB))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestHumanSize(t *testing.T) {
|
|
||||||
assertEquals(t, "1 kB", HumanSize(1000))
|
|
||||||
assertEquals(t, "1.024 kB", HumanSize(1024))
|
|
||||||
assertEquals(t, "1 MB", HumanSize(1000000))
|
|
||||||
assertEquals(t, "1.049 MB", HumanSize(1048576))
|
|
||||||
assertEquals(t, "2 MB", HumanSize(2*MB))
|
|
||||||
assertEquals(t, "3.42 GB", HumanSize(float64(3.42*GB)))
|
|
||||||
assertEquals(t, "5.372 TB", HumanSize(float64(5.372*TB)))
|
|
||||||
assertEquals(t, "2.22 PB", HumanSize(float64(2.22*PB)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFromHumanSize(t *testing.T) {
|
|
||||||
assertSuccessEquals(t, 32, FromHumanSize, "32")
|
|
||||||
assertSuccessEquals(t, 32, FromHumanSize, "32b")
|
|
||||||
assertSuccessEquals(t, 32, FromHumanSize, "32B")
|
|
||||||
assertSuccessEquals(t, 32*KB, FromHumanSize, "32k")
|
|
||||||
assertSuccessEquals(t, 32*KB, FromHumanSize, "32K")
|
|
||||||
assertSuccessEquals(t, 32*KB, FromHumanSize, "32kb")
|
|
||||||
assertSuccessEquals(t, 32*KB, FromHumanSize, "32Kb")
|
|
||||||
assertSuccessEquals(t, 32*MB, FromHumanSize, "32Mb")
|
|
||||||
assertSuccessEquals(t, 32*GB, FromHumanSize, "32Gb")
|
|
||||||
assertSuccessEquals(t, 32*TB, FromHumanSize, "32Tb")
|
|
||||||
assertSuccessEquals(t, 32*PB, FromHumanSize, "32Pb")
|
|
||||||
|
|
||||||
assertError(t, FromHumanSize, "")
|
|
||||||
assertError(t, FromHumanSize, "hello")
|
|
||||||
assertError(t, FromHumanSize, "-32")
|
|
||||||
assertError(t, FromHumanSize, "32.3")
|
|
||||||
assertError(t, FromHumanSize, " 32 ")
|
|
||||||
assertError(t, FromHumanSize, "32.3Kb")
|
|
||||||
assertError(t, FromHumanSize, "32 mb")
|
|
||||||
assertError(t, FromHumanSize, "32m b")
|
|
||||||
assertError(t, FromHumanSize, "32bm")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRAMInBytes(t *testing.T) {
|
|
||||||
assertSuccessEquals(t, 32, RAMInBytes, "32")
|
|
||||||
assertSuccessEquals(t, 32, RAMInBytes, "32b")
|
|
||||||
assertSuccessEquals(t, 32, RAMInBytes, "32B")
|
|
||||||
assertSuccessEquals(t, 32*KiB, RAMInBytes, "32k")
|
|
||||||
assertSuccessEquals(t, 32*KiB, RAMInBytes, "32K")
|
|
||||||
assertSuccessEquals(t, 32*KiB, RAMInBytes, "32kb")
|
|
||||||
assertSuccessEquals(t, 32*KiB, RAMInBytes, "32Kb")
|
|
||||||
assertSuccessEquals(t, 32*MiB, RAMInBytes, "32Mb")
|
|
||||||
assertSuccessEquals(t, 32*GiB, RAMInBytes, "32Gb")
|
|
||||||
assertSuccessEquals(t, 32*TiB, RAMInBytes, "32Tb")
|
|
||||||
assertSuccessEquals(t, 32*PiB, RAMInBytes, "32Pb")
|
|
||||||
assertSuccessEquals(t, 32*PiB, RAMInBytes, "32PB")
|
|
||||||
assertSuccessEquals(t, 32*PiB, RAMInBytes, "32P")
|
|
||||||
|
|
||||||
assertError(t, RAMInBytes, "")
|
|
||||||
assertError(t, RAMInBytes, "hello")
|
|
||||||
assertError(t, RAMInBytes, "-32")
|
|
||||||
assertError(t, RAMInBytes, "32.3")
|
|
||||||
assertError(t, RAMInBytes, " 32 ")
|
|
||||||
assertError(t, RAMInBytes, "32.3Kb")
|
|
||||||
assertError(t, RAMInBytes, "32 mb")
|
|
||||||
assertError(t, RAMInBytes, "32m b")
|
|
||||||
assertError(t, RAMInBytes, "32bm")
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertEquals(t *testing.T, expected, actual interface{}) {
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("Expected '%v' but got '%v'", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// func that maps to the parse function signatures as testing abstraction
|
|
||||||
type parseFn func(string) (int64, error)
|
|
||||||
|
|
||||||
// Define 'String()' for pretty-print
|
|
||||||
func (fn parseFn) String() string {
|
|
||||||
fnName := runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name()
|
|
||||||
return fnName[strings.LastIndex(fnName, ".")+1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertSuccessEquals(t *testing.T, expected int64, fn parseFn, arg string) {
|
|
||||||
res, err := fn(arg)
|
|
||||||
if err != nil || res != expected {
|
|
||||||
t.Errorf("%s(\"%s\") -> expected '%d' but got '%d' with error '%v'", fn, arg, expected, res, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertError(t *testing.T, fn parseFn, arg string) {
|
|
||||||
res, err := fn(arg)
|
|
||||||
if err == nil && res != -1 {
|
|
||||||
t.Errorf("%s(\"%s\") -> expected error but got '%d'", fn, arg, res)
|
|
||||||
}
|
|
||||||
}
|
|
74
Godeps/_workspace/src/github.com/docker/go-units/ulimit_test.go
generated
vendored
74
Godeps/_workspace/src/github.com/docker/go-units/ulimit_test.go
generated
vendored
|
@ -1,74 +0,0 @@
|
||||||
package units
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ExampleParseUlimit() {
|
|
||||||
fmt.Println(ParseUlimit("nofile=512:1024"))
|
|
||||||
fmt.Println(ParseUlimit("nofile=1024"))
|
|
||||||
fmt.Println(ParseUlimit("cpu=2:4"))
|
|
||||||
fmt.Println(ParseUlimit("cpu=6"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseUlimitValid(t *testing.T) {
|
|
||||||
u1 := &Ulimit{"nofile", 1024, 512}
|
|
||||||
if u2, _ := ParseUlimit("nofile=512:1024"); *u1 != *u2 {
|
|
||||||
t.Fatalf("expected %q, but got %q", u1, u2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseUlimitInvalidLimitType(t *testing.T) {
|
|
||||||
if _, err := ParseUlimit("notarealtype=1024:1024"); err == nil {
|
|
||||||
t.Fatalf("expected error on invalid ulimit type")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseUlimitBadFormat(t *testing.T) {
|
|
||||||
if _, err := ParseUlimit("nofile:1024:1024"); err == nil {
|
|
||||||
t.Fatal("expected error on bad syntax")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := ParseUlimit("nofile"); err == nil {
|
|
||||||
t.Fatal("expected error on bad syntax")
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := ParseUlimit("nofile="); err == nil {
|
|
||||||
t.Fatal("expected error on bad syntax")
|
|
||||||
}
|
|
||||||
if _, err := ParseUlimit("nofile=:"); err == nil {
|
|
||||||
t.Fatal("expected error on bad syntax")
|
|
||||||
}
|
|
||||||
if _, err := ParseUlimit("nofile=:1024"); err == nil {
|
|
||||||
t.Fatal("expected error on bad syntax")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseUlimitHardLessThanSoft(t *testing.T) {
|
|
||||||
if _, err := ParseUlimit("nofile=1024:1"); err == nil {
|
|
||||||
t.Fatal("expected error on hard limit less than soft limit")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseUlimitInvalidValueType(t *testing.T) {
|
|
||||||
if _, err := ParseUlimit("nofile=asdf"); err == nil {
|
|
||||||
t.Fatal("expected error on bad value type, but got no error")
|
|
||||||
} else if _, ok := err.(*strconv.NumError); !ok {
|
|
||||||
t.Fatalf("expected error on bad value type, but got `%s`", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := ParseUlimit("nofile=1024:asdf"); err == nil {
|
|
||||||
t.Fatal("expected error on bad value type, but got no error")
|
|
||||||
} else if _, ok := err.(*strconv.NumError); !ok {
|
|
||||||
t.Fatalf("expected error on bad value type, but got `%s`", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUlimitStringOutput(t *testing.T) {
|
|
||||||
u := &Ulimit{"nofile", 1024, 512}
|
|
||||||
if s := u.String(); s != "nofile=512:1024" {
|
|
||||||
t.Fatal("expected String to return nofile=512:1024, but got", s)
|
|
||||||
}
|
|
||||||
}
|
|
51
Godeps/_workspace/src/github.com/emicklei/go-restful/bench_curly_test.go
generated
vendored
51
Godeps/_workspace/src/github.com/emicklei/go-restful/bench_curly_test.go
generated
vendored
|
@ -1,51 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setupCurly(container *Container) []string {
|
|
||||||
wsCount := 26
|
|
||||||
rtCount := 26
|
|
||||||
urisCurly := []string{}
|
|
||||||
|
|
||||||
container.Router(CurlyRouter{})
|
|
||||||
for i := 0; i < wsCount; i++ {
|
|
||||||
root := fmt.Sprintf("/%s/{%s}/", string(i+97), string(i+97))
|
|
||||||
ws := new(WebService).Path(root)
|
|
||||||
for j := 0; j < rtCount; j++ {
|
|
||||||
sub := fmt.Sprintf("/%s2/{%s2}", string(j+97), string(j+97))
|
|
||||||
ws.Route(ws.GET(sub).Consumes("application/xml").Produces("application/xml").To(echoCurly))
|
|
||||||
}
|
|
||||||
container.Add(ws)
|
|
||||||
for _, each := range ws.Routes() {
|
|
||||||
urisCurly = append(urisCurly, "http://bench.com"+each.Path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return urisCurly
|
|
||||||
}
|
|
||||||
|
|
||||||
func echoCurly(req *Request, resp *Response) {}
|
|
||||||
|
|
||||||
func BenchmarkManyCurly(b *testing.B) {
|
|
||||||
container := NewContainer()
|
|
||||||
urisCurly := setupCurly(container)
|
|
||||||
b.ResetTimer()
|
|
||||||
for t := 0; t < b.N; t++ {
|
|
||||||
for r := 0; r < 1000; r++ {
|
|
||||||
for _, each := range urisCurly {
|
|
||||||
sendNoReturnTo(each, container, t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func sendNoReturnTo(address string, container *Container, t int) {
|
|
||||||
httpRequest, _ := http.NewRequest("GET", address, nil)
|
|
||||||
httpRequest.Header.Set("Accept", "application/xml")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
container.dispatch(httpWriter, httpRequest)
|
|
||||||
}
|
|
43
Godeps/_workspace/src/github.com/emicklei/go-restful/bench_test.go
generated
vendored
43
Godeps/_workspace/src/github.com/emicklei/go-restful/bench_test.go
generated
vendored
|
@ -1,43 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
var uris = []string{}
|
|
||||||
|
|
||||||
func setup(container *Container) {
|
|
||||||
wsCount := 26
|
|
||||||
rtCount := 26
|
|
||||||
|
|
||||||
for i := 0; i < wsCount; i++ {
|
|
||||||
root := fmt.Sprintf("/%s/{%s}/", string(i+97), string(i+97))
|
|
||||||
ws := new(WebService).Path(root)
|
|
||||||
for j := 0; j < rtCount; j++ {
|
|
||||||
sub := fmt.Sprintf("/%s2/{%s2}", string(j+97), string(j+97))
|
|
||||||
ws.Route(ws.GET(sub).To(echo))
|
|
||||||
}
|
|
||||||
container.Add(ws)
|
|
||||||
for _, each := range ws.Routes() {
|
|
||||||
uris = append(uris, "http://bench.com"+each.Path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func echo(req *Request, resp *Response) {
|
|
||||||
io.WriteString(resp.ResponseWriter, "echo")
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkMany(b *testing.B) {
|
|
||||||
container := NewContainer()
|
|
||||||
setup(container)
|
|
||||||
b.ResetTimer()
|
|
||||||
for t := 0; t < b.N; t++ {
|
|
||||||
for _, each := range uris {
|
|
||||||
// println(each)
|
|
||||||
sendItTo(each, container)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
127
Godeps/_workspace/src/github.com/emicklei/go-restful/compress_test.go
generated
vendored
127
Godeps/_workspace/src/github.com/emicklei/go-restful/compress_test.go
generated
vendored
|
@ -1,127 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"compress/gzip"
|
|
||||||
"compress/zlib"
|
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// go test -v -test.run TestGzip ...restful
|
|
||||||
func TestGzip(t *testing.T) {
|
|
||||||
EnableContentEncoding = true
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", nil)
|
|
||||||
httpRequest.Header.Set("Accept-Encoding", "gzip,deflate")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
wanted, encoding := wantsCompressedResponse(httpRequest)
|
|
||||||
if !wanted {
|
|
||||||
t.Fatal("should accept gzip")
|
|
||||||
}
|
|
||||||
if encoding != "gzip" {
|
|
||||||
t.Fatal("expected gzip")
|
|
||||||
}
|
|
||||||
c, err := NewCompressingResponseWriter(httpWriter, encoding)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
c.Write([]byte("Hello World"))
|
|
||||||
c.Close()
|
|
||||||
if httpWriter.Header().Get("Content-Encoding") != "gzip" {
|
|
||||||
t.Fatal("Missing gzip header")
|
|
||||||
}
|
|
||||||
reader, err := gzip.NewReader(httpWriter.Body)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
data, err := ioutil.ReadAll(reader)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
if got, want := string(data), "Hello World"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeflate(t *testing.T) {
|
|
||||||
EnableContentEncoding = true
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", nil)
|
|
||||||
httpRequest.Header.Set("Accept-Encoding", "deflate,gzip")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
wanted, encoding := wantsCompressedResponse(httpRequest)
|
|
||||||
if !wanted {
|
|
||||||
t.Fatal("should accept deflate")
|
|
||||||
}
|
|
||||||
if encoding != "deflate" {
|
|
||||||
t.Fatal("expected deflate")
|
|
||||||
}
|
|
||||||
c, err := NewCompressingResponseWriter(httpWriter, encoding)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
c.Write([]byte("Hello World"))
|
|
||||||
c.Close()
|
|
||||||
if httpWriter.Header().Get("Content-Encoding") != "deflate" {
|
|
||||||
t.Fatal("Missing deflate header")
|
|
||||||
}
|
|
||||||
reader, err := zlib.NewReader(httpWriter.Body)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
data, err := ioutil.ReadAll(reader)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err.Error())
|
|
||||||
}
|
|
||||||
if got, want := string(data), "Hello World"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGzipDecompressRequestBody(t *testing.T) {
|
|
||||||
b := new(bytes.Buffer)
|
|
||||||
w := newGzipWriter()
|
|
||||||
w.Reset(b)
|
|
||||||
io.WriteString(w, `{"msg":"hi"}`)
|
|
||||||
w.Flush()
|
|
||||||
w.Close()
|
|
||||||
|
|
||||||
req := new(Request)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/", bytes.NewReader(b.Bytes()))
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/json")
|
|
||||||
httpRequest.Header.Set("Content-Encoding", "gzip")
|
|
||||||
req.Request = httpRequest
|
|
||||||
|
|
||||||
doCacheReadEntityBytes = false
|
|
||||||
doc := make(map[string]interface{})
|
|
||||||
req.ReadEntity(&doc)
|
|
||||||
|
|
||||||
if got, want := doc["msg"], "hi"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestZlibDecompressRequestBody(t *testing.T) {
|
|
||||||
b := new(bytes.Buffer)
|
|
||||||
w := newZlibWriter()
|
|
||||||
w.Reset(b)
|
|
||||||
io.WriteString(w, `{"msg":"hi"}`)
|
|
||||||
w.Flush()
|
|
||||||
w.Close()
|
|
||||||
|
|
||||||
req := new(Request)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/", bytes.NewReader(b.Bytes()))
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/json")
|
|
||||||
httpRequest.Header.Set("Content-Encoding", "deflate")
|
|
||||||
req.Request = httpRequest
|
|
||||||
|
|
||||||
doCacheReadEntityBytes = false
|
|
||||||
doc := make(map[string]interface{})
|
|
||||||
req.ReadEntity(&doc)
|
|
||||||
|
|
||||||
if got, want := doc["msg"], "hi"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
61
Godeps/_workspace/src/github.com/emicklei/go-restful/container_test.go
generated
vendored
61
Godeps/_workspace/src/github.com/emicklei/go-restful/container_test.go
generated
vendored
|
@ -1,61 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// go test -v -test.run TestContainer_computeAllowedMethods ...restful
|
|
||||||
func TestContainer_computeAllowedMethods(t *testing.T) {
|
|
||||||
wc := NewContainer()
|
|
||||||
ws1 := new(WebService).Path("/users")
|
|
||||||
ws1.Route(ws1.GET("{i}").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("{i}").To(dummy))
|
|
||||||
wc.Add(ws1)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://api.his.com/users/1", nil)
|
|
||||||
rreq := Request{Request: httpRequest}
|
|
||||||
m := wc.computeAllowedMethods(&rreq)
|
|
||||||
if len(m) != 2 {
|
|
||||||
t.Errorf("got %d expected 2 methods, %v", len(m), m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestContainer_HandleWithFilter(t *testing.T) {
|
|
||||||
prefilterCalled := false
|
|
||||||
postfilterCalled := false
|
|
||||||
httpHandlerCalled := false
|
|
||||||
|
|
||||||
wc := NewContainer()
|
|
||||||
wc.Filter(func(request *Request, response *Response, chain *FilterChain) {
|
|
||||||
prefilterCalled = true
|
|
||||||
chain.ProcessFilter(request, response)
|
|
||||||
})
|
|
||||||
wc.HandleWithFilter("/", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
|
||||||
httpHandlerCalled = true
|
|
||||||
w.Write([]byte("ok"))
|
|
||||||
}))
|
|
||||||
wc.Filter(func(request *Request, response *Response, chain *FilterChain) {
|
|
||||||
postfilterCalled = true
|
|
||||||
chain.ProcessFilter(request, response)
|
|
||||||
})
|
|
||||||
|
|
||||||
recorder := httptest.NewRecorder()
|
|
||||||
request, _ := http.NewRequest("GET", "/", nil)
|
|
||||||
wc.ServeHTTP(recorder, request)
|
|
||||||
if recorder.Code != http.StatusOK {
|
|
||||||
t.Errorf("unexpected code %d", recorder.Code)
|
|
||||||
}
|
|
||||||
if recorder.Body.String() != "ok" {
|
|
||||||
t.Errorf("unexpected body %s", recorder.Body.String())
|
|
||||||
}
|
|
||||||
if !prefilterCalled {
|
|
||||||
t.Errorf("filter added before calling HandleWithFilter wasn't called")
|
|
||||||
}
|
|
||||||
if !postfilterCalled {
|
|
||||||
t.Errorf("filter added after calling HandleWithFilter wasn't called")
|
|
||||||
}
|
|
||||||
if !httpHandlerCalled {
|
|
||||||
t.Errorf("handler added by calling HandleWithFilter wasn't called")
|
|
||||||
}
|
|
||||||
}
|
|
125
Godeps/_workspace/src/github.com/emicklei/go-restful/cors_filter_test.go
generated
vendored
125
Godeps/_workspace/src/github.com/emicklei/go-restful/cors_filter_test.go
generated
vendored
|
@ -1,125 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// go test -v -test.run TestCORSFilter_Preflight ...restful
|
|
||||||
// http://www.html5rocks.com/en/tutorials/cors/#toc-handling-a-not-so-simple-request
|
|
||||||
func TestCORSFilter_Preflight(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
ws := new(WebService)
|
|
||||||
ws.Route(ws.PUT("/cors").To(dummy))
|
|
||||||
Add(ws)
|
|
||||||
|
|
||||||
cors := CrossOriginResourceSharing{
|
|
||||||
ExposeHeaders: []string{"X-Custom-Header"},
|
|
||||||
AllowedHeaders: []string{"X-Custom-Header", "X-Additional-Header"},
|
|
||||||
CookiesAllowed: true,
|
|
||||||
Container: DefaultContainer}
|
|
||||||
Filter(cors.Filter)
|
|
||||||
|
|
||||||
// Preflight
|
|
||||||
httpRequest, _ := http.NewRequest("OPTIONS", "http://api.alice.com/cors", nil)
|
|
||||||
httpRequest.Method = "OPTIONS"
|
|
||||||
httpRequest.Header.Set(HEADER_Origin, "http://api.bob.com")
|
|
||||||
httpRequest.Header.Set(HEADER_AccessControlRequestMethod, "PUT")
|
|
||||||
httpRequest.Header.Set(HEADER_AccessControlRequestHeaders, "X-Custom-Header, X-Additional-Header")
|
|
||||||
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
|
|
||||||
actual := httpWriter.Header().Get(HEADER_AccessControlAllowOrigin)
|
|
||||||
if "http://api.bob.com" != actual {
|
|
||||||
t.Fatal("expected: http://api.bob.com but got:" + actual)
|
|
||||||
}
|
|
||||||
actual = httpWriter.Header().Get(HEADER_AccessControlAllowMethods)
|
|
||||||
if "PUT" != actual {
|
|
||||||
t.Fatal("expected: PUT but got:" + actual)
|
|
||||||
}
|
|
||||||
actual = httpWriter.Header().Get(HEADER_AccessControlAllowHeaders)
|
|
||||||
if "X-Custom-Header, X-Additional-Header" != actual {
|
|
||||||
t.Fatal("expected: X-Custom-Header, X-Additional-Header but got:" + actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !cors.isOriginAllowed("somewhere") {
|
|
||||||
t.Fatal("origin expected to be allowed")
|
|
||||||
}
|
|
||||||
cors.AllowedDomains = []string{"overthere.com"}
|
|
||||||
if cors.isOriginAllowed("somewhere") {
|
|
||||||
t.Fatal("origin [somewhere] expected NOT to be allowed")
|
|
||||||
}
|
|
||||||
if !cors.isOriginAllowed("overthere.com") {
|
|
||||||
t.Fatal("origin [overthere] expected to be allowed")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestCORSFilter_Actual ...restful
|
|
||||||
// http://www.html5rocks.com/en/tutorials/cors/#toc-handling-a-not-so-simple-request
|
|
||||||
func TestCORSFilter_Actual(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
ws := new(WebService)
|
|
||||||
ws.Route(ws.PUT("/cors").To(dummy))
|
|
||||||
Add(ws)
|
|
||||||
|
|
||||||
cors := CrossOriginResourceSharing{
|
|
||||||
ExposeHeaders: []string{"X-Custom-Header"},
|
|
||||||
AllowedHeaders: []string{"X-Custom-Header", "X-Additional-Header"},
|
|
||||||
CookiesAllowed: true,
|
|
||||||
Container: DefaultContainer}
|
|
||||||
Filter(cors.Filter)
|
|
||||||
|
|
||||||
// Actual
|
|
||||||
httpRequest, _ := http.NewRequest("PUT", "http://api.alice.com/cors", nil)
|
|
||||||
httpRequest.Header.Set(HEADER_Origin, "http://api.bob.com")
|
|
||||||
httpRequest.Header.Set("X-Custom-Header", "value")
|
|
||||||
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
actual := httpWriter.Header().Get(HEADER_AccessControlAllowOrigin)
|
|
||||||
if "http://api.bob.com" != actual {
|
|
||||||
t.Fatal("expected: http://api.bob.com but got:" + actual)
|
|
||||||
}
|
|
||||||
if httpWriter.Body.String() != "dummy" {
|
|
||||||
t.Fatal("expected: dummy but got:" + httpWriter.Body.String())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var allowedDomainInput = []struct {
|
|
||||||
domains []string
|
|
||||||
origin string
|
|
||||||
accepted bool
|
|
||||||
}{
|
|
||||||
{[]string{}, "http://anything.com", true},
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestCORSFilter_AllowedDomains ...restful
|
|
||||||
func TestCORSFilter_AllowedDomains(t *testing.T) {
|
|
||||||
for _, each := range allowedDomainInput {
|
|
||||||
tearDown()
|
|
||||||
ws := new(WebService)
|
|
||||||
ws.Route(ws.PUT("/cors").To(dummy))
|
|
||||||
Add(ws)
|
|
||||||
|
|
||||||
cors := CrossOriginResourceSharing{
|
|
||||||
AllowedDomains: each.domains,
|
|
||||||
CookiesAllowed: true,
|
|
||||||
Container: DefaultContainer}
|
|
||||||
Filter(cors.Filter)
|
|
||||||
|
|
||||||
httpRequest, _ := http.NewRequest("PUT", "http://api.his.com/cors", nil)
|
|
||||||
httpRequest.Header.Set(HEADER_Origin, each.origin)
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
actual := httpWriter.Header().Get(HEADER_AccessControlAllowOrigin)
|
|
||||||
if actual != each.origin && each.accepted {
|
|
||||||
t.Fatal("expected to be accepted")
|
|
||||||
}
|
|
||||||
if actual == each.origin && !each.accepted {
|
|
||||||
t.Fatal("did not expect to be accepted")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
231
Godeps/_workspace/src/github.com/emicklei/go-restful/curly_test.go
generated
vendored
231
Godeps/_workspace/src/github.com/emicklei/go-restful/curly_test.go
generated
vendored
|
@ -1,231 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
var requestPaths = []struct {
|
|
||||||
// url with path (1) is handled by service with root (2) and remainder has value final (3)
|
|
||||||
path, root string
|
|
||||||
}{
|
|
||||||
{"/", "/"},
|
|
||||||
{"/p", "/p"},
|
|
||||||
{"/p/x", "/p/{q}"},
|
|
||||||
{"/q/x", "/q"},
|
|
||||||
{"/p/x/", "/p/{q}"},
|
|
||||||
{"/p/x/y", "/p/{q}"},
|
|
||||||
{"/q/x/y", "/q"},
|
|
||||||
{"/z/q", "/{p}/q"},
|
|
||||||
{"/a/b/c/q", "/"},
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestCurlyDetectWebService ...restful
|
|
||||||
func TestCurlyDetectWebService(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/")
|
|
||||||
ws2 := new(WebService).Path("/p")
|
|
||||||
ws3 := new(WebService).Path("/q")
|
|
||||||
ws4 := new(WebService).Path("/p/q")
|
|
||||||
ws5 := new(WebService).Path("/p/{q}")
|
|
||||||
ws7 := new(WebService).Path("/{p}/q")
|
|
||||||
var wss = []*WebService{ws1, ws2, ws3, ws4, ws5, ws7}
|
|
||||||
|
|
||||||
for _, each := range wss {
|
|
||||||
t.Logf("path=%s,toks=%v\n", each.pathExpr.Source, each.pathExpr.tokens)
|
|
||||||
}
|
|
||||||
|
|
||||||
router := CurlyRouter{}
|
|
||||||
|
|
||||||
ok := true
|
|
||||||
for i, fixture := range requestPaths {
|
|
||||||
requestTokens := tokenizePath(fixture.path)
|
|
||||||
who := router.detectWebService(requestTokens, wss)
|
|
||||||
if who != nil && who.RootPath() != fixture.root {
|
|
||||||
t.Logf("[line:%v] Unexpected dispatcher, expected:%v, actual:%v", i, fixture.root, who.RootPath())
|
|
||||||
ok = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var serviceDetects = []struct {
|
|
||||||
path string
|
|
||||||
found bool
|
|
||||||
root string
|
|
||||||
}{
|
|
||||||
{"/a/b", true, "/{p}/{q}/{r}"},
|
|
||||||
{"/p/q", true, "/p/q"},
|
|
||||||
{"/q/p", true, "/q"},
|
|
||||||
{"/", true, "/"},
|
|
||||||
{"/p/q/r", true, "/p/q"},
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run Test_detectWebService ...restful
|
|
||||||
func Test_detectWebService(t *testing.T) {
|
|
||||||
router := CurlyRouter{}
|
|
||||||
ws1 := new(WebService).Path("/")
|
|
||||||
ws2 := new(WebService).Path("/p")
|
|
||||||
ws3 := new(WebService).Path("/q")
|
|
||||||
ws4 := new(WebService).Path("/p/q")
|
|
||||||
ws5 := new(WebService).Path("/p/{q}")
|
|
||||||
ws6 := new(WebService).Path("/p/{q}/")
|
|
||||||
ws7 := new(WebService).Path("/{p}/q")
|
|
||||||
ws8 := new(WebService).Path("/{p}/{q}/{r}")
|
|
||||||
var wss = []*WebService{ws8, ws7, ws6, ws5, ws4, ws3, ws2, ws1}
|
|
||||||
for _, fix := range serviceDetects {
|
|
||||||
requestPath := fix.path
|
|
||||||
requestTokens := tokenizePath(requestPath)
|
|
||||||
for _, ws := range wss {
|
|
||||||
serviceTokens := ws.pathExpr.tokens
|
|
||||||
matches, score := router.computeWebserviceScore(requestTokens, serviceTokens)
|
|
||||||
t.Logf("req=%s,toks:%v,ws=%s,toks:%v,score=%d,matches=%v", requestPath, requestTokens, ws.RootPath(), serviceTokens, score, matches)
|
|
||||||
}
|
|
||||||
best := router.detectWebService(requestTokens, wss)
|
|
||||||
if best != nil {
|
|
||||||
if fix.found {
|
|
||||||
t.Logf("best=%s", best.RootPath())
|
|
||||||
} else {
|
|
||||||
t.Fatalf("should have found:%s", fix.root)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var routeMatchers = []struct {
|
|
||||||
route string
|
|
||||||
path string
|
|
||||||
matches bool
|
|
||||||
paramCount int
|
|
||||||
staticCount int
|
|
||||||
}{
|
|
||||||
// route, request-path
|
|
||||||
{"/a", "/a", true, 0, 1},
|
|
||||||
{"/a", "/b", false, 0, 0},
|
|
||||||
{"/a", "/b", false, 0, 0},
|
|
||||||
{"/a/{b}/c/", "/a/2/c", true, 1, 2},
|
|
||||||
{"/{a}/{b}/{c}/", "/a/b", false, 0, 0},
|
|
||||||
{"/{x:*}", "/", false, 0, 0},
|
|
||||||
{"/{x:*}", "/a", true, 1, 0},
|
|
||||||
{"/{x:*}", "/a/b", true, 1, 0},
|
|
||||||
{"/a/{x:*}", "/a/b", true, 1, 1},
|
|
||||||
{"/a/{x:[A-Z][A-Z]}", "/a/ZX", true, 1, 1},
|
|
||||||
{"/basepath/{resource:*}", "/basepath/some/other/location/test.xml", true, 1, 1},
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run Test_matchesRouteByPathTokens ...restful
|
|
||||||
func Test_matchesRouteByPathTokens(t *testing.T) {
|
|
||||||
router := CurlyRouter{}
|
|
||||||
for i, each := range routeMatchers {
|
|
||||||
routeToks := tokenizePath(each.route)
|
|
||||||
reqToks := tokenizePath(each.path)
|
|
||||||
matches, pCount, sCount := router.matchesRouteByPathTokens(routeToks, reqToks)
|
|
||||||
if matches != each.matches {
|
|
||||||
t.Fatalf("[%d] unexpected matches outcome route:%s, path:%s, matches:%v", i, each.route, each.path, matches)
|
|
||||||
}
|
|
||||||
if pCount != each.paramCount {
|
|
||||||
t.Fatalf("[%d] unexpected paramCount got:%d want:%d ", i, pCount, each.paramCount)
|
|
||||||
}
|
|
||||||
if sCount != each.staticCount {
|
|
||||||
t.Fatalf("[%d] unexpected staticCount got:%d want:%d ", i, sCount, each.staticCount)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestExtractParameters_Wildcard1 ...restful
|
|
||||||
func TestExtractParameters_Wildcard1(t *testing.T) {
|
|
||||||
params := doExtractParams("/fixed/{var:*}", 2, "/fixed/remainder", t)
|
|
||||||
if params["var"] != "remainder" {
|
|
||||||
t.Errorf("parameter mismatch var: %s", params["var"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestExtractParameters_Wildcard2 ...restful
|
|
||||||
func TestExtractParameters_Wildcard2(t *testing.T) {
|
|
||||||
params := doExtractParams("/fixed/{var:*}", 2, "/fixed/remain/der", t)
|
|
||||||
if params["var"] != "remain/der" {
|
|
||||||
t.Errorf("parameter mismatch var: %s", params["var"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestExtractParameters_Wildcard3 ...restful
|
|
||||||
func TestExtractParameters_Wildcard3(t *testing.T) {
|
|
||||||
params := doExtractParams("/static/{var:*}", 2, "/static/test/sub/hi.html", t)
|
|
||||||
if params["var"] != "test/sub/hi.html" {
|
|
||||||
t.Errorf("parameter mismatch var: %s", params["var"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestCurly_ISSUE_34 ...restful
|
|
||||||
func TestCurly_ISSUE_34(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/")
|
|
||||||
ws1.Route(ws1.GET("/{type}/{id}").To(curlyDummy))
|
|
||||||
ws1.Route(ws1.GET("/network/{id}").To(curlyDummy))
|
|
||||||
routes := CurlyRouter{}.selectRoutes(ws1, tokenizePath("/network/12"))
|
|
||||||
if len(routes) != 2 {
|
|
||||||
t.Fatal("expected 2 routes")
|
|
||||||
}
|
|
||||||
if routes[0].Path != "/network/{id}" {
|
|
||||||
t.Error("first is", routes[0].Path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestCurly_ISSUE_34_2 ...restful
|
|
||||||
func TestCurly_ISSUE_34_2(t *testing.T) {
|
|
||||||
ws1 := new(WebService)
|
|
||||||
ws1.Route(ws1.GET("/network/{id}").To(curlyDummy))
|
|
||||||
ws1.Route(ws1.GET("/{type}/{id}").To(curlyDummy))
|
|
||||||
routes := CurlyRouter{}.selectRoutes(ws1, tokenizePath("/network/12"))
|
|
||||||
if len(routes) != 2 {
|
|
||||||
t.Fatal("expected 2 routes")
|
|
||||||
}
|
|
||||||
if routes[0].Path != "/network/{id}" {
|
|
||||||
t.Error("first is", routes[0].Path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestCurly_JsonHtml ...restful
|
|
||||||
func TestCurly_JsonHtml(t *testing.T) {
|
|
||||||
ws1 := new(WebService)
|
|
||||||
ws1.Path("/")
|
|
||||||
ws1.Route(ws1.GET("/some.html").To(curlyDummy).Consumes("*/*").Produces("text/html"))
|
|
||||||
req, _ := http.NewRequest("GET", "/some.html", nil)
|
|
||||||
req.Header.Set("Accept", "application/json")
|
|
||||||
_, route, err := CurlyRouter{}.SelectRoute([]*WebService{ws1}, req)
|
|
||||||
if err == nil {
|
|
||||||
t.Error("error expected")
|
|
||||||
}
|
|
||||||
if route != nil {
|
|
||||||
t.Error("no route expected")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestCurly_ISSUE_137 ...restful
|
|
||||||
func TestCurly_ISSUE_137(t *testing.T) {
|
|
||||||
ws1 := new(WebService)
|
|
||||||
ws1.Route(ws1.GET("/hello").To(curlyDummy))
|
|
||||||
ws1.Path("/")
|
|
||||||
req, _ := http.NewRequest("GET", "/", nil)
|
|
||||||
_, route, _ := CurlyRouter{}.SelectRoute([]*WebService{ws1}, req)
|
|
||||||
t.Log(route)
|
|
||||||
if route != nil {
|
|
||||||
t.Error("no route expected")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestCurly_ISSUE_137_2 ...restful
|
|
||||||
func TestCurly_ISSUE_137_2(t *testing.T) {
|
|
||||||
ws1 := new(WebService)
|
|
||||||
ws1.Route(ws1.GET("/hello").To(curlyDummy))
|
|
||||||
ws1.Path("/")
|
|
||||||
req, _ := http.NewRequest("GET", "/hello/bob", nil)
|
|
||||||
_, route, _ := CurlyRouter{}.SelectRoute([]*WebService{ws1}, req)
|
|
||||||
t.Log(route)
|
|
||||||
if route != nil {
|
|
||||||
t.Errorf("no route expected, got %v", route)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func curlyDummy(req *Request, resp *Response) { io.WriteString(resp.ResponseWriter, "curlyDummy") }
|
|
41
Godeps/_workspace/src/github.com/emicklei/go-restful/doc_examples_test.go
generated
vendored
41
Godeps/_workspace/src/github.com/emicklei/go-restful/doc_examples_test.go
generated
vendored
|
@ -1,41 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import "net/http"
|
|
||||||
|
|
||||||
func ExampleOPTIONSFilter() {
|
|
||||||
// Install the OPTIONS filter on the default Container
|
|
||||||
Filter(OPTIONSFilter())
|
|
||||||
}
|
|
||||||
func ExampleContainer_OPTIONSFilter() {
|
|
||||||
// Install the OPTIONS filter on a Container
|
|
||||||
myContainer := new(Container)
|
|
||||||
myContainer.Filter(myContainer.OPTIONSFilter)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExampleContainer() {
|
|
||||||
// The Default container of go-restful uses the http.DefaultServeMux.
|
|
||||||
// You can create your own Container using restful.NewContainer() and create a new http.Server for that particular container
|
|
||||||
|
|
||||||
ws := new(WebService)
|
|
||||||
wsContainer := NewContainer()
|
|
||||||
wsContainer.Add(ws)
|
|
||||||
server := &http.Server{Addr: ":8080", Handler: wsContainer}
|
|
||||||
server.ListenAndServe()
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExampleCrossOriginResourceSharing() {
|
|
||||||
// To install this filter on the Default Container use:
|
|
||||||
cors := CrossOriginResourceSharing{ExposeHeaders: []string{"X-My-Header"}, CookiesAllowed: false, Container: DefaultContainer}
|
|
||||||
Filter(cors.Filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExampleServiceError() {
|
|
||||||
resp := new(Response)
|
|
||||||
resp.WriteEntity(NewError(http.StatusBadRequest, "Non-integer {id} path parameter"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func ExampleBoundedCachedCompressors() {
|
|
||||||
// Register a compressor provider (gzip/deflate read/write) that uses
|
|
||||||
// a bounded cache with a maximum of 20 writers and 20 readers.
|
|
||||||
SetCompressorProvider(NewBoundedCachedCompressors(20, 20))
|
|
||||||
}
|
|
69
Godeps/_workspace/src/github.com/emicklei/go-restful/entity_accessors_test.go
generated
vendored
69
Godeps/_workspace/src/github.com/emicklei/go-restful/entity_accessors_test.go
generated
vendored
|
@ -1,69 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
type keyvalue struct {
|
|
||||||
readCalled bool
|
|
||||||
writeCalled bool
|
|
||||||
}
|
|
||||||
|
|
||||||
func (kv *keyvalue) Read(req *Request, v interface{}) error {
|
|
||||||
//t := reflect.TypeOf(v)
|
|
||||||
//rv := reflect.ValueOf(v)
|
|
||||||
kv.readCalled = true
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (kv *keyvalue) Write(resp *Response, status int, v interface{}) error {
|
|
||||||
t := reflect.TypeOf(v)
|
|
||||||
rv := reflect.ValueOf(v)
|
|
||||||
for ix := 0; ix < t.NumField(); ix++ {
|
|
||||||
sf := t.Field(ix)
|
|
||||||
io.WriteString(resp, sf.Name)
|
|
||||||
io.WriteString(resp, "=")
|
|
||||||
io.WriteString(resp, fmt.Sprintf("%v\n", rv.Field(ix).Interface()))
|
|
||||||
}
|
|
||||||
kv.writeCalled = true
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestKeyValueEncoding ...restful
|
|
||||||
func TestKeyValueEncoding(t *testing.T) {
|
|
||||||
type Book struct {
|
|
||||||
Title string
|
|
||||||
Author string
|
|
||||||
PublishedYear int
|
|
||||||
}
|
|
||||||
kv := new(keyvalue)
|
|
||||||
RegisterEntityAccessor("application/kv", kv)
|
|
||||||
b := Book{"Singing for Dummies", "john doe", 2015}
|
|
||||||
|
|
||||||
// Write
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
// Accept Produces
|
|
||||||
resp := Response{httpWriter, "application/kv,*/*;q=0.8", []string{"application/kv"}, 0, 0, true, nil}
|
|
||||||
resp.WriteEntity(b)
|
|
||||||
t.Log(string(httpWriter.Body.Bytes()))
|
|
||||||
if !kv.writeCalled {
|
|
||||||
t.Error("Write never called")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read
|
|
||||||
bodyReader := bytes.NewReader(httpWriter.Body.Bytes())
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/kv; charset=UTF-8")
|
|
||||||
request := NewRequest(httpRequest)
|
|
||||||
var bb Book
|
|
||||||
request.ReadEntity(&bb)
|
|
||||||
if !kv.readCalled {
|
|
||||||
t.Error("Read never called")
|
|
||||||
}
|
|
||||||
}
|
|
1
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/.goconvey
generated
vendored
1
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/.goconvey
generated
vendored
|
@ -1 +0,0 @@
|
||||||
ignore
|
|
|
@ -1 +0,0 @@
|
||||||
ignore
|
|
20
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/google_app_engine/app.yaml
generated
vendored
20
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/google_app_engine/app.yaml
generated
vendored
|
@ -1,20 +0,0 @@
|
||||||
#
|
|
||||||
# Include your application ID here
|
|
||||||
#
|
|
||||||
application: <your_app_id>
|
|
||||||
version: 1
|
|
||||||
runtime: go
|
|
||||||
api_version: go1
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
#
|
|
||||||
# Regex for all swagger files to make as static content.
|
|
||||||
# You should create the folder static/swagger and copy
|
|
||||||
# swagger-ui into it.
|
|
||||||
#
|
|
||||||
- url: /apidocs/(.*?)/(.*\.(js|html|css))
|
|
||||||
static_files: static/swagger/\1/\2
|
|
||||||
upload: static/swagger/(.*?)/(.*\.(js|html|css))
|
|
||||||
|
|
||||||
- url: /.*
|
|
||||||
script: _go_app
|
|
|
@ -1 +0,0 @@
|
||||||
ignore
|
|
|
@ -1,18 +0,0 @@
|
||||||
application: <your_app_id>
|
|
||||||
version: 1
|
|
||||||
runtime: go
|
|
||||||
api_version: go1
|
|
||||||
|
|
||||||
handlers:
|
|
||||||
# Regex for all swagger files to make as static content.
|
|
||||||
# You should create the folder static/swagger and copy
|
|
||||||
# swagger-ui into it.
|
|
||||||
#
|
|
||||||
- url: /apidocs/(.*?)/(.*\.(js|html|css))
|
|
||||||
static_files: static/swagger/\1/\2
|
|
||||||
upload: static/swagger/(.*?)/(.*\.(js|html|css))
|
|
||||||
|
|
||||||
# Catch all.
|
|
||||||
- url: /.*
|
|
||||||
script: _go_app
|
|
||||||
login: required
|
|
|
@ -1,266 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/emicklei/go-restful/swagger"
|
|
||||||
"google.golang.com/appengine"
|
|
||||||
"google.golang.com/appengine/datastore"
|
|
||||||
"google.golang.com/appengine/user"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example demonstrates a reasonably complete suite of RESTful operations backed
|
|
||||||
// by DataStore on Google App Engine.
|
|
||||||
|
|
||||||
// Our simple example struct.
|
|
||||||
type Profile struct {
|
|
||||||
LastModified time.Time `json:"-" xml:"-"`
|
|
||||||
Email string `json:"-" xml:"-"`
|
|
||||||
FirstName string `json:"first_name" xml:"first-name"`
|
|
||||||
NickName string `json:"nick_name" xml:"nick-name"`
|
|
||||||
LastName string `json:"last_name" xml:"last-name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProfileApi struct {
|
|
||||||
Path string
|
|
||||||
}
|
|
||||||
|
|
||||||
func gaeUrl() string {
|
|
||||||
if appengine.IsDevAppServer() {
|
|
||||||
return "http://localhost:8080"
|
|
||||||
} else {
|
|
||||||
// Include your URL on App Engine here.
|
|
||||||
// I found no way to get AppID without appengine.Context and this always
|
|
||||||
// based on a http.Request.
|
|
||||||
return "http://federatedservices.appspot.com"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
u := ProfileApi{Path: "/profiles"}
|
|
||||||
u.register()
|
|
||||||
|
|
||||||
// Optionally, you can install the Swagger Service which provides a nice Web UI on your REST API
|
|
||||||
// You need to download the Swagger HTML5 assets and change the FilePath location in the config below.
|
|
||||||
// Open <your_app_id>.appspot.com/apidocs and enter
|
|
||||||
// Place the Swagger UI files into a folder called static/swagger if you wish to use Swagger
|
|
||||||
// http://<your_app_id>.appspot.com/apidocs.json in the api input field.
|
|
||||||
// For testing, you can use http://localhost:8080/apidocs.json
|
|
||||||
config := swagger.Config{
|
|
||||||
// You control what services are visible
|
|
||||||
WebServices: restful.RegisteredWebServices(),
|
|
||||||
WebServicesUrl: gaeUrl(),
|
|
||||||
ApiPath: "/apidocs.json",
|
|
||||||
|
|
||||||
// Optionally, specifiy where the UI is located
|
|
||||||
SwaggerPath: "/apidocs/",
|
|
||||||
|
|
||||||
// GAE support static content which is configured in your app.yaml.
|
|
||||||
// This example expect the swagger-ui in static/swagger so you should place it there :)
|
|
||||||
SwaggerFilePath: "static/swagger"}
|
|
||||||
swagger.InstallSwaggerService(config)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u ProfileApi) register() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
|
|
||||||
ws.
|
|
||||||
Path(u.Path).
|
|
||||||
// You can specify consumes and produces per route as well.
|
|
||||||
Consumes(restful.MIME_JSON, restful.MIME_XML).
|
|
||||||
Produces(restful.MIME_JSON, restful.MIME_XML)
|
|
||||||
|
|
||||||
ws.Route(ws.POST("").To(u.insert).
|
|
||||||
// Swagger documentation.
|
|
||||||
Doc("insert a new profile").
|
|
||||||
Param(ws.BodyParameter("Profile", "representation of a profile").DataType("main.Profile")).
|
|
||||||
Reads(Profile{}))
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{profile-id}").To(u.read).
|
|
||||||
// Swagger documentation.
|
|
||||||
Doc("read a profile").
|
|
||||||
Param(ws.PathParameter("profile-id", "identifier for a profile").DataType("string")).
|
|
||||||
Writes(Profile{}))
|
|
||||||
|
|
||||||
ws.Route(ws.PUT("/{profile-id}").To(u.update).
|
|
||||||
// Swagger documentation.
|
|
||||||
Doc("update an existing profile").
|
|
||||||
Param(ws.PathParameter("profile-id", "identifier for a profile").DataType("string")).
|
|
||||||
Param(ws.BodyParameter("Profile", "representation of a profile").DataType("main.Profile")).
|
|
||||||
Reads(Profile{}))
|
|
||||||
|
|
||||||
ws.Route(ws.DELETE("/{profile-id}").To(u.remove).
|
|
||||||
// Swagger documentation.
|
|
||||||
Doc("remove a profile").
|
|
||||||
Param(ws.PathParameter("profile-id", "identifier for a profile").DataType("string")))
|
|
||||||
|
|
||||||
restful.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST http://localhost:8080/profiles
|
|
||||||
// {"first_name": "Ivan", "nick_name": "Socks", "last_name": "Hawkes"}
|
|
||||||
//
|
|
||||||
func (u *ProfileApi) insert(r *restful.Request, w *restful.Response) {
|
|
||||||
c := appengine.NewContext(r.Request)
|
|
||||||
|
|
||||||
// Marshall the entity from the request into a struct.
|
|
||||||
p := new(Profile)
|
|
||||||
err := r.ReadEntity(&p)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteError(http.StatusNotAcceptable, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure we start with a sensible value for this field.
|
|
||||||
p.LastModified = time.Now()
|
|
||||||
|
|
||||||
// The profile belongs to this user.
|
|
||||||
p.Email = user.Current(c).String()
|
|
||||||
|
|
||||||
k, err := datastore.Put(c, datastore.NewIncompleteKey(c, "profiles", nil), p)
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let them know the location of the newly created resource.
|
|
||||||
// TODO: Use a safe Url path append function.
|
|
||||||
w.AddHeader("Location", u.Path+"/"+k.Encode())
|
|
||||||
|
|
||||||
// Return the resultant entity.
|
|
||||||
w.WriteHeader(http.StatusCreated)
|
|
||||||
w.WriteEntity(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/profiles/ahdkZXZ-ZmVkZXJhdGlvbi1zZXJ2aWNlc3IVCxIIcHJvZmlsZXMYgICAgICAgAoM
|
|
||||||
//
|
|
||||||
func (u ProfileApi) read(r *restful.Request, w *restful.Response) {
|
|
||||||
c := appengine.NewContext(r.Request)
|
|
||||||
|
|
||||||
// Decode the request parameter to determine the key for the entity.
|
|
||||||
k, err := datastore.DecodeKey(r.PathParameter("profile-id"))
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve the entity from the datastore.
|
|
||||||
p := Profile{}
|
|
||||||
if err := datastore.Get(c, k, &p); err != nil {
|
|
||||||
if err.Error() == "datastore: no such entity" {
|
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
|
||||||
} else {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check we own the profile before allowing them to view it.
|
|
||||||
// Optionally, return a 404 instead to help prevent guessing ids.
|
|
||||||
// TODO: Allow admins access.
|
|
||||||
if p.Email != user.Current(c).String() {
|
|
||||||
http.Error(w, "You do not have access to this resource", http.StatusForbidden)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
w.WriteEntity(p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT http://localhost:8080/profiles/ahdkZXZ-ZmVkZXJhdGlvbi1zZXJ2aWNlc3IVCxIIcHJvZmlsZXMYgICAgICAgAoM
|
|
||||||
// {"first_name": "Ivan", "nick_name": "Socks", "last_name": "Hawkes"}
|
|
||||||
//
|
|
||||||
func (u *ProfileApi) update(r *restful.Request, w *restful.Response) {
|
|
||||||
c := appengine.NewContext(r.Request)
|
|
||||||
|
|
||||||
// Decode the request parameter to determine the key for the entity.
|
|
||||||
k, err := datastore.DecodeKey(r.PathParameter("profile-id"))
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Marshall the entity from the request into a struct.
|
|
||||||
p := new(Profile)
|
|
||||||
err = r.ReadEntity(&p)
|
|
||||||
if err != nil {
|
|
||||||
w.WriteError(http.StatusNotAcceptable, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve the old entity from the datastore.
|
|
||||||
old := Profile{}
|
|
||||||
if err := datastore.Get(c, k, &old); err != nil {
|
|
||||||
if err.Error() == "datastore: no such entity" {
|
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
|
||||||
} else {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check we own the profile before allowing them to update it.
|
|
||||||
// Optionally, return a 404 instead to help prevent guessing ids.
|
|
||||||
// TODO: Allow admins access.
|
|
||||||
if old.Email != user.Current(c).String() {
|
|
||||||
http.Error(w, "You do not have access to this resource", http.StatusForbidden)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Since the whole entity is re-written, we need to assign any invariant fields again
|
|
||||||
// e.g. the owner of the entity.
|
|
||||||
p.Email = user.Current(c).String()
|
|
||||||
|
|
||||||
// Keep track of the last modification date.
|
|
||||||
p.LastModified = time.Now()
|
|
||||||
|
|
||||||
// Attempt to overwrite the old entity.
|
|
||||||
_, err = datastore.Put(c, k, p)
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let them know it succeeded.
|
|
||||||
w.WriteHeader(http.StatusNoContent)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE http://localhost:8080/profiles/ahdkZXZ-ZmVkZXJhdGlvbi1zZXJ2aWNlc3IVCxIIcHJvZmlsZXMYgICAgICAgAoM
|
|
||||||
//
|
|
||||||
func (u *ProfileApi) remove(r *restful.Request, w *restful.Response) {
|
|
||||||
c := appengine.NewContext(r.Request)
|
|
||||||
|
|
||||||
// Decode the request parameter to determine the key for the entity.
|
|
||||||
k, err := datastore.DecodeKey(r.PathParameter("profile-id"))
|
|
||||||
if err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve the old entity from the datastore.
|
|
||||||
old := Profile{}
|
|
||||||
if err := datastore.Get(c, k, &old); err != nil {
|
|
||||||
if err.Error() == "datastore: no such entity" {
|
|
||||||
http.Error(w, err.Error(), http.StatusNotFound)
|
|
||||||
} else {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check we own the profile before allowing them to delete it.
|
|
||||||
// Optionally, return a 404 instead to help prevent guessing ids.
|
|
||||||
// TODO: Allow admins access.
|
|
||||||
if old.Email != user.Current(c).String() {
|
|
||||||
http.Error(w, "You do not have access to this resource", http.StatusForbidden)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete the entity.
|
|
||||||
if err := datastore.Delete(c, k); err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Success notification.
|
|
||||||
w.WriteHeader(http.StatusNoContent)
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/mjibson/appstats"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
func stats(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
c := appstats.NewContext(req.Request)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
c.Stats.Status = resp.StatusCode()
|
|
||||||
c.Save()
|
|
||||||
}
|
|
|
@ -1,161 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/emicklei/go-restful/swagger"
|
|
||||||
"google.golang.com/appengine"
|
|
||||||
"google.golang.com/appengine/memcache"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example is functionally the same as ../restful-user-service.go
|
|
||||||
// but it`s supposed to run on Goole App Engine (GAE)
|
|
||||||
//
|
|
||||||
// contributed by ivanhawkes
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Id, Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserService struct {
|
|
||||||
// normally one would use DAO (data access object)
|
|
||||||
// but in this example we simple use memcache.
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserService) Register() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
|
|
||||||
ws.
|
|
||||||
Path("/users").
|
|
||||||
Consumes(restful.MIME_XML, restful.MIME_JSON).
|
|
||||||
Produces(restful.MIME_JSON, restful.MIME_XML) // you can specify this per route as well
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{user-id}").To(u.findUser).
|
|
||||||
// docs
|
|
||||||
Doc("get a user").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
|
|
||||||
Writes(User{})) // on the response
|
|
||||||
|
|
||||||
ws.Route(ws.PATCH("").To(u.updateUser).
|
|
||||||
// docs
|
|
||||||
Doc("update a user").
|
|
||||||
Reads(User{})) // from the request
|
|
||||||
|
|
||||||
ws.Route(ws.PUT("/{user-id}").To(u.createUser).
|
|
||||||
// docs
|
|
||||||
Doc("create a user").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
|
|
||||||
Reads(User{})) // from the request
|
|
||||||
|
|
||||||
ws.Route(ws.DELETE("/{user-id}").To(u.removeUser).
|
|
||||||
// docs
|
|
||||||
Doc("delete a user").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")))
|
|
||||||
|
|
||||||
restful.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
func (u UserService) findUser(request *restful.Request, response *restful.Response) {
|
|
||||||
c := appengine.NewContext(request.Request)
|
|
||||||
id := request.PathParameter("user-id")
|
|
||||||
usr := new(User)
|
|
||||||
_, err := memcache.Gob.Get(c, id, &usr)
|
|
||||||
if err != nil || len(usr.Id) == 0 {
|
|
||||||
response.WriteErrorString(http.StatusNotFound, "User could not be found.")
|
|
||||||
} else {
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PATCH http://localhost:8080/users
|
|
||||||
// <User><Id>1</Id><Name>Melissa Raspberry</Name></User>
|
|
||||||
//
|
|
||||||
func (u *UserService) updateUser(request *restful.Request, response *restful.Response) {
|
|
||||||
c := appengine.NewContext(request.Request)
|
|
||||||
usr := new(User)
|
|
||||||
err := request.ReadEntity(&usr)
|
|
||||||
if err == nil {
|
|
||||||
item := &memcache.Item{
|
|
||||||
Key: usr.Id,
|
|
||||||
Object: &usr,
|
|
||||||
}
|
|
||||||
err = memcache.Gob.Set(c, item)
|
|
||||||
if err != nil {
|
|
||||||
response.WriteError(http.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
} else {
|
|
||||||
response.WriteError(http.StatusInternalServerError, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT http://localhost:8080/users/1
|
|
||||||
// <User><Id>1</Id><Name>Melissa</Name></User>
|
|
||||||
//
|
|
||||||
func (u *UserService) createUser(request *restful.Request, response *restful.Response) {
|
|
||||||
c := appengine.NewContext(request.Request)
|
|
||||||
usr := User{Id: request.PathParameter("user-id")}
|
|
||||||
err := request.ReadEntity(&usr)
|
|
||||||
if err == nil {
|
|
||||||
item := &memcache.Item{
|
|
||||||
Key: usr.Id,
|
|
||||||
Object: &usr,
|
|
||||||
}
|
|
||||||
err = memcache.Gob.Add(c, item)
|
|
||||||
if err != nil {
|
|
||||||
response.WriteError(http.StatusInternalServerError, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
response.WriteHeader(http.StatusCreated)
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
} else {
|
|
||||||
response.WriteError(http.StatusInternalServerError, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
func (u *UserService) removeUser(request *restful.Request, response *restful.Response) {
|
|
||||||
c := appengine.NewContext(request.Request)
|
|
||||||
id := request.PathParameter("user-id")
|
|
||||||
err := memcache.Delete(c, id)
|
|
||||||
if err != nil {
|
|
||||||
response.WriteError(http.StatusInternalServerError, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getGaeURL() string {
|
|
||||||
if appengine.IsDevAppServer() {
|
|
||||||
return "http://localhost:8080"
|
|
||||||
} else {
|
|
||||||
/**
|
|
||||||
* Include your URL on App Engine here.
|
|
||||||
* I found no way to get AppID without appengine.Context and this always
|
|
||||||
* based on a http.Request.
|
|
||||||
*/
|
|
||||||
return "http://<your_app_id>.appspot.com"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
u := UserService{}
|
|
||||||
u.Register()
|
|
||||||
|
|
||||||
// Optionally, you can install the Swagger Service which provides a nice Web UI on your REST API
|
|
||||||
// You need to download the Swagger HTML5 assets and change the FilePath location in the config below.
|
|
||||||
// Open <your_app_id>.appspot.com/apidocs and enter http://<your_app_id>.appspot.com/apidocs.json in the api input field.
|
|
||||||
config := swagger.Config{
|
|
||||||
WebServices: restful.RegisteredWebServices(), // you control what services are visible
|
|
||||||
WebServicesUrl: getGaeURL(),
|
|
||||||
ApiPath: "/apidocs.json",
|
|
||||||
|
|
||||||
// Optionally, specifiy where the UI is located
|
|
||||||
SwaggerPath: "/apidocs/",
|
|
||||||
// GAE support static content which is configured in your app.yaml.
|
|
||||||
// This example expect the swagger-ui in static/swagger so you should place it there :)
|
|
||||||
SwaggerFilePath: "static/swagger"}
|
|
||||||
swagger.InstallSwaggerService(config)
|
|
||||||
}
|
|
7
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/home.html
generated
vendored
7
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/home.html
generated
vendored
|
@ -1,7 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
|
|
||||||
<html>
|
|
||||||
<body>
|
|
||||||
<h1>{{.Text}}</h1>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
67
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-CORS-filter.go
generated
vendored
67
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-CORS-filter.go
generated
vendored
|
@ -1,67 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Cross-origin resource sharing (CORS) is a mechanism that allows JavaScript on a web page
|
|
||||||
// to make XMLHttpRequests to another domain, not the domain the JavaScript originated from.
|
|
||||||
//
|
|
||||||
// http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
|
|
||||||
// http://enable-cors.org/server.html
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/users
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
// PUT http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
// DELETE http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
// OPTIONS http://localhost:8080/users/1 with Header "Origin" set to some domain and
|
|
||||||
|
|
||||||
type UserResource struct{}
|
|
||||||
|
|
||||||
func (u UserResource) RegisterTo(container *restful.Container) {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.
|
|
||||||
Path("/users").
|
|
||||||
Consumes("*/*").
|
|
||||||
Produces("*/*")
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{user-id}").To(u.nop))
|
|
||||||
ws.Route(ws.POST("").To(u.nop))
|
|
||||||
ws.Route(ws.PUT("/{user-id}").To(u.nop))
|
|
||||||
ws.Route(ws.DELETE("/{user-id}").To(u.nop))
|
|
||||||
|
|
||||||
container.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserResource) nop(request *restful.Request, response *restful.Response) {
|
|
||||||
io.WriteString(response.ResponseWriter, "this would be a normal response")
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
wsContainer := restful.NewContainer()
|
|
||||||
u := UserResource{}
|
|
||||||
u.RegisterTo(wsContainer)
|
|
||||||
|
|
||||||
// Add container filter to enable CORS
|
|
||||||
cors := restful.CrossOriginResourceSharing{
|
|
||||||
ExposeHeaders: []string{"X-My-Header"},
|
|
||||||
AllowedHeaders: []string{"Content-Type", "Accept"},
|
|
||||||
CookiesAllowed: false,
|
|
||||||
Container: wsContainer}
|
|
||||||
wsContainer.Filter(cors.Filter)
|
|
||||||
|
|
||||||
// Add container filter to respond to OPTIONS
|
|
||||||
wsContainer.Filter(wsContainer.OPTIONSFilter)
|
|
||||||
|
|
||||||
log.Printf("start listening on localhost:8080")
|
|
||||||
server := &http.Server{Addr: ":8080", Handler: wsContainer}
|
|
||||||
log.Fatal(server.ListenAndServe())
|
|
||||||
}
|
|
54
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-NCSA-logging.go
generated
vendored
54
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-NCSA-logging.go
generated
vendored
|
@ -1,54 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to create a filter that produces log lines
|
|
||||||
// according to the Common Log Format, also known as the NCSA standard.
|
|
||||||
//
|
|
||||||
// kindly contributed by leehambley
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/ping
|
|
||||||
|
|
||||||
var logger *log.Logger = log.New(os.Stdout, "", 0)
|
|
||||||
|
|
||||||
func NCSACommonLogFormatLogger() restful.FilterFunction {
|
|
||||||
return func(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
var username = "-"
|
|
||||||
if req.Request.URL.User != nil {
|
|
||||||
if name := req.Request.URL.User.Username(); name != "" {
|
|
||||||
username = name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
logger.Printf("%s - %s [%s] \"%s %s %s\" %d %d",
|
|
||||||
strings.Split(req.Request.RemoteAddr, ":")[0],
|
|
||||||
username,
|
|
||||||
time.Now().Format("02/Jan/2006:15:04:05 -0700"),
|
|
||||||
req.Request.Method,
|
|
||||||
req.Request.URL.RequestURI(),
|
|
||||||
req.Request.Proto,
|
|
||||||
resp.StatusCode(),
|
|
||||||
resp.ContentLength(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Filter(NCSACommonLogFormatLogger())
|
|
||||||
ws.Route(ws.GET("/ping").To(hello))
|
|
||||||
restful.Add(ws)
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func hello(req *restful.Request, resp *restful.Response) {
|
|
||||||
io.WriteString(resp, "pong")
|
|
||||||
}
|
|
|
@ -1,35 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to create a (Route) Filter that performs Basic Authentication on the Http request.
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/secret
|
|
||||||
// and use admin,admin for the credentials
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Route(ws.GET("/secret").Filter(basicAuthenticate).To(secret))
|
|
||||||
restful.Add(ws)
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func basicAuthenticate(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
encoded := req.Request.Header.Get("Authorization")
|
|
||||||
// usr/pwd = admin/admin
|
|
||||||
// real code does some decoding
|
|
||||||
if len(encoded) == 0 || "Basic YWRtaW46YWRtaW4=" != encoded {
|
|
||||||
resp.AddHeader("WWW-Authenticate", "Basic realm=Protected Area")
|
|
||||||
resp.WriteErrorString(401, "401: Not Authorized")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func secret(req *restful.Request, resp *restful.Response) {
|
|
||||||
io.WriteString(resp, "42")
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"runtime/pprof"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ProfilingService is a WebService that can start/stop a CPU profile and write results to a file
|
|
||||||
// GET /{rootPath}/start will activate CPU profiling
|
|
||||||
// GET /{rootPath}/stop will stop profiling
|
|
||||||
//
|
|
||||||
// NewProfileService("/profiler", "ace.prof").AddWebServiceTo(restful.DefaultContainer)
|
|
||||||
//
|
|
||||||
type ProfilingService struct {
|
|
||||||
rootPath string // the base (root) of the service, e.g. /profiler
|
|
||||||
cpuprofile string // the output filename to write profile results, e.g. myservice.prof
|
|
||||||
cpufile *os.File // if not nil, then profiling is active
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewProfileService(rootPath string, outputFilename string) *ProfilingService {
|
|
||||||
ps := new(ProfilingService)
|
|
||||||
ps.rootPath = rootPath
|
|
||||||
ps.cpuprofile = outputFilename
|
|
||||||
return ps
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add this ProfileService to a restful Container
|
|
||||||
func (p ProfilingService) AddWebServiceTo(container *restful.Container) {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Path(p.rootPath).Consumes("*/*").Produces(restful.MIME_JSON)
|
|
||||||
ws.Route(ws.GET("/start").To(p.startProfiler))
|
|
||||||
ws.Route(ws.GET("/stop").To(p.stopProfiler))
|
|
||||||
container.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ProfilingService) startProfiler(req *restful.Request, resp *restful.Response) {
|
|
||||||
if p.cpufile != nil {
|
|
||||||
io.WriteString(resp.ResponseWriter, "[restful] CPU profiling already running")
|
|
||||||
return // error?
|
|
||||||
}
|
|
||||||
cpufile, err := os.Create(p.cpuprofile)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
// remember for close
|
|
||||||
p.cpufile = cpufile
|
|
||||||
pprof.StartCPUProfile(cpufile)
|
|
||||||
io.WriteString(resp.ResponseWriter, "[restful] CPU profiling started, writing on:"+p.cpuprofile)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ProfilingService) stopProfiler(req *restful.Request, resp *restful.Response) {
|
|
||||||
if p.cpufile == nil {
|
|
||||||
io.WriteString(resp.ResponseWriter, "[restful] CPU profiling not active")
|
|
||||||
return // error?
|
|
||||||
}
|
|
||||||
pprof.StopCPUProfile()
|
|
||||||
p.cpufile.Close()
|
|
||||||
p.cpufile = nil
|
|
||||||
io.WriteString(resp.ResponseWriter, "[restful] CPU profiling stopped, closing:"+p.cpuprofile)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {} // exists for example compilation only
|
|
107
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-curly-router.go
generated
vendored
107
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-curly-router.go
generated
vendored
|
@ -1,107 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example has the same service definition as restful-user-resource
|
|
||||||
// but uses a different router (CurlyRouter) that does not use regular expressions
|
|
||||||
//
|
|
||||||
// POST http://localhost:8080/users
|
|
||||||
// <User><Id>1</Id><Name>Melissa Raspberry</Name></User>
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
// PUT http://localhost:8080/users/1
|
|
||||||
// <User><Id>1</Id><Name>Melissa</Name></User>
|
|
||||||
//
|
|
||||||
// DELETE http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Id, Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserResource struct {
|
|
||||||
// normally one would use DAO (data access object)
|
|
||||||
users map[string]User
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserResource) Register(container *restful.Container) {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.
|
|
||||||
Path("/users").
|
|
||||||
Consumes(restful.MIME_XML, restful.MIME_JSON).
|
|
||||||
Produces(restful.MIME_JSON, restful.MIME_XML) // you can specify this per route as well
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{user-id}").To(u.findUser))
|
|
||||||
ws.Route(ws.POST("").To(u.updateUser))
|
|
||||||
ws.Route(ws.PUT("/{user-id}").To(u.createUser))
|
|
||||||
ws.Route(ws.DELETE("/{user-id}").To(u.removeUser))
|
|
||||||
|
|
||||||
container.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
func (u UserResource) findUser(request *restful.Request, response *restful.Response) {
|
|
||||||
id := request.PathParameter("user-id")
|
|
||||||
usr := u.users[id]
|
|
||||||
if len(usr.Id) == 0 {
|
|
||||||
response.AddHeader("Content-Type", "text/plain")
|
|
||||||
response.WriteErrorString(http.StatusNotFound, "User could not be found.")
|
|
||||||
} else {
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST http://localhost:8080/users
|
|
||||||
// <User><Id>1</Id><Name>Melissa Raspberry</Name></User>
|
|
||||||
//
|
|
||||||
func (u *UserResource) updateUser(request *restful.Request, response *restful.Response) {
|
|
||||||
usr := new(User)
|
|
||||||
err := request.ReadEntity(&usr)
|
|
||||||
if err == nil {
|
|
||||||
u.users[usr.Id] = *usr
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
} else {
|
|
||||||
response.AddHeader("Content-Type", "text/plain")
|
|
||||||
response.WriteErrorString(http.StatusInternalServerError, err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT http://localhost:8080/users/1
|
|
||||||
// <User><Id>1</Id><Name>Melissa</Name></User>
|
|
||||||
//
|
|
||||||
func (u *UserResource) createUser(request *restful.Request, response *restful.Response) {
|
|
||||||
usr := User{Id: request.PathParameter("user-id")}
|
|
||||||
err := request.ReadEntity(&usr)
|
|
||||||
if err == nil {
|
|
||||||
u.users[usr.Id] = usr
|
|
||||||
response.WriteHeader(http.StatusCreated)
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
} else {
|
|
||||||
response.AddHeader("Content-Type", "text/plain")
|
|
||||||
response.WriteErrorString(http.StatusInternalServerError, err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
func (u *UserResource) removeUser(request *restful.Request, response *restful.Response) {
|
|
||||||
id := request.PathParameter("user-id")
|
|
||||||
delete(u.users, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
wsContainer := restful.NewContainer()
|
|
||||||
wsContainer.Router(restful.CurlyRouter{})
|
|
||||||
u := UserResource{map[string]User{}}
|
|
||||||
u.Register(wsContainer)
|
|
||||||
|
|
||||||
log.Printf("start listening on localhost:8080")
|
|
||||||
server := &http.Server{Addr: ":8080", Handler: wsContainer}
|
|
||||||
log.Fatal(server.ListenAndServe())
|
|
||||||
}
|
|
61
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-encoding-filter.go
generated
vendored
61
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-encoding-filter.go
generated
vendored
|
@ -1,61 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Id, Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserList struct {
|
|
||||||
Users []User
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// This example shows how to use the CompressingResponseWriter by a Filter
|
|
||||||
// such that encoding can be enabled per WebService or per Route (instead of per container)
|
|
||||||
// Using restful.DefaultContainer.EnableContentEncoding(true) will encode all responses served by WebServices in the DefaultContainer.
|
|
||||||
//
|
|
||||||
// Set Accept-Encoding to gzip or deflate
|
|
||||||
// GET http://localhost:8080/users/42
|
|
||||||
// and look at the response headers
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
restful.Add(NewUserService())
|
|
||||||
log.Printf("start listening on localhost:8080")
|
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewUserService() *restful.WebService {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.
|
|
||||||
Path("/users").
|
|
||||||
Consumes(restful.MIME_XML, restful.MIME_JSON).
|
|
||||||
Produces(restful.MIME_JSON, restful.MIME_XML)
|
|
||||||
|
|
||||||
// install a response encoding filter
|
|
||||||
ws.Route(ws.GET("/{user-id}").Filter(encodingFilter).To(findUser))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route Filter (defines FilterFunction)
|
|
||||||
func encodingFilter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
log.Printf("[encoding-filter] %s,%s\n", req.Request.Method, req.Request.URL)
|
|
||||||
// wrap responseWriter into a compressing one
|
|
||||||
compress, _ := restful.NewCompressingResponseWriter(resp.ResponseWriter, restful.ENCODING_GZIP)
|
|
||||||
resp.ResponseWriter = compress
|
|
||||||
defer func() {
|
|
||||||
compress.Close()
|
|
||||||
}()
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/users/42
|
|
||||||
//
|
|
||||||
func findUser(request *restful.Request, response *restful.Response) {
|
|
||||||
log.Printf("findUser")
|
|
||||||
response.WriteEntity(User{"42", "Gandalf"})
|
|
||||||
}
|
|
114
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-filters.go
generated
vendored
114
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-filters.go
generated
vendored
|
@ -1,114 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Id, Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserList struct {
|
|
||||||
Users []User
|
|
||||||
}
|
|
||||||
|
|
||||||
// This example show how to create and use the three different Filters (Container,WebService and Route)
|
|
||||||
// When applied to the restful.DefaultContainer, we refer to them as a global filter.
|
|
||||||
//
|
|
||||||
// GET http://locahost:8080/users/42
|
|
||||||
// and see the logging per filter (try repeating this request)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// install a global (=DefaultContainer) filter (processed before any webservice in the DefaultContainer)
|
|
||||||
restful.Filter(globalLogging)
|
|
||||||
|
|
||||||
restful.Add(NewUserService())
|
|
||||||
log.Printf("start listening on localhost:8080")
|
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewUserService() *restful.WebService {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.
|
|
||||||
Path("/users").
|
|
||||||
Consumes(restful.MIME_XML, restful.MIME_JSON).
|
|
||||||
Produces(restful.MIME_JSON, restful.MIME_XML)
|
|
||||||
|
|
||||||
// install a webservice filter (processed before any route)
|
|
||||||
ws.Filter(webserviceLogging).Filter(measureTime)
|
|
||||||
|
|
||||||
// install a counter filter
|
|
||||||
ws.Route(ws.GET("").Filter(NewCountFilter().routeCounter).To(getAllUsers))
|
|
||||||
|
|
||||||
// install 2 chained route filters (processed before calling findUser)
|
|
||||||
ws.Route(ws.GET("/{user-id}").Filter(routeLogging).Filter(NewCountFilter().routeCounter).To(findUser))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
// Global Filter
|
|
||||||
func globalLogging(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
log.Printf("[global-filter (logger)] %s,%s\n", req.Request.Method, req.Request.URL)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WebService Filter
|
|
||||||
func webserviceLogging(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
log.Printf("[webservice-filter (logger)] %s,%s\n", req.Request.Method, req.Request.URL)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// WebService (post-process) Filter (as a struct that defines a FilterFunction)
|
|
||||||
func measureTime(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
now := time.Now()
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
log.Printf("[webservice-filter (timer)] %v\n", time.Now().Sub(now))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route Filter (defines FilterFunction)
|
|
||||||
func routeLogging(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
log.Printf("[route-filter (logger)] %s,%s\n", req.Request.Method, req.Request.URL)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Route Filter (as a struct that defines a FilterFunction)
|
|
||||||
// CountFilter implements a FilterFunction for counting requests.
|
|
||||||
type CountFilter struct {
|
|
||||||
count int
|
|
||||||
counter chan int // for go-routine safe count increments
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewCountFilter creates and initializes a new CountFilter.
|
|
||||||
func NewCountFilter() *CountFilter {
|
|
||||||
c := new(CountFilter)
|
|
||||||
c.counter = make(chan int)
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
c.count += <-c.counter
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
return c
|
|
||||||
}
|
|
||||||
|
|
||||||
// routeCounter increments the count of the filter (through a channel)
|
|
||||||
func (c *CountFilter) routeCounter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
c.counter <- 1
|
|
||||||
log.Printf("[route-filter (counter)] count:%d", c.count)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/users
|
|
||||||
//
|
|
||||||
func getAllUsers(request *restful.Request, response *restful.Response) {
|
|
||||||
log.Printf("getAllUsers")
|
|
||||||
response.WriteEntity(UserList{[]User{User{"42", "Gandalf"}, User{"3.14", "Pi"}}})
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/users/42
|
|
||||||
//
|
|
||||||
func findUser(request *restful.Request, response *restful.Response) {
|
|
||||||
log.Printf("findUser")
|
|
||||||
response.WriteEntity(User{"42", "Gandalf"})
|
|
||||||
}
|
|
62
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-form-handling.go
generated
vendored
62
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-form-handling.go
generated
vendored
|
@ -1,62 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/gorilla/schema"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to handle a POST of a HTML form that uses the standard x-www-form-urlencoded content-type.
|
|
||||||
// It uses the gorilla web tool kit schema package to decode the form data into a struct.
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/profiles
|
|
||||||
//
|
|
||||||
|
|
||||||
type Profile struct {
|
|
||||||
Name string
|
|
||||||
Age int
|
|
||||||
}
|
|
||||||
|
|
||||||
var decoder *schema.Decoder
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
decoder = schema.NewDecoder()
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Route(ws.POST("/profiles").Consumes("application/x-www-form-urlencoded").To(postAdddress))
|
|
||||||
ws.Route(ws.GET("/profiles").To(addresssForm))
|
|
||||||
restful.Add(ws)
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func postAdddress(req *restful.Request, resp *restful.Response) {
|
|
||||||
err := req.Request.ParseForm()
|
|
||||||
if err != nil {
|
|
||||||
resp.WriteErrorString(http.StatusBadRequest, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
p := new(Profile)
|
|
||||||
err = decoder.Decode(p, req.Request.PostForm)
|
|
||||||
if err != nil {
|
|
||||||
resp.WriteErrorString(http.StatusBadRequest, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
io.WriteString(resp.ResponseWriter, fmt.Sprintf("<html><body>Name=%s, Age=%d</body></html>", p.Name, p.Age))
|
|
||||||
}
|
|
||||||
|
|
||||||
func addresssForm(req *restful.Request, resp *restful.Response) {
|
|
||||||
io.WriteString(resp.ResponseWriter,
|
|
||||||
`<html>
|
|
||||||
<body>
|
|
||||||
<h1>Enter Profile</h1>
|
|
||||||
<form method="post">
|
|
||||||
<label>Name:</label>
|
|
||||||
<input type="text" name="Name"/>
|
|
||||||
<label>Age:</label>
|
|
||||||
<input type="text" name="Age"/>
|
|
||||||
<input type="Submit" />
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>`)
|
|
||||||
}
|
|
22
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-hello-world.go
generated
vendored
22
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-hello-world.go
generated
vendored
|
@ -1,22 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows the minimal code needed to get a restful.WebService working.
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/hello
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Route(ws.GET("/hello").To(hello))
|
|
||||||
restful.Add(ws)
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func hello(req *restful.Request, resp *restful.Response) {
|
|
||||||
io.WriteString(resp, "world")
|
|
||||||
}
|
|
35
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-html-template.go
generated
vendored
35
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-html-template.go
generated
vendored
|
@ -1,35 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to serve a HTML page using the standard Go template engine.
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Route(ws.GET("/").To(home))
|
|
||||||
restful.Add(ws)
|
|
||||||
print("open browser on http://localhost:8080/\n")
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Message struct {
|
|
||||||
Text string
|
|
||||||
}
|
|
||||||
|
|
||||||
func home(req *restful.Request, resp *restful.Response) {
|
|
||||||
p := &Message{"restful-html-template demo"}
|
|
||||||
// you might want to cache compiled templates
|
|
||||||
t, err := template.ParseFiles("home.html")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Template gave: %s", err)
|
|
||||||
}
|
|
||||||
t.Execute(resp.ResponseWriter, p)
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to have a program with 2 WebServices containers
|
|
||||||
// each having a http server listening on its own port.
|
|
||||||
//
|
|
||||||
// The first "hello" is added to the restful.DefaultContainer (and uses DefaultServeMux)
|
|
||||||
// For the second "hello", a new container and ServeMux is created
|
|
||||||
// and requires a new http.Server with the container being the Handler.
|
|
||||||
// This first server is spawn in its own go-routine such that the program proceeds to create the second.
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/hello
|
|
||||||
// GET http://localhost:8081/hello
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Route(ws.GET("/hello").To(hello))
|
|
||||||
restful.Add(ws)
|
|
||||||
go func() {
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}()
|
|
||||||
|
|
||||||
container2 := restful.NewContainer()
|
|
||||||
ws2 := new(restful.WebService)
|
|
||||||
ws2.Route(ws2.GET("/hello").To(hello2))
|
|
||||||
container2.Add(ws2)
|
|
||||||
server := &http.Server{Addr: ":8081", Handler: container2}
|
|
||||||
log.Fatal(server.ListenAndServe())
|
|
||||||
}
|
|
||||||
|
|
||||||
func hello(req *restful.Request, resp *restful.Response) {
|
|
||||||
io.WriteString(resp, "default world")
|
|
||||||
}
|
|
||||||
|
|
||||||
func hello2(req *restful.Request, resp *restful.Response) {
|
|
||||||
io.WriteString(resp, "second world")
|
|
||||||
}
|
|
51
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-options-filter.go
generated
vendored
51
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-options-filter.go
generated
vendored
|
@ -1,51 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to use the OPTIONSFilter on a Container
|
|
||||||
//
|
|
||||||
// OPTIONS http://localhost:8080/users
|
|
||||||
//
|
|
||||||
// OPTIONS http://localhost:8080/users/1
|
|
||||||
|
|
||||||
type UserResource struct{}
|
|
||||||
|
|
||||||
func (u UserResource) RegisterTo(container *restful.Container) {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.
|
|
||||||
Path("/users").
|
|
||||||
Consumes("*/*").
|
|
||||||
Produces("*/*")
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{user-id}").To(u.nop))
|
|
||||||
ws.Route(ws.POST("").To(u.nop))
|
|
||||||
ws.Route(ws.PUT("/{user-id}").To(u.nop))
|
|
||||||
ws.Route(ws.DELETE("/{user-id}").To(u.nop))
|
|
||||||
|
|
||||||
container.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserResource) nop(request *restful.Request, response *restful.Response) {
|
|
||||||
io.WriteString(response.ResponseWriter, "this would be a normal response")
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
wsContainer := restful.NewContainer()
|
|
||||||
u := UserResource{}
|
|
||||||
u.RegisterTo(wsContainer)
|
|
||||||
|
|
||||||
// Add container filter to respond to OPTIONS
|
|
||||||
wsContainer.Filter(wsContainer.OPTIONSFilter)
|
|
||||||
|
|
||||||
// For use on the default container, you can write
|
|
||||||
// restful.Filter(restful.OPTIONSFilter())
|
|
||||||
|
|
||||||
log.Printf("start listening on localhost:8080")
|
|
||||||
server := &http.Server{Addr: ":8080", Handler: wsContainer}
|
|
||||||
log.Fatal(server.ListenAndServe())
|
|
||||||
}
|
|
26
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-path-tail.go
generated
vendored
26
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-path-tail.go
generated
vendored
|
@ -1,26 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
. "github.com/emicklei/go-restful"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to a Route that matches the "tail" of a path.
|
|
||||||
// Requires the use of a CurlyRouter and the star "*" path parameter pattern.
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/basepath/some/other/location/test.xml
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
DefaultContainer.Router(CurlyRouter{})
|
|
||||||
ws := new(WebService)
|
|
||||||
ws.Route(ws.GET("/basepath/{resource:*}").To(staticFromPathParam))
|
|
||||||
Add(ws)
|
|
||||||
|
|
||||||
println("[go-restful] serve path tails from http://localhost:8080/basepath")
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func staticFromPathParam(req *Request, resp *Response) {
|
|
||||||
io.WriteString(resp, "Tail="+req.PathParameter("resource"))
|
|
||||||
}
|
|
|
@ -1,98 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"io"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how the different types of filters are called in the request-response flow.
|
|
||||||
// The call chain is logged on the console when sending an http request.
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/1
|
|
||||||
// GET http://localhost:8080/2
|
|
||||||
|
|
||||||
var indentLevel int
|
|
||||||
|
|
||||||
func container_filter_A(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
log.Printf("url path:%v\n", req.Request.URL)
|
|
||||||
trace("container_filter_A: before", 1)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
trace("container_filter_A: after", -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func container_filter_B(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
trace("container_filter_B: before", 1)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
trace("container_filter_B: after", -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func service_filter_A(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
trace("service_filter_A: before", 1)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
trace("service_filter_A: after", -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func service_filter_B(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
trace("service_filter_B: before", 1)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
trace("service_filter_B: after", -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func route_filter_A(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
trace("route_filter_A: before", 1)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
trace("route_filter_A: after", -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func route_filter_B(req *restful.Request, resp *restful.Response, chain *restful.FilterChain) {
|
|
||||||
trace("route_filter_B: before", 1)
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
trace("route_filter_B: after", -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func trace(what string, delta int) {
|
|
||||||
indented := what
|
|
||||||
if delta < 0 {
|
|
||||||
indentLevel += delta
|
|
||||||
}
|
|
||||||
for t := 0; t < indentLevel; t++ {
|
|
||||||
indented = "." + indented
|
|
||||||
}
|
|
||||||
log.Printf("%s", indented)
|
|
||||||
if delta > 0 {
|
|
||||||
indentLevel += delta
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
restful.Filter(container_filter_A)
|
|
||||||
restful.Filter(container_filter_B)
|
|
||||||
|
|
||||||
ws1 := new(restful.WebService)
|
|
||||||
ws1.Path("/1")
|
|
||||||
ws1.Filter(service_filter_A)
|
|
||||||
ws1.Filter(service_filter_B)
|
|
||||||
ws1.Route(ws1.GET("").To(doit1).Filter(route_filter_A).Filter(route_filter_B))
|
|
||||||
|
|
||||||
ws2 := new(restful.WebService)
|
|
||||||
ws2.Path("/2")
|
|
||||||
ws2.Filter(service_filter_A)
|
|
||||||
ws2.Filter(service_filter_B)
|
|
||||||
ws2.Route(ws2.GET("").To(doit2).Filter(route_filter_A).Filter(route_filter_B))
|
|
||||||
|
|
||||||
restful.Add(ws1)
|
|
||||||
restful.Add(ws2)
|
|
||||||
|
|
||||||
log.Print("go-restful example listing on http://localhost:8080/1 and http://localhost:8080/2")
|
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
||||||
}
|
|
||||||
|
|
||||||
func doit1(req *restful.Request, resp *restful.Response) {
|
|
||||||
io.WriteString(resp, "nothing to see in 1")
|
|
||||||
}
|
|
||||||
|
|
||||||
func doit2(req *restful.Request, resp *restful.Response) {
|
|
||||||
io.WriteString(resp, "nothing to see in 2")
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to use methods as RouteFunctions for WebServices.
|
|
||||||
// The ProductResource has a Register() method that creates and initializes
|
|
||||||
// a WebService to expose its methods as REST operations.
|
|
||||||
// The WebService is added to the restful.DefaultContainer.
|
|
||||||
// A ProductResource is typically created using some data access object.
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/products/1
|
|
||||||
// POST http://localhost:8080/products
|
|
||||||
// <Product><Id>1</Id><Title>The First</Title></Product>
|
|
||||||
|
|
||||||
type Product struct {
|
|
||||||
Id, Title string
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProductResource struct {
|
|
||||||
// typically reference a DAO (data-access-object)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p ProductResource) getOne(req *restful.Request, resp *restful.Response) {
|
|
||||||
id := req.PathParameter("id")
|
|
||||||
log.Println("getting product with id:" + id)
|
|
||||||
resp.WriteEntity(Product{Id: id, Title: "test"})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p ProductResource) postOne(req *restful.Request, resp *restful.Response) {
|
|
||||||
updatedProduct := new(Product)
|
|
||||||
err := req.ReadEntity(updatedProduct)
|
|
||||||
if err != nil { // bad request
|
|
||||||
resp.WriteErrorString(http.StatusBadRequest, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
log.Println("updating product with id:" + updatedProduct.Id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p ProductResource) Register() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Path("/products")
|
|
||||||
ws.Consumes(restful.MIME_XML)
|
|
||||||
ws.Produces(restful.MIME_XML)
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{id}").To(p.getOne).
|
|
||||||
Doc("get the product by its id").
|
|
||||||
Param(ws.PathParameter("id", "identifier of the product").DataType("string")))
|
|
||||||
|
|
||||||
ws.Route(ws.POST("").To(p.postOne).
|
|
||||||
Doc("update or create a product").
|
|
||||||
Param(ws.BodyParameter("Product", "a Product (XML)").DataType("main.Product")))
|
|
||||||
|
|
||||||
restful.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ProductResource{}.Register()
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
39
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-route_test.go
generated
vendored
39
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-route_test.go
generated
vendored
|
@ -1,39 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
Result string
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestRouteExtractParameter(t *testing.T) {
|
|
||||||
// setup service
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Consumes(restful.MIME_XML)
|
|
||||||
ws.Route(ws.GET("/test/{param}").To(DummyHandler))
|
|
||||||
restful.Add(ws)
|
|
||||||
|
|
||||||
// setup request + writer
|
|
||||||
bodyReader := strings.NewReader("<Sample><Value>42</Value></Sample>")
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test/THIS", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", restful.MIME_XML)
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
|
|
||||||
// run
|
|
||||||
restful.DefaultContainer.ServeHTTP(httpWriter, httpRequest)
|
|
||||||
|
|
||||||
if Result != "THIS" {
|
|
||||||
t.Fatalf("Result is actually: %s", Result)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func DummyHandler(rq *restful.Request, rp *restful.Response) {
|
|
||||||
Result = rq.PathParameter("param")
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example show how to test one particular RouteFunction (getIt)
|
|
||||||
// It uses the httptest.ResponseRecorder to capture output
|
|
||||||
|
|
||||||
func getIt(req *restful.Request, resp *restful.Response) {
|
|
||||||
resp.WriteHeader(204)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCallFunction(t *testing.T) {
|
|
||||||
httpReq, _ := http.NewRequest("GET", "/", nil)
|
|
||||||
req := restful.NewRequest(httpReq)
|
|
||||||
|
|
||||||
recorder := new(httptest.ResponseRecorder)
|
|
||||||
resp := restful.NewResponse(recorder)
|
|
||||||
|
|
||||||
getIt(req, resp)
|
|
||||||
if recorder.Code != 204 {
|
|
||||||
t.Fatalf("Missing or wrong status code:%d", recorder.Code)
|
|
||||||
}
|
|
||||||
}
|
|
47
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-serve-static.go
generated
vendored
47
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-serve-static.go
generated
vendored
|
@ -1,47 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"net/http"
|
|
||||||
"path"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example shows how to define methods that serve static files
|
|
||||||
// It uses the standard http.ServeFile method
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/static/test.xml
|
|
||||||
// GET http://localhost:8080/static/
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/static?resource=subdir/test.xml
|
|
||||||
|
|
||||||
var rootdir = "/tmp"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
restful.DefaultContainer.Router(restful.CurlyRouter{})
|
|
||||||
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Route(ws.GET("/static/{subpath:*}").To(staticFromPathParam))
|
|
||||||
ws.Route(ws.GET("/static").To(staticFromQueryParam))
|
|
||||||
restful.Add(ws)
|
|
||||||
|
|
||||||
println("[go-restful] serving files on http://localhost:8080/static from local /tmp")
|
|
||||||
http.ListenAndServe(":8080", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func staticFromPathParam(req *restful.Request, resp *restful.Response) {
|
|
||||||
actual := path.Join(rootdir, req.PathParameter("subpath"))
|
|
||||||
fmt.Printf("serving %s ... (from %s)\n", actual, req.PathParameter("subpath"))
|
|
||||||
http.ServeFile(
|
|
||||||
resp.ResponseWriter,
|
|
||||||
req.Request,
|
|
||||||
actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
func staticFromQueryParam(req *restful.Request, resp *restful.Response) {
|
|
||||||
http.ServeFile(
|
|
||||||
resp.ResponseWriter,
|
|
||||||
req.Request,
|
|
||||||
path.Join(rootdir, req.QueryParameter("resource")))
|
|
||||||
}
|
|
61
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-swagger.go
generated
vendored
61
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-swagger.go
generated
vendored
|
@ -1,61 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/emicklei/go-restful/swagger"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Book struct {
|
|
||||||
Title string
|
|
||||||
Author string
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Path("/books")
|
|
||||||
ws.Consumes(restful.MIME_JSON, restful.MIME_XML)
|
|
||||||
ws.Produces(restful.MIME_JSON, restful.MIME_XML)
|
|
||||||
restful.Add(ws)
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{medium}").To(noop).
|
|
||||||
Doc("Search all books").
|
|
||||||
Param(ws.PathParameter("medium", "digital or paperback").DataType("string")).
|
|
||||||
Param(ws.QueryParameter("language", "en,nl,de").DataType("string")).
|
|
||||||
Param(ws.HeaderParameter("If-Modified-Since", "last known timestamp").DataType("datetime")).
|
|
||||||
Do(returns200, returns500))
|
|
||||||
|
|
||||||
ws.Route(ws.PUT("/{medium}").To(noop).
|
|
||||||
Doc("Add a new book").
|
|
||||||
Param(ws.PathParameter("medium", "digital or paperback").DataType("string")).
|
|
||||||
Reads(Book{}))
|
|
||||||
|
|
||||||
// You can install the Swagger Service which provides a nice Web UI on your REST API
|
|
||||||
// You need to download the Swagger HTML5 assets and change the FilePath location in the config below.
|
|
||||||
// Open http://localhost:8080/apidocs and enter http://localhost:8080/apidocs.json in the api input field.
|
|
||||||
config := swagger.Config{
|
|
||||||
WebServices: restful.DefaultContainer.RegisteredWebServices(), // you control what services are visible
|
|
||||||
WebServicesUrl: "http://localhost:8080",
|
|
||||||
ApiPath: "/apidocs.json",
|
|
||||||
|
|
||||||
// Optionally, specifiy where the UI is located
|
|
||||||
SwaggerPath: "/apidocs/",
|
|
||||||
SwaggerFilePath: "/Users/emicklei/xProjects/swagger-ui/dist"}
|
|
||||||
swagger.RegisterSwaggerService(config, restful.DefaultContainer)
|
|
||||||
|
|
||||||
log.Printf("start listening on localhost:8080")
|
|
||||||
server := &http.Server{Addr: ":8080", Handler: restful.DefaultContainer}
|
|
||||||
log.Fatal(server.ListenAndServe())
|
|
||||||
}
|
|
||||||
|
|
||||||
func noop(req *restful.Request, resp *restful.Response) {}
|
|
||||||
|
|
||||||
func returns200(b *restful.RouteBuilder) {
|
|
||||||
b.Returns(http.StatusOK, "OK", Book{})
|
|
||||||
}
|
|
||||||
|
|
||||||
func returns500(b *restful.RouteBuilder) {
|
|
||||||
b.Returns(http.StatusInternalServerError, "Bummer, something went wrong", nil)
|
|
||||||
}
|
|
152
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-user-resource.go
generated
vendored
152
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-user-resource.go
generated
vendored
|
@ -1,152 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/emicklei/go-restful/swagger"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example show a complete (GET,PUT,POST,DELETE) conventional example of
|
|
||||||
// a REST Resource including documentation to be served by e.g. a Swagger UI
|
|
||||||
// It is recommended to create a Resource struct (UserResource) that can encapsulate
|
|
||||||
// an object that provide domain access (a DAO)
|
|
||||||
// It has a Register method including the complete Route mapping to methods together
|
|
||||||
// with all the appropriate documentation
|
|
||||||
//
|
|
||||||
// POST http://localhost:8080/users
|
|
||||||
// <User><Id>1</Id><Name>Melissa Raspberry</Name></User>
|
|
||||||
//
|
|
||||||
// GET http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
// PUT http://localhost:8080/users/1
|
|
||||||
// <User><Id>1</Id><Name>Melissa</Name></User>
|
|
||||||
//
|
|
||||||
// DELETE http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Id, Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserResource struct {
|
|
||||||
// normally one would use DAO (data access object)
|
|
||||||
users map[string]User
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserResource) Register(container *restful.Container) {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.
|
|
||||||
Path("/users").
|
|
||||||
Doc("Manage Users").
|
|
||||||
Consumes(restful.MIME_XML, restful.MIME_JSON).
|
|
||||||
Produces(restful.MIME_JSON, restful.MIME_XML) // you can specify this per route as well
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{user-id}").To(u.findUser).
|
|
||||||
// docs
|
|
||||||
Doc("get a user").
|
|
||||||
Operation("findUser").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
|
|
||||||
Writes(User{})) // on the response
|
|
||||||
|
|
||||||
ws.Route(ws.PUT("/{user-id}").To(u.updateUser).
|
|
||||||
// docs
|
|
||||||
Doc("update a user").
|
|
||||||
Operation("updateUser").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
|
|
||||||
ReturnsError(409, "duplicate user-id", nil).
|
|
||||||
Reads(User{})) // from the request
|
|
||||||
|
|
||||||
ws.Route(ws.POST("").To(u.createUser).
|
|
||||||
// docs
|
|
||||||
Doc("create a user").
|
|
||||||
Operation("createUser").
|
|
||||||
Reads(User{})) // from the request
|
|
||||||
|
|
||||||
ws.Route(ws.DELETE("/{user-id}").To(u.removeUser).
|
|
||||||
// docs
|
|
||||||
Doc("delete a user").
|
|
||||||
Operation("removeUser").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")))
|
|
||||||
|
|
||||||
container.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
func (u UserResource) findUser(request *restful.Request, response *restful.Response) {
|
|
||||||
id := request.PathParameter("user-id")
|
|
||||||
usr := u.users[id]
|
|
||||||
if len(usr.Id) == 0 {
|
|
||||||
response.AddHeader("Content-Type", "text/plain")
|
|
||||||
response.WriteErrorString(http.StatusNotFound, "404: User could not be found.")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST http://localhost:8080/users
|
|
||||||
// <User><Name>Melissa</Name></User>
|
|
||||||
//
|
|
||||||
func (u *UserResource) createUser(request *restful.Request, response *restful.Response) {
|
|
||||||
usr := new(User)
|
|
||||||
err := request.ReadEntity(usr)
|
|
||||||
if err != nil {
|
|
||||||
response.AddHeader("Content-Type", "text/plain")
|
|
||||||
response.WriteErrorString(http.StatusInternalServerError, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
usr.Id = strconv.Itoa(len(u.users) + 1) // simple id generation
|
|
||||||
u.users[usr.Id] = *usr
|
|
||||||
response.WriteHeaderAndEntity(http.StatusCreated, usr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT http://localhost:8080/users/1
|
|
||||||
// <User><Id>1</Id><Name>Melissa Raspberry</Name></User>
|
|
||||||
//
|
|
||||||
func (u *UserResource) updateUser(request *restful.Request, response *restful.Response) {
|
|
||||||
usr := new(User)
|
|
||||||
err := request.ReadEntity(&usr)
|
|
||||||
if err != nil {
|
|
||||||
response.AddHeader("Content-Type", "text/plain")
|
|
||||||
response.WriteErrorString(http.StatusInternalServerError, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
u.users[usr.Id] = *usr
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
func (u *UserResource) removeUser(request *restful.Request, response *restful.Response) {
|
|
||||||
id := request.PathParameter("user-id")
|
|
||||||
delete(u.users, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
// to see what happens in the package, uncomment the following
|
|
||||||
//restful.TraceLogger(log.New(os.Stdout, "[restful] ", log.LstdFlags|log.Lshortfile))
|
|
||||||
|
|
||||||
wsContainer := restful.NewContainer()
|
|
||||||
u := UserResource{map[string]User{}}
|
|
||||||
u.Register(wsContainer)
|
|
||||||
|
|
||||||
// Optionally, you can install the Swagger Service which provides a nice Web UI on your REST API
|
|
||||||
// You need to download the Swagger HTML5 assets and change the FilePath location in the config below.
|
|
||||||
// Open http://localhost:8080/apidocs and enter http://localhost:8080/apidocs.json in the api input field.
|
|
||||||
config := swagger.Config{
|
|
||||||
WebServices: wsContainer.RegisteredWebServices(), // you control what services are visible
|
|
||||||
WebServicesUrl: "http://localhost:8080",
|
|
||||||
ApiPath: "/apidocs.json",
|
|
||||||
|
|
||||||
// Optionally, specifiy where the UI is located
|
|
||||||
SwaggerPath: "/apidocs/",
|
|
||||||
SwaggerFilePath: "/Users/emicklei/xProjects/swagger-ui/dist"}
|
|
||||||
swagger.RegisterSwaggerService(config, wsContainer)
|
|
||||||
|
|
||||||
log.Printf("start listening on localhost:8080")
|
|
||||||
server := &http.Server{Addr: ":8080", Handler: wsContainer}
|
|
||||||
log.Fatal(server.ListenAndServe())
|
|
||||||
}
|
|
137
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-user-service.go
generated
vendored
137
Godeps/_workspace/src/github.com/emicklei/go-restful/examples/restful-user-service.go
generated
vendored
|
@ -1,137 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"log"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/emicklei/go-restful/swagger"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This example is functionally the same as the example in restful-user-resource.go
|
|
||||||
// with the only difference that is served using the restful.DefaultContainer
|
|
||||||
|
|
||||||
type User struct {
|
|
||||||
Id, Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserService struct {
|
|
||||||
// normally one would use DAO (data access object)
|
|
||||||
users map[string]User
|
|
||||||
}
|
|
||||||
|
|
||||||
func (u UserService) Register() {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.
|
|
||||||
Path("/users").
|
|
||||||
Consumes(restful.MIME_XML, restful.MIME_JSON).
|
|
||||||
Produces(restful.MIME_JSON, restful.MIME_XML) // you can specify this per route as well
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/").To(u.findAllUsers).
|
|
||||||
// docs
|
|
||||||
Doc("get all users").
|
|
||||||
Operation("findAllUsers").
|
|
||||||
Returns(200, "OK", []User{}))
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/{user-id}").To(u.findUser).
|
|
||||||
// docs
|
|
||||||
Doc("get a user").
|
|
||||||
Operation("findUser").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
|
|
||||||
Writes(User{})) // on the response
|
|
||||||
|
|
||||||
ws.Route(ws.PUT("/{user-id}").To(u.updateUser).
|
|
||||||
// docs
|
|
||||||
Doc("update a user").
|
|
||||||
Operation("updateUser").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")).
|
|
||||||
Reads(User{})) // from the request
|
|
||||||
|
|
||||||
ws.Route(ws.PUT("").To(u.createUser).
|
|
||||||
// docs
|
|
||||||
Doc("create a user").
|
|
||||||
Operation("createUser").
|
|
||||||
Reads(User{})) // from the request
|
|
||||||
|
|
||||||
ws.Route(ws.DELETE("/{user-id}").To(u.removeUser).
|
|
||||||
// docs
|
|
||||||
Doc("delete a user").
|
|
||||||
Operation("removeUser").
|
|
||||||
Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")))
|
|
||||||
|
|
||||||
restful.Add(ws)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/users
|
|
||||||
//
|
|
||||||
func (u UserService) findAllUsers(request *restful.Request, response *restful.Response) {
|
|
||||||
response.WriteEntity(u.users)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
func (u UserService) findUser(request *restful.Request, response *restful.Response) {
|
|
||||||
id := request.PathParameter("user-id")
|
|
||||||
usr := u.users[id]
|
|
||||||
if len(usr.Id) == 0 {
|
|
||||||
response.WriteErrorString(http.StatusNotFound, "User could not be found.")
|
|
||||||
} else {
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT http://localhost:8080/users/1
|
|
||||||
// <User><Id>1</Id><Name>Melissa Raspberry</Name></User>
|
|
||||||
//
|
|
||||||
func (u *UserService) updateUser(request *restful.Request, response *restful.Response) {
|
|
||||||
usr := new(User)
|
|
||||||
err := request.ReadEntity(&usr)
|
|
||||||
if err == nil {
|
|
||||||
u.users[usr.Id] = *usr
|
|
||||||
response.WriteEntity(usr)
|
|
||||||
} else {
|
|
||||||
response.WriteError(http.StatusInternalServerError, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT http://localhost:8080/users/1
|
|
||||||
// <User><Id>1</Id><Name>Melissa</Name></User>
|
|
||||||
//
|
|
||||||
func (u *UserService) createUser(request *restful.Request, response *restful.Response) {
|
|
||||||
usr := User{Id: request.PathParameter("user-id")}
|
|
||||||
err := request.ReadEntity(&usr)
|
|
||||||
if err == nil {
|
|
||||||
u.users[usr.Id] = usr
|
|
||||||
response.WriteHeaderAndEntity(http.StatusCreated, usr)
|
|
||||||
} else {
|
|
||||||
response.WriteError(http.StatusInternalServerError, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE http://localhost:8080/users/1
|
|
||||||
//
|
|
||||||
func (u *UserService) removeUser(request *restful.Request, response *restful.Response) {
|
|
||||||
id := request.PathParameter("user-id")
|
|
||||||
delete(u.users, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
u := UserService{map[string]User{}}
|
|
||||||
u.Register()
|
|
||||||
|
|
||||||
// Optionally, you can install the Swagger Service which provides a nice Web UI on your REST API
|
|
||||||
// You need to download the Swagger HTML5 assets and change the FilePath location in the config below.
|
|
||||||
// Open http://localhost:8080/apidocs and enter http://localhost:8080/apidocs.json in the api input field.
|
|
||||||
config := swagger.Config{
|
|
||||||
WebServices: restful.RegisteredWebServices(), // you control what services are visible
|
|
||||||
WebServicesUrl: "http://localhost:8080",
|
|
||||||
ApiPath: "/apidocs.json",
|
|
||||||
|
|
||||||
// Optionally, specifiy where the UI is located
|
|
||||||
SwaggerPath: "/apidocs/",
|
|
||||||
SwaggerFilePath: "/Users/emicklei/Projects/swagger-ui/dist"}
|
|
||||||
swagger.InstallSwaggerService(config)
|
|
||||||
|
|
||||||
log.Printf("start listening on localhost:8080")
|
|
||||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
||||||
}
|
|
141
Godeps/_workspace/src/github.com/emicklei/go-restful/filter_test.go
generated
vendored
141
Godeps/_workspace/src/github.com/emicklei/go-restful/filter_test.go
generated
vendored
|
@ -1,141 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func setupServices(addGlobalFilter bool, addServiceFilter bool, addRouteFilter bool) {
|
|
||||||
if addGlobalFilter {
|
|
||||||
Filter(globalFilter)
|
|
||||||
}
|
|
||||||
Add(newTestService(addServiceFilter, addRouteFilter))
|
|
||||||
}
|
|
||||||
|
|
||||||
func tearDown() {
|
|
||||||
DefaultContainer.webServices = []*WebService{}
|
|
||||||
DefaultContainer.isRegisteredOnRoot = true // this allows for setupServices multiple times
|
|
||||||
DefaultContainer.containerFilters = []FilterFunction{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newTestService(addServiceFilter bool, addRouteFilter bool) *WebService {
|
|
||||||
ws := new(WebService).Path("")
|
|
||||||
if addServiceFilter {
|
|
||||||
ws.Filter(serviceFilter)
|
|
||||||
}
|
|
||||||
rb := ws.GET("/foo").To(foo)
|
|
||||||
if addRouteFilter {
|
|
||||||
rb.Filter(routeFilter)
|
|
||||||
}
|
|
||||||
ws.Route(rb)
|
|
||||||
ws.Route(ws.GET("/bar").To(bar))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
func foo(req *Request, resp *Response) {
|
|
||||||
io.WriteString(resp.ResponseWriter, "foo")
|
|
||||||
}
|
|
||||||
|
|
||||||
func bar(req *Request, resp *Response) {
|
|
||||||
io.WriteString(resp.ResponseWriter, "bar")
|
|
||||||
}
|
|
||||||
|
|
||||||
func fail(req *Request, resp *Response) {
|
|
||||||
http.Error(resp.ResponseWriter, "something failed", http.StatusInternalServerError)
|
|
||||||
}
|
|
||||||
|
|
||||||
func globalFilter(req *Request, resp *Response, chain *FilterChain) {
|
|
||||||
io.WriteString(resp.ResponseWriter, "global-")
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func serviceFilter(req *Request, resp *Response, chain *FilterChain) {
|
|
||||||
io.WriteString(resp.ResponseWriter, "service-")
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func routeFilter(req *Request, resp *Response, chain *FilterChain) {
|
|
||||||
io.WriteString(resp.ResponseWriter, "route-")
|
|
||||||
chain.ProcessFilter(req, resp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoFilter(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
setupServices(false, false, false)
|
|
||||||
actual := sendIt("http://example.com/foo")
|
|
||||||
if "foo" != actual {
|
|
||||||
t.Fatal("expected: foo but got:" + actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGlobalFilter(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
setupServices(true, false, false)
|
|
||||||
actual := sendIt("http://example.com/foo")
|
|
||||||
if "global-foo" != actual {
|
|
||||||
t.Fatal("expected: global-foo but got:" + actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWebServiceFilter(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
setupServices(true, true, false)
|
|
||||||
actual := sendIt("http://example.com/foo")
|
|
||||||
if "global-service-foo" != actual {
|
|
||||||
t.Fatal("expected: global-service-foo but got:" + actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRouteFilter(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
setupServices(true, true, true)
|
|
||||||
actual := sendIt("http://example.com/foo")
|
|
||||||
if "global-service-route-foo" != actual {
|
|
||||||
t.Fatal("expected: global-service-route-foo but got:" + actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRouteFilterOnly(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
setupServices(false, false, true)
|
|
||||||
actual := sendIt("http://example.com/foo")
|
|
||||||
if "route-foo" != actual {
|
|
||||||
t.Fatal("expected: route-foo but got:" + actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBar(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
setupServices(false, true, false)
|
|
||||||
actual := sendIt("http://example.com/bar")
|
|
||||||
if "service-bar" != actual {
|
|
||||||
t.Fatal("expected: service-bar but got:" + actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAllFiltersBar(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
setupServices(true, true, true)
|
|
||||||
actual := sendIt("http://example.com/bar")
|
|
||||||
if "global-service-bar" != actual {
|
|
||||||
t.Fatal("expected: global-service-bar but got:" + actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func sendIt(address string) string {
|
|
||||||
httpRequest, _ := http.NewRequest("GET", address, nil)
|
|
||||||
httpRequest.Header.Set("Accept", "*/*")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
return httpWriter.Body.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func sendItTo(address string, container *Container) string {
|
|
||||||
httpRequest, _ := http.NewRequest("GET", address, nil)
|
|
||||||
httpRequest.Header.Set("Accept", "*/*")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
container.dispatch(httpWriter, httpRequest)
|
|
||||||
return httpWriter.Body.String()
|
|
||||||
}
|
|
212
Godeps/_workspace/src/github.com/emicklei/go-restful/jsr311_test.go
generated
vendored
212
Godeps/_workspace/src/github.com/emicklei/go-restful/jsr311_test.go
generated
vendored
|
@ -1,212 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"io"
|
|
||||||
"sort"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
//
|
|
||||||
// Step 1 tests
|
|
||||||
//
|
|
||||||
var paths = []struct {
|
|
||||||
// url with path (1) is handled by service with root (2) and last capturing group has value final (3)
|
|
||||||
path, root, final string
|
|
||||||
}{
|
|
||||||
{"/", "/", "/"},
|
|
||||||
{"/p", "/p", ""},
|
|
||||||
{"/p/x", "/p/{q}", ""},
|
|
||||||
{"/q/x", "/q", "/x"},
|
|
||||||
{"/p/x/", "/p/{q}", "/"},
|
|
||||||
{"/p/x/y", "/p/{q}", "/y"},
|
|
||||||
{"/q/x/y", "/q", "/x/y"},
|
|
||||||
{"/z/q", "/{p}/q", ""},
|
|
||||||
{"/a/b/c/q", "/", "/a/b/c/q"},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDetectDispatcher(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/")
|
|
||||||
ws2 := new(WebService).Path("/p")
|
|
||||||
ws3 := new(WebService).Path("/q")
|
|
||||||
ws4 := new(WebService).Path("/p/q")
|
|
||||||
ws5 := new(WebService).Path("/p/{q}")
|
|
||||||
ws6 := new(WebService).Path("/p/{q}/")
|
|
||||||
ws7 := new(WebService).Path("/{p}/q")
|
|
||||||
var dispatchers = []*WebService{ws1, ws2, ws3, ws4, ws5, ws6, ws7}
|
|
||||||
|
|
||||||
wc := NewContainer()
|
|
||||||
for _, each := range dispatchers {
|
|
||||||
wc.Add(each)
|
|
||||||
}
|
|
||||||
|
|
||||||
router := RouterJSR311{}
|
|
||||||
|
|
||||||
ok := true
|
|
||||||
for i, fixture := range paths {
|
|
||||||
who, final, err := router.detectDispatcher(fixture.path, dispatchers)
|
|
||||||
if err != nil {
|
|
||||||
t.Logf("error in detection:%v", err)
|
|
||||||
ok = false
|
|
||||||
}
|
|
||||||
if who.RootPath() != fixture.root {
|
|
||||||
t.Logf("[line:%v] Unexpected dispatcher, expected:%v, actual:%v", i, fixture.root, who.RootPath())
|
|
||||||
ok = false
|
|
||||||
}
|
|
||||||
if final != fixture.final {
|
|
||||||
t.Logf("[line:%v] Unexpected final, expected:%v, actual:%v", i, fixture.final, final)
|
|
||||||
ok = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Step 2 tests
|
|
||||||
//
|
|
||||||
|
|
||||||
// go test -v -test.run TestISSUE_179 ...restful
|
|
||||||
func TestISSUE_179(t *testing.T) {
|
|
||||||
ws1 := new(WebService)
|
|
||||||
ws1.Route(ws1.GET("/v1/category/{param:*}").To(dummy))
|
|
||||||
routes := RouterJSR311{}.selectRoutes(ws1, "/v1/category/sub/sub")
|
|
||||||
t.Logf("%v", routes)
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestISSUE_30 ...restful
|
|
||||||
func TestISSUE_30(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/users")
|
|
||||||
ws1.Route(ws1.GET("/{id}").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("/login").To(dummy))
|
|
||||||
routes := RouterJSR311{}.selectRoutes(ws1, "/login")
|
|
||||||
if len(routes) != 2 {
|
|
||||||
t.Fatal("expected 2 routes")
|
|
||||||
}
|
|
||||||
if routes[0].Path != "/users/login" {
|
|
||||||
t.Error("first is", routes[0].Path)
|
|
||||||
t.Logf("routes:%v", routes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestISSUE_34 ...restful
|
|
||||||
func TestISSUE_34(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/")
|
|
||||||
ws1.Route(ws1.GET("/{type}/{id}").To(dummy))
|
|
||||||
ws1.Route(ws1.GET("/network/{id}").To(dummy))
|
|
||||||
routes := RouterJSR311{}.selectRoutes(ws1, "/network/12")
|
|
||||||
if len(routes) != 2 {
|
|
||||||
t.Fatal("expected 2 routes")
|
|
||||||
}
|
|
||||||
if routes[0].Path != "/network/{id}" {
|
|
||||||
t.Error("first is", routes[0].Path)
|
|
||||||
t.Logf("routes:%v", routes)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestISSUE_34_2 ...restful
|
|
||||||
func TestISSUE_34_2(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/")
|
|
||||||
// change the registration order
|
|
||||||
ws1.Route(ws1.GET("/network/{id}").To(dummy))
|
|
||||||
ws1.Route(ws1.GET("/{type}/{id}").To(dummy))
|
|
||||||
routes := RouterJSR311{}.selectRoutes(ws1, "/network/12")
|
|
||||||
if len(routes) != 2 {
|
|
||||||
t.Fatal("expected 2 routes")
|
|
||||||
}
|
|
||||||
if routes[0].Path != "/network/{id}" {
|
|
||||||
t.Error("first is", routes[0].Path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestISSUE_137 ...restful
|
|
||||||
func TestISSUE_137(t *testing.T) {
|
|
||||||
ws1 := new(WebService)
|
|
||||||
ws1.Route(ws1.GET("/hello").To(dummy))
|
|
||||||
routes := RouterJSR311{}.selectRoutes(ws1, "/")
|
|
||||||
t.Log(routes)
|
|
||||||
if len(routes) > 0 {
|
|
||||||
t.Error("no route expected")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSelectRoutesSlash(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/")
|
|
||||||
ws1.Route(ws1.GET("").To(dummy))
|
|
||||||
ws1.Route(ws1.GET("/").To(dummy))
|
|
||||||
ws1.Route(ws1.GET("/u").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("/u").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("/u/v").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("/u/{w}").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("/u/{w}/z").To(dummy))
|
|
||||||
routes := RouterJSR311{}.selectRoutes(ws1, "/u")
|
|
||||||
checkRoutesContains(routes, "/u", t)
|
|
||||||
checkRoutesContainsNo(routes, "/u/v", t)
|
|
||||||
checkRoutesContainsNo(routes, "/", t)
|
|
||||||
checkRoutesContainsNo(routes, "/u/{w}/z", t)
|
|
||||||
}
|
|
||||||
func TestSelectRoutesU(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/u")
|
|
||||||
ws1.Route(ws1.GET("").To(dummy))
|
|
||||||
ws1.Route(ws1.GET("/").To(dummy))
|
|
||||||
ws1.Route(ws1.GET("/v").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("/{w}").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("/{w}/z").To(dummy)) // so full path = /u/{w}/z
|
|
||||||
routes := RouterJSR311{}.selectRoutes(ws1, "/v") // test against /u/v
|
|
||||||
checkRoutesContains(routes, "/u/{w}", t)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSelectRoutesUsers1(t *testing.T) {
|
|
||||||
ws1 := new(WebService).Path("/users")
|
|
||||||
ws1.Route(ws1.POST("").To(dummy))
|
|
||||||
ws1.Route(ws1.POST("/").To(dummy))
|
|
||||||
ws1.Route(ws1.PUT("/{id}").To(dummy))
|
|
||||||
routes := RouterJSR311{}.selectRoutes(ws1, "/1")
|
|
||||||
checkRoutesContains(routes, "/users/{id}", t)
|
|
||||||
}
|
|
||||||
func checkRoutesContains(routes []Route, path string, t *testing.T) {
|
|
||||||
if !containsRoutePath(routes, path, t) {
|
|
||||||
for _, r := range routes {
|
|
||||||
t.Logf("route %v %v", r.Method, r.Path)
|
|
||||||
}
|
|
||||||
t.Fatalf("routes should include [%v]:", path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func checkRoutesContainsNo(routes []Route, path string, t *testing.T) {
|
|
||||||
if containsRoutePath(routes, path, t) {
|
|
||||||
for _, r := range routes {
|
|
||||||
t.Logf("route %v %v", r.Method, r.Path)
|
|
||||||
}
|
|
||||||
t.Fatalf("routes should not include [%v]:", path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func containsRoutePath(routes []Route, path string, t *testing.T) bool {
|
|
||||||
for _, each := range routes {
|
|
||||||
if each.Path == path {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestSortableRouteCandidates ...restful
|
|
||||||
func TestSortableRouteCandidates(t *testing.T) {
|
|
||||||
fixture := &sortableRouteCandidates{}
|
|
||||||
r1 := routeCandidate{matchesCount: 0, literalCount: 0, nonDefaultCount: 0}
|
|
||||||
r2 := routeCandidate{matchesCount: 0, literalCount: 0, nonDefaultCount: 1}
|
|
||||||
r3 := routeCandidate{matchesCount: 0, literalCount: 1, nonDefaultCount: 1}
|
|
||||||
r4 := routeCandidate{matchesCount: 1, literalCount: 1, nonDefaultCount: 0}
|
|
||||||
r5 := routeCandidate{matchesCount: 1, literalCount: 0, nonDefaultCount: 0}
|
|
||||||
fixture.candidates = append(fixture.candidates, r5, r4, r3, r2, r1)
|
|
||||||
sort.Sort(sort.Reverse(fixture))
|
|
||||||
first := fixture.candidates[0]
|
|
||||||
if first.matchesCount != 1 && first.literalCount != 1 && first.nonDefaultCount != 0 {
|
|
||||||
t.Fatal("expected r4")
|
|
||||||
}
|
|
||||||
last := fixture.candidates[len(fixture.candidates)-1]
|
|
||||||
if last.matchesCount != 0 && last.literalCount != 0 && last.nonDefaultCount != 0 {
|
|
||||||
t.Fatal("expected r1")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func dummy(req *Request, resp *Response) { io.WriteString(resp.ResponseWriter, "dummy") }
|
|
34
Godeps/_workspace/src/github.com/emicklei/go-restful/options_filter_test.go
generated
vendored
34
Godeps/_workspace/src/github.com/emicklei/go-restful/options_filter_test.go
generated
vendored
|
@ -1,34 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// go test -v -test.run TestOptionsFilter ...restful
|
|
||||||
func TestOptionsFilter(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
ws := new(WebService)
|
|
||||||
ws.Route(ws.GET("/candy/{kind}").To(dummy))
|
|
||||||
ws.Route(ws.DELETE("/candy/{kind}").To(dummy))
|
|
||||||
ws.Route(ws.POST("/candies").To(dummy))
|
|
||||||
Add(ws)
|
|
||||||
Filter(OPTIONSFilter())
|
|
||||||
|
|
||||||
httpRequest, _ := http.NewRequest("OPTIONS", "http://here.io/candy/gum", nil)
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
actual := httpWriter.Header().Get(HEADER_Allow)
|
|
||||||
if "GET,DELETE" != actual {
|
|
||||||
t.Fatal("expected: GET,DELETE but got:" + actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
httpRequest, _ = http.NewRequest("OPTIONS", "http://here.io/candies", nil)
|
|
||||||
httpWriter = httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
actual = httpWriter.Header().Get(HEADER_Allow)
|
|
||||||
if "POST" != actual {
|
|
||||||
t.Fatal("expected: POST but got:" + actual)
|
|
||||||
}
|
|
||||||
}
|
|
37
Godeps/_workspace/src/github.com/emicklei/go-restful/path_expression_test.go
generated
vendored
37
Godeps/_workspace/src/github.com/emicklei/go-restful/path_expression_test.go
generated
vendored
|
@ -1,37 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
var tempregexs = []struct {
|
|
||||||
template, regex string
|
|
||||||
literalCount, varCount int
|
|
||||||
}{
|
|
||||||
{"", "^(/.*)?$", 0, 0},
|
|
||||||
{"/a/{b}/c/", "^/a/([^/]+?)/c(/.*)?$", 2, 1},
|
|
||||||
{"/{a}/{b}/{c-d-e}/", "^/([^/]+?)/([^/]+?)/([^/]+?)(/.*)?$", 0, 3},
|
|
||||||
{"/{p}/abcde", "^/([^/]+?)/abcde(/.*)?$", 5, 1},
|
|
||||||
{"/a/{b:*}", "^/a/(.*)(/.*)?$", 1, 1},
|
|
||||||
{"/a/{b:[a-z]+}", "^/a/([a-z]+)(/.*)?$", 1, 1},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTemplateToRegularExpression(t *testing.T) {
|
|
||||||
ok := true
|
|
||||||
for i, fixture := range tempregexs {
|
|
||||||
actual, lCount, vCount, _ := templateToRegularExpression(fixture.template)
|
|
||||||
if actual != fixture.regex {
|
|
||||||
t.Logf("regex mismatch, expected:%v , actual:%v, line:%v\n", fixture.regex, actual, i) // 11 = where the data starts
|
|
||||||
ok = false
|
|
||||||
}
|
|
||||||
if lCount != fixture.literalCount {
|
|
||||||
t.Logf("literal count mismatch, expected:%v , actual:%v, line:%v\n", fixture.literalCount, lCount, i)
|
|
||||||
ok = false
|
|
||||||
}
|
|
||||||
if vCount != fixture.varCount {
|
|
||||||
t.Logf("variable count mismatch, expected:%v , actual:%v, line:%v\n", fixture.varCount, vCount, i)
|
|
||||||
ok = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !ok {
|
|
||||||
t.Fatal("one or more expression did not match")
|
|
||||||
}
|
|
||||||
}
|
|
204
Godeps/_workspace/src/github.com/emicklei/go-restful/request_test.go
generated
vendored
204
Godeps/_workspace/src/github.com/emicklei/go-restful/request_test.go
generated
vendored
|
@ -1,204 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestQueryParameter(t *testing.T) {
|
|
||||||
hreq := http.Request{Method: "GET"}
|
|
||||||
hreq.URL, _ = url.Parse("http://www.google.com/search?q=foo&q=bar")
|
|
||||||
rreq := Request{Request: &hreq}
|
|
||||||
if rreq.QueryParameter("q") != "foo" {
|
|
||||||
t.Errorf("q!=foo %#v", rreq)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Anything map[string]interface{}
|
|
||||||
|
|
||||||
type Number struct {
|
|
||||||
ValueFloat float64
|
|
||||||
ValueInt int64
|
|
||||||
}
|
|
||||||
|
|
||||||
type Sample struct {
|
|
||||||
Value string
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadEntityXmlCached(t *testing.T) {
|
|
||||||
SetCacheReadEntity(true)
|
|
||||||
bodyReader := strings.NewReader("<Sample><Value>42</Value></Sample>")
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/xml")
|
|
||||||
request := &Request{Request: httpRequest}
|
|
||||||
sam := new(Sample)
|
|
||||||
request.ReadEntity(sam)
|
|
||||||
if sam.Value != "42" {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
if request.bodyContent == nil {
|
|
||||||
t.Fatal("no expected cached bytes found")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadEntityXmlNonCached(t *testing.T) {
|
|
||||||
SetCacheReadEntity(false)
|
|
||||||
bodyReader := strings.NewReader("<Sample><Value>42</Value></Sample>")
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/xml")
|
|
||||||
request := &Request{Request: httpRequest}
|
|
||||||
sam := new(Sample)
|
|
||||||
request.ReadEntity(sam)
|
|
||||||
if sam.Value != "42" {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
if request.bodyContent != nil {
|
|
||||||
t.Fatal("unexpected cached bytes found")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadEntityJson(t *testing.T) {
|
|
||||||
bodyReader := strings.NewReader(`{"Value" : "42"}`)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/json")
|
|
||||||
request := &Request{Request: httpRequest}
|
|
||||||
sam := new(Sample)
|
|
||||||
request.ReadEntity(sam)
|
|
||||||
if sam.Value != "42" {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadEntityJsonCharset(t *testing.T) {
|
|
||||||
bodyReader := strings.NewReader(`{"Value" : "42"}`)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/json; charset=UTF-8")
|
|
||||||
request := NewRequest(httpRequest)
|
|
||||||
sam := new(Sample)
|
|
||||||
request.ReadEntity(sam)
|
|
||||||
if sam.Value != "42" {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadEntityJsonNumber(t *testing.T) {
|
|
||||||
SetCacheReadEntity(true)
|
|
||||||
bodyReader := strings.NewReader(`{"Value" : 4899710515899924123}`)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/json")
|
|
||||||
request := &Request{Request: httpRequest}
|
|
||||||
any := make(Anything)
|
|
||||||
request.ReadEntity(&any)
|
|
||||||
number, ok := any["Value"].(json.Number)
|
|
||||||
if !ok {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
vint, err := number.Int64()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal("convert failed")
|
|
||||||
}
|
|
||||||
if vint != 4899710515899924123 {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
vfloat, err := number.Float64()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal("convert failed")
|
|
||||||
}
|
|
||||||
// match the default behaviour
|
|
||||||
vstring := strconv.FormatFloat(vfloat, 'e', 15, 64)
|
|
||||||
if vstring != "4.899710515899924e+18" {
|
|
||||||
t.Fatal("convert float64 failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadEntityJsonNumberNonCached(t *testing.T) {
|
|
||||||
SetCacheReadEntity(false)
|
|
||||||
bodyReader := strings.NewReader(`{"Value" : 4899710515899924123}`)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/json")
|
|
||||||
request := &Request{Request: httpRequest}
|
|
||||||
any := make(Anything)
|
|
||||||
request.ReadEntity(&any)
|
|
||||||
number, ok := any["Value"].(json.Number)
|
|
||||||
if !ok {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
vint, err := number.Int64()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal("convert failed")
|
|
||||||
}
|
|
||||||
if vint != 4899710515899924123 {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
vfloat, err := number.Float64()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal("convert failed")
|
|
||||||
}
|
|
||||||
// match the default behaviour
|
|
||||||
vstring := strconv.FormatFloat(vfloat, 'e', 15, 64)
|
|
||||||
if vstring != "4.899710515899924e+18" {
|
|
||||||
t.Fatal("convert float64 failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadEntityJsonLong(t *testing.T) {
|
|
||||||
bodyReader := strings.NewReader(`{"ValueFloat" : 4899710515899924123, "ValueInt": 4899710515899924123}`)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/json")
|
|
||||||
request := &Request{Request: httpRequest}
|
|
||||||
number := new(Number)
|
|
||||||
request.ReadEntity(&number)
|
|
||||||
if number.ValueInt != 4899710515899924123 {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
// match the default behaviour
|
|
||||||
vstring := strconv.FormatFloat(number.ValueFloat, 'e', 15, 64)
|
|
||||||
if vstring != "4.899710515899924e+18" {
|
|
||||||
t.Fatal("convert float64 failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestBodyParameter(t *testing.T) {
|
|
||||||
bodyReader := strings.NewReader(`value1=42&value2=43`)
|
|
||||||
httpRequest, _ := http.NewRequest("POST", "/test?value1=44", bodyReader) // POST and PUT body parameters take precedence over URL query string
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
|
|
||||||
request := NewRequest(httpRequest)
|
|
||||||
v1, err := request.BodyParameter("value1")
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
v2, err := request.BodyParameter("value2")
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
if v1 != "42" || v2 != "43" {
|
|
||||||
t.Fatal("read failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestReadEntityUnkown(t *testing.T) {
|
|
||||||
bodyReader := strings.NewReader("?")
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/rubbish")
|
|
||||||
request := NewRequest(httpRequest)
|
|
||||||
sam := new(Sample)
|
|
||||||
err := request.ReadEntity(sam)
|
|
||||||
if err == nil {
|
|
||||||
t.Fatal("read should be in error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSetAttribute(t *testing.T) {
|
|
||||||
bodyReader := strings.NewReader("?")
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "/test", bodyReader)
|
|
||||||
request := NewRequest(httpRequest)
|
|
||||||
request.SetAttribute("go", "there")
|
|
||||||
there := request.Attribute("go")
|
|
||||||
if there != "there" {
|
|
||||||
t.Fatalf("missing request attribute:%v", there)
|
|
||||||
}
|
|
||||||
}
|
|
204
Godeps/_workspace/src/github.com/emicklei/go-restful/response_test.go
generated
vendored
204
Godeps/_workspace/src/github.com/emicklei/go-restful/response_test.go
generated
vendored
|
@ -1,204 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"errors"
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestWriteHeader(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "*/*", []string{"*/*"}, 0, 0, true, nil}
|
|
||||||
resp.WriteHeader(123)
|
|
||||||
if resp.StatusCode() != 123 {
|
|
||||||
t.Errorf("Unexpected status code:%d", resp.StatusCode())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNoWriteHeader(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "*/*", []string{"*/*"}, 0, 0, true, nil}
|
|
||||||
if resp.StatusCode() != http.StatusOK {
|
|
||||||
t.Errorf("Unexpected status code:%d", resp.StatusCode())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type food struct {
|
|
||||||
Kind string
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestMeasureContentLengthXml ...restful
|
|
||||||
func TestMeasureContentLengthXml(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "*/*", []string{"*/*"}, 0, 0, true, nil}
|
|
||||||
resp.WriteAsXml(food{"apple"})
|
|
||||||
if resp.ContentLength() != 76 {
|
|
||||||
t.Errorf("Incorrect measured length:%d", resp.ContentLength())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestMeasureContentLengthJson ...restful
|
|
||||||
func TestMeasureContentLengthJson(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "*/*", []string{"*/*"}, 0, 0, true, nil}
|
|
||||||
resp.WriteAsJson(food{"apple"})
|
|
||||||
if resp.ContentLength() != 22 {
|
|
||||||
t.Errorf("Incorrect measured length:%d", resp.ContentLength())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestMeasureContentLengthJsonNotPretty ...restful
|
|
||||||
func TestMeasureContentLengthJsonNotPretty(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "*/*", []string{"*/*"}, 0, 0, false, nil}
|
|
||||||
resp.WriteAsJson(food{"apple"})
|
|
||||||
if resp.ContentLength() != 17 { // 16+1 using the Encoder directly yields another /n
|
|
||||||
t.Errorf("Incorrect measured length:%d", resp.ContentLength())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestMeasureContentLengthWriteErrorString ...restful
|
|
||||||
func TestMeasureContentLengthWriteErrorString(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "*/*", []string{"*/*"}, 0, 0, true, nil}
|
|
||||||
resp.WriteErrorString(404, "Invalid")
|
|
||||||
if resp.ContentLength() != len("Invalid") {
|
|
||||||
t.Errorf("Incorrect measured length:%d", resp.ContentLength())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestStatusIsPassedToResponse ...restful
|
|
||||||
func TestStatusIsPassedToResponse(t *testing.T) {
|
|
||||||
for _, each := range []struct {
|
|
||||||
write, read int
|
|
||||||
}{
|
|
||||||
{write: 204, read: 204},
|
|
||||||
{write: 304, read: 304},
|
|
||||||
{write: 200, read: 200},
|
|
||||||
{write: 400, read: 400},
|
|
||||||
} {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "*/*", []string{"*/*"}, 0, 0, true, nil}
|
|
||||||
resp.WriteHeader(each.write)
|
|
||||||
if got, want := httpWriter.Code, each.read; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestStatusCreatedAndContentTypeJson_Issue54 ...restful
|
|
||||||
func TestStatusCreatedAndContentTypeJson_Issue54(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "application/json", []string{"application/json"}, 0, 0, true, nil}
|
|
||||||
resp.WriteHeader(201)
|
|
||||||
resp.WriteAsJson(food{"Juicy"})
|
|
||||||
if httpWriter.HeaderMap.Get("Content-Type") != "application/json" {
|
|
||||||
t.Errorf("Expected content type json but got:%d", httpWriter.HeaderMap.Get("Content-Type"))
|
|
||||||
}
|
|
||||||
if httpWriter.Code != 201 {
|
|
||||||
t.Errorf("Expected status 201 but got:%d", httpWriter.Code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type errorOnWriteRecorder struct {
|
|
||||||
*httptest.ResponseRecorder
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e errorOnWriteRecorder) Write(bytes []byte) (int, error) {
|
|
||||||
return 0, errors.New("fail")
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestLastWriteErrorCaught ...restful
|
|
||||||
func TestLastWriteErrorCaught(t *testing.T) {
|
|
||||||
httpWriter := errorOnWriteRecorder{httptest.NewRecorder()}
|
|
||||||
resp := Response{httpWriter, "application/json", []string{"application/json"}, 0, 0, true, nil}
|
|
||||||
err := resp.WriteAsJson(food{"Juicy"})
|
|
||||||
if err.Error() != "fail" {
|
|
||||||
t.Errorf("Unexpected error message:%v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestAcceptStarStar_Issue83 ...restful
|
|
||||||
func TestAcceptStarStar_Issue83(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
// Accept Produces
|
|
||||||
resp := Response{httpWriter, "application/bogus,*/*;q=0.8", []string{"application/json"}, 0, 0, true, nil}
|
|
||||||
resp.WriteEntity(food{"Juicy"})
|
|
||||||
ct := httpWriter.Header().Get("Content-Type")
|
|
||||||
if "application/json" != ct {
|
|
||||||
t.Errorf("Unexpected content type:%s", ct)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestAcceptSkipStarStar_Issue83 ...restful
|
|
||||||
func TestAcceptSkipStarStar_Issue83(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
// Accept Produces
|
|
||||||
resp := Response{httpWriter, " application/xml ,*/* ; q=0.8", []string{"application/json", "application/xml"}, 0, 0, true, nil}
|
|
||||||
resp.WriteEntity(food{"Juicy"})
|
|
||||||
ct := httpWriter.Header().Get("Content-Type")
|
|
||||||
if "application/xml" != ct {
|
|
||||||
t.Errorf("Unexpected content type:%s", ct)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestAcceptXmlBeforeStarStar_Issue83 ...restful
|
|
||||||
func TestAcceptXmlBeforeStarStar_Issue83(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
// Accept Produces
|
|
||||||
resp := Response{httpWriter, "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", []string{"application/json"}, 0, 0, true, nil}
|
|
||||||
resp.WriteEntity(food{"Juicy"})
|
|
||||||
ct := httpWriter.Header().Get("Content-Type")
|
|
||||||
if "application/json" != ct {
|
|
||||||
t.Errorf("Unexpected content type:%s", ct)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestWriteHeaderNoContent_Issue124 ...restful
|
|
||||||
func TestWriteHeaderNoContent_Issue124(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "text/plain", []string{"text/plain"}, 0, 0, true, nil}
|
|
||||||
resp.WriteHeader(http.StatusNoContent)
|
|
||||||
if httpWriter.Code != http.StatusNoContent {
|
|
||||||
t.Errorf("got %d want %d", httpWriter.Code, http.StatusNoContent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestStatusCreatedAndContentTypeJson_Issue163 ...restful
|
|
||||||
func TestStatusCreatedAndContentTypeJson_Issue163(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "application/json", []string{"application/json"}, 0, 0, true, nil}
|
|
||||||
resp.WriteHeader(http.StatusNotModified)
|
|
||||||
if httpWriter.Code != http.StatusNotModified {
|
|
||||||
t.Errorf("Got %d want %d", httpWriter.Code, http.StatusNotModified)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteHeaderAndEntity_Issue235(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "application/json", []string{"application/json"}, 0, 0, true, nil}
|
|
||||||
var pong = struct {
|
|
||||||
Foo string `json:"foo"`
|
|
||||||
}{Foo: "123"}
|
|
||||||
resp.WriteHeaderAndEntity(404, pong)
|
|
||||||
if httpWriter.Code != http.StatusNotFound {
|
|
||||||
t.Errorf("got %d want %d", httpWriter.Code, http.StatusNoContent)
|
|
||||||
}
|
|
||||||
if got, want := httpWriter.Header().Get("Content-Type"), "application/json"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
if !strings.HasPrefix(httpWriter.Body.String(), "{") {
|
|
||||||
t.Errorf("expected pong struct in json:%s", httpWriter.Body.String())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteEntityNotAcceptable(t *testing.T) {
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
resp := Response{httpWriter, "application/bogus", []string{"application/json"}, 0, 0, true, nil}
|
|
||||||
resp.WriteEntity("done")
|
|
||||||
if httpWriter.Code != http.StatusNotAcceptable {
|
|
||||||
t.Errorf("got %d want %d", httpWriter.Code, http.StatusNotAcceptable)
|
|
||||||
}
|
|
||||||
}
|
|
58
Godeps/_workspace/src/github.com/emicklei/go-restful/route_builder_test.go
generated
vendored
58
Godeps/_workspace/src/github.com/emicklei/go-restful/route_builder_test.go
generated
vendored
|
@ -1,58 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestRouteBuilder_PathParameter(t *testing.T) {
|
|
||||||
p := &Parameter{&ParameterData{Name: "name", Description: "desc"}}
|
|
||||||
p.AllowMultiple(true)
|
|
||||||
p.DataType("int")
|
|
||||||
p.Required(true)
|
|
||||||
values := map[string]string{"a": "b"}
|
|
||||||
p.AllowableValues(values)
|
|
||||||
p.bePath()
|
|
||||||
|
|
||||||
b := new(RouteBuilder)
|
|
||||||
b.function = dummy
|
|
||||||
b.Param(p)
|
|
||||||
r := b.Build()
|
|
||||||
if !r.ParameterDocs[0].Data().AllowMultiple {
|
|
||||||
t.Error("AllowMultiple invalid")
|
|
||||||
}
|
|
||||||
if r.ParameterDocs[0].Data().DataType != "int" {
|
|
||||||
t.Error("dataType invalid")
|
|
||||||
}
|
|
||||||
if !r.ParameterDocs[0].Data().Required {
|
|
||||||
t.Error("required invalid")
|
|
||||||
}
|
|
||||||
if r.ParameterDocs[0].Data().Kind != PathParameterKind {
|
|
||||||
t.Error("kind invalid")
|
|
||||||
}
|
|
||||||
if r.ParameterDocs[0].Data().AllowableValues["a"] != "b" {
|
|
||||||
t.Error("allowableValues invalid")
|
|
||||||
}
|
|
||||||
if b.ParameterNamed("name") == nil {
|
|
||||||
t.Error("access to parameter failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRouteBuilder(t *testing.T) {
|
|
||||||
json := "application/json"
|
|
||||||
b := new(RouteBuilder)
|
|
||||||
b.To(dummy)
|
|
||||||
b.Path("/routes").Method("HEAD").Consumes(json).Produces(json)
|
|
||||||
r := b.Build()
|
|
||||||
if r.Path != "/routes" {
|
|
||||||
t.Error("path invalid")
|
|
||||||
}
|
|
||||||
if r.Produces[0] != json {
|
|
||||||
t.Error("produces invalid")
|
|
||||||
}
|
|
||||||
if r.Consumes[0] != json {
|
|
||||||
t.Error("consumes invalid")
|
|
||||||
}
|
|
||||||
if r.Operation != "dummy" {
|
|
||||||
t.Error("Operation not set")
|
|
||||||
}
|
|
||||||
}
|
|
127
Godeps/_workspace/src/github.com/emicklei/go-restful/route_test.go
generated
vendored
127
Godeps/_workspace/src/github.com/emicklei/go-restful/route_test.go
generated
vendored
|
@ -1,127 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// accept should match produces
|
|
||||||
func TestMatchesAcceptPlainTextWhenProducePlainTextAsLast(t *testing.T) {
|
|
||||||
r := Route{Produces: []string{"application/json", "text/plain"}}
|
|
||||||
if !r.matchesAccept("text/plain") {
|
|
||||||
t.Errorf("accept should match text/plain")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// accept should match produces
|
|
||||||
func TestMatchesAcceptStar(t *testing.T) {
|
|
||||||
r := Route{Produces: []string{"application/xml"}}
|
|
||||||
if !r.matchesAccept("*/*") {
|
|
||||||
t.Errorf("accept should match star")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// accept should match produces
|
|
||||||
func TestMatchesAcceptIE(t *testing.T) {
|
|
||||||
r := Route{Produces: []string{"application/xml"}}
|
|
||||||
if !r.matchesAccept("text/html, application/xhtml+xml, */*") {
|
|
||||||
t.Errorf("accept should match star")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// accept should match produces
|
|
||||||
func TestMatchesAcceptXml(t *testing.T) {
|
|
||||||
r := Route{Produces: []string{"application/xml"}}
|
|
||||||
if r.matchesAccept("application/json") {
|
|
||||||
t.Errorf("accept should not match json")
|
|
||||||
}
|
|
||||||
if !r.matchesAccept("application/xml") {
|
|
||||||
t.Errorf("accept should match xml")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// accept should match produces
|
|
||||||
func TestMatchesAcceptAny(t *testing.T) {
|
|
||||||
r := Route{Produces: []string{"*/*"}}
|
|
||||||
if !r.matchesAccept("application/json") {
|
|
||||||
t.Errorf("accept should match json")
|
|
||||||
}
|
|
||||||
if !r.matchesAccept("application/xml") {
|
|
||||||
t.Errorf("accept should match xml")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// content type should match consumes
|
|
||||||
func TestMatchesContentTypeXml(t *testing.T) {
|
|
||||||
r := Route{Consumes: []string{"application/xml"}}
|
|
||||||
if r.matchesContentType("application/json") {
|
|
||||||
t.Errorf("accept should not match json")
|
|
||||||
}
|
|
||||||
if !r.matchesContentType("application/xml") {
|
|
||||||
t.Errorf("accept should match xml")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// content type should match consumes
|
|
||||||
func TestMatchesContentTypeCharsetInformation(t *testing.T) {
|
|
||||||
r := Route{Consumes: []string{"application/json"}}
|
|
||||||
if !r.matchesContentType("application/json; charset=UTF-8") {
|
|
||||||
t.Errorf("matchesContentType should ignore charset information")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatchesPath_OneParam(t *testing.T) {
|
|
||||||
params := doExtractParams("/from/{source}", 2, "/from/here", t)
|
|
||||||
if params["source"] != "here" {
|
|
||||||
t.Errorf("parameter mismatch here")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatchesPath_Slash(t *testing.T) {
|
|
||||||
params := doExtractParams("/", 0, "/", t)
|
|
||||||
if len(params) != 0 {
|
|
||||||
t.Errorf("expected empty parameters")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatchesPath_SlashNonVar(t *testing.T) {
|
|
||||||
params := doExtractParams("/any", 1, "/any", t)
|
|
||||||
if len(params) != 0 {
|
|
||||||
t.Errorf("expected empty parameters")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatchesPath_TwoVars(t *testing.T) {
|
|
||||||
params := doExtractParams("/from/{source}/to/{destination}", 4, "/from/AMS/to/NY", t)
|
|
||||||
if params["source"] != "AMS" {
|
|
||||||
t.Errorf("parameter mismatch AMS")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMatchesPath_VarOnFront(t *testing.T) {
|
|
||||||
params := doExtractParams("{what}/from/{source}/", 3, "who/from/SOS/", t)
|
|
||||||
if params["source"] != "SOS" {
|
|
||||||
t.Errorf("parameter mismatch SOS")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestExtractParameters_EmptyValue(t *testing.T) {
|
|
||||||
params := doExtractParams("/fixed/{var}", 2, "/fixed/", t)
|
|
||||||
if params["var"] != "" {
|
|
||||||
t.Errorf("parameter mismatch var")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTokenizePath(t *testing.T) {
|
|
||||||
if len(tokenizePath("/")) != 0 {
|
|
||||||
t.Errorf("not empty path tokens")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func doExtractParams(routePath string, size int, urlPath string, t *testing.T) map[string]string {
|
|
||||||
r := Route{Path: routePath}
|
|
||||||
r.postBuild()
|
|
||||||
if len(r.pathParts) != size {
|
|
||||||
t.Fatalf("len not %v %v, but %v", size, r.pathParts, len(r.pathParts))
|
|
||||||
}
|
|
||||||
return r.extractParameters(urlPath)
|
|
||||||
}
|
|
1142
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/model_builder_test.go
generated
vendored
1142
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/model_builder_test.go
generated
vendored
File diff suppressed because it is too large
Load diff
48
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/model_list_test.go
generated
vendored
48
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/model_list_test.go
generated
vendored
|
@ -1,48 +0,0 @@
|
||||||
package swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestModelList(t *testing.T) {
|
|
||||||
m := Model{}
|
|
||||||
m.Id = "m"
|
|
||||||
l := ModelList{}
|
|
||||||
l.Put("m", m)
|
|
||||||
k, ok := l.At("m")
|
|
||||||
if !ok {
|
|
||||||
t.Error("want model back")
|
|
||||||
}
|
|
||||||
if got, want := k.Id, "m"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestModelList_Marshal(t *testing.T) {
|
|
||||||
l := ModelList{}
|
|
||||||
m := Model{Id: "myid"}
|
|
||||||
l.Put("myid", m)
|
|
||||||
data, err := json.Marshal(l)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
if got, want := string(data), `{"myid":{"id":"myid","properties":{}}}`; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestModelList_Unmarshal(t *testing.T) {
|
|
||||||
data := `{"myid":{"id":"myid","properties":{}}}`
|
|
||||||
l := ModelList{}
|
|
||||||
if err := json.Unmarshal([]byte(data), &l); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
m, ok := l.At("myid")
|
|
||||||
if !ok {
|
|
||||||
t.Error("expected myid")
|
|
||||||
}
|
|
||||||
if got, want := m.Id, "myid"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
60
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/model_property_ext_test.go
generated
vendored
60
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/model_property_ext_test.go
generated
vendored
|
@ -1,60 +0,0 @@
|
||||||
package swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestThatExtraTagsAreReadIntoModel ...swagger
|
|
||||||
func TestThatExtraTagsAreReadIntoModel(t *testing.T) {
|
|
||||||
type fakeint int
|
|
||||||
type Anything struct {
|
|
||||||
Name string `description:"name" modelDescription:"a test"`
|
|
||||||
Size int `minimum:"0" maximum:"10"`
|
|
||||||
Stati string `enum:"off|on" default:"on" modelDescription:"more description"`
|
|
||||||
ID string `unique:"true"`
|
|
||||||
FakeInt fakeint `type:"integer"`
|
|
||||||
IP net.IP `type:"string"`
|
|
||||||
Password string
|
|
||||||
}
|
|
||||||
m := modelsFromStruct(Anything{})
|
|
||||||
props, _ := m.At("swagger.Anything")
|
|
||||||
p1, _ := props.Properties.At("Name")
|
|
||||||
if got, want := p1.Description, "name"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
p2, _ := props.Properties.At("Size")
|
|
||||||
if got, want := p2.Minimum, "0"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
if got, want := p2.Maximum, "10"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
p3, _ := props.Properties.At("Stati")
|
|
||||||
if got, want := p3.Enum[0], "off"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
if got, want := p3.Enum[1], "on"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
p4, _ := props.Properties.At("ID")
|
|
||||||
if got, want := *p4.UniqueItems, true; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
p5, _ := props.Properties.At("Password")
|
|
||||||
if got, want := *p5.Type, "string"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
p6, _ := props.Properties.At("FakeInt")
|
|
||||||
if got, want := *p6.Type, "integer"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
p7, _ := props.Properties.At("IP")
|
|
||||||
if got, want := *p7.Type, "string"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
|
|
||||||
if got, want := props.Description, "a test\nmore description"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
47
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/model_property_list_test.go
generated
vendored
47
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/model_property_list_test.go
generated
vendored
|
@ -1,47 +0,0 @@
|
||||||
package swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestModelPropertyList(t *testing.T) {
|
|
||||||
l := ModelPropertyList{}
|
|
||||||
p := ModelProperty{Description: "d"}
|
|
||||||
l.Put("p", p)
|
|
||||||
q, ok := l.At("p")
|
|
||||||
if !ok {
|
|
||||||
t.Error("expected p")
|
|
||||||
}
|
|
||||||
if got, want := q.Description, "d"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestModelPropertyList_Marshal(t *testing.T) {
|
|
||||||
l := ModelPropertyList{}
|
|
||||||
p := ModelProperty{Description: "d"}
|
|
||||||
l.Put("p", p)
|
|
||||||
data, err := json.Marshal(l)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
if got, want := string(data), `{"p":{"description":"d"}}`; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestModelPropertyList_Unmarshal(t *testing.T) {
|
|
||||||
data := `{"p":{"description":"d"}}`
|
|
||||||
l := ModelPropertyList{}
|
|
||||||
if err := json.Unmarshal([]byte(data), &l); err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
m, ok := l.At("p")
|
|
||||||
if !ok {
|
|
||||||
t.Error("expected p")
|
|
||||||
}
|
|
||||||
if got, want := m.Description, "d"; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
29
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/ordered_route_map_test.go
generated
vendored
29
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/ordered_route_map_test.go
generated
vendored
|
@ -1,29 +0,0 @@
|
||||||
package swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
)
|
|
||||||
|
|
||||||
// go test -v -test.run TestOrderedRouteMap ...swagger
|
|
||||||
func TestOrderedRouteMap(t *testing.T) {
|
|
||||||
m := newOrderedRouteMap()
|
|
||||||
r1 := restful.Route{Path: "/r1"}
|
|
||||||
r2 := restful.Route{Path: "/r2"}
|
|
||||||
m.Add("a", r1)
|
|
||||||
m.Add("b", r2)
|
|
||||||
m.Add("b", r1)
|
|
||||||
m.Add("d", r2)
|
|
||||||
m.Add("c", r2)
|
|
||||||
order := ""
|
|
||||||
m.Do(func(k string, routes []restful.Route) {
|
|
||||||
order += k
|
|
||||||
if len(routes) == 0 {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
if order != "abdc" {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
}
|
|
42
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/postbuild_model_test.go
generated
vendored
42
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/postbuild_model_test.go
generated
vendored
|
@ -1,42 +0,0 @@
|
||||||
package swagger
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
type Boat struct {
|
|
||||||
Length int `json:"-"` // on default, this makes the fields not required
|
|
||||||
Weight int `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// PostBuildModel is from swagger.ModelBuildable
|
|
||||||
func (b Boat) PostBuildModel(m *Model) *Model {
|
|
||||||
// override required
|
|
||||||
m.Required = []string{"Length", "Weight"}
|
|
||||||
|
|
||||||
// add model property (just to test is can be added; is this a real usecase?)
|
|
||||||
extraType := "string"
|
|
||||||
m.Properties.Put("extra", ModelProperty{
|
|
||||||
Description: "extra description",
|
|
||||||
DataTypeFields: DataTypeFields{
|
|
||||||
Type: &extraType,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCustomPostModelBuilde(t *testing.T) {
|
|
||||||
testJsonFromStruct(t, Boat{}, `{
|
|
||||||
"swagger.Boat": {
|
|
||||||
"id": "swagger.Boat",
|
|
||||||
"required": [
|
|
||||||
"Length",
|
|
||||||
"Weight"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"extra": {
|
|
||||||
"type": "string",
|
|
||||||
"description": "extra description"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`)
|
|
||||||
}
|
|
284
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/swagger_test.go
generated
vendored
284
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/swagger_test.go
generated
vendored
|
@ -1,284 +0,0 @@
|
||||||
package swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/emicklei/go-restful"
|
|
||||||
"github.com/emicklei/go-restful/swagger/test_package"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestInfoStruct_Issue231(t *testing.T) {
|
|
||||||
config := Config{
|
|
||||||
Info: Info{
|
|
||||||
Title: "Title",
|
|
||||||
Description: "Description",
|
|
||||||
TermsOfServiceUrl: "http://example.com",
|
|
||||||
Contact: "example@example.com",
|
|
||||||
License: "License",
|
|
||||||
LicenseUrl: "http://example.com/license.txt",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
sws := newSwaggerService(config)
|
|
||||||
str, err := json.MarshalIndent(sws.produceListing(), "", " ")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
compareJson(t, string(str), `
|
|
||||||
{
|
|
||||||
"apiVersion": "",
|
|
||||||
"swaggerVersion": "1.2",
|
|
||||||
"apis": null,
|
|
||||||
"info": {
|
|
||||||
"title": "Title",
|
|
||||||
"description": "Description",
|
|
||||||
"termsOfServiceUrl": "http://example.com",
|
|
||||||
"contact": "example@example.com",
|
|
||||||
"license": "License",
|
|
||||||
"licenseUrl": "http://example.com/license.txt"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestThatMultiplePathsOnRootAreHandled ...swagger
|
|
||||||
func TestThatMultiplePathsOnRootAreHandled(t *testing.T) {
|
|
||||||
ws1 := new(restful.WebService)
|
|
||||||
ws1.Route(ws1.GET("/_ping").To(dummy))
|
|
||||||
ws1.Route(ws1.GET("/version").To(dummy))
|
|
||||||
|
|
||||||
cfg := Config{
|
|
||||||
WebServicesUrl: "http://here.com",
|
|
||||||
ApiPath: "/apipath",
|
|
||||||
WebServices: []*restful.WebService{ws1},
|
|
||||||
}
|
|
||||||
sws := newSwaggerService(cfg)
|
|
||||||
decl := sws.composeDeclaration(ws1, "/")
|
|
||||||
if got, want := len(decl.Apis), 2; got != want {
|
|
||||||
t.Errorf("got %v want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestWriteSamples(t *testing.T) {
|
|
||||||
ws1 := new(restful.WebService)
|
|
||||||
ws1.Route(ws1.GET("/object").To(dummy).Writes(test_package.TestStruct{}))
|
|
||||||
ws1.Route(ws1.GET("/array").To(dummy).Writes([]test_package.TestStruct{}))
|
|
||||||
ws1.Route(ws1.GET("/object_and_array").To(dummy).Writes(struct{ Abc test_package.TestStruct }{}))
|
|
||||||
|
|
||||||
cfg := Config{
|
|
||||||
WebServicesUrl: "http://here.com",
|
|
||||||
ApiPath: "/apipath",
|
|
||||||
WebServices: []*restful.WebService{ws1},
|
|
||||||
}
|
|
||||||
sws := newSwaggerService(cfg)
|
|
||||||
|
|
||||||
decl := sws.composeDeclaration(ws1, "/")
|
|
||||||
|
|
||||||
str, err := json.MarshalIndent(decl.Apis, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
compareJson(t, string(str), `
|
|
||||||
[
|
|
||||||
{
|
|
||||||
"path": "/object",
|
|
||||||
"description": "",
|
|
||||||
"operations": [
|
|
||||||
{
|
|
||||||
"type": "test_package.TestStruct",
|
|
||||||
"method": "GET",
|
|
||||||
"nickname": "dummy",
|
|
||||||
"parameters": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/array",
|
|
||||||
"description": "",
|
|
||||||
"operations": [
|
|
||||||
{
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"$ref": "test_package.TestStruct"
|
|
||||||
},
|
|
||||||
"method": "GET",
|
|
||||||
"nickname": "dummy",
|
|
||||||
"parameters": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "/object_and_array",
|
|
||||||
"description": "",
|
|
||||||
"operations": [
|
|
||||||
{
|
|
||||||
"type": "struct { Abc test_package.TestStruct }",
|
|
||||||
"method": "GET",
|
|
||||||
"nickname": "dummy",
|
|
||||||
"parameters": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]`)
|
|
||||||
|
|
||||||
str, err = json.MarshalIndent(decl.Models, "", " ")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
compareJson(t, string(str), `
|
|
||||||
{
|
|
||||||
"test_package.TestStruct": {
|
|
||||||
"id": "test_package.TestStruct",
|
|
||||||
"required": [
|
|
||||||
"TestField"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"TestField": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"||test_package.TestStruct": {
|
|
||||||
"id": "||test_package.TestStruct",
|
|
||||||
"properties": {}
|
|
||||||
},
|
|
||||||
"struct { Abc test_package.TestStruct }": {
|
|
||||||
"id": "struct { Abc test_package.TestStruct }",
|
|
||||||
"required": [
|
|
||||||
"Abc"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"Abc": {
|
|
||||||
"$ref": "test_package.TestStruct"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}`)
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestServiceToApi ...swagger
|
|
||||||
func TestServiceToApi(t *testing.T) {
|
|
||||||
ws := new(restful.WebService)
|
|
||||||
ws.Path("/tests")
|
|
||||||
ws.Consumes(restful.MIME_JSON)
|
|
||||||
ws.Produces(restful.MIME_XML)
|
|
||||||
ws.Route(ws.GET("/a").To(dummy).Writes(sample{}))
|
|
||||||
ws.Route(ws.PUT("/b").To(dummy).Writes(sample{}))
|
|
||||||
ws.Route(ws.POST("/c").To(dummy).Writes(sample{}))
|
|
||||||
ws.Route(ws.DELETE("/d").To(dummy).Writes(sample{}))
|
|
||||||
|
|
||||||
ws.Route(ws.GET("/d").To(dummy).Writes(sample{}))
|
|
||||||
ws.Route(ws.PUT("/c").To(dummy).Writes(sample{}))
|
|
||||||
ws.Route(ws.POST("/b").To(dummy).Writes(sample{}))
|
|
||||||
ws.Route(ws.DELETE("/a").To(dummy).Writes(sample{}))
|
|
||||||
ws.ApiVersion("1.2.3")
|
|
||||||
cfg := Config{
|
|
||||||
WebServicesUrl: "http://here.com",
|
|
||||||
ApiPath: "/apipath",
|
|
||||||
WebServices: []*restful.WebService{ws},
|
|
||||||
PostBuildHandler: func(in *ApiDeclarationList) {},
|
|
||||||
}
|
|
||||||
sws := newSwaggerService(cfg)
|
|
||||||
decl := sws.composeDeclaration(ws, "/tests")
|
|
||||||
// checks
|
|
||||||
if decl.ApiVersion != "1.2.3" {
|
|
||||||
t.Errorf("got %v want %v", decl.ApiVersion, "1.2.3")
|
|
||||||
}
|
|
||||||
if decl.BasePath != "http://here.com" {
|
|
||||||
t.Errorf("got %v want %v", decl.BasePath, "http://here.com")
|
|
||||||
}
|
|
||||||
if len(decl.Apis) != 4 {
|
|
||||||
t.Errorf("got %v want %v", len(decl.Apis), 4)
|
|
||||||
}
|
|
||||||
pathOrder := ""
|
|
||||||
for _, each := range decl.Apis {
|
|
||||||
pathOrder += each.Path
|
|
||||||
for _, other := range each.Operations {
|
|
||||||
pathOrder += other.Method
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if pathOrder != "/tests/aGETDELETE/tests/bPUTPOST/tests/cPOSTPUT/tests/dDELETEGET" {
|
|
||||||
t.Errorf("got %v want %v", pathOrder, "see test source")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func dummy(i *restful.Request, o *restful.Response) {}
|
|
||||||
|
|
||||||
// go test -v -test.run TestIssue78 ...swagger
|
|
||||||
type Response struct {
|
|
||||||
Code int
|
|
||||||
Users *[]User
|
|
||||||
Items *[]TestItem
|
|
||||||
}
|
|
||||||
type User struct {
|
|
||||||
Id, Name string
|
|
||||||
}
|
|
||||||
type TestItem struct {
|
|
||||||
Id, Name string
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestComposeResponseMessages ...swagger
|
|
||||||
func TestComposeResponseMessages(t *testing.T) {
|
|
||||||
responseErrors := map[int]restful.ResponseError{}
|
|
||||||
responseErrors[400] = restful.ResponseError{Code: 400, Message: "Bad Request", Model: TestItem{}}
|
|
||||||
route := restful.Route{ResponseErrors: responseErrors}
|
|
||||||
decl := new(ApiDeclaration)
|
|
||||||
decl.Models = ModelList{}
|
|
||||||
msgs := composeResponseMessages(route, decl)
|
|
||||||
if msgs[0].ResponseModel != "swagger.TestItem" {
|
|
||||||
t.Errorf("got %s want swagger.TestItem", msgs[0].ResponseModel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear && go test -v -test.run TestComposeResponseMessageArray ...swagger
|
|
||||||
func TestComposeResponseMessageArray(t *testing.T) {
|
|
||||||
responseErrors := map[int]restful.ResponseError{}
|
|
||||||
responseErrors[400] = restful.ResponseError{Code: 400, Message: "Bad Request", Model: []TestItem{}}
|
|
||||||
route := restful.Route{ResponseErrors: responseErrors}
|
|
||||||
decl := new(ApiDeclaration)
|
|
||||||
decl.Models = ModelList{}
|
|
||||||
msgs := composeResponseMessages(route, decl)
|
|
||||||
if msgs[0].ResponseModel != "array[swagger.TestItem]" {
|
|
||||||
t.Errorf("got %s want swagger.TestItem", msgs[0].ResponseModel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestIssue78(t *testing.T) {
|
|
||||||
sws := newSwaggerService(Config{})
|
|
||||||
models := new(ModelList)
|
|
||||||
sws.addModelFromSampleTo(&Operation{}, true, Response{Items: &[]TestItem{}}, models)
|
|
||||||
model, ok := models.At("swagger.Response")
|
|
||||||
if !ok {
|
|
||||||
t.Fatal("missing response model")
|
|
||||||
}
|
|
||||||
if "swagger.Response" != model.Id {
|
|
||||||
t.Fatal("wrong model id:" + model.Id)
|
|
||||||
}
|
|
||||||
code, ok := model.Properties.At("Code")
|
|
||||||
if !ok {
|
|
||||||
t.Fatal("missing code")
|
|
||||||
}
|
|
||||||
if "integer" != *code.Type {
|
|
||||||
t.Fatal("wrong code type:" + *code.Type)
|
|
||||||
}
|
|
||||||
items, ok := model.Properties.At("Items")
|
|
||||||
if !ok {
|
|
||||||
t.Fatal("missing items")
|
|
||||||
}
|
|
||||||
if "array" != *items.Type {
|
|
||||||
t.Fatal("wrong items type:" + *items.Type)
|
|
||||||
}
|
|
||||||
items_items := items.Items
|
|
||||||
if items_items == nil {
|
|
||||||
t.Fatal("missing items->items")
|
|
||||||
}
|
|
||||||
ref := items_items.Ref
|
|
||||||
if ref == nil {
|
|
||||||
t.Fatal("missing $ref")
|
|
||||||
}
|
|
||||||
if *ref != "swagger.TestItem" {
|
|
||||||
t.Fatal("wrong $ref:" + *ref)
|
|
||||||
}
|
|
||||||
}
|
|
5
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/test_package/struct.go
generated
vendored
5
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/test_package/struct.go
generated
vendored
|
@ -1,5 +0,0 @@
|
||||||
package test_package
|
|
||||||
|
|
||||||
type TestStruct struct {
|
|
||||||
TestField string
|
|
||||||
}
|
|
78
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/utils_test.go
generated
vendored
78
Godeps/_workspace/src/github.com/emicklei/go-restful/swagger/utils_test.go
generated
vendored
|
@ -1,78 +0,0 @@
|
||||||
package swagger
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func testJsonFromStruct(t *testing.T, sample interface{}, expectedJson string) bool {
|
|
||||||
m := modelsFromStruct(sample)
|
|
||||||
data, _ := json.MarshalIndent(m, " ", " ")
|
|
||||||
return compareJson(t, string(data), expectedJson)
|
|
||||||
}
|
|
||||||
|
|
||||||
func modelsFromStruct(sample interface{}) *ModelList {
|
|
||||||
models := new(ModelList)
|
|
||||||
builder := modelBuilder{models}
|
|
||||||
builder.addModelFrom(sample)
|
|
||||||
return models
|
|
||||||
}
|
|
||||||
|
|
||||||
func compareJson(t *testing.T, actualJsonAsString string, expectedJsonAsString string) bool {
|
|
||||||
success := false
|
|
||||||
var actualMap map[string]interface{}
|
|
||||||
json.Unmarshal([]byte(actualJsonAsString), &actualMap)
|
|
||||||
var expectedMap map[string]interface{}
|
|
||||||
err := json.Unmarshal([]byte(expectedJsonAsString), &expectedMap)
|
|
||||||
if err != nil {
|
|
||||||
var actualArray []interface{}
|
|
||||||
json.Unmarshal([]byte(actualJsonAsString), &actualArray)
|
|
||||||
var expectedArray []interface{}
|
|
||||||
err := json.Unmarshal([]byte(expectedJsonAsString), &expectedArray)
|
|
||||||
success = reflect.DeepEqual(actualArray, expectedArray)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Unparsable expected JSON: %s", err)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
success = reflect.DeepEqual(actualMap, expectedMap)
|
|
||||||
}
|
|
||||||
if !success {
|
|
||||||
t.Log("---- expected -----")
|
|
||||||
t.Log(withLineNumbers(expectedJsonAsString))
|
|
||||||
t.Log("---- actual -----")
|
|
||||||
t.Log(withLineNumbers(actualJsonAsString))
|
|
||||||
t.Log("---- raw -----")
|
|
||||||
t.Log(actualJsonAsString)
|
|
||||||
t.Error("there are differences")
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func indexOfNonMatchingLine(actual, expected string) int {
|
|
||||||
a := strings.Split(actual, "\n")
|
|
||||||
e := strings.Split(expected, "\n")
|
|
||||||
size := len(a)
|
|
||||||
if len(e) < len(a) {
|
|
||||||
size = len(e)
|
|
||||||
}
|
|
||||||
for i := 0; i < size; i++ {
|
|
||||||
if a[i] != e[i] {
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
|
|
||||||
func withLineNumbers(content string) string {
|
|
||||||
var buffer bytes.Buffer
|
|
||||||
lines := strings.Split(content, "\n")
|
|
||||||
for i, each := range lines {
|
|
||||||
buffer.WriteString(fmt.Sprintf("%d:%s\n", i, each))
|
|
||||||
}
|
|
||||||
return buffer.String()
|
|
||||||
}
|
|
18
Godeps/_workspace/src/github.com/emicklei/go-restful/tracer_test.go
generated
vendored
18
Godeps/_workspace/src/github.com/emicklei/go-restful/tracer_test.go
generated
vendored
|
@ -1,18 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
// Use like this:
|
|
||||||
//
|
|
||||||
// TraceLogger(testLogger{t})
|
|
||||||
type testLogger struct {
|
|
||||||
t *testing.T
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l testLogger) Print(v ...interface{}) {
|
|
||||||
l.t.Log(v...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l testLogger) Printf(format string, v ...interface{}) {
|
|
||||||
l.t.Logf(format, v...)
|
|
||||||
}
|
|
254
Godeps/_workspace/src/github.com/emicklei/go-restful/web_service_test.go
generated
vendored
254
Godeps/_workspace/src/github.com/emicklei/go-restful/web_service_test.go
generated
vendored
|
@ -1,254 +0,0 @@
|
||||||
package restful
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
pathGetFriends = "/get/{userId}/friends"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestParameter(t *testing.T) {
|
|
||||||
p := &Parameter{&ParameterData{Name: "name", Description: "desc"}}
|
|
||||||
p.AllowMultiple(true)
|
|
||||||
p.DataType("int")
|
|
||||||
p.Required(true)
|
|
||||||
values := map[string]string{"a": "b"}
|
|
||||||
p.AllowableValues(values)
|
|
||||||
p.bePath()
|
|
||||||
|
|
||||||
ws := new(WebService)
|
|
||||||
ws.Param(p)
|
|
||||||
if ws.pathParameters[0].Data().Name != "name" {
|
|
||||||
t.Error("path parameter (or name) invalid")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func TestWebService_CanCreateParameterKinds(t *testing.T) {
|
|
||||||
ws := new(WebService)
|
|
||||||
if ws.BodyParameter("b", "b").Kind() != BodyParameterKind {
|
|
||||||
t.Error("body parameter expected")
|
|
||||||
}
|
|
||||||
if ws.PathParameter("p", "p").Kind() != PathParameterKind {
|
|
||||||
t.Error("path parameter expected")
|
|
||||||
}
|
|
||||||
if ws.QueryParameter("q", "q").Kind() != QueryParameterKind {
|
|
||||||
t.Error("query parameter expected")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCapturePanic(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
Add(newPanicingService())
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://here.com/fire", nil)
|
|
||||||
httpRequest.Header.Set("Accept", "*/*")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if 500 != httpWriter.Code {
|
|
||||||
t.Error("500 expected on fire")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCapturePanicWithEncoded(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
Add(newPanicingService())
|
|
||||||
DefaultContainer.EnableContentEncoding(true)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://here.com/fire", nil)
|
|
||||||
httpRequest.Header.Set("Accept", "*/*")
|
|
||||||
httpRequest.Header.Set("Accept-Encoding", "gzip")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if 500 != httpWriter.Code {
|
|
||||||
t.Error("500 expected on fire, got", httpWriter.Code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNotFound(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://here.com/missing", nil)
|
|
||||||
httpRequest.Header.Set("Accept", "*/*")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if 404 != httpWriter.Code {
|
|
||||||
t.Error("404 expected on missing")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMethodNotAllowed(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
Add(newGetOnlyService())
|
|
||||||
httpRequest, _ := http.NewRequest("POST", "http://here.com/get", nil)
|
|
||||||
httpRequest.Header.Set("Accept", "*/*")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if 405 != httpWriter.Code {
|
|
||||||
t.Error("405 expected method not allowed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSelectedRoutePath_Issue100(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
Add(newSelectedRouteTestingService())
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://here.com/get/232452/friends", nil)
|
|
||||||
httpRequest.Header.Set("Accept", "*/*")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if http.StatusOK != httpWriter.Code {
|
|
||||||
t.Error(http.StatusOK, "expected,", httpWriter.Code, "received.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestContentType415_Issue170(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
Add(newGetOnlyJsonOnlyService())
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://here.com/get", nil)
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if 200 != httpWriter.Code {
|
|
||||||
t.Errorf("Expected 200, got %d", httpWriter.Code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestContentType415_POST_Issue170(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
Add(newPostOnlyJsonOnlyService())
|
|
||||||
httpRequest, _ := http.NewRequest("POST", "http://here.com/post", nil)
|
|
||||||
httpRequest.Header.Set("Content-Type", "application/json")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if 200 != httpWriter.Code {
|
|
||||||
t.Errorf("Expected 200, got %d", httpWriter.Code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestContentType406PlainJson ...restful
|
|
||||||
func TestContentType406PlainJson(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
TraceLogger(testLogger{t})
|
|
||||||
Add(newGetPlainTextOrJsonService())
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://here.com/get", nil)
|
|
||||||
httpRequest.Header.Set("Accept", "text/plain")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if got, want := httpWriter.Code, 200; got != want {
|
|
||||||
t.Errorf("got %v, want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRemoveRoute(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
TraceLogger(testLogger{t})
|
|
||||||
ws := newGetPlainTextOrJsonService()
|
|
||||||
Add(ws)
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://here.com/get", nil)
|
|
||||||
httpRequest.Header.Set("Accept", "text/plain")
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if got, want := httpWriter.Code, 200; got != want {
|
|
||||||
t.Errorf("got %v, want %v", got, want)
|
|
||||||
}
|
|
||||||
|
|
||||||
// dynamic apis are disabled, should error and do nothing
|
|
||||||
if err := ws.RemoveRoute("/get", "GET"); err == nil {
|
|
||||||
t.Error("unexpected non-error")
|
|
||||||
}
|
|
||||||
|
|
||||||
httpWriter = httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if got, want := httpWriter.Code, 200; got != want {
|
|
||||||
t.Errorf("got %v, want %v", got, want)
|
|
||||||
}
|
|
||||||
|
|
||||||
ws.SetDynamicRoutes(true)
|
|
||||||
if err := ws.RemoveRoute("/get", "GET"); err != nil {
|
|
||||||
t.Errorf("unexpected error %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
httpWriter = httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if got, want := httpWriter.Code, 404; got != want {
|
|
||||||
t.Errorf("got %v, want %v", got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// go test -v -test.run TestContentTypeOctet_Issue170 ...restful
|
|
||||||
func TestContentTypeOctet_Issue170(t *testing.T) {
|
|
||||||
tearDown()
|
|
||||||
Add(newGetConsumingOctetStreamService())
|
|
||||||
// with content-type
|
|
||||||
httpRequest, _ := http.NewRequest("GET", "http://here.com/get", nil)
|
|
||||||
httpRequest.Header.Set("Content-Type", MIME_OCTET)
|
|
||||||
httpWriter := httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if 200 != httpWriter.Code {
|
|
||||||
t.Errorf("Expected 200, got %d", httpWriter.Code)
|
|
||||||
}
|
|
||||||
// without content-type
|
|
||||||
httpRequest, _ = http.NewRequest("GET", "http://here.com/get", nil)
|
|
||||||
httpWriter = httptest.NewRecorder()
|
|
||||||
DefaultContainer.dispatch(httpWriter, httpRequest)
|
|
||||||
if 200 != httpWriter.Code {
|
|
||||||
t.Errorf("Expected 200, got %d", httpWriter.Code)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func newPanicingService() *WebService {
|
|
||||||
ws := new(WebService).Path("")
|
|
||||||
ws.Route(ws.GET("/fire").To(doPanic))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
func newGetOnlyService() *WebService {
|
|
||||||
ws := new(WebService).Path("")
|
|
||||||
ws.Route(ws.GET("/get").To(doPanic))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
func newPostOnlyJsonOnlyService() *WebService {
|
|
||||||
ws := new(WebService).Path("")
|
|
||||||
ws.Consumes("application/json")
|
|
||||||
ws.Route(ws.POST("/post").To(doNothing))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
func newGetOnlyJsonOnlyService() *WebService {
|
|
||||||
ws := new(WebService).Path("")
|
|
||||||
ws.Consumes("application/json")
|
|
||||||
ws.Route(ws.GET("/get").To(doNothing))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
func newGetPlainTextOrJsonService() *WebService {
|
|
||||||
ws := new(WebService).Path("")
|
|
||||||
ws.Produces("text/plain", "application/json")
|
|
||||||
ws.Route(ws.GET("/get").To(doNothing))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
func newGetConsumingOctetStreamService() *WebService {
|
|
||||||
ws := new(WebService).Path("")
|
|
||||||
ws.Consumes("application/octet-stream")
|
|
||||||
ws.Route(ws.GET("/get").To(doNothing))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
func newSelectedRouteTestingService() *WebService {
|
|
||||||
ws := new(WebService).Path("")
|
|
||||||
ws.Route(ws.GET(pathGetFriends).To(selectedRouteChecker))
|
|
||||||
return ws
|
|
||||||
}
|
|
||||||
|
|
||||||
func selectedRouteChecker(req *Request, resp *Response) {
|
|
||||||
if req.SelectedRoutePath() != pathGetFriends {
|
|
||||||
resp.InternalServerError()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func doPanic(req *Request, resp *Response) {
|
|
||||||
println("lightning...")
|
|
||||||
panic("fire")
|
|
||||||
}
|
|
||||||
|
|
||||||
func doNothing(req *Request, resp *Response) {
|
|
||||||
}
|
|
322
Godeps/_workspace/src/github.com/evanphx/json-patch/merge_test.go
generated
vendored
322
Godeps/_workspace/src/github.com/evanphx/json-patch/merge_test.go
generated
vendored
|
@ -1,322 +0,0 @@
|
||||||
package jsonpatch
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func mergePatch(doc, patch string) string {
|
|
||||||
out, err := MergePatch([]byte(doc), []byte(patch))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(out)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergePatchReplaceKey(t *testing.T) {
|
|
||||||
doc := `{ "title": "hello" }`
|
|
||||||
pat := `{ "title": "goodbye" }`
|
|
||||||
|
|
||||||
res := mergePatch(doc, pat)
|
|
||||||
|
|
||||||
if !compareJSON(pat, res) {
|
|
||||||
t.Fatalf("Key was not replaced")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergePatchIgnoresOtherValues(t *testing.T) {
|
|
||||||
doc := `{ "title": "hello", "age": 18 }`
|
|
||||||
pat := `{ "title": "goodbye" }`
|
|
||||||
|
|
||||||
res := mergePatch(doc, pat)
|
|
||||||
|
|
||||||
exp := `{ "title": "goodbye", "age": 18 }`
|
|
||||||
|
|
||||||
if !compareJSON(exp, res) {
|
|
||||||
t.Fatalf("Key was not replaced")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergePatchNilDoc(t *testing.T) {
|
|
||||||
doc := `{ "title": null }`
|
|
||||||
pat := `{ "title": {"foo": "bar"} }`
|
|
||||||
|
|
||||||
res := mergePatch(doc, pat)
|
|
||||||
|
|
||||||
exp := `{ "title": {"foo": "bar"} }`
|
|
||||||
|
|
||||||
if !compareJSON(exp, res) {
|
|
||||||
t.Fatalf("Key was not replaced")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergePatchRecursesIntoObjects(t *testing.T) {
|
|
||||||
doc := `{ "person": { "title": "hello", "age": 18 } }`
|
|
||||||
pat := `{ "person": { "title": "goodbye" } }`
|
|
||||||
|
|
||||||
res := mergePatch(doc, pat)
|
|
||||||
|
|
||||||
exp := `{ "person": { "title": "goodbye", "age": 18 } }`
|
|
||||||
|
|
||||||
if !compareJSON(exp, res) {
|
|
||||||
t.Fatalf("Key was not replaced")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type nonObjectCases struct {
|
|
||||||
doc, pat, res string
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergePatchReplacesNonObjectsWholesale(t *testing.T) {
|
|
||||||
a1 := `[1]`
|
|
||||||
a2 := `[2]`
|
|
||||||
o1 := `{ "a": 1 }`
|
|
||||||
o2 := `{ "a": 2 }`
|
|
||||||
o3 := `{ "a": 1, "b": 1 }`
|
|
||||||
o4 := `{ "a": 2, "b": 1 }`
|
|
||||||
|
|
||||||
cases := []nonObjectCases{
|
|
||||||
{a1, a2, a2},
|
|
||||||
{o1, a2, a2},
|
|
||||||
{a1, o1, o1},
|
|
||||||
{o3, o2, o4},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, c := range cases {
|
|
||||||
act := mergePatch(c.doc, c.pat)
|
|
||||||
|
|
||||||
if !compareJSON(c.res, act) {
|
|
||||||
t.Errorf("whole object replacement failed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergePatchReturnsErrorOnBadJSON(t *testing.T) {
|
|
||||||
_, err := MergePatch([]byte(`[[[[`), []byte(`1`))
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
t.Errorf("Did not return an error for bad json: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = MergePatch([]byte(`1`), []byte(`[[[[`))
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
t.Errorf("Did not return an error for bad json: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var rfcTests = []struct {
|
|
||||||
target string
|
|
||||||
patch string
|
|
||||||
expected string
|
|
||||||
}{
|
|
||||||
// test cases from https://tools.ietf.org/html/rfc7386#appendix-A
|
|
||||||
{target: `{"a":"b"}`, patch: `{"a":"c"}`, expected: `{"a":"c"}`},
|
|
||||||
{target: `{"a":"b"}`, patch: `{"b":"c"}`, expected: `{"a":"b","b":"c"}`},
|
|
||||||
{target: `{"a":"b"}`, patch: `{"a":null}`, expected: `{}`},
|
|
||||||
{target: `{"a":"b","b":"c"}`, patch: `{"a":null}`, expected: `{"b":"c"}`},
|
|
||||||
{target: `{"a":["b"]}`, patch: `{"a":"c"}`, expected: `{"a":"c"}`},
|
|
||||||
{target: `{"a":"c"}`, patch: `{"a":["b"]}`, expected: `{"a":["b"]}`},
|
|
||||||
{target: `{"a":{"b": "c"}}`, patch: `{"a": {"b": "d","c": null}}`, expected: `{"a":{"b":"d"}}`},
|
|
||||||
{target: `{"a":[{"b":"c"}]}`, patch: `{"a":[1]}`, expected: `{"a":[1]}`},
|
|
||||||
{target: `["a","b"]`, patch: `["c","d"]`, expected: `["c","d"]`},
|
|
||||||
{target: `{"a":"b"}`, patch: `["c"]`, expected: `["c"]`},
|
|
||||||
// {target: `{"a":"foo"}`, patch: `null`, expected: `null`},
|
|
||||||
// {target: `{"a":"foo"}`, patch: `"bar"`, expected: `"bar"`},
|
|
||||||
{target: `{"e":null}`, patch: `{"a":1}`, expected: `{"a":1,"e":null}`},
|
|
||||||
{target: `[1,2]`, patch: `{"a":"b","c":null}`, expected: `{"a":"b"}`},
|
|
||||||
{target: `{}`, patch: `{"a":{"bb":{"ccc":null}}}`, expected: `{"a":{"bb":{}}}`},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergePatchRFCCases(t *testing.T) {
|
|
||||||
for i, c := range rfcTests {
|
|
||||||
out := mergePatch(c.target, c.patch)
|
|
||||||
|
|
||||||
if !compareJSON(out, c.expected) {
|
|
||||||
t.Errorf("case[%d], patch '%s' did not apply properly to '%s'. expected:\n'%s'\ngot:\n'%s'", i, c.patch, c.target, c.expected, out)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var rfcFailTests = `
|
|
||||||
{"a":"foo"} | null
|
|
||||||
{"a":"foo"} | "bar"
|
|
||||||
`
|
|
||||||
|
|
||||||
func TestMergePatchFailRFCCases(t *testing.T) {
|
|
||||||
tests := strings.Split(rfcFailTests, "\n")
|
|
||||||
|
|
||||||
for _, c := range tests {
|
|
||||||
if strings.TrimSpace(c) == "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
parts := strings.SplitN(c, "|", 2)
|
|
||||||
|
|
||||||
doc := strings.TrimSpace(parts[0])
|
|
||||||
pat := strings.TrimSpace(parts[1])
|
|
||||||
|
|
||||||
out, err := MergePatch([]byte(doc), []byte(pat))
|
|
||||||
|
|
||||||
if err != errBadJSONPatch {
|
|
||||||
t.Errorf("error not returned properly: %s, %s", err, string(out))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeReplaceKey(t *testing.T) {
|
|
||||||
doc := `{ "title": "hello", "nested": {"one": 1, "two": 2} }`
|
|
||||||
pat := `{ "title": "goodbye", "nested": {"one": 2, "two": 2} }`
|
|
||||||
|
|
||||||
exp := `{ "title": "goodbye", "nested": {"one": 2} }`
|
|
||||||
|
|
||||||
res, err := CreateMergePatch([]byte(doc), []byte(pat))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !compareJSON(exp, string(res)) {
|
|
||||||
t.Fatalf("Key was not replaced")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeGetArray(t *testing.T) {
|
|
||||||
doc := `{ "title": "hello", "array": ["one", "two"], "notmatch": [1, 2, 3] }`
|
|
||||||
pat := `{ "title": "hello", "array": ["one", "two", "three"], "notmatch": [1, 2, 3] }`
|
|
||||||
|
|
||||||
exp := `{ "array": ["one", "two", "three"] }`
|
|
||||||
|
|
||||||
res, err := CreateMergePatch([]byte(doc), []byte(pat))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !compareJSON(exp, string(res)) {
|
|
||||||
t.Fatalf("Array was not added")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeGetObjArray(t *testing.T) {
|
|
||||||
doc := `{ "title": "hello", "array": [{"banana": true}, {"evil": false}], "notmatch": [{"one":1}, {"two":2}, {"three":3}] }`
|
|
||||||
pat := `{ "title": "hello", "array": [{"banana": false}, {"evil": true}], "notmatch": [{"one":1}, {"two":2}, {"three":3}] }`
|
|
||||||
|
|
||||||
exp := `{ "array": [{"banana": false}, {"evil": true}] }`
|
|
||||||
|
|
||||||
res, err := CreateMergePatch([]byte(doc), []byte(pat))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !compareJSON(exp, string(res)) {
|
|
||||||
t.Fatalf("Object array was not added")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeDeleteKey(t *testing.T) {
|
|
||||||
doc := `{ "title": "hello", "nested": {"one": 1, "two": 2} }`
|
|
||||||
pat := `{ "title": "hello", "nested": {"one": 1} }`
|
|
||||||
|
|
||||||
exp := `{"nested":{"two":null}}`
|
|
||||||
|
|
||||||
res, err := CreateMergePatch([]byte(doc), []byte(pat))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot use "compareJSON", since Equals does not report a difference if the value is null
|
|
||||||
if exp != string(res) {
|
|
||||||
t.Fatalf("Key was not removed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeEmptyArray(t *testing.T) {
|
|
||||||
doc := `{ "array": null }`
|
|
||||||
pat := `{ "array": [] }`
|
|
||||||
|
|
||||||
exp := `{"array":[]}`
|
|
||||||
|
|
||||||
res, err := CreateMergePatch([]byte(doc), []byte(pat))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot use "compareJSON", since Equals does not report a difference if the value is null
|
|
||||||
if exp != string(res) {
|
|
||||||
t.Fatalf("Key was not removed")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeObjArray(t *testing.T) {
|
|
||||||
doc := `{ "array": [ {"a": {"b": 2}}, {"a": {"b": 3}} ]}`
|
|
||||||
exp := `{}`
|
|
||||||
|
|
||||||
res, err := CreateMergePatch([]byte(doc), []byte(doc))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot use "compareJSON", since Equals does not report a difference if the value is null
|
|
||||||
if exp != string(res) {
|
|
||||||
t.Fatalf("Array was not empty, was " + string(res))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeComplexMatch(t *testing.T) {
|
|
||||||
doc := `{"hello": "world","t": true ,"f": false, "n": null,"i": 123,"pi": 3.1416,"a": [1, 2, 3, 4], "nested": {"hello": "world","t": true ,"f": false, "n": null,"i": 123,"pi": 3.1416,"a": [1, 2, 3, 4]} }`
|
|
||||||
empty := `{}`
|
|
||||||
res, err := CreateMergePatch([]byte(doc), []byte(doc))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// We cannot use "compareJSON", since Equals does not report a difference if the value is null
|
|
||||||
if empty != string(res) {
|
|
||||||
t.Fatalf("Did not get empty result, was:%s", string(res))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeComplexAddAll(t *testing.T) {
|
|
||||||
doc := `{"hello": "world","t": true ,"f": false, "n": null,"i": 123,"pi": 3.1416,"a": [1, 2, 3, 4], "nested": {"hello": "world","t": true ,"f": false, "n": null,"i": 123,"pi": 3.1416,"a": [1, 2, 3, 4]} }`
|
|
||||||
empty := `{}`
|
|
||||||
res, err := CreateMergePatch([]byte(empty), []byte(doc))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
if !compareJSON(doc, string(res)) {
|
|
||||||
t.Fatalf("Did not get everything as, it was:\n%s", string(res))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMergeComplexRemoveAll(t *testing.T) {
|
|
||||||
doc := `{"hello": "world","t": true ,"f": false, "n": null,"i": 123,"pi": 3.1416,"a": [1, 2, 3, 4], "nested": {"hello": "world","t": true ,"f": false, "n": null,"i": 123,"pi": 3.1416,"a": [1, 2, 3, 4]} }`
|
|
||||||
exp := `{"a":null,"f":null,"hello":null,"i":null,"n":null,"nested":null,"pi":null,"t":null}`
|
|
||||||
empty := `{}`
|
|
||||||
res, err := CreateMergePatch([]byte(doc), []byte(empty))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unexpected error: %s, %s", err, string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
if exp != string(res) {
|
|
||||||
t.Fatalf("Did not get result, was:%s", string(res))
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Crashes if using compareJSON like this:
|
|
||||||
/*
|
|
||||||
if !compareJSON(doc, string(res)) {
|
|
||||||
t.Fatalf("Did not get everything as, it was:\n%s", string(res))
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
234
Godeps/_workspace/src/github.com/evanphx/json-patch/patch_test.go
generated
vendored
234
Godeps/_workspace/src/github.com/evanphx/json-patch/patch_test.go
generated
vendored
|
@ -1,234 +0,0 @@
|
||||||
package jsonpatch
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func reformatJSON(j string) string {
|
|
||||||
buf := new(bytes.Buffer)
|
|
||||||
|
|
||||||
json.Indent(buf, []byte(j), "", " ")
|
|
||||||
|
|
||||||
return buf.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
func compareJSON(a, b string) bool {
|
|
||||||
// return Equal([]byte(a), []byte(b))
|
|
||||||
|
|
||||||
var obj_a, obj_b map[string]interface{}
|
|
||||||
json.Unmarshal([]byte(a), &obj_a)
|
|
||||||
json.Unmarshal([]byte(b), &obj_b)
|
|
||||||
|
|
||||||
// fmt.Printf("Comparing %#v\nagainst %#v\n", obj_a, obj_b)
|
|
||||||
return reflect.DeepEqual(obj_a, obj_b)
|
|
||||||
}
|
|
||||||
|
|
||||||
func applyPatch(doc, patch string) (string, error) {
|
|
||||||
obj, err := DecodePatch([]byte(patch))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
out, err := obj.Apply([]byte(doc))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(out), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type Case struct {
|
|
||||||
doc, patch, result string
|
|
||||||
}
|
|
||||||
|
|
||||||
var Cases = []Case{
|
|
||||||
{
|
|
||||||
`{ "foo": "bar"}`,
|
|
||||||
`[
|
|
||||||
{ "op": "add", "path": "/baz", "value": "qux" }
|
|
||||||
]`,
|
|
||||||
`{
|
|
||||||
"baz": "qux",
|
|
||||||
"foo": "bar"
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "foo": [ "bar", "baz" ] }`,
|
|
||||||
`[
|
|
||||||
{ "op": "add", "path": "/foo/1", "value": "qux" }
|
|
||||||
]`,
|
|
||||||
`{ "foo": [ "bar", "qux", "baz" ] }`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "baz": "qux", "foo": "bar" }`,
|
|
||||||
`[ { "op": "remove", "path": "/baz" } ]`,
|
|
||||||
`{ "foo": "bar" }`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "foo": [ "bar", "qux", "baz" ] }`,
|
|
||||||
`[ { "op": "remove", "path": "/foo/1" } ]`,
|
|
||||||
`{ "foo": [ "bar", "baz" ] }`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "baz": "qux", "foo": "bar" }`,
|
|
||||||
`[ { "op": "replace", "path": "/baz", "value": "boo" } ]`,
|
|
||||||
`{ "baz": "boo", "foo": "bar" }`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{
|
|
||||||
"foo": {
|
|
||||||
"bar": "baz",
|
|
||||||
"waldo": "fred"
|
|
||||||
},
|
|
||||||
"qux": {
|
|
||||||
"corge": "grault"
|
|
||||||
}
|
|
||||||
}`,
|
|
||||||
`[ { "op": "move", "from": "/foo/waldo", "path": "/qux/thud" } ]`,
|
|
||||||
`{
|
|
||||||
"foo": {
|
|
||||||
"bar": "baz"
|
|
||||||
},
|
|
||||||
"qux": {
|
|
||||||
"corge": "grault",
|
|
||||||
"thud": "fred"
|
|
||||||
}
|
|
||||||
}`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "foo": [ "all", "grass", "cows", "eat" ] }`,
|
|
||||||
`[ { "op": "move", "from": "/foo/1", "path": "/foo/3" } ]`,
|
|
||||||
`{ "foo": [ "all", "cows", "eat", "grass" ] }`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "foo": "bar" }`,
|
|
||||||
`[ { "op": "add", "path": "/child", "value": { "grandchild": { } } } ]`,
|
|
||||||
`{ "foo": "bar", "child": { "grandchild": { } } }`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "foo": ["bar"] }`,
|
|
||||||
`[ { "op": "add", "path": "/foo/-", "value": ["abc", "def"] } ]`,
|
|
||||||
`{ "foo": ["bar", ["abc", "def"]] }`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "foo": "bar", "qux": { "baz": 1, "bar": null } }`,
|
|
||||||
`[ { "op": "remove", "path": "/qux/bar" } ]`,
|
|
||||||
`{ "foo": "bar", "qux": { "baz": 1 } }`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
type BadCase struct {
|
|
||||||
doc, patch string
|
|
||||||
}
|
|
||||||
|
|
||||||
var MutationTestCases = []BadCase{
|
|
||||||
{
|
|
||||||
`{ "foo": "bar", "qux": { "baz": 1, "bar": null } }`,
|
|
||||||
`[ { "op": "remove", "path": "/qux/bar" } ]`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
var BadCases = []BadCase{
|
|
||||||
{
|
|
||||||
`{ "foo": "bar" }`,
|
|
||||||
`[ { "op": "add", "path": "/baz/bat", "value": "qux" } ]`,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAllCases(t *testing.T) {
|
|
||||||
for _, c := range Cases {
|
|
||||||
out, err := applyPatch(c.doc, c.patch)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unable to apply patch: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !compareJSON(out, c.result) {
|
|
||||||
t.Errorf("Patch did not apply. Expected:\n%s\n\nActual:\n%s",
|
|
||||||
reformatJSON(c.result), reformatJSON(out))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, c := range MutationTestCases {
|
|
||||||
out, err := applyPatch(c.doc, c.patch)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("Unable to apply patch: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if compareJSON(out, c.doc) {
|
|
||||||
t.Errorf("Patch did not apply. Original:\n%s\n\nPatched:\n%s",
|
|
||||||
reformatJSON(c.doc), reformatJSON(out))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, c := range BadCases {
|
|
||||||
_, err := applyPatch(c.doc, c.patch)
|
|
||||||
|
|
||||||
if err == nil {
|
|
||||||
t.Errorf("Patch should have failed to apply but it did not")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type TestCase struct {
|
|
||||||
doc, patch string
|
|
||||||
result bool
|
|
||||||
failedPath string
|
|
||||||
}
|
|
||||||
|
|
||||||
var TestCases = []TestCase{
|
|
||||||
{
|
|
||||||
`{
|
|
||||||
"baz": "qux",
|
|
||||||
"foo": [ "a", 2, "c" ]
|
|
||||||
}`,
|
|
||||||
`[
|
|
||||||
{ "op": "test", "path": "/baz", "value": "qux" },
|
|
||||||
{ "op": "test", "path": "/foo/1", "value": 2 }
|
|
||||||
]`,
|
|
||||||
true,
|
|
||||||
"",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{ "baz": "qux" }`,
|
|
||||||
`[ { "op": "test", "path": "/baz", "value": "bar" } ]`,
|
|
||||||
false,
|
|
||||||
"/baz",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
`{
|
|
||||||
"baz": "qux",
|
|
||||||
"foo": ["a", 2, "c"]
|
|
||||||
}`,
|
|
||||||
`[
|
|
||||||
{ "op": "test", "path": "/baz", "value": "qux" },
|
|
||||||
{ "op": "test", "path": "/foo/1", "value": "c" }
|
|
||||||
]`,
|
|
||||||
false,
|
|
||||||
"/foo/1",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestAllTest(t *testing.T) {
|
|
||||||
for _, c := range TestCases {
|
|
||||||
_, err := applyPatch(c.doc, c.patch)
|
|
||||||
|
|
||||||
if c.result && err != nil {
|
|
||||||
t.Errorf("Testing failed when it should have passed: %s", err)
|
|
||||||
} else if !c.result && err == nil {
|
|
||||||
t.Errorf("Testing passed when it should have faild: %s", err)
|
|
||||||
} else if !c.result {
|
|
||||||
expected := fmt.Sprintf("Testing value %s failed", c.failedPath)
|
|
||||||
if err.Error() != expected {
|
|
||||||
t.Errorf("Testing failed as expected but invalid message: expected [%s], got [%s]", expected, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
6
Godeps/_workspace/src/github.com/fatih/structs/field.go
generated
vendored
6
Godeps/_workspace/src/github.com/fatih/structs/field.go
generated
vendored
|
@ -41,7 +41,7 @@ func (f *Field) IsExported() bool {
|
||||||
return f.field.PkgPath == ""
|
return f.field.PkgPath == ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsZero returns true if the given field is not initalized (has a zero value).
|
// IsZero returns true if the given field is not initialized (has a zero value).
|
||||||
// It panics if the field is not exported.
|
// It panics if the field is not exported.
|
||||||
func (f *Field) IsZero() bool {
|
func (f *Field) IsZero() bool {
|
||||||
zero := reflect.Zero(f.value.Type()).Interface()
|
zero := reflect.Zero(f.value.Type()).Interface()
|
||||||
|
@ -60,8 +60,8 @@ func (f *Field) Kind() reflect.Kind {
|
||||||
return f.value.Kind()
|
return f.value.Kind()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set sets the field to given value v. It retuns an error if the field is not
|
// Set sets the field to given value v. It returns an error if the field is not
|
||||||
// settable (not addresable or not exported) or if the given value's type
|
// settable (not addressable or not exported) or if the given value's type
|
||||||
// doesn't match the fields type.
|
// doesn't match the fields type.
|
||||||
func (f *Field) Set(val interface{}) error {
|
func (f *Field) Set(val interface{}) error {
|
||||||
// we can't set unexported fields, so be sure this field is exported
|
// we can't set unexported fields, so be sure this field is exported
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue