• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aws / aws-codedeploy-agent / 4600315001

pending completion
4600315001

push

github

GitHub
Updating latest version info for master branch

1129 of 2362 relevant lines covered (47.8%)

2.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

21.88
/lib/instance_agent/plugins/codedeploy/onpremise_config.rb
1
require 'instance_agent/file_credentials'
1✔
2

3
module InstanceAgent
1✔
4
  module Plugins
1✔
5
    module CodeDeployPlugin
1✔
6
      class OnPremisesConfig
1✔
7
        def self.configure
1✔
8
          file_path = InstanceAgent::Config.config[:on_premises_config_file]
×
9
          file_config = nil
×
10
          if File.exists?(file_path) && File.readable?(file_path)
×
11
            begin
12
              file_config = YAML.load(File.read(file_path)).symbolize_keys
×
13
            rescue
14
              log(:error, "Invalid on premises config file")
×
15
              raise "The deployment failed because the format of the following on-premises configuration file is invalid: #{file_path}"
×
16
            end
17
          else
18
            log(:info, "On Premises config file does not exist or not readable")
×
19
          end
20
          return unless file_config
×
21

22
          raise "On Premises config cannot contain both 'iam_user_arn' and 'iam_session_arn' keys." if file_config[:iam_user_arn] and file_config[:iam_session_arn]
×
23
          if file_config[:iam_user_arn]
×
24
            [:region, :aws_access_key_id, :aws_secret_access_key].each do |field|
×
25
              raise "'#{field}' key is required when 'iam_user_arn' is provided." unless file_config[field]
×
26
            end
27
            ENV['AWS_REGION'] = file_config[:region]
×
28
            ENV['AWS_ACCESS_KEY'] = file_config[:aws_access_key_id]
×
29
            ENV['AWS_SECRET_KEY'] = file_config[:aws_secret_access_key]
×
30
            ENV['AWS_HOST_IDENTIFIER'] = file_config[:iam_user_arn]
×
31
          elsif file_config[:iam_session_arn]
×
32
            [:region, :aws_credentials_file].each do |field|
×
33
              raise "'#{field}' key is required when 'iam_session_arn' is provided." unless file_config[field]
×
34
            end
35
            ENV['AWS_REGION'] = file_config[:region]
×
36
            ENV['AWS_HOST_IDENTIFIER'] = file_config[:iam_session_arn]
×
37
            ENV['AWS_CREDENTIALS_FILE'] = file_config[:aws_credentials_file]
×
38
            Aws.config[:credentials] = InstanceAgent::FileCredentials.new(file_config[:aws_credentials_file])
×
39
          end
40
        end
41

42
        def self.log(severity, message)
1✔
43
          raise ArgumentError, "Unknown severity #{severity.inspect}" unless InstanceAgent::Log::SEVERITIES.include?(severity.to_s)
×
44
          InstanceAgent::Log.send(severity.to_sym, "#{message}")
×
45
        end
46
      end
47
    end
48
  end
49
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc