Method: Inspec::InspecCLI#archive

Defined in:
lib/inspec/cli.rb

#archive(path) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/inspec/cli.rb', line 150

def archive(path)
  o = opts.dup
  diagnose(o)

  o[:logger] = Logger.new(STDOUT)
  o[:logger].level = get_log_level(o.log_level)
  o[:backend] = Inspec::Backend.create(target: 'mock://')

  # Force vendoring with overwrite when archiving
  vendor_options = o.dup
  vendor_options[:overwrite] = true
  vendor_deps(path, vendor_options)

  profile = Inspec::Profile.for_target(path, o)
  result = profile.check

  if result && !o[:ignore_errors] == false
    o[:logger].info 'Profile check failed. Please fix the profile before generating an archive.'
    return exit 1
  end

  # generate archive
  exit 1 unless profile.archive(o)
rescue StandardError => e
  pretty_handle_exception(e)
end