Skip to content

Commit 67a2faf

Browse files
aj-awsMichael Choi
authored andcommitted
Source code changes and dependency updates for Ruby 3.1 and 3.2 support
commit: 6c7988df7868ecfa183fe9778ef5ed5587210698 Author: Andres Jardon <[email protected]> Date: 2023-03-20T20:06:16.000Z Source code changes and dependency updates for Ruby 3.1 and 3.2 support commit: 3aa58788849a414fb0ae6ddd94a96d8dbf696f92 Author: Andres Jardon <[email protected]> Date: 2023-03-20T18:04:30.000Z Source code changes and dependency updates for Ruby 3.1 and 3.2 support commit: 77a4cc18f931284d4908a4f8bfa1854727e205ad Author: Andres Jardon <[email protected]> Date: 2023-03-17T19:53:35.000Z Source code changes and dependency updates for Ruby 3.1 and 3.2 support
1 parent 18347be commit 67a2faf

File tree

21 files changed

+415
-186
lines changed

21 files changed

+415
-186
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source 'http://rubygems.org'
77
gemspec
88
gem "process_manager", "0.0.13", :path => "#{File.expand_path(__FILE__)}/../vendor/gems/process_manager-0.0.13"
99
gem "codedeploy-commands", "1.0.0", :path => "#{File.expand_path(__FILE__)}/../vendor/gems/codedeploy-commands-1.0.0"
10+
gem "simple_pid", "0.2.1", :path => "#{File.expand_path(__FILE__)}/../vendor/gems/simple_pid-0.2.1"
1011

1112
group :test do
1213
gem 'test-unit'

codedeploy_agent.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
1818
spec.add_dependency('logging', '~> 2.2')
1919
spec.add_dependency('aws-sdk-core', '~> 3')
2020
spec.add_dependency('aws-sdk-s3', '~> 1')
21-
spec.add_dependency('simple_pid', '~> 0.2.1')
2221
spec.add_dependency('docopt', '~> 0.5.0')
2322
spec.add_dependency('concurrent-ruby', '~> 1.1.9')
2423

lib/aws/codedeploy/local/cli_validator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def validate(args)
2727
raise ValidationError.new("location #{location} cannot be http, only encrypted (https) url endpoints supported")
2828
end
2929

30-
if (uri.scheme != 'https' && uri.scheme != 's3' && !File.exists?(location))
30+
if (uri.scheme != 'https' && uri.scheme != 's3' && !File.exist?(location))
3131
raise ValidationError.new("location #{location} is specified as a file or directory which does not exist")
3232
end
3333

@@ -41,10 +41,10 @@ def validate(args)
4141

4242
if (type == 'directory' && (uri.scheme != 'https' && uri.scheme != 's3' && File.directory?(location)))
4343
appspec_filename = args['--appspec-filename']
44-
if !appspec_filename.nil? && !File.exists?("#{location}/#{appspec_filename}")
44+
if !appspec_filename.nil? && !File.exist?("#{location}/#{appspec_filename}")
4545
raise ValidationError.new("Expecting appspec file at location #{location}/#{appspec_filename} but it is not found there. Please either run the CLI from within a directory containing the #{appspec_filename} file or specify a bundle location containing an #{appspec_filename} file in its root directory")
4646
end
47-
if appspec_filename.nil? && !File.exists?("#{location}/appspec.yml") && !File.exists?("#{location}/appspec.yaml")
47+
if appspec_filename.nil? && !File.exist?("#{location}/appspec.yml") && !File.exist?("#{location}/appspec.yaml")
4848
raise ValidationError.new("Expecting appspec file at location #{location}/appspec.yml or #{location}/appspec.yaml but it is not found there. Please either run the CLI from within a directory containing the appspec.yml or appspec.yaml file or specify a bundle location containing an appspec.yml or appspec.yaml file in its root directory")
4949
end
5050
end

lib/instance_agent/log.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class InstanceAgent::DeploymentLog
88

99
def initialize
1010
deployment_logs_dir = File.join(InstanceAgent::Config.config[:root_dir], 'deployment-logs')
11-
FileUtils.mkdir_p(deployment_logs_dir) unless File.exists? deployment_logs_dir
11+
FileUtils.mkdir_p(deployment_logs_dir) unless File.exist? deployment_logs_dir
1212
@deployment_log ||= Logger.new(File.join(deployment_logs_dir, "#{InstanceAgent::Config.config[:program_name]}-deployments.log"), 8, 64 * 1024 * 1024)
1313
@deployment_log.formatter = proc do |severity, datetime, progname, msg|
1414
"[#{datetime.strftime('%Y-%m-%d %H:%M:%S.%L')}] #{msg}\n"

lib/instance_agent/plugins/codedeploy/hook_executor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def script_error_prefix(script_location, script_run_as_user)
210210
private
211211
def create_script_log_file_if_needed
212212
script_log_file_location = File.join(@current_deployment_root_dir, ScriptLog::SCRIPT_LOG_FILE_RELATIVE_LOCATION)
213-
if(!File.exists?(script_log_file_location))
213+
if(!File.exist?(script_log_file_location))
214214
unless File.directory?(File.dirname(script_log_file_location))
215215
FileUtils.mkdir_p(File.dirname(script_log_file_location))
216216
end
@@ -232,7 +232,7 @@ def script_absolute_path(script)
232232
def parse_app_spec
233233
app_spec_location = File.join(@deployment_archive_dir, @app_spec_path)
234234
log(:debug, "Checking for app spec in #{app_spec_location}")
235-
unless File.exists?(app_spec_location)
235+
unless File.exist?(app_spec_location)
236236
raise <<-MESSAGE.gsub(/^[\s\t]*/, '').gsub(/\s*\n/, ' ').strip
237237
The CodeDeploy agent did not find an AppSpec file within the unpacked revision directory at revision-relative path "#{@app_spec_path}".
238238
The revision was unpacked to directory "#{@deployment_archive_dir}", and the AppSpec file was expected but not found at path
@@ -249,7 +249,7 @@ def select_correct_deployment_root_dir(current_deployment_root_dir, last_success
249249
hook_deployment_mapping = mapping_between_hooks_and_deployments
250250
if(select_correct_mapping_for_hooks == LAST_SUCCESSFUL_DEPLOYMENT && !File.exist?(File.join(@deployment_root_dir, 'deployment-archive')))
251251
@deployment_root_dir = last_successful_deployment_root_dir
252-
elsif(select_correct_mapping_for_hooks == MOST_RECENT_DEPLOYMENT && !File.exists?(File.join(@deployment_root_dir, 'deployment-archive')))
252+
elsif(select_correct_mapping_for_hooks == MOST_RECENT_DEPLOYMENT && !File.exist?(File.join(@deployment_root_dir, 'deployment-archive')))
253253
@deployment_root_dir = most_recent_deployment_dir
254254
end
255255
end

lib/instance_agent/plugins/codedeploy/installer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def initialize(opts = {})
2727
def install(deployment_group_id, application_specification)
2828
cleanup_file = File.join(deployment_instructions_dir, "#{deployment_group_id}-cleanup")
2929

30-
if File.exists?(cleanup_file)
30+
if File.exist?(cleanup_file)
3131
commands = InstanceAgent::Plugins::CodeDeployPlugin::InstallInstruction.parse_remove_commands(File.read(cleanup_file))
3232
commands.each do |cmd|
3333
cmd.execute
@@ -116,7 +116,7 @@ def generate_directory_copy(i, absolute_source_path, destination, file_exists_be
116116

117117
private
118118
def generate_normal_copy(i, absolute_source_path, destination, file_exists_behavior)
119-
if File.exists?(destination)
119+
if File.exist?(destination)
120120
case file_exists_behavior
121121
when "DISALLOW"
122122
raise "The deployment failed because a specified file already exists at this location: #{destination}"
@@ -136,7 +136,7 @@ def generate_normal_copy(i, absolute_source_path, destination, file_exists_behav
136136
def fill_in_missing_ancestors(i, destination)
137137
missing_ancestors = []
138138
parent_dir = File.dirname(destination)
139-
while !File.exists?(parent_dir) &&
139+
while !File.exist?(parent_dir) &&
140140
parent_dir != "." && parent_dir != "/"
141141
missing_ancestors.unshift(parent_dir)
142142
parent_dir = File.dirname(parent_dir)

lib/instance_agent/plugins/codedeploy/onpremise_config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class OnPremisesConfig
77
def self.configure
88
file_path = InstanceAgent::Config.config[:on_premises_config_file]
99
file_config = nil
10-
if File.exists?(file_path) && File.readable?(file_path)
10+
if File.readable?(file_path)
1111
begin
1212
file_config = YAML.load(File.read(file_path)).symbolize_keys
1313
rescue

spec/aws/codedeploy/local/cli_validator_spec.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
end
3333

3434
it 'returns the same arguments' do
35-
allow(File).to receive(:exists?).with(VALID_FILE).and_return(true)
35+
allow(File).to receive(:exist?).with(VALID_FILE).and_return(true)
3636
expect(validator.validate(args)).to equal(args)
3737
end
3838
end
@@ -93,10 +93,10 @@
9393
end
9494

9595
it 'throws a ValidationError' do
96-
allow(File).to receive(:exists?).with(FAKE_DIRECTORY).and_return(true)
96+
allow(File).to receive(:exist?).with(FAKE_DIRECTORY).and_return(true)
9797
allow(File).to receive(:directory?).with(FAKE_DIRECTORY).and_return(true)
98-
expect(File).to receive(:exists?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(false)
99-
expect(File).to receive(:exists?).with("#{FAKE_DIRECTORY}/appspec.yaml").and_return(false)
98+
expect(File).to receive(:exist?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(false)
99+
expect(File).to receive(:exist?).with("#{FAKE_DIRECTORY}/appspec.yaml").and_return(false)
100100
expect{validator.validate(args)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "Expecting appspec file at location #{FAKE_DIRECTORY}/appspec.yml or #{FAKE_DIRECTORY}/appspec.yaml but it is not found there. Please either run the CLI from within a directory containing the appspec.yml or appspec.yaml file or specify a bundle location containing an appspec.yml or appspec.yaml file in its root directory")
101101
end
102102
end
@@ -109,9 +109,9 @@
109109
end
110110

111111
it 'throws a ValidationError' do
112-
allow(File).to receive(:exists?).with(FAKE_DIRECTORY).and_return(true)
112+
allow(File).to receive(:exist?).with(FAKE_DIRECTORY).and_return(true)
113113
allow(File).to receive(:directory?).with(FAKE_DIRECTORY).and_return(true)
114-
expect(File).to receive(:exists?).with("#{FAKE_DIRECTORY}/appspec-override.yaml").and_return(false)
114+
expect(File).to receive(:exist?).with("#{FAKE_DIRECTORY}/appspec-override.yaml").and_return(false)
115115
expect{validator.validate(args)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "Expecting appspec file at location #{FAKE_DIRECTORY}/appspec-override.yaml but it is not found there. Please either run the CLI from within a directory containing the appspec-override.yaml file or specify a bundle location containing an appspec-override.yaml file in its root directory")
116116
end
117117
end
@@ -129,7 +129,7 @@
129129
end
130130

131131
it 'throws a ValidationError' do
132-
allow(File).to receive(:exists?).with(FAKE_FILE_WHICH_DOES_NOT_EXIST).and_return(false)
132+
allow(File).to receive(:exist?).with(FAKE_FILE_WHICH_DOES_NOT_EXIST).and_return(false)
133133
expect{validator.validate(args)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "location #{FAKE_FILE_WHICH_DOES_NOT_EXIST} is specified as a file or directory which does not exist")
134134
end
135135
end
@@ -147,7 +147,7 @@
147147
end
148148

149149
it 'throws a ValidationError' do
150-
allow(File).to receive(:exists?).with(FAKE_FILE).and_return(true)
150+
allow(File).to receive(:exist?).with(FAKE_FILE).and_return(true)
151151
allow(File).to receive(:file?).with(FAKE_FILE).and_return(true)
152152
expect{validator.validate(args)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "location #{FAKE_FILE} is specified with type directory but it is a file")
153153
end
@@ -173,7 +173,7 @@
173173
end
174174

175175
it 'throws a ValidationError' do
176-
allow(File).to receive(:exists?).with(FAKE_DIRECTORY).and_return(true)
176+
allow(File).to receive(:exist?).with(FAKE_DIRECTORY).and_return(true)
177177
allow(File).to receive(:directory?).with(FAKE_DIRECTORY).and_return(true)
178178
expect{validator.validate(argszip)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "location #{FAKE_DIRECTORY} is specified as a compressed local file but it is a directory")
179179
expect{validator.validate(argstgz)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "location #{FAKE_DIRECTORY} is specified as a compressed local file but it is a directory")
@@ -189,9 +189,9 @@
189189
end
190190

191191
it 'throws a ValidationError' do
192-
allow(File).to receive(:exists?).with(FAKE_DIRECTORY).and_return(true)
192+
allow(File).to receive(:exist?).with(FAKE_DIRECTORY).and_return(true)
193193
allow(File).to receive(:directory?).with(FAKE_DIRECTORY).and_return(true)
194-
expect(File).to receive(:exists?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(true)
194+
expect(File).to receive(:exist?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(true)
195195
expect{validator.validate(args)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "The only events that can be specified before DownloadBundle are BeforeBlockTraffic,AfterBlockTraffic,ApplicationStop. Please fix the order of your specified events: #{args['--events']}")
196196
end
197197
end
@@ -205,9 +205,9 @@
205205
end
206206

207207
it 'throws a ValidationError' do
208-
allow(File).to receive(:exists?).with(FAKE_DIRECTORY).and_return(true)
208+
allow(File).to receive(:exist?).with(FAKE_DIRECTORY).and_return(true)
209209
allow(File).to receive(:directory?).with(FAKE_DIRECTORY).and_return(true)
210-
expect(File).to receive(:exists?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(true)
210+
expect(File).to receive(:exist?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(true)
211211
expect{validator.validate(args)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "The only events that can be specified before DownloadBundle are BeforeBlockTraffic,AfterBlockTraffic,ApplicationStop. Please fix the order of your specified events: #{args['--events']}")
212212
end
213213
end
@@ -221,9 +221,9 @@
221221
end
222222

223223
it 'throws a ValidationError' do
224-
allow(File).to receive(:exists?).with(FAKE_DIRECTORY).and_return(true)
224+
allow(File).to receive(:exist?).with(FAKE_DIRECTORY).and_return(true)
225225
allow(File).to receive(:directory?).with(FAKE_DIRECTORY).and_return(true)
226-
expect(File).to receive(:exists?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(true)
226+
expect(File).to receive(:exist?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(true)
227227
expect{validator.validate(args)}.to raise_error(AWS::CodeDeploy::Local::CLIValidator::ValidationError, "The only events that can be specified before Install are BeforeBlockTraffic,AfterBlockTraffic,ApplicationStop,DownloadBundle,BeforeInstall. Please fix the order of your specified events: #{args['--events']}")
228228
end
229229
end
@@ -237,9 +237,9 @@
237237
end
238238

239239
it 'returns the same arguments' do
240-
allow(File).to receive(:exists?).with(FAKE_DIRECTORY).and_return(true)
240+
allow(File).to receive(:exist?).with(FAKE_DIRECTORY).and_return(true)
241241
allow(File).to receive(:directory?).with(FAKE_DIRECTORY).and_return(true)
242-
expect(File).to receive(:exists?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(true)
242+
expect(File).to receive(:exist?).with("#{FAKE_DIRECTORY}/appspec.yml").and_return(true)
243243
expect(validator.validate(args)).to equal(args)
244244
end
245245
end

0 commit comments

Comments
 (0)