Class: Podman

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec-podman-resources/resources/podman.rb

Instance Method Summary collapse

Instance Method Details

#containersObject



45
46
47
# File 'lib/inspec-podman-resources/resources/podman.rb', line 45

def containers
  PodmanContainerFilter.new(parse_containers)
end

#imagesObject



49
50
51
# File 'lib/inspec-podman-resources/resources/podman.rb', line 49

def images
  PodmanImageFilter.new(parse_images)
end

#infoObject



75
76
77
78
79
80
81
82
83
# File 'lib/inspec-podman-resources/resources/podman.rb', line 75

def info
  return @info if defined?(@info)

  sub_cmd = "info --format json"
  output = run_command(sub_cmd)
  @info = Hashie::Mash.new(JSON.parse(output))
rescue JSON::ParserError => _e
  Hashie::Mash.new({})
end

#networksObject



53
54
55
# File 'lib/inspec-podman-resources/resources/podman.rb', line 53

def networks
  PodmanNetworkFilter.new(parse_networks)
end

#object(id) ⇒ Object

returns information about podman objects



86
87
88
89
90
91
92
93
94
95
# File 'lib/inspec-podman-resources/resources/podman.rb', line 86

def object(id)
  return @inspect if defined?(@inspect)

  output = run_command("inspect #{id} --format json")
  data = JSON.parse(output)
  data = data[0] if data.is_a?(Array)
  @inspect = Hashie::Mash.new(data)
rescue JSON::ParserError => _e
  Hashie::Mash.new({})
end

#podsObject



57
58
59
# File 'lib/inspec-podman-resources/resources/podman.rb', line 57

def pods
  PodmanPodFilter.new(parse_pods)
end

#to_sObject



97
98
99
# File 'lib/inspec-podman-resources/resources/podman.rb', line 97

def to_s
  "Podman"
end

#versionObject



65
66
67
68
69
70
71
72
73
# File 'lib/inspec-podman-resources/resources/podman.rb', line 65

def version
  return @version if defined?(@version)

  sub_cmd = "version --format json"
  output = run_command(sub_cmd)
  @version = Hashie::Mash.new(JSON.parse(output))
rescue JSON::ParserError => _e
  Hashie::Mash.new({})
end

#volumesObject



61
62
63
# File 'lib/inspec-podman-resources/resources/podman.rb', line 61

def volumes
  PodmanVolumeFilter.new(parse_volumes)
end