Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace unmaintained uuid library #1029

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions brokerpaktestframework/test_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"

"github.com/cloudfoundry/cloud-service-broker/v2/internal/testdrive"
"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain/apiresponses"
)

Expand Down Expand Up @@ -36,7 +36,7 @@ func (instance *TestInstance) Start(logger io.Writer, config []string) error {

func (instance *TestInstance) Catalog() (*apiresponses.CatalogResponse, error) {
resp := &apiresponses.CatalogResponse{}
catalogResponse := instance.broker.Client.Catalog(uuid.New())
catalogResponse := instance.broker.Client.Catalog(uuid.NewString())
switch {
case catalogResponse.Error != nil:
return nil, catalogResponse.Error
Expand All @@ -61,7 +61,7 @@ func (instance *TestInstance) withCatalogLookup(serviceName, planName string, cb
}

func (instance *TestInstance) Provision(serviceName string, planName string, params map[string]any) (string, error) {
instanceID := uuid.New()
instanceID := uuid.NewString()

err := instance.withCatalogLookup(serviceName, planName, func(serviceID, planID string) error {
_, err := instance.broker.Provision(serviceID, planID, testdrive.WithProvisionServiceInstanceGUID(instanceID), testdrive.WithProvisionParams(params))
Expand Down
18 changes: 9 additions & 9 deletions cmd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/cloudfoundry/cloud-service-broker/v2/pkg/featureflags"
"github.com/cloudfoundry/cloud-service-broker/v2/pkg/server"
"github.com/cloudfoundry/cloud-service-broker/v2/utils"
"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -89,35 +89,35 @@ user-defined plans.
rootCmd.AddCommand(clientCmd)

clientCatalogCmd := newClientCommand("catalog", "Show the service catalog", func(client *client.Client) *client.BrokerResponse {
return client.Catalog(uuid.New())
return client.Catalog(uuid.NewString())
})

provisionCmd := newClientCommand("provision", "Provision a service", func(client *client.Client) *client.BrokerResponse {
return client.Provision(instanceID, serviceID, planID, uuid.New(), json.RawMessage(parametersJSON))
return client.Provision(instanceID, serviceID, planID, uuid.NewString(), json.RawMessage(parametersJSON))
})

deprovisionCmd := newClientCommand("deprovision", "Deprovision a service", func(client *client.Client) *client.BrokerResponse {
return client.Deprovision(instanceID, serviceID, planID, uuid.New())
return client.Deprovision(instanceID, serviceID, planID, uuid.NewString())
})

bindCmd := newClientCommand("bind", "Bind to a service", func(client *client.Client) *client.BrokerResponse {
return client.Bind(instanceID, bindingID, serviceID, planID, uuid.New(), json.RawMessage(parametersJSON))
return client.Bind(instanceID, bindingID, serviceID, planID, uuid.NewString(), json.RawMessage(parametersJSON))
})

unbindCmd := newClientCommand("unbind", "Unbind a service", func(client *client.Client) *client.BrokerResponse {
return client.Unbind(instanceID, bindingID, serviceID, planID, uuid.New())
return client.Unbind(instanceID, bindingID, serviceID, planID, uuid.NewString())
})

lastCmd := newClientCommand("last", "Get the status of the last operation", func(client *client.Client) *client.BrokerResponse {
return client.LastOperation(instanceID, uuid.New())
return client.LastOperation(instanceID, uuid.NewString())
})

updateCmd := newClientCommand("update", "Update the instance details", func(client *client.Client) *client.BrokerResponse {
return client.Update(instanceID, serviceID, planID, uuid.New(), json.RawMessage(parametersJSON), domain.PreviousValues{}, nil)
return client.Update(instanceID, serviceID, planID, uuid.NewString(), json.RawMessage(parametersJSON), domain.PreviousValues{}, nil)
})

upgradeCmd := newClientCommand("upgrade", "Upgrade the service instance", func(c *client.Client) *client.BrokerResponse {
return c.Update(instanceID, serviceID, planID, uuid.New(), json.RawMessage("{}"),
return c.Update(instanceID, serviceID, planID, uuid.NewString(), json.RawMessage("{}"),
domain.PreviousValues{ServiceID: serviceID, PlanID: planID, MaintenanceInfo: &domain.MaintenanceInfo{Version: oldVersion}},
&domain.MaintenanceInfo{Version: newVersion})
})
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
code.cloudfoundry.org/lager/v3 v3.0.3
github.com/go-sql-driver/mysql v1.8.1
github.com/google/gops v0.3.28
github.com/google/uuid v1.4.0
github.com/hashicorp/go-getter v1.7.4
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-version v1.7.0
Expand All @@ -17,7 +18,6 @@ require (
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/otiai10/copy v1.14.0
github.com/pborman/uuid v1.2.1
github.com/pivotal-cf/brokerapi/v11 v11.0.0
github.com/russross/blackfriday/v2 v2.1.0
github.com/spf13/cast v1.6.0
Expand Down Expand Up @@ -61,7 +61,6 @@ require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand All @@ -83,6 +82,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.0 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
Expand Down
4 changes: 2 additions & 2 deletions integrationtest/integrationtest_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (

"gorm.io/gorm"

"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
"github.com/pborman/uuid"
)

func TestIntegration(t *testing.T) {
Expand Down Expand Up @@ -62,7 +62,7 @@ var _ = BeforeEach(func() {
})

func requestID() string {
return uuid.New()
return uuid.NewString()
}

func must[A any](a A, err error) A {
Expand Down
6 changes: 3 additions & 3 deletions integrationtest/subsume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/cloudfoundry/cloud-service-broker/v2/integrationtest/packer"
"github.com/cloudfoundry/cloud-service-broker/v2/internal/testdrive"

"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/pborman/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
)

Expand Down Expand Up @@ -39,8 +39,8 @@ var _ = Describe("Subsume", func() {
// This test relies on a behaviour in the random string resource where it gets re-created after being imported
const serviceOfferingGUID = "76c5725c-b246-11eb-871f-ffc97563fbd0"
const servicePlanGUID = "8b52a460-b246-11eb-a8f5-d349948e2481"
serviceInstanceGUID := uuid.New()
provisionResponse := broker.Client.Provision(serviceInstanceGUID, serviceOfferingGUID, servicePlanGUID, uuid.New(), []byte(`{"value":"thisisnotrandomatall"}`))
serviceInstanceGUID := uuid.NewString()
provisionResponse := broker.Client.Provision(serviceInstanceGUID, serviceOfferingGUID, servicePlanGUID, uuid.NewString(), []byte(`{"value":"thisisnotrandomatall"}`))
Expect(provisionResponse.Error).NotTo(HaveOccurred())
Expect(provisionResponse.StatusCode).To(Equal(http.StatusAccepted), string(provisionResponse.ResponseBody))
Expect(broker.LastOperationFinalState(serviceInstanceGUID)).To(Equal(domain.Failed))
Expand Down
18 changes: 9 additions & 9 deletions integrationtest/termination_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

"github.com/cloudfoundry/cloud-service-broker/v2/integrationtest/packer"
"github.com/cloudfoundry/cloud-service-broker/v2/internal/testdrive"
"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gbytes"
"github.com/pborman/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
)

Expand Down Expand Up @@ -41,8 +41,8 @@ var _ = Describe("Recovery From Broker Termination", func() {

It("can recover from a terminated create", func() {
By("starting to provision")
instanceGUID := uuid.New()
response := broker.Client.Provision(instanceGUID, serviceOfferingGUID, servicePlanGUID, uuid.New(), nil)
instanceGUID := uuid.NewString()
response := broker.Client.Provision(instanceGUID, serviceOfferingGUID, servicePlanGUID, uuid.NewString(), nil)
Expect(response.Error).NotTo(HaveOccurred())
Expect(response.StatusCode).To(Equal(http.StatusAccepted))

Expand All @@ -62,12 +62,12 @@ var _ = Describe("Recovery From Broker Termination", func() {

// OSBAPI requires that HTTP 409 (Conflict) is returned
By("refusing to allow a duplicate instance")
response = broker.Client.Provision(instanceGUID, serviceOfferingGUID, servicePlanGUID, uuid.New(), nil)
response = broker.Client.Provision(instanceGUID, serviceOfferingGUID, servicePlanGUID, uuid.NewString(), nil)
Expect(response.Error).NotTo(HaveOccurred())
Expect(response.StatusCode).To(Equal(http.StatusConflict))

By("allowing the instance to be cleaned up")
response = broker.Client.Deprovision(instanceGUID, serviceOfferingGUID, servicePlanGUID, uuid.New())
response = broker.Client.Deprovision(instanceGUID, serviceOfferingGUID, servicePlanGUID, uuid.NewString())
Expect(response.Error).NotTo(HaveOccurred())
Expect(response.StatusCode).To(Equal(http.StatusOK))
})
Expand All @@ -78,7 +78,7 @@ var _ = Describe("Recovery From Broker Termination", func() {
Expect(err).NotTo(HaveOccurred())

By("starting to update")
response := broker.Client.Update(instance.GUID, serviceOfferingGUID, servicePlanGUID, uuid.New(), nil, domain.PreviousValues{}, nil)
response := broker.Client.Update(instance.GUID, serviceOfferingGUID, servicePlanGUID, uuid.NewString(), nil, domain.PreviousValues{}, nil)
Expect(response.Error).NotTo(HaveOccurred())
Expect(response.StatusCode).To(Equal(http.StatusAccepted))

Expand Down Expand Up @@ -106,7 +106,7 @@ var _ = Describe("Recovery From Broker Termination", func() {
Expect(err).NotTo(HaveOccurred())

By("starting to delete")
response := broker.Client.Deprovision(instance.GUID, serviceOfferingGUID, servicePlanGUID, uuid.New())
response := broker.Client.Deprovision(instance.GUID, serviceOfferingGUID, servicePlanGUID, uuid.NewString())
Expect(response.Error).NotTo(HaveOccurred())
Expect(response.StatusCode).To(Equal(http.StatusAccepted))

Expand Down Expand Up @@ -134,7 +134,7 @@ var _ = Describe("Recovery From Broker Termination", func() {
Expect(err).NotTo(HaveOccurred())

By("starting to bind")
bindingGUID := uuid.New()
bindingGUID := uuid.NewString()
go broker.CreateBinding(instance, testdrive.WithBindingGUID(bindingGUID))

Eventually(stdout).Should(Say(fmt.Sprintf(`"cloud-service-broker.Binding".*"binding_id":"%s"`, bindingGUID)))
Expand All @@ -153,7 +153,7 @@ var _ = Describe("Recovery From Broker Termination", func() {
instance, err := broker.Provision(serviceOfferingGUID, servicePlanGUID)
Expect(err).NotTo(HaveOccurred())

bindingGUID := uuid.New()
bindingGUID := uuid.NewString()
_, err = broker.CreateBinding(instance, testdrive.WithBindingGUID(bindingGUID))
Expect(err).NotTo(HaveOccurred())

Expand Down
4 changes: 2 additions & 2 deletions internal/local/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"net/http"

"github.com/cloudfoundry/cloud-service-broker/v2/pkg/client"
"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
)

func catalog(clnt *client.Client) []domain.Service {
catalogResponse := clnt.Catalog(uuid.New())
catalogResponse := clnt.Catalog(uuid.NewString())
switch {
case catalogResponse.Error != nil:
log.Fatal(catalogResponse.Error)
Expand Down
6 changes: 3 additions & 3 deletions internal/testdrive/broker_create_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"

"github.com/cloudfoundry/cloud-service-broker/v2/pkg/client"
"github.com/pborman/uuid"
"github.com/google/uuid"
)

type ServiceBinding struct {
Expand All @@ -23,7 +23,7 @@ type CreateBindingOption func(*createBindingConfig) error
func (b *Broker) CreateBinding(s ServiceInstance, opts ...CreateBindingOption) (ServiceBinding, error) {
var bindResponse *client.BrokerResponse
cfg := createBindingConfig{
guid: uuid.New(),
guid: uuid.NewString(),
}

for _, o := range opts {
Expand All @@ -32,7 +32,7 @@ func (b *Broker) CreateBinding(s ServiceInstance, opts ...CreateBindingOption) (
}
}

bindResponse = b.Client.Bind(s.GUID, cfg.guid, s.ServiceOfferingGUID, s.ServicePlanGUID, uuid.New(), cfg.params)
bindResponse = b.Client.Bind(s.GUID, cfg.guid, s.ServiceOfferingGUID, s.ServicePlanGUID, uuid.NewString(), cfg.params)
switch {
case bindResponse.Error != nil:
return ServiceBinding{GUID: cfg.guid}, bindResponse.Error
Expand Down
4 changes: 2 additions & 2 deletions internal/testdrive/broker_delete_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package testdrive
import (
"net/http"

"github.com/pborman/uuid"
"github.com/google/uuid"
)

func (b *Broker) DeleteBinding(s ServiceInstance, serviceBindingGUID string) error {
unbindResponse := b.Client.Unbind(s.GUID, serviceBindingGUID, s.ServiceOfferingGUID, s.ServicePlanGUID, uuid.New())
unbindResponse := b.Client.Unbind(s.GUID, serviceBindingGUID, s.ServiceOfferingGUID, s.ServicePlanGUID, uuid.NewString())
switch {
case unbindResponse.Error != nil:
return unbindResponse.Error
Expand Down
4 changes: 2 additions & 2 deletions internal/testdrive/broker_deprovision.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"fmt"
"net/http"

"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
)

func (b *Broker) Deprovision(s ServiceInstance) error {
deprovisionResponse := b.Client.Deprovision(s.GUID, s.ServiceOfferingGUID, s.ServicePlanGUID, uuid.New())
deprovisionResponse := b.Client.Deprovision(s.GUID, s.ServiceOfferingGUID, s.ServicePlanGUID, uuid.NewString())
switch {
case deprovisionResponse.Error != nil:
return deprovisionResponse.Error
Expand Down
4 changes: 2 additions & 2 deletions internal/testdrive/broker_last_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"net/http"
"time"

"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
)

func (b *Broker) LastOperation(serviceInstanceGUID string) (domain.LastOperation, error) {
lastOperationResponse := b.Client.LastOperation(serviceInstanceGUID, uuid.New())
lastOperationResponse := b.Client.LastOperation(serviceInstanceGUID, uuid.NewString())
switch {
case lastOperationResponse.Error != nil:
return domain.LastOperation{}, lastOperationResponse.Error
Expand Down
6 changes: 3 additions & 3 deletions internal/testdrive/broker_provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"

"github.com/cloudfoundry/cloud-service-broker/v2/internal/steps"
"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
)

Expand All @@ -24,7 +24,7 @@ type provisionConfig struct {
type ProvisionOption func(*provisionConfig) error

func (b *Broker) Provision(serviceOfferingGUID, servicePlanGUID string, opts ...ProvisionOption) (ServiceInstance, error) {
cfg := provisionConfig{guid: uuid.New()}
cfg := provisionConfig{guid: uuid.NewString()}
for _, o := range opts {
if err := o(&cfg); err != nil {
return ServiceInstance{}, err
Expand All @@ -33,7 +33,7 @@ func (b *Broker) Provision(serviceOfferingGUID, servicePlanGUID string, opts ...

err := steps.RunSequentially(
func() error {
provisionResponse := b.Client.Provision(cfg.guid, serviceOfferingGUID, servicePlanGUID, uuid.New(), cfg.params)
provisionResponse := b.Client.Provision(cfg.guid, serviceOfferingGUID, servicePlanGUID, uuid.NewString(), cfg.params)
switch {
case provisionResponse.Error != nil:
return provisionResponse.Error
Expand Down
6 changes: 3 additions & 3 deletions internal/testdrive/broker_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/cloudfoundry/cloud-service-broker/v2/pkg/client"
"github.com/cloudfoundry/cloud-service-broker/v2/utils/freeport"
"github.com/pborman/uuid"
"github.com/google/uuid"
)

type StartBrokerOption func(config *startBrokerConfig)
Expand All @@ -36,8 +36,8 @@ func StartBroker(csbPath, bpk, db string, opts ...StartBrokerOption) (*Broker, e
return nil, err
}

username := uuid.New()
password := uuid.New()
username := uuid.NewString()
password := uuid.NewString()

cmd := exec.Command(csbPath, "serve")
cmd.Dir = bpk
Expand Down
4 changes: 2 additions & 2 deletions internal/testdrive/broker_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"

"github.com/cloudfoundry/cloud-service-broker/v2/internal/steps"
"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
)

Expand All @@ -31,7 +31,7 @@ func (b *Broker) UpdateService(s ServiceInstance, opts ...UpdateOption) error {

return steps.RunSequentially(
func() error {
updateResponse := b.Client.Update(s.GUID, s.ServiceOfferingGUID, cfg.servicePlanGUID, uuid.New(), cfg.params, cfg.previousValues, cfg.maintenanceInfo)
updateResponse := b.Client.Update(s.GUID, s.ServiceOfferingGUID, cfg.servicePlanGUID, uuid.NewString(), cfg.params, cfg.previousValues, cfg.maintenanceInfo)
switch {
case updateResponse.Error != nil:
return updateResponse.Error
Expand Down
4 changes: 2 additions & 2 deletions internal/testdrive/broker_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"

"github.com/cloudfoundry/cloud-service-broker/v2/internal/steps"
"github.com/pborman/uuid"
"github.com/google/uuid"
"github.com/pivotal-cf/brokerapi/v11/domain"
)

Expand All @@ -29,7 +29,7 @@ func (b *Broker) UpgradeService(s ServiceInstance, version string, opts ...Upgra

return steps.RunSequentially(
func() error {
updateResponse := b.Client.Update(s.GUID, s.ServiceOfferingGUID, s.ServicePlanGUID, uuid.New(), cfg.params, cfg.previousValues, &maintenanceInfo)
updateResponse := b.Client.Update(s.GUID, s.ServiceOfferingGUID, s.ServicePlanGUID, uuid.NewString(), cfg.params, cfg.previousValues, &maintenanceInfo)
switch {
case updateResponse.Error != nil:
return updateResponse.Error
Expand Down
Loading
Loading