diff --git a/.golangci.yaml b/.golangci.yaml index 16e427d68..8f5d17877 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -58,6 +58,8 @@ linters: desc: use go.yaml.in/yaml/v3 instead - pkg: gopkg.in/yaml.v3 desc: use go.yaml.in/yaml/v3 instead + - pkg: github.com/gofrs/uuid + desc: use github.com/google/uuid - pkg: github.com/Masterminds/semver$ desc: use github.com/Masterminds/semver/v3 - pkg: github.com/blang/semver diff --git a/api/cmd/portainer/main.go b/api/cmd/portainer/main.go index ba28200f3..e6f176086 100644 --- a/api/cmd/portainer/main.go +++ b/api/cmd/portainer/main.go @@ -55,7 +55,7 @@ import ( "github.com/portainer/portainer/pkg/libstack/compose" "github.com/portainer/portainer/pkg/validate" - "github.com/gofrs/uuid" + "github.com/google/uuid" "github.com/rs/zerolog/log" ) @@ -119,7 +119,7 @@ func initDataStore(flags *portainer.CLIFlags, secretKey []byte, fileService port } if isNew { - instanceId, err := uuid.NewV4() + instanceId, err := uuid.NewRandom() if err != nil { log.Fatal().Err(err).Msg("failed generating instance id") } diff --git a/api/database/boltdb/json_test.go b/api/database/boltdb/json_test.go index 303a5d527..83867aebb 100644 --- a/api/database/boltdb/json_test.go +++ b/api/database/boltdb/json_test.go @@ -10,7 +10,7 @@ import ( "io" "testing" - "github.com/gofrs/uuid" + "github.com/google/uuid" "github.com/pkg/errors" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -29,7 +29,7 @@ func secretToEncryptionKey(passphrase string) []byte { func Test_MarshalObjectUnencrypted(t *testing.T) { is := assert.New(t) - uuid := uuid.Must(uuid.NewV4()) + uuid := uuid.New() tests := []struct { object any diff --git a/api/dataservices/stack/tests/stack_test.go b/api/dataservices/stack/tests/stack_test.go index 5ef8521ff..3409df951 100644 --- a/api/dataservices/stack/tests/stack_test.go +++ b/api/dataservices/stack/tests/stack_test.go @@ -8,13 +8,13 @@ import ( "github.com/portainer/portainer/api/datastore" "github.com/portainer/portainer/api/filesystem" - "github.com/gofrs/uuid" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func newGuidString(t *testing.T) string { - uuid, err := uuid.NewV4() + uuid, err := uuid.NewRandom() require.NoError(t, err) return uuid.String() diff --git a/api/filesystem/filesystem.go b/api/filesystem/filesystem.go index 7d926103c..c0674563f 100644 --- a/api/filesystem/filesystem.go +++ b/api/filesystem/filesystem.go @@ -14,7 +14,7 @@ import ( portainer "github.com/portainer/portainer/api" "github.com/portainer/portainer/api/logs" - "github.com/gofrs/uuid" + "github.com/google/uuid" "github.com/rs/zerolog/log" "github.com/segmentio/encoding/json" ) @@ -812,7 +812,7 @@ func (service *Service) getEdgeJobTaskLogPath(edgeJobID string, taskID string) s // GetTemporaryPath returns a temp folder func (service *Service) GetTemporaryPath() (string, error) { - uid, err := uuid.NewV4() + uid, err := uuid.NewRandom() if err != nil { return "", err } diff --git a/api/http/handler/endpoints/endpoint_create.go b/api/http/handler/endpoints/endpoint_create.go index 2fa39f82a..f2599f3ef 100644 --- a/api/http/handler/endpoints/endpoint_create.go +++ b/api/http/handler/endpoints/endpoint_create.go @@ -18,7 +18,7 @@ import ( "github.com/portainer/portainer/pkg/libhttp/request" "github.com/portainer/portainer/pkg/libhttp/response" - "github.com/gofrs/uuid" + "github.com/google/uuid" ) type endpointCreatePayload struct { @@ -405,7 +405,7 @@ func (handler *Handler) createEdgeAgentEndpoint(tx dataservices.DataStoreTx, pay } if settings.EnforceEdgeID { - edgeID, err := uuid.NewV4() + edgeID, err := uuid.NewRandom() if err != nil { return nil, httperror.InternalServerError("Cannot generate the Edge ID", err) } diff --git a/api/http/handler/stacks/stack_update_git_test.go b/api/http/handler/stacks/stack_update_git_test.go index 261c3d13d..beecb4402 100644 --- a/api/http/handler/stacks/stack_update_git_test.go +++ b/api/http/handler/stacks/stack_update_git_test.go @@ -13,13 +13,13 @@ import ( "github.com/portainer/portainer/api/http/security" "github.com/portainer/portainer/api/internal/testhelpers" - "github.com/gofrs/uuid" + "github.com/google/uuid" "github.com/segmentio/encoding/json" "github.com/stretchr/testify/require" ) func TestStackUpdateGitWebhookUniqueness(t *testing.T) { - webhook, err := uuid.NewV4() + webhook, err := uuid.NewRandom() require.NoError(t, err) _, store := datastore.MustNewTestStore(t, false, false) diff --git a/api/http/handler/stacks/webhook_invoke.go b/api/http/handler/stacks/webhook_invoke.go index 813f932c2..d2f9b022f 100644 --- a/api/http/handler/stacks/webhook_invoke.go +++ b/api/http/handler/stacks/webhook_invoke.go @@ -9,7 +9,7 @@ import ( "github.com/portainer/portainer/pkg/libhttp/request" "github.com/portainer/portainer/pkg/libhttp/response" - "github.com/gofrs/uuid" + "github.com/google/uuid" ) // @id WebhookInvoke @@ -56,7 +56,7 @@ func retrieveUUIDRouteVariableValue(r *http.Request, name string) (uuid.UUID, er return uuid.Nil, err } - uid, err := uuid.FromString(webhookID) + uid, err := uuid.Parse(webhookID) if err != nil { return uuid.Nil, err } diff --git a/api/http/handler/stacks/webhook_invoke_test.go b/api/http/handler/stacks/webhook_invoke_test.go index 4a7ba3456..b9dc2a290 100644 --- a/api/http/handler/stacks/webhook_invoke_test.go +++ b/api/http/handler/stacks/webhook_invoke_test.go @@ -9,7 +9,7 @@ import ( "github.com/portainer/portainer/api/datastore" "github.com/portainer/portainer/api/internal/testhelpers" - "github.com/gofrs/uuid" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -52,7 +52,7 @@ func TestHandler_webhookInvoke(t *testing.T) { } func newGuidString(t *testing.T) string { - uuid, err := uuid.NewV4() + uuid, err := uuid.NewRandom() require.NoError(t, err) return uuid.String() diff --git a/api/http/handler/webhooks/webhook_create.go b/api/http/handler/webhooks/webhook_create.go index d7edde333..86f4884a6 100644 --- a/api/http/handler/webhooks/webhook_create.go +++ b/api/http/handler/webhooks/webhook_create.go @@ -11,7 +11,7 @@ import ( "github.com/portainer/portainer/pkg/libhttp/request" "github.com/portainer/portainer/pkg/libhttp/response" - "github.com/gofrs/uuid" + "github.com/google/uuid" ) type webhookCreatePayload struct { @@ -86,7 +86,7 @@ func (handler *Handler) webhookCreate(w http.ResponseWriter, r *http.Request) *h } } - token, err := uuid.NewV4() + token, err := uuid.NewRandom() if err != nil { return httperror.InternalServerError("Error creating unique token", err) } diff --git a/api/jwt/jwt.go b/api/jwt/jwt.go index 07491c052..3fec37ee3 100644 --- a/api/jwt/jwt.go +++ b/api/jwt/jwt.go @@ -9,8 +9,8 @@ import ( "github.com/portainer/portainer/api/apikey" "github.com/portainer/portainer/api/dataservices" - "github.com/gofrs/uuid" "github.com/golang-jwt/jwt/v4" + "github.com/google/uuid" "github.com/rs/zerolog/log" ) @@ -185,7 +185,7 @@ func (service *Service) generateSignedToken(data *portainer.TokenData, expiresAt expiresAt = time.Now().Add(99 * year) } - uuid, err := uuid.NewV4() + uuid, err := uuid.NewRandom() if err != nil { return "", fmt.Errorf("unable to generate the JWT ID: %w", err) } diff --git a/go.mod b/go.mod index 84e1c075c..4515c1fc7 100644 --- a/go.mod +++ b/go.mod @@ -25,7 +25,6 @@ require ( github.com/g07cha/defender v0.0.0-20180505193036-5665c627c814 github.com/go-git/go-git/v5 v5.17.0 github.com/go-ldap/ldap/v3 v3.4.1 - github.com/gofrs/uuid v4.2.0+incompatible github.com/golang-jwt/jwt/v4 v4.5.2 github.com/google/go-cmp v0.7.0 github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index 9c1e8db1e..90a900b7b 100644 --- a/go.sum +++ b/go.sum @@ -311,8 +311,6 @@ github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJA github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= -github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= -github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=