From feb1c8d3fc5dce4002cca03b7d80c158cfb937df Mon Sep 17 00:00:00 2001 From: Mohamed Bana Date: Tue, 6 Sep 2022 17:41:03 +0100 Subject: [PATCH] OAuth2: Dynamic Secrets Code review points: > If V(1) returns a logger, create a variable called debugLog := l.logger.V(1) and then use that. The code can then describe what it is `internal/envoy/manager/envoy_callbacks.go`: Introduce `debugLogger` variable Signed-off-by: Mohamed Bana --- internal/envoy/manager/envoy_callbacks.go | 25 ++++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/internal/envoy/manager/envoy_callbacks.go b/internal/envoy/manager/envoy_callbacks.go index 6e00b1c3..856477e9 100644 --- a/internal/envoy/manager/envoy_callbacks.go +++ b/internal/envoy/manager/envoy_callbacks.go @@ -21,8 +21,6 @@ // SOFTWARE. // Callbacks are called by GRPC server on new events. -// -// `l.logger.V(1)` is effectively debug level. package manager import ( @@ -45,46 +43,49 @@ func NewCallbacks(cacheManager *cacheManager, logger logr.Logger) *Callbacks { } func (c *Callbacks) OnStreamOpen(ctx context.Context, id int64, typeUrl string) error { - c.logger.V(1).Info("OnStreamOpen", "id", id, "typeUrl", typeUrl) + c.logger.Info("OnStreamOpen", "id", id, "typeUrl", typeUrl) return nil } func (c *Callbacks) OnStreamClosed(id int64) { - c.logger.V(1).Info("OnStreamClosed", "id", id) + c.logger.Info("OnStreamClosed", "id", id) } func (c *Callbacks) OnDeltaStreamOpen(ctx context.Context, id int64, typeUrl string) error { - c.logger.V(1).Info("OnDeltaStreamOpen", "id", id, "typeUrl", typeUrl) + debuggerLogger := c.logger.V(1) + debuggerLogger.Info("OnDeltaStreamOpen", "id", id, "typeUrl", typeUrl) return nil } func (c *Callbacks) OnDeltaStreamClosed(id int64) { - c.logger.V(1).Info("OnDeltaStreamClosed", "id", id) + debuggerLogger := c.logger.V(1) + debuggerLogger.Info("OnDeltaStreamClosed", "id", id) } func (c *Callbacks) OnStreamRequest(id int64, request *envoy_discovery_v3.DiscoveryRequest) error { c.logger.Info("OnStreamRequest", "id", id, "request.TypeUrl", request.TypeUrl, "request.Node.Cluster", request.Node.Cluster, "request.Node.Id", request.Node.Id) - return nil } func (c *Callbacks) OnStreamResponse(ctx context.Context, id int64, request *envoy_discovery_v3.DiscoveryRequest, response *envoy_discovery_v3.DiscoveryResponse) { - c.logger.V(1).Info("OnStreamResponse", "id", id, "request.TypeUrl", request.TypeUrl, "response.TypeUrl", response.TypeUrl) + c.logger.Info("OnStreamResponse", "id", id, "request.TypeUrl", request.TypeUrl, "response.TypeUrl", response.TypeUrl, "request.Node.Cluster", request.Node.Cluster, "request.Node.Id", request.Node.Id) } func (c *Callbacks) OnStreamDeltaResponse(id int64, request *envoy_discovery_v3.DeltaDiscoveryRequest, response *envoy_discovery_v3.DeltaDiscoveryResponse) { - c.logger.V(1).Info("OnStreamDeltaResponse", "id", id, "request.TypeUrl", request.TypeUrl, "response.TypeUrl", response.TypeUrl) + debuggerLogger := c.logger.V(1) + debuggerLogger.Info("OnStreamDeltaResponse", "id", id, "request.TypeUrl", request.TypeUrl, "response.TypeUrl", response.TypeUrl) } func (c *Callbacks) OnStreamDeltaRequest(id int64, request *envoy_discovery_v3.DeltaDiscoveryRequest) error { - c.logger.V(1).Info("OnStreamDeltaRequest", "id", id, "request.TypeUrl", request.TypeUrl) + debuggerLogger := c.logger.V(1) + debuggerLogger.Info("OnStreamDeltaRequest", "id", id, "request.TypeUrl", request.TypeUrl) return nil } func (c *Callbacks) OnFetchRequest(ctx context.Context, request *envoy_discovery_v3.DiscoveryRequest) error { - c.logger.V(1).Info("OnFetchRequest", "request.TypeUrl", request.TypeUrl) + c.logger.Info("OnFetchRequest", "request.TypeUrl", request.TypeUrl, "request.Node.Cluster", request.Node.Cluster, "request.Node.Id", request.Node.Id) return nil } func (c *Callbacks) OnFetchResponse(request *envoy_discovery_v3.DiscoveryRequest, response *envoy_discovery_v3.DiscoveryResponse) { - c.logger.V(1).Info("OnFetchResponse", "request.TypeUrl", request.TypeUrl, "response.TypeUrl", response.TypeUrl) + c.logger.Info("OnFetchResponse", "request.TypeUrl", request.TypeUrl, "response.TypeUrl", response.TypeUrl, "request.Node.Cluster", request.Node.Cluster, "request.Node.Id", request.Node.Id) }