Merge pull request #75270 from justincormack/uuid4
Use UUIDv4 not UUIDv1
This commit is contained in:
		@@ -470,6 +470,10 @@
 | 
				
			|||||||
			"ImportPath": "github.com/google/gofuzz",
 | 
								"ImportPath": "github.com/google/gofuzz",
 | 
				
			||||||
			"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
								"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"ImportPath": "github.com/google/uuid",
 | 
				
			||||||
 | 
								"Rev": "8c31c18f31ede9fc8eae72290a7e7a8064e9b3e3"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
								"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
				
			||||||
			"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
								"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,6 +62,10 @@
 | 
				
			|||||||
			"ImportPath": "github.com/google/gofuzz",
 | 
								"ImportPath": "github.com/google/gofuzz",
 | 
				
			||||||
			"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
								"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"ImportPath": "github.com/google/uuid",
 | 
				
			||||||
 | 
								"Rev": "8c31c18f31ede9fc8eae72290a7e7a8064e9b3e3"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
								"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
				
			||||||
			"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
								"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
				
			||||||
@@ -98,10 +102,6 @@
 | 
				
			|||||||
			"ImportPath": "github.com/mxk/go-flowrate/flowrate",
 | 
								"ImportPath": "github.com/mxk/go-flowrate/flowrate",
 | 
				
			||||||
			"Rev": "cca7078d478f8520f85629ad7c68962d31ed7682"
 | 
								"Rev": "cca7078d478f8520f85629ad7c68962d31ed7682"
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			"ImportPath": "github.com/pborman/uuid",
 | 
					 | 
				
			||||||
			"Rev": "ca53cad383cad2479bbba7f7a1a05797ec1386e4"
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"ImportPath": "github.com/pmezard/go-difflib/difflib",
 | 
								"ImportPath": "github.com/pmezard/go-difflib/difflib",
 | 
				
			||||||
			"Rev": "5d4384ee4fb2527b0a1256a821ebfc92f91efefc"
 | 
								"Rev": "5d4384ee4fb2527b0a1256a821ebfc92f91efefc"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@ go_library(
 | 
				
			|||||||
    importpath = "k8s.io/apimachinery/pkg/util/uuid",
 | 
					    importpath = "k8s.io/apimachinery/pkg/util/uuid",
 | 
				
			||||||
    deps = [
 | 
					    deps = [
 | 
				
			||||||
        "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
 | 
					        "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
 | 
				
			||||||
        "//vendor/github.com/pborman/uuid:go_default_library",
 | 
					        "//vendor/github.com/google/uuid:go_default_library",
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,27 +17,11 @@ limitations under the License.
 | 
				
			|||||||
package uuid
 | 
					package uuid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"sync"
 | 
						"github.com/google/uuid"
 | 
				
			||||||
 | 
					 | 
				
			||||||
	"github.com/pborman/uuid"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/types"
 | 
						"k8s.io/apimachinery/pkg/types"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var uuidLock sync.Mutex
 | 
					 | 
				
			||||||
var lastUUID uuid.UUID
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
func NewUUID() types.UID {
 | 
					func NewUUID() types.UID {
 | 
				
			||||||
	uuidLock.Lock()
 | 
						return types.UID(uuid.New().String())
 | 
				
			||||||
	defer uuidLock.Unlock()
 | 
					 | 
				
			||||||
	result := uuid.NewUUID()
 | 
					 | 
				
			||||||
	// The UUID package is naive and can generate identical UUIDs if the
 | 
					 | 
				
			||||||
	// time interval is quick enough.
 | 
					 | 
				
			||||||
	// The UUID uses 100 ns increments so it's short enough to actively
 | 
					 | 
				
			||||||
	// wait for a new value.
 | 
					 | 
				
			||||||
	for uuid.Equal(lastUUID, result) == true {
 | 
					 | 
				
			||||||
		result = uuid.NewUUID()
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	lastUUID = result
 | 
					 | 
				
			||||||
	return types.UID(result.String())
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								staging/src/k8s.io/apiserver/Godeps/Godeps.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								staging/src/k8s.io/apiserver/Godeps/Godeps.json
									
									
									
										generated
									
									
									
								
							@@ -450,6 +450,10 @@
 | 
				
			|||||||
			"ImportPath": "github.com/google/gofuzz",
 | 
								"ImportPath": "github.com/google/gofuzz",
 | 
				
			||||||
			"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
								"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"ImportPath": "github.com/google/uuid",
 | 
				
			||||||
 | 
								"Rev": "8c31c18f31ede9fc8eae72290a7e7a8064e9b3e3"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
								"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
				
			||||||
			"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
								"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -142,6 +142,10 @@
 | 
				
			|||||||
			"ImportPath": "github.com/google/gofuzz",
 | 
								"ImportPath": "github.com/google/gofuzz",
 | 
				
			||||||
			"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
								"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"ImportPath": "github.com/google/uuid",
 | 
				
			||||||
 | 
								"Rev": "8c31c18f31ede9fc8eae72290a7e7a8064e9b3e3"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
								"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
				
			||||||
			"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
								"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,6 +134,10 @@
 | 
				
			|||||||
			"ImportPath": "github.com/google/gofuzz",
 | 
								"ImportPath": "github.com/google/gofuzz",
 | 
				
			||||||
			"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
								"Rev": "24818f796faf91cd76ec7bddd72458fbced7a6c1"
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								"ImportPath": "github.com/google/uuid",
 | 
				
			||||||
 | 
								"Rev": "8c31c18f31ede9fc8eae72290a7e7a8064e9b3e3"
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
								"ImportPath": "github.com/googleapis/gnostic/OpenAPIv2",
 | 
				
			||||||
			"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
								"Rev": "0c5108395e2debce0d731cf0287ddf7242066aba"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user