Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Expanduser for sharing things
Browse files Browse the repository at this point in the history
This allows one to share things like .ssh/.gnupg and other stuff easier
into the container.
  • Loading branch information
shuhaowu committed May 5, 2018
1 parent e0a3ebc commit d584992
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lxdock/conf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def from_base_dir(cls, base_dir='.'):
config.interpolate()

try:
schema(config._dict)
config._dict = schema(config._dict)
except Invalid as e:
# Formats the voluptuous error
path = ' @ %s' % '.'.join(map(str, e.path)) if e.path else ''
Expand Down
27 changes: 23 additions & 4 deletions lxdock/conf/schema.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
from voluptuous import (ALLOW_EXTRA, All, Any, Coerce, Extra, In, IsDir, Length, Required, Schema,
Url)
import os.path

from voluptuous import (ALLOW_EXTRA, All, Any, Coerce, Extra, In, Invalid, Length, PathExists,
Required, Schema, Url)

from ..provisioners import Provisioner
from .validators import Hostname, LXDIdentifier


def get_schema():
def is_dir_after_expand_user(path):
if type(path) != str:
raise Invalid

path = os.path.expanduser(path)
if not os.path.isdir(path):
raise Invalid

return path

_top_level_and_containers_common_options = {
'environment': {Extra: Coerce(str)},
'hostnames': [Hostname(), ],
Expand All @@ -18,8 +30,7 @@ def get_schema():
'provisioning': [], # will be set dynamically using provisioner classes...
'server': Url(),
'shares': [{
# The existence of the source directory will be checked!
'source': IsDir(),
'source': is_dir_after_expand_user,
'dest': str,
'set_host_acl': bool, # TODO: need a way to deprecate this
}],
Expand All @@ -34,6 +45,14 @@ def get_schema():
'password': str,
'shell': str,
}],
'x11': {
'enabled': bool,
'xsocket_path': PathExists(),
'xauthority_path': PathExists(),
'extra_driver_paths': [str],
'setup_guest_profile_d': bool,
'gpu_properties': {Extra: Coerce(str)}
},
'extras': {
'network_wait_timeout': int
}
Expand Down

0 comments on commit d584992

Please sign in to comment.