From 1bbabd8ba6e92a7b64cfe787dce0e4c84c1e2624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pereira?= Date: Wed, 20 Nov 2024 16:03:05 -0600 Subject: [PATCH] Change uuid library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: João Pereira --- cf/appfiles/app_files_test.go | 7 ++----- cf/commands/create_app_manifest_test.go | 16 ++++++---------- command/v7/v7_suite_test.go | 8 ++------ go.mod | 2 +- go.sum | 1 + integration/assets/hydrabroker/app/helpers.go | 7 ++----- .../assets/hydrabroker/database/database.go | 7 ++----- .../integrationtest/integrationtest_test.go | 6 ++---- .../assets/hydrabroker/store/bindings_test.go | 8 ++------ .../assets/hydrabroker/store/instances_test.go | 8 ++------ integration/helpers/name_generator.go | 9 ++------- 11 files changed, 24 insertions(+), 55 deletions(-) diff --git a/cf/appfiles/app_files_test.go b/cf/appfiles/app_files_test.go index 63e79ce3571..3a3910c7254 100644 --- a/cf/appfiles/app_files_test.go +++ b/cf/appfiles/app_files_test.go @@ -8,10 +8,9 @@ import ( "strings" "code.cloudfoundry.org/cli/cf/appfiles" - uuid "github.com/nu7hatch/gouuid" - "code.cloudfoundry.org/cli/cf/models" "code.cloudfoundry.org/gofileutils/fileutils" + "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -215,9 +214,7 @@ var _ = Describe("AppFiles", func() { tmpDir, err = ioutil.TempDir("", "untraversable-test") Expect(err).NotTo(HaveOccurred()) - guid, err := uuid.NewV4() - Expect(err).NotTo(HaveOccurred()) - + guid := uuid.New() untraversableDirName = guid.String() untraversableDirPath := filepath.Join(tmpDir, untraversableDirName) diff --git a/cf/commands/create_app_manifest_test.go b/cf/commands/create_app_manifest_test.go index ad3b71d9b76..f2d8804e23a 100644 --- a/cf/commands/create_app_manifest_test.go +++ b/cf/commands/create_app_manifest_test.go @@ -3,7 +3,10 @@ package commands_test import ( "errors" "fmt" + "os" + "code.cloudfoundry.org/cli/cf/api/apifakes" + "code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes" "code.cloudfoundry.org/cli/cf/commandregistry" "code.cloudfoundry.org/cli/cf/commands" "code.cloudfoundry.org/cli/cf/configuration/coreconfig" @@ -12,16 +15,10 @@ import ( "code.cloudfoundry.org/cli/cf/models" "code.cloudfoundry.org/cli/cf/requirements" "code.cloudfoundry.org/cli/cf/requirements/requirementsfakes" - - "code.cloudfoundry.org/cli/cf/api/apifakes" - "code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes" testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" - testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" - - "os" - . "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers" - uuid "github.com/nu7hatch/gouuid" + testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal" + uuid "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -47,8 +44,7 @@ var _ = Describe("CreateAppManifest", func() { ) BeforeEach(func() { - rand, err := uuid.NewV4() - Expect(err).ToNot(HaveOccurred()) + rand := uuid.New() appName = fmt.Sprintf("app-name-%s", rand) ui = &testterm.FakeUI{} configRepo = testconfig.NewRepositoryWithDefaults() diff --git a/command/v7/v7_suite_test.go b/command/v7/v7_suite_test.go index 8a1af2c03a2..c66e62bc1a1 100644 --- a/command/v7/v7_suite_test.go +++ b/command/v7/v7_suite_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - uuid "github.com/nu7hatch/gouuid" + uuid "github.com/google/uuid" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" log "github.com/sirupsen/logrus" @@ -23,11 +23,7 @@ var _ = BeforeEach(func() { // RandomString provides a random string func RandomString(prefix string) string { - guid, err := uuid.NewV4() - if err != nil { - panic(err) - } - + guid := uuid.New() return prefix + "-" + guid.String() } diff --git a/go.mod b/go.mod index 3d96c0b4968..c91f2d8d605 100644 --- a/go.mod +++ b/go.mod @@ -25,13 +25,13 @@ require ( github.com/distribution/reference v0.6.0 github.com/fatih/color v1.18.0 github.com/google/go-querystring v1.1.0 + github.com/google/uuid v1.6.0 github.com/jessevdk/go-flags v1.6.1 github.com/lunixbochs/vtclean v1.0.0 github.com/mattn/go-colorable v0.1.13 github.com/mattn/go-runewidth v0.0.16 github.com/maxbrunsfeld/counterfeiter/v6 v6.10.0 github.com/moby/term v0.5.0 - github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d github.com/onsi/ginkgo/v2 v2.22.0 github.com/onsi/gomega v1.36.1 github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f diff --git a/go.sum b/go.sum index cda8386fe53..4c766de928b 100644 --- a/go.sum +++ b/go.sum @@ -217,6 +217,7 @@ github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7s github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c= github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= github.com/pivotal-cf/brokerapi/v7 v7.2.0/go.mod h1:5QRQ8vJmav91F+AvY5NA/QoDOq70XgBVxXKUK4N/cNE= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= diff --git a/integration/assets/hydrabroker/app/helpers.go b/integration/assets/hydrabroker/app/helpers.go index 0ccbbb945ce..d5b680333e3 100644 --- a/integration/assets/hydrabroker/app/helpers.go +++ b/integration/assets/hydrabroker/app/helpers.go @@ -7,8 +7,8 @@ import ( "net/http" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/store" + uuid "github.com/google/uuid" "github.com/gorilla/mux" - uuid "github.com/nu7hatch/gouuid" ) func respondWithJSON(w http.ResponseWriter, data interface{}) error { @@ -41,9 +41,6 @@ func readGUIDs(r *http.Request) (requestGUIDs, error) { } func mustGUID() string { - rawGUID, err := uuid.NewV4() - if err != nil { - panic(err) - } + rawGUID := uuid.New() return rawGUID.String() } diff --git a/integration/assets/hydrabroker/database/database.go b/integration/assets/hydrabroker/database/database.go index 8ea704bfb30..e8374608149 100644 --- a/integration/assets/hydrabroker/database/database.go +++ b/integration/assets/hydrabroker/database/database.go @@ -4,7 +4,7 @@ import ( "fmt" "sync" - uuid "github.com/nu7hatch/gouuid" + uuid "github.com/google/uuid" ) type ID string @@ -15,10 +15,7 @@ type Database struct { } func NewID() ID { - rawGUID, err := uuid.NewV4() - if err != nil { - panic(err) - } + rawGUID := uuid.New() return ID(rawGUID.String()) } diff --git a/integration/assets/hydrabroker/integrationtest/integrationtest_test.go b/integration/assets/hydrabroker/integrationtest/integrationtest_test.go index db73f73c02b..5f4af8b464e 100644 --- a/integration/assets/hydrabroker/integrationtest/integrationtest_test.go +++ b/integration/assets/hydrabroker/integrationtest/integrationtest_test.go @@ -14,7 +14,7 @@ import ( "code.cloudfoundry.org/cli/integration/assets/hydrabroker/app" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources" - uuid2 "github.com/nu7hatch/gouuid" + "github.com/google/uuid" "github.com/pivotal-cf/brokerapi/v7/domain/apiresponses" ) @@ -654,9 +654,7 @@ func randomConfiguration() config.BrokerConfiguration { } func randomString() string { - uuid, err := uuid2.NewV4() - Expect(err).NotTo(HaveOccurred()) - return uuid.String() + return uuid.New().String() } func toJSON(input interface{}) io.Reader { diff --git a/integration/assets/hydrabroker/store/bindings_test.go b/integration/assets/hydrabroker/store/bindings_test.go index fe30b42ef50..9e10cc4c655 100644 --- a/integration/assets/hydrabroker/store/bindings_test.go +++ b/integration/assets/hydrabroker/store/bindings_test.go @@ -6,7 +6,7 @@ import ( "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/store" - uuid "github.com/nu7hatch/gouuid" + "github.com/google/uuid" ) var _ = Describe("Bindings", func() { @@ -17,11 +17,7 @@ var _ = Describe("Bindings", func() { ) randomID := func() store.BindingID { - rawGUID, err := uuid.NewV4() - if err != nil { - panic(err) - } - + rawGUID := uuid.New() return store.BindingID(rawGUID.String()) } diff --git a/integration/assets/hydrabroker/store/instances_test.go b/integration/assets/hydrabroker/store/instances_test.go index 0fb45a2da1f..86795816887 100644 --- a/integration/assets/hydrabroker/store/instances_test.go +++ b/integration/assets/hydrabroker/store/instances_test.go @@ -6,7 +6,7 @@ import ( "code.cloudfoundry.org/cli/integration/assets/hydrabroker/config" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources" "code.cloudfoundry.org/cli/integration/assets/hydrabroker/store" - uuid "github.com/nu7hatch/gouuid" + "github.com/google/uuid" ) var _ = Describe("Instances", func() { @@ -16,11 +16,7 @@ var _ = Describe("Instances", func() { ) randomID := func() store.InstanceID { - rawGUID, err := uuid.NewV4() - if err != nil { - panic(err) - } - + rawGUID := uuid.New() return store.InstanceID(rawGUID.String()) } diff --git a/integration/helpers/name_generator.go b/integration/helpers/name_generator.go index c6fcfeed525..ebeaefd976b 100644 --- a/integration/helpers/name_generator.go +++ b/integration/helpers/name_generator.go @@ -6,7 +6,7 @@ import ( "sort" "strings" - uuid "github.com/nu7hatch/gouuid" + "github.com/google/uuid" ) // TODO: Is this working??? @@ -162,12 +162,7 @@ func PrefixedRandomName(namePrefix string) string { // RandomName provides a random string func RandomName() string { - guid, err := uuid.NewV4() - if err != nil { - panic(err) - } - - return guid.String() + return uuid.New().String() } func RandomURL() string {