class Aws::Plugins::DeployAgentVersion::Handler

Public Class Methods

new(handler = nil) click to toggle source
# File vendor/gems/codedeploy-commands/lib/aws/plugins/deploy_agent_version.rb, line 5
def initialize(handler = nil)
  @handler = handler
  file_path = File.expand_path(File.join(InstanceAgent::Platform.util.codedeploy_version_file, '.version'))
  if File.exist?(file_path)
    @agent_version ||= File.read(file_path).split(': ').last.strip
  else 
    @agent_version ||= "UNKNOWN_VERSION"
    log(:warn, "Version tracking file either does not exist or cannot be read in #{file_path}.")
  end
end

Public Instance Methods

call(context) click to toggle source
# File vendor/gems/codedeploy-commands/lib/aws/plugins/deploy_agent_version.rb, line 16
def call(context)
  context.http_request.headers['x-amz-codedeploy-agent-version'] = @agent_version
  @handler.call(context)
end

Private Instance Methods

log(severity, message) click to toggle source
# File vendor/gems/codedeploy-commands/lib/aws/plugins/deploy_agent_version.rb, line 22
def log(severity, message)
  raise ArgumentError, "Unknown severity #{severity.inspect}" unless InstanceAgent::Log::SEVERITIES.include?(severity.to_s)
  InstanceAgent::Log.send(severity.to_sym, "#{message}")
end