Class: DockerImage
- Inherits:
-
Object
show all
- Includes:
- DockerObject
- Defined in:
- lib/inspec-docker-resources/resources/docker_image.rb
Instance Method Summary
collapse
#exist?, #id
Constructor Details
#initialize(opts = {}) ⇒ DockerImage
Returns a new instance of DockerImage.
31
32
33
34
35
36
|
# File 'lib/inspec-docker-resources/resources/docker_image.rb', line 31
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]
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/inspec-docker-resources/resources/docker_image.rb', line 51
def method_missing(*hash_keys)
image_hash_inspection(hash_keys)
end
|
Instance Method Details
#image ⇒ Object
38
39
40
|
# File 'lib/inspec-docker-resources/resources/docker_image.rb', line 38
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
65
66
67
|
# File 'lib/inspec-docker-resources/resources/docker_image.rb', line 65
def inspection
image_inspect_info
end
|
#repo ⇒ Object
42
43
44
|
# File 'lib/inspec-docker-resources/resources/docker_image.rb', line 42
def repo
object_info.repositories[0] if object_info.entries.size == 1
end
|
#resource_id ⇒ Object
74
75
76
|
# File 'lib/inspec-docker-resources/resources/docker_image.rb', line 74
def resource_id
object_info.ids[0] || @opts[:id] || @opts[:image] || ""
end
|
#tag ⇒ Object
46
47
48
|
# File 'lib/inspec-docker-resources/resources/docker_image.rb', line 46
def tag
object_info.tags[0] if object_info.entries.size == 1
end
|
#to_s ⇒ Object
69
70
71
72
|
# File 'lib/inspec-docker-resources/resources/docker_image.rb', line 69
def to_s
img = @opts[:image] || @opts[:id]
"Docker Image #{img}"
end
|