-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
command/logout: Add terraform logout command #24048
Conversation
7fe6e95
to
91ca9e5
Compare
Use terraform logout to remove stored credentials for a remote service host.
73761e5
to
325f8a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great overall! I think I found a potential panic but I also may be misreading the code
} | ||
} | ||
|
||
if credsCtx.Location == cliconfig.CredentialsInOtherFile { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if credsCtx
is nil, this will panic, and it sounds like that's not impossible .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot!
Unless I'm missing something, I think it actually was impossible. Despite the comments, the services were always initialized with a cliconfig.CredentialsSource
, both in real code and tests. (This code was cargo culted from the login command, which is why I'm unsure.)
So in 7ff5878 I've removed the check (for both login and logout) and replaced it with a type assertion. I'm not 100% sure this is the right move, but tests pass and the commands work, and at least this way the panic will happen on a more useful line 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha! That is an excellent step forward - As you said, if it happens out in the wild, we'll know when and where 😁
The type assertion checks on the credentials source are unnecessary, and the alternative code path they allow would panic.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Use
terraform logout
to remove stored credentials for a remote service host. This is the corresponding command toterraform login
.Screenshots
Normal successful usage:
For a specific hostname (e.g. a TFE instance):
Using a credentials helper:
When attempting to remove credentials which were manually configured (e.g. in
~/.terraformrc
):If the credentials helper fails:
When already logged out: