bosh_cli 1.2840.0 → 1.2847.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: 1e93ae5c2fe1c781b37b94fbff419995baa1042a
4
- data.tar.gz: 073cca5e0b6b366f4fa0654b24625130e55f4039
3
+ metadata.gz: 4cfc5df8739eb9e7d78d6a9a2c84c0f1f2fd0e1a
4
+ data.tar.gz: a1c755ce722b3f95391f3ba5e380d13fd11ff40f
5
5
  SHA512:
6
- metadata.gz: ed49e3f58a0b79aa89d968a9bbe75acaa2c67a12df7d66bb65e4646b3e8af59a0a967a454e0844e8859696ea576dc1167ec9b511588aa6c8c8060fbc27338d76
7
- data.tar.gz: 642c36c8276eab9eb80ace81194994d392fa31c6b41fb78dba2630ce20945e1eff609379e85043ee9a36fc9d20bcb2c4fb3c5380704d570384920246f309a8d6
6
+ metadata.gz: 1dc06fa69265c241c855cc4d93710ddda55b63c82e4cfa4f9a48340e0f97c84763eb1b75ed2ce729f493b41c0cc34507e1660c94a3384f16eeec095b29bf1f0f
7
+ data.tar.gz: cb3e88d9a6958aa4ec9da5ce26a28ab1588be46b6eedb4120a90b95ebab4b16916c76873b427722e0a240eaec79afc382c5e69f9f9dc3d5df58c462d330e17bd
data/lib/cli.rb CHANGED
@@ -70,7 +70,7 @@ require 'cli/non_interactive_progress_renderer'
70
70
  require 'cli/source_control/git_ignore'
71
71
 
72
72
  require 'cli/versions/versions_index'
73
- require 'cli/versions/local_version_storage'
73
+ require 'cli/versions/local_artifact_storage'
74
74
  require 'cli/versions/release_versions_index'
75
75
  require 'cli/versions/releases_dir_migrator'
76
76
  require 'cli/versions/version_file_resolver'
@@ -66,7 +66,7 @@ module Bosh::Cli
66
66
  end
67
67
 
68
68
  if artifact.dev_artifact? && final? && !dry_run?
69
- artifact = @archive_repository.copy_from_dev_to_final(artifact)
69
+ @archive_repository.promote_from_dev_to_final(artifact)
70
70
  end
71
71
 
72
72
  artifact
@@ -1,20 +1,21 @@
1
1
  module Bosh::Cli
2
2
  class ArchiveRepository
3
- def initialize(archive_dir, blobstore, resource)
3
+ def initialize(archive_dir, artifacts_dir, blobstore, resource)
4
4
  @archive_dir = archive_dir
5
5
  @blobstore = blobstore
6
6
 
7
- dev_builds_dir = Pathname(@archive_dir).join(".dev_builds", resource.plural_type, resource.name).to_s
7
+ dev_builds_dir = Pathname(@archive_dir).join('.dev_builds', resource.plural_type, resource.name).to_s
8
8
  FileUtils.mkdir_p(dev_builds_dir)
9
9
  @dev_index = Versions::VersionsIndex.new(dev_builds_dir)
10
- @dev_storage = Versions::LocalVersionStorage.new(dev_builds_dir)
11
10
 
12
- final_builds_dir = Pathname(@archive_dir).join(".final_builds", resource.plural_type, resource.name).to_s
11
+ final_builds_dir = Pathname(@archive_dir).join('.final_builds', resource.plural_type, resource.name).to_s
13
12
  FileUtils.mkdir_p(final_builds_dir)
14
13
  @final_index = Versions::VersionsIndex.new(final_builds_dir)
15
- @final_storage = Versions::LocalVersionStorage.new(final_builds_dir)
16
14
 
17
- @final_resolver = Versions::VersionFileResolver.new(@final_storage, @blobstore)
15
+ @storage = Versions::LocalArtifactStorage.new(artifacts_dir)
16
+ FileUtils.mkdir_p(artifacts_dir)
17
+
18
+ @final_resolver = Versions::VersionFileResolver.new(@storage, @blobstore)
18
19
  end
19
20
 
20
21
  def lookup(resource)
@@ -26,18 +27,18 @@ module Bosh::Cli
26
27
  version = artifact_info['version'] || fingerprint
27
28
  sha1 = artifact_info['sha1']
28
29
 
29
- say('Using final version')
30
- tarball_path = @final_resolver.find_file(blobstore_id, sha1, version, "#{resource.singular_type} #{resource.name} (#{version})") # todo: 'package' vs 'job'
30
+ say("Using final version '#{version}'")
31
+ tarball_path = @final_resolver.find_file(blobstore_id, sha1, "#{resource.singular_type} #{resource.name} (#{version})")
31
32
 
32
33
  BuildArtifact.new(resource.name, fingerprint, tarball_path, sha1, resource.dependencies, false, false)
33
34
  else
34
35
  artifact_info = @dev_index[fingerprint]
35
36
  if artifact_info
36
- version = artifact_info['version'] || fingerprint
37
- if @dev_storage.has_file?(version)
38
- say('Using dev version')
37
+ if @storage.has_file?(artifact_info['sha1'])
38
+ version = artifact_info['version'] || fingerprint
39
+ say("Using dev version '#{version}'")
39
40
 
40
- tarball_path = @dev_storage.get_file(version)
41
+ tarball_path = @storage.get_file(artifact_info['sha1'])
41
42
  if file_checksum(tarball_path) != artifact_info['sha1']
42
43
  raise CorruptedArchive, "#{resource.singular_type} #{resource.name} (#{version}) archive at #{tarball_path} corrupted"
43
44
  end
@@ -75,27 +76,33 @@ module Bosh::Cli
75
76
  def install(artifact)
76
77
  fingerprint = artifact.fingerprint
77
78
  origin_file = artifact.tarball_path
78
- new_tarball_path = place_file_and_update_index(fingerprint, origin_file,
79
- artifact.dev_artifact? ? @dev_index : @final_index,
80
- artifact.dev_artifact? ? @dev_storage : @final_storage)
81
79
 
82
- BuildArtifact.new(artifact.name, artifact.fingerprint, new_tarball_path, artifact.sha1, artifact.dependencies, artifact.new_version?, artifact.dev_artifact?)
80
+ tarball_path = @storage.put_file(artifact.sha1, origin_file)
81
+
82
+ update_index(
83
+ tarball_path,
84
+ fingerprint,
85
+ artifact.dev_artifact? ? @dev_index : @final_index)
86
+
87
+ BuildArtifact.new(artifact.name, artifact.fingerprint, tarball_path, artifact.sha1, artifact.dependencies, artifact.new_version?, artifact.dev_artifact?)
83
88
  end
84
89
 
85
- def copy_from_dev_to_final(artifact)
86
- final_tarball_path = place_file_and_update_index(artifact.fingerprint, artifact.tarball_path, @final_index, @final_storage)
87
- BuildArtifact.new(artifact.name, artifact.fingerprint, final_tarball_path, artifact.sha1, artifact.dependencies, artifact.new_version?, false)
90
+ def promote_from_dev_to_final(artifact)
91
+ update_index(artifact.tarball_path, artifact.fingerprint, @final_index)
92
+ artifact.promote_to_final
88
93
  end
89
94
 
90
95
  private
91
96
 
92
- def place_file_and_update_index(fingerprint, origin_file, index, storage)
93
- # add version (with its validation) before adding sha1
94
- index.add_version(fingerprint, {'version' => fingerprint} )
95
- tarball_path = storage.put_file(fingerprint, origin_file)
97
+ def update_index(tarball_path, fingerprint, index)
98
+ # In case of corrupted file the new file will be downloaded/re-generated
99
+ # so sha1 needs to be updated to fix the index
100
+ unless index[fingerprint]
101
+ index.add_version(fingerprint, {'version' => fingerprint} )
102
+ end
103
+
96
104
  sha1 = file_checksum(tarball_path)
97
105
  index.update_version(fingerprint, {'version' => fingerprint, 'sha1' => sha1})
98
- tarball_path
99
106
  end
100
107
 
101
108
  def file_checksum(path)
@@ -1,12 +1,13 @@
1
1
  module Bosh::Cli
2
2
  class ArchiveRepositoryProvider
3
- def initialize(archive_dir, blobstore)
3
+ def initialize(archive_dir, artifacts_dir, blobstore)
4
4
  @archive_dir = archive_dir
5
+ @artifacts_dir = artifacts_dir
5
6
  @blobstore = blobstore
6
7
  end
7
8
 
8
9
  def get(resource)
9
- ArchiveRepository.new(@archive_dir, @blobstore, resource)
10
+ ArchiveRepository.new(@archive_dir, @artifacts_dir, @blobstore, resource)
10
11
  end
11
12
  end
12
13
  end
@@ -115,6 +115,10 @@ module Bosh::Cli
115
115
  options[:target] || config.target_name || target_url
116
116
  end
117
117
 
118
+ def cache_dir
119
+ File.join(Dir.home, '.bosh', 'cache')
120
+ end
121
+
118
122
  protected
119
123
 
120
124
  # Prints director task completion report. Note that event log usually
@@ -13,6 +13,10 @@ module Bosh::Cli
13
13
  @is_new_version = is_new_version
14
14
  end
15
15
 
16
+ def promote_to_final
17
+ @is_dev_artifact = false
18
+ end
19
+
16
20
  def version
17
21
  fingerprint
18
22
  end
@@ -26,7 +26,7 @@ module Bosh::Cli::Command
26
26
  end
27
27
 
28
28
  say('Recreating release from the manifest')
29
- Bosh::Cli::ReleaseCompiler.compile(manifest_file, release.blobstore)
29
+ Bosh::Cli::ReleaseCompiler.compile(manifest_file, cache_dir, release.blobstore)
30
30
  release_filename = manifest_file
31
31
  else
32
32
  version = options[:version]
@@ -84,6 +84,8 @@ module Bosh::Cli::Command
84
84
  header('Building DEV release'.make_green)
85
85
  end
86
86
 
87
+ say("Release artifact cache: #{cache_dir}")
88
+
87
89
  header('Building packages')
88
90
  package_artifacts = build_packages(dry_run, final)
89
91
 
@@ -162,7 +164,7 @@ module Bosh::Cli::Command
162
164
  end
163
165
 
164
166
  def archive_repository_provider
165
- @archive_repository_provider ||= Bosh::Cli::ArchiveRepositoryProvider.new(work_dir, release.blobstore)
167
+ @archive_repository_provider ||= Bosh::Cli::ArchiveRepositoryProvider.new(work_dir, cache_dir, release.blobstore)
166
168
  end
167
169
 
168
170
  def build_release(dry_run, final, job_artifacts, manifest_only, package_artifacts, name, version)
@@ -53,7 +53,7 @@ module Bosh::Cli::Command
53
53
  blobstore = release.blobstore
54
54
  tmpdir = Dir.mktmpdir
55
55
 
56
- compiler = Bosh::Cli::ReleaseCompiler.new(manifest_path, blobstore, package_matches)
56
+ compiler = Bosh::Cli::ReleaseCompiler.new(manifest_path, cache_dir, blobstore, package_matches)
57
57
  need_repack = true
58
58
 
59
59
  unless compiler.exists?
@@ -25,9 +25,9 @@ module Bosh::Cli
25
25
  @final_index = Versions::VersionsIndex.new(final_releases_dir)
26
26
  @dev_index = Versions::VersionsIndex.new(dev_releases_dir)
27
27
  @index = @final ? @final_index : @dev_index
28
- @release_storage = Versions::LocalVersionStorage.new(@index.storage_dir, @name)
28
+ @release_storage = Versions::LocalArtifactStorage.new(@index.storage_dir)
29
29
 
30
- if @version && @release_storage.has_file?(@version)
30
+ if @version && @release_storage.has_file?(release_filename)
31
31
  raise ReleaseVersionError.new('Release version already exists')
32
32
  end
33
33
 
@@ -49,6 +49,10 @@ module Bosh::Cli
49
49
  @final
50
50
  end
51
51
 
52
+ def release_filename
53
+ "#{@name}-#{@version}.tgz"
54
+ end
55
+
52
56
  # @return [Array<Bosh::Cli::BuildArtifact>] List of job artifacts
53
57
  # affected by this release compared to the previous one.
54
58
  def affected_jobs
@@ -156,7 +160,7 @@ module Bosh::Cli
156
160
 
157
161
  def generate_tarball
158
162
  generate_manifest unless @manifest_generated
159
- return if @release_storage.has_file?(@version)
163
+ return if @release_storage.has_file?(release_filename)
160
164
 
161
165
  unless @jobs_copied
162
166
  header("Copying jobs...")
@@ -6,8 +6,8 @@ module Bosh::Cli
6
6
 
7
7
  attr_writer :tarball_path
8
8
 
9
- def self.compile(manifest_file, blobstore)
10
- new(manifest_file, blobstore).compile
9
+ def self.compile(manifest_file, artifacts_dir, blobstore)
10
+ new(manifest_file, artifacts_dir, blobstore).compile
11
11
  end
12
12
 
13
13
  # @param [String] manifest_file Release manifest path
@@ -15,7 +15,7 @@ module Bosh::Cli
15
15
  # @param [Array] package_matches List of package checksums that director
16
16
  # can match
17
17
  # @param [String] release_source Release directory
18
- def initialize(manifest_file, blobstore,
18
+ def initialize(manifest_file, artifacts_dir, blobstore,
19
19
  package_matches = [], release_source = nil)
20
20
 
21
21
  @blobstore = blobstore
@@ -23,6 +23,7 @@ module Bosh::Cli
23
23
  @manifest_file = File.expand_path(manifest_file, @release_source)
24
24
  @tarball_path = nil
25
25
 
26
+ @artifacts_dir = artifacts_dir
26
27
  @build_dir = Dir.mktmpdir
27
28
  @jobs_dir = File.join(@build_dir, "jobs")
28
29
  @packages_dir = File.join(@build_dir, "packages")
@@ -131,14 +132,13 @@ module Bosh::Cli
131
132
  err("Cannot find #{build_type} with checksum `#{build.sha1}'")
132
133
  end
133
134
 
134
- version = found_build["version"]
135
135
  sha1 = found_build["sha1"]
136
136
  blobstore_id = found_build["blobstore_id"]
137
137
 
138
- storage = Versions::LocalVersionStorage.new(index.storage_dir)
138
+ storage = Versions::LocalArtifactStorage.new(@artifacts_dir)
139
139
 
140
140
  resolver = Versions::VersionFileResolver.new(storage, @blobstore)
141
- resolver.find_file(blobstore_id, sha1, version, "#{build_type} #{desc}")
141
+ resolver.find_file(blobstore_id, sha1, "#{build_type} #{desc}")
142
142
  rescue Bosh::Blobstore::BlobstoreError => e
143
143
  raise BlobstoreError, "Blobstore error: #{e}"
144
144
  end
data/lib/cli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cli
3
- VERSION = '1.2840.0'
3
+ VERSION = '1.2847.0'
4
4
  end
5
5
  end
@@ -1,40 +1,39 @@
1
1
  module Bosh::Cli::Versions
2
- class LocalVersionStorage
2
+ class LocalArtifactStorage
3
3
 
4
4
  class Sha1MismatchError < StandardError; end
5
5
 
6
6
  attr_reader :storage_dir
7
7
 
8
- def initialize(storage_dir, name_prefix=nil)
8
+ def initialize(storage_dir)
9
9
  @storage_dir = storage_dir
10
- @name_prefix = name_prefix
11
10
  end
12
11
 
13
- def put_file(version, origin_file_path)
14
- destination = file_path(version)
12
+ def put_file(sha, origin_file_path)
13
+ destination = file_path(sha)
15
14
  unless File.exist?(origin_file_path)
16
- raise "Trying to store non-existant file `#{origin_file_path}' for version `#{version}'"
15
+ raise "Trying to store non-existant file `#{origin_file_path}' with sha `#{sha}'"
17
16
  end
17
+ FileUtils.mkdir_p(File.dirname(destination))
18
18
  FileUtils.cp(origin_file_path, destination, :preserve => true)
19
19
 
20
20
  File.expand_path(destination)
21
21
  end
22
22
 
23
- def get_file(version)
24
- destination = file_path(version)
23
+ def get_file(sha)
24
+ destination = file_path(sha)
25
25
  unless File.exist?(destination)
26
- raise "Trying to retrieve non-existant file `#{destination}' for version `#{version}'"
26
+ raise "Trying to retrieve non-existant file `#{destination}' with sha `#{sha}'"
27
27
  end
28
28
 
29
29
  File.expand_path(destination)
30
30
  end
31
31
 
32
- def has_file?(version)
33
- File.exists?(file_path(version))
32
+ def has_file?(sha)
33
+ File.exists?(file_path(sha))
34
34
  end
35
35
 
36
- def file_path(version)
37
- name = @name_prefix.blank? ? "#{version}.tgz" : "#{@name_prefix}-#{version}.tgz"
36
+ def file_path(name)
38
37
  File.join(@storage_dir, name)
39
38
  end
40
39
  end
@@ -7,9 +7,9 @@ module Bosh::Cli::Versions
7
7
  @tmpdir = tmpdir
8
8
  end
9
9
 
10
- def find_file(blobstore_id, sha1, version, desc)
11
- if @storage.has_file?(version)
12
- file_path = @storage.get_file(version)
10
+ def find_file(blobstore_id, sha1, desc)
11
+ if @storage.has_file?(sha1)
12
+ file_path = @storage.get_file(sha1)
13
13
  file_sha1 = Digest::SHA1.file(file_path).hexdigest
14
14
  if file_sha1 == sha1
15
15
  return file_path
@@ -29,7 +29,7 @@ module Bosh::Cli::Versions
29
29
  @blobstore.get(blobstore_id, tmp_file, sha1: sha1)
30
30
  end
31
31
 
32
- @storage.put_file(version, tmp_file_path)
32
+ @storage.put_file(sha1, tmp_file_path)
33
33
  ensure
34
34
  FileUtils.rm(tmp_file_path, :force => true)
35
35
  end
@@ -31,7 +31,7 @@ module Bosh::Cli::Versions
31
31
  @index_file = File.join(@storage_dir, 'index.yml')
32
32
 
33
33
  if File.file?(@index_file)
34
- init_index(VersionsIndex.load_index_yaml(@index_file))
34
+ reload
35
35
  else
36
36
  init_index({})
37
37
  end
@@ -82,6 +82,10 @@ module Bosh::Cli::Versions
82
82
  raise "Cannot update non-existent entry with key `#{key}'"
83
83
  end
84
84
 
85
+ if old_build['blobstore_id']
86
+ raise "Cannot update entry `#{old_build}' with a blobstore id"
87
+ end
88
+
85
89
  if new_build['version'] != old_build['version']
86
90
  raise "Cannot update entry `#{old_build}' with a different version: `#{new_build}'"
87
91
  end
@@ -128,6 +132,10 @@ module Bosh::Cli::Versions
128
132
  VersionsIndex.write_index_yaml(@index_file, @data)
129
133
  end
130
134
 
135
+ def reload
136
+ init_index(VersionsIndex.load_index_yaml(@index_file))
137
+ end
138
+
131
139
  private
132
140
 
133
141
  def create_directories
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2840.0
4
+ version: 1.2847.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - VMware
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-11 00:00:00.000000000 Z
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_common
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.2840.0
19
+ version: 1.2847.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.2840.0
26
+ version: 1.2847.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bosh-template
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.2840.0
33
+ version: 1.2847.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.2840.0
40
+ version: 1.2847.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json_pure
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2840.0
117
+ version: 1.2847.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 1.2840.0
124
+ version: 1.2847.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: net-ssh
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +194,7 @@ dependencies:
194
194
  version: 0.5.4
195
195
  description: |-
196
196
  BOSH CLI
197
- e0ed0c
197
+ 139553
198
198
  email: support@cloudfoundry.com
199
199
  executables:
200
200
  - bosh
@@ -294,7 +294,7 @@ files:
294
294
  - lib/cli/task_tracking/total_duration.rb
295
295
  - lib/cli/validation.rb
296
296
  - lib/cli/version.rb
297
- - lib/cli/versions/local_version_storage.rb
297
+ - lib/cli/versions/local_artifact_storage.rb
298
298
  - lib/cli/versions/multi_release_support.rb
299
299
  - lib/cli/versions/release_versions_index.rb
300
300
  - lib/cli/versions/releases_dir_migrator.rb