Skip to content
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

fix(aws): enable when using .aws/credentials #4604

Merged
merged 1 commit into from Nov 27, 2022

Conversation

offbyone
Copy link
Contributor

fix(aws): enable when using .aws/credentials


Description

Check in the AWS credentials file for the credential_process in order to enable
the aws module, not just in the .aws/config file (and all related configured
locations for same.)

Motivation and Context

Closes #4603

Screenshots (if appropriate):

How Has This Been Tested?

  • I have tested using MacOS
  • I have tested using Linux
  • I have tested using Windows

Checklist:

  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.

@offbyone offbyone force-pushed the fix-aws-credentials-file branch 3 times, most recently from 8d7e72d to e1edd98 Compare November 14, 2022 19:41
Comment on lines 178 to 181
config_section.contains_key("credential_process")
|| config_section.contains_key("sso_start_url")
|| credential_section.contains_key("credential_process")
|| credential_section.contains_key("sso_start_url"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has_credential_process_or_sso has been mostly concerned with the config file and has_defined_credentials with the credentials file. Given that, please move the has_defined_credentials into has_defined_credentials or change this function to first do the check on the config file and either return on success, or follow up with the credentials file check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't quite feel right to me. That checks for an actual active credential, which in this case would require me to invoke the credential process under the hood... not something we want to do in the prompt. This is just looking for the configuration that enables credentials, in the second place where it can be found. The AWS CLI allows for it to be configured in two places (which is a bad idea, for sure!) but right now Starship only looks in one of them.

If I'm going to change that, I think the name of those methods should change as well. I'll update the PR with the changes from the below, but I think this method's the right place for the code. If you insist otherwise, I'll move it, but it feels wrong to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still prefer If you changed this code to do the checks sequentially, to only read each file based on necessity. But since it looks like they both will be read in most cases either way, keeping it this way would be fine too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my thinking too; the most common configuration will have both files read, so I don't think there's a lot of benefit or optimization in making that more complex. Doubly so because starship caches the read, so it's still pretty safe.

src/modules/aws.rs Show resolved Hide resolved
Copy link
Member

@davidkna davidkna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more or less lgtm

@andytom andytom merged commit c8ac877 into starship:master Nov 27, 2022
@andytom
Copy link
Member

andytom commented Nov 27, 2022

Thank you for your contribution @offbyone and thank you for reviewing @davidkna.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS module not displayed when credential_process is defined in .aws/credentials
3 participants