vara 0.21.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84c028dcdfe4d9f29f8802dcb4d5e0da970b69e2
4
- data.tar.gz: 7a4cfbee05ecdf94e6f4608f342943e9e1226edd
3
+ metadata.gz: 53b15fc0f2bf249075d85c00adbcc4bd31a595ed
4
+ data.tar.gz: 884e2d22736c9c2cb6ad17eccf9e29aff93fcf9c
5
5
  SHA512:
6
- metadata.gz: dbd59239f1b4f1a3c26a505d45e1c0781cdfaecef6b30354bf945594cf82a8b0974d4d3932247e4fc236aa25da38827831ef706980510ed5681db547d24e8abc
7
- data.tar.gz: 5d1ac158c0197ef9c6c43bbc14cb3b9a67dd6038ff9ab332776af0561589ed8a18fe8c1c192ea58e53919a3918bf492fad1683b28bb0a413bb504dbe2053b631
6
+ metadata.gz: a22c87efc0c7940a3e01d40ae6092c7fd6765ee6d7e9e9241708bee3beaa5b8845393926b6ba8b99c55f19b01d169cc89af65ebb23e1e7f09fbc074fd734044d
7
+ data.tar.gz: d791843f683c38eefd8078797daddf201650d1832c6d3cca7412f20f4215d9d37eca63bafbe7c8c8324fd37a816262195b8342502dc12b281784d0564046a03c
@@ -7,7 +7,7 @@ module Vara
7
7
  # @param source [String] The URL from which to download
8
8
  # @param target [String] The path on disk for where to save the downloaded file
9
9
  def self.download(metadata, target)
10
- fail 'URL or AWS Config required to download!' unless metadata.url || metadata.aws
10
+ raise 'URL or AWS Config required to download!' unless metadata.url || metadata.aws
11
11
  if metadata.aws
12
12
  download_from_aws(metadata.aws, target)
13
13
  elsif metadata.url
@@ -14,7 +14,7 @@ module Vara
14
14
 
15
15
  # @param repo_path [String] Path to the root of the repository to inspect
16
16
  def initialize(repo_path)
17
- fail "The directory #{repo_path} must be a git repo" unless self.class.git_repo?(repo_path)
17
+ raise "The directory #{repo_path} must be a git repo" unless self.class.git_repo?(repo_path)
18
18
  @repo_path = repo_path
19
19
  end
20
20
 
data/lib/vara/linter.rb CHANGED
@@ -13,7 +13,7 @@ module Vara
13
13
 
14
14
  def lint!
15
15
  validate_metadata_version
16
- fail LintError, errors.join("\n") unless errors.empty?
16
+ raise LintError, errors.join("\n") unless errors.empty?
17
17
  end
18
18
 
19
19
  private
data/lib/vara/log.rb CHANGED
@@ -30,7 +30,7 @@ module Vara
30
30
  class Log
31
31
  class << self
32
32
  def instance
33
- @instance || fail('Logging attempted without being configured first!')
33
+ @instance || raise('Logging attempted without being configured first!')
34
34
  end
35
35
 
36
36
  def test_mode!
@@ -59,7 +59,7 @@ module Vara
59
59
  # @raise [RuntimeError] if the URL is not set.
60
60
  # @return [String]
61
61
  def url
62
- @url || fail("URL unknown for compiled_packages #{name}")
62
+ @url || raise("URL unknown for compiled_packages #{name}")
63
63
  end
64
64
 
65
65
  # @return [nil] the interface for downloader requires this method
data/lib/vara/product.rb CHANGED
@@ -18,12 +18,12 @@ module Vara
18
18
  end
19
19
 
20
20
  def metadata_file
21
- @metadata_file ||= find_metadata_file || fail('No metadata file found.')
21
+ @metadata_file ||= find_metadata_file || raise('No metadata file found.')
22
22
  end
23
23
 
24
24
  def build
25
25
  if metadata.explicit_stemcell? && metadata.stemcell_criteria?
26
- fail 'binaries.yml includes both stemcell and stemcell criteria keys'
26
+ raise 'binaries.yml includes both stemcell and stemcell criteria keys'
27
27
  end
28
28
 
29
29
  ProductArtifactZipper.new(path, ProductContents.from_metadata_path(metadata_file), @options).zip!
@@ -83,7 +83,7 @@ module Vara
83
83
  when 1 then
84
84
  files.first
85
85
  else
86
- fail("Found: #{files.map { |f| File.basename(f) }}. Vara supports one .yml file under metadata/")
86
+ raise("Found: #{files.map { |f| File.basename(f) }}. Vara supports one .yml file under metadata/")
87
87
  end
88
88
  end
89
89
  end
@@ -3,7 +3,7 @@ require 'digest/md5'
3
3
  module Vara
4
4
  class ProductArtifactValidator
5
5
  def self.validate_file_checksum(file_metadata, file_name)
6
- fail "No checksum for file #{file_name}!" unless file_metadata.md5 || file_metadata.sha1
6
+ raise "No checksum for file #{file_name}!" unless file_metadata.md5 || file_metadata.sha1
7
7
 
8
8
  validate_md5(file_metadata, file_name) if file_metadata.md5
9
9
 
@@ -13,13 +13,13 @@ module Vara
13
13
  def self.validate_sha1(file_metadata, file_name)
14
14
  sha1_got = Digest::SHA1.file(file_name).hexdigest
15
15
  sha1_expected = file_metadata.sha1
16
- fail "sha1 mismatch for file #{file_name}, expected #{sha1_expected}, got #{sha1_got}" if sha1_got != sha1_expected
16
+ raise "sha1 mismatch for file #{file_name}, expected #{sha1_expected}, got #{sha1_got}" if sha1_got != sha1_expected
17
17
  end
18
18
 
19
19
  def self.validate_md5(file_metadata, file_name)
20
20
  md5_got = Digest::MD5.file(file_name).hexdigest
21
21
  md5_expected = file_metadata.md5
22
- fail "md5 mismatch for file #{file_name}, expected #{md5_expected}, got #{md5_got}" if md5_got != md5_expected
22
+ raise "md5 mismatch for file #{file_name}, expected #{md5_expected}, got #{md5_got}" if md5_got != md5_expected
23
23
  end
24
24
  end
25
25
  end
@@ -20,7 +20,7 @@ module Vara
20
20
  # @return [String] The path to the content migration file on disk
21
21
  def content_migrations_path
22
22
  paths = Dir.glob(File.expand_path(File.join(root_path, 'content_migrations', '*.yml')))
23
- fail "Exactly one content_migrations file is required in #{root_path}/content_migrations" if paths.size != 1
23
+ raise "Exactly one content_migrations file is required in #{root_path}/content_migrations" if paths.size != 1
24
24
  paths.first
25
25
  end
26
26
 
@@ -59,7 +59,7 @@ module Vara
59
59
  r['name'] == external_release['name']
60
60
  end
61
61
 
62
- fail "Specified release #{external_release['name']} does not exist in binaries.yml" unless replace
62
+ raise "Specified release #{external_release['name']} does not exist in binaries.yml" unless replace
63
63
 
64
64
  metadata['releases'][replace] = external_release
65
65
  end
@@ -70,24 +70,24 @@ module Vara
70
70
  missing_keys = REQUIRED_RELEASE_KEYS - external_release.keys.to_a
71
71
  specified_release = "Specified release #{File.basename(external_release_path)} "
72
72
 
73
- fail specified_release + "is missing required keywords: #{missing_keys}" unless missing_keys.empty?
73
+ raise specified_release + "is missing required keywords: #{missing_keys}" unless missing_keys.empty?
74
74
 
75
75
  exclusive_key_count = (EXCLUSIVE_KEYS - external_release.keys.to_a).length
76
76
  case
77
77
  when exclusive_key_count < 1
78
- fail specified_release + "contains more than one of the following keys, but only one is allowed: #{EXCLUSIVE_KEYS}"
78
+ raise specified_release + "contains more than one of the following keys, but only one is allowed: #{EXCLUSIVE_KEYS}"
79
79
  when exclusive_key_count > 1
80
- fail specified_release + "requires one of the following keys: #{EXCLUSIVE_KEYS}"
80
+ raise specified_release + "requires one of the following keys: #{EXCLUSIVE_KEYS}"
81
81
  end
82
82
 
83
83
  if external_release.key?('aws')
84
84
  missing_aws_keys = missing_aws_keys(external_release)
85
85
 
86
- fail specified_release + "is missing required aws hash keywords: #{missing_aws_keys}" unless missing_aws_keys.empty?
86
+ raise specified_release + "is missing required aws hash keywords: #{missing_aws_keys}" unless missing_aws_keys.empty?
87
87
  end
88
88
 
89
89
  extra_keys = external_release.keys.to_a - REQUIRED_RELEASE_KEYS - EXCLUSIVE_KEYS
90
- fail specified_release + "has extra keywords: #{extra_keys}" unless extra_keys.empty?
90
+ raise specified_release + "has extra keywords: #{extra_keys}" unless extra_keys.empty?
91
91
  external_release
92
92
  end
93
93
  # rubocop:enable CyclomaticComplexity
@@ -18,7 +18,7 @@ module Vara
18
18
 
19
19
  def download
20
20
  if product_metadata.explicit_stemcell? && product_metadata.stemcell_criteria?
21
- fail 'binaries.yml includes both stemcell and stemcell criteria keys'
21
+ raise 'binaries.yml includes both stemcell and stemcell criteria keys'
22
22
  end
23
23
 
24
24
  if product_metadata.explicit_stemcell?
@@ -1,4 +1,6 @@
1
1
  module Vara
2
+ class VersionError < RuntimeError; end
3
+
2
4
  class StaticVersioner
3
5
  PRODUCT_VERSION_KEY = 'product_version'.freeze
4
6
  TO_VERSION_KEY = 'to_version'.freeze
@@ -9,6 +11,12 @@ module Vara
9
11
  # @param product_directory_path [String]
10
12
  # @param version [String] the product version
11
13
  def initialize(product_directory_path, version)
14
+ begin
15
+ Gem::Version.create(version)
16
+ rescue
17
+ raise Vara::VersionError, "Invalid version: #{version}"
18
+ end
19
+
12
20
  @product_directory_path = product_directory_path
13
21
  @version = version
14
22
  end
data/lib/vara/tarball.rb CHANGED
@@ -50,7 +50,7 @@ module Vara
50
50
  stderr_string = stderr.read
51
51
  end
52
52
 
53
- fail "Invalid tarball: #{path_to_binary}. Tar command STDOUT: #{stdout_string}\n STDERR:#{stderr_string}" unless status.success?
53
+ raise "Invalid tarball: #{path_to_binary}. Tar command STDOUT: #{stdout_string}\n STDERR:#{stderr_string}" unless status.success?
54
54
 
55
55
  log.info("Verified that #{path_to_binary} as a valid tar file")
56
56
  end
@@ -58,7 +58,7 @@ module Vara
58
58
  def validate_checksum
59
59
  log.info("Beginning checksum validation of #{metadata}")
60
60
  log.info("Path to File: #{path_to_binary}")
61
- fail "Metadata doesn't include SHA1 or MD5 checksum!" unless metadata.md5 || metadata.sha1
61
+ raise "Metadata doesn't include SHA1 or MD5 checksum!" unless metadata.md5 || metadata.sha1
62
62
  validate_md5 if metadata.md5
63
63
  validate_sha1 if metadata.sha1
64
64
  log.info("#{metadata} checksum validation complete")
@@ -68,14 +68,14 @@ module Vara
68
68
  log.info("Expected SHA1: #{metadata.sha1}")
69
69
  actual_sha1 = Digest::SHA1.file(path_to_binary).hexdigest
70
70
  log.info("Actual SHA1: #{actual_sha1}")
71
- fail "SHA1 doesn't match expected value!" unless actual_sha1 == metadata.sha1
71
+ raise "SHA1 doesn't match expected value!" unless actual_sha1 == metadata.sha1
72
72
  end
73
73
 
74
74
  def validate_md5
75
75
  log.info("Expected MD5: #{metadata.md5}")
76
76
  actual_md5 = Digest::MD5.file(path_to_binary).hexdigest
77
77
  log.info("Actual MD5: #{actual_md5}")
78
- fail "MD5 doesn't match expected value!" unless actual_md5 == metadata.md5
78
+ raise "MD5 doesn't match expected value!" unless actual_md5 == metadata.md5
79
79
  end
80
80
  end
81
81
  end
data/lib/vara/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Vara
2
- VERSION = '0.21.1'.freeze
2
+ VERSION = '0.22.0'.freeze
3
3
  end
4
4
 
5
5
  # Copyright (c) 2014-2015 Pivotal Software, Inc.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.1
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CF Release Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-07 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor