-
Notifications
You must be signed in to change notification settings - Fork 441
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
git demo snap update - Bug 1595229 #593
Changes from all commits
c44983e
4776a5e
ab746aa
c18f763
efa3055
95735a0
e8eb79c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,5 @@ dist | |
htmlcov | ||
__pycache__ | ||
docs/**.html | ||
*~ | ||
*.swp |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
This example builds git trunk. It demonstrates the use of the 'home' | ||
plug to allow it access to the users home directory. | ||
|
||
After building and installing the snap, you will need to run the following | ||
command to grant it access to your home directory: | ||
|
||
```sh | ||
snap connect git:home ubuntu-core:home | ||
``` | ||
|
||
Only access to the home directory is granted. You can see this containment | ||
in action by attempting to initialize a repository in /tmp: | ||
|
||
```sh | ||
$ mkdir -p /tmp/foo | ||
$ cd /tmp/foo | ||
$ /snap/bin/git init | ||
fatal: Could not change back to '/tmp/foo': No such file or directory | ||
``` | ||
|
||
Initializing and using repositories in your home directory works fine: | ||
|
||
```sh | ||
$ mkdir -p $HOME/tmp/foo | ||
$ cd $HOME/tmp/foo | ||
$ /snap/bin/git init | ||
Initialized empty Git repository in /home/ubuntu/tmp/foo/.git/ | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,15 @@ description: This example is not really production quality | |
confinement: strict | ||
|
||
apps: | ||
server: | ||
git: | ||
command: bin/git | ||
# git will not 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
# After connecting up the home interface it gains access to | ||
# non-hidden files in home directories. | ||
plugs: | ||
- home | ||
|
||
parts: | ||
git: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*- | ||
# | ||
# Copyright (C) 2016 Canonical Ltd | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 3 as | ||
# published by the Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import snaps_tests | ||
|
||
|
||
class GitTestCase(snaps_tests.SnapsTestCase): | ||
|
||
snap_content_dir = 'git' | ||
|
||
def test_git(self): | ||
self.build_snap(self.snap_content_dir) | ||
self.install_snap(self.snap_content_dir, 'git', '0') | ||
self.snappy_testbed.run_command(['sudo', 'snap', 'connect', | ||
'git:home', 'ubuntu-core:home']) | ||
self.assertTrue( | ||
self.snappy_testbed.run_command(['/snap/bin/git', | ||
'--version']).startswith('git')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for adding the test! 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? |
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.
thank you :)