Skip to content

Commit

Permalink
refactor: bump github.com/gofrs/uuid to current major version (#5120)
Browse files Browse the repository at this point in the history
* refactor: bump github.com/gofrs/uuid to current major version

consistently use one uuid library

* lint: run go mod tidy
  • Loading branch information
kruskall authored Jul 22, 2024
1 parent 4d074b9 commit 10d8e04
Show file tree
Hide file tree
Showing 28 changed files with 110 additions and 138 deletions.
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ linters-settings:
- errors
- fmt
reason: "This package is deprecated, use `fmt.Errorf` with `%w` instead"
- github.com/google/uuid:
# Recommended modules that should be used instead. (Optional)
recommendations:
- github.com/gofrs/uuid/v5
reason: "Use one uuid library consistently across the codebase"

gomoddirectives:
# Forbid local `replace` directives
Expand Down
110 changes: 40 additions & 70 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2951,12 +2951,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : github.com/gofrs/uuid
Version: v4.4.0+incompatible
Dependency : github.com/gofrs/uuid/v5
Version: v5.2.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid@v4.4.0+incompatible/LICENSE:
Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/[email protected]/LICENSE:

Copyright (C) 2013-2018 by Maxim Bublis <[email protected]>

Expand Down Expand Up @@ -3229,43 +3229,6 @@ Contents of probable licence file $GOMODCACHE/github.com/google/[email protected]
limitations under the License.


--------------------------------------------------------------------------------
Dependency : github.com/google/uuid
Version: v1.6.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/google/[email protected]/LICENSE:

Copyright (c) 2009,2014 Google Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : github.com/gorilla/mux
Version: v1.8.0
Expand Down Expand Up @@ -22868,36 +22831,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/gofrs/uuid/v5
Version: v5.2.0
Licence type (autodetected): MIT
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/[email protected]/LICENSE:

Copyright (C) 2013-2018 by Maxim Bublis <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


--------------------------------------------------------------------------------
Dependency : github.com/gogo/protobuf
Version: v1.3.2
Expand Down Expand Up @@ -24493,6 +24426,43 @@ Contents of probable licence file $GOMODCACHE/github.com/google/[email protected]
limitations under the License.


--------------------------------------------------------------------------------
Dependency : github.com/google/uuid
Version: v1.6.0
Licence type (autodetected): BSD-3-Clause
--------------------------------------------------------------------------------

Contents of probable licence file $GOMODCACHE/github.com/google/[email protected]/LICENSE:

Copyright (c) 2009,2014 Google Inc. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


--------------------------------------------------------------------------------
Dependency : github.com/gorilla/websocket
Version: v1.5.0
Expand Down
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ require (
github.com/fatih/color v1.16.0
github.com/fsnotify/fsnotify v1.7.0
github.com/gofrs/flock v0.8.1
github.com/gofrs/uuid v4.4.0+incompatible
github.com/gofrs/uuid/v5 v5.2.0
github.com/google/go-cmp v0.6.0
github.com/google/pprof v0.0.0-20230426061923-93006964c1fc
github.com/google/uuid v1.6.0
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-multierror v1.1.1
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95
Expand Down Expand Up @@ -172,7 +171,6 @@ require (
github.com/gobuffalo/here v0.6.7 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/goccy/go-json v0.10.3 // indirect
github.com/gofrs/uuid/v5 v5.2.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
Expand All @@ -182,6 +180,7 @@ require (
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/consul/api v1.29.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,6 @@ github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PU
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM=
github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/agent/application/info/agent_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"io"
"time"

"github.com/gofrs/uuid"
"github.com/gofrs/uuid/v5"
"gopkg.in/yaml.v2"

"github.com/elastic/elastic-agent/internal/pkg/agent/application/filelock"
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/runtime/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"sync/atomic"
"time"

"github.com/gofrs/uuid"
"github.com/gofrs/uuid/v5"
"go.elastic.co/apm/module/apmgrpc/v2"
"go.elastic.co/apm/v2"
"google.golang.org/grpc"
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/runtime/manager_fake_input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
fakecmp "github.com/elastic/elastic-agent/pkg/component/fake/component/comp"
"github.com/elastic/elastic-agent/pkg/core/logger"

"github.com/gofrs/uuid"
"github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/runtime/runtime_comm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"google.golang.org/grpc/status"
protobuf "google.golang.org/protobuf/proto"

"github.com/gofrs/uuid"
"github.com/gofrs/uuid/v5"

"github.com/elastic/elastic-agent-client/v7/pkg/client"
"github.com/elastic/elastic-agent-client/v7/pkg/client/chunk"
Expand Down
4 changes: 2 additions & 2 deletions pkg/testing/tools/estools/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strconv"
"strings"

"github.com/google/uuid"
"github.com/gofrs/uuid/v5"

"github.com/elastic/elastic-agent-libs/mapstr"
"github.com/elastic/elastic-transport-go/v8/elastictransport"
Expand Down Expand Up @@ -207,7 +207,7 @@ func CreateServiceToken(ctx context.Context, client elastictransport.Interface,
req := esapi.SecurityCreateServiceTokenRequest{
Namespace: "elastic",
Service: service,
Name: uuid.New().String(), // FIXME(michel-laterman): We need to specify a random name until an upstream issue is fixed: https://github.com/elastic/go-elasticsearch/issues/861
Name: uuid.Must(uuid.NewV4()).String(), // FIXME(michel-laterman): We need to specify a random name until an upstream issue is fixed: https://github.com/elastic/go-elasticsearch/issues/861
}
resp, err := req.Do(ctx, client)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/testing/tools/fleettools/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"os"
"strings"

"github.com/google/uuid"
"github.com/gofrs/uuid/v5"

"github.com/elastic/elastic-agent-libs/kibana"
)
Expand Down Expand Up @@ -157,7 +157,7 @@ func DefaultURL(ctx context.Context, client *kibana.Client) (string, error) {
// an enrollment token and returns an EnrollParams with the information to enroll
// an agent. If an error happens, it returns nil and a non-nil error.
func NewEnrollParams(ctx context.Context, client *kibana.Client) (*EnrollParams, error) {
policyUUID := uuid.New().String()
policyUUID := uuid.Must(uuid.NewV4()).String()
policy := kibana.AgentPolicy{
Name: "test-policy-" + policyUUID,
Namespace: "default",
Expand Down
4 changes: 2 additions & 2 deletions testing/fleetservertest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strconv"
"sync"

"github.com/google/uuid"
"github.com/gofrs/uuid/v5"
"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -121,7 +121,7 @@ func NewRouter(handlers *Handlers) *mux.Router {

ww := &statusResponseWriter{w: w}

requestID := uuid.New().String()
requestID := uuid.Must(uuid.NewV4()).String()
handlers.logFn("[%s] STARTING - %s %s %s %s\n",
requestID, r.Method, r.URL, r.Proto, r.RemoteAddr)
route.Handler.
Expand Down
8 changes: 4 additions & 4 deletions testing/integration/agent_long_running_leak_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"
"time"

"github.com/google/uuid"
"github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -96,7 +96,7 @@ func (runner *ExtendedRunner) SetupSuite() {
out, err = cmd.CombinedOutput()
require.NoError(runner.T(), err, "got out: %s", string(out))

policyUUID := uuid.New().String()
policyUUID := uuid.Must(uuid.NewV4()).String()
installOpts := atesting.InstallOpts{
NonInteractive: true,
Force: true,
Expand All @@ -120,10 +120,10 @@ func (runner *ExtendedRunner) SetupSuite() {
policyResp, err := tools.InstallAgentWithPolicy(ctx, runner.T(), installOpts, runner.agentFixture, runner.info.KibanaClient, basePolicy)
require.NoError(runner.T(), err)

_, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "agent_long_test_base_system_integ.json", uuid.New().String(), policyResp.ID)
_, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "agent_long_test_base_system_integ.json", uuid.Must(uuid.NewV4()).String(), policyResp.ID)
require.NoError(runner.T(), err)

_, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "apache", "1.17.0", "agent_long_test_apache.json", uuid.New().String(), policyResp.ID)
_, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "apache", "1.17.0", "agent_long_test_apache.json", uuid.Must(uuid.NewV4()).String(), policyResp.ID)
require.NoError(runner.T(), err)

}
Expand Down
2 changes: 1 addition & 1 deletion testing/integration/beats_serverless_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"text/template"
"time"

"github.com/gofrs/uuid"
"github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
10 changes: 5 additions & 5 deletions testing/integration/container_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"text/template"
"time"

"github.com/google/uuid"
"github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -155,7 +155,7 @@ func TestContainerCMD(t *testing.T) {
ctx,
agentFixture,
info,
fmt.Sprintf("%s-%s", t.Name(), uuid.New().String()),
fmt.Sprintf("%s-%s", t.Name(), uuid.Must(uuid.NewV4()).String()),
"")
env := []string{
"FLEET_ENROLL=1",
Expand Down Expand Up @@ -242,7 +242,7 @@ func TestContainerCMDWithAVeryLongStatePath(t *testing.T) {
ctx,
agentFixture,
info,
fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()),
"")

env := []string{
Expand Down Expand Up @@ -333,7 +333,7 @@ func TestContainerCMDEventToStderr(t *testing.T) {
ctx,
agentFixture,
info,
fmt.Sprintf("%s-%s", t.Name(), uuid.New().String()),
fmt.Sprintf("%s-%s", t.Name(), uuid.Must(uuid.NewV4()).String()),
outputID)

fleetURL, err := fleettools.DefaultURL(ctx, info.KibanaClient)
Expand Down Expand Up @@ -403,7 +403,7 @@ func createMockESOutput(t *testing.T, info *define.Info) (string, string) {
`
// The API will return an error if the output ID/name contains an
// UUID substring, so we replace the '-' by '_' to keep the API happy.
outputUUID := strings.Replace(uuid.New().String(), "-", "_", -1)
outputUUID := strings.Replace(uuid.Must(uuid.NewV4()).String(), "-", "_", -1)
bodyStr := fmt.Sprintf(createOutputBody, outputUUID, mockesURL)
bodyReader := strings.NewReader(bodyStr)
// THE URL IS MISSING
Expand Down
6 changes: 3 additions & 3 deletions testing/integration/delay_enroll_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"testing"
"time"

"github.com/google/uuid"
"github.com/gofrs/uuid/v5"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent-libs/kibana"
Expand Down Expand Up @@ -44,7 +44,7 @@ func TestDelayEnroll(t *testing.T) {
// name. This policy does not contain any integration.
t.Log("Enrolling agent in Fleet with a test policy")
createPolicyReq := kibana.AgentPolicy{
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()),
Namespace: info.Namespace,
Description: "test policy for agent enrollment",
MonitoringEnabled: []kibana.MonitoringEnabledOption{
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestDelayEnrollUnprivileged(t *testing.T) {
// name. This policy does not contain any integration.
t.Log("Enrolling agent in Fleet with a test policy")
createPolicyReq := kibana.AgentPolicy{
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()),
Namespace: info.Namespace,
Description: "test policy for agent enrollment",
MonitoringEnabled: []kibana.MonitoringEnabledOption{
Expand Down
Loading

0 comments on commit 10d8e04

Please sign in to comment.