Skip to content

Commit

Permalink
Merge pull request #536 from DarrellMozingo/docker_config_with_index
Browse files Browse the repository at this point in the history
Add access to Docker config arrays.
  • Loading branch information
mizzy committed Sep 24, 2015
2 parents e5ee36e + 7a6e491 commit 16ed51d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/serverspec/type/docker_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def exist?
def [](key)
value = inspection
key.split('.').each do |k|
value = value[k]
is_index = k.start_with?('[') && k.end_with?(']')
value = value[is_index ? k.to_i : k]
end
value
end
Expand Down
10 changes: 9 additions & 1 deletion spec/type/linux/docker_container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
it { should have_volume('/tmp', '/data') }
its(:inspection) { should include 'Driver' => 'aufs' }
its(['Config.Cmd']) { should include '/bin/sh' }
its(['HostConfig.PortBindings.80.[0].HostPort']) { should eq '8080' }
end

describe docker_container('restarting') do
Expand Down Expand Up @@ -73,7 +74,14 @@ def inspect_container
"Links": null,
"LxcConf": [],
"NetworkMode": "bridge",
"PortBindings": {},
"PortBindings": {
"80": [
{
"HostIp": "",
"HostPort": "8080"
}
]
},
"Privileged": false,
"PublishAllPorts": false,
"VolumesFrom": null
Expand Down

0 comments on commit 16ed51d

Please sign in to comment.