-
Notifications
You must be signed in to change notification settings - Fork 521
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
host-ctr: refactoring #1235
host-ctr: refactoring #1235
Conversation
9883a4f
to
210f7d4
Compare
} | ||
|
||
func _main() int { | ||
// Parse command-line arguments | ||
func _main() error { |
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.
Instead of returning the result of having called the command, the cli.App
type should be returned for direct use in testing and have that cli.App.Run
called from the real main
. This gives a little more control to testing entrypoints where Run
can optionally be called.
If that were changed, I'd rename this to func App() cli.App
(App
because it stands out a bit more than app
, not because it needs to exported and because I personally like it :P)
var ( | ||
containerID string | ||
source string | ||
containerdSocket string | ||
namespace string | ||
superpowered bool | ||
pullImageOnly bool | ||
) |
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 want to say change this to not use predeclared vars, but I can't come up with a good reason right now to make it otherwise (using cli.Context.String()
and friends instead). I'm in favor of leaving this as-is for now (Sam and I have debated this before ourselves, I'm ambivalent).
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 like the predeclared vars.
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 like the predeclared vars.
I know, but it's less clear in these circumstances because the two subcommands are each using them. There's not a lot of them and so the scope remains clear for now - I would push on this if there were more at play. For now, I think its reasonable and good to move forward with.
} | ||
|
||
img, err := pullImage(ctx, ref, client) | ||
// Check if the target container already exists. If it does, take over the helm to manage 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.
Can we separate the functional changes from the refactoring changes?
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.
Oh oops. I totally forgot that this came along with my cherry pick.
Refactors `host-ctr`. Organizes functionality into subcommands.
210f7d4
to
553e770
Compare
var ( | ||
containerID string | ||
source string | ||
containerdSocket string | ||
namespace string | ||
superpowered bool | ||
pullImageOnly bool | ||
) |
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 like the predeclared vars.
I know, but it's less clear in these circumstances because the two subcommands are each using them. There's not a lot of them and so the scope remains clear for now - I would push on this if there were more at play. For now, I think its reasonable and good to move forward with.
Issue number:
N/A
Description of changes:
Testing done:
Build image and launched several instances and all host containers came up fine. kubelet running fine, meaning pause container got pulled successfully.
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.