mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
Switch from to code.google.com/p/go-uuid/uuid to github.com/pborman/uuid
This commit is contained in:
parent
12d2638637
commit
a29789d60e
9
Godeps/Godeps.json
generated
9
Godeps/Godeps.json
generated
@ -14,11 +14,6 @@
|
|||||||
"ImportPath": "code.google.com/p/gcfg",
|
"ImportPath": "code.google.com/p/gcfg",
|
||||||
"Rev": "c2d3050044d05357eaf6c3547249ba57c5e235cb"
|
"Rev": "c2d3050044d05357eaf6c3547249ba57c5e235cb"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"ImportPath": "code.google.com/p/go-uuid/uuid",
|
|
||||||
"Comment": "null-12",
|
|
||||||
"Rev": "7dda39b2e7d5e265014674c5af696ba4186679e9"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/GoogleCloudPlatform/gcloud-golang/compute/metadata",
|
"ImportPath": "github.com/GoogleCloudPlatform/gcloud-golang/compute/metadata",
|
||||||
"Rev": "e34a32f9b0ecbc0784865fb2d47f3818c09521d4"
|
"Rev": "e34a32f9b0ecbc0784865fb2d47f3818c09521d4"
|
||||||
@ -427,6 +422,10 @@
|
|||||||
"Comment": "v1.0-28-g8adf9e1",
|
"Comment": "v1.0-28-g8adf9e1",
|
||||||
"Rev": "8adf9e1730c55cdc590de7d49766cb2acc88d8f2"
|
"Rev": "8adf9e1730c55cdc590de7d49766cb2acc88d8f2"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"ImportPath": "github.com/pborman/uuid",
|
||||||
|
"Rev": "ca53cad383cad2479bbba7f7a1a05797ec1386e4"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/prometheus/client_golang/extraction",
|
"ImportPath": "github.com/prometheus/client_golang/extraction",
|
||||||
"Comment": "0.4.0-1-g692492e",
|
"Comment": "0.4.0-1-g692492e",
|
||||||
|
1
Godeps/_workspace/src/github.com/pborman/uuid/CONTRIBUTORS
generated
vendored
Normal file
1
Godeps/_workspace/src/github.com/pborman/uuid/CONTRIBUTORS
generated
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
Paul Borman <borman@google.com>
|
@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2009 Google Inc. All rights reserved.
|
Copyright (c) 2009,2014 Google Inc. All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
modification, are permitted provided that the following conditions are
|
modification, are permitted provided that the following conditions are
|
30
Godeps/_workspace/src/github.com/pborman/uuid/json.go
generated
vendored
Normal file
30
Godeps/_workspace/src/github.com/pborman/uuid/json.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2014 Google Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package uuid
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
func (u UUID) MarshalJSON() ([]byte, error) {
|
||||||
|
if len(u) == 0 {
|
||||||
|
return []byte(`""`), nil
|
||||||
|
}
|
||||||
|
return []byte(`"` + u.String() + `"`), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *UUID) UnmarshalJSON(data []byte) error {
|
||||||
|
if len(data) == 0 || string(data) == `""` {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if len(data) < 2 || data[0] != '"' || data[len(data)-1] != '"' {
|
||||||
|
return errors.New("invalid UUID format")
|
||||||
|
}
|
||||||
|
data = data[1 : len(data)-1]
|
||||||
|
uu := Parse(string(data))
|
||||||
|
if uu == nil {
|
||||||
|
return errors.New("invalid UUID format")
|
||||||
|
}
|
||||||
|
*u = uu
|
||||||
|
return nil
|
||||||
|
}
|
32
Godeps/_workspace/src/github.com/pborman/uuid/json_test.go
generated
vendored
Normal file
32
Godeps/_workspace/src/github.com/pborman/uuid/json_test.go
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// Copyright 2014 Google Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package uuid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"reflect"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
var testUUID = Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
|
||||||
|
|
||||||
|
func TestJSON(t *testing.T) {
|
||||||
|
type S struct {
|
||||||
|
ID1 UUID
|
||||||
|
ID2 UUID
|
||||||
|
}
|
||||||
|
s1 := S{ID1: testUUID}
|
||||||
|
data, err := json.Marshal(&s1)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var s2 S
|
||||||
|
if err := json.Unmarshal(data, &s2); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(&s1, &s2) {
|
||||||
|
t.Errorf("got %#v, want %#v", s2, s1)
|
||||||
|
}
|
||||||
|
}
|
66
Godeps/_workspace/src/github.com/pborman/uuid/seq_test.go
generated
vendored
Normal file
66
Godeps/_workspace/src/github.com/pborman/uuid/seq_test.go
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// Copyright 2014 Google Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package uuid
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"runtime"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// This test is only run when --regressions is passed on the go test line.
|
||||||
|
var regressions = flag.Bool("regressions", false, "run uuid regression tests")
|
||||||
|
|
||||||
|
// TestClockSeqRace tests for a particular race condition of returning two
|
||||||
|
// identical Version1 UUIDs. The duration of 1 minute was chosen as the race
|
||||||
|
// condition, before being fixed, nearly always occured in under 30 seconds.
|
||||||
|
func TestClockSeqRace(t *testing.T) {
|
||||||
|
if !*regressions {
|
||||||
|
t.Skip("skipping regression tests")
|
||||||
|
}
|
||||||
|
duration := time.Minute
|
||||||
|
|
||||||
|
done := make(chan struct{})
|
||||||
|
defer close(done)
|
||||||
|
|
||||||
|
ch := make(chan UUID, 10000)
|
||||||
|
ncpu := runtime.NumCPU()
|
||||||
|
switch ncpu {
|
||||||
|
case 0, 1:
|
||||||
|
// We can't run the test effectively.
|
||||||
|
t.Skip("skipping race test, only one CPU detected")
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
runtime.GOMAXPROCS(ncpu)
|
||||||
|
}
|
||||||
|
for i := 0; i < ncpu; i++ {
|
||||||
|
go func() {
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return
|
||||||
|
case ch <- NewUUID():
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
|
uuids := make(map[string]bool)
|
||||||
|
cnt := 0
|
||||||
|
start := time.Now()
|
||||||
|
for u := range ch {
|
||||||
|
s := u.String()
|
||||||
|
if uuids[s] {
|
||||||
|
t.Errorf("duplicate uuid after %d in %v: %s", cnt, time.Since(start), s)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uuids[s] = true
|
||||||
|
if time.Since(start) > duration {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cnt++
|
||||||
|
}
|
||||||
|
}
|
@ -40,15 +40,15 @@ func (t Time) UnixTime() (sec, nsec int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and
|
// GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and
|
||||||
// adjusts the clock sequence as needed. An error is returned if the current
|
// clock sequence as well as adjusting the clock sequence as needed. An error
|
||||||
// time cannot be determined.
|
// is returned if the current time cannot be determined.
|
||||||
func GetTime() (Time, error) {
|
func GetTime() (Time, uint16, error) {
|
||||||
defer mu.Unlock()
|
defer mu.Unlock()
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
return getTime()
|
return getTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
func getTime() (Time, error) {
|
func getTime() (Time, uint16, error) {
|
||||||
t := timeNow()
|
t := timeNow()
|
||||||
|
|
||||||
// If we don't have a clock sequence already, set one.
|
// If we don't have a clock sequence already, set one.
|
||||||
@ -63,7 +63,7 @@ func getTime() (Time, error) {
|
|||||||
clock_seq = ((clock_seq + 1) & 0x3fff) | 0x8000
|
clock_seq = ((clock_seq + 1) & 0x3fff) | 0x8000
|
||||||
}
|
}
|
||||||
lasttime = now
|
lasttime = now
|
||||||
return Time(now), nil
|
return Time(now), clock_seq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClockSequence returns the current clock sequence, generating one if not
|
// ClockSequence returns the current clock sequence, generating one if not
|
@ -19,7 +19,7 @@ func NewUUID() UUID {
|
|||||||
SetNodeInterface("")
|
SetNodeInterface("")
|
||||||
}
|
}
|
||||||
|
|
||||||
now, err := GetTime()
|
now, seq, err := GetTime()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ func NewUUID() UUID {
|
|||||||
binary.BigEndian.PutUint32(uuid[0:], time_low)
|
binary.BigEndian.PutUint32(uuid[0:], time_low)
|
||||||
binary.BigEndian.PutUint16(uuid[4:], time_mid)
|
binary.BigEndian.PutUint16(uuid[4:], time_mid)
|
||||||
binary.BigEndian.PutUint16(uuid[6:], time_hi)
|
binary.BigEndian.PutUint16(uuid[6:], time_hi)
|
||||||
binary.BigEndian.PutUint16(uuid[8:], clock_seq)
|
binary.BigEndian.PutUint16(uuid[8:], seq)
|
||||||
copy(uuid[10:], nodeID)
|
copy(uuid[10:], nodeID)
|
||||||
|
|
||||||
return uuid
|
return uuid
|
@ -21,13 +21,13 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.google.com/p/go-uuid/uuid"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/offers"
|
"github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/offers"
|
||||||
annotation "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/meta"
|
annotation "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/meta"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/metrics"
|
"github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/metrics"
|
||||||
mresource "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/resource"
|
mresource "github.com/GoogleCloudPlatform/kubernetes/contrib/mesos/pkg/scheduler/resource"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
|
||||||
"github.com/gogo/protobuf/proto"
|
"github.com/gogo/protobuf/proto"
|
||||||
|
"github.com/pborman/uuid"
|
||||||
|
|
||||||
log "github.com/golang/glog"
|
log "github.com/golang/glog"
|
||||||
mesos "github.com/mesos/mesos-go/mesosproto"
|
mesos "github.com/mesos/mesos-go/mesosproto"
|
||||||
|
@ -21,8 +21,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"code.google.com/p/go-uuid/uuid"
|
|
||||||
log "github.com/golang/glog"
|
log "github.com/golang/glog"
|
||||||
|
"github.com/pborman/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
type UID struct {
|
type UID struct {
|
||||||
|
@ -20,8 +20,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.google.com/p/go-uuid/uuid"
|
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/types"
|
||||||
|
"github.com/pborman/uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
var uuidLock sync.Mutex
|
var uuidLock sync.Mutex
|
||||||
|
Loading…
Reference in New Issue
Block a user