Skip to content

Commit

Permalink
feat: remove CF auth to avoid delay of 60s for nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
dpittner authored and hkantare committed Mar 4, 2024
1 parent 846cff3 commit 69a5d24
Showing 1 changed file with 2 additions and 28 deletions.
30 changes: 2 additions & 28 deletions ibm/conns/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,20 +1324,8 @@ func (c *Config) ClientSession() (interface{}, error) {
session.functionConfigErr = fmt.Errorf("[ERROR] Error occured while fetching auth key for function: %q", err)
}
}
err = authenticateCF(sess.BluemixSession)
if err != nil {
for count := c.RetryCount; count >= 0; count-- {
if err == nil || !isRetryable(err) {
break
}
time.Sleep(c.RetryDelay)
log.Printf("Retrying CF Authentication %d", count)
err = authenticateCF(sess.BluemixSession)
}
if err != nil {
session.functionConfigErr = fmt.Errorf("[ERROR] Error occured while fetching auth key for function: %q", err)
}
}

session.functionConfigErr = fmt.Errorf("[ERROR] Error occured while fetching auth key for function: %q", err)
}

if c.IAMTrustedProfileID == "" && sess.BluemixSession.Config.IAMAccessToken != "" && sess.BluemixSession.Config.BluemixAPIKey == "" {
Expand Down Expand Up @@ -3406,20 +3394,6 @@ func authenticateAPIKey(sess *bxsession.Session) error {
return tokenRefresher.AuthenticateAPIKey(config.BluemixAPIKey)
}

func authenticateCF(sess *bxsession.Session) error {
config := sess.Config
tokenRefresher, err := authentication.NewUAARepository(config, &rest.Client{
DefaultHeader: gohttp.Header{
"User-Agent": []string{http.UserAgent()},
"X-Original-User-Agent": []string{http.UserAgent()},
},
})
if err != nil {
return err
}
return tokenRefresher.AuthenticateAPIKey(config.BluemixAPIKey)
}

func fetchUserDetails(sess *bxsession.Session, retries int, retryDelay time.Duration) (*UserConfig, error) {
config := sess.Config
user := UserConfig{}
Expand Down

0 comments on commit 69a5d24

Please sign in to comment.