bosh-workspace 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +5 -13
  2. data/.ruby-version +1 -1
  3. data/.travis.yml +8 -0
  4. data/Gemfile +4 -0
  5. data/Guardfile +2 -2
  6. data/README.md +78 -39
  7. data/Rakefile +4 -0
  8. data/bosh-workspace.gemspec +4 -1
  9. data/lib/bosh/cli/commands/prepare.rb +74 -0
  10. data/lib/bosh/cli/commands/{01_make_manifest.rb → project_deployment.rb} +4 -26
  11. data/lib/bosh/workspace.rb +7 -3
  12. data/lib/bosh/workspace/helpers/dns_helper.rb +72 -0
  13. data/lib/bosh/workspace/helpers/project_deployment_helper.rb +8 -3
  14. data/lib/bosh/workspace/helpers/release_helper.rb +33 -0
  15. data/lib/bosh/workspace/helpers/spiff_helper.rb +1 -1
  16. data/lib/bosh/workspace/helpers/stemcell_helper.rb +45 -0
  17. data/lib/bosh/workspace/manifest_builder.rb +10 -25
  18. data/lib/bosh/workspace/project_deployment.rb +77 -0
  19. data/lib/bosh/workspace/release.rb +41 -33
  20. data/lib/bosh/workspace/stemcell.rb +23 -0
  21. data/lib/bosh/workspace/stub_file.rb +44 -0
  22. data/lib/bosh/workspace/version.rb +1 -1
  23. data/spec/assets/dns/job-properties.yml +22 -0
  24. data/spec/assets/dns/jobs.yml +18 -0
  25. data/spec/assets/dns/networks-manual.yml +19 -0
  26. data/spec/assets/dns/networks-no-manual.yml +18 -0
  27. data/spec/assets/dns/properties.yml +29 -0
  28. data/spec/assets/foo-boshrelease-repo.zip +0 -0
  29. data/spec/commands/prepare_spec.rb +99 -0
  30. data/spec/commands/{command_make_manifest_spec.rb → project_deployment_spec.rb} +4 -23
  31. data/spec/helpers/dns_helper_spec.rb +59 -0
  32. data/spec/helpers/project_deployment_helper_spec.rb +24 -23
  33. data/spec/helpers/release_helper_spec.rb +76 -0
  34. data/spec/helpers/spiff_helper_spec.rb +2 -2
  35. data/spec/helpers/stemcell_helper_spec.rb +89 -0
  36. data/spec/manifest_builder_spec.rb +24 -45
  37. data/spec/project_deployment_spec.rb +157 -0
  38. data/spec/release_spec.rb +39 -18
  39. data/spec/spec_helper.rb +9 -3
  40. data/spec/stemcell_spec.rb +28 -0
  41. data/spec/stub_file_spec.rb +74 -0
  42. metadata +90 -22
  43. data/lib/bosh/workspace/deployment_manifest.rb +0 -67
  44. data/lib/bosh/workspace/release_manager.rb +0 -14
  45. data/spec/deployment_manifest_spec.rb +0 -93
  46. data/spec/release_manager_spec.rb +0 -17
@@ -1,4 +1,5 @@
1
- # Copyright (c) 2012-2013 Stark & Wayne, LLC
1
+ require "codeclimate-test-reporter"
2
+ CodeClimate::TestReporter.start
2
3
 
3
4
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
4
5
 
@@ -61,8 +62,8 @@ def in_home_dir(&block)
61
62
  FileUtils.chdir(home_file, &block)
62
63
  end
63
64
 
64
- def get_tmp_file_path(content)
65
- tmp_file = File.open(File.join(Dir.mktmpdir, "tmp"), "w")
65
+ def get_tmp_file_path(content, file_name="tmp")
66
+ tmp_file = File.open(File.join(Dir.mktmpdir, file_name), "w")
66
67
  tmp_file.write(content)
67
68
  tmp_file.close
68
69
  tmp_file.path
@@ -73,6 +74,11 @@ def asset_dir(*path)
73
74
  File.join(assets_dir, *path)
74
75
  end
75
76
 
77
+ def asset_file(*path)
78
+ assets_file = File.expand_path("../assets", __FILE__)
79
+ IO.read(File.join(assets_file, *path))
80
+ end
81
+
76
82
  def extracted_asset_dir(name, *path)
77
83
  zipped_file = asset_dir(*path)
78
84
  target_dir = File.expand_path("../../tmp/#{name}", __FILE__)
@@ -0,0 +1,28 @@
1
+ describe Bosh::Workspace::Stemcell do
2
+ subject { Bosh::Workspace::Stemcell.new(stemcell, stemcells_dir) }
3
+ let(:stemcells_dir) { ".stemcells" }
4
+ let(:stemcell) { { "name" => name, "version" => version } }
5
+ let(:name) { "bosh-warden-boshlite-ubuntu-trusty-go_agent" }
6
+ let(:file_name) { "bosh-stemcell-3-warden-boshlite-ubuntu-trusty-go_agent.tgz" }
7
+ let(:version) { 3 }
8
+
9
+ describe "#name_version" do
10
+ its(:name_version) { should eq "#{name}/#{version}" }
11
+ end
12
+
13
+ describe "#file_name" do
14
+ its(:file_name) { should eq file_name }
15
+ end
16
+
17
+ describe "#downloaded?" do
18
+ before { File.should_receive(:exists?).with(/\/#{file_name}/).and_return(true) }
19
+ its(:downloaded?) { should eq true }
20
+ end
21
+
22
+ describe "attr readers" do
23
+ let(:file) { "#{stemcells_dir}/#{file_name}" }
24
+ %w(name version file).each do |attr|
25
+ its(attr.to_sym) { should eq eval(attr) }
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,74 @@
1
+ describe Bosh::Workspace::StubFile do
2
+ let(:project_deployment) { instance_double("Bosh::Workspace::ProjectDeployment",
3
+ name: "bar",
4
+ director_uuid: "foo-bar-uuid",
5
+ stemcells: stemcells,
6
+ releases: [ { "name" => "foo", "version" => "latest", "git" => "release_repo.git" } ],
7
+ templates: ["foo.yml"],
8
+ meta: meta,
9
+ merged_file: ".deployments/foo.yml")
10
+ }
11
+ let(:meta) {{ "foo" => "bar" }}
12
+ let(:stemcells) { [ { "name" => "foo", "version" => "2"} ] }
13
+ let(:path) { "foo/.stubs/bar.yml"}
14
+
15
+ let(:stub_file) { Bosh::Workspace::StubFile.new(project_deployment) }
16
+ subject { stub_file }
17
+
18
+ describe ".create" do
19
+ let(:stub_file) { instance_double("Bosh::Workspace::StubFile") }
20
+ subject { Bosh::Workspace::StubFile.create(path, project_deployment) }
21
+
22
+ it "calls write" do
23
+ Bosh::Workspace::StubFile.should_receive(:new)
24
+ .with(project_deployment).and_return(stub_file)
25
+ stub_file.should_receive(:write).with(path)
26
+ subject
27
+ end
28
+ end
29
+
30
+ describe "#write" do
31
+ it "writes yaml content" do
32
+ IO.should_receive(:write).with(path, /---\n/)
33
+ subject.write(path)
34
+ end
35
+ end
36
+
37
+ describe "#content" do
38
+ subject { stub_file.content }
39
+ its(["name"]) { should eq project_deployment.name }
40
+ its(["director_uuid"]) { should eq project_deployment.director_uuid }
41
+ its(["releases"]) { should be_a(Array) }
42
+ its(["meta"]) { should be_a(Hash) }
43
+ end
44
+
45
+ describe "#releases" do
46
+ it "filters disallowed keys" do
47
+ expect(subject.releases.first).to_not include "git" => "release_repo.git"
48
+ expect(subject.releases.first).to include "name" => "foo", "version" => "latest"
49
+ end
50
+ end
51
+
52
+ describe "#meta" do
53
+ let(:stemcell_foo) { { "name" => "foo", "version" => "2" } }
54
+ let(:stemcell_bar) { { "name" => "bar", "version" => "3" } }
55
+
56
+ context "1 stemcell" do
57
+ let(:stemcells) { [ stemcell_foo ] }
58
+ its(:meta) { should include "stemcell" => stemcell_foo }
59
+ its(:meta) { should include meta }
60
+ end
61
+
62
+ context "multiple stemcells" do
63
+ let(:stemcells) { [ stemcell_foo, stemcell_bar ] }
64
+ its(:meta) { should include "stemcells" => [ stemcell_foo, stemcell_bar ] }
65
+ its(:meta) { should include meta }
66
+ end
67
+
68
+ context "meta already containing stemcell" do
69
+ let(:meta) { { "stemcell" => stemcell_bar } }
70
+ let(:stemcells) { [ stemcell_foo ] }
71
+ its(:meta) { should include "stemcell" => stemcell_bar }
72
+ end
73
+ end
74
+ end
metadata CHANGED
@@ -1,29 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh-workspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Koster
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-13 00:00:00.000000000 Z
11
+ date: 2014-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_cli
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.1722.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
26
  version: 1.1722.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bosh_common
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1722.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1722.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: semi_semantic
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 1.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 1.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: membrane
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.2
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: git
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +86,14 @@ dependencies:
44
86
  requirements:
45
87
  - - ~>
46
88
  - !ruby/object:Gem::Version
47
- version: '1.3'
89
+ version: '1.6'
48
90
  type: :development
49
91
  prerelease: false
50
92
  version_requirements: !ruby/object:Gem::Requirement
51
93
  requirements:
52
94
  - - ~>
53
95
  - !ruby/object:Gem::Version
54
- version: '1.3'
96
+ version: '1.6'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: rspec
57
99
  requirement: !ruby/object:Gem::Requirement
@@ -70,28 +112,28 @@ dependencies:
70
112
  name: rspec-fire
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
- - - ! '>='
115
+ - - '>='
74
116
  - !ruby/object:Gem::Version
75
117
  version: '0'
76
118
  type: :development
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
- - - ! '>='
122
+ - - '>='
81
123
  - !ruby/object:Gem::Version
82
124
  version: '0'
83
125
  - !ruby/object:Gem::Dependency
84
126
  name: rake
85
127
  requirement: !ruby/object:Gem::Requirement
86
128
  requirements:
87
- - - ! '>='
129
+ - - '>='
88
130
  - !ruby/object:Gem::Version
89
131
  version: '0'
90
132
  type: :development
91
133
  prerelease: false
92
134
  version_requirements: !ruby/object:Gem::Requirement
93
135
  requirements:
94
- - - ! '>='
136
+ - - '>='
95
137
  - !ruby/object:Gem::Version
96
138
  version: '0'
97
139
  - !ruby/object:Gem::Dependency
@@ -119,36 +161,52 @@ files:
119
161
  - .rspec
120
162
  - .ruby-gemset
121
163
  - .ruby-version
164
+ - .travis.yml
122
165
  - Gemfile
123
166
  - Guardfile
124
167
  - LICENSE.txt
125
168
  - README.md
126
169
  - Rakefile
127
170
  - bosh-workspace.gemspec
128
- - lib/bosh/cli/commands/01_make_manifest.rb
171
+ - lib/bosh/cli/commands/prepare.rb
172
+ - lib/bosh/cli/commands/project_deployment.rb
129
173
  - lib/bosh/workspace.rb
130
- - lib/bosh/workspace/deployment_manifest.rb
174
+ - lib/bosh/workspace/helpers/dns_helper.rb
131
175
  - lib/bosh/workspace/helpers/project_deployment_helper.rb
176
+ - lib/bosh/workspace/helpers/release_helper.rb
132
177
  - lib/bosh/workspace/helpers/spiff_helper.rb
178
+ - lib/bosh/workspace/helpers/stemcell_helper.rb
133
179
  - lib/bosh/workspace/manifest_builder.rb
180
+ - lib/bosh/workspace/project_deployment.rb
134
181
  - lib/bosh/workspace/release.rb
135
- - lib/bosh/workspace/release_manager.rb
182
+ - lib/bosh/workspace/stemcell.rb
183
+ - lib/bosh/workspace/stub_file.rb
136
184
  - lib/bosh/workspace/version.rb
137
185
  - spec/assets/bin/spiff
186
+ - spec/assets/dns/job-properties.yml
187
+ - spec/assets/dns/jobs.yml
188
+ - spec/assets/dns/networks-manual.yml
189
+ - spec/assets/dns/networks-no-manual.yml
190
+ - spec/assets/dns/properties.yml
138
191
  - spec/assets/empty-manifests-repo/.keep
139
192
  - spec/assets/foo-boshrelease-repo.zip
140
193
  - spec/assets/manifests-repo/.manifests/foo.yml
141
194
  - spec/assets/manifests-repo/deployments/bar.yml
142
195
  - spec/assets/manifests-repo/deployments/foo.yml
143
196
  - spec/assets/manifests-repo/templates/foo/bar.yml
144
- - spec/commands/command_make_manifest_spec.rb
145
- - spec/deployment_manifest_spec.rb
197
+ - spec/commands/prepare_spec.rb
198
+ - spec/commands/project_deployment_spec.rb
199
+ - spec/helpers/dns_helper_spec.rb
146
200
  - spec/helpers/project_deployment_helper_spec.rb
201
+ - spec/helpers/release_helper_spec.rb
147
202
  - spec/helpers/spiff_helper_spec.rb
203
+ - spec/helpers/stemcell_helper_spec.rb
148
204
  - spec/manifest_builder_spec.rb
149
- - spec/release_manager_spec.rb
205
+ - spec/project_deployment_spec.rb
150
206
  - spec/release_spec.rb
151
207
  - spec/spec_helper.rb
208
+ - spec/stemcell_spec.rb
209
+ - spec/stub_file_spec.rb
152
210
  homepage: http://starkandwayne.com
153
211
  licenses:
154
212
  - MIT
@@ -159,33 +217,43 @@ require_paths:
159
217
  - lib
160
218
  required_ruby_version: !ruby/object:Gem::Requirement
161
219
  requirements:
162
- - - ! '>='
220
+ - - '>='
163
221
  - !ruby/object:Gem::Version
164
222
  version: 2.0.0
165
223
  required_rubygems_version: !ruby/object:Gem::Requirement
166
224
  requirements:
167
- - - ! '>='
225
+ - - '>='
168
226
  - !ruby/object:Gem::Version
169
227
  version: '0'
170
228
  requirements: []
171
229
  rubyforge_project:
172
- rubygems_version: 2.1.11
230
+ rubygems_version: 2.2.2
173
231
  signing_key:
174
232
  specification_version: 4
175
233
  summary: Manage your bosh workspace
176
234
  test_files:
177
235
  - spec/assets/bin/spiff
236
+ - spec/assets/dns/job-properties.yml
237
+ - spec/assets/dns/jobs.yml
238
+ - spec/assets/dns/networks-manual.yml
239
+ - spec/assets/dns/networks-no-manual.yml
240
+ - spec/assets/dns/properties.yml
178
241
  - spec/assets/empty-manifests-repo/.keep
179
242
  - spec/assets/foo-boshrelease-repo.zip
180
243
  - spec/assets/manifests-repo/.manifests/foo.yml
181
244
  - spec/assets/manifests-repo/deployments/bar.yml
182
245
  - spec/assets/manifests-repo/deployments/foo.yml
183
246
  - spec/assets/manifests-repo/templates/foo/bar.yml
184
- - spec/commands/command_make_manifest_spec.rb
185
- - spec/deployment_manifest_spec.rb
247
+ - spec/commands/prepare_spec.rb
248
+ - spec/commands/project_deployment_spec.rb
249
+ - spec/helpers/dns_helper_spec.rb
186
250
  - spec/helpers/project_deployment_helper_spec.rb
251
+ - spec/helpers/release_helper_spec.rb
187
252
  - spec/helpers/spiff_helper_spec.rb
253
+ - spec/helpers/stemcell_helper_spec.rb
188
254
  - spec/manifest_builder_spec.rb
189
- - spec/release_manager_spec.rb
255
+ - spec/project_deployment_spec.rb
190
256
  - spec/release_spec.rb
191
257
  - spec/spec_helper.rb
258
+ - spec/stemcell_spec.rb
259
+ - spec/stub_file_spec.rb
@@ -1,67 +0,0 @@
1
- module Bosh::Manifests
2
- class DeploymentManifest
3
- include Bosh::Cli::Validation
4
- attr_writer :director_uuid
5
- attr_reader :file
6
-
7
- def initialize(file)
8
- @file = file
9
- err("Deployment file does not exist: #{file}") unless File.exist? @file
10
- @manifest = Psych.load(File.read(@file))
11
- end
12
-
13
- def perform_validation(options = {})
14
- if @manifest.is_a?(Hash)
15
- unless @manifest.has_key?("name") && @manifest["name"].is_a?(String)
16
- errors << "Manifest should contain a name"
17
- end
18
-
19
- unless @manifest.has_key?("director_uuid") && @manifest["director_uuid"].is_a?(String)
20
- errors << "Manifest should contain a director_uuid"
21
- end
22
-
23
- unless @manifest.has_key?("templates") && @manifest["templates"].is_a?(Array)
24
- errors << "Manifest should contain templates"
25
- end
26
-
27
- unless @manifest.has_key?("releases") && @manifest["releases"].is_a?(Array)
28
- errors << "Manifest should contain releases"
29
- end
30
-
31
- unless @manifest.has_key?("meta") && @manifest["meta"].is_a?(Hash)
32
- errors << "Manifest should contain meta hash"
33
- end
34
- else
35
- errors << "Manifest should be a hash"
36
- end
37
- end
38
-
39
- def director_uuid
40
- @director_uuid || @manifest["director_uuid"]
41
- end
42
-
43
- def merged_file
44
- @merged_file ||= begin
45
- path = File.join(file_dirname, "../.deployments", file_basename)
46
- FileUtils.mkpath File.dirname(path)
47
- File.expand_path path
48
- end
49
- end
50
-
51
- %w[name templates releases meta].each do |var|
52
- define_method var do
53
- @manifest[var]
54
- end
55
- end
56
-
57
- private
58
-
59
- def file_basename
60
- File.basename(@file)
61
- end
62
-
63
- def file_dirname
64
- File.dirname(@file)
65
- end
66
- end
67
- end
@@ -1,14 +0,0 @@
1
- module Bosh::Manifests
2
- class ReleaseManager
3
- def initialize(releases, work_dir)
4
- releases_dir = File.join(work_dir, ".releases")
5
- @releases = releases.map { |r| Release.new(r, releases_dir) }
6
- end
7
-
8
- def update_release_repos
9
- @releases.each do |release|
10
- release.checkout_current_version
11
- end
12
- end
13
- end
14
- end