Class: Inspec::Resources::DockerImage
- Inherits:
-
Object
- Object
- Inspec::Resources::DockerImage
show all
- Includes:
- DockerObject
- Defined in:
- lib/inspec/resources/docker_image.rb
Instance Method Summary
collapse
#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 = {})
o = opts.dup
o = { image: opts } if opts.is_a?(String)
@opts = sanitize_options(o)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*hash_keys) ⇒ Object
method_missing handles when hash_keys are invoked to check information obtained on docker inspect [image_name]
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/inspec/resources/docker_image.rb', line 52
def method_missing(*hash_keys)
image_hash_inspection(hash_keys)
end
|
Instance Method Details
#image ⇒ Object
39
40
41
|
# File 'lib/inspec/resources/docker_image.rb', line 39
def image
"#{repo}:#{tag}" if object_info.entries.size == 1
end
|
#inspection ⇒ Object
inspection property allows to test any of the hash key-value pairs as part of the image_inspect_info
66
67
68
|
# File 'lib/inspec/resources/docker_image.rb', line 66
def inspection
image_inspect_info
end
|
#repo ⇒ Object
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
|
#resource_id ⇒ Object
75
76
77
|
# File 'lib/inspec/resources/docker_image.rb', line 75
def resource_id
object_info.ids[0] || @opts[:id] || @opts[:image] || ""
end
|
#tag ⇒ Object
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_s ⇒ Object
70
71
72
73
|
# File 'lib/inspec/resources/docker_image.rb', line 70
def to_s
img = @opts[:image] || @opts[:id]
"Docker Image #{img}"
end
|