Class: PodmanPod

Inherits:
Object
  • Object
show all
Includes:
Utils::Podman
Defined in:
lib/inspec-podman-resources/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.

Raises:

  • (Inspec::Exceptions::ResourceFailed)


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

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.



37
38
39
# File 'lib/inspec-podman-resources/resources/podman_pod.rb', line 37

def pod_id
  @pod_id
end

#pod_infoObject (readonly)

Returns the value of attribute pod_info.



37
38
39
# File 'lib/inspec-podman-resources/resources/podman_pod.rb', line 37

def pod_info
  @pod_info
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/inspec-podman-resources/resources/podman_pod.rb', line 72

def exist?
  !pod_info.empty?
end

#resource_idObject



76
77
78
# File 'lib/inspec-podman-resources/resources/podman_pod.rb', line 76

def resource_id
  pod_id
end

#to_sObject



80
81
82
# File 'lib/inspec-podman-resources/resources/podman_pod.rb', line 80

def to_s
  "Podman Pod #{resource_id}"
end