Skip to content

Commit 3e47cac

Browse files
KatyalHelen1987
authored andcommitted
Fix to allow adcs endpoint to be configured through the config file instead
from an env variable. Prior to this change, the deploy_control_endpoint was being overridden incorrectly from environment , which in turn was causing issues when agent was running in a separate shell from where the env variable was set up. This change adds :deploy_control_endpoint as a config variable * Unit Tests : Y * Integration Tests : Y (but will be tested more extensively in pipeline) cr https://code.amazon.com/reviews/CR-8897225
1 parent 7a58ba9 commit 3e47cac

File tree

7 files changed

+14
-12
lines changed

7 files changed

+14
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
``` ruby
99
git clone https://github.com/aws/aws-codedeploy-agent.git
10-
gem install bundler
10+
gem install bundler -v 1.3.5
1111
cd aws-codedeploy-agent
1212
bundle install
1313
rake clean && rake

bin/update

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ EOF
9797
end
9898

9999
def supported_ruby_versions
100-
['2.4', '2.3', '2.2', '2.1', '2.0']
100+
['2.5', '2.4', '2.3', '2.2', '2.1', '2.0']
101101
end
102102

103103
# check ruby version, only version 2.x works

lib/instance_agent/config.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def initialize
4141
:on_premises_config_file => '/etc/codedeploy-agent/conf/codedeploy.onpremises.yml',
4242
:proxy_uri => nil,
4343
:enable_deployments_log => true,
44-
:use_fips_mode => false
44+
:use_fips_mode => false,
45+
:deploy_control_endpoint => nil
4546
})
4647
end
4748

lib/instance_agent/plugins/codedeploy/command_poller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def initialize
3838
region = ENV['AWS_REGION'] || InstanceMetadata.region
3939
@host_identifier = ENV['AWS_HOST_IDENTIFIER'] || InstanceMetadata.host_identifier
4040

41-
log(:debug, "Configuring deploy control client: Region = #{region.inspect}")
42-
log(:debug, "Deploy control endpoint override = " + ENV['AWS_DEPLOY_CONTROL_ENDPOINT'].inspect)
41+
log(:debug, "Configuring deploy control client: Region=#{region.inspect}")
42+
log(:debug, "Deploy control endpoint override=#{InstanceAgent::Config.config[:deploy_control_endpoint]}")
4343

4444
@deploy_control = InstanceAgent::Plugins::CodeDeployPlugin::CodeDeployControl.new(:region => region, :logger => InstanceAgent::Log, :ssl_ca_directory => ENV['AWS_SSL_CA_DIRECTORY'])
4545
@deploy_control_client = @deploy_control.get_client

test/instance_agent/config_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class InstanceAgentConfigTest < InstanceAgentTestCase
3232
:proxy_uri => nil,
3333
:enable_deployments_log => true,
3434
:kill_agent_max_wait_time_seconds => 7200,
35-
:use_fips_mode => false
35+
:use_fips_mode => false,
36+
:deploy_control_endpoint => nil
3637
}, InstanceAgent::Config.config)
3738
end
3839

test/instance_agent/plugins/codedeploy/codedeploy_control_test.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class CodeDeployControlTest < InstanceAgentTestCase
3636

3737
context "without an endpoint" do
3838
setup do
39-
ENV['AWS_DEPLOY_CONTROL_ENDPOINT'] = nil
39+
InstanceAgent::Config.config[:deploy_control_endpoint] = nil
4040
end
4141

4242
should "raise an exception" do
@@ -53,17 +53,17 @@ class CodeDeployControlTest < InstanceAgentTestCase
5353

5454
context "with ADCS endpoint set in an environment variable" do
5555
setup do
56-
ENV['AWS_DEPLOY_CONTROL_ENDPOINT'] = "https://tempuri"
56+
InstanceAgent::Config.config[:deploy_control_endpoint] = "https://tempuri"
5757
end
5858

5959
should "use endpoint from environment variable" do
6060
codedeploy_control_client = CodeDeployControl.new :region => "us-west-2"
6161
assert_equal "tempuri", codedeploy_control_client.get_client.config.endpoint.host
6262
end
6363

64-
cleanup do
65-
ENV['AWS_DEPLOY_CONTROL_ENDPOINT'] = nil
66-
end
64+
cleanup do
65+
InstanceAgent::Config.config[:deploy_control_endpoint] = nil
66+
end
6767
end
6868

6969
context "with use_fips_mode not set" do

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Aws
44
module Plugins
55
class DeployControlEndpoint < Seahorse::Client::Plugin
66
option(:endpoint) do |cfg|
7-
url = ENV['AWS_DEPLOY_CONTROL_ENDPOINT']
7+
url = InstanceAgent::Config.config[:deploy_control_endpoint]
88
if url.nil?
99
url = "https://codedeploy-commands"
1010
if InstanceAgent::Config.config[:use_fips_mode]

0 commit comments

Comments
 (0)