Class: Inspec::Resources::AlpinePkg

Inherits:
PkgManagement show all
Defined in:
lib/resources/package.rb

Instance Attribute Summary

Attributes inherited from PkgManagement

#inspec

Instance Method Summary collapse

Methods inherited from PkgManagement

#initialize, #missing_requirements

Constructor Details

This class inherits a constructor from Inspec::Resources::PkgManagement

Instance Method Details

#info(package_name) ⇒ Object



257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/resources/package.rb', line 257

def info(package_name)
  cmd = inspec.command("apk info -vv --no-network | grep #{package_name}")
  return {} if cmd.exit_status.to_i != 0

  pkg_info = cmd.stdout.split("\n").delete_if { |e| e =~ /^WARNING/i }
  pkg = pkg_info[0].split(' - ')[0]

  {
    name: pkg.partition('-')[0],
    installed: true,
    version: pkg.partition('-')[2],
    type: 'pkg',
  }
end