Class: Inspec::Resources::DockerImage

Inherits:
Object
  • Object
show all
Includes:
DockerObject
Defined in:
lib/inspec/resources/docker_image.rb

Instance Method Summary collapse

Methods included from DockerObject

#exist?, #id

Constructor Details

#initialize(opts = {}) ⇒ DockerImage

Returns a new instance of DockerImage.



32
33
34
35
36
37
# File 'lib/inspec/resources/docker_image.rb', line 32

def initialize(opts = {})
  # do sanitizion of input values
  o = opts.dup
  o = { image: opts } if opts.is_a?(String)
  @opts = sanitize_options(o)
end

Instance Method Details

#imageObject



39
40
41
# File 'lib/inspec/resources/docker_image.rb', line 39

def image
  "#{repo}:#{tag}" if object_info.entries.size == 1
end

#repoObject



43
44
45
# File 'lib/inspec/resources/docker_image.rb', line 43

def repo
  object_info.repositories[0] if object_info.entries.size == 1
end

#tagObject



47
48
49
# File 'lib/inspec/resources/docker_image.rb', line 47

def tag
  object_info.tags[0] if object_info.entries.size == 1
end

#to_sObject



51
52
53
54
# File 'lib/inspec/resources/docker_image.rb', line 51

def to_s
  img = @opts[:image] || @opts[:id]
  "Docker Image #{img}"
end