Skip to content

Commit

Permalink
@ teracyhq#405 | add config_path for the docker_registry recipe to re…
Browse files Browse the repository at this point in the history
…move the hard coded parts
  • Loading branch information
hoatle committed Jan 16, 2018
1 parent 331725a commit 91d05d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 9 additions & 5 deletions main-cookbooks/teracy-dev/recipes/docker_registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@

docker_registry_conf = node['docker_registry']

docker_config_path = docker_registry_conf['config_path']


if docker_conf['enabled'] == true
execute 'rm ~/.docker/config.json' do
command 'rm /home/vagrant/.docker/config.json || true'
command "rm #{docker_config_path} || true"
only_if {
docker_registry_conf['force'] == true and
File.exist?('/home/vagrant/.docker/config.json')
File.exist?(docker_config_path)
}
end

docker_registry_conf['entries'].each.with_index do |entry, index|
docker_registry_conf['entries'].each do |entry|
# private registry login

username = entry['username'] ? entry['username'] : ''
Expand All @@ -40,12 +43,13 @@
end
end


execute 'copy /root/.docker/config.json to ~/.docker/config.json' do
command 'cp /root/.docker/config.json /home/vagrant/.docker/config.json'
command "cp /root/.docker/config.json #{docker_config_path}"
only_if {
File.exist?('/root/.docker/config.json') and (
docker_registry_conf['force'] == true or
not File.exist?('/home/vagrant/.docker/config.json')
not File.exist?(docker_config_path)
)
}
end
Expand Down
1 change: 1 addition & 0 deletions vagrant_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"docker_registry": {
// set true to force re-login with all the defined entries, default: false (login once)
"force": false,
"config_path": "/home/vagrant/.docker/config.json",
"entries": []
// example:
// "entries": [
Expand Down

0 comments on commit 91d05d5

Please sign in to comment.