Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1bbabd8

Browse files
committedJan 10, 2025·
Change uuid library
Signed-off-by: João Pereira <[email protected]>
1 parent 520fb4d commit 1bbabd8

File tree

11 files changed

+24
-55
lines changed

11 files changed

+24
-55
lines changed
 

‎cf/appfiles/app_files_test.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import (
88
"strings"
99

1010
"code.cloudfoundry.org/cli/cf/appfiles"
11-
uuid "github.com/nu7hatch/gouuid"
12-
1311
"code.cloudfoundry.org/cli/cf/models"
1412
"code.cloudfoundry.org/gofileutils/fileutils"
13+
"github.com/google/uuid"
1514

1615
. "github.com/onsi/ginkgo/v2"
1716
. "github.com/onsi/gomega"
@@ -215,9 +214,7 @@ var _ = Describe("AppFiles", func() {
215214
tmpDir, err = ioutil.TempDir("", "untraversable-test")
216215
Expect(err).NotTo(HaveOccurred())
217216

218-
guid, err := uuid.NewV4()
219-
Expect(err).NotTo(HaveOccurred())
220-
217+
guid := uuid.New()
221218
untraversableDirName = guid.String()
222219
untraversableDirPath := filepath.Join(tmpDir, untraversableDirName)
223220

‎cf/commands/create_app_manifest_test.go

+6-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ package commands_test
33
import (
44
"errors"
55
"fmt"
6+
"os"
67

8+
"code.cloudfoundry.org/cli/cf/api/apifakes"
9+
"code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes"
710
"code.cloudfoundry.org/cli/cf/commandregistry"
811
"code.cloudfoundry.org/cli/cf/commands"
912
"code.cloudfoundry.org/cli/cf/configuration/coreconfig"
@@ -12,16 +15,10 @@ import (
1215
"code.cloudfoundry.org/cli/cf/models"
1316
"code.cloudfoundry.org/cli/cf/requirements"
1417
"code.cloudfoundry.org/cli/cf/requirements/requirementsfakes"
15-
16-
"code.cloudfoundry.org/cli/cf/api/apifakes"
17-
"code.cloudfoundry.org/cli/cf/api/stacks/stacksfakes"
1818
testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration"
19-
testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal"
20-
21-
"os"
22-
2319
. "code.cloudfoundry.org/cli/cf/util/testhelpers/matchers"
24-
uuid "github.com/nu7hatch/gouuid"
20+
testterm "code.cloudfoundry.org/cli/cf/util/testhelpers/terminal"
21+
uuid "github.com/google/uuid"
2522
. "github.com/onsi/ginkgo/v2"
2623
. "github.com/onsi/gomega"
2724
)
@@ -47,8 +44,7 @@ var _ = Describe("CreateAppManifest", func() {
4744
)
4845

4946
BeforeEach(func() {
50-
rand, err := uuid.NewV4()
51-
Expect(err).ToNot(HaveOccurred())
47+
rand := uuid.New()
5248
appName = fmt.Sprintf("app-name-%s", rand)
5349
ui = &testterm.FakeUI{}
5450
configRepo = testconfig.NewRepositoryWithDefaults()

‎command/v7/v7_suite_test.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strings"
77
"testing"
88

9-
uuid "github.com/nu7hatch/gouuid"
9+
uuid "github.com/google/uuid"
1010
. "github.com/onsi/ginkgo/v2"
1111
. "github.com/onsi/gomega"
1212
log "github.com/sirupsen/logrus"
@@ -23,11 +23,7 @@ var _ = BeforeEach(func() {
2323

2424
// RandomString provides a random string
2525
func RandomString(prefix string) string {
26-
guid, err := uuid.NewV4()
27-
if err != nil {
28-
panic(err)
29-
}
30-
26+
guid := uuid.New()
3127
return prefix + "-" + guid.String()
3228
}
3329

‎go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ require (
2525
github.com/distribution/reference v0.6.0
2626
github.com/fatih/color v1.18.0
2727
github.com/google/go-querystring v1.1.0
28+
github.com/google/uuid v1.6.0
2829
github.com/jessevdk/go-flags v1.6.1
2930
github.com/lunixbochs/vtclean v1.0.0
3031
github.com/mattn/go-colorable v0.1.13
3132
github.com/mattn/go-runewidth v0.0.16
3233
github.com/maxbrunsfeld/counterfeiter/v6 v6.10.0
3334
github.com/moby/term v0.5.0
34-
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d
3535
github.com/onsi/ginkgo/v2 v2.22.0
3636
github.com/onsi/gomega v1.36.1
3737
github.com/sabhiram/go-gitignore v0.0.0-20171017070213-362f9845770f

‎go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ github.com/openzipkin/zipkin-go v0.4.3 h1:9EGwpqkgnwdEIJ+Od7QVSEIH+ocmm5nPat0G7s
217217
github.com/openzipkin/zipkin-go v0.4.3/go.mod h1:M9wCJZFWCo2RiY+o1eBCEMe0Dp2S5LDHcMZmk3RmK7c=
218218
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34=
219219
github.com/pivotal-cf/brokerapi/v7 v7.2.0/go.mod h1:5QRQ8vJmav91F+AvY5NA/QoDOq70XgBVxXKUK4N/cNE=
220+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
220221
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
221222
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
222223
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=

‎integration/assets/hydrabroker/app/helpers.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"net/http"
88

99
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/store"
10+
uuid "github.com/google/uuid"
1011
"github.com/gorilla/mux"
11-
uuid "github.com/nu7hatch/gouuid"
1212
)
1313

1414
func respondWithJSON(w http.ResponseWriter, data interface{}) error {
@@ -41,9 +41,6 @@ func readGUIDs(r *http.Request) (requestGUIDs, error) {
4141
}
4242

4343
func mustGUID() string {
44-
rawGUID, err := uuid.NewV4()
45-
if err != nil {
46-
panic(err)
47-
}
44+
rawGUID := uuid.New()
4845
return rawGUID.String()
4946
}

‎integration/assets/hydrabroker/database/database.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"sync"
66

7-
uuid "github.com/nu7hatch/gouuid"
7+
uuid "github.com/google/uuid"
88
)
99

1010
type ID string
@@ -15,10 +15,7 @@ type Database struct {
1515
}
1616

1717
func NewID() ID {
18-
rawGUID, err := uuid.NewV4()
19-
if err != nil {
20-
panic(err)
21-
}
18+
rawGUID := uuid.New()
2219

2320
return ID(rawGUID.String())
2421
}

‎integration/assets/hydrabroker/integrationtest/integrationtest_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/app"
1515
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/config"
1616
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources"
17-
uuid2 "github.com/nu7hatch/gouuid"
17+
"github.com/google/uuid"
1818
"github.com/pivotal-cf/brokerapi/v7/domain/apiresponses"
1919
)
2020

@@ -654,9 +654,7 @@ func randomConfiguration() config.BrokerConfiguration {
654654
}
655655

656656
func randomString() string {
657-
uuid, err := uuid2.NewV4()
658-
Expect(err).NotTo(HaveOccurred())
659-
return uuid.String()
657+
return uuid.New().String()
660658
}
661659

662660
func toJSON(input interface{}) io.Reader {

‎integration/assets/hydrabroker/store/bindings_test.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/config"
77
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources"
88
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/store"
9-
uuid "github.com/nu7hatch/gouuid"
9+
"github.com/google/uuid"
1010
)
1111

1212
var _ = Describe("Bindings", func() {
@@ -17,11 +17,7 @@ var _ = Describe("Bindings", func() {
1717
)
1818

1919
randomID := func() store.BindingID {
20-
rawGUID, err := uuid.NewV4()
21-
if err != nil {
22-
panic(err)
23-
}
24-
20+
rawGUID := uuid.New()
2521
return store.BindingID(rawGUID.String())
2622
}
2723

‎integration/assets/hydrabroker/store/instances_test.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/config"
77
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/resources"
88
"code.cloudfoundry.org/cli/integration/assets/hydrabroker/store"
9-
uuid "github.com/nu7hatch/gouuid"
9+
"github.com/google/uuid"
1010
)
1111

1212
var _ = Describe("Instances", func() {
@@ -16,11 +16,7 @@ var _ = Describe("Instances", func() {
1616
)
1717

1818
randomID := func() store.InstanceID {
19-
rawGUID, err := uuid.NewV4()
20-
if err != nil {
21-
panic(err)
22-
}
23-
19+
rawGUID := uuid.New()
2420
return store.InstanceID(rawGUID.String())
2521
}
2622

‎integration/helpers/name_generator.go

+2-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"sort"
77
"strings"
88

9-
uuid "github.com/nu7hatch/gouuid"
9+
"github.com/google/uuid"
1010
)
1111

1212
// TODO: Is this working???
@@ -162,12 +162,7 @@ func PrefixedRandomName(namePrefix string) string {
162162

163163
// RandomName provides a random string
164164
func RandomName() string {
165-
guid, err := uuid.NewV4()
166-
if err != nil {
167-
panic(err)
168-
}
169-
170-
return guid.String()
165+
return uuid.New().String()
171166
}
172167

173168
func RandomURL() string {

0 commit comments

Comments
 (0)
Please sign in to comment.