Skip to content

Commit e8b463b

Browse files
committed
pkg/asset/installconfig/aws/permissions: If we can mint, skip passthrough check
Save an API request if we already know we have sufficient authorization.
1 parent df20136 commit e8b463b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/asset/installconfig/aws/permissions.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,17 +210,19 @@ func ValidateCreds(ssn *session.Session) error {
210210
if err != nil {
211211
return errors.Wrap(err, "mint credentials check")
212212
}
213+
if canMint {
214+
return nil
215+
}
213216

214217
// Check whether we can use the current credentials in passthrough mode to satisfy
215218
// cluster services needing to interact with the cloud
216219
canPassthrough, err := credvalidator.CheckCloudCredPassthrough(client, logger)
217220
if err != nil {
218221
return errors.Wrap(err, "passthrough credentials check")
219222
}
220-
221-
if !canMint && !canPassthrough {
222-
return errors.New("AWS credentials cannot be used to either create new creds or use as-is")
223+
if canPassthrough {
224+
return nil
223225
}
224226

225-
return nil
227+
return errors.New("AWS credentials cannot be used to either create new creds or use as-is")
226228
}

0 commit comments

Comments
 (0)