bosh_cli 1.2950.0 → 1.2957.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cli/commands/release/create_release.rb +2 -57
- data/lib/cli/commands/release/finalize_release.rb +143 -0
- data/lib/cli/release_print_helper.rb +60 -0
- data/lib/cli/release_tarball.rb +77 -6
- data/lib/cli/version.rb +1 -1
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4c43e590bd60e19d51b6f40052a5e25552712a0
|
4
|
+
data.tar.gz: 730712d500e6fd5ba18029aff88faa046c65751d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb127e885dfe3d743023318b5f8c06d89604987196171d107b5382566be403e0d372458797023fac29a3003bca12ea0f972476e37fad496aa416ebdc3bf03928
|
7
|
+
data.tar.gz: bd75913d2e3bb252325fc4ab647ff81a8afa2632e40434dda861870f865207e06112bb6769186dbd283b3d2c729b66f03f289439c1d49b91173bfab618da0889
|
@@ -1,6 +1,8 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../release_print_helper.rb')
|
1
2
|
module Bosh::Cli::Command
|
2
3
|
module Release
|
3
4
|
class CreateRelease < Base
|
5
|
+
include ReleasePrintHelper
|
4
6
|
include Bosh::Cli::DependencyHelper
|
5
7
|
|
6
8
|
DEFAULT_RELEASE_NAME = 'bosh-release'
|
@@ -236,63 +238,6 @@ module Bosh::Cli::Command
|
|
236
238
|
release.save_config
|
237
239
|
end
|
238
240
|
|
239
|
-
def show_summary(builder)
|
240
|
-
packages_table = table do |t|
|
241
|
-
t.headings = %w(Name Version Notes)
|
242
|
-
builder.packages.each do |package_artifact|
|
243
|
-
t << artifact_summary(package_artifact)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
jobs_table = table do |t|
|
248
|
-
t.headings = %w(Name Version Notes)
|
249
|
-
builder.jobs.each do |job_artifact|
|
250
|
-
t << artifact_summary(job_artifact)
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
if builder.license
|
255
|
-
license_table = table do |t|
|
256
|
-
t.headings = %w(Name Version Notes)
|
257
|
-
t << artifact_summary(builder.license)
|
258
|
-
end
|
259
|
-
|
260
|
-
say('License')
|
261
|
-
say(license_table)
|
262
|
-
nl
|
263
|
-
end
|
264
|
-
|
265
|
-
say('Packages')
|
266
|
-
say(packages_table)
|
267
|
-
nl
|
268
|
-
say('Jobs')
|
269
|
-
say(jobs_table)
|
270
|
-
|
271
|
-
affected_jobs = builder.affected_jobs
|
272
|
-
|
273
|
-
if affected_jobs.size > 0
|
274
|
-
nl
|
275
|
-
say('Jobs affected by changes in this release')
|
276
|
-
|
277
|
-
affected_jobs_table = table do |t|
|
278
|
-
t.headings = %w(Name Version)
|
279
|
-
affected_jobs.each do |job|
|
280
|
-
t << [job.name, job.version]
|
281
|
-
end
|
282
|
-
end
|
283
|
-
|
284
|
-
say(affected_jobs_table)
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
def artifact_summary(artifact)
|
289
|
-
[
|
290
|
-
artifact.name,
|
291
|
-
artifact.version,
|
292
|
-
artifact.new_version? ? 'new version' : '',
|
293
|
-
]
|
294
|
-
end
|
295
|
-
|
296
241
|
def commit_hash
|
297
242
|
status = Bosh::Exec.sh('git show-ref --head --hash=8 2> /dev/null')
|
298
243
|
status.output.split.first
|
@@ -0,0 +1,143 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../release_print_helper.rb')
|
2
|
+
module Bosh::Cli::Command
|
3
|
+
module Release
|
4
|
+
class FinalizeRelease < Base
|
5
|
+
include ReleasePrintHelper
|
6
|
+
include Bosh::Cli::DependencyHelper
|
7
|
+
|
8
|
+
# bosh finalize release
|
9
|
+
usage 'finalize release'
|
10
|
+
desc 'Create final release from dev release tarball (assumes current directory to be a release repository)'
|
11
|
+
option '--dry-run', 'stop before writing release manifest'
|
12
|
+
option '--name NAME', 'specify a custom release name'
|
13
|
+
option '--version VERSION', 'specify a custom version number (ex: 1.0.0 or 1.0-beta.2+dev.10)'
|
14
|
+
|
15
|
+
def finalize(tarball_path)
|
16
|
+
options[:final] = true
|
17
|
+
|
18
|
+
# validate preconditions
|
19
|
+
check_if_release_dir
|
20
|
+
|
21
|
+
tarball = extract_and_validate_tarball(tarball_path)
|
22
|
+
|
23
|
+
manifest = Psych.load(tarball.manifest)
|
24
|
+
|
25
|
+
dev_release_name = manifest["name"]
|
26
|
+
dev_release_ver = manifest["version"]
|
27
|
+
final_release_name = options[:name] || dev_release_name
|
28
|
+
|
29
|
+
final_release_dir = File.join('releases', final_release_name)
|
30
|
+
@release_index = Bosh::Cli::Versions::VersionsIndex.new(final_release_dir)
|
31
|
+
final_release_ver = options[:version] || next_final_version
|
32
|
+
|
33
|
+
if options[:version] && @release_index.version_strings.include?(options[:version])
|
34
|
+
raise Bosh::Cli::ReleaseVersionError.new('Release version already exists')
|
35
|
+
end
|
36
|
+
|
37
|
+
check_if_blob_manager_is_dirty
|
38
|
+
|
39
|
+
@progress_renderer = Bosh::Cli::InteractiveProgressRenderer.new
|
40
|
+
|
41
|
+
if !options[:dry_run] then
|
42
|
+
release.blobstore # prime & validate blobstore config
|
43
|
+
|
44
|
+
manifest["version"] = final_release_ver
|
45
|
+
manifest["name"] = final_release_name
|
46
|
+
|
47
|
+
tarball.replace_manifest(manifest)
|
48
|
+
|
49
|
+
FileUtils.mkdir_p(final_release_dir)
|
50
|
+
final_release_manifest_path = File.absolute_path(File.join(final_release_dir, "#{final_release_name}-#{final_release_ver}.yml"))
|
51
|
+
File.open(final_release_manifest_path, 'w') do |release_manifest_file|
|
52
|
+
release_manifest_file.puts(tarball.manifest)
|
53
|
+
end
|
54
|
+
|
55
|
+
@release_index.add_version(SecureRandom.uuid, "version" => final_release_ver)
|
56
|
+
|
57
|
+
final_release_tarball_path = File.absolute_path(File.join(final_release_dir, "#{final_release_name}-#{final_release_ver}.tgz"))
|
58
|
+
tarball.create_from_unpacked(final_release_tarball_path)
|
59
|
+
|
60
|
+
upload_package_and_job_blobs(manifest, tarball)
|
61
|
+
|
62
|
+
nl
|
63
|
+
say("Creating final release #{final_release_name}/#{final_release_ver} from dev release #{dev_release_name}/#{dev_release_ver}")
|
64
|
+
|
65
|
+
release.latest_release_filename = final_release_manifest_path
|
66
|
+
release.save_config
|
67
|
+
|
68
|
+
header('Release summary')
|
69
|
+
show_summary(tarball)
|
70
|
+
nl
|
71
|
+
|
72
|
+
say("Release name: #{final_release_name.make_green}")
|
73
|
+
say("Release version: #{final_release_ver.to_s.make_green}")
|
74
|
+
say("Release manifest: #{release.latest_release_filename.make_green}")
|
75
|
+
say("Release tarball (#{pretty_size(final_release_tarball_path)}): " + final_release_tarball_path.make_green)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def upload_package_and_job_blobs(manifest, tarball)
|
80
|
+
manifest['packages'].each do |package|
|
81
|
+
upload_to_blobstore(package, 'packages', tarball.package_tarball_path(package['name']))
|
82
|
+
end
|
83
|
+
|
84
|
+
manifest['jobs'].each do |job|
|
85
|
+
upload_to_blobstore(job, 'jobs', tarball.job_tarball_path(job['name']))
|
86
|
+
end
|
87
|
+
|
88
|
+
if manifest['license']
|
89
|
+
license_metadata = manifest['license'].clone
|
90
|
+
license_metadata['name'] = 'license'
|
91
|
+
upload_to_blobstore(license_metadata, '', tarball.license_tarball_path)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def extract_and_validate_tarball(tarball_path)
|
96
|
+
tarball = Bosh::Cli::ReleaseTarball.new(tarball_path)
|
97
|
+
err("Cannot find release tarball #{tarball_path}") if !tarball.exists?
|
98
|
+
|
99
|
+
err("#{tarball_path} is not a valid release tarball") if !tarball.valid?(:print_release_info => false)
|
100
|
+
tarball
|
101
|
+
end
|
102
|
+
|
103
|
+
def check_if_blob_manager_is_dirty
|
104
|
+
nl
|
105
|
+
blob_manager.sync
|
106
|
+
if blob_manager.dirty?
|
107
|
+
blob_manager.print_status
|
108
|
+
err("Please use '--force' or upload new blobs")
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def next_final_version
|
113
|
+
latest_final_version = Bosh::Cli::Versions::ReleaseVersionsIndex.new(@release_index).latest_version
|
114
|
+
latest_final_version ||= Bosh::Common::Version::ReleaseVersion.parse('0')
|
115
|
+
latest_final_version = latest_final_version.increment_release
|
116
|
+
latest_final_version.to_s
|
117
|
+
end
|
118
|
+
|
119
|
+
def upload_to_blobstore(artifact, plural_type, artifact_path)
|
120
|
+
err("Cannot find artifact complete information, please upgrade tarball to newer version") if !artifact['fingerprint']
|
121
|
+
|
122
|
+
final_builds_dir = File.join('.final_builds', plural_type, artifact['name']).to_s
|
123
|
+
FileUtils.mkdir_p(final_builds_dir)
|
124
|
+
final_builds_index = Bosh::Cli::Versions::VersionsIndex.new(final_builds_dir)
|
125
|
+
|
126
|
+
return artifact if final_builds_index[artifact['fingerprint']]
|
127
|
+
|
128
|
+
@progress_renderer.start(artifact['name'], "uploading...")
|
129
|
+
blobstore_id = nil
|
130
|
+
File.open(artifact_path, 'r') do |f|
|
131
|
+
blobstore_id = @release.blobstore.create(f)
|
132
|
+
end
|
133
|
+
|
134
|
+
final_builds_index.add_version(artifact['fingerprint'], {
|
135
|
+
'version' => artifact['version'],
|
136
|
+
'sha1' => artifact['sha1'],
|
137
|
+
'blobstore_id' => blobstore_id
|
138
|
+
})
|
139
|
+
@progress_renderer.finish(artifact['name'], "uploaded")
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module ReleasePrintHelper
|
2
|
+
|
3
|
+
private
|
4
|
+
def artifact_summary(artifact)
|
5
|
+
[
|
6
|
+
artifact.name,
|
7
|
+
artifact.version,
|
8
|
+
artifact.new_version? ? 'new version' : '',
|
9
|
+
]
|
10
|
+
end
|
11
|
+
|
12
|
+
def show_summary(builder)
|
13
|
+
packages_table = table do |t|
|
14
|
+
t.headings = %w(Name Version Notes)
|
15
|
+
builder.packages.each do |package_artifact|
|
16
|
+
t << artifact_summary(package_artifact)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
jobs_table = table do |t|
|
21
|
+
t.headings = %w(Name Version Notes)
|
22
|
+
builder.jobs.each do |job_artifact|
|
23
|
+
t << artifact_summary(job_artifact)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if builder.license
|
28
|
+
license_table = table do |t|
|
29
|
+
t.headings = %w(Name Version Notes)
|
30
|
+
t << artifact_summary(builder.license)
|
31
|
+
end
|
32
|
+
|
33
|
+
say('License')
|
34
|
+
say(license_table)
|
35
|
+
nl
|
36
|
+
end
|
37
|
+
|
38
|
+
say('Packages')
|
39
|
+
say(packages_table)
|
40
|
+
nl
|
41
|
+
say('Jobs')
|
42
|
+
say(jobs_table)
|
43
|
+
|
44
|
+
affected_jobs = builder.affected_jobs
|
45
|
+
|
46
|
+
if affected_jobs.size > 0
|
47
|
+
nl
|
48
|
+
say('Jobs affected by changes in this release')
|
49
|
+
|
50
|
+
affected_jobs_table = table do |t|
|
51
|
+
t.headings = %w(Name Version)
|
52
|
+
affected_jobs.each do |job|
|
53
|
+
t << [job.name, job.version]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
say(affected_jobs_table)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/cli/release_tarball.rb
CHANGED
@@ -4,7 +4,7 @@ module Bosh::Cli
|
|
4
4
|
include DependencyHelper
|
5
5
|
|
6
6
|
attr_reader :release_name, :jobs, :packages, :version
|
7
|
-
attr_reader :skipped # Mostly for tests
|
7
|
+
attr_reader :skipped, :unpack_dir # Mostly for tests
|
8
8
|
|
9
9
|
def initialize(tarball_path)
|
10
10
|
@tarball_path = File.expand_path(tarball_path, Dir.pwd)
|
@@ -20,6 +20,13 @@ module Bosh::Cli
|
|
20
20
|
@unpacked = $?.exitstatus == 0
|
21
21
|
end
|
22
22
|
|
23
|
+
# Creates a new tarball from the current contents of @unpack_dir
|
24
|
+
def create_from_unpacked(target_path)
|
25
|
+
raise "Not unpacked yet!" unless @unpacked
|
26
|
+
`tar -C #{@unpack_dir} -pczf '#{File.expand_path(target_path)}' . 2>&1`
|
27
|
+
$?.exitstatus == 0
|
28
|
+
end
|
29
|
+
|
23
30
|
def exists?
|
24
31
|
File.exists?(@tarball_path) && File.readable?(@tarball_path)
|
25
32
|
end
|
@@ -30,6 +37,35 @@ module Bosh::Cli
|
|
30
37
|
File.read(File.join(@unpack_dir, "release.MF"))
|
31
38
|
end
|
32
39
|
|
40
|
+
def replace_manifest(hash)
|
41
|
+
return nil unless valid?
|
42
|
+
unpack
|
43
|
+
write_yaml(hash, File.join(@unpack_dir, "release.MF"))
|
44
|
+
end
|
45
|
+
|
46
|
+
def job_tarball_path(name)
|
47
|
+
return nil unless valid?
|
48
|
+
unpack
|
49
|
+
File.join(@unpack_dir, 'jobs', "#{name}.tgz")
|
50
|
+
end
|
51
|
+
|
52
|
+
def package_tarball_path(name)
|
53
|
+
return nil unless valid?
|
54
|
+
unpack
|
55
|
+
File.join(@unpack_dir, 'packages', "#{name}.tgz")
|
56
|
+
end
|
57
|
+
|
58
|
+
def license_tarball_path
|
59
|
+
return nil unless valid?
|
60
|
+
unpack
|
61
|
+
l = Resources::License.new(@unpack_dir)
|
62
|
+
if l.files
|
63
|
+
l.files[0][0]
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
33
69
|
def convert_to_old_format
|
34
70
|
step('Converting to old format',
|
35
71
|
"Cannot extract tarball #{@tarball_path}", :fatal) do
|
@@ -95,10 +131,8 @@ module Bosh::Cli
|
|
95
131
|
# and packages in place when we do validation. However for jobs and packages
|
96
132
|
# that are present we still need to validate checksums
|
97
133
|
def perform_validation(options = {})
|
98
|
-
|
99
|
-
|
100
|
-
!!options[:allow_sparse] :
|
101
|
-
false
|
134
|
+
allow_sparse = options.fetch(:allow_sparse, false)
|
135
|
+
should_print_release_info = options.fetch(:print_release_info, true)
|
102
136
|
|
103
137
|
step("File exists and readable",
|
104
138
|
"Cannot find release file #{@tarball_path}", :fatal) do
|
@@ -252,7 +286,44 @@ module Bosh::Cli
|
|
252
286
|
end
|
253
287
|
end
|
254
288
|
|
255
|
-
print_info(manifest)
|
289
|
+
print_info(manifest) if should_print_release_info
|
290
|
+
end
|
291
|
+
|
292
|
+
class TarballArtifact
|
293
|
+
def initialize(info)
|
294
|
+
@name = info['name']
|
295
|
+
@version = info['version']
|
296
|
+
end
|
297
|
+
|
298
|
+
attr_reader :name, :version
|
299
|
+
|
300
|
+
def new_version?
|
301
|
+
false
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
def license
|
306
|
+
m = Psych.load(manifest)
|
307
|
+
license = m['license']
|
308
|
+
return nil if !license
|
309
|
+
license['name'] = 'license'
|
310
|
+
TarballArtifact.new(license)
|
311
|
+
end
|
312
|
+
|
313
|
+
def packages
|
314
|
+
m = Psych.load(manifest)
|
315
|
+
packages = m['packages'] || []
|
316
|
+
packages.map { |pkg| TarballArtifact.new(pkg) }
|
317
|
+
end
|
318
|
+
|
319
|
+
def jobs
|
320
|
+
m = Psych.load(manifest)
|
321
|
+
jobs = m['jobs'] || []
|
322
|
+
jobs.map { |job| TarballArtifact.new(job) }
|
323
|
+
end
|
324
|
+
|
325
|
+
def affected_jobs
|
326
|
+
[]
|
256
327
|
end
|
257
328
|
|
258
329
|
def print_info(manifest)
|
data/lib/cli/version.rb
CHANGED
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.
|
4
|
+
version: 1.2957.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-04-
|
11
|
+
date: 2015-04-30 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.
|
19
|
+
version: 1.2957.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.
|
26
|
+
version: 1.2957.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.
|
33
|
+
version: 1.2957.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.
|
40
|
+
version: 1.2957.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: cf-uaa-lib
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 1.
|
131
|
+
version: 1.2957.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 1.
|
138
|
+
version: 1.2957.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: net-ssh
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -306,7 +306,7 @@ dependencies:
|
|
306
306
|
version: '0'
|
307
307
|
description: |-
|
308
308
|
BOSH CLI
|
309
|
-
|
309
|
+
c9cf4f
|
310
310
|
email: support@cloudfoundry.com
|
311
311
|
executables:
|
312
312
|
- bosh
|
@@ -361,6 +361,7 @@ files:
|
|
361
361
|
- lib/cli/commands/property_management.rb
|
362
362
|
- lib/cli/commands/release/create_release.rb
|
363
363
|
- lib/cli/commands/release/delete_release.rb
|
364
|
+
- lib/cli/commands/release/finalize_release.rb
|
364
365
|
- lib/cli/commands/release/init_release.rb
|
365
366
|
- lib/cli/commands/release/list_releases.rb
|
366
367
|
- lib/cli/commands/release/reset_release.rb
|
@@ -401,6 +402,7 @@ files:
|
|
401
402
|
- lib/cli/release_archiver.rb
|
402
403
|
- lib/cli/release_builder.rb
|
403
404
|
- lib/cli/release_compiler.rb
|
405
|
+
- lib/cli/release_print_helper.rb
|
404
406
|
- lib/cli/release_tarball.rb
|
405
407
|
- lib/cli/resources/job.rb
|
406
408
|
- lib/cli/resources/license.rb
|