Skip to content

Commit

Permalink
Added support for the 'registry-mirror' docker daemon option.
Browse files Browse the repository at this point in the history
  • Loading branch information
jperville committed Nov 12, 2014
1 parent 0fd4fb5 commit 19d1f5e
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ no_proxy | NO_PROXY environment variable | String | nil
options | Additional options to pass to docker. These could be flags like "-api-enable-cors". | String | nil
pidfile | Path to use for daemon PID file | String | nil (implicitly /var/run/docker.pid)
ramdisk | Set DOCKER_RAMDISK when using RAM disk | TrueClass or FalseClass | false
registry-mirror | List of docker registry mirrors | String, Array | nil
restart | Restart containers on boot | TrueClass or FalseClass | auto-detected (see attributes/default.rb)
selinux_enabled | Enable SELinux | TrueClass or FalseClass | nil
storage_driver | Storage driver for docker | String | nil
Expand Down
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
default['docker']['options'] = nil
default['docker']['pidfile'] = nil
default['docker']['ramdisk'] = false
default['docker']['registry-mirror'] = nil
default['docker']['selinux_enabled'] = nil
default['docker']['storage_driver'] = nil
default['docker']['storage_opt'] = nil
Expand Down
1 change: 1 addition & 0 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def self.daemon_cli_args(node)
'iptables' => node['docker']['iptables'],
'mtu' => node['docker']['mtu'],
'pidfile' => node['docker']['pidfile'],
'registry-mirror' => Array(node['docker']['registry-mirror']),
'restart' => node['docker']['restart'],
'selinux-enabled' => node['docker']['selinux_enabled'],
'storage-driver' => node['docker']['storage_driver'],
Expand Down
26 changes: 26 additions & 0 deletions spec/systemd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,32 @@
end
end

context 'when registry-mirror is set with String' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['registry-mirror'] = 'http://registry.example.com:1337'
runner.converge(described_recipe)
end

it 'adds registry-mirror flag to docker service' do
expect(chef_run).to render_file('/usr/lib/systemd/system/docker.service').with_content(
%r{^ExecStart=/usr/bin/docker -d.* --registry-mirror=http://registry\.example\.com:1337.*})
end
end

context 'when registry-mirror is set with Array' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['registry-mirror'] = %w(http://registry.example.com:1337 http://registry.example.com:1338)
runner.converge(described_recipe)
end

it 'adds registry-mirror flags to docker service' do
expect(chef_run).to render_file('/usr/lib/systemd/system/docker.service').with_content(
%r{^ExecStart=/usr/bin/docker -d.* --registry-mirror=http://registry\.example\.com:1337 --registry-mirror=http://registry\.example\.com:1338.*})
end
end

context 'when storage_driver is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down
26 changes: 26 additions & 0 deletions spec/sysv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,32 @@
end
end

context 'when registry-mirror is set with String' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['registry-mirror'] = 'http://registry.example.com:1337'
runner.converge(described_recipe)
end

it 'adds registry-mirror flag to docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
%r{^DOCKER_OPTS='.* --registry-mirror=http://registry\.example\.com:1337.*'$})
end
end

context 'when registry-mirror is set with Array' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['registry-mirror'] = %w(http://registry.example.com:1337 http://registry.example.com:1338)
runner.converge(described_recipe)
end

it 'adds registry-mirror flags to docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
%r{^DOCKER_OPTS='.* --registry-mirror=http://registry\.example\.com:1337 --registry-mirror=http://registry\.example\.com:1338.*'$})
end
end

context 'when storage_driver is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down
26 changes: 26 additions & 0 deletions spec/upstart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,32 @@
end
end

context 'when registry-mirror is set with String' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['registry-mirror'] = 'http://registry.example.com:1337'
runner.converge(described_recipe)
end

it 'adds registry-mirror flag to docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
%r{^DOCKER_OPTS='.* --registry-mirror=http://registry\.example\.com:1337.*'$})
end
end

context 'when registry-mirror is set with Array' do
let(:chef_run) do
runner = ChefSpec::Runner.new
runner.node.set['docker']['registry-mirror'] = %w(http://registry.example.com:1337 http://registry.example.com:1338)
runner.converge(described_recipe)
end

it 'adds registry-mirror flags to docker service' do
expect(chef_run).to render_file('/etc/default/docker').with_content(
%r{^DOCKER_OPTS='.* --registry-mirror=http://registry\.example\.com:1337 --registry-mirror=http://registry\.example\.com:1338.*'$})
end
end

context 'when storage_driver is set' do
let(:chef_run) do
runner = ChefSpec::Runner.new
Expand Down

0 comments on commit 19d1f5e

Please sign in to comment.