Skip to content

Commit

Permalink
bring back ownership defaults
Browse files Browse the repository at this point in the history
closes #358
  • Loading branch information
trehn committed Sep 12, 2017
1 parent 895f493 commit 3748352
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
7 changes: 4 additions & 3 deletions bundlewrap/items/directories.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def validator_mode(item_id, value):
"mode for {item} should be three or four digits long, was: '{value}'"
).format(item=item_id, value=value))


ATTRIBUTE_VALIDATORS = defaultdict(lambda: lambda id, value: None)
ATTRIBUTE_VALIDATORS.update({
'mode': validator_mode,
Expand All @@ -45,9 +46,9 @@ class Directory(Item):
"""
BUNDLE_ATTRIBUTE_NAME = "directories"
ITEM_ATTRIBUTES = {
'group': None,
'mode': None,
'owner': None,
'group': 'root',
'mode': 755,
'owner': 'root',
'purge': False,
}
ITEM_TYPE_NAME = "directory"
Expand Down
6 changes: 3 additions & 3 deletions bundlewrap/items/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ class File(Item):
'context': None,
'delete': False,
'encoding': "utf-8",
'group': None,
'mode': None,
'owner': None,
'group': 'root',
'mode': 644,
'owner': 'root',
'source': None,
'verify_with': None,
}
Expand Down
4 changes: 2 additions & 2 deletions bundlewrap/items/symlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Symlink(Item):
"""
BUNDLE_ATTRIBUTE_NAME = "symlinks"
ITEM_ATTRIBUTES = {
'group': None,
'owner': None,
'group': 'root',
'owner': 'root',
'target': None,
}
ITEM_TYPE_NAME = "symlink"
Expand Down
8 changes: 4 additions & 4 deletions docs/content/items/directory.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

directories = {
"/path/to/directory": {
"mode": "0644",
"mode": "0755",
"owner": "root",
"group": "root",
},
Expand All @@ -16,19 +16,19 @@ See also: [The list of generic builtin item attributes](../repo/bundles.md#built

### group

Name of the group this directory belongs to. Defaults to `None` (don't care about group).
Name of the group this directory belongs to. Defaults to `'root'`. Set to `None` if you don't want BundleWrap to change whatever is set on the node.

<br>

### mode

Directory mode as returned by `stat -c %a <directory>`. Defaults to `None` (don't care about mode).
Directory mode as returned by `stat -c %a <directory>`. Defaults to `755`. Set to `None` if you don't want BundleWrap to change whatever is set on the node.

<br>

### owner

Username of the directory's owner. Defaults to `None` (don't care about owner).
Username of the directory's owner. Defaults to `'root'`. Set to `None` if you don't want BundleWrap to change whatever is set on the node.

<br>

Expand Down
6 changes: 3 additions & 3 deletions docs/content/items/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ Encoding of the target file. Note that this applies to the remote file only, you

### group

Name of the group this file belongs to. Defaults to `None` (don't care about group).
Name of the group this file belongs to. Defaults to `'root'`. Set to `None` if you don't want BundleWrap to change whatever is set on the node.

<br>

### mode

File mode as returned by `stat -c %a <file>`. Defaults to `None` (don't care about mode).
File mode as returned by `stat -c %a <file>`. Defaults to `644`. Set to `None` if you don't want BundleWrap to change whatever is set on the node.

<br>

### owner

Username of the file's owner. Defaults to `None` (don't care about owner).
Username of the file's owner. Defaults to `'root'`. Set to `None` if you don't want BundleWrap to change whatever is set on the node.

<br>

Expand Down
4 changes: 2 additions & 2 deletions docs/content/items/symlink.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ File or directory this symlink points to. **This attribute is required.**

### group

Name of the group this symlink belongs to. Defaults to `root`. Defaults to `None` (don't care about group).
Name of the group this symlink belongs to. Defaults to `'root'`. Set to `None` if you don't want BundleWrap to change whatever is set on the node.

<br>

### owner

Username of the symlink's owner. Defaults to `root`. Defaults to `None` (don't care about owner).
Username of the symlink's owner. Defaults to `'root'`. Set to `None` if you don't want BundleWrap to change whatever is set on the node.
9 changes: 6 additions & 3 deletions tests/integration/bw_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_deterministic(tmpdir):
hashes.add(stdout.strip())

assert len(hashes) == 1
assert hashes.pop() == b"8c155b4e7056463eb2c8a8345f4f316f6d7359f6"
assert hashes.pop() == b"e383f171de850338ea08ed0ee9cc1d4afe9ad9e7"


def test_dict(tmpdir):
Expand All @@ -89,16 +89,19 @@ def test_dict(tmpdir):

stdout, stderr, rcode = run("bw hash -d", path=str(tmpdir))
assert rcode == 0
assert stdout == b"8ab35c696b63a853ccf568b27a50e24a69964487 node1\n"
assert stdout == b"923b810a809d28b1321372cf53580e0e95f949c9 node1\n"

stdout, stderr, rcode = run("bw hash -d node1", path=str(tmpdir))
assert rcode == 0
assert stdout == b"503583964eadabacb18fda32cc9fb1e9f66e424b file:/test\n"
assert stdout == b"ef572a7fb123be8ac6778eea0dedca7c81c9ba87 file:/test\n"

stdout, stderr, rcode = run("bw hash -d node1 file:/test", path=str(tmpdir))
assert rcode == 0
assert stdout == (
b"content_hash\tc05a36d547e2b1682472f76985018038d1feebc5\n"
b"group\troot\n"
b"mode\t644\n"
b"owner\troot\n"
b"type\tfile\n"
)

Expand Down

0 comments on commit 3748352

Please sign in to comment.