Skip to content

Commit 10d8e04

Browse files
authored
refactor: bump github.com/gofrs/uuid to current major version (elastic#5120)
* refactor: bump github.com/gofrs/uuid to current major version consistently use one uuid library * lint: run go mod tidy
1 parent 4d074b9 commit 10d8e04

28 files changed

+110
-138
lines changed

.golangci.yml

+5
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ linters-settings:
9999
- errors
100100
- fmt
101101
reason: "This package is deprecated, use `fmt.Errorf` with `%w` instead"
102+
- github.com/google/uuid:
103+
# Recommended modules that should be used instead. (Optional)
104+
recommendations:
105+
- github.com/gofrs/uuid/v5
106+
reason: "Use one uuid library consistently across the codebase"
102107

103108
gomoddirectives:
104109
# Forbid local `replace` directives

NOTICE.txt

+40-70
Original file line numberDiff line numberDiff line change
@@ -2951,12 +2951,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29512951

29522952

29532953
--------------------------------------------------------------------------------
2954-
Dependency : github.com/gofrs/uuid
2955-
Version: v4.4.0+incompatible
2954+
Dependency : github.com/gofrs/uuid/v5
2955+
Version: v5.2.0
29562956
Licence type (autodetected): MIT
29572957
--------------------------------------------------------------------------------
29582958

2959-
Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid@v4.4.0+incompatible/LICENSE:
2959+
Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/v5@v5.2.0/LICENSE:
29602960

29612961
Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
29622962

@@ -3229,43 +3229,6 @@ Contents of probable licence file $GOMODCACHE/github.com/google/pprof@v0.0.0-202
32293229
limitations under the License.
32303230

32313231

3232-
--------------------------------------------------------------------------------
3233-
Dependency : github.com/google/uuid
3234-
Version: v1.6.0
3235-
Licence type (autodetected): BSD-3-Clause
3236-
--------------------------------------------------------------------------------
3237-
3238-
Contents of probable licence file $GOMODCACHE/github.com/google/uuid@v1.6.0/LICENSE:
3239-
3240-
Copyright (c) 2009,2014 Google Inc. All rights reserved.
3241-
3242-
Redistribution and use in source and binary forms, with or without
3243-
modification, are permitted provided that the following conditions are
3244-
met:
3245-
3246-
* Redistributions of source code must retain the above copyright
3247-
notice, this list of conditions and the following disclaimer.
3248-
* Redistributions in binary form must reproduce the above
3249-
copyright notice, this list of conditions and the following disclaimer
3250-
in the documentation and/or other materials provided with the
3251-
distribution.
3252-
* Neither the name of Google Inc. nor the names of its
3253-
contributors may be used to endorse or promote products derived from
3254-
this software without specific prior written permission.
3255-
3256-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3257-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3258-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3259-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3260-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3261-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3262-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3263-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3264-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3265-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3266-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3267-
3268-
32693232
--------------------------------------------------------------------------------
32703233
Dependency : github.com/gorilla/mux
32713234
Version: v1.8.0
@@ -22868,36 +22831,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2286822831
SOFTWARE.
2286922832

2287022833

22871-
--------------------------------------------------------------------------------
22872-
Dependency : github.com/gofrs/uuid/v5
22873-
Version: v5.2.0
22874-
Licence type (autodetected): MIT
22875-
--------------------------------------------------------------------------------
22876-
22877-
Contents of probable licence file $GOMODCACHE/github.com/gofrs/uuid/v5@v5.2.0/LICENSE:
22878-
22879-
Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
22880-
22881-
Permission is hereby granted, free of charge, to any person obtaining
22882-
a copy of this software and associated documentation files (the
22883-
"Software"), to deal in the Software without restriction, including
22884-
without limitation the rights to use, copy, modify, merge, publish,
22885-
distribute, sublicense, and/or sell copies of the Software, and to
22886-
permit persons to whom the Software is furnished to do so, subject to
22887-
the following conditions:
22888-
22889-
The above copyright notice and this permission notice shall be
22890-
included in all copies or substantial portions of the Software.
22891-
22892-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22893-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22894-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22895-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22896-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22897-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22898-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22899-
22900-
2290122834
--------------------------------------------------------------------------------
2290222835
Dependency : github.com/gogo/protobuf
2290322836
Version: v1.3.2
@@ -24493,6 +24426,43 @@ Contents of probable licence file $GOMODCACHE/github.com/google/shlex@v0.0.0-201
2449324426
limitations under the License.
2449424427

2449524428

24429+
--------------------------------------------------------------------------------
24430+
Dependency : github.com/google/uuid
24431+
Version: v1.6.0
24432+
Licence type (autodetected): BSD-3-Clause
24433+
--------------------------------------------------------------------------------
24434+
24435+
Contents of probable licence file $GOMODCACHE/github.com/google/uuid@v1.6.0/LICENSE:
24436+
24437+
Copyright (c) 2009,2014 Google Inc. All rights reserved.
24438+
24439+
Redistribution and use in source and binary forms, with or without
24440+
modification, are permitted provided that the following conditions are
24441+
met:
24442+
24443+
* Redistributions of source code must retain the above copyright
24444+
notice, this list of conditions and the following disclaimer.
24445+
* Redistributions in binary form must reproduce the above
24446+
copyright notice, this list of conditions and the following disclaimer
24447+
in the documentation and/or other materials provided with the
24448+
distribution.
24449+
* Neither the name of Google Inc. nor the names of its
24450+
contributors may be used to endorse or promote products derived from
24451+
this software without specific prior written permission.
24452+
24453+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24454+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24455+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24456+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24457+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24458+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24459+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24460+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24461+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24462+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24463+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24464+
24465+
2449624466
--------------------------------------------------------------------------------
2449724467
Dependency : github.com/gorilla/websocket
2449824468
Version: v1.5.0

go.mod

+2-3
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ require (
2525
github.com/fatih/color v1.16.0
2626
github.com/fsnotify/fsnotify v1.7.0
2727
github.com/gofrs/flock v0.8.1
28-
github.com/gofrs/uuid v4.4.0+incompatible
28+
github.com/gofrs/uuid/v5 v5.2.0
2929
github.com/google/go-cmp v0.6.0
3030
github.com/google/pprof v0.0.0-20230426061923-93006964c1fc
31-
github.com/google/uuid v1.6.0
3231
github.com/gorilla/mux v1.8.0
3332
github.com/hashicorp/go-multierror v1.1.1
3433
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95
@@ -172,7 +171,6 @@ require (
172171
github.com/gobuffalo/here v0.6.7 // indirect
173172
github.com/gobwas/glob v0.2.3 // indirect
174173
github.com/goccy/go-json v0.10.3 // indirect
175-
github.com/gofrs/uuid/v5 v5.2.0 // indirect
176174
github.com/gogo/protobuf v1.3.2 // indirect
177175
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
178176
github.com/golang/protobuf v1.5.4 // indirect
@@ -182,6 +180,7 @@ require (
182180
github.com/google/gofuzz v1.2.0 // indirect
183181
github.com/google/licenseclassifier v0.0.0-20221004142553-c1ed8fcf4bab // indirect
184182
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
183+
github.com/google/uuid v1.6.0 // indirect
185184
github.com/gorilla/websocket v1.5.0 // indirect
186185
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
187186
github.com/hashicorp/consul/api v1.29.1 // indirect

go.sum

-2
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,6 @@ github.com/goccy/go-json v0.10.3/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PU
886886
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
887887
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
888888
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
889-
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
890-
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
891889
github.com/gofrs/uuid/v5 v5.2.0 h1:qw1GMx6/y8vhVsx626ImfKMuS5CvJmhIKKtuyvfajMM=
892890
github.com/gofrs/uuid/v5 v5.2.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
893891
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=

internal/pkg/agent/application/info/agent_id.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"io"
1212
"time"
1313

14-
"github.com/gofrs/uuid"
14+
"github.com/gofrs/uuid/v5"
1515
"gopkg.in/yaml.v2"
1616

1717
"github.com/elastic/elastic-agent/internal/pkg/agent/application/filelock"

pkg/component/runtime/manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"sync/atomic"
2020
"time"
2121

22-
"github.com/gofrs/uuid"
22+
"github.com/gofrs/uuid/v5"
2323
"go.elastic.co/apm/module/apmgrpc/v2"
2424
"go.elastic.co/apm/v2"
2525
"google.golang.org/grpc"

pkg/component/runtime/manager_fake_input_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
fakecmp "github.com/elastic/elastic-agent/pkg/component/fake/component/comp"
2828
"github.com/elastic/elastic-agent/pkg/core/logger"
2929

30-
"github.com/gofrs/uuid"
30+
"github.com/gofrs/uuid/v5"
3131
"github.com/stretchr/testify/assert"
3232
"github.com/stretchr/testify/require"
3333
"github.com/stretchr/testify/suite"

pkg/component/runtime/runtime_comm.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"google.golang.org/grpc/status"
1616
protobuf "google.golang.org/protobuf/proto"
1717

18-
"github.com/gofrs/uuid"
18+
"github.com/gofrs/uuid/v5"
1919

2020
"github.com/elastic/elastic-agent-client/v7/pkg/client"
2121
"github.com/elastic/elastic-agent-client/v7/pkg/client/chunk"

pkg/testing/tools/estools/elasticsearch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"strconv"
1414
"strings"
1515

16-
"github.com/google/uuid"
16+
"github.com/gofrs/uuid/v5"
1717

1818
"github.com/elastic/elastic-agent-libs/mapstr"
1919
"github.com/elastic/elastic-transport-go/v8/elastictransport"
@@ -207,7 +207,7 @@ func CreateServiceToken(ctx context.Context, client elastictransport.Interface,
207207
req := esapi.SecurityCreateServiceTokenRequest{
208208
Namespace: "elastic",
209209
Service: service,
210-
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
210+
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
211211
}
212212
resp, err := req.Do(ctx, client)
213213
if err != nil {

pkg/testing/tools/fleettools/fleet.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"os"
1212
"strings"
1313

14-
"github.com/google/uuid"
14+
"github.com/gofrs/uuid/v5"
1515

1616
"github.com/elastic/elastic-agent-libs/kibana"
1717
)
@@ -157,7 +157,7 @@ func DefaultURL(ctx context.Context, client *kibana.Client) (string, error) {
157157
// an enrollment token and returns an EnrollParams with the information to enroll
158158
// an agent. If an error happens, it returns nil and a non-nil error.
159159
func NewEnrollParams(ctx context.Context, client *kibana.Client) (*EnrollParams, error) {
160-
policyUUID := uuid.New().String()
160+
policyUUID := uuid.Must(uuid.NewV4()).String()
161161
policy := kibana.AgentPolicy{
162162
Name: "test-policy-" + policyUUID,
163163
Namespace: "default",

testing/fleetservertest/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"strconv"
1414
"sync"
1515

16-
"github.com/google/uuid"
16+
"github.com/gofrs/uuid/v5"
1717
"github.com/gorilla/mux"
1818
)
1919

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

122122
ww := &statusResponseWriter{w: w}
123123

124-
requestID := uuid.New().String()
124+
requestID := uuid.Must(uuid.NewV4()).String()
125125
handlers.logFn("[%s] STARTING - %s %s %s %s\n",
126126
requestID, r.Method, r.URL, r.Proto, r.RemoteAddr)
127127
route.Handler.

testing/integration/agent_long_running_leak_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"testing"
2222
"time"
2323

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

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

123-
_, err = tools.InstallPackageFromDefaultFile(ctx, runner.info.KibanaClient, "system", "1.53.1", "agent_long_test_base_system_integ.json", uuid.New().String(), policyResp.ID)
123+
_, 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)
124124
require.NoError(runner.T(), err)
125125

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

129129
}

testing/integration/beats_serverless_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
"text/template"
2020
"time"
2121

22-
"github.com/gofrs/uuid"
22+
"github.com/gofrs/uuid/v5"
2323
"github.com/stretchr/testify/assert"
2424
"github.com/stretchr/testify/require"
2525
"github.com/stretchr/testify/suite"

testing/integration/container_cmd_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"text/template"
2323
"time"
2424

25-
"github.com/google/uuid"
25+
"github.com/gofrs/uuid/v5"
2626
"github.com/stretchr/testify/assert"
2727
"github.com/stretchr/testify/require"
2828

@@ -155,7 +155,7 @@ func TestContainerCMD(t *testing.T) {
155155
ctx,
156156
agentFixture,
157157
info,
158-
fmt.Sprintf("%s-%s", t.Name(), uuid.New().String()),
158+
fmt.Sprintf("%s-%s", t.Name(), uuid.Must(uuid.NewV4()).String()),
159159
"")
160160
env := []string{
161161
"FLEET_ENROLL=1",
@@ -242,7 +242,7 @@ func TestContainerCMDWithAVeryLongStatePath(t *testing.T) {
242242
ctx,
243243
agentFixture,
244244
info,
245-
fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
245+
fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()),
246246
"")
247247

248248
env := []string{
@@ -333,7 +333,7 @@ func TestContainerCMDEventToStderr(t *testing.T) {
333333
ctx,
334334
agentFixture,
335335
info,
336-
fmt.Sprintf("%s-%s", t.Name(), uuid.New().String()),
336+
fmt.Sprintf("%s-%s", t.Name(), uuid.Must(uuid.NewV4()).String()),
337337
outputID)
338338

339339
fleetURL, err := fleettools.DefaultURL(ctx, info.KibanaClient)
@@ -403,7 +403,7 @@ func createMockESOutput(t *testing.T, info *define.Info) (string, string) {
403403
`
404404
// The API will return an error if the output ID/name contains an
405405
// UUID substring, so we replace the '-' by '_' to keep the API happy.
406-
outputUUID := strings.Replace(uuid.New().String(), "-", "_", -1)
406+
outputUUID := strings.Replace(uuid.Must(uuid.NewV4()).String(), "-", "_", -1)
407407
bodyStr := fmt.Sprintf(createOutputBody, outputUUID, mockesURL)
408408
bodyReader := strings.NewReader(bodyStr)
409409
// THE URL IS MISSING

testing/integration/delay_enroll_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"testing"
1313
"time"
1414

15-
"github.com/google/uuid"
15+
"github.com/gofrs/uuid/v5"
1616
"github.com/stretchr/testify/require"
1717

1818
"github.com/elastic/elastic-agent-libs/kibana"
@@ -44,7 +44,7 @@ func TestDelayEnroll(t *testing.T) {
4444
// name. This policy does not contain any integration.
4545
t.Log("Enrolling agent in Fleet with a test policy")
4646
createPolicyReq := kibana.AgentPolicy{
47-
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
47+
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()),
4848
Namespace: info.Namespace,
4949
Description: "test policy for agent enrollment",
5050
MonitoringEnabled: []kibana.MonitoringEnabledOption{
@@ -104,7 +104,7 @@ func TestDelayEnrollUnprivileged(t *testing.T) {
104104
// name. This policy does not contain any integration.
105105
t.Log("Enrolling agent in Fleet with a test policy")
106106
createPolicyReq := kibana.AgentPolicy{
107-
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.New().String()),
107+
Name: fmt.Sprintf("test-policy-enroll-%s", uuid.Must(uuid.NewV4()).String()),
108108
Namespace: info.Namespace,
109109
Description: "test policy for agent enrollment",
110110
MonitoringEnabled: []kibana.MonitoringEnabledOption{

0 commit comments

Comments
 (0)