-
Notifications
You must be signed in to change notification settings - Fork 114
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 a Krane CLI with one command #524
Conversation
6ffc725
to
df12046
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.
I just need some clarification on the __FILE__ == $PROGRAM_NAME
logic in exe/krane
since it wasn't quite working as I would have expected.
Oops, didn't notice the failed CI before I 👍 but it's just a simple rubocop fix |
Changes since I approved, going to start review over
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 had a look at this yesterday and chatted with Danny. Here's a quick summary of my thoughts:
- I'm not a big fan of concerns, especially when they aren't being introduced to allow code reuse. In this case we're basically just using them to hide the code in another file. Let's make proper objects instead if we want to separate pieces of the code. I played around a bit, and this is my suggestion for an alternative: cli...knverey_cli (I'm not suggesting adding the deploy task in the same PR btw--just trying to get a feel for how something larger would look).
- I noticed while playing around with the branch that Thor automatically introduces two versions for boolean arguments, e.g. if you add
--prune
you also get--no-prune
. That's not according to plan, but I'm fine with it. - I also noticed that
-f path/to/file -f path/to/other
ends up with justpath/to/other
in the filename option. Maybe I'm doing something wrong, but that could be a problem. Let's confirm whether this works before merging anything with Thor. If it doesn't, you'll need to make a call on whether that's a dealbreaker (or maybe it could be PR'd upstream?). - With a single CLI, we're always immediately loading all of our code, and that is visibly slow. Especially when all you're trying to do is print the help for a command. We should make sure the way we structure our code leaves us options for speeding this up. The obvious/easy/sketchy way would be to move the actual requires right into the command-invoking methods (or the thing they call). Maybe there's a better way though.
- Danny and I talked about having a blackbox test for each command that invokes the actual executable and basically just checks exit codes.
- Seeing an
instance_variable_set
anywhere is always a red flag for me (ivars are very internal details of a class!), but it is true that we have no way to inject a logger in this case. In theory the CLI classes themselves should not need to use our fancy logger though. Most of the time they shouldn't be printing anything at all themselves (version may be the one exception). Since these classes are getting their own small test suite, I'd suggest considering using the standardcapture_io
methods and running that suite in serial (those methods aren't threadsafe IIIRC). Here's an example that wrapscapture_io
to continue to provide thePRINT_LOGS
option and expose the logs to helpers.
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.
Overall this makes sense to me. I imagine we'll learn more as we start adding more commands, but this seems like a proper start. Just a few small outstanding questions before I ✅
e8be4f7
to
1e05e7b
Compare
@@ -0,0 +1,5 @@ | |||
# frozen_string_literal: true | |||
require 'kubernetes-deploy/common' |
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.
This is a partial optimization to make loading time faster. If we require kubernetes-deploy
it takes about 0.8 seconds to print the krane help
. As is about 0.4 and if we require nothing 0.3. I feel like this strikes a good balance between not feeling to slugish to print help but not having to cherry pick exactly what we want when want it.
This is ready for 👀 though I don't want to merge it till after the |
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 to me
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 to me!
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.
What are you trying to accomplish with this PR?
Start down the road of adding a new CLI
Krane
. Our first step is addingkrane version
See #256 for lots of details
How is this accomplished?
We've picked
Thor
to help make the cli as easy as possible. We've pickedversion
to be the first command because it's just about trivial.What could go wrong?
Its new code, so the only real issue is if the dependency causes people headaches.
CLI
A fun question here is what exactly should the output be. I looked at
kubectl
,ruby
,node
,bash
, andgrep
and each of these prints something different. Most are of the formprogram_name version_string
. So that's what I went for.