Skip to content

Commit d1a216c

Browse files
authored
Renames context package to avoid linter errors in pipeline (#4476)
Fix to rename context package to grpcInfo to avoid linter errors in pipeline
1 parent 852585e commit d1a216c

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

internal/controller/nginx/agent/command.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (cs *commandService) CreateConnection(
7777
return nil, errors.New("empty connection request")
7878
}
7979

80-
gi, ok := grpcContext.GrpcInfoFromContext(ctx)
80+
gi, ok := grpcContext.FromContext(ctx)
8181
if !ok {
8282
return nil, agentgrpc.ErrStatusInvalidConnection
8383
}
@@ -126,7 +126,7 @@ func (cs *commandService) CreateConnection(
126126
func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error {
127127
ctx := in.Context()
128128

129-
gi, ok := grpcContext.GrpcInfoFromContext(ctx)
129+
gi, ok := grpcContext.FromContext(ctx)
130130
if !ok {
131131
return agentgrpc.ErrStatusInvalidConnection
132132
}
@@ -562,7 +562,7 @@ func (cs *commandService) UpdateDataPlaneStatus(
562562
return nil, errors.New("empty UpdateDataPlaneStatus request")
563563
}
564564

565-
gi, ok := grpcContext.GrpcInfoFromContext(ctx)
565+
gi, ok := grpcContext.FromContext(ctx)
566566
if !ok {
567567
return nil, agentgrpc.ErrStatusInvalidConnection
568568
}

internal/controller/nginx/agent/file.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (fs *fileService) GetFile(
5656
ctx context.Context,
5757
req *pb.GetFileRequest,
5858
) (*pb.GetFileResponse, error) {
59-
gi, ok := grpcContext.GrpcInfoFromContext(ctx)
59+
gi, ok := grpcContext.FromContext(ctx)
6060
if !ok {
6161
return nil, agentgrpc.ErrStatusInvalidConnection
6262
}
@@ -84,7 +84,7 @@ func (fs *fileService) GetFileStream(
8484
req *pb.GetFileRequest,
8585
server grpc.ServerStreamingServer[pb.FileDataChunk],
8686
) error {
87-
gi, ok := grpcContext.GrpcInfoFromContext(server.Context())
87+
gi, ok := grpcContext.FromContext(server.Context())
8888
if !ok {
8989
return agentgrpc.ErrStatusInvalidConnection
9090
}
@@ -187,7 +187,7 @@ func (fs *fileService) UpdateOverview(
187187
ctx context.Context,
188188
req *pb.UpdateOverviewRequest,
189189
) (*pb.UpdateOverviewResponse, error) {
190-
gi, ok := grpcContext.GrpcInfoFromContext(ctx)
190+
gi, ok := grpcContext.FromContext(ctx)
191191
if !ok {
192192
return &pb.UpdateOverviewResponse{}, agentgrpc.ErrStatusInvalidConnection
193193
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package context
1+
package grpcinfo
22

33
import (
44
"context"
@@ -17,9 +17,9 @@ func NewGrpcContext(ctx context.Context, r GrpcInfo) context.Context {
1717
return context.WithValue(ctx, contextGRPCKey{}, r)
1818
}
1919

20-
// GrpcInfoFromContext returns the GrpcInfo saved in ctx if it exists.
20+
// FromContext returns the GrpcInfo saved in ctx if it exists.
2121
// Returns false if there's no GrpcInfo in the context.
22-
func GrpcInfoFromContext(ctx context.Context) (GrpcInfo, bool) {
22+
func FromContext(ctx context.Context) (GrpcInfo, bool) {
2323
v, ok := ctx.Value(contextGRPCKey{}).(GrpcInfo)
2424
return v, ok
2525
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package context_test
1+
package grpcinfo_test
22

33
import (
44
"context"
@@ -16,7 +16,7 @@ func TestGrpcInfoInContext(t *testing.T) {
1616
grpcInfo := grpcContext.GrpcInfo{Token: "test"}
1717

1818
newCtx := grpcContext.NewGrpcContext(context.Background(), grpcInfo)
19-
info, ok := grpcContext.GrpcInfoFromContext(newCtx)
19+
info, ok := grpcContext.FromContext(newCtx)
2020
g.Expect(ok).To(BeTrue())
2121
g.Expect(info).To(Equal(grpcInfo))
2222
}
@@ -25,7 +25,7 @@ func TestGrpcInfoNotInContext(t *testing.T) {
2525
t.Parallel()
2626
g := NewWithT(t)
2727

28-
info, ok := grpcContext.GrpcInfoFromContext(context.Background())
28+
info, ok := grpcContext.FromContext(context.Background())
2929
g.Expect(ok).To(BeFalse())
3030
g.Expect(info).To(Equal(grpcContext.GrpcInfo{}))
3131
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/*
2-
Package context contains the functions for storing extra information in the gRPC context.
2+
Package grpcinfo contains helpers for storing and retrieving gRPC identity information in a context.Context.
33
*/
4-
package context //nolint:revive // ignoring conflicting package name
4+
package grpcinfo

0 commit comments

Comments
 (0)