Module: Utils::Podman
- Included in:
- PodmanImage, PodmanNetwork, PodmanPod, PodmanVolume
- Defined in:
- lib/inspec-podman-resources/resources/utils/podman.rb
Instance Method Summary collapse
-
#generate_go_template(labels) ⇒ Object
Generates the template in this format using labels hash: “"id": .ID}, "name": .Name}”,.
- #parse_command_output(output) ⇒ Object
- #podman_running? ⇒ Boolean
Instance Method Details
#generate_go_template(labels) ⇒ Object
Generates the template in this format using labels hash: “"id": .ID}, "name": .Name}”,
12 13 14 |
# File 'lib/inspec-podman-resources/resources/utils/podman.rb', line 12 def generate_go_template(labels) (labels.map { |k, v| "\"#{k}\": {{json .#{v}}}" }).join(", ") end |
#parse_command_output(output) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/inspec-podman-resources/resources/utils/podman.rb', line 16 def parse_command_output(output) require "json" unless defined?(JSON) JSON.parse(output) rescue JSON::ParserError => _e warn "Could not parse the command output" {} end |
#podman_running? ⇒ Boolean
7 8 9 |
# File 'lib/inspec-podman-resources/resources/utils/podman.rb', line 7 def podman_running? inspec.command("podman version").exit_status == 0 end |