Class: OpscodeAcl::AclAdd

Inherits:
Chef::Knife
  • Object
show all
Defined in:
lib/chef/knife/acl_add.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actor_nameObject (readonly)

Returns the value of attribute actor_name.



24
25
26
# File 'lib/chef/knife/acl_add.rb', line 24

def actor_name
  @actor_name
end

#actor_typeObject (readonly)

Returns the value of attribute actor_type.



24
25
26
# File 'lib/chef/knife/acl_add.rb', line 24

def actor_type
  @actor_type
end

#object_nameObject (readonly)

Returns the value of attribute object_name.



24
25
26
# File 'lib/chef/knife/acl_add.rb', line 24

def object_name
  @object_name
end

#object_typeObject (readonly)

Returns the value of attribute object_type.



24
25
26
# File 'lib/chef/knife/acl_add.rb', line 24

def object_type
  @object_type
end

#permObject (readonly)

Returns the value of attribute perm.



24
25
26
# File 'lib/chef/knife/acl_add.rb', line 24

def perm
  @perm
end

Instance Method Details

#add_actor_to_ace!(name, ace) ⇒ Object



58
59
60
# File 'lib/chef/knife/acl_add.rb', line 58

def add_actor_to_ace!(name, ace)
  ace['actors'] << name unless ace['actors'].include?(name)
end

#add_group_to_ace!(name, ace) ⇒ Object



54
55
56
# File 'lib/chef/knife/acl_add.rb', line 54

def add_group_to_ace!(name, ace)
  ace['groups'] << name unless ace['groups'].include?(name)
end

#runObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/chef/knife/acl_add.rb', line 30

def run
  @object_type, @object_name, @perm, @actor_type, @actor_name = name_args

  if name_args.length < 5
    show_usage
    ui.fatal "You must specify the object type, object name, perm, actor type (client or group), and actor name"
    exit 1
  end

  validate_all_params!
  ace = get_ace(object_type, object_name, perm)

  case actor_type
  when "client"
    add_actor_to_ace!(actor_name, ace)
  when "group"
    add_group_to_ace!(actor_name, ace)
  when "users"
    # Not Implemented yet, we shouldn't get here.
  end

  update_ace!(object_type, object_name, perm, ace)
end