Method: InspecPlugins::Compliance::CLI#download

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

#download(profile_name) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb', line 94

def download(profile_name)
  o = options.dup
  configure_logger(o)

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

  profile_name = InspecPlugins::Compliance::API.sanitize_profile_name(profile_name)
  if InspecPlugins::Compliance::API.exist?(config, profile_name)
    puts "Downloading `#{profile_name}`"

    fetcher = InspecPlugins::Compliance::Fetcher.resolve(
      {
        compliance: profile_name,
      },
    )

    # we provide a name, the fetcher adds the extension
    _owner, id = profile_name.split('/')
    file_name = fetcher.fetch(o.name || id)
    puts "Profile stored to #{file_name}"
  else
    puts "Profile #{profile_name} is not available in Chef Compliance."
    exit 1
  end
end