Skip to content

Commit

Permalink
Deal with cacheKey creation failures
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Snaps <[email protected]>
  • Loading branch information
alexsnaps committed Oct 24, 2024
1 parent 49c9c42 commit 613c9b5
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
10 changes: 6 additions & 4 deletions pkg/evaluators/authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ func (config *AuthorizationConfig) Call(pipeline auth.AuthPipeline, ctx context.

if cache != nil {
cacheKey, _ = cache.ResolveKeyFor(pipeline.GetAuthorizationJSON())
if cachedObj, err := cache.Get(cacheKey); err != nil {
logger.V(1).Error(err, "failed to retrieve data from the cache")
} else if cachedObj != nil {
return cachedObj, nil
if cacheKey != nil {
if cachedObj, err := cache.Get(cacheKey); err != nil {
logger.V(1).Error(err, "failed to retrieve data from the cache")
} else if cachedObj != nil {
return cachedObj, nil
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/evaluators/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,12 @@ func (config *IdentityConfig) Call(pipeline auth.AuthPipeline, ctx context.Conte

if cache != nil {
cacheKey, _ = cache.ResolveKeyFor(pipeline.GetAuthorizationJSON())
if cachedObj, err := cache.Get(cacheKey); err != nil {
logger.V(1).Error(err, "failed to retrieve data from the cache")
} else if cachedObj != nil {
return cachedObj, nil
if cacheKey != nil {
if cachedObj, err := cache.Get(cacheKey); err != nil {
logger.V(1).Error(err, "failed to retrieve data from the cache")
} else if cachedObj != nil {
return cachedObj, nil
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/evaluators/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ func (config *MetadataConfig) Call(pipeline auth.AuthPipeline, ctx context.Conte

if cache != nil {
cacheKey, _ = cache.ResolveKeyFor(pipeline.GetAuthorizationJSON())
if cachedObj, err := cache.Get(cacheKey); err != nil {
logger.V(1).Error(err, "failed to retrieve data from the cache")
} else if cachedObj != nil {
return cachedObj, nil
if cacheKey != nil {
if cachedObj, err := cache.Get(cacheKey); err != nil {
logger.V(1).Error(err, "failed to retrieve data from the cache")
} else if cachedObj != nil {
return cachedObj, nil
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/evaluators/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ func (config *ResponseConfig) Call(pipeline auth.AuthPipeline, ctx context.Conte

if cache != nil {
cacheKey, _ = cache.ResolveKeyFor(pipeline.GetAuthorizationJSON())
if cachedObj, err := cache.Get(cacheKey); err != nil {
logger.V(1).Error(err, "failed to retrieve data from the cache")
} else if cachedObj != nil {
return cachedObj, nil
if cacheKey != nil {
if cachedObj, err := cache.Get(cacheKey); err != nil {
logger.V(1).Error(err, "failed to retrieve data from the cache")
} else if cachedObj != nil {
return cachedObj, nil
}
}
}

Expand Down

0 comments on commit 613c9b5

Please sign in to comment.