Provide inspec.lock for archives as well

Signed-off-by: Alex Pop <apop@chef.io>
This commit is contained in:
Alex Pop 2016-11-24 17:56:31 +00:00 committed by Christoph Hartmann
parent 45ef79b098
commit 4c60a69eae
3 changed files with 11 additions and 5 deletions

1
.gitignore vendored
View file

@ -14,6 +14,7 @@ omnibus/.cache
omnibus/pkg
test/**/*.lock
examples/**/*.lock
examples/meta-profile/vendor/
habitat/VERSION
habitat/results
/.ruby-gemset

View file

@ -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

View file

@ -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