Skip to content
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

Merged
merged 1 commit into from
Dec 9, 2020

Conversation

etungsten
Copy link
Contributor

@etungsten etungsten commented Dec 9, 2020

Issue number:
N/A

Description of changes:

Author: Erikson Tung <etung@amazon.com>
Date:   Fri Dec 4 18:34:07 2020 -0800

    host-ctr: refactoring
    
    Refactors `host-ctr`.
    Organizes functionality into subcommands.

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.

}

func _main() int {
// Parse command-line arguments
func _main() error {
Copy link
Member

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)

Comment on lines 55 to 63
var (
containerID string
source string
containerdSocket string
namespace string
superpowered bool
pullImageOnly bool
)
Copy link
Member

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).

Copy link
Contributor

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.

Copy link
Member

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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.
@etungsten
Copy link
Contributor Author

etungsten commented Dec 9, 2020

Push above removes some of the changes I accidentally picked up from #1230

Tested things and they still work

Also addresses @jahkeup's comments.

Comment on lines 55 to 63
var (
containerID string
source string
containerdSocket string
namespace string
superpowered bool
pullImageOnly bool
)
Copy link
Member

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.

@etungsten etungsten merged commit e8812ae into bottlerocket-os:develop Dec 9, 2020
@etungsten etungsten deleted the host-ctr-refactor branch December 9, 2020 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants