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

many: implement snapctl command. #1667

Merged
merged 10 commits into from Aug 15, 2016

Conversation

kyrofa
Copy link
Contributor

@kyrofa kyrofa commented Aug 10, 2016

The snapctl command is the method of communication between hooks and snapd. This PR makes more progress on LP: #1586465 by adding the command as well as relevant sections of the REST API, all the way down to the HookManager. The relevant HookManager functionality will be completed in a subsequent PR.

The `snaptool` command is the method of communication between hooks and
snapd. This commit adds the command as well as relevant sections of the
REST API, all the way down to the HookManager. The relevant HookManager
functionality will be completed in a subsequent commit.

Updates: #1586465

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
@niemeyer
Copy link
Contributor

We've agreed online to rename "snaptool" to "snapdo". Suggestions will follow that idea.

}

// RunSnaptool requests a snaptool run for the given context and arguments.
func (client *Client) RunSnaptool(context string, args []string) (stdout string, stderr string, err error) {
Copy link
Contributor

@niemeyer niemeyer Aug 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the new name, we can have client.Do(options) client.SnapCtl(options).

Let's please introduce a DoOptions SnapCtlOptions with Context and Args for now. It'll grow Stdin, and probably evolve further to support files/etc at some point.

Copy link
Contributor

@niemeyer niemeyer Aug 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, as the result, let's please do (stdout, stderr []byte, err error), which is more typical for these values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, snapctl feels nicer. Allows us to have noun getters without it being awkward (e.g. "snapctl plugs" vs. "snapdo plugs"). Will adapt the points made after that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Ah, as the result, let's please do (stdout, stderr []byte, err error), which is more typical for these values.

Note that []byte is json-encoded as a base64 string, so I had to convert shuffle between []byte and string in order to do this.

@niemeyer
Copy link
Contributor

LGTM with those notes.

@kyrofa kyrofa changed the title many: implement snaptool command. many: implement snapctl command. Aug 11, 2016
kyrofa and others added 4 commits August 11, 2016 10:30
Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Signed-off-by: Kyle Fazzari <kyle@canonical.com>
@niemeyer
Copy link
Contributor

LGTM once tests go green. Thanks for the changes.

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
@@ -1,4 +1,5 @@
/usr/bin/snap
/usr/bin/snapctl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we want this in PATH or rather hide it a bit more into e.g. /usr/lib/snapd/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably at least want it in PATH for the hook being executed, since that's where we anticipate it being called (at least for now-- not sure what the long-term vision for this tool is). We could still put it in /usr/lib/snapd/ but then getting it the path would require snap run to add that to the environment. What do you think? @niemeyer do you have any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/usr/lib/snapd sounds a bit nicer, as it means hiding something that unusable for most people, and also having tab-completion on bare "snap" completing the space.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, but agree regarding your point @kyrofa, that we want this in PATH for the hooks. We need to put /usr/lib/snapd in path, or move snapctl inside a subdir there and have that in PATH.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I've put snapctl in /usr/lib/snapd/util, and added that directory to the PATH for both apps and hooks via snap run.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussion on telegram, scratched that-- just put it in /usr/lib/snapd.

@mvo5
Copy link
Contributor

mvo5 commented Aug 15, 2016

Looks good, just one question inline.

kyrofa and others added 3 commits August 15, 2016 09:07
Make sure that directory is in the PATH for hooks and apps.

Signed-off-by: Kyle Fazzari <kyle@canonical.com>
Signed-off-by: Kyle Fazzari <kyle@canonical.com>
@kyrofa kyrofa merged commit 1afe183 into snapcore:master Aug 15, 2016
@kyrofa kyrofa deleted the feature/1586465/snaptool branch August 15, 2016 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants