Skip to content

Commit 51e2886

Browse files
author
carabasdaniel
authored
Merge pull request #632 from puppetlabs/root_dir
(MODULES-10691) - Add root_dir in daemon.json
2 parents e6666cf + 2c48f10 commit 51e2886

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

spec/acceptance/docker_spec.rb

+30-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
raise 'Could not retrieve ip address for Windows box' if result.exit_code != 0
1010
ip = result.stdout.split("\n")[0].split(':')[1].strip
1111
@windows_ip = ip
12-
docker_arg = "docker_ee => true, extra_parameters => '\"insecure-registries\": [ \"#{@windows_ip}:5000\" ]'"
12+
docker_args = "docker_ee => true, extra_parameters => '\"insecure-registries\": [ \"#{@windows_ip}:5000\" ]'"
13+
root_dir = 'C:/Users/Administrator/AppData/Local/Temp'
1314
docker_registry_image = 'stefanscherer/registry-windows'
1415
docker_network = 'nat'
1516
registry_host = @windows_ip
1617
config_file = '/cygdrive/c/Users/Administrator/.docker/config.json'
17-
root_dir = 'C:/Users/Administrator/AppData/Local/Temp'
1818
server_strip = "#{registry_host}_#{registry_port}"
1919
bad_server_strip = "#{registry_host}_5001"
2020
broken = true
@@ -43,10 +43,10 @@
4343
context 'When adding system user', win_broken: broken do
4444
let(:pp) do
4545
"
46-
class { 'docker': #{docker_arg}
46+
class { 'docker': #{docker_args},
4747
docker_users => ['user1']
4848
}
49-
"
49+
"
5050
end
5151

5252
it 'the docker daemon' do
@@ -56,6 +56,31 @@ class { 'docker': #{docker_arg}
5656
end
5757
end
5858

59+
context 'When root_dir is set' do
60+
let(:pp) do
61+
"class { 'docker': #{docker_args}, root_dir => \"#{root_dir}\"}"
62+
end
63+
64+
let(:shell_command) do
65+
if os[:family] == 'windows'
66+
'cat C:/ProgramData/docker/config/daemon.json'
67+
else
68+
'systemctl status docker'
69+
end
70+
end
71+
72+
it 'works' do
73+
apply_manifest(pp, catch_failures: true)
74+
run_shell(shell_command) do |r|
75+
if os[:family] == 'windows'
76+
expect(r.stdout).to match(%r{\"data-root\": \"#{root_dir}\"})
77+
else
78+
expect(r.stdout).to match(%r{--data-root #{root_dir}})
79+
end
80+
end
81+
end
82+
end
83+
5984
context 'with default parameters', win_broken: broken do
6085
let(:pp) do
6186
"
@@ -177,7 +202,7 @@ class { 'docker':
177202

178203
it 'is able to run registry' do
179204
pp = <<-MANIFEST
180-
class { 'docker': #{docker_arg}}
205+
class { 'docker': #{docker_args}}
181206
docker::run { 'registry':
182207
image => '#{docker_registry_image}',
183208
pull_on_start => true,

templates/windows/config/daemon.json.erb

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<% if @extra_parameters %><% @extra_parameters_array.each do |param| %>
1818
<%= param %> ,<% end %>
1919
<% end -%>
20+
<% if @root_dir %>"data-root": "<%= @root_dir %>",<% end -%>
2021
"labels": <%= @labels_array.to_json %>
2122
}

0 commit comments

Comments
 (0)