Class: Inspec::Resources::Docker
- Inherits:
-
Object
- Object
- Inspec::Resources::Docker
- Defined in:
- lib/resources/docker.rb
Overview
This resource helps to parse information from the docker host For compatability with Serverspec we also offer the following resouses:
-
docker_container
-
docker_image
Instance Method Summary collapse
- #containers ⇒ Object
- #images ⇒ Object
- #info ⇒ Object
-
#object(id) ⇒ Object
returns information about docker objects.
- #plugins ⇒ Object
- #services ⇒ Object
- #to_s ⇒ Object
- #version ⇒ Object
Instance Method Details
#containers ⇒ Object
132 133 134 |
# File 'lib/resources/docker.rb', line 132 def containers DockerContainerFilter.new(parse_containers) end |
#images ⇒ Object
136 137 138 |
# File 'lib/resources/docker.rb', line 136 def images DockerImageFilter.new(parse_images) end |
#info ⇒ Object
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/resources/docker.rb', line 158 def info return @info if defined?(@info) data = {} # docke info format is only supported for Docker 17.03+ cmd = inspec.command('docker info --format \'{{ json . }}\'') data = JSON.parse(cmd.stdout) if cmd.exit_status == 0 @info = Hashie::Mash.new(data) rescue JSON::ParserError => _e return Hashie::Mash.new({}) end |
#object(id) ⇒ Object
returns information about docker objects
170 171 172 173 174 175 176 177 |
# File 'lib/resources/docker.rb', line 170 def object(id) return @inspect if defined?(@inspect) data = JSON.parse(inspec.command("docker inspect #{id}").stdout) data = data[0] if data.is_a?(Array) @inspect = Hashie::Mash.new(data) rescue JSON::ParserError => _e return Hashie::Mash.new({}) end |
#plugins ⇒ Object
140 141 142 |
# File 'lib/resources/docker.rb', line 140 def plugins DockerPluginFilter.new(parse_plugins) end |
#services ⇒ Object
144 145 146 |
# File 'lib/resources/docker.rb', line 144 def services DockerServiceFilter.new(parse_services) end |
#to_s ⇒ Object
179 180 181 |
# File 'lib/resources/docker.rb', line 179 def to_s 'Docker Host' end |
#version ⇒ Object
148 149 150 151 152 153 154 155 156 |
# File 'lib/resources/docker.rb', line 148 def version return @version if defined?(@version) data = {} cmd = inspec.command('docker version --format \'{{ json . }}\'') data = JSON.parse(cmd.stdout) if cmd.exit_status == 0 @version = Hashie::Mash.new(data) rescue JSON::ParserError => _e return Hashie::Mash.new({}) end |