Class: Inspec::Resources::PodmanPod

Inherits:
Object
  • Object
show all
Includes:
Utils::Podman
Defined in:
lib/inspec/resources/podman_pod.rb

Constant Summary collapse

LABELS =
{
  "id" => "ID",
  "name" => "Name",
  "created_at" => "Created",
  "create_command" => "CreateCommand",
  "state" => "State",
  "hostname" => "Hostname",
  "create_cgroup" => "CreateCgroup",
  "cgroup_parent" => "CgroupParent",
  "cgroup_path" => "CgroupPath",
  "create_infra" => "CreateInfra",
  "infra_container_id" => "InfraContainerID",
  "infra_config" => "InfraConfig",
  "shared_namespaces" => "SharedNamespaces",
  "num_containers" => "NumContainers",
  "containers" => "Containers",
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Podman

#generate_go_template, #parse_command_output, #podman_running?

Constructor Details

#initialize(pod_id) ⇒ PodmanPod

Returns a new instance of PodmanPod.



40
41
42
43
44
45
46
# File 'lib/inspec/resources/podman_pod.rb', line 40

def initialize(pod_id)
  skip_resource "The `podman_pod` resource is not yet available on your OS." unless inspec.os.unix?
  raise Inspec::Exceptions::ResourceFailed, "Podman is not running. Please make sure it is installed and running." unless podman_running?

  @pod_id = pod_id
  @pod_info = get_pod_info
end

Instance Attribute Details

#pod_idObject (readonly)

Returns the value of attribute pod_id.



38
39
40
# File 'lib/inspec/resources/podman_pod.rb', line 38

def pod_id
  @pod_id
end

#pod_infoObject (readonly)

Returns the value of attribute pod_info.



38
39
40
# File 'lib/inspec/resources/podman_pod.rb', line 38

def pod_info
  @pod_info
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/inspec/resources/podman_pod.rb', line 73

def exist?
  !pod_info.empty?
end

#resource_idObject



77
78
79
# File 'lib/inspec/resources/podman_pod.rb', line 77

def resource_id
  pod_id
end

#to_sObject



81
82
83
# File 'lib/inspec/resources/podman_pod.rb', line 81

def to_s
  "Podman Pod #{resource_id}"
end