Class: PodmanContainer
- Inherits:
-
Object
- Object
- PodmanContainer
- Includes:
- PodmanObject
- Defined in:
- lib/inspec-podman-resources/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 PodmanObject
Constructor Details
#initialize(opts = {}) ⇒ PodmanContainer
Returns a new instance of PodmanContainer.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 28 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
55 56 57 58 59 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 55 def command return unless object_info.entries.length == 1 object_info.commands[0] end |
#image ⇒ Object
61 62 63 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 61 def image object_info.images[0] if object_info.entries.length == 1 end |
#labels ⇒ Object
47 48 49 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 47 def labels object_info.labels end |
#ports ⇒ Object
51 52 53 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 51 def ports object_info.ports[0] if object_info.entries.length == 1 end |
#resource_id ⇒ Object
65 66 67 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 65 def resource_id object_info.ids[0] || @opts[:id] || @opts[:name] || "" end |
#running? ⇒ Boolean
39 40 41 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 39 def running? status.downcase.start_with?("up") if object_info.entries.length == 1 end |
#status ⇒ Object
43 44 45 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 43 def status object_info.status[0] if object_info.entries.length == 1 end |
#to_s ⇒ Object
69 70 71 72 |
# File 'lib/inspec-podman-resources/resources/podman_container.rb', line 69 def to_s name = @opts[:name] || @opts[:id] "Podman Container #{name}" end |