-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add lineage attribute across commands #1128
Conversation
I'm concerned about mandating changes to every instantiation of command objects throughout our codebase. Seems like it's easy to miss one. I also think this clutters the Is there a reason we can't just do this dynamically and fill in this value during the building of the command table (without requiring them at instantiation time)? We know the parents during the building process. Also, I think it would be more valuable to just have the parents be a list of the command objects themselves. You can always access the |
@jamesls The hardest part was trying to pass in the parents for custom commands that hooked in via the event system (there was not really a way to do that at instantiation without passing it through I also like the idea that we just pass the command objects for its lineage. The only thing that we will have to work on is decreasing the lack of parity between the various command objects (which is a goal of ours). For example, the operation object does not have a |
Yeah, sorry, after the event is fired was what I meant. If we just created a property on the command objects we set after we were done firing the command table event, then every command would automatically get this populated. Also I'd be in favor of having a more consistent interface between the custom commands and the stuff in clidriver. Adding a name property would be great. |
2126ce9
to
3ea31ef
Compare
4bd57fa
to
940a006
Compare
940a006
to
8d15a4a
Compare
Sorry for all of the coveralls comments. These are real weird. The main reason it drops so much in the latest comment is because of s3 but I did not touch that module. Then sometimes it does not drop such as in the comment above it. In the end there are a few lines that I do miss and that involves not hitting some of the getters and modifiers for the properties that I added in the cli driver. Do I need tests for those? I noticed that we do not test the attributes of the service and operation command anywhere else in @jamesls Let me know what you think. It is ready to get looked at again. |
@kyleknap I'd prefer to add tests. The fact that we didn't previously test the properties doesn't really seem like that good of a reason to not test the new properties. Seems like it would pretty simple tests anyways. |
@jamesls Cool. The tests seemed a little out of place at first because most of the tests in Note that coveralls is still saying that my coverage dropped. However, all of the lines that I added are covered. I even covered some previous lines that were missing before in Let me know what you think. |
def test_load_lineage(self): | ||
self.assertEqual(self.command.lineage, [self.command]) | ||
|
||
def test_pass_lineage_to_child_command(self): |
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.
Can't we do this without patching by just creating a new command class that has subcommands instead of using the BasicCommand
instance? I'd prefer to avoid mocking these types of calls especially if they don't need to be.
What about adding an integration test that works on a servicecommand/serviceoperation instance as well as a custom command? That way we can verify these values on actual real world commands? Otherwise looks good, I much prefer this approach. Thanks for updating. |
For example (not sure what we'd need to do to get this into an integration test harness) but something along these lines:
|
@jamesls I incorporated your feedback and added integration test in my latest commit. |
Looks great, thanks for updating. |
Add lineage attribute across commands
* chore(version): set 0.14.3.dev1 version (aws#1112) (aws#1113) * Depend on development version of lambda-builders for dev builds (aws#1111) * Depend on development version of lambda-builders for dev builds * Adding prod.txt to manifest * Splitting dev and tool dependencies * fix(build): Resolve path after .aws-sam is created (aws#1110) * fix(build): Resolve path after .aws-sam is created * fix: build (make pr) * Design and implementation for producing debug build artifacts (aws#1095) * design: Initial Design for producing debug artifacts * initial implementation * Adding unit tests * Integration test with debug build mode * Adjust Design doc and add keyword arg to a call * fix(dotnet): init template fixes (aws#1117) * chore(version): set 0.15.0 (aws#1125) * Revert "Depend on development version of lambda-builders for dev builds (aws#1111)" (aws#1128) This reverts commit 7e9de790e23791ba176faff2030286db4007e503. * Bumping to Lambda Builders 0.3.0 (aws#1129) Bumping to Lambda Builders 0.3.0 * fix(func-tests): add dependency manager param (aws#1130)
For each of the command classes, a
lineage
attribute was added. The purpose of thelineage
attribute is to be able to tell how to get to a specific command came from in the CLI. Thelineage
attribute is represented by a list of all of the commands that came before that specific command (in order) including the command itself. So for these commands, here are their lineages:aws ec2
--> ['ec2'
]aws ec2 run-instances
--> ['ec2'
,run-instances'
]aws s3 ls
--> ['s3'
,'ls'
]aws s3api wait object-exists
--> ['s3api'
,'wait'
,'object-exists'
]This attribute helps unify the data-driven and custom commands because you can see how commands are linked together. Before, figuring out how to get to a command tended to be a little difficult and unreliable because the logic in figuring it out differed across command class and sometimes would require parsing event names.
I did my best to plumb this through to all of the custom commands, but if I missed one, let me know.
cc @jamesls @danielgtaylor