Method: InspecPlugins::Compliance::CLI#profiles

Defined in:
lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb

#profilesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb', line 44

def profiles
  config = InspecPlugins::Compliance::Configuration.new
  return if !loggedin(config)

  # set owner to config
  config['owner'] = options['owner'] || config['user']

  msg, profiles = InspecPlugins::Compliance::API.profiles(config)
  profiles.sort_by! { |hsh| hsh['title'] }
  if !profiles.empty?
    # iterate over profiles
    headline('Available profiles:')
    profiles.each { |profile|
      owner = profile['owner_id'] || profile['owner']
      li("#{profile['title']} v#{profile['version']} (#{mark_text(owner + '/' + profile['name'])})")
    }
  else
    puts msg if msg != 'success'
    puts 'Could not find any profiles'
    exit 1
  end
rescue InspecPlugins::Compliance::ServerConfigurationMissing
  STDERR.puts "\nServer configuration information is missing. Please login using `inspec compliance login`"
  exit 1
end