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
User agent v2 #8664
User agent v2 #8664
Conversation
3acb404
to
0a854e2
Compare
59d60cc
to
f5fa323
Compare
f26fca0
to
1ade664
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.
The implementation looks good. I only had some minor feedback. I plan on taking another pass later to go over the tests, but it's looking good so far.
awscli/utils.py
Outdated
def add_command_lineage_to_user_agent_extra(session, lineage): | ||
# Find existing command metadata and append the last item in the lineage to | ||
# it | ||
if comp := _LINEAGE_COMMAND_METADATA_REGEX.search(session.user_agent_extra): |
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.
Looking at this now, I plan take a deeper look into this to see if we actually need this logic. This is definitely a bit messy and it would be nice if we could avoid it all together.
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.
Circling back on this... So I think this pull request made the chance of the session having the command component less significant: #7399. Specifically, the log will eagerly delegate to the subcommand's __call__
instead of updating the user agent.
That being said there are instances such as s3 rb --force
where a command is called directly:
def _force(self, path, parsed_globals): |
md/command#s3.rb.rm
on the DeleteObject calls).
I think with this knowledge, we can probably just update it to check if md/command
is defined and only add the command if it is not in the user agent. That should help simplify this logic.
404985d
to
42d0b8c
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.
Looks good. Just had a few more comments on the tests.
876386c
to
5edbd23
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.
Looks good! 🚢
Port user agent 2.0 from botocore. Update existing CLI v2 user agent formatting. Moves the source installer and arch to separate metadata: Before: `exe/x86_64` After: `md/installer#exe md/arch#x86_64` Moves the linux distro to separate metadata. Before the linux distro was appended to the source/arch metadata, like `src/x86_64.Ubuntu.18`. Now, since installer and arch are separate, moves distro to `md/distrib#Ubuntu.18`. Updates command lineage from `command/cmd.subcmd` to `md/command#cmd.subcmd`. Updates prompt modefrom `prompt/on` to `md/prompty#on`. Change format for ecs customization user agent from `customization/ecs-deploy` to `md/customization#ecs-deploy`. This is retained because CLI v1 does not include the command lineage. Adds helper methods for setting the user agent to make it easier to alter them in the future. Changes the behavior when adding the command lineage metadata to not assume that it comes at the end of the string. Also it removes the case that if a command lineage is already present to add the last element of the lineage. This is no longer necessary because sub-command parsing always occurs before injecting the user agent string.
d484bf7
to
edb1c40
Compare
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.