Class: Inspec::Resources::PodmanContainer

Inherits:
Object
  • Object
show all
Includes:
DockerObject
Defined in:
lib/inspec/resources/podman_container.rb

Instance Method Summary collapse

Methods included from DockerObject

#exist?, #id

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

#commandObject



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

#imageObject



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

#labelsObject



48
49
50
# File 'lib/inspec/resources/podman_container.rb', line 48

def labels
  object_info.labels
end

#portsObject



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_idObject



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

Returns:

  • (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

#statusObject



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_sObject



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