Class: InstanceAgent::CodeDeployPlugin::ChangeOwnerCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/instance_agent/codedeploy_plugin/install_instruction.rb

Instance Method Summary collapse

Constructor Details

#initialize(object, owner, group) ⇒ ChangeOwnerCommand

Returns a new instance of ChangeOwnerCommand.



314
315
316
317
318
# File 'lib/instance_agent/codedeploy_plugin/install_instruction.rb', line 314

def initialize(object, owner, group)
  @object = object
  @owner = owner
  @group = group
end

Instance Method Details

#execute(cleanup_file) ⇒ Object



320
321
322
323
324
# File 'lib/instance_agent/codedeploy_plugin/install_instruction.rb', line 320

def execute(cleanup_file)
  ownerid = Etc.getpwnam(@owner).uid if @owner
  groupid = Etc.getgrnam(@group).gid if @group
  File.chown(ownerid, groupid, @object)
end

#to_hObject



326
327
328
# File 'lib/instance_agent/codedeploy_plugin/install_instruction.rb', line 326

def to_h
  {"type" => "chown", "owner" => @owner, "group" => @group, "file" => @object}
end