git demo snap update - Bug 1595229 #593

Closed
wants to merge 7 commits into
from

Conversation

Projects
None yet
6 participants

stub42 commented Jun 22, 2016

Addresses https://bugs.launchpad.net/snapcraft/+bug/1595229

Adds the 'home' plug to the snap and documentation on how to use it.

stub42 added some commits Jun 22, 2016

Can one of the admins verify this patch?

Can one of the admins verify this patch?

@@ -14,3 +14,4 @@ dist
htmlcov
__pycache__
docs/**.html
+*~
@elopio

elopio Jun 24, 2016

Member

thank you :)

demos/git/README.md
+snap connect git:home ubuntu-core:home
+```
+
+Only access the home directory is granted. You can see this containment
@elopio

elopio Jun 24, 2016

Member

*Only access TO the home ...
I think we should explain the type of access. From snapd's docs: Can access non-hidden files in user's $HOME to read/write/lock.

@stub42

stub42 Jun 24, 2016

Fixed the grammar. I didn't explain about hidden files as I don't know what snappy considers hidden files - dotfiles seem to work just fine.

demos/git/README.md
+fatal: Could not change back to '/tmp/foo': No such file or directory
+```
+
+Files repositories in your home directory work fine:
@elopio

elopio Jun 24, 2016

Member

there's an error here, but I'm not sure what you were trying to say.
Maybe: Initializing repositories in your...

demos/git/README.md
+Files repositories in your home directory work fine:
+```sh
+$ mkdir -p ~/tmp/foo
+$ cd ~/tmp/foo
@elopio

elopio Jun 24, 2016

Member

I think it would be a nice touch to use $HOME instead of ~. Don't you think?

demos/git/README.md
+$ mkdir -p ~/tmp/foo
+$ cd ~/tmp/foo
+$ /snap/bin/git init
+Initialized empty Git repository in /home/stub/tmp/foo/.git/
@elopio

elopio Jun 24, 2016

Member

I would replace stub with

@stub42

stub42 Jun 24, 2016

Changed to ubuntu, per default user name on our images.

demos/git/snapcraft.yaml
command: bin/git
+ # git will now have access to files outside of its containment
+ # until you run the following command after installing the snap:
+ # snap connect git:home ubuntu-core:home
@elopio

elopio Jun 24, 2016

Member

What about:
git will have access to files in the user's home directory when you run ...

@stub42

stub42 Jun 24, 2016

I like emphasising access is contained by default. Requiring users to manually connect the home interface is a security measure and not a meaningless chore. I'm extended the text a bit to make things clearer.

Member

elopio commented Jun 24, 2016

I like this. I would like to get @didrocks to look at it, because maybe in his plans for the tour and the website there's an explanation of the home interface. In that case we could get rid of this demo, and move everything you wrote to the tour. If it's not in his short-term plans, lets land this one.

And this is missing a test. Take a look at the ones in snaps_tests/demos_tests and see how we can run the connect command, and then verify that the snap is working. Let me know if you need a hand with this.

Can one of the admins verify this patch?

Can one of the admins verify this patch?

Contributor

didrocks commented Jun 24, 2016

Agreed with Leo, this demo is becoming redondant once the tour/documentation will talk more about plugs. However, this isn't going to be released short term, so +1 on shipping something like this.

stub42 added some commits Jun 24, 2016

Collaborator

sergiusens commented Jun 24, 2016

retest this please
ok to test

Can one of the admins verify this patch?

Can one of the admins verify this patch?

+ 'git:home', 'ubuntu-core:home'])
+ self.assertTrue(
+ self.snappy_testbed.run_command(['/snap/bin/git',
+ '--version']).startswith('git'))
@elopio

elopio Jun 24, 2016

Member

Thanks for adding the test!
But I was thinking that you could do something like:
self.snappy_testbed.run_command(['mkdir', '-p', '$HOME/tmp/foo'])
self.snappy_testbed.run_command(['/snap/bin/git', 'init', '$HOME/tmp/foo'])

This might need some more work on the run helpers. I'm around to help.

Also, now that this is more extensively tested, would you mind removing the scenario in snaps_tests/demos/tests.py?

stub42 added some commits Jun 27, 2016

stub42 commented Jun 27, 2016

Confirming that the 'home' interface does what it claims does not need to be part of this test, so I'd rather leave it like it is than pollute $HOME with temp directories.

Or is this sandboxed somehow and I don't have to worry about cleaning up $HOME safely and reliably?

I have removed the redundant test in snaps_tests/demos/tests.py

@stub42 stub42 closed this Jun 27, 2016

@stub42 stub42 reopened this Jun 27, 2016

Can one of the admins verify this patch?

Can one of the admins verify this patch?

Member

elopio commented Jul 5, 2016

The home is not sandboxed. You would have to rm anything you put in there to leave it clean.
We could make it a fixture, to be called by all tests if it becomes ugly.
I am ok with this test checking that the home interface works too. I see this suite as testing the integration with ubuntu and snapd, so checking that if we declare an interface in the snapcraft.yaml, then the snap won't work until we connect that interface is a nice test for me. Of course, there are downsides to this, feel free to disagree :) Also, one can argue that a test called git shouldn't be where we place an interface test, that's why I'm so happy about the tour work, as it documents and tests the features progressively and independently.

I will leave you my 👍 here, as this is clearly way better than before. And I'm waiting to hear your opinion on my comments. We can push many things for later, reporting bugs for them.

Can one of the admins verify this patch?

Can one of the admins verify this patch?

stub42 commented Jul 5, 2016

The test seems to be legitimately failing, and I haven't got them running locally yet to debug.

Member

elopio commented Aug 3, 2016

Can you please resolve the conflict so we can take a look at the failing test?

Can one of the admins verify this patch?

Can one of the admins verify this patch?

Member

kyrofa commented Aug 12, 2016

There seems to be little activity here. I'll go ahead and close this for now-- feel free to reopen once it's ready to progress.

@kyrofa kyrofa closed this Aug 12, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment