Class: Inspec::Resources::Docker

Inherits:
Object
  • Object
show all
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

Instance Method Details

#containersObject



100
101
102
# File 'lib/resources/docker.rb', line 100

def containers
  DockerContainerFilter.new(parse_containers)
end

#imagesObject



104
105
106
# File 'lib/resources/docker.rb', line 104

def images
  DockerImageFilter.new(parse_images)
end

#infoObject



114
115
116
117
118
# File 'lib/resources/docker.rb', line 114

def info
  return @info if defined?(@info)
  data = JSON.parse(inspec.command('docker info --format \'{{ json . }}\'').stdout)
  @info = Hashie::Mash.new(data)
end

#object(id) ⇒ Object

returns information about docker objects



121
122
123
124
125
126
# File 'lib/resources/docker.rb', line 121

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)
end

#to_sObject



128
129
130
# File 'lib/resources/docker.rb', line 128

def to_s
  'Docker Host'
end

#versionObject



108
109
110
111
112
# File 'lib/resources/docker.rb', line 108

def version
  return @version if defined?(@version)
  data = JSON.parse(inspec.command('docker version --format \'{{ json . }}\'').stdout)
  @version = Hashie::Mash.new(data)
end