begin to make OBJECT_MARKER dynamic
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
78c3c09163
commit
c363fc24de
4 changed files with 23 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2010-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
# 2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -23,7 +24,6 @@ from cdist.core.cdist_type import CdistType
|
||||||
from cdist.core.cdist_type import NoSuchTypeError
|
from cdist.core.cdist_type import NoSuchTypeError
|
||||||
from cdist.core.cdist_object import CdistObject
|
from cdist.core.cdist_object import CdistObject
|
||||||
from cdist.core.cdist_object import IllegalObjectIdError
|
from cdist.core.cdist_object import IllegalObjectIdError
|
||||||
from cdist.core.cdist_object import OBJECT_MARKER
|
|
||||||
from cdist.core.explorer import Explorer
|
from cdist.core.explorer import Explorer
|
||||||
from cdist.core.manifest import Manifest
|
from cdist.core.manifest import Manifest
|
||||||
from cdist.core.code import Code
|
from cdist.core.code import Code
|
||||||
|
|
|
@ -32,9 +32,6 @@ from cdist.util import fsproperty
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
OBJECT_MARKER = '.cdist'
|
|
||||||
|
|
||||||
|
|
||||||
class IllegalObjectIdError(cdist.Error):
|
class IllegalObjectIdError(cdist.Error):
|
||||||
def __init__(self, object_id, message=None):
|
def __init__(self, object_id, message=None):
|
||||||
self.object_id = object_id
|
self.object_id = object_id
|
||||||
|
@ -66,16 +63,18 @@ class CdistObject(object):
|
||||||
STATE_RUNNING = "running"
|
STATE_RUNNING = "running"
|
||||||
STATE_DONE = "done"
|
STATE_DONE = "done"
|
||||||
|
|
||||||
def __init__(self, cdist_type, base_path, object_id=''):
|
def __init__(self, cdist_type, base_path, object_marker=".cdist", object_id=''):
|
||||||
self.cdist_type = cdist_type # instance of Type
|
self.cdist_type = cdist_type # instance of Type
|
||||||
self.base_path = base_path
|
self.base_path = base_path
|
||||||
self.object_id = object_id
|
self.object_id = object_id
|
||||||
|
|
||||||
|
self.object_marker = object_marker
|
||||||
|
|
||||||
self.validate_object_id()
|
self.validate_object_id()
|
||||||
self.sanitise_object_id()
|
self.sanitise_object_id()
|
||||||
|
|
||||||
self.name = self.join_name(self.cdist_type.name, self.object_id)
|
self.name = self.join_name(self.cdist_type.name, self.object_id)
|
||||||
self.path = os.path.join(self.cdist_type.path, self.object_id, OBJECT_MARKER)
|
self.path = os.path.join(self.cdist_type.path, self.object_id, self.object_marker)
|
||||||
self.absolute_path = os.path.join(self.base_path, self.path)
|
self.absolute_path = os.path.join(self.base_path, self.path)
|
||||||
self.code_local_path = os.path.join(self.path, "code-local")
|
self.code_local_path = os.path.join(self.path, "code-local")
|
||||||
self.code_remote_path = os.path.join(self.path, "code-remote")
|
self.code_remote_path = os.path.join(self.path, "code-remote")
|
||||||
|
@ -97,7 +96,7 @@ class CdistObject(object):
|
||||||
def list_object_names(cls, object_base_path):
|
def list_object_names(cls, object_base_path):
|
||||||
"""Return a list of object names"""
|
"""Return a list of object names"""
|
||||||
for path, dirs, files in os.walk(object_base_path):
|
for path, dirs, files in os.walk(object_base_path):
|
||||||
if OBJECT_MARKER in dirs:
|
if self.object_marker in dirs:
|
||||||
yield os.path.relpath(path, object_base_path)
|
yield os.path.relpath(path, object_base_path)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -127,8 +126,8 @@ class CdistObject(object):
|
||||||
"""Validate the given object_id and raise IllegalObjectIdError if it's not valid.
|
"""Validate the given object_id and raise IllegalObjectIdError if it's not valid.
|
||||||
"""
|
"""
|
||||||
if self.object_id:
|
if self.object_id:
|
||||||
if OBJECT_MARKER in self.object_id.split(os.sep):
|
if self.object_marker in self.object_id.split(os.sep):
|
||||||
raise IllegalObjectIdError(self.object_id, 'object_id may not contain \'%s\'' % OBJECT_MARKER)
|
raise IllegalObjectIdError(self.object_id, 'object_id may not contain \'%s\'' % self.object_marker)
|
||||||
if '//' in self.object_id:
|
if '//' in self.object_id:
|
||||||
raise IllegalObjectIdError(self.object_id, 'object_id may not contain //')
|
raise IllegalObjectIdError(self.object_id, 'object_id may not contain //')
|
||||||
if self.object_id == '.':
|
if self.object_id == '.':
|
||||||
|
|
14
docs/dev/logs/2014-05-06.object-marker
Normal file
14
docs/dev/logs/2014-05-06.object-marker
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
Change object marker from .cdist to .cdist-TEMPNAME to allow using
|
||||||
|
object ids that contain / are .cdist.
|
||||||
|
|
||||||
|
Changes required:
|
||||||
|
|
||||||
|
cdist/emulator.py:
|
||||||
|
needs to know suffix/name
|
||||||
|
tests:
|
||||||
|
allow object id named /.cdist
|
||||||
|
tests:
|
||||||
|
many
|
||||||
|
cdist/config.py:
|
||||||
|
have suffix
|
||||||
|
|
Loading…
Reference in a new issue