Revert "implement before/after to declare dependencies and deprecate require"
Comment from asteven:
Some problems showed up while updating the docs and tests.
You should revert the merge for now.
This reverts commit 84770b9ef2
.
This commit is contained in:
parent
4718b81a08
commit
2fe647a1f7
4 changed files with 7 additions and 38 deletions
|
@ -186,8 +186,6 @@ class CdistObject(object):
|
||||||
return os.path.join(self.path, "explorer")
|
return os.path.join(self.path, "explorer")
|
||||||
|
|
||||||
requirements = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'require'))
|
requirements = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'require'))
|
||||||
before = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'before'))
|
|
||||||
after = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'after'))
|
|
||||||
autorequire = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'autorequire'))
|
autorequire = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'autorequire'))
|
||||||
parameters = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.parameter_path))
|
parameters = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.parameter_path))
|
||||||
explorers = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.explorer_path))
|
explorers = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.explorer_path))
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import warnings
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import cdist
|
import cdist
|
||||||
|
@ -93,12 +92,8 @@ class Emulator(object):
|
||||||
|
|
||||||
def commandline(self):
|
def commandline(self):
|
||||||
"""Parse command line"""
|
"""Parse command line"""
|
||||||
self.meta_parameters = dict.fromkeys(('after', 'before'))
|
|
||||||
meta_parser = argparse.ArgumentParser(add_help=False)
|
|
||||||
for meta_parameter in self.meta_parameters.keys():
|
|
||||||
meta_parser.add_argument('--%s' % meta_parameter, action='append', required=False)
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(add_help=False, parents=[meta_parser], argument_default=argparse.SUPPRESS)
|
parser = argparse.ArgumentParser(add_help=False, argument_default=argparse.SUPPRESS)
|
||||||
|
|
||||||
for parameter in self.cdist_type.required_parameters:
|
for parameter in self.cdist_type.required_parameters:
|
||||||
argument = "--" + parameter
|
argument = "--" + parameter
|
||||||
|
@ -124,11 +119,6 @@ class Emulator(object):
|
||||||
self.args = parser.parse_args(self.argv[1:])
|
self.args = parser.parse_args(self.argv[1:])
|
||||||
self.log.debug('Args: %s' % self.args)
|
self.log.debug('Args: %s' % self.args)
|
||||||
|
|
||||||
# Handle meta parameters
|
|
||||||
for meta_parameter in self.meta_parameters.keys():
|
|
||||||
if meta_parameter in self.args:
|
|
||||||
self.meta_parameters[meta_parameter] = getattr(self.args, meta_parameter)
|
|
||||||
delattr(self.args, meta_parameter)
|
|
||||||
|
|
||||||
def setup_object(self):
|
def setup_object(self):
|
||||||
# Setup object_id - FIXME: unset / do not setup anymore!
|
# Setup object_id - FIXME: unset / do not setup anymore!
|
||||||
|
@ -185,18 +175,10 @@ class Emulator(object):
|
||||||
|
|
||||||
def record_requirements(self):
|
def record_requirements(self):
|
||||||
"""record requirements"""
|
"""record requirements"""
|
||||||
for key in ('before', 'after'):
|
|
||||||
if key in self.meta_parameters and self.meta_parameters[key]:
|
|
||||||
for value in self.meta_parameters[key]:
|
|
||||||
self.log.debug("Recording requirement: %s %s %s", self.cdist_object.name, key, value)
|
|
||||||
dependency_list = getattr(self.cdist_object, key)
|
|
||||||
# append to the object.after or object.before lists
|
|
||||||
dependency_list.append(value)
|
|
||||||
|
|
||||||
if "require" in self.env:
|
if "require" in self.env:
|
||||||
warnings.warn("The 'require' envrionment variable is deprecated. Use the --before and --after meta parameters to define dependencies.", category=PendingDeprecationWarning, stacklevel=2)
|
|
||||||
|
|
||||||
requirements = self.env['require']
|
requirements = self.env['require']
|
||||||
|
self.log.debug("reqs = " + requirements)
|
||||||
for requirement in requirements.split(" "):
|
for requirement in requirements.split(" "):
|
||||||
# Ignore empty fields - probably the only field anyway
|
# Ignore empty fields - probably the only field anyway
|
||||||
if len(requirement) == 0: continue
|
if len(requirement) == 0: continue
|
||||||
|
@ -205,10 +187,11 @@ class Emulator(object):
|
||||||
cdist_object = self.cdist_object.object_from_name(requirement)
|
cdist_object = self.cdist_object.object_from_name(requirement)
|
||||||
|
|
||||||
self.log.debug("Recording requirement: " + requirement)
|
self.log.debug("Recording requirement: " + requirement)
|
||||||
|
|
||||||
# Save the sanitised version, not the user supplied one
|
# Save the sanitised version, not the user supplied one
|
||||||
# (__file//bar => __file/bar)
|
# (__file//bar => __file/bar)
|
||||||
# This ensures pattern matching is done against sanitised list
|
# This ensures pattern matching is done against sanitised list
|
||||||
self.cdist_object.after.append(cdist_object.name)
|
self.cdist_object.requirements.append(cdist_object.name)
|
||||||
|
|
||||||
def record_auto_requirements(self):
|
def record_auto_requirements(self):
|
||||||
"""An object shall automatically depend on all objects that it defined in it's type manifest.
|
"""An object shall automatically depend on all objects that it defined in it's type manifest.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2011-2012 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -109,21 +109,10 @@ class DependencyResolver(object):
|
||||||
raise RequirementNotFoundError(pattern)
|
raise RequirementNotFoundError(pattern)
|
||||||
|
|
||||||
def _preprocess_requirements(self):
|
def _preprocess_requirements(self):
|
||||||
"""Find all before, after and autorequire dependencies and merge them
|
"""Find all autorequire dependencies and merge them to be just requirements
|
||||||
to be just requirements for further processing.
|
for further processing.
|
||||||
"""
|
"""
|
||||||
for cdist_object in self.objects.values():
|
for cdist_object in self.objects.values():
|
||||||
if cdist_object.after:
|
|
||||||
cdist_object.requirements.extend(cdist_object.after)
|
|
||||||
# As we changed the object on disc, we have to ensure it is not
|
|
||||||
# preprocessed again if someone would call us multiple times.
|
|
||||||
cdist_object.after = []
|
|
||||||
if cdist_object.before:
|
|
||||||
for other_object in self.find_requirements_by_name(cdist_object.before):
|
|
||||||
other_object.requirements.append(cdist_object.name)
|
|
||||||
# As we changed the object on disc, we have to ensure it is not
|
|
||||||
# preprocessed again if someone would call us multiple times.
|
|
||||||
cdist_object.before = []
|
|
||||||
if cdist_object.autorequire:
|
if cdist_object.autorequire:
|
||||||
# The objects (children) that this cdist_object (parent) defined
|
# The objects (children) that this cdist_object (parent) defined
|
||||||
# in it's type manifest shall inherit all explicit requirements
|
# in it's type manifest shall inherit all explicit requirements
|
||||||
|
|
|
@ -87,7 +87,6 @@ class ObjectTestCase(test.CdistTestCase):
|
||||||
self.cdist_object.code_local = ''
|
self.cdist_object.code_local = ''
|
||||||
self.cdist_object.code_remote = ''
|
self.cdist_object.code_remote = ''
|
||||||
self.cdist_object.state = ''
|
self.cdist_object.state = ''
|
||||||
self.cdist_object.requirements = []
|
|
||||||
|
|
||||||
def test_name(self):
|
def test_name(self):
|
||||||
self.assertEqual(self.cdist_object.name, '__third/moon')
|
self.assertEqual(self.cdist_object.name, '__third/moon')
|
||||||
|
|
Loading…
Reference in a new issue