migrate callers to g/g/uuid

This commit is contained in:
Mike Danese 2019-11-04 23:15:20 -08:00
parent 590cbef0f6
commit a4ca9e6c93
25 changed files with 50 additions and 48 deletions

View File

@ -23,7 +23,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/github.com/quobyte/api:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/utils/strings:go_default_library",

View File

@ -22,7 +22,7 @@ import (
"path/filepath"
gostrings "strings"
"github.com/pborman/uuid"
"github.com/google/uuid"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -408,7 +408,7 @@ func (provisioner *quobyteVolumeProvisioner) Provision(selectedNode *v1.Node, al
}
// create random image name
provisioner.volume = fmt.Sprintf("kubernetes-dynamic-pvc-%s", uuid.NewUUID())
provisioner.volume = fmt.Sprintf("kubernetes-dynamic-pvc-%s", uuid.New().String())
manager := &quobyteVolumeManager{
config: cfg,

View File

@ -13,6 +13,7 @@ require (
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d
github.com/google/go-cmp v0.3.0
github.com/google/gofuzz v1.0.0
github.com/google/uuid v1.1.1
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d
github.com/pborman/uuid v1.2.0
github.com/spf13/cobra v0.0.5

View File

@ -31,7 +31,7 @@ go_library(
"//staging/src/k8s.io/client-go/rest:go_default_library",
"//staging/src/k8s.io/client-go/restmapper:go_default_library",
"//staging/src/k8s.io/client-go/scale:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/k8s.io/utils/pointer:go_default_library",
],
)

View File

@ -21,7 +21,7 @@ import (
"os"
"strings"
"github.com/pborman/uuid"
"github.com/google/uuid"
"k8s.io/apiextensions-apiserver/pkg/cmd/server/options"
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
@ -59,7 +59,7 @@ users:
fakeKubeConfig.Close()
s, err := servertesting.StartTestServer(t, nil, append([]string{
"--etcd-prefix", uuid.New(),
"--etcd-prefix", uuid.New().String(),
"--etcd-servers", strings.Join(IntegrationEtcdServers(), ","),
"--authentication-skip-lookup",
"--authentication-kubeconfig", fakeKubeConfig.Name(),

View File

@ -19,6 +19,7 @@ require (
github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d
github.com/google/go-cmp v0.3.0
github.com/google/gofuzz v1.0.0
github.com/google/uuid v1.1.1
github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d
github.com/gorilla/websocket v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0

View File

@ -37,7 +37,7 @@ go_library(
"//staging/src/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
"//staging/src/k8s.io/component-base/metrics:go_default_library",
"//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@ -23,7 +23,7 @@ import (
"reflect"
"time"
"github.com/pborman/uuid"
"github.com/google/uuid"
"k8s.io/klog"
authnv1 "k8s.io/api/authentication/v1"
@ -58,7 +58,7 @@ func NewEventFromRequest(req *http.Request, level auditinternal.Level, attribs a
if ids != "" {
ev.AuditID = types.UID(ids)
} else {
ev.AuditID = types.UID(uuid.NewRandom().String())
ev.AuditID = types.UID(uuid.New().String())
}
ips := utilnet.SourceIPs(req)

View File

@ -18,7 +18,7 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/authentication/authenticator:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
],
)

View File

@ -21,7 +21,7 @@ import (
"testing"
"time"
"github.com/pborman/uuid"
"github.com/google/uuid"
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apiserver/pkg/authentication/authenticator"
@ -50,7 +50,7 @@ func BenchmarkStripedCache(b *testing.B) {
func benchmarkCache(cache cache, b *testing.B) {
keys := []string{}
for i := 0; i < b.N; i++ {
key := uuid.NewRandom().String()
key := uuid.New().String()
keys = append(keys, key)
}

View File

@ -33,7 +33,7 @@ go_test(
"//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/github.com/stretchr/testify/assert:go_default_library",
],
)

View File

@ -26,7 +26,7 @@ import (
"testing"
"time"
"github.com/pborman/uuid"
"github.com/google/uuid"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
@ -223,7 +223,7 @@ func TestAudit(t *testing.T) {
"short running with auditID",
shortRunningPath,
"GET",
uuid.NewRandom().String(),
uuid.New().String(),
nil,
func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("foo"))
@ -422,7 +422,7 @@ func TestAudit(t *testing.T) {
"empty longrunning with audit id",
longRunningPath,
"GET",
uuid.NewRandom().String(),
uuid.New().String(),
nil,
func(w http.ResponseWriter, req *http.Request) {
w.Write([]byte("foo"))
@ -778,7 +778,7 @@ func TestAuditIDHttpHeader(t *testing.T) {
},
{
"no http header when there is no audit even the request header specified",
uuid.NewRandom().String(),
uuid.New().String(),
auditinternal.LevelNone,
false,
},
@ -790,7 +790,7 @@ func TestAuditIDHttpHeader(t *testing.T) {
},
{
"user provided header",
uuid.NewRandom().String(),
uuid.New().String(),
auditinternal.LevelRequestResponse,
true,
},

View File

@ -113,7 +113,7 @@ go_library(
"//vendor/github.com/emicklei/go-restful:go_default_library",
"//vendor/github.com/evanphx/json-patch:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/golang.org/x/net/http2:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/kube-openapi/pkg/builder:go_default_library",

View File

@ -30,7 +30,7 @@ import (
jsonpatch "github.com/evanphx/json-patch"
"github.com/go-openapi/spec"
"github.com/pborman/uuid"
"github.com/google/uuid"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
@ -727,7 +727,7 @@ func AuthorizeClientBearerToken(loopback *restclient.Config, authn *Authenticati
}
privilegedLoopbackToken := loopback.BearerToken
var uid = uuid.NewRandom().String()
var uid = uuid.New().String()
tokens := make(map[string]*user.DefaultInfo)
tokens[privilegedLoopbackToken] = &user.DefaultInfo{
Name: user.APIServerUser,

View File

@ -82,7 +82,7 @@ go_library(
"//staging/src/k8s.io/client-go/util/cert:go_default_library",
"//staging/src/k8s.io/client-go/util/keyutil:go_default_library",
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/github.com/spf13/pflag:go_default_library",
"//vendor/gopkg.in/natefinch/lumberjack.v2:go_default_library",
"//vendor/k8s.io/klog:go_default_library",

View File

@ -19,7 +19,7 @@ package options
import (
"fmt"
"github.com/pborman/uuid"
"github.com/google/uuid"
"k8s.io/apiserver/pkg/server"
"k8s.io/apiserver/pkg/server/dynamiccertificates"
@ -60,7 +60,7 @@ func (s *SecureServingOptionsWithLoopback) ApplyTo(secureServingInfo **server.Se
return fmt.Errorf("failed to generate self-signed certificate for loopback connection: %v", err)
}
secureLoopbackClientConfig, err := (*secureServingInfo).NewLoopbackClientConfig(uuid.NewRandom().String(), certPem)
secureLoopbackClientConfig, err := (*secureServingInfo).NewLoopbackClientConfig(uuid.New().String(), certPem)
switch {
// if we failed and there's no fallback loopback client config, we need to fail
case err != nil && *loopbackClientConfig == nil:

View File

@ -47,6 +47,6 @@ go_test(
"//staging/src/k8s.io/apiserver/pkg/apis/audit/v1:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/apis/audit/v1beta1:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/audit:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
],
)

View File

@ -23,7 +23,7 @@ import (
"testing"
"time"
"github.com/pborman/uuid"
"github.com/google/uuid"
authnv1 "k8s.io/api/authentication/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -48,7 +48,7 @@ func TestLogEventsLegacy(t *testing.T) {
}{
{
&auditinternal.Event{
AuditID: types.UID(uuid.NewRandom().String()),
AuditID: types.UID(uuid.New().String()),
},
`[\d\:\-\.\+TZ]+ AUDIT: id="[\w-]+" stage="" ip="<unknown>" method="" user="<none>" groups="<none>" as="<self>" asgroups="<lookup>" namespace="<none>" uri="" response="<deferred>"`,
},
@ -62,7 +62,7 @@ func TestLogEventsLegacy(t *testing.T) {
"127.0.0.1",
},
RequestReceivedTimestamp: metav1.NewMicroTime(time.Now()),
AuditID: types.UID(uuid.NewRandom().String()),
AuditID: types.UID(uuid.New().String()),
Stage: auditinternal.StageRequestReceived,
Verb: "get",
User: authnv1.UserInfo{
@ -80,7 +80,7 @@ func TestLogEventsLegacy(t *testing.T) {
},
{
&auditinternal.Event{
AuditID: types.UID(uuid.NewRandom().String()),
AuditID: types.UID(uuid.New().String()),
Level: auditinternal.LevelMetadata,
ObjectRef: &auditinternal.ObjectReference{
Resource: "foo",
@ -108,7 +108,7 @@ func TestLogEventsLegacy(t *testing.T) {
func TestLogEventsJson(t *testing.T) {
for _, event := range []*auditinternal.Event{
{
AuditID: types.UID(uuid.NewRandom().String()),
AuditID: types.UID(uuid.New().String()),
},
{
ResponseStatus: &metav1.Status{
@ -120,7 +120,7 @@ func TestLogEventsJson(t *testing.T) {
},
RequestReceivedTimestamp: metav1.NewMicroTime(time.Now().Truncate(time.Microsecond)),
StageTimestamp: metav1.NewMicroTime(time.Now().Truncate(time.Microsecond)),
AuditID: types.UID(uuid.NewRandom().String()),
AuditID: types.UID(uuid.New().String()),
Stage: auditinternal.StageRequestReceived,
Verb: "get",
User: authnv1.UserInfo{
@ -135,7 +135,7 @@ func TestLogEventsJson(t *testing.T) {
},
},
{
AuditID: types.UID(uuid.NewRandom().String()),
AuditID: types.UID(uuid.New().String()),
Level: auditinternal.LevelMetadata,
ObjectRef: &auditinternal.ObjectReference{
Resource: "foo",

View File

@ -18,7 +18,7 @@ go_library(
deps = [
"//test/e2e_node/remote:go_default_library",
"//test/e2e_node/system:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/golang.org/x/oauth2/google:go_default_library",
"//vendor/google.golang.org/api/compute/v0.beta:go_default_library",
"//vendor/google.golang.org/api/option:go_default_library",

View File

@ -39,7 +39,7 @@ import (
"k8s.io/kubernetes/test/e2e_node/remote"
"k8s.io/kubernetes/test/e2e_node/system"
"github.com/pborman/uuid"
"github.com/google/uuid"
"golang.org/x/oauth2/google"
compute "google.golang.org/api/compute/v0.beta"
"google.golang.org/api/option"
@ -300,7 +300,7 @@ func main() {
}
}
if *instanceNamePrefix == "" {
*instanceNamePrefix = "tmp-node-e2e-" + uuid.NewUUID().String()[:8]
*instanceNamePrefix = "tmp-node-e2e-" + uuid.New().String()[:8]
}
// Setup coloring
@ -785,7 +785,7 @@ func imageToInstanceName(imageConfig *internalGCEImage) string {
}
// For benchmark test, node name has the format 'machine-image-uuid' to run
// different machine types with the same image in parallel
return imageConfig.machine + "-" + imageConfig.image + "-" + uuid.NewUUID().String()[:8]
return imageConfig.machine + "-" + imageConfig.image + "-" + uuid.New().String()[:8]
}
func sourceImage(image, imageProject string) string {

View File

@ -71,7 +71,7 @@ go_test(
"//staging/src/k8s.io/component-base/featuregate/testing:go_default_library",
"//staging/src/k8s.io/kubectl/pkg/cmd/util:go_default_library",
"//test/integration/framework:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/k8s.io/gengo/examples/set-gen/sets:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],

View File

@ -22,7 +22,7 @@ import (
"sync/atomic"
"testing"
"github.com/pborman/uuid"
"github.com/google/uuid"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
@ -45,7 +45,7 @@ func TestPatchConflicts(t *testing.T) {
UIDs := make([]types.UID, numOfConcurrentPatches)
ownerRefs := []metav1.OwnerReference{}
for i := 0; i < numOfConcurrentPatches; i++ {
uid := types.UID(uuid.NewRandom().String())
uid := types.UID(uuid.New().String())
ownerName := fmt.Sprintf("owner-%d", i)
UIDs[i] = uid
ownerRefs = append(ownerRefs, metav1.OwnerReference{
@ -76,7 +76,7 @@ func TestPatchConflicts(t *testing.T) {
go func(i int) {
defer wg.Done()
labelName := fmt.Sprintf("label-%d", i)
value := uuid.NewRandom().String()
value := uuid.New().String()
obj, err := client.Patch(types.StrategicMergePatchType).
Namespace(ns.Name).

View File

@ -70,7 +70,7 @@ go_library(
"//test/e2e/framework/node:go_default_library",
"//test/utils:go_default_library",
"//vendor/github.com/go-openapi/spec:go_default_library",
"//vendor/github.com/pborman/uuid:go_default_library",
"//vendor/github.com/google/uuid:go_default_library",
"//vendor/go.etcd.io/etcd/clientv3:go_default_library",
"//vendor/google.golang.org/grpc/grpclog:go_default_library",
"//vendor/k8s.io/klog:go_default_library",

View File

@ -27,7 +27,7 @@ import (
"time"
"github.com/go-openapi/spec"
"github.com/pborman/uuid"
"github.com/google/uuid"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
authauthenticator "k8s.io/apiserver/pkg/authentication/authenticator"
@ -157,12 +157,12 @@ func startMasterOrDie(masterConfig *master.Config, incomingServer *httptest.Serv
}
masterConfig.GenericConfig.LoopbackClientConfig.Host = s.URL
privilegedLoopbackToken := uuid.NewRandom().String()
privilegedLoopbackToken := uuid.New().String()
// wrap any available authorizer
tokens := make(map[string]*user.DefaultInfo)
tokens[privilegedLoopbackToken] = &user.DefaultInfo{
Name: user.APIServerUser,
UID: uuid.NewRandom().String(),
UID: uuid.New().String(),
Groups: []string{user.SystemPrivilegedGroup},
}
@ -260,7 +260,7 @@ func DefaultEtcdOptions() *options.EtcdOptions {
// This causes the integration tests to exercise the etcd
// prefix code, so please don't change without ensuring
// sufficient coverage in other ways.
etcdOptions := options.NewEtcdOptions(storagebackend.NewDefaultConfig(uuid.New(), nil))
etcdOptions := options.NewEtcdOptions(storagebackend.NewDefaultConfig(uuid.New().String(), nil))
etcdOptions.StorageConfig.Transport.ServerList = []string{GetEtcdURL()}
return etcdOptions
}
@ -332,7 +332,7 @@ func RunAMasterUsingServer(masterConfig *master.Config, s *httptest.Server, mast
// SharedEtcd creates a storage config for a shared etcd instance, with a unique prefix.
func SharedEtcd() *storagebackend.Config {
cfg := storagebackend.NewDefaultConfig(path.Join(uuid.New(), "registry"), nil)
cfg := storagebackend.NewDefaultConfig(path.Join(uuid.New().String(), "registry"), nil)
cfg.Transport.ServerList = []string{GetEtcdURL()}
return cfg
}

View File

@ -25,7 +25,7 @@ import (
"testing"
"time"
"github.com/pborman/uuid"
"github.com/google/uuid"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
@ -90,7 +90,7 @@ func StartTestServer(t *testing.T, stopCh <-chan struct{}, setup TestServerSetup
kubeAPIServerOptions.SecureServing.BindAddress = net.ParseIP("127.0.0.1")
kubeAPIServerOptions.SecureServing.ServerCert.CertDirectory = certDir
kubeAPIServerOptions.InsecureServing.BindPort = 0
kubeAPIServerOptions.Etcd.StorageConfig.Prefix = path.Join("/", uuid.New(), "registry")
kubeAPIServerOptions.Etcd.StorageConfig.Prefix = path.Join("/", uuid.New().String(), "registry")
kubeAPIServerOptions.Etcd.StorageConfig.Transport.ServerList = []string{GetEtcdURL()}
kubeAPIServerOptions.ServiceClusterIPRanges = defaultServiceClusterIPRange.String()
kubeAPIServerOptions.Authentication.RequestHeader.UsernameHeaders = []string{"X-Remote-User"}