diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-13 02:21:48 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-09-13 02:21:48 +0000 |
commit | 0a4e3925466a99af943ea257bad8b74993976cb8 (patch) | |
tree | a120ae6115e1f19e24e19a4690dadb55596592e1 /lib | |
parent | 58ca9d1241eac3fb982aa673195d5e49ab0a1889 (diff) | |
download | puppet-0a4e3925466a99af943ea257bad8b74993976cb8.tar.gz puppet-0a4e3925466a99af943ea257bad8b74993976cb8.tar.xz puppet-0a4e3925466a99af943ea257bad8b74993976cb8.zip |
fixing component flattening and sorting; it was not working for cases where objects inside of components had dependencies from other components
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@650 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/type/component.rb | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/lib/puppet/type/component.rb b/lib/puppet/type/component.rb index d6c53fe18..345afb75b 100644 --- a/lib/puppet/type/component.rb +++ b/lib/puppet/type/component.rb @@ -23,23 +23,33 @@ module Puppet # topo sort functions def self.sort(objects) list = [] - inlist = {} + tmplist = {} objects.each { |obj| - self.recurse(obj, inlist, list) + self.recurse(obj, tmplist, list) } - return list + return list.flatten end + # FIXME this method assumes that dependencies themselves + # are never components def self.recurse(obj, inlist, list) - return if inlist.include?(obj.object_id) + if inlist.include?(obj.object_id) + return + end + inlist[obj.object_id] = true obj.eachdependency { |req| self.recurse(req, inlist, list) } - - list << obj - inlist[obj.object_id] = true + + if obj.is_a?(Puppet::Type::Component) + obj.each { |child| + self.recurse(child, inlist, list) + } + else + list << obj + end end def each @@ -48,13 +58,7 @@ module Puppet # this returns a sorted array, not a new component, but that suits me just fine def flatten - self.class.sort(@children.collect { |child| - if child.is_a?(self.class) - child.flatten - else - child - end - }.flatten) + self.class.sort(@children).flatten end def initialize(args) @@ -69,14 +73,6 @@ module Puppet # [self.name, self[:type]] end - # the "old" way of doing things - # just turn the container into a transaction - def oldevaluate - transaction = Puppet::Transaction.new(@children) - transaction.component = self - return transaction - end - # flatten all children, sort them, and evaluate them in order # this is only called on one component over the whole system # this also won't work with scheduling, but eh |