Skip to content

Commit f1c0caa

Browse files
committed
Added environment variables support
2 parents 2b1d9dc + 5695428 commit f1c0caa

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

metadata.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
license 'MIT'
77
description 'Installs/Configures ama-docker-compose'
88
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
9-
version '0.1.1'
9+
version '0.1.2'
1010

1111
supports 'debian', '>= 7.0'
1212
supports 'ubuntu', '>= 14.04'

resources/docker_compose_deployment.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
attribute :shell_timeout, Integer, default: 300
1010
attribute :signal, String, default: 'SIGKILL'
1111
attribute :scale, String
12+
attribute :environment, [Hash, NilClass], default: {}
1213

1314
action_class do
1415
def configuration_files
@@ -23,9 +24,12 @@ def execute(*arguments)
2324
end
2425
command = command.concat(arguments)
2526
parameters = {}
26-
if @new_resource.shell_timeout and new_resource.shell_timeout > 0
27+
if new_resource.shell_timeout and new_resource.shell_timeout > 0
2728
parameters[:timeout] = new_resource.shell_timeout
2829
end
30+
if new_resource.environment
31+
parameters[:environment] = new_resource.environment
32+
end
2933
execution = Mixlib::ShellOut.new(*command, parameters).run_command
3034
execution.error!
3135
end

test/cookbooks/ama-docker-compose-integration/recipes/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@
3636
include_recipe '::deployment_up_and_kill'
3737
include_recipe '::deployment_lifecycle'
3838
include_recipe '::deployment_up_and_down_with_different_executable'
39+
include_recipe '::deployment_environment'
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Cookbook Name:: ama-docker-compose-integration
3+
# Recipe:: deployment_environment
4+
#
5+
# Copyright 2017, AMA Team
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining
8+
# a copy of this software and associated documentation files (the
9+
# "Software"), to deal in the Software without restriction, including
10+
# without limitation the rights to use, copy, modify, merge, publish,
11+
# distribute, sublicense, and/or sell copies of the Software, and to
12+
# permit persons to whom the Software is furnished to do so, subject to
13+
# the following conditions:
14+
#
15+
# The above copyright notice and this permission notice shall be
16+
# included in all copies or substantial portions of the Software.
17+
#
18+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25+
#
26+
27+
workspace = workspace_directory!('environment')
28+
path = ::File.join(workspace, 'docker-compose-custom.yml')
29+
custom_path = ::File.join(workspace, 'docker-compose-custom.yml')
30+
31+
cookbook_file custom_path do
32+
source 'docker-compose.yml'
33+
end
34+
35+
# It should bring up deployment even though compose file path is not
36+
# supplied directly
37+
docker_compose_deployment 'fake://path' do
38+
files([])
39+
environment(COMPOSE_FILE: custom_path)
40+
action [:up, :kill]
41+
end

test/integration/default/controls/installation.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
end
2525
end
2626

27-
2827
control 'existing installation removal' do
2928
describe docker_compose_installation(profile.workspace('existing-installation-removal/docker-compose')) do
3029
it { should_not exist }

0 commit comments

Comments
 (0)