Class: Inspec::Resources::PodmanVolume

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

Constant Summary collapse

LABELS =
{
  "name" => "Name",
  "driver" => "Driver",
  "mountpoint" => "Mountpoint",
  "created_at" => "CreatedAt",
  "labels" => "Labels",
  "scope" => "Scope",
  "options" => "Options",
  "mount_count" => "MountCount",
  "needs_copy_up" => "NeedsCopyUp",
  "needs_chown" => "NeedsChown",
}.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(volume_name) ⇒ PodmanVolume

Returns a new instance of PodmanVolume.



31
32
33
34
35
36
37
# File 'lib/inspec/resources/podman_volume.rb', line 31

def initialize(volume_name)
  skip_resource "The `podman_volume` 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?

  @volume_name = volume_name
  @volume_info = get_volume_info
end

Instance Attribute Details

#volume_infoObject (readonly)

Returns the value of attribute volume_info.



29
30
31
# File 'lib/inspec/resources/podman_volume.rb', line 29

def volume_info
  @volume_info
end

#volume_nameObject (readonly)

Returns the value of attribute volume_name.



29
30
31
# File 'lib/inspec/resources/podman_volume.rb', line 29

def volume_name
  @volume_name
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/inspec/resources/podman_volume.rb', line 59

def exist?
  !volume_info.empty?
end

#resource_idObject



63
64
65
# File 'lib/inspec/resources/podman_volume.rb', line 63

def resource_id
  volume_name
end

#to_sObject



67
68
69
# File 'lib/inspec/resources/podman_volume.rb', line 67

def to_s
  "podman_volume #{resource_id}"
end