Skip to content

Commit 74d88a7

Browse files
authored
Merge branch 'nginx:main' into add_snippestspolicy
2 parents a3536fc + eb83cdb commit 74d88a7

File tree

24 files changed

+228
-232
lines changed

24 files changed

+228
-232
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
path: ${{ github.workspace }}/dist
6161

6262
- name: Docker Buildx
63-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
63+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
6464
with:
6565
driver-opts: network=host
6666

@@ -194,7 +194,7 @@ jobs:
194194
fail-build: false
195195

196196
- name: Upload scan result to GitHub Security tab
197-
uses: github/codeql-action/upload-sarif@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4.31.8
197+
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
198198
if: ${{ !inputs.dry_run }}
199199
continue-on-error: true
200200
with:

.github/workflows/conformance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
run: echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
7575

7676
- name: Docker Buildx
77-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
77+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
7878

7979
- name: NGF Docker meta
8080
id: ngf-meta

.github/workflows/functional.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
5757

5858
- name: Docker Buildx
59-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
59+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
6060

6161
- name: NGF Docker meta
6262
id: ngf-meta

.github/workflows/helm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
path: ${{ github.workspace }}/dist
3636

3737
- name: Docker Buildx
38-
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
38+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
3939

4040
- name: NGF Docker meta
4141
id: ngf-meta

.github/workflows/scorecards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ jobs:
6060

6161
# Upload the results to GitHub's code scanning dashboard.
6262
- name: "Upload to code-scanning"
63-
uses: github/codeql-action/upload-sarif@1b168cd39490f61582a9beae412bb7057a6b2c4e # v4.31.8
63+
uses: github/codeql-action/upload-sarif@5d4e8d1aca955e8d8589aabd499c5cae939e33c7 # v4.31.9
6464
with:
6565
sarif_file: results.sarif

internal/controller/nginx/agent/broadcast/broadcast_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package broadcast_test
22

33
import (
4-
"context"
54
"testing"
65

76
. "github.com/onsi/gomega"
@@ -16,7 +15,7 @@ func TestSubscribe(t *testing.T) {
1615
stopCh := make(chan struct{})
1716
defer close(stopCh)
1817

19-
broadcaster := broadcast.NewDeploymentBroadcaster(context.Background(), stopCh)
18+
broadcaster := broadcast.NewDeploymentBroadcaster(t.Context(), stopCh)
2019

2120
subscriber := broadcaster.Subscribe()
2221
g.Expect(subscriber.ID).NotTo(BeEmpty())
@@ -41,7 +40,7 @@ func TestSubscribe_MultipleListeners(t *testing.T) {
4140
stopCh := make(chan struct{})
4241
defer close(stopCh)
4342

44-
broadcaster := broadcast.NewDeploymentBroadcaster(context.Background(), stopCh)
43+
broadcaster := broadcast.NewDeploymentBroadcaster(t.Context(), stopCh)
4544

4645
subscriber1 := broadcaster.Subscribe()
4746
subscriber2 := broadcaster.Subscribe()
@@ -70,7 +69,7 @@ func TestSubscribe_NoListeners(t *testing.T) {
7069
stopCh := make(chan struct{})
7170
defer close(stopCh)
7271

73-
broadcaster := broadcast.NewDeploymentBroadcaster(context.Background(), stopCh)
72+
broadcaster := broadcast.NewDeploymentBroadcaster(t.Context(), stopCh)
7473

7574
message := broadcast.NginxAgentMessage{
7675
ConfigVersion: "v1",
@@ -88,7 +87,7 @@ func TestCancelSubscription(t *testing.T) {
8887
stopCh := make(chan struct{})
8988
defer close(stopCh)
9089

91-
broadcaster := broadcast.NewDeploymentBroadcaster(context.Background(), stopCh)
90+
broadcaster := broadcast.NewDeploymentBroadcaster(t.Context(), stopCh)
9291

9392
subscriber := broadcaster.Subscribe()
9493

internal/controller/nginx/agent/command_test.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,16 @@ func createFakeK8sClient(initObjs ...runtime.Object) (client.Client, error) {
7373
return fakeClient, nil
7474
}
7575

76-
func createGrpcContext() context.Context {
77-
return grpcContext.NewGrpcContext(context.Background(), grpcContext.GrpcInfo{
76+
func createGrpcContext(t *testing.T) context.Context {
77+
t.Helper()
78+
return grpcContext.NewGrpcContext(t.Context(), grpcContext.GrpcInfo{
7879
UUID: "1234567",
7980
})
8081
}
8182

82-
func createGrpcContextWithCancel() (context.Context, context.CancelFunc) {
83-
ctx, cancel := context.WithCancel(context.Background())
84-
83+
func createGrpcContextWithCancel(t *testing.T) (context.Context, context.CancelFunc) {
84+
t.Helper()
85+
ctx, cancel := context.WithCancel(t.Context())
8586
return grpcContext.NewGrpcContext(ctx, grpcContext.GrpcInfo{
8687
UUID: "1234567",
8788
}), cancel
@@ -122,7 +123,7 @@ func TestCreateConnection(t *testing.T) {
122123
}{
123124
{
124125
name: "successfully tracks a connection",
125-
ctx: createGrpcContext(),
126+
ctx: createGrpcContext(t),
126127
request: &pb.CreateConnectionRequest{
127128
Resource: &pb.Resource{
128129
Info: &pb.Resource_ContainerInfo{
@@ -181,14 +182,14 @@ func TestCreateConnection(t *testing.T) {
181182
},
182183
{
183184
name: "context is missing data",
184-
ctx: context.Background(),
185+
ctx: t.Context(),
185186
request: &pb.CreateConnectionRequest{},
186187
response: nil,
187188
errString: agentgrpc.ErrStatusInvalidConnection.Error(),
188189
},
189190
{
190191
name: "error getting pod owner",
191-
ctx: createGrpcContext(),
192+
ctx: createGrpcContext(t),
192193
request: &pb.CreateConnectionRequest{
193194
Resource: &pb.Resource{
194195
Info: &pb.Resource_ContainerInfo{
@@ -360,7 +361,7 @@ func TestSubscribe(t *testing.T) {
360361
}
361362
deployment.SetNGINXPlusActions([]*pb.NGINXPlusAction{initialAction})
362363

363-
ctx, cancel := createGrpcContextWithCancel()
364+
ctx, cancel := createGrpcContextWithCancel(t)
364365
defer cancel()
365366

366367
mockServer := newMockSubscribeServer(ctx)
@@ -501,7 +502,7 @@ func TestSubscribe_Reset(t *testing.T) {
501502
deployment.SetFiles(files, []v1.VolumeMount{})
502503
deployment.SetImageVersion("nginx:v1.0.0")
503504

504-
ctx, cancel := createGrpcContextWithCancel()
505+
ctx, cancel := createGrpcContextWithCancel(t)
505506
defer cancel()
506507

507508
mockServer := newMockSubscribeServer(ctx)
@@ -542,7 +543,7 @@ func TestSubscribe_Errors(t *testing.T) {
542543
}{
543544
{
544545
name: "context is missing data",
545-
ctx: context.Background(),
546+
ctx: t.Context(),
546547
errString: agentgrpc.ErrStatusInvalidConnection.Error(),
547548
},
548549
{
@@ -594,7 +595,7 @@ func TestSubscribe_Errors(t *testing.T) {
594595
if test.ctx != nil {
595596
ctx = test.ctx
596597
} else {
597-
ctx, cancel = createGrpcContextWithCancel()
598+
ctx, cancel = createGrpcContextWithCancel(t)
598599
defer cancel()
599600
}
600601

@@ -723,7 +724,7 @@ func TestSetInitialConfig_Errors(t *testing.T) {
723724
test.setup(msgr, deployment)
724725
}
725726

726-
err = cs.setInitialConfig(context.Background(), &grpcContext.GrpcInfo{}, deployment, conn, msgr)
727+
err = cs.setInitialConfig(t.Context(), &grpcContext.GrpcInfo{}, deployment, conn, msgr)
727728

728729
g.Expect(err).To(HaveOccurred())
729730
g.Expect(err.Error()).To(ContainSubstring(test.errString))
@@ -744,7 +745,7 @@ func TestUpdateDataPlaneStatus(t *testing.T) {
744745
}{
745746
{
746747
name: "successfully sets the status",
747-
ctx: createGrpcContext(),
748+
ctx: createGrpcContext(t),
748749
request: &pb.UpdateDataPlaneStatusRequest{
749750
Resource: &pb.Resource{
750751
Instances: []*pb.Instance{
@@ -762,7 +763,7 @@ func TestUpdateDataPlaneStatus(t *testing.T) {
762763
},
763764
{
764765
name: "successfully sets the status using plus",
765-
ctx: createGrpcContext(),
766+
ctx: createGrpcContext(t),
766767
request: &pb.UpdateDataPlaneStatusRequest{
767768
Resource: &pb.Resource{
768769
Instances: []*pb.Instance{
@@ -786,14 +787,14 @@ func TestUpdateDataPlaneStatus(t *testing.T) {
786787
},
787788
{
788789
name: "context is missing data",
789-
ctx: context.Background(),
790+
ctx: t.Context(),
790791
request: &pb.UpdateDataPlaneStatusRequest{},
791792
response: nil,
792793
errString: agentgrpc.ErrStatusInvalidConnection.Error(),
793794
},
794795
{
795796
name: "request does not contain ID",
796-
ctx: createGrpcContext(),
797+
ctx: createGrpcContext(t),
797798
request: &pb.UpdateDataPlaneStatusRequest{},
798799
response: nil,
799800
errString: "request does not contain nginx instanceID",
@@ -855,7 +856,7 @@ func TestUpdateDataPlaneHealth(t *testing.T) {
855856
nil,
856857
)
857858

858-
resp, err := cs.UpdateDataPlaneHealth(context.Background(), &pb.UpdateDataPlaneHealthRequest{})
859+
resp, err := cs.UpdateDataPlaneHealth(t.Context(), &pb.UpdateDataPlaneHealthRequest{})
859860

860861
g.Expect(err).ToNot(HaveOccurred())
861862
g.Expect(resp).To(Equal(&pb.UpdateDataPlaneHealthResponse{}))

internal/controller/nginx/agent/deployment_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package agent
22

33
import (
4-
"context"
54
"errors"
65
"testing"
76

@@ -218,13 +217,13 @@ func TestDeploymentStore(t *testing.T) {
218217

219218
nsName := types.NamespacedName{Namespace: "default", Name: "test-deployment"}
220219

221-
deployment := store.GetOrStore(context.Background(), nsName, nil)
220+
deployment := store.GetOrStore(t.Context(), nsName, nil)
222221
g.Expect(deployment).ToNot(BeNil())
223222

224223
fetchedDeployment := store.Get(nsName)
225224
g.Expect(fetchedDeployment).To(Equal(deployment))
226225

227-
deployment = store.GetOrStore(context.Background(), nsName, nil)
226+
deployment = store.GetOrStore(t.Context(), nsName, nil)
228227
g.Expect(fetchedDeployment).To(Equal(deployment))
229228

230229
store.Remove(nsName)

internal/controller/nginx/agent/grpc/context/context_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package grpcinfo_test
22

33
import (
4-
"context"
54
"testing"
65

76
. "github.com/onsi/gomega"
@@ -15,7 +14,7 @@ func TestGrpcInfoInContext(t *testing.T) {
1514

1615
grpcInfo := grpcContext.GrpcInfo{Token: "test"}
1716

18-
newCtx := grpcContext.NewGrpcContext(context.Background(), grpcInfo)
17+
newCtx := grpcContext.NewGrpcContext(t.Context(), grpcInfo)
1918
info, ok := grpcContext.FromContext(newCtx)
2019
g.Expect(ok).To(BeTrue())
2120
g.Expect(info).To(Equal(grpcInfo))
@@ -25,7 +24,7 @@ func TestGrpcInfoNotInContext(t *testing.T) {
2524
t.Parallel()
2625
g := NewWithT(t)
2726

28-
info, ok := grpcContext.FromContext(context.Background())
27+
info, ok := grpcContext.FromContext(t.Context())
2928
g.Expect(ok).To(BeFalse())
3029
g.Expect(info).To(Equal(grpcContext.GrpcInfo{}))
3130
}

internal/controller/nginx/agent/grpc/messenger/messenger_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestSend(t *testing.T) {
6464
t.Parallel()
6565
g := NewWithT(t)
6666

67-
ctx, cancel := context.WithCancel(context.Background())
67+
ctx, cancel := context.WithCancel(t.Context())
6868
defer cancel()
6969

7070
server := createServer()
@@ -90,7 +90,7 @@ func TestMessages(t *testing.T) {
9090
t.Parallel()
9191
g := NewWithT(t)
9292

93-
ctx, cancel := context.WithCancel(context.Background())
93+
ctx, cancel := context.WithCancel(t.Context())
9494
defer cancel()
9595

9696
server := createServer()
@@ -108,7 +108,7 @@ func TestErrors(t *testing.T) {
108108
t.Parallel()
109109
g := NewWithT(t)
110110

111-
ctx, cancel := context.WithCancel(context.Background())
111+
ctx, cancel := context.WithCancel(t.Context())
112112
defer cancel()
113113

114114
server := createErrorServer()

0 commit comments

Comments
 (0)