Skip to content

Commit

Permalink
Replace github.com/pborman/uuid with github.com/google/uuid (#7173)
Browse files Browse the repository at this point in the history
* Replace `github.com/pborman/uuid` with `github.com/google/uuid`

`github.com/pborman/uuid` is no longer being actively maintained (last
release was 2019). So we should just use the newer
`github.com/google/uuid`.

Signed-off-by: Eng Zer Jun <[email protected]>

* fix: handle error and convert to string properly

Reference: #7173 (review)
Co-authored-by: Armel Soro <[email protected]>
Signed-off-by: Eng Zer Jun <[email protected]>

---------

Signed-off-by: Eng Zer Jun <[email protected]>
Co-authored-by: Armel Soro <[email protected]>
  • Loading branch information
Juneezee and rm3l authored Jan 22, 2024
1 parent e72cca7 commit 943490b
Show file tree
Hide file tree
Showing 20 changed files with 12 additions and 729 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
github.com/go-openapi/spec v0.20.8
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.3.1
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.0
github.com/jedib0t/go-pretty/v6 v6.4.7
Expand All @@ -40,7 +41,6 @@ require (
github.com/openshift/oc v0.0.0-alpha.0.0.20220402064836-f1f09a392fd1
github.com/operator-framework/api v0.17.7
github.com/operator-framework/operator-lifecycle-manager v0.21.2
github.com/pborman/uuid v1.2.1
github.com/posener/complete v1.2.3
github.com/redhat-developer/service-binding-operator v1.0.1-0.20211222115357-5b7bbba3bfb3
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
Expand Down Expand Up @@ -133,7 +133,6 @@ require (
github.com/google/licensecheck v0.3.1 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 11 additions & 6 deletions pkg/segment/segment.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package segment

import (
"bytes"
"context"
"errors"
"fmt"
Expand All @@ -18,7 +19,7 @@ import (
"github.com/redhat-developer/odo/pkg/config"
scontext "github.com/redhat-developer/odo/pkg/segment/context"

"github.com/pborman/uuid"
"github.com/google/uuid"
"golang.org/x/term"
"gopkg.in/segmentio/analytics-go.v3"
"k8s.io/klog"
Expand Down Expand Up @@ -214,14 +215,18 @@ func GetUserIdentity(telemetryFilePath string) (string, error) {
}
}

// check if the id is a valid uuid, if not, nil is returned
if uuid.Parse(strings.TrimSpace(string(id))) == nil {
id = []byte(uuid.NewRandom().String())
if err := os.WriteFile(telemetryFilePath, id, 0600); err != nil {
// check if the id is a valid uuid, if not, generates a new one and writes to file
if _, err := uuid.ParseBytes(bytes.TrimSpace(id)); err != nil {
u, uErr := uuid.NewRandom()
if uErr != nil {
return "", fmt.Errorf("failed to generate anonymous ID for telemetry: %w", uErr)
}
id = []byte(u.String())
if err := os.WriteFile(telemetryFilePath, id, 0o600); err != nil {
return "", err
}
}
return strings.TrimSpace(string(id)), nil
return string(bytes.TrimSpace(id)), nil
}

// SetError sanitizes any PII(Personally Identifiable Information) from the error
Expand Down
10 changes: 0 additions & 10 deletions vendor/github.com/pborman/uuid/.travis.yml

This file was deleted.

10 changes: 0 additions & 10 deletions vendor/github.com/pborman/uuid/CONTRIBUTING.md

This file was deleted.

1 change: 0 additions & 1 deletion vendor/github.com/pborman/uuid/CONTRIBUTORS

This file was deleted.

27 changes: 0 additions & 27 deletions vendor/github.com/pborman/uuid/LICENSE

This file was deleted.

15 changes: 0 additions & 15 deletions vendor/github.com/pborman/uuid/README.md

This file was deleted.

84 changes: 0 additions & 84 deletions vendor/github.com/pborman/uuid/dce.go

This file was deleted.

13 changes: 0 additions & 13 deletions vendor/github.com/pborman/uuid/doc.go

This file was deleted.

53 changes: 0 additions & 53 deletions vendor/github.com/pborman/uuid/hash.go

This file was deleted.

85 changes: 0 additions & 85 deletions vendor/github.com/pborman/uuid/marshal.go

This file was deleted.

Loading

0 comments on commit 943490b

Please sign in to comment.