Method: Compliance::API.upload

Defined in:
lib/bundles/inspec-compliance/api.rb

.upload(config, owner, profile_name, archive_path) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/bundles/inspec-compliance/api.rb', line 109

def self.upload(config, owner, profile_name, archive_path)
  # Chef Compliance
  if is_compliance_server?(config)
    url = "#{config['server']}/owners/#{owner}/compliance/#{profile_name}/tar"
  # Chef Automate pre 0.8.0
  elsif is_automate_server_pre_080?(config)
    url = "#{config['server']}/#{owner}"
  # Chef Automate
  else
    url = "#{config['server']}/profiles/#{owner}"
  end

  headers = get_headers(config)
  res = Compliance::HTTP.post_file(url, headers, archive_path, config['insecure'])
  [res.is_a?(Net::HTTPSuccess), res.body]
end