Skip to content

Commit 18eed56

Browse files
committed
more renaming
1 parent 77300a7 commit 18eed56

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

internal/controller/nginx/agent/command.go

Lines changed: 16 additions & 16 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.FromContext(ctx)
80+
grpcInfo, ok := grpcContext.FromContext(ctx)
8181
if !ok {
8282
return nil, agentgrpc.ErrStatusInvalidConnection
8383
}
@@ -105,7 +105,7 @@ func (cs *commandService) CreateConnection(
105105
ParentType: depType,
106106
InstanceID: getNginxInstanceID(resource.GetInstances()),
107107
}
108-
cs.connTracker.Track(gi.UUID, conn)
108+
cs.connTracker.Track(grpcInfo.UUID, conn)
109109

110110
return &pb.CreateConnectionResponse{
111111
Response: &pb.CommandResponse{
@@ -127,31 +127,31 @@ func (cs *commandService) CreateConnection(
127127
func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error {
128128
ctx := in.Context()
129129

130-
gi, ok := grpcContext.FromContext(ctx)
130+
grpcInfo, ok := grpcContext.FromContext(ctx)
131131
if !ok {
132132
return agentgrpc.ErrStatusInvalidConnection
133133
}
134-
defer cs.connTracker.RemoveConnection(gi.UUID)
134+
defer cs.connTracker.RemoveConnection(grpcInfo.UUID)
135135

136136
// wait for the agent to report itself and nginx
137-
conn, deployment, err := cs.waitForConnection(ctx, gi)
137+
conn, deployment, err := cs.waitForConnection(ctx, grpcInfo)
138138
if err != nil {
139139
cs.logger.Error(err, "error waiting for connection")
140140
return err
141141
}
142-
defer deployment.RemovePodStatus(gi.UUID)
142+
defer deployment.RemovePodStatus(grpcInfo.UUID)
143143

144144
cs.logger.Info(
145145
"Successfully connected to nginx agent",
146146
conn.ParentType, conn.ParentName,
147-
"uuid", gi.UUID,
147+
"uuid", grpcInfo.UUID,
148148
)
149149

150150
msgr := messenger.New(in)
151151
go msgr.Run(ctx)
152152

153153
// apply current config before starting event loop
154-
if err := cs.setInitialConfig(ctx, &gi, deployment, conn, msgr); err != nil {
154+
if err := cs.setInitialConfig(ctx, &grpcInfo, deployment, conn, msgr); err != nil {
155155
return err
156156
}
157157

@@ -193,7 +193,7 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
193193
cs.logger.V(1).Info("Sending configuration to agent", "requestType", msg.Type)
194194
if err := msgr.Send(ctx, req); err != nil {
195195
cs.logger.Error(err, "error sending request to agent")
196-
deployment.SetPodErrorStatus(gi.UUID, err)
196+
deployment.SetPodErrorStatus(grpcInfo.UUID, err)
197197
channels.ResponseCh <- struct{}{}
198198

199199
return grpcStatus.Error(codes.Internal, err.Error())
@@ -203,8 +203,8 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
203203
// Only broadcast operations should signal ResponseCh for coordination.
204204
pendingBroadcastRequest = &msg
205205
case err = <-msgr.Errors():
206-
cs.logger.Error(err, "connection error", conn.ParentType, conn.ParentName, "uuid", gi.UUID)
207-
deployment.SetPodErrorStatus(gi.UUID, err)
206+
cs.logger.Error(err, "connection error", conn.ParentType, conn.ParentName, "uuid", grpcInfo.UUID)
207+
deployment.SetPodErrorStatus(grpcInfo.UUID, err)
208208
select {
209209
case channels.ResponseCh <- struct{}{}:
210210
default:
@@ -225,9 +225,9 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
225225
continue
226226
}
227227
err := fmt.Errorf("msg: %s; error: %s", res.GetMessage(), res.GetError())
228-
deployment.SetPodErrorStatus(gi.UUID, err)
228+
deployment.SetPodErrorStatus(grpcInfo.UUID, err)
229229
} else {
230-
deployment.SetPodErrorStatus(gi.UUID, nil)
230+
deployment.SetPodErrorStatus(grpcInfo.UUID, nil)
231231
}
232232

233233
// Signal broadcast completion only for tracked broadcast operations.
@@ -239,7 +239,7 @@ func (cs *commandService) Subscribe(in pb.CommandService_SubscribeServer) error
239239
cs.logger.V(1).Info(
240240
"Received response for non-broadcast request (likely initial config)",
241241
conn.ParentType, conn.ParentName,
242-
"uuid", gi.UUID,
242+
"uuid", grpcInfo.UUID,
243243
)
244244
}
245245
}
@@ -537,7 +537,7 @@ func (cs *commandService) UpdateDataPlaneStatus(
537537
return nil, errors.New("empty UpdateDataPlaneStatus request")
538538
}
539539

540-
gi, ok := grpcContext.FromContext(ctx)
540+
grpcInfo, ok := grpcContext.FromContext(ctx)
541541
if !ok {
542542
return nil, agentgrpc.ErrStatusInvalidConnection
543543
}
@@ -547,7 +547,7 @@ func (cs *commandService) UpdateDataPlaneStatus(
547547
return nil, grpcStatus.Errorf(codes.InvalidArgument, "request does not contain nginx instanceID")
548548
}
549549

550-
cs.connTracker.SetInstanceID(gi.UUID, instanceID)
550+
cs.connTracker.SetInstanceID(grpcInfo.UUID, instanceID)
551551

552552
return &pb.UpdateDataPlaneStatusResponse{}, nil
553553
}

internal/controller/nginx/agent/file.go

Lines changed: 6 additions & 6 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.FromContext(ctx)
59+
grpcInfo, ok := grpcContext.FromContext(ctx)
6060
if !ok {
6161
return nil, agentgrpc.ErrStatusInvalidConnection
6262
}
@@ -65,7 +65,7 @@ func (fs *fileService) GetFile(
6565
return nil, status.Error(codes.InvalidArgument, "invalid request")
6666
}
6767

68-
contents, err := fs.getFileContents(req, gi.UUID)
68+
contents, err := fs.getFileContents(req, grpcInfo.UUID)
6969
if err != nil {
7070
return nil, err
7171
}
@@ -84,7 +84,7 @@ func (fs *fileService) GetFileStream(
8484
req *pb.GetFileRequest,
8585
server grpc.ServerStreamingServer[pb.FileDataChunk],
8686
) error {
87-
gi, ok := grpcContext.FromContext(server.Context())
87+
grpcInfo, ok := grpcContext.FromContext(server.Context())
8888
if !ok {
8989
return agentgrpc.ErrStatusInvalidConnection
9090
}
@@ -93,7 +93,7 @@ func (fs *fileService) GetFileStream(
9393
return status.Error(codes.InvalidArgument, "invalid request")
9494
}
9595

96-
contents, err := fs.getFileContents(req, gi.UUID)
96+
contents, err := fs.getFileContents(req, grpcInfo.UUID)
9797
if err != nil {
9898
return err
9999
}
@@ -187,12 +187,12 @@ func (fs *fileService) UpdateOverview(
187187
ctx context.Context,
188188
req *pb.UpdateOverviewRequest,
189189
) (*pb.UpdateOverviewResponse, error) {
190-
gi, ok := grpcContext.FromContext(ctx)
190+
grpcInfo, ok := grpcContext.FromContext(ctx)
191191
if !ok {
192192
return &pb.UpdateOverviewResponse{}, agentgrpc.ErrStatusInvalidConnection
193193
}
194194

195-
conn := fs.connTracker.GetConnection(gi.UUID)
195+
conn := fs.connTracker.GetConnection(grpcInfo.UUID)
196196
if conn.InstanceID == "" {
197197
return &pb.UpdateOverviewResponse{}, status.Errorf(codes.NotFound, "connection not found")
198198
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ func (c ContextSetter) Unary(logger logr.Logger) grpc.UnaryServerInterceptor {
8484
// validateConnection checks that the connection is valid and returns a new
8585
// context containing information used by the gRPC command/file services.
8686
func (c ContextSetter) validateConnection(ctx context.Context) (context.Context, error) {
87-
gi, err := getGrpcInfo(ctx)
87+
grpcInfo, err := getGrpcInfo(ctx)
8888
if err != nil {
8989
return nil, err
9090
}
9191

92-
return c.validateToken(ctx, gi)
92+
return c.validateToken(ctx, grpcInfo)
9393
}
9494

9595
func getGrpcInfo(ctx context.Context) (*grpcContext.GrpcInfo, error) {

0 commit comments

Comments
 (0)