Class: Inspec::ProfileVendor
- Inherits:
-
Object
- Object
- Inspec::ProfileVendor
- Defined in:
- lib/inspec/profile_vendor.rb
Instance Attribute Summary collapse
-
#profile_path ⇒ Object
readonly
Returns the value of attribute profile_path.
Instance Method Summary collapse
- #cache_path ⇒ Object
-
#initialize(path) ⇒ ProfileVendor
constructor
A new instance of ProfileVendor.
- #lockfile ⇒ Object
-
#make_readable ⇒ Object
The URL fetcher uses a Tempfile to retrieve the vendored profile, which creates a file that is only readable by the current user.
- #vendor!(opts) ⇒ Object
Constructor Details
#initialize(path) ⇒ ProfileVendor
Returns a new instance of ProfileVendor.
8 9 10 |
# File 'lib/inspec/profile_vendor.rb', line 8 def initialize(path) @profile_path = Pathname.new(File.(path)) end |
Instance Attribute Details
#profile_path ⇒ Object (readonly)
Returns the value of attribute profile_path.
6 7 8 |
# File 'lib/inspec/profile_vendor.rb', line 6 def profile_path @profile_path end |
Instance Method Details
#cache_path ⇒ Object
33 34 35 |
# File 'lib/inspec/profile_vendor.rb', line 33 def cache_path profile_path.join("vendor") end |
#lockfile ⇒ Object
37 38 39 |
# File 'lib/inspec/profile_vendor.rb', line 37 def lockfile profile_path.join("inspec.lock") end |
#make_readable ⇒ Object
The URL fetcher uses a Tempfile to retrieve the vendored profile, which creates a file that is only readable by the current user. In most circumstances, this is likely OK. However, in environments like a Habitat package, these files need to be readable by all users or the Habitat Supervisor may not be able to start InSpec correctly.
This method makes sure all vendored files are mode 644 for this use case. This method is not called by default - the caller vendoring the profile must make the decision as to whether this is necessary.
27 28 29 30 31 |
# File 'lib/inspec/profile_vendor.rb', line 27 def make_readable Dir.glob("#{cache_path}/**/*") do |e| FileUtils.chmod(0644, e) if File.file?(e) end end |
#vendor!(opts) ⇒ Object
12 13 14 |
# File 'lib/inspec/profile_vendor.rb', line 12 def vendor!(opts) vendor_dependencies!(opts) end |