[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Jesse Wolfe jes5199 at gmail.com
Tue May 10 07:59:18 UTC 2011


The following commit has been merged in the experimental branch:
commit 163ec172e06a2b8aab9f9c9247dd45bc0dea3f72
Merge: c9592f048331d7728d42f55cb29f5748ec9b1a67 574812ef00e6681fce88bd1e66bbc07e7ade4b41
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Mon Oct 4 16:31:30 2010 -0700

    Partial merge to 2.6.2rc1 : Merge commit '574812e' into next
    
    The API for AST objects has changed, making the initialization of this
    spec somewhat more complicated.
    Also, git seems to have been confused by whitespace changes.
    
    Manually Resolved Conflicts:
    	lib/puppet/parser/ast/resource.rb

diff --combined lib/puppet/parser/ast/resource.rb
index 2320714,6909c85..bd15d99
--- a/lib/puppet/parser/ast/resource.rb
+++ b/lib/puppet/parser/ast/resource.rb
@@@ -3,15 -3,26 +3,15 @@@ require 'puppet/parser/ast/resource_ref
  # Any normal puppet resource declaration.  Can point to a definition or a
  # builtin type.
  class Puppet::Parser::AST
 -class Resource < AST::ResourceReference
 +class Resource < AST::Branch
  
    associates_doc
  
 -  attr_accessor :title, :type, :exported, :virtual
 -  attr_reader :parameters
 +  attr_accessor :type, :instances, :exported, :virtual
  
    # Does not actually return an object; instead sets an object
    # in the current scope.
    def evaluate(scope)
 -    # Evaluate all of the specified params.
 -    paramobjects = parameters.collect { |param|
 -      param.safeevaluate(scope)
 -    }
 -
 -    resource_titles = @title.safeevaluate(scope)
 -
 -    # it's easier to always use an array, even for only one name
 -    resource_titles = [resource_titles] unless resource_titles.is_a?(Array)
 -
      # We want virtual to be true if exported is true.  We can't
      # just set :virtual => self.virtual in the initialization,
      # because sometimes the :virtual attribute is set *after*
@@@ -19,49 -30,45 +19,48 @@@
      # is true.  Argh, this was a very tough one to track down.
      virt = self.virtual || self.exported
  
 -    # This is where our implicit iteration takes place; if someone
 -    # passed an array as the name, then we act just like the called us
 -    # many times.
 -    fully_qualified_type, resource_titles = scope.resolve_type_and_titles(type, resource_titles)
 +    # First level of implicit iteration: build a resource for each
 +    # instance.  This handles things like:
 +    # file { '/foo': owner => blah; '/bar': owner => blah }
 +    @instances.collect { |instance|
  
 -    resource_titles.flatten.collect { |resource_title|
 -      exceptwrap :type => Puppet::ParseError do
 -        resource = Puppet::Parser::Resource.new(
 -          fully_qualified_type, resource_title,
 -          :parameters => paramobjects,
 -          :file => self.file,
 -          :line => self.line,
 -          :exported => self.exported,
 -          :virtual => virt,
 -          :source => scope.source,
 -          :scope => scope,
 -          :strict => true
 -        )
 +      # Evaluate all of the specified params.
 +      paramobjects = instance.parameters.collect { |param|
 +        param.safeevaluate(scope)
 +      }
  
 -        # And then store the resource in the compiler.
 -        # At some point, we need to switch all of this to return
 -        # resources instead of storing them like this.
 -        scope.compiler.add_resource(scope, resource)
 -        resource
 -      end
 -    }.reject { |resource| resource.nil? }
 -  end
 +      resource_titles = instance.title.safeevaluate(scope)
 +
 +      # it's easier to always use an array, even for only one name
 +      resource_titles = [resource_titles] unless resource_titles.is_a?(Array)
 +
 +      fully_qualified_type, resource_titles = scope.resolve_type_and_titles(type, resource_titles)
 +
 +      # Second level of implicit iteration; build a resource for each
 +      # title.  This handles things like:
 +      # file { ['/foo', '/bar']: owner => blah }
 +      resource_titles.flatten.collect { |resource_title|
 +        exceptwrap :type => Puppet::ParseError do
 +          resource = Puppet::Parser::Resource.new(
 +            fully_qualified_type, resource_title,
 +            :parameters => paramobjects,
 +            :file => self.file,
 +            :line => self.line,
 +            :exported => self.exported,
 +            :virtual => virt,
 +            :source => scope.source,
 +            :scope => scope,
- 
 +            :strict => true
 +          )
  
 -  # Set the parameters for our object.
 -  def parameters=(params)
 -    if params.is_a?(AST::ASTArray)
 -      @parameters = params
 -    else
 -      @parameters = AST::ASTArray.new(
 -        :line => params.line,
 -        :file => params.file,
 -        :children => [params]
 -      )
 -    end
 +          # And then store the resource in the compiler.
 +          # At some point, we need to switch all of this to return
 +          # resources instead of storing them like this.
 +          scope.compiler.add_resource(scope, resource)
 +          resource
 +        end
 +      }
 +    }.flatten.reject { |resource| resource.nil? }
    end
  end
  end
diff --combined lib/puppet/util/rdoc/parser.rb
index aca6616,f9beced..ce34442
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@@ -17,7 -17,7 +17,7 @@@ class Parse
  
    SITE = "__site__"
  
 -  attr_accessor :ast, :input_file_name, :top_level
 +  attr_accessor :input_file_name, :top_level
  
    # parser registration into RDoc
    parse_files_matching(/\.(rb|pp)$/)
@@@ -33,18 -33,15 +33,18 @@@
  
    # main entry point
    def scan
 -    env = Puppet::Node::Environment.new
 -    unless env.known_resource_types.watching_file?(@input_file_name)
 +    environment = Puppet::Node::Environment.new
 +    unless environment.known_resource_types.watching_file?(@input_file_name)
        Puppet.info "rdoc: scanning #{@input_file_name}"
        if @input_file_name =~ /\.pp$/
 -        @parser = Puppet::Parser::Parser.new(env)
 +        @parser = Puppet::Parser::Parser.new(environment)
          @parser.file = @input_file_name
 -        @ast = @parser.parse
 +        @known_resource_types = environment.known_resource_types
 +        @parser.parse.instantiate('').each do |type|
 +          @known_resource_types.add type
 +        end
 +        scan_top_level(@top_level)
        end
 -      scan_top_level(@top_level)
      end
      @top_level
    end
@@@ -207,19 -204,19 +207,21 @@@
        if stmt.is_a?(Puppet::Parser::AST::Resource) and !stmt.type.nil?
          begin
            type = stmt.type.split("::").collect { |s| s.capitalize }.join("::")
--          title = stmt.title.is_a?(Puppet::Parser::AST::ASTArray) ? stmt.title.to_s.gsub(/\[(.*)\]/,'\1') : stmt.title.to_s
--          Puppet.debug "rdoc: found resource: #{type}[#{title}]"
++          stmt.instances.each do |inst|
++            title = inst.title.is_a?(Puppet::Parser::AST::ASTArray) ? inst.title.to_s.gsub(/\[(.*)\]/,'\1') : inst.title.to_s
++            Puppet.debug "rdoc: found resource: #{type}[#{title}]"
  
--          param = []
-           stmt.params.children.each do |p|
-             res = {}
-             res["name"] = p.param
-             res["value"] = "#{p.value.to_s}" unless p.value.nil?
 -          stmt.parameters.children.each do |p|
 -            res = {}
 -            res["name"] = p.param
 -            res["value"] = "#{p.value.to_s}" unless p.value.nil?
++            param = []
++            inst.parameters.children.each do |p|
++              res = {}
++              res["name"] = p.param
++              res["value"] = "#{p.value.to_s}" unless p.value.nil?
  
--            param << res
--          end
++              param << res
++            end
  
--          container.add_resource(PuppetResource.new(type, title, stmt.doc, param))
++            container.add_resource(PuppetResource.new(type, title, stmt.doc, param))
++          end
          rescue => detail
            raise Puppet::ParseError, "impossible to parse resource in #{stmt.file} at line #{stmt.line}: #{detail}"
          end
@@@ -340,7 -337,7 +342,7 @@@
    # that contains the documentation
    def parse_elements(container)
      Puppet.debug "rdoc: scanning manifest"
 -    @ast.hostclasses.values.sort { |a,b| a.name <=> b.name }.each do |klass|
 +    @known_resource_types.hostclasses.values.sort { |a,b| a.name <=> b.name }.each do |klass|
        name = klass.name
        if klass.file == @input_file_name
          unless name.empty?
@@@ -353,13 -350,13 +355,13 @@@
        end
      end
  
 -    @ast.definitions.each do |name, define|
 +    @known_resource_types.definitions.each do |name, define|
        if define.file == @input_file_name
          document_define(name,define,container)
        end
      end
  
 -    @ast.nodes.each do |name, node|
 +    @known_resource_types.nodes.each do |name, node|
        if node.file == @input_file_name
          document_node(name.to_s,node,container)
        end
diff --combined spec/unit/util/rdoc/parser_spec.rb
index 7809c75,28c33c2..04713f2
--- a/spec/unit/util/rdoc/parser_spec.rb
+++ b/spec/unit/util/rdoc/parser_spec.rb
@@@ -20,7 -20,7 +20,7 @@@ describe RDoc::Parser d
        @parser.stubs(:scan_top_level)
        parser = stub 'parser'
        Puppet::Parser::Parser.stubs(:new).returns(parser)
 -      parser.expects(:parse)
 +      parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
        parser.expects(:file=).with("module/manifests/init.pp")
  
        @parser.scan
@@@ -29,7 -29,6 +29,7 @@@
      it "should scan the ast for Puppet files" do
        parser = stub_everything 'parser'
        Puppet::Parser::Parser.stubs(:new).returns(parser)
 +      parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
  
        @parser.expects(:scan_top_level)
  
@@@ -39,7 -38,6 +39,7 @@@
      it "should return a PuppetTopLevel to RDoc" do
        parser = stub_everything 'parser'
        Puppet::Parser::Parser.stubs(:new).returns(parser)
 +      parser.expects(:parse).returns(Puppet::Parser::AST::Hostclass.new(''))
  
        @parser.expects(:scan_top_level)
  
@@@ -49,8 -47,8 +49,8 @@@
  
    describe "when scanning top level entities" do
      before :each do
 -      @resource_type_collection = stub_everything 'resource_type_collection'
 -      @parser.ast = @resource_type_collection
 +      @resource_type_collection = resource_type_collection = stub_everything('resource_type_collection')
 +      @parser.instance_eval { @known_resource_types = resource_type_collection }
        @parser.stubs(:split_module).returns("module")
  
        @topcontainer = stub_everything 'topcontainer'
@@@ -143,8 -141,8 +143,8 @@@
        @definition = stub_everything 'definition', :file => "module/manifests/init.pp", :type => :definition, :name => "mydef"
        @node = stub_everything 'node', :file => "module/manifests/init.pp", :type => :node, :name => "mynode"
  
 -      @resource_type_collection = Puppet::Resource::TypeCollection.new("env")
 -      @parser.ast = @resource_type_collection
 +      @resource_type_collection = resource_type_collection = Puppet::Resource::TypeCollection.new("env")
 +      @parser.instance_eval { @known_resource_types = resource_type_collection }
  
        @container = stub_everything 'container'
      end
@@@ -342,10 -340,12 +342,12 @@@
  
      def create_stmt(name)
        stmt_value = stub "#{name}_value", :value => "myclass"
-       stmt = stub_everything 'stmt', :name => name, :arguments => [stmt_value], :doc => "mydoc"
-       stmt.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
-       stmt.stubs(:is_a?).with(Puppet::Parser::AST::Function).returns(true)
-       stmt
+ 
+       Puppet::Parser::AST::Function.new(
+         :name      => name,
+         :arguments => [stmt_value],
+         :doc       => 'mydoc'
+       )
      end
  
      before(:each) do
@@@ -379,10 -379,11 +381,11 @@@
  
      def create_stmt
        stmt_value = stub "resource_ref", :to_s => "File[\"/tmp/a\"]"
-       stmt = stub_everything 'stmt', :name => "realize", :arguments => [stmt_value], :doc => "mydoc"
-       stmt.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
-       stmt.stubs(:is_a?).with(Puppet::Parser::AST::Function).returns(true)
-       stmt
+       Puppet::Parser::AST::Function.new(
+         :name      => 'realize',
+         :arguments => [stmt_value],
+         :doc       => 'mydoc'
+       )
      end
  
      before(:each) do
@@@ -434,11 -435,12 +437,16 @@@
    describe "when scanning for resources" do
      before :each do
        @class = stub_everything 'class'
- 
-       param = stub 'params', :children => []
-       @stmt = stub_everything 'stmt', :type => "File", :title => "myfile", :doc => "mydoc", :params => param
-       @stmt.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(false)
-       @stmt.stubs(:is_a?).with(Puppet::Parser::AST::Resource).returns(true)
+       @stmt = Puppet::Parser::AST::Resource.new(
+         :type       => "File",
 -        :title      => "myfile",
 -        :doc        => 'mydoc',
 -        :parameters => Puppet::Parser::AST::ASTArray.new(:children => [])
++        :instances  => Puppet::Parser::AST::ASTArray.new(:children => [
++          Puppet::Parser::AST::ResourceInstance.new(
++            :title => Puppet::Parser::AST::Name.new(:value => "myfile"),
++            :parameters => Puppet::Parser::AST::ASTArray.new(:children => [])
++          )
++        ]),
++        :doc        => 'mydoc'
+       )
  
        @code = stub_everything 'code'
        @code.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(true)

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list