Module: Inspec::Utils::Podman

Included in:
Resources::PodmanImage, Resources::PodmanNetwork, Resources::PodmanPod, Resources::PodmanVolume
Defined in:
lib/inspec/utils/podman.rb

Instance Method Summary collapse

Instance Method Details

#generate_go_template(labels) ⇒ Object

Generates the template in this format using labels hash: “"id": .ID}, "name": .Name}”,



11
12
13
# File 'lib/inspec/utils/podman.rb', line 11

def generate_go_template(labels)
  (labels.map { |k, v| "\"#{k}\": {{json .#{v}}}" }).join(", ")
end

#parse_command_output(output) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/inspec/utils/podman.rb', line 15

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

Returns:

  • (Boolean)


6
7
8
# File 'lib/inspec/utils/podman.rb', line 6

def podman_running?
  inspec.command("podman version").exit_status == 0
end