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

« back to all changes in this revision

Viewing changes to lib/puppet/interface/action_manager.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:
7
7
    require 'puppet/interface/action_builder'
8
8
 
9
9
    @actions ||= {}
10
 
    @default_action ||= nil
11
10
    raise "Action #{name} already defined for #{self}" if action?(name)
 
11
 
12
12
    action = Puppet::Interface::ActionBuilder.build(self, name, &block)
13
 
    if action.default
14
 
      raise "Actions #{@default_action.name} and #{name} cannot both be default" if @default_action
15
 
      @default_action = action
 
13
 
 
14
    if action.default and current = get_default_action
 
15
      raise "Actions #{current.name} and #{name} cannot both be default"
16
16
    end
 
17
 
17
18
    @actions[action.name] = action
18
19
  end
19
20
 
61
62
  end
62
63
 
63
64
  def get_default_action
64
 
    @default_action
 
65
    default = actions.map {|x| get_action(x) }.select {|x| x.default }
 
66
    if default.length > 1
 
67
      raise "The actions #{default.map(&:name).join(", ")} cannot all be default"
 
68
    end
 
69
    default.first
65
70
  end
66
71
 
67
72
  def action?(name)