private
def generate_normal_copy(i, absolute_source_path, destination)
if File.exists?(destination)
case @file_exists_behavior
when "DISALLOW"
raise "The deployment failed because a specified file already exists at this location: #{destination}"
when "OVERWRITE"
i.copy(absolute_source_path, destination)
when "RETAIN"
# neither generate copy command or fail the deployment
else
raise "The deployment failed because an invalid option was specified for fileExistsBehavior: #{@file_exists_behavior}. Valid options include OVERWRITE, RETAIN, and DISALLOW."
end
else
i.copy(absolute_source_path, destination)
end
end
class CopyCommand
attr_reader :destination, :source
def initialize(source, destination)
@source = source
@destination = destination
end
def execute(cleanup_file)
# NO need to check if file already exists in here, because if that's the case,
# the CopyCommand entry should not even be created by Installer
cleanup_file.puts(@destination)
if File.symlink?(@source)
FileUtils.symlink(File.readlink(@source), @destination)
else
FileUtils.copy(@source, @destination, :preserve => true)
end
end
def to_h
{:type => :copy, :source => @source, :destination => @destination}
end
end
Symlink 관련 버그
--file-exists-behavior "OVERWRITE" 옵션을 사용하고 있는데, 파일이 Symlink인 경우 오류가 나는 현상 #143
InstanceAgent::Plugins::CodeDeployPlugin::CommandPoller: Error during perform: Errno::EEXIST - File exists
참고 링크
https://docs.aws.amazon.com/cli/latest/reference/deploy/create-deployment.html https://docs.aws.amazon.com/ko_kr/codedeploy/latest/userguide/deployments-local.html
코드 위치
installer.py >> generate_normal_copy