Skip to content

Commit

Permalink
address commnet
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK committed May 25, 2023
1 parent ed5ff8d commit fefbab5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions source/aws_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1542,16 +1542,18 @@ AWS_STATIC_STRING_FROM_LITERAL(s_default_profile_env_variable_name, "AWS_PROFILE

struct aws_string *aws_get_profile_name(struct aws_allocator *allocator, const struct aws_byte_cursor *override_name) {
/**
* The default profile must be used if the user does NOT specify a profile.
* the default profile can be overridden using the AWS_PROFILE environment variable.
*/
* Profile name is resolved in the following order.
* 1. If the override_path variable is provided.
* 2. Check `AWS_PROFILE` environment variable and use the value if it is not empty.
* 3. Use "default". */
struct aws_string *profile_name = NULL;
if (override_name != NULL && override_name->ptr != NULL) {
profile_name = aws_string_new_from_array(allocator, override_name->ptr, override_name->len);
} else {
/* Use the default profile. Override the default profile with AWS_PROFILE environment variable if exist */
if (aws_get_environment_value(allocator, s_default_profile_env_variable_name, &profile_name) ||
profile_name == NULL) {
/* Try to fetch profile from AWS_PROFILE environment variable */
aws_get_environment_value(allocator, s_default_profile_env_variable_name, &profile_name);
/* Use default profile if it doesn't exist. */
if (profile_name == NULL) {
profile_name = aws_string_new_from_string(allocator, s_default_profile_name);
}
}
Expand Down

0 comments on commit fefbab5

Please sign in to comment.