Class: Inspec::Resources::PodmanContainer
- Inherits:
-
Object
- Object
- Inspec::Resources::PodmanContainer
- Includes:
- DockerObject
- Defined in:
- lib/inspec/resources/podman_container.rb
Instance Method Summary collapse
- #command ⇒ Object
- #image ⇒ Object
-
#initialize(opts = {}) ⇒ PodmanContainer
constructor
A new instance of PodmanContainer.
- #labels ⇒ Object
- #ports ⇒ Object
- #resource_id ⇒ Object
- #running? ⇒ Boolean
- #status ⇒ Object
- #to_s ⇒ Object
Methods included from DockerObject
Constructor Details
#initialize(opts = {}) ⇒ PodmanContainer
Returns a new instance of PodmanContainer.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/inspec/resources/podman_container.rb', line 29 def initialize(opts = {}) skip_resource "The `podman_container` resource is not yet available on your OS." unless inspec.os.unix? # if a string is provided, we expect it is the name if opts.is_a?(String) @opts = { name: opts } else @opts = opts end end |
Instance Method Details
#command ⇒ Object
56 57 58 59 60 |
# File 'lib/inspec/resources/podman_container.rb', line 56 def command return unless object_info.entries.length == 1 object_info.commands[0] end |
#image ⇒ Object
62 63 64 |
# File 'lib/inspec/resources/podman_container.rb', line 62 def image object_info.images[0] if object_info.entries.length == 1 end |
#labels ⇒ Object
48 49 50 |
# File 'lib/inspec/resources/podman_container.rb', line 48 def labels object_info.labels end |
#ports ⇒ Object
52 53 54 |
# File 'lib/inspec/resources/podman_container.rb', line 52 def ports object_info.ports[0] if object_info.entries.length == 1 end |
#resource_id ⇒ Object
66 67 68 |
# File 'lib/inspec/resources/podman_container.rb', line 66 def resource_id object_info.ids[0] || @opts[:id] || @opts[:name] || "" end |
#running? ⇒ Boolean
40 41 42 |
# File 'lib/inspec/resources/podman_container.rb', line 40 def running? status.downcase.start_with?("up") if object_info.entries.length == 1 end |
#status ⇒ Object
44 45 46 |
# File 'lib/inspec/resources/podman_container.rb', line 44 def status object_info.status[0] if object_info.entries.length == 1 end |
#to_s ⇒ Object
70 71 72 73 |
# File 'lib/inspec/resources/podman_container.rb', line 70 def to_s name = @opts[:name] || @opts[:id] "Podman Container #{name}" end |