Class: PodmanImage
- Inherits:
-
Object
- Object
- PodmanImage
- Includes:
- PodmanObject, Utils::Podman
- Defined in:
- lib/inspec-podman-resources/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 PodmanObject
Constructor Details
#initialize(opts) ⇒ PodmanImage
Returns a new instance of PodmanImage.
36 37 38 39 40 41 42 43 |
# File 'lib/inspec-podman-resources/resources/podman_image.rb', line 36 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.
34 35 36 |
# File 'lib/inspec-podman-resources/resources/podman_image.rb', line 34 def image_info @image_info end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
34 35 36 |
# File 'lib/inspec-podman-resources/resources/podman_image.rb', line 34 def opts @opts end |
Instance Method Details
#exist? ⇒ Boolean
66 67 68 |
# File 'lib/inspec-podman-resources/resources/podman_image.rb', line 66 def exist? ! image_info.empty? end |
#k ⇒ Object
This creates all the required properties methods dynamically.
60 61 62 63 64 |
# File 'lib/inspec-podman-resources/resources/podman_image.rb', line 60 LABELS.each do |k, v| define_method(k) do image_info[k.to_s] end end |
#resource_id ⇒ Object
70 71 72 |
# File 'lib/inspec-podman-resources/resources/podman_image.rb', line 70 def resource_id opts[:id] || opts[:image] || "" end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/inspec-podman-resources/resources/podman_image.rb', line 74 def to_s "podman_image #{resource_id}" end |