Class: Inspec::Resources::PodmanImage
- Inherits:
-
Object
- Object
- Inspec::Resources::PodmanImage
- Includes:
- DockerObject, Utils::Podman
- Defined in:
- lib/inspec/resources/podman_image.rb
Constant Summary collapse
- LABELS =
{ "id" => "ID", "repo_tags" => "RepoTags", "size" => "Size", "digest" => "Digest", "created_at" => "Created", "version" => "Version", "names_history" => "NamesHistory", "repo_digests" => "RepoDigests", "architecture" => "Architecture", "os" => "Os", "virtual_size" => "VirtualSize", }.freeze
Instance Attribute Summary collapse
-
#image_info ⇒ Object
readonly
Returns the value of attribute image_info.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
- #exist? ⇒ Boolean
-
#initialize(opts) ⇒ PodmanImage
constructor
A new instance of PodmanImage.
-
#k ⇒ Object
This creates all the required properties methods dynamically.
- #resource_id ⇒ Object
- #to_s ⇒ Object
Methods included from Utils::Podman
#generate_go_template, #parse_command_output, #podman_running?
Methods included from DockerObject
Constructor Details
#initialize(opts) ⇒ PodmanImage
Returns a new instance of PodmanImage.
38 39 40 41 42 43 44 45 |
# File 'lib/inspec/resources/podman_image.rb', line 38 def initialize(opts) skip_resource "The `podman_image` resource is not yet available on your OS." unless inspec.os.unix? opts = { image: opts } if opts.is_a?(String) @opts = (opts) raise Inspec::Exceptions::ResourceFailed, "Podman is not running. Please make sure it is installed and running." unless podman_running? @image_info = get_image_info end |
Instance Attribute Details
#image_info ⇒ Object (readonly)
Returns the value of attribute image_info.
36 37 38 |
# File 'lib/inspec/resources/podman_image.rb', line 36 def image_info @image_info end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
36 37 38 |
# File 'lib/inspec/resources/podman_image.rb', line 36 def opts @opts end |
Instance Method Details
#exist? ⇒ Boolean
68 69 70 |
# File 'lib/inspec/resources/podman_image.rb', line 68 def exist? ! image_info.empty? end |
#k ⇒ Object
This creates all the required properties methods dynamically.
62 63 64 65 66 |
# File 'lib/inspec/resources/podman_image.rb', line 62 LABELS.each do |k, v| define_method(k) do image_info[k.to_s] end end |
#resource_id ⇒ Object
72 73 74 |
# File 'lib/inspec/resources/podman_image.rb', line 72 def resource_id opts[:id] || opts[:image] || "" end |
#to_s ⇒ Object
76 77 78 |
# File 'lib/inspec/resources/podman_image.rb', line 76 def to_s "podman_image #{resource_id}" end |