diff options
Diffstat (limited to 'lib/chef/compliance/fetcher/automate.rb')
-rw-r--r-- | lib/chef/compliance/fetcher/automate.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/chef/compliance/fetcher/automate.rb b/lib/chef/compliance/fetcher/automate.rb index b254684280..64aff6833a 100644 --- a/lib/chef/compliance/fetcher/automate.rb +++ b/lib/chef/compliance/fetcher/automate.rb @@ -32,12 +32,12 @@ class Chef profile_fetch_url = target[:url] else # verifies that the target e.g base/ssh exists - base_path = "/compliance/profiles/#{uri.host}#{uri.path}" - + profile = sanitize_profile_name(uri) + owner, id = profile.split("/") profile_path = if target.respond_to?(:key?) && target.key?(:version) - "#{base_path}/version/#{target[:version]}/tar" + "/compliance/profiles/#{owner}/#{id}/version/#{target[:version]}/tar" else - "#{base_path}/tar" + "/compliance/profiles/#{owner}/#{id}/tar" end url = URI(Chef::Config[:data_collector][:server_url]) @@ -60,6 +60,17 @@ class Chef nil end + # returns a parsed url for `admin/profile` or `compliance://admin/profile` + # TODO: remove in future, copied from inspec to support older versions of inspec + def self.sanitize_profile_name(profile) + uri = if URI(profile).scheme == "compliance" + URI(profile) + else + URI("compliance://#{profile}") + end + uri.to_s.sub(%r{^compliance:\/\/}, "") + end + def to_s "#{ChefUtils::Dist::Automate::PRODUCT} for #{ChefUtils::Dist::Solo::PRODUCT} Fetcher" end |