From e51a347a80aa9ee7001ad85dabf87ca056bc23e5 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 24 Jun 2025 15:47:57 +0100 Subject: [PATCH 1/5] _bin/tools/go get golang.org/x/net@latest Signed-off-by: Richard Wall --- go.mod | 12 ++++++------ go.sum | 7 +++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index ffec286c..65be919c 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.10.0 - golang.org/x/sync v0.11.0 + golang.org/x/sync v0.15.0 gopkg.in/yaml.v2 v2.4.0 k8s.io/api v0.33.0-alpha.1 k8s.io/apimachinery v0.33.0-alpha.1 @@ -57,9 +57,9 @@ require ( go.opentelemetry.io/otel/trace v1.28.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.35.0 // indirect + golang.org/x/crypto v0.39.0 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect - golang.org/x/net v0.36.0 // indirect + golang.org/x/net v0.41.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240826202546-f6391c0de4c7 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect @@ -95,9 +95,9 @@ require ( github.com/prometheus/common v0.62.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect golang.org/x/oauth2 v0.24.0 // indirect - golang.org/x/sys v0.30.0 // indirect - golang.org/x/term v0.29.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/sys v0.33.0 // indirect + golang.org/x/term v0.32.0 // indirect + golang.org/x/text v0.26.0 // indirect golang.org/x/time v0.7.0 // indirect google.golang.org/protobuf v1.36.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/go.sum b/go.sum index 25dfdd7a..7098dd9e 100644 --- a/go.sum +++ b/go.sum @@ -226,6 +226,7 @@ golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= +golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -236,6 +237,8 @@ golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA= golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I= +golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= +golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -243,6 +246,7 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -250,12 +254,15 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= +golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From 299c019214139d437c15739e6170d84fc4c6d886 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 24 Jun 2025 15:48:10 +0100 Subject: [PATCH 2/5] make go-tidy Signed-off-by: Richard Wall --- go.sum | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/go.sum b/go.sum index 7098dd9e..bd51d230 100644 --- a/go.sum +++ b/go.sum @@ -224,8 +224,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs= -golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ= +golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM= golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= @@ -235,8 +234,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.36.0 h1:vWF2fRbw4qslQsQzgFqZff+BItCvGFQqKzKIzx1rmoA= -golang.org/x/net v0.36.0/go.mod h1:bFmbeoIPfrw4sMHNhb4J9f6+tPziuGjq7Jk/38fxi1I= golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw= golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA= golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= @@ -244,24 +241,20 @@ golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbht golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= -golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= -golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= -golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= +golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= -golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M= golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA= golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= @@ -269,8 +262,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ= -golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0= +golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc= +golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 2bbd0a6cfed0aa416438400262776b7ce598633c Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 24 Jun 2025 15:50:04 +0100 Subject: [PATCH 3/5] _bin/tools/go get go@1.24.4 Signed-off-by: Richard Wall --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 65be919c..d2db40e1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/jetstack/preflight -go 1.23.4 +go 1.24.4 require ( github.com/Venafi/vcert/v5 v5.8.1 From a53aee2990731b9bf9abe9a6963d20997fad6323 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 24 Jun 2025 15:56:34 +0100 Subject: [PATCH 4/5] Use testing.Context (a Go 1.24 feature) Signed-off-by: Richard Wall --- cmd/agent_test.go | 2 +- pkg/agent/config_test.go | 6 +++--- pkg/client/client_venconn_test.go | 2 +- pkg/datagatherer/k8s/dynamic_test.go | 9 ++++----- pkg/echo/echo_test.go | 3 +-- pkg/internal/cyberark/dataupload/dataupload_test.go | 3 +-- .../cyberark/identity/advance_authentication_test.go | 3 +-- .../cyberark/identity/start_authentication_test.go | 3 +-- pkg/internal/cyberark/servicediscovery/discovery_test.go | 3 +-- pkg/logs/logs_test.go | 3 +-- 10 files changed, 15 insertions(+), 22 deletions(-) diff --git a/cmd/agent_test.go b/cmd/agent_test.go index 9c92144d..5a7501b0 100644 --- a/cmd/agent_test.go +++ b/cmd/agent_test.go @@ -39,7 +39,7 @@ func TestAgentRunOneShot(t *testing.T) { return } t.Log("Running child process") - ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + ctx, cancel := context.WithTimeout(t.Context(), time.Second*3) defer cancel() cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^TestAgentRunOneShot$") var ( diff --git a/pkg/agent/config_test.go b/pkg/agent/config_test.go index 61cd1606..11d66ec3 100644 --- a/pkg/agent/config_test.go +++ b/pkg/agent/config_test.go @@ -659,7 +659,7 @@ func Test_ValidateAndCombineConfig_VenafiCloudKeyPair(t *testing.T) { t.Run("server, uploader_id, and cluster name are correctly passed", func(t *testing.T) { t.Setenv("POD_NAMESPACE", "venafi") - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() log := ktesting.NewLogger(t, ktesting.NewConfig(ktesting.Verbosity(10))) ctx = klog.NewContext(ctx, log) @@ -752,7 +752,7 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) { name: venafi-connection namespace: venafi `))) { - require.NoError(t, kcl.Create(context.Background(), obj)) + require.NoError(t, kcl.Create(t.Context(), obj)) } t.Run("err when cluster_id field is empty", func(t *testing.T) { @@ -768,7 +768,7 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) { }) t.Run("the server field is ignored when VenafiConnection is used", func(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() log := ktesting.NewLogger(t, ktesting.NewConfig(ktesting.Verbosity(10))) ctx = klog.NewContext(ctx, log) diff --git a/pkg/client/client_venconn_test.go b/pkg/client/client_venconn_test.go index f857cf91..6b9e14a4 100644 --- a/pkg/client/client_venconn_test.go +++ b/pkg/client/client_venconn_test.go @@ -36,7 +36,7 @@ import ( // // [1] https://github.com/kubernetes-sigs/controller-runtime/issues/2341 func TestVenConnClient_PostDataReadingsWithOptions(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(t.Context()) defer cancel() log := ktesting.NewLogger(t, ktesting.NewConfig(ktesting.Verbosity(10))) ctx = klog.NewContext(ctx, log) diff --git a/pkg/datagatherer/k8s/dynamic_test.go b/pkg/datagatherer/k8s/dynamic_test.go index 5f954804..072c4c1c 100644 --- a/pkg/datagatherer/k8s/dynamic_test.go +++ b/pkg/datagatherer/k8s/dynamic_test.go @@ -1,7 +1,6 @@ package k8s import ( - "context" "encoding/json" "fmt" "reflect" @@ -117,7 +116,7 @@ func sortGatheredResources(list []*api.GatheredResource) { } func TestNewDataGathererWithClientAndDynamicInformer(t *testing.T) { - ctx := context.Background() + ctx := t.Context() config := ConfigDynamic{ ExcludeNamespaces: []string{"kube-system"}, GroupVersionResource: schema.GroupVersionResource{Group: "foobar", Version: "v1", Resource: "foos"}, @@ -164,7 +163,7 @@ func TestNewDataGathererWithClientAndDynamicInformer(t *testing.T) { } func TestNewDataGathererWithClientAndSharedIndexInformer(t *testing.T) { - ctx := context.Background() + ctx := t.Context() config := ConfigDynamic{ IncludeNamespaces: []string{"a"}, GroupVersionResource: schema.GroupVersionResource{Group: "", Version: "v1", Resource: "pods"}, @@ -638,7 +637,7 @@ func TestDynamicGatherer_Fetch(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { var wg sync.WaitGroup - ctx := context.Background() + ctx := t.Context() gvrToListKind := map[schema.GroupVersionResource]string{ {Group: "foobar", Version: "v1", Resource: "foos"}: "UnstructuredList", {Group: "apps", Version: "v1", Resource: "deployments"}: "UnstructuredList", @@ -958,7 +957,7 @@ func TestDynamicGathererNativeResources_Fetch(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { var wg sync.WaitGroup - ctx := context.Background() + ctx := t.Context() clientset := fakeclientset.NewSimpleClientset(tc.addObjects...) diff --git a/pkg/echo/echo_test.go b/pkg/echo/echo_test.go index 91a7f1ec..d9cd9318 100644 --- a/pkg/echo/echo_test.go +++ b/pkg/echo/echo_test.go @@ -2,7 +2,6 @@ package echo import ( "bytes" - "context" "encoding/json" "net/http" "net/http/httptest" @@ -61,7 +60,7 @@ func TestEchoServerRequestResponse(t *testing.T) { } // generate a request to test the handler containing the JSON data as a body - req, err := http.NewRequestWithContext(context.TODO(), sampleUpload.method, "http://example.com/api/v1/datareadings", bytes.NewBuffer(requestBodyJSON)) + req, err := http.NewRequestWithContext(t.Context(), sampleUpload.method, "http://example.com/api/v1/datareadings", bytes.NewBuffer(requestBodyJSON)) if err != nil { t.Fatalf("[%s]\nfailed to generate request to test echo server: %s", sampleUpload.description, err) } diff --git a/pkg/internal/cyberark/dataupload/dataupload_test.go b/pkg/internal/cyberark/dataupload/dataupload_test.go index 43423152..01fffe45 100644 --- a/pkg/internal/cyberark/dataupload/dataupload_test.go +++ b/pkg/internal/cyberark/dataupload/dataupload_test.go @@ -1,7 +1,6 @@ package dataupload_test import ( - "context" "crypto/x509" "encoding/pem" "fmt" @@ -113,7 +112,7 @@ func TestCyberArkClient_PostDataReadingsWithOptions(t *testing.T) { cyberArkClient, err := dataupload.NewCyberArkClient(certPool, server.Server.URL, tc.authenticate) require.NoError(t, err) - err = cyberArkClient.PostDataReadingsWithOptions(context.TODO(), tc.payload, tc.opts) + err = cyberArkClient.PostDataReadingsWithOptions(t.Context(), tc.payload, tc.opts) tc.requireFn(t, err) }) } diff --git a/pkg/internal/cyberark/identity/advance_authentication_test.go b/pkg/internal/cyberark/identity/advance_authentication_test.go index a670f542..96749835 100644 --- a/pkg/internal/cyberark/identity/advance_authentication_test.go +++ b/pkg/internal/cyberark/identity/advance_authentication_test.go @@ -1,7 +1,6 @@ package identity import ( - "context" "fmt" "testing" @@ -98,7 +97,7 @@ func Test_IdentityAdvanceAuthentication(t *testing.T) { for name, testSpec := range tests { t.Run(name, func(t *testing.T) { - ctx := context.Background() + ctx := t.Context() identityServer := MockIdentityServer() defer identityServer.Close() diff --git a/pkg/internal/cyberark/identity/start_authentication_test.go b/pkg/internal/cyberark/identity/start_authentication_test.go index 92ba150e..a25ad139 100644 --- a/pkg/internal/cyberark/identity/start_authentication_test.go +++ b/pkg/internal/cyberark/identity/start_authentication_test.go @@ -1,7 +1,6 @@ package identity import ( - "context" "fmt" "testing" @@ -39,7 +38,7 @@ func Test_IdentityStartAuthentication(t *testing.T) { for name, testSpec := range tests { t.Run(name, func(t *testing.T) { - ctx := context.Background() + ctx := t.Context() identityServer := MockIdentityServer() defer identityServer.Close() diff --git a/pkg/internal/cyberark/servicediscovery/discovery_test.go b/pkg/internal/cyberark/servicediscovery/discovery_test.go index 8dd19ed6..84bb9281 100644 --- a/pkg/internal/cyberark/servicediscovery/discovery_test.go +++ b/pkg/internal/cyberark/servicediscovery/discovery_test.go @@ -1,7 +1,6 @@ package servicediscovery import ( - "context" "fmt" "testing" ) @@ -46,7 +45,7 @@ func Test_DiscoverIdentityAPIURL(t *testing.T) { for name, testSpec := range tests { t.Run(name, func(t *testing.T) { - ctx := context.Background() + ctx := t.Context() ts := MockDiscoveryServer() defer ts.Close() diff --git a/pkg/logs/logs_test.go b/pkg/logs/logs_test.go index c4f27a5f..c351d011 100644 --- a/pkg/logs/logs_test.go +++ b/pkg/logs/logs_test.go @@ -2,7 +2,6 @@ package logs_test import ( "bytes" - "context" "errors" "fmt" "io" @@ -65,7 +64,7 @@ func TestLogs(t *testing.T) { klog.Warning("klog Warning") klog.ErrorS(errors.New("fake-error"), "klog Error") klog.InfoS("klog InfoS", "key", "value") - logger := klog.FromContext(context.Background()).WithName("foo") + logger := klog.FromContext(t.Context()).WithName("foo") logger.V(3).Info("Contextual Info Level 3", "key", "value") logger.Error(errors.New("fake-error"), "Contextual error", "key", "value") From aa12acc5cdbc1a03e27d3cd1ea4fffd6fb0ab479 Mon Sep 17 00:00:00 2001 From: Richard Wall Date: Tue, 24 Jun 2025 15:59:16 +0100 Subject: [PATCH 5/5] Fix govet warnings Signed-off-by: Richard Wall --- pkg/agent/config_test.go | 4 ++-- pkg/logs/logs_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/agent/config_test.go b/pkg/agent/config_test.go index 11d66ec3..2743a493 100644 --- a/pkg/agent/config_test.go +++ b/pkg/agent/config_test.go @@ -704,7 +704,7 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) { t.Setenv("KUBECONFIG", testutil.WithKubeconfig(t, cfg)) srv, cert, setVenafiCloudAssert := testutil.FakeVenafiCloud(t) for _, obj := range testutil.Parse( - testutil.VenConnRBAC + testutil.Undent(fmt.Sprintf(` + testutil.VenConnRBAC + testutil.Undent(` --- apiVersion: jetstack.io/v1alpha1 kind: VenafiConnection @@ -751,7 +751,7 @@ func Test_ValidateAndCombineConfig_VenafiConnection(t *testing.T) { - kind: ServiceAccount name: venafi-connection namespace: venafi - `))) { + `)) { require.NoError(t, kcl.Create(t.Context(), obj)) } diff --git a/pkg/logs/logs_test.go b/pkg/logs/logs_test.go index c351d011..0a3b7820 100644 --- a/pkg/logs/logs_test.go +++ b/pkg/logs/logs_test.go @@ -385,10 +385,10 @@ retrying in %v after error: %s datagatherer informer for %q has failed and is backing off due to error: %s this is a happy log that should show as INFO`, "\n") expect := strings.TrimPrefix(` -level=ERROR msg="failed to complete initial sync of %!q(MISSING) data gatherer %!q(MISSING): %!v(MISSING)" source=agent +level=ERROR msg="failed to complete initial sync of %q data gatherer %q: %v" source=agent level=ERROR msg="error messages will not show in the pod's events because the POD_NAME environment variable is empty" source=agent -level=ERROR msg="retrying in %!v(MISSING) after error: %!s(MISSING)" source=agent -level=ERROR msg="datagatherer informer for %!q(MISSING) has failed and is backing off due to error: %!s(MISSING)" source=agent +level=ERROR msg="retrying in %v after error: %s" source=agent +level=ERROR msg="datagatherer informer for %q has failed and is backing off due to error: %s" source=agent level=INFO msg="this is a happy log that should show as INFO" source=agent `, "\n") @@ -409,7 +409,7 @@ level=INFO msg="this is a happy log that should show as INFO" source=agent for _, line := range strings.Split(given, "\n") { // Simulate the current agent's logs. - logger.Printf(line) // nolint:staticcheck + logger.Print(line) } assert.Equal(t, expect, gotBuf.String())