mirror of
https://github.com/inspec/inspec
synced 2024-11-22 20:53:11 +00:00
Provide inspec.lock for archives as well
Signed-off-by: Alex Pop <apop@chef.io>
This commit is contained in:
parent
45ef79b098
commit
4c60a69eae
3 changed files with 11 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -14,6 +14,7 @@ omnibus/.cache
|
|||
omnibus/pkg
|
||||
test/**/*.lock
|
||||
examples/**/*.lock
|
||||
examples/meta-profile/vendor/
|
||||
habitat/VERSION
|
||||
habitat/results
|
||||
/.ruby-gemset
|
||||
|
|
|
@ -15,14 +15,19 @@ module Inspec
|
|||
new(lockfile_content)
|
||||
end
|
||||
|
||||
def self.from_file(path)
|
||||
parsed_content = YAML.load(File.read(path))
|
||||
def self.from_content(content)
|
||||
parsed_content = YAML.load(content)
|
||||
version = parsed_content['lockfile_version']
|
||||
fail "No lockfile_version set in #{path}!" if version.nil?
|
||||
validate_lockfile_version!(version.to_i)
|
||||
new(parsed_content)
|
||||
end
|
||||
|
||||
def self.from_file(path)
|
||||
content = File.read(path)
|
||||
from_content(content)
|
||||
end
|
||||
|
||||
def self.validate_lockfile_version!(version)
|
||||
if version < MINIMUM_SUPPORTED_VERSION
|
||||
fail <<EOF
|
||||
|
|
|
@ -206,7 +206,7 @@ module Inspec
|
|||
res
|
||||
end
|
||||
|
||||
# Check if the profile is internall well-structured. The logger will be
|
||||
# Check if the profile is internally well-structured. The logger will be
|
||||
# used to print information on errors and warnings which are found.
|
||||
#
|
||||
# @return [Boolean] true if no errors were found, false otherwise
|
||||
|
@ -343,7 +343,7 @@ module Inspec
|
|||
end
|
||||
|
||||
def lockfile_exists?
|
||||
File.exist?(lockfile_path)
|
||||
@source_reader.target.files.include?('inspec.lock')
|
||||
end
|
||||
|
||||
def lockfile_path
|
||||
|
@ -361,7 +361,7 @@ module Inspec
|
|||
|
||||
def lockfile
|
||||
@lockfile ||= if lockfile_exists?
|
||||
Inspec::Lockfile.from_file(lockfile_path)
|
||||
Inspec::Lockfile.from_content(@source_reader.target.read('inspec.lock'))
|
||||
else
|
||||
generate_lockfile
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue