Skip to content

Commit

Permalink
OAuth2: Dynamic Secrets
Browse files Browse the repository at this point in the history
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 <mohamed@bana.io>
  • Loading branch information
mbana committed Sep 6, 2022
1 parent 03f91e9 commit feb1c8d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions internal/envoy/manager/envoy_callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)
}

0 comments on commit feb1c8d

Please sign in to comment.