Skip to content

Commit

Permalink
remove version directory from config file
Browse files Browse the repository at this point in the history
  • Loading branch information
feverLu committed Nov 17, 2015
1 parent 0938fe1 commit 1850735
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion conf/codedeployagent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
:program_name: codedeploy-agent
:root_dir: '/opt/codedeploy-agent/deployment-root'
:verbose: false
:version_dir: '/opt/codedeploy-agent/'
:wait_between_runs: 1
:proxy_uri:
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@ class DeployAgentVersion < Seahorse::Client::Plugin
class Handler < Seahorse::Client::Handler
def initialize(handler = nil)
@handler = handler
file_path = File.join(ProcessManager::Config.config[:version_dir], '.version')
file_path = get_version_tracking_file
if File.exist?(file_path)
@agent_version ||= File.read(file_path).split(': ').last.strip
else
@agent_version ||= "UNKNOWN_VERSION"
log(:warn, "Version tracking file doesn't exist in directory #{file_path}")
log(:warn, "Version tracking file either does not exist or cannot be read.")
end
end

def call(context)
context.http_request.headers['x-amz-codedeploy-agent-version'] = @agent_version
@handler.call(context)
end

def get_version_tracking_file
version_dir = ProcessManager::Config.config[:root_dir]
if version_dir.eql? 'Amazon/CodeDeploy'
file_path = File.join(version_dir, '.version')
else
file_path = File.join(version_dir, '..', '.version')
end
end

private
def log(severity, message)
Expand Down

0 comments on commit 1850735

Please sign in to comment.