bosh_cli 1.2549.0 → 1.2559.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.
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Cli::Command
4
2
  class JobRename < Base
5
3
  # bosh rename
@@ -1,9 +1,5 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Cli
4
2
  module DeploymentHelper
5
- include VersionCalc
6
-
7
3
  def prepare_deployment_manifest(options = {})
8
4
  deployment_required
9
5
  manifest_filename = deployment
@@ -372,7 +368,7 @@ module Bosh::Cli
372
368
  end
373
369
 
374
370
  stemcells.inject({}) do |hash, (name, versions)|
375
- hash[name] = versions.sort { |v1, v2| version_cmp(v2, v1) }.first
371
+ hash[name] = versions.map { |v| Bosh::Common::VersionNumber.new(v) }.max.to_s
376
372
  hash
377
373
  end
378
374
  end
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Cli
4
2
  class JobBuilder
5
3
  include PackagingHelper
@@ -236,7 +234,8 @@ module Bosh::Cli
236
234
  private
237
235
 
238
236
  def make_fingerprint
239
- contents = ""
237
+ versioning_scheme = 2
238
+ contents = "v#{versioning_scheme}"
240
239
 
241
240
  files = all_templates
242
241
  files << File.join(job_dir, "spec")
@@ -211,7 +211,8 @@ module Bosh::Cli
211
211
  private
212
212
 
213
213
  def make_fingerprint
214
- contents = ""
214
+ versioning_scheme = 2
215
+ contents = "v#{versioning_scheme}"
215
216
 
216
217
  signatures = glob_matches.map do |match|
217
218
  file_digest = nil
@@ -1,13 +1,9 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  # This relies on having the following instance variables in a host class:
4
2
  # @dev_builds_dir, @final_builds_dir, @blobstore,
5
3
  # @name, @version, @tarball_path, @final, @artefact_type
6
4
 
7
5
  module Bosh::Cli
8
6
  module PackagingHelper
9
- include Bosh::Cli::VersionCalc
10
-
11
7
  attr_accessor :dry_run
12
8
 
13
9
  def init_indices
@@ -27,32 +23,21 @@ module Bosh::Cli
27
23
  @tarball_generated || @promoted || @will_be_promoted
28
24
  end
29
25
 
30
- def older_version?
31
- if @tarball_generated
32
- false
33
- elsif @used_final_version
34
- version_cmp(@version, @final_index.latest_version) < 0
35
- else
36
- version_cmp(@version, @dev_index.latest_version) < 0
37
- end
38
- end
39
-
40
26
  def notes
41
27
  notes = []
42
28
 
43
29
  if @will_be_promoted
44
- new_final_version = @final_index.latest_version.to_i + 1
30
+ new_final_version = @version
45
31
  notes << "new final version #{new_final_version}"
46
32
  elsif new_version?
47
- notes << "new version"
33
+ notes << 'new version'
48
34
  end
49
35
 
50
- notes << "older than latest" if older_version?
51
36
  notes
52
37
  end
53
38
 
54
39
  def build
55
- with_indent(" ") do
40
+ with_indent(' ') do
56
41
  use_final_version || use_dev_version || generate_tarball
57
42
  end
58
43
  upload_tarball(@tarball_path) if final? && !dry_run?
@@ -60,20 +45,20 @@ module Bosh::Cli
60
45
  end
61
46
 
62
47
  def use_final_version
63
- say("Final version:", " ")
48
+ say('Final version:', ' ')
64
49
 
65
50
  item = @final_index[fingerprint]
66
51
 
67
52
  if item.nil?
68
- say("NOT FOUND".make_red)
53
+ say('NOT FOUND'.make_red)
69
54
  return nil
70
55
  end
71
56
 
72
- blobstore_id = item["blobstore_id"]
73
- version = item["version"]
57
+ blobstore_id = item['blobstore_id']
58
+ version = fingerprint
74
59
 
75
60
  if blobstore_id.nil?
76
- say("No blobstore id".make_red)
61
+ say('No blobstore id'.make_red)
77
62
  return nil
78
63
  end
79
64
 
@@ -81,29 +66,29 @@ module Bosh::Cli
81
66
  need_fetch = true
82
67
 
83
68
  if File.exists?(filename)
84
- say("FOUND LOCAL".make_green)
85
- if file_checksum(filename) == item["sha1"]
69
+ say('FOUND LOCAL'.make_green)
70
+ if file_checksum(filename) == item['sha1']
86
71
  @tarball_path = filename
87
72
  need_fetch = false
88
73
  else
89
- say("LOCAL CHECKSUM MISMATCH".make_red)
74
+ say('LOCAL CHECKSUM MISMATCH'.make_red)
90
75
  need_fetch = true
91
76
  end
92
77
  end
93
78
 
94
79
  if need_fetch
95
80
  say("Downloading `#{name} (#{version})'...".make_green)
96
- tmp_file = File.open(File.join(Dir.mktmpdir, name), "w")
81
+ tmp_file = File.open(File.join(Dir.mktmpdir, name), 'w')
97
82
  @blobstore.get(blobstore_id, tmp_file)
98
83
  tmp_file.close
99
- if Digest::SHA1.file(tmp_file.path).hexdigest == item["sha1"]
84
+ if Digest::SHA1.file(tmp_file.path).hexdigest == item['sha1']
100
85
  @tarball_path = @final_index.add_version(fingerprint,
101
86
  item,
102
87
  tmp_file.path)
103
88
  else
104
89
  err("`#{name}' (#{version}) is corrupted in blobstore " +
105
90
  "(id=#{blobstore_id}), " +
106
- "please remove it manually and re-generate the final release")
91
+ 'please remove it manually and re-generate the final release')
107
92
  end
108
93
  end
109
94
 
@@ -117,25 +102,25 @@ module Bosh::Cli
117
102
  end
118
103
 
119
104
  def use_dev_version
120
- say("Dev version:", " ")
105
+ say('Dev version:', ' ')
121
106
  item = @dev_index[fingerprint]
122
107
 
123
108
  if item.nil?
124
- say("NOT FOUND".make_red)
109
+ say('NOT FOUND'.make_red)
125
110
  return nil
126
111
  end
127
112
 
128
- version = item["version"]
113
+ version = fingerprint
129
114
  filename = @dev_index.filename(version)
130
115
 
131
116
  if File.exists?(filename)
132
- say("FOUND LOCAL".make_green)
117
+ say('FOUND LOCAL'.make_green)
133
118
  else
134
- say("TARBALL MISSING".make_red)
119
+ say('TARBALL MISSING'.make_red)
135
120
  return nil
136
121
  end
137
122
 
138
- if file_checksum(filename) == item["sha1"]
123
+ if file_checksum(filename) == item['sha1']
139
124
  @tarball_path = filename
140
125
  @version = version
141
126
  @used_dev_version = true
@@ -147,20 +132,17 @@ module Bosh::Cli
147
132
 
148
133
  def generate_tarball
149
134
  if final?
150
- err_message = "No matching build found for " +
135
+ err_message = 'No matching build found for ' +
151
136
  "`#{@name}' #{@artefact_type}.\n" +
152
137
  "Please consider creating a dev release first.\n" +
153
138
  "The fingerprint is `#{fingerprint}'."
154
139
  err(err_message)
155
140
  end
156
141
 
157
- current_final = @final_index.latest_version.to_i
158
- new_minor = minor_version(@dev_index.latest_version(current_final)) + 1
159
-
160
- version = "#{current_final}.#{new_minor}-dev"
142
+ version = fingerprint
161
143
  tmp_file = Tempfile.new(name)
162
144
 
163
- say("Generating...")
145
+ say('Generating...')
164
146
 
165
147
  copy_files
166
148
 
@@ -172,7 +154,7 @@ module Bosh::Cli
172
154
  end
173
155
 
174
156
  item = {
175
- "version" => version
157
+ 'version' => version
176
158
  }
177
159
 
178
160
  unless dry_run?
@@ -192,20 +174,20 @@ module Bosh::Cli
192
174
  say("Uploading final version #{version}...")
193
175
 
194
176
  if item
195
- say("This package has already been uploaded")
177
+ say('This package has already been uploaded')
196
178
  return
197
179
  end
198
180
 
199
- version = @final_index.latest_version.to_i + 1
181
+ version = fingerprint
200
182
 
201
183
  blobstore_id = nil
202
- File.open(path, "r") do |f|
184
+ File.open(path, 'r') do |f|
203
185
  blobstore_id = @blobstore.create(f)
204
186
  end
205
187
 
206
188
  item = {
207
- "blobstore_id" => blobstore_id,
208
- "version" => version
189
+ 'blobstore_id' => blobstore_id,
190
+ 'version' => version
209
191
  }
210
192
 
211
193
  say("Uploaded, blobstore id #{blobstore_id}")
@@ -227,7 +209,7 @@ module Bosh::Cli
227
209
  file_checksum(@tarball_path)
228
210
  else
229
211
  raise RuntimeError,
230
- "cannot read checksum for not yet generated package/job"
212
+ 'cannot read checksum for not yet generated package/job'
231
213
  end
232
214
  end
233
215
 
@@ -239,11 +221,11 @@ module Bosh::Cli
239
221
  # fingerprints to change, hence the exact values below.
240
222
  def tracked_permissions(path)
241
223
  if File.directory?(path)
242
- "40755"
224
+ '40755'
243
225
  elsif File.executable?(path)
244
- "100755"
226
+ '100755'
245
227
  else
246
- "100644"
228
+ '100644'
247
229
  end
248
230
  end
249
231
  end
data/lib/cli/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module Cli
3
- VERSION = '1.2549.0'
3
+ VERSION = '1.2559.0'
4
4
  end
5
5
  end
@@ -1,7 +1,10 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  require 'common/version_number'
4
2
 
3
+ ##
4
+ # This module is in general unsafe to use as packages and jobs
5
+ # use their fingerprints as versions and therefore are not numerically
6
+ # comparable. At the moment releases retain a numerically comparable
7
+ # version which necessitates this code
5
8
  module Bosh::Cli
6
9
  module VersionCalc
7
10
 
@@ -1,5 +1,3 @@
1
- # Copyright (c) 2009-2012 VMware, Inc.
2
-
3
1
  module Bosh::Cli
4
2
  class VersionsIndex
5
3
  include VersionCalc
@@ -27,6 +25,14 @@ module Bosh::Cli
27
25
  @data["builds"][fingerprint]
28
26
  end
29
27
 
28
+ ##
29
+ # Return the last version from the version index file
30
+ # as jobs and packages have a non-numeric versioning
31
+ # scheme based on their fingerprint. This function relies
32
+ # on hash insertion order being preserved. While this
33
+ # is the behavior for Ruby 1.9.X and 2.X we should
34
+ # remember that this implementation is
35
+ # a little brittle.
30
36
  def latest_version(major = nil)
31
37
  builds = @data["builds"].values
32
38
 
@@ -38,16 +44,7 @@ module Bosh::Cli
38
44
 
39
45
  return nil if builds.empty?
40
46
 
41
- sorted = builds.sort do |build1, build2|
42
- cmp = version_cmp(build2["version"], build1["version"])
43
- if cmp == 0
44
- raise "There is a duplicate version `#{build1["version"]}' " +
45
- "in index `#{@index_file}'"
46
- end
47
- cmp
48
- end
49
-
50
- sorted[0]["version"]
47
+ builds.last["version"]
51
48
  end
52
49
 
53
50
  def version_exists?(version)
@@ -69,7 +66,7 @@ module Bosh::Cli
69
66
  end
70
67
 
71
68
  @data["builds"].each_pair do |fp, build|
72
- if version_cmp(build["version"], version) == 0 && fp != fingerprint
69
+ if build["version"] == version && fp != fingerprint
73
70
  raise "Trying to add duplicate version `#{version}' " +
74
71
  "into index `#{@index_file}'"
75
72
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2549.0
4
+ version: 1.2559.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-14 00:00:00.000000000 Z
12
+ date: 2014-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bosh_common
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.2549.0
21
+ version: 1.2559.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.2549.0
29
+ version: 1.2559.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: json_pure
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -114,7 +114,7 @@ dependencies:
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
- version: 1.2549.0
117
+ version: 1.2559.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ~>
124
124
  - !ruby/object:Gem::Version
125
- version: 1.2549.0
125
+ version: 1.2559.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: net-ssh
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -269,7 +269,7 @@ dependencies:
269
269
  version: '0'
270
270
  description: ! 'BOSH CLI
271
271
 
272
- 0d3835'
272
+ 664e0d'
273
273
  email: support@cloudfoundry.com
274
274
  executables:
275
275
  - bosh
@@ -382,7 +382,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
382
382
  version: '0'
383
383
  segments:
384
384
  - 0
385
- hash: 2582591083377905506
385
+ hash: 850142297051739399
386
386
  requirements: []
387
387
  rubyforge_project:
388
388
  rubygems_version: 1.8.23