Bump lockfile version to 1.0

Signed-off-by: Steven Danna <steve@chef.io>
This commit is contained in:
Steven Danna 2016-09-23 17:12:47 +01:00
parent 3072c4c91d
commit f23a0d1098
No known key found for this signature in database
GPG key ID: 94DFB46E861A7DAE
2 changed files with 9 additions and 17 deletions

View file

@ -4,8 +4,8 @@ require 'yaml'
module Inspec
class Lockfile
# When we finalize this feature, we should set these to 1
MINIMUM_SUPPORTED_VERSION = 0
CURRENT_LOCKFILE_VERSION = 0
MINIMUM_SUPPORTED_VERSION = 1
CURRENT_LOCKFILE_VERSION = 1
def self.from_dependency_set(dep_set)
lockfile_content = {
@ -32,14 +32,6 @@ lower than the minimum supported version #{MINIMUM_SUPPORTED_VERSION}.
Please create a new lockfile for this project by running:
inspec vendor
EOF
elsif version == 0
# Remove this case once this feature stablizes
$stderr.puts <<EOF
WARNING: This is a version 0 lockfile. Thank you for trying the
experimental dependency management feature. Please be aware you may
need to regenerate this lockfile in future versions as the feature is
currently in development.
EOF
elsif version > CURRENT_LOCKFILE_VERSION
fail <<EOF
@ -78,8 +70,8 @@ EOF
# different entry points of the API.
def parse_content_hash(lockfile_content_hash)
case version
when 0
parse_content_hash_0(lockfile_content_hash)
when 1
parse_content_hash_1(lockfile_content_hash)
else
# If we've gotten here, there is likely a mistake in the
# lockfile version validation in the constructor.
@ -87,7 +79,7 @@ EOF
end
end
def parse_content_hash_0(lockfile_content_hash)
def parse_content_hash_1(lockfile_content_hash)
@deps = if lockfile_content_hash['depends']
lockfile_content_hash['depends'].map { |i| symbolize_keys(i) }
end

View file

@ -6,7 +6,7 @@ describe Inspec::Lockfile do
let(:lockfile_content) {
<<EOF
---
lockfile_version: 0
lockfile_version: 1
depends:
- name: foo
resolved_source:
@ -23,7 +23,7 @@ EOF
let(:lockfile_content) {
<<EOF
---
lockfile_version: 0
lockfile_version: 1
depends:
- name: foo
resolved_source:
@ -39,7 +39,7 @@ EOF
end
let(:lockfile_hash) {
{ 'lockfile_version' => 0,
{ 'lockfile_version' => 1,
'depends' => [
{ 'name' => "foo", 'resolved_source' => {'url' => "http://foo"}, 'version_constraints' => ">= 0",
'dependencies' => [{ 'name' => 'bar', 'resolved_source' => {'url' => 'http://bar' }, 'version_constraints' => ">= 0"}]
@ -47,7 +47,7 @@ EOF
}
let(:lockfile_hash_with_symbols) {
{ 'lockfile_version' => 0,
{ 'lockfile_version' => 1,
'depends' => [
{ name: "foo", resolved_source: {url: "http://foo"}, version_constraints: ">= 0",
dependencies: [{ name: 'bar', resolved_source: {url: 'http://bar' }, version_constraints: ">= 0"}]