Class: InstanceAgent::Plugins::CodeDeployPlugin::ChangeOwnerCommand

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

Instance Method Summary collapse

Constructor Details

#initialize(object, owner, group) ⇒ ChangeOwnerCommand

Returns a new instance of ChangeOwnerCommand.



330
331
332
333
334
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 330

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

Instance Method Details

#execute(cleanup_file) ⇒ Object



336
337
338
339
340
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 336

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



342
343
344
# File 'lib/instance_agent/plugins/codedeploy/install_instruction.rb', line 342

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