mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Updated godeps
Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
parent
68ae284db5
commit
53c755b79d
5 changed files with 203 additions and 1 deletions
15
libnetwork/Godeps/Godeps.json
generated
15
libnetwork/Godeps/Godeps.json
generated
|
@ -1,12 +1,20 @@
|
|||
{
|
||||
"ImportPath": "github.com/docker/libnetwork",
|
||||
"GoVersion": "go1.2.1",
|
||||
"GoVersion": "go1.4.2",
|
||||
"Packages": [
|
||||
"./..."
|
||||
],
|
||||
"Deps": [
|
||||
{
|
||||
"ImportPath": "github.com/Sirupsen/logrus",
|
||||
"Comment": "v0.6.4-12-g467d9d5",
|
||||
"Rev": "467d9d55c2d2c17248441a8fc661561161f40d5e"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/common",
|
||||
"Comment": "v1.4.1-1379-g8e107a9",
|
||||
"Rev": "8e107a93210c54f22ec1354d969c771b1abfbe05"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/docker/pkg/iptables",
|
||||
"Comment": "v1.4.1-2492-ge690ad9",
|
||||
|
@ -27,6 +35,11 @@
|
|||
"Comment": "v1.4.1-2492-ge690ad9",
|
||||
"Rev": "e690ad92925a045344bde8d2d59d7a7f602dded6"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/docker/libcontainer/utils",
|
||||
"Comment": "v1.4.0-324-g88989e6",
|
||||
"Rev": "88989e66d3a1ab960deb37f3dd7f824d85e1b9bc"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/vishvananda/netlink",
|
||||
"Rev": "8eb64238879fed52fd51c5b30ad20b928fb4c36c"
|
||||
|
|
47
libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/common/randomid.go
generated
vendored
Normal file
47
libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/common/randomid.go
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// TruncateID returns a shorthand version of a string identifier for convenience.
|
||||
// A collision with other shorthands is very unlikely, but possible.
|
||||
// In case of a collision a lookup with TruncIndex.Get() will fail, and the caller
|
||||
// will need to use a langer prefix, or the full-length Id.
|
||||
func TruncateID(id string) string {
|
||||
shortLen := 12
|
||||
if len(id) < shortLen {
|
||||
shortLen = len(id)
|
||||
}
|
||||
return id[:shortLen]
|
||||
}
|
||||
|
||||
// GenerateRandomID returns an unique id
|
||||
func GenerateRandomID() string {
|
||||
for {
|
||||
id := make([]byte, 32)
|
||||
if _, err := io.ReadFull(rand.Reader, id); err != nil {
|
||||
panic(err) // This shouldn't happen
|
||||
}
|
||||
value := hex.EncodeToString(id)
|
||||
// if we try to parse the truncated for as an int and we don't have
|
||||
// an error then the value is all numberic and causes issues when
|
||||
// used as a hostname. ref #3869
|
||||
if _, err := strconv.ParseInt(TruncateID(value), 10, 64); err == nil {
|
||||
continue
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
func RandomString() string {
|
||||
id := make([]byte, 32)
|
||||
|
||||
if _, err := io.ReadFull(rand.Reader, id); err != nil {
|
||||
panic(err) // This shouldn't happen
|
||||
}
|
||||
return hex.EncodeToString(id)
|
||||
}
|
59
libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/common/randomid_test.go
generated
vendored
Normal file
59
libnetwork/Godeps/_workspace/src/github.com/docker/docker/pkg/common/randomid_test.go
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestShortenId(t *testing.T) {
|
||||
id := GenerateRandomID()
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) != 12 {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortenIdEmpty(t *testing.T) {
|
||||
id := ""
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) > len(id) {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShortenIdInvalid(t *testing.T) {
|
||||
id := "1234"
|
||||
truncID := TruncateID(id)
|
||||
if len(truncID) != len(id) {
|
||||
t.Fatalf("Id returned is incorrect: truncate on %s returned %s", id, truncID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateRandomID(t *testing.T) {
|
||||
id := GenerateRandomID()
|
||||
|
||||
if len(id) != 64 {
|
||||
t.Fatalf("Id returned is incorrect: %s", id)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRandomString(t *testing.T) {
|
||||
id := RandomString()
|
||||
if len(id) != 64 {
|
||||
t.Fatalf("Id returned is incorrect: %s", id)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRandomStringUniqueness(t *testing.T) {
|
||||
repeats := 25
|
||||
set := make(map[string]struct{}, repeats)
|
||||
for i := 0; i < repeats; i = i + 1 {
|
||||
id := RandomString()
|
||||
if len(id) != 64 {
|
||||
t.Fatalf("Id returned is incorrect: %s", id)
|
||||
}
|
||||
if _, ok := set[id]; ok {
|
||||
t.Fatalf("Random number is repeated")
|
||||
}
|
||||
set[id] = struct{}{}
|
||||
}
|
||||
}
|
68
libnetwork/Godeps/_workspace/src/github.com/docker/libcontainer/utils/utils.go
generated
vendored
Normal file
68
libnetwork/Godeps/_workspace/src/github.com/docker/libcontainer/utils/utils.go
generated
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const (
|
||||
exitSignalOffset = 128
|
||||
)
|
||||
|
||||
// GenerateRandomName returns a new name joined with a prefix. This size
|
||||
// specified is used to truncate the randomly generated value
|
||||
func GenerateRandomName(prefix string, size int) (string, error) {
|
||||
id := make([]byte, 32)
|
||||
if _, err := io.ReadFull(rand.Reader, id); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return prefix + hex.EncodeToString(id)[:size], nil
|
||||
}
|
||||
|
||||
// ResolveRootfs ensures that the current working directory is
|
||||
// not a symlink and returns the absolute path to the rootfs
|
||||
func ResolveRootfs(uncleanRootfs string) (string, error) {
|
||||
rootfs, err := filepath.Abs(uncleanRootfs)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.EvalSymlinks(rootfs)
|
||||
}
|
||||
|
||||
func CloseExecFrom(minFd int) error {
|
||||
fdList, err := ioutil.ReadDir("/proc/self/fd")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, fi := range fdList {
|
||||
fd, err := strconv.Atoi(fi.Name())
|
||||
if err != nil {
|
||||
// ignore non-numeric file names
|
||||
continue
|
||||
}
|
||||
|
||||
if fd < minFd {
|
||||
// ignore descriptors lower than our specified minimum
|
||||
continue
|
||||
}
|
||||
|
||||
// intentionally ignore errors from syscall.CloseOnExec
|
||||
syscall.CloseOnExec(fd)
|
||||
// the cases where this might fail are basically file descriptors that have already been closed (including and especially the one that was created when ioutil.ReadDir did the "opendir" syscall)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExitStatus returns the correct exit status for a process based on if it
|
||||
// was signaled or existed cleanly.
|
||||
func ExitStatus(status syscall.WaitStatus) int {
|
||||
if status.Signaled() {
|
||||
return exitSignalOffset + int(status.Signal())
|
||||
}
|
||||
return status.ExitStatus()
|
||||
}
|
15
libnetwork/Godeps/_workspace/src/github.com/docker/libcontainer/utils/utils_test.go
generated
vendored
Normal file
15
libnetwork/Godeps/_workspace/src/github.com/docker/libcontainer/utils/utils_test.go
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
|||
package utils
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestGenerateName(t *testing.T) {
|
||||
name, err := GenerateRandomName("veth", 5)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expected := 5 + len("veth")
|
||||
if len(name) != 5+len("veth") {
|
||||
t.Fatalf("expected name to be %d chars but received %d", expected, len(name))
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue