~ubuntu-branches/ubuntu/trusty/puppet/trusty

« back to all changes in this revision

Viewing changes to lib/puppet/parser/ast/collexpr.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-10-22 14:08:22 UTC
  • mfrom: (1.1.25) (3.1.32 sid)
  • Revision ID: package-import@ubuntu.com-20111022140822-odxde5lohc45yhuz
Tags: 2.7.6-1
* New upstream release (CVE-2011-3872)
* Remove cherry-picked "groupadd_aix_warning" patch
* Install all new manpages

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    end
20
20
 
21
21
    # The code is only used for virtual lookups
22
 
    str1, code1 = @test1.safeevaluate scope
23
 
    str2, code2 = @test2.safeevaluate scope
 
22
    match1, code1 = @test1.safeevaluate scope
 
23
    match2, code2 = @test2.safeevaluate scope
24
24
 
25
25
    # First build up the virtual code.
26
26
    # If we're a conjunction operator, then we're calling code.  I did
31
31
      when "and"; code1.call(resource) and code2.call(resource)
32
32
      when "or"; code1.call(resource) or code2.call(resource)
33
33
      when "=="
34
 
        if str1 == "tag"
35
 
          resource.tagged?(str2)
 
34
        if match1 == "tag"
 
35
          resource.tagged?(match2)
36
36
        else
37
 
          if resource[str1].is_a?(Array)
38
 
            resource[str1].include?(str2)
 
37
          if resource[match1].is_a?(Array)
 
38
            resource[match1].include?(match2)
39
39
          else
40
 
            resource[str1] == str2
 
40
            resource[match1] == match2
41
41
          end
42
42
        end
43
 
      when "!="; resource[str1] != str2
44
 
      end
45
 
    end
46
 
 
47
 
    # Now build up the rails conditions code
48
 
    if self.parens and self.form == :exported
49
 
      Puppet.warning "Parentheses are ignored in Rails searches"
50
 
    end
51
 
 
52
 
    case @oper
53
 
    when "and", "or"
54
 
      if form == :exported
55
 
        raise Puppet::ParseError, "Puppet does not currently support collecting exported resources with more than one condition"
56
 
      end
57
 
      oper = @oper.upcase
58
 
    when "=="; oper = "="
59
 
    else
60
 
      oper = @oper
61
 
    end
62
 
 
63
 
    if oper == "=" or oper == "!="
64
 
      # Add the rails association info where necessary
65
 
      case str1
66
 
      when "title"
67
 
        str = "title #{oper} '#{str2}'"
68
 
      when "tag"
69
 
        str = "puppet_tags.name #{oper} '#{str2}'"
70
 
      else
71
 
        str = "param_values.value #{oper} '#{str2}' and param_names.name = '#{str1}'"
72
 
      end
73
 
    else
74
 
      str = "(#{str1}) #{oper} (#{str2})"
75
 
    end
76
 
 
77
 
    return str, code
 
43
      when "!="; resource[match1] != match2
 
44
      end
 
45
    end
 
46
 
 
47
    match = [match1, @oper, match2]
 
48
    return match, code
78
49
  end
79
50
 
80
51
  def initialize(hash = {})