Class: Chef::Compliance::Fetcher::Automate
- Inherits:
-
InspecPlugins::Compliance::Fetcher
- Object
- InspecPlugins::Compliance::Fetcher
- Chef::Compliance::Fetcher::Automate
- Defined in:
- lib/chef/compliance/fetcher/automate.rb
Constant Summary collapse
- CONFIG =
{ "insecure" => true, "token" => nil, "server_type" => "automate", "automate" => { "ent" => "default", "token_type" => "dctoken", }, }.freeze
Class Method Summary collapse
- .resolve(target) ⇒ Object
-
.sanitize_profile_name(profile) ⇒ Object
returns a parsed url for ‘admin/profile` or `compliance://admin/profile` TODO: remove in future, copied from inspec to support older versions of inspec.
Instance Method Summary collapse
Class Method Details
.resolve(target) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/chef/compliance/fetcher/automate.rb', line 24 def self.resolve(target) uri = get_target_uri(target) return nil if uri.nil? config = CONFIG.dup # we have detailed information available in our lockfile, no need to ask the server if target.respond_to?(:key?) && target.key?(:url) profile_fetch_url = target[:url] else # verifies that the target e.g base/ssh exists profile = sanitize_profile_name(uri) owner, id = profile.split("/") profile_path = if target.respond_to?(:key?) && target.key?(:version) "/compliance/profiles/#{owner}/#{id}/version/#{target[:version]}/tar" else "/compliance/profiles/#{owner}/#{id}/tar" end url = URI(Chef::Config[:data_collector][:server_url]) url.path = profile_path profile_fetch_url = url.to_s config["token"] = Chef::Config[:data_collector][:token] end new(profile_fetch_url, config) rescue URI::Error => _e nil end |
.sanitize_profile_name(profile) ⇒ Object
returns a parsed url for ‘admin/profile` or `compliance://admin/profile` TODO: remove in future, copied from inspec to support older versions of inspec
58 59 60 61 62 63 64 65 |
# File 'lib/chef/compliance/fetcher/automate.rb', line 58 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 |
Instance Method Details
#to_s ⇒ Object
67 68 69 |
# File 'lib/chef/compliance/fetcher/automate.rb', line 67 def to_s "#{ChefUtils::Dist::Automate::PRODUCT} for #{ChefUtils::Dist::Solo::PRODUCT} Fetcher" end |