refactor: use shared code for IAM based authenticators#118
Conversation
Codecov Report
@@ Coverage Diff @@
## main #118 +/- ##
==========================================
+ Coverage 98.77% 98.92% +0.14%
==========================================
Files 18 20 +2
Lines 737 746 +9
==========================================
+ Hits 728 738 +10
+ Misses 9 8 -1
Continue to review full report at Codecov.
|
|
I am thinking about one more thing that could improve the project structure: put all the token managers into a single directory, just like the authenticators. Not sure would this break anything or not, I only found this. |
if you move the token manager files to a new "token_managers" directory, couldn't you just update the |
There was a problem hiding this comment.
Looks good! I spotted one minor thing that needs to be changed but I'll approve now to avoid a re-review. It looks like this refactoring work will greatly reduce the amount of new code needed for the ContainerAuthenticator and (later on) the VPCInstanceAuthenticator. I've found the same thing in the Java core as well and I suspect @dpopp07 is seeing the same in the Node core. @dpopp07 Thank you for the idea to do this refactoring :)
| Attributes: | ||
| token_manager (TokenManager): Retrives and manages IAM tokens from the endpoint specified by the url. | ||
| """ | ||
| authentication_type = 'iam' |
There was a problem hiding this comment.
This won't apply to all IAM-based authenticators, so it probably belongs only in the IamAuthenticator class.
dpopp07
left a comment
There was a problem hiding this comment.
I second Phil's comment but otherwise, looks good! 👍
More info:
- Surround top-level function and class definitions with two blank
lines: https://www.python.org/dev/peps/pep-0008/#blank-lines
- Imports grouping and ordering:
https://www.python.org/dev/peps/pep-0008/#imports
|
I've pushed More info:
(Since there is a lot of changes (number of files) in the last commit, it makes the overall diff a bit messy, sorry for that! I didn't want to create a separate PR for this.) |
| """ | ||
| headers = { | ||
| 'Content-type': 'applicaton/x-www-form-urlencoded', | ||
| 'Content-type': 'application/x-www-form-urlencoded', |
There was a problem hiding this comment.
wow, the misspelled "applicaton" didn't cause a problem before??? :)
There was a problem hiding this comment.
I was surprised too! The container authenticator tests will cover this, so I didn't change the tests here.
|
🎉 This PR is included in version 3.11.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |

This PR introduces two new classes:
IAMRequestBasedTokenManagerandIAMRequestBasedAuthenticator. These contain common functionalities for IAM auth based flows.I haven't changed the tests on purpose. (Well, there is a minor change to fix the codecov patch check). The reason is to make sure that no interface change has been made, so everything is working just like before.