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

Refactor configuration loading to parse profile files only once #2152

Merged
merged 7 commits into from
Jan 3, 2023

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Dec 30, 2022

Motivation and Context

Description

  1. Refactor to only parse profile files once in a lazy async cell
  2. Support setting the profile name and profile file at a SdkConfig level instead of for each provider.

Testing

  • UT

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@rcoh rcoh force-pushed the config-profile-refactor branch from b905766 to c0080e0 Compare December 30, 2022 21:08
@rcoh rcoh marked this pull request as ready for review December 30, 2022 21:08
@rcoh rcoh requested review from a team as code owners December 30, 2022 21:08
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

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

LGTM! I like how parsing profile files is now single-sourced in ProviderConfig.

/// .load()
/// .await;
/// # }
pub fn profile_name(mut self, profile_name: impl Into<String>) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

/// This **does not set** the HTTP connector used when sending operations. To change that
/// connector, use [ConfigLoader::http_connector].
///
/// NOTE: Update the provider config with care because it will override any other settings.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we be more specific about what this will override? I'm wondering if we should rename ProviderConfig to better highlight the stuff it provides. I'm thinking of something like this:

  • OsProvider
  • PlatformProvider
  • SystemProvider

match AppName::new(app_id.to_owned()) {
Ok(app_name) => Some(app_name),
Err(err) => {
tracing::warn!(err = %err, "`sdk-ua-app-id` property `{}` was invalid", app_id);
Copy link
Contributor

@Velfi Velfi Jan 3, 2023

Choose a reason for hiding this comment

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

If possible, we should consider the following:

  • add a call to action here that tells people how to fix this or stop the warning
  • explain to users what value will be used instead
  • explain to users how this may affect logging of requests
  • explain why you would want to set this
  • explain what makes an app ID invalid

We could perhaps link users to docs, but I couldn't find any that described this field.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

%err will include details so this should be OK

&& profile_set.selected_profile() == "default"
&& profile_set.get_profile("default").is_none()
{
if profile_set.selected_profile() == "default" && profile_set.get_profile("default").is_none() {
tracing::debug!("No default profile defined");
return Err(ProfileFileError::NoProfilesDefined);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for a user to have other profiles but they forgot to set the profile name? If so, then I think this error could be improved. It's not so much that no profiles were defined but that the selected profile (default) couldn't be found.

@rcoh rcoh force-pushed the config-profile-refactor branch from c0080e0 to 02af1b5 Compare January 3, 2023 16:17
@github-actions
Copy link

github-actions bot commented Jan 3, 2023

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh force-pushed the config-profile-refactor branch from 174e066 to be5b69e Compare January 3, 2023 18:26
@github-actions
Copy link

github-actions bot commented Jan 3, 2023

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh merged commit 88afcf8 into main Jan 3, 2023
@rcoh rcoh deleted the config-profile-refactor branch January 3, 2023 19:37
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.

Profile File Refactoring
3 participants