Rename InstanceCredentialsCache back to InstanceCredentialsProvider (but leave the constructor NewInstanceCredentialsCache because it returns a credentials cache).
Update NewInstanceCredentialsCache to wrap InstanceCredentialsProvider in a cache and return *aws.CredentialsCache.
Change the type of the ecsAgent.credentialsCache field from aws.CredentialsProvider to *aws.CredentialsCache. Foresight has shown me that other parts of our codebase will use ecsAgent.credentialsCache and forcefully expire cached credentials, for which they'll need CredentialsCache.Invalidate. The aws.CredentialsProvider interface does not have an Invalidate method.
Testing
Github checks pass.
New tests cover the changes: no
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Summary
Fix
NewInstanceCredentialsCache
so that it actually wraps the credentials provider in a credentials cache. This is a followup to https://github.com/aws/amazon-ecs-agent/pull/4424#discussion_r1844604109:As you can see in the code snippets below, the returned provider is not wrapped in a cache. https://github.com/aws/amazon-ecs-agent/blob/c24cdaea3e30649fdfbde4906ca964bad49f3126/ecs-agent/credentials/providers/instance_credentials_provider_linux.go#L41-L46
https://github.com/aws/amazon-ecs-agent/blob/c24cdaea3e30649fdfbde4906ca964bad49f3126/ecs-agent/credentials/providers/instance_credentials_provider_windows.go#L76-L78
Implementation details
InstanceCredentialsCache
back toInstanceCredentialsProvider
(but leave the constructorNewInstanceCredentialsCache
because it returns a credentials cache).NewInstanceCredentialsCache
to wrapInstanceCredentialsProvider
in a cache and return*aws.CredentialsCache
.ecsAgent.credentialsCache
field fromaws.CredentialsProvider
to*aws.CredentialsCache
. Foresight has shown me that other parts of our codebase will useecsAgent.credentialsCache
and forcefully expire cached credentials, for which they'll needCredentialsCache.Invalidate
. Theaws.CredentialsProvider
interface does not have anInvalidate
method.Testing
Github checks pass.
New tests cover the changes: no
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.