Skip to content

Commit

Permalink
Change uuid library
Browse files Browse the repository at this point in the history
Signed-off-by: João Pereira <[email protected]>
  • Loading branch information
joaopapereira committed Nov 20, 2024
1 parent b93e526 commit 835fea3
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 55 deletions.
7 changes: 2 additions & 5 deletions cf/appfiles/app_files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down
16 changes: 6 additions & 10 deletions cf/commands/create_app_manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
)
Expand All @@ -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()
Expand Down
8 changes: 2 additions & 6 deletions command/v7/v7_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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.21.0
github.com/onsi/gomega v1.35.1
github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ 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=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
7 changes: 2 additions & 5 deletions integration/assets/hydrabroker/app/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
}
7 changes: 2 additions & 5 deletions integration/assets/hydrabroker/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"sync"

uuid "github.com/nu7hatch/gouuid"
uuid "github.com/google/uuid"
)

type ID string
Expand All @@ -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())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions integration/assets/hydrabroker/store/bindings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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())
}

Expand Down
8 changes: 2 additions & 6 deletions integration/assets/hydrabroker/store/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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())
}

Expand Down
9 changes: 2 additions & 7 deletions integration/helpers/name_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sort"
"strings"

uuid "github.com/nu7hatch/gouuid"
"github.com/google/uuid"
)

// TODO: Is this working???
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 835fea3

Please sign in to comment.