Class: Compliance::Fetcher
- Inherits:
-
Fetchers::Url
- Object
- Fetchers::Url
- Compliance::Fetcher
- Defined in:
- lib/bundles/inspec-compliance/target.rb
Constant Summary
Constants inherited from Fetchers::Url
Fetchers::Url::GITHUB_URL_REGEX, Fetchers::Url::GITHUB_URL_WITH_TREE_REGEX, Fetchers::Url::MIME_TYPES
Instance Attribute Summary
Attributes inherited from Fetchers::Url
Class Method Summary collapse
Instance Method Summary collapse
-
#resolved_source ⇒ Object
We want to save compliance: in the lockfile rather than url: to make sure we go back through the ComplianceAPI handling.
- #to_s ⇒ Object
Methods inherited from Fetchers::Url
#fetch, #initialize, resolve_from_string, transform
Constructor Details
This class inherits a constructor from Fetchers::Url
Class Method Details
.resolve(target) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bundles/inspec-compliance/target.rb', line 16 def self.resolve(target) uri = if target.is_a?(String) && URI(target).scheme == 'compliance' URI(target) elsif target.respond_to?(:key?) && target.key?(:compliance) URI("compliance://#{target[:compliance]}") end return nil if uri.nil? # check if we have a compliance token config = Compliance::Configuration.new return nil if config['token'].nil? # verifies that the target e.g base/ssh exists profile = uri.host + uri.path Compliance::API.exist?(config, profile) new(target_url(profile, config), config) rescue URI::Error => _e nil end |
.target_url(profile, config) ⇒ Object
37 38 39 40 |
# File 'lib/bundles/inspec-compliance/target.rb', line 37 def self.target_url(profile, config) owner, id = profile.split('/') "#{config['server']}/owners/#{owner}/compliance/#{id}/tar" end |
Instance Method Details
#resolved_source ⇒ Object
We want to save compliance: in the lockfile rather than url: to make sure we go back through the ComplianceAPI handling.
46 47 48 |
# File 'lib/bundles/inspec-compliance/target.rb', line 46 def resolved_source { compliance: supermarket_profile_name } end |
#to_s ⇒ Object
50 51 52 |
# File 'lib/bundles/inspec-compliance/target.rb', line 50 def to_s 'Chef Compliance Profile Loader' end |