Class: Inspec::Resources::DockerImage

Inherits:
Object
  • Object
show all
Includes:
DockerObject
Defined in:
lib/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.



35
36
37
38
39
40
# File 'lib/resources/docker_image.rb', line 35

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



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

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

#repoObject



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

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

#tagObject



50
51
52
# File 'lib/resources/docker_image.rb', line 50

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

#to_sObject



54
55
56
57
# File 'lib/resources/docker_image.rb', line 54

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