mirror of
https://github.com/inspec/inspec
synced 2024-11-26 14:40:26 +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
|
omnibus/pkg
|
||||||
test/**/*.lock
|
test/**/*.lock
|
||||||
examples/**/*.lock
|
examples/**/*.lock
|
||||||
|
examples/meta-profile/vendor/
|
||||||
habitat/VERSION
|
habitat/VERSION
|
||||||
habitat/results
|
habitat/results
|
||||||
/.ruby-gemset
|
/.ruby-gemset
|
||||||
|
|
|
@ -15,14 +15,19 @@ module Inspec
|
||||||
new(lockfile_content)
|
new(lockfile_content)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_file(path)
|
def self.from_content(content)
|
||||||
parsed_content = YAML.load(File.read(path))
|
parsed_content = YAML.load(content)
|
||||||
version = parsed_content['lockfile_version']
|
version = parsed_content['lockfile_version']
|
||||||
fail "No lockfile_version set in #{path}!" if version.nil?
|
fail "No lockfile_version set in #{path}!" if version.nil?
|
||||||
validate_lockfile_version!(version.to_i)
|
validate_lockfile_version!(version.to_i)
|
||||||
new(parsed_content)
|
new(parsed_content)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.from_file(path)
|
||||||
|
content = File.read(path)
|
||||||
|
from_content(content)
|
||||||
|
end
|
||||||
|
|
||||||
def self.validate_lockfile_version!(version)
|
def self.validate_lockfile_version!(version)
|
||||||
if version < MINIMUM_SUPPORTED_VERSION
|
if version < MINIMUM_SUPPORTED_VERSION
|
||||||
fail <<EOF
|
fail <<EOF
|
||||||
|
|
|
@ -206,7 +206,7 @@ module Inspec
|
||||||
res
|
res
|
||||||
end
|
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.
|
# used to print information on errors and warnings which are found.
|
||||||
#
|
#
|
||||||
# @return [Boolean] true if no errors were found, false otherwise
|
# @return [Boolean] true if no errors were found, false otherwise
|
||||||
|
@ -343,7 +343,7 @@ module Inspec
|
||||||
end
|
end
|
||||||
|
|
||||||
def lockfile_exists?
|
def lockfile_exists?
|
||||||
File.exist?(lockfile_path)
|
@source_reader.target.files.include?('inspec.lock')
|
||||||
end
|
end
|
||||||
|
|
||||||
def lockfile_path
|
def lockfile_path
|
||||||
|
@ -361,7 +361,7 @@ module Inspec
|
||||||
|
|
||||||
def lockfile
|
def lockfile
|
||||||
@lockfile ||= if lockfile_exists?
|
@lockfile ||= if lockfile_exists?
|
||||||
Inspec::Lockfile.from_file(lockfile_path)
|
Inspec::Lockfile.from_content(@source_reader.target.read('inspec.lock'))
|
||||||
else
|
else
|
||||||
generate_lockfile
|
generate_lockfile
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue