Skip to content

Commit

Permalink
PR Review
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Silverio <[email protected]>
  • Loading branch information
jsilverio22 committed Mar 3, 2023
1 parent 9dd316b commit 704b51c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,21 @@ func (c *serviceAccountCache) Get(name, namespace string) (role, aud string, use
var respSA *CacheResponse
{
respSA = c.getSA(name, namespace)
klog.V(5).Infof("Service account %s/%s not found in cache", namespace, name)
if respSA != nil && respSA.RoleARN != "" {
return respSA.RoleARN, respSA.Audience, respSA.UseRegionalSTS, respSA.TokenExpiration, nil
}
}
{
resp := c.getCM(name, namespace)
if resp != nil {
return resp.RoleARN, resp.Audience, resp.UseRegionalSTS, resp.TokenExpiration, nil
respCM := c.getCM(name, namespace)
if respCM != nil {
return respCM.RoleARN, respCM.Audience, respCM.UseRegionalSTS, respCM.TokenExpiration, nil
}
}
//if no mutation is needed due to annotations return nil err to allow request through
if respSA != nil && respSA.RoleARN == "" {
return "", "", false, pkg.DefaultTokenExpiration, nil
if respSA == nil {
return "", "", false, pkg.DefaultTokenExpiration, fmt.Errorf("service account %s/%s not found in cache and one is expected", namespace, name)
}
return "", "", false, pkg.DefaultTokenExpiration, fmt.Errorf("service account %s/%s not found in cache and one is expected", namespace, name)

return "", "", false, pkg.DefaultTokenExpiration, nil
}

func (c *serviceAccountCache) getSA(name, namespace string) *CacheResponse {
Expand Down

0 comments on commit 704b51c

Please sign in to comment.