-
Notifications
You must be signed in to change notification settings - Fork 16
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
Update parsing logic to include sso-session #24
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #24 +/- ##
==========================================
+ Coverage 67.75% 68.20% +0.44%
==========================================
Files 9 9
Lines 2562 2585 +23
==========================================
+ Hits 1736 1763 +27
+ Misses 826 822 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
include/aws/sdkutils/aws_profile.h
Outdated
AWS_SDKUTILS_API | ||
const struct aws_profile *aws_profile_collection_get_sso_session( | ||
const struct aws_profile_collection *profile_collection, | ||
const struct aws_string *profile_name); |
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.
profile_name
name
, session_name
, identifier
, id
, session_id
???
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.
Thanks, I have updated it to a generic function.
include/aws/sdkutils/aws_profile.h
Outdated
* Returns the number of sso-sessions in a collection | ||
*/ | ||
AWS_SDKUTILS_API | ||
size_t aws_profile_collection_get_sso_session_count(const struct aws_profile_collection *profile_collection); |
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.
should we have a generic api that can return map of all values for a given section type and name?
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.
Thanks, fixed.
source/aws_profile.c
Outdated
|
||
if (element == NULL) { | ||
struct aws_hash_element *profile = NULL; | ||
aws_hash_table_find(&collection->sections, profile_name, &profile); |
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.
nit: hash table find seems inconsistent. first one checks for error, second one ignores it
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.
Thanks, fixed by refactor.
@@ -895,6 +991,16 @@ static bool s_parse_profile_declaration( | |||
return true; | |||
} | |||
|
|||
s_parse_by_character_predicate(&profile_cursor, s_is_whitespace, NULL, 0); | |||
} else if (has_sso_session_prefix) { | |||
if (context->profile_collection->profile_source == AWS_PST_CREDENTIALS) { |
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 we dont allow profiles or other section types in cred files, do we need to have that check inside of specific section type if
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.
Not sure how to improve this, as a profile can be valid without any prefix. This is only invalid if there was a prefix other than profile, and the source is CREDENTIALS.
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.
fix & ship
include/aws/sdkutils/aws_profile.h
Outdated
const struct aws_profile *aws_profile_collection_get_section( | ||
const struct aws_profile_collection *profile_collection, | ||
const struct aws_string *section_name, | ||
const enum aws_profile_section_type section_type); |
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.
trivial: put type before name. It just makes more sense
const struct aws_profile *aws_profile_collection_get_section( | |
const struct aws_profile_collection *profile_collection, | |
const struct aws_string *section_name, | |
const enum aws_profile_section_type section_type); | |
const struct aws_profile *aws_profile_collection_get_section( | |
const struct aws_profile_collection *profile_collection, | |
const enum aws_profile_section_type section_type, | |
const struct aws_string *section_name); |
@@ -99,12 +109,29 @@ const struct aws_profile *aws_profile_collection_get_profile( | |||
const struct aws_profile_collection *profile_collection, | |||
const struct aws_string *profile_name); | |||
|
|||
/* | |||
* Retrieves a reference to a section with the specified name and type, if it exists, from the profile collection. |
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.
mention somewhere that you can get the "default" profile by passing AWS_PROFILE_SECTION_TYPE_PROFILE, "default"
source/aws_profile.c
Outdated
@@ -620,7 +641,8 @@ static int s_profile_collection_add_profile( | |||
const struct aws_byte_cursor *profile_name, | |||
bool has_prefix, | |||
const struct profile_file_parse_context *context, | |||
struct aws_profile **current_profile_out) { | |||
struct aws_profile **current_profile_out, | |||
const enum aws_profile_section_type section_type) { |
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.
similar to earlier comment, move section_type
arg so that it comes before profile_name
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.
also, debatable, but does it make to code more clear going forward if we change profile_name -> section_name
or name
?
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.
I think it would be better to stick to one naming scheme instead of mixing and matching.
Co-authored-by: Michael Graeb <graebm@amazon.com>
Description of changes:
Changed the profiles map to an array of sections map so that we can handle sso-sessions, which are a different type of section.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.