Class: Inspec::Resources::DockerImage
- Inherits:
-
Object
- Object
- Inspec::Resources::DockerImage
- Defined in:
- lib/resources/docker_image.rb
Instance Method Summary collapse
- #exist? ⇒ Boolean
- #id ⇒ Object
- #image ⇒ Object
-
#initialize(opts = {}) ⇒ DockerImage
constructor
A new instance of DockerImage.
- #repo ⇒ Object
- #tag ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ DockerImage
Returns a new instance of DockerImage.
31 32 33 34 35 36 |
# File 'lib/resources/docker_image.rb', line 31 def initialize(opts = {}) # do sanitizion of input values o = opts.dup o = { image: opts } if opts.is_a?(String) @opts = (o) end |
Instance Method Details
#exist? ⇒ Boolean
38 39 40 |
# File 'lib/resources/docker_image.rb', line 38 def exist? image_info.exists? end |
#id ⇒ Object
42 43 44 |
# File 'lib/resources/docker_image.rb', line 42 def id image_info.ids[0] if image_info.entries.size == 1 end |
#image ⇒ Object
46 47 48 |
# File 'lib/resources/docker_image.rb', line 46 def image "#{repo}:#{tag}" if image_info.entries.size == 1 end |
#repo ⇒ Object
50 51 52 |
# File 'lib/resources/docker_image.rb', line 50 def repo image_info.repositories[0] if image_info.entries.size == 1 end |
#tag ⇒ Object
54 55 56 |
# File 'lib/resources/docker_image.rb', line 54 def tag image_info.[0] if image_info.entries.size == 1 end |
#to_s ⇒ Object
58 59 60 61 |
# File 'lib/resources/docker_image.rb', line 58 def to_s img = @opts[:image] || @opts[:id] "Docker Image #{img}" end |