Skip to content

Commit 0938fe1

Browse files
committed
move loading version tracking file into initialize block
1 parent a4e8cec commit 0938fe1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

vendor/gems/codedeploy-commands-1.0.0/lib/aws/plugins/deploy_agent_version.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ module Aws
22
module Plugins
33
class DeployAgentVersion < Seahorse::Client::Plugin
44
class Handler < Seahorse::Client::Handler
5-
def call(context)
5+
def initialize(handler = nil)
6+
@handler = handler
67
file_path = File.join(ProcessManager::Config.config[:version_dir], '.version')
78
if File.exist?(file_path)
8-
agent_version = File.read(file_path).chomp.split(': ').last
9+
@agent_version ||= File.read(file_path).split(': ').last.strip
910
else
10-
agent_version = "UNKNOWN_VERSION"
11+
@agent_version ||= "UNKNOWN_VERSION"
1112
log(:warn, "Version tracking file doesn't exist in directory #{file_path}")
1213
end
14+
end
1315

14-
context.http_request.headers['x-amz-codedeploy-agent-version'] = agent_version
16+
def call(context)
17+
context.http_request.headers['x-amz-codedeploy-agent-version'] = @agent_version
1518
@handler.call(context)
1619
end
1720

0 commit comments

Comments
 (0)