cf 4.2.9.rc3 → 4.2.9.rc5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c55cc0d0ff989f6e5afc8b9404527c74f0390644
4
- data.tar.gz: 6f896df4b514a8e2827aed83b7687b670233078a
3
+ metadata.gz: e4e2f3033d9d821a41f9ddc7f2dbeab8de538317
4
+ data.tar.gz: b6aa6ef1017ce73a108cac2dcf560a443c82882c
5
5
  SHA512:
6
- metadata.gz: ac80ed0d9c5a7eef372b9f6e25dfcae8920fff2612582331ac83726ab586dcec5269bd48e872dd4bfe686b6f9584940c88df936703063ff9e2d00ffe92f3640f
7
- data.tar.gz: 9f040edd92bfc646f5897b418aa365fc6037ad549ad82ebd9068226bfe09cef3db7e78e87131ce4ab2cf941a64a12a6edbf1ae94be6d47459253fd48e6d3ea92
6
+ metadata.gz: 5df73a8dd292d078af3679f56f1729415af83706513028997a7d9264fbef9dda9c96feae5422e1e138a93879e87621258a3128acd59b7574e7a9bff0f74d7329
7
+ data.tar.gz: 26a10354a3e832f2a395c18f2f7d090d09675ac648bd298e56220157f7aaf53308163611d74f6d856225bc3a1712a62bf8b7d332e684ff122fa27e7e283ecbfc
@@ -72,7 +72,8 @@ module CF::Service
72
72
  service_instance.name = input[:name, offering]
73
73
  finalize
74
74
 
75
- service_instance.credentials = ask_credentials # input[:credentials]
75
+ # at this point there's no way input[:credentials] can work interactively...
76
+ service_instance.credentials = input[:credentials, nil] || ask_credentials
76
77
  else
77
78
  service_instance = client.managed_service_instance
78
79
  service_instance.name = input[:name, offering]
data/lib/cf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CF
2
- VERSION = "4.2.9.rc3".freeze
2
+ VERSION = "4.2.9.rc5".freeze
3
3
  end
@@ -1,5 +1,6 @@
1
1
  require "yaml"
2
2
  require "set"
3
+ require "cf/cli/service/create"
3
4
 
4
5
  require "manifests/loader"
5
6
 
@@ -182,16 +183,23 @@ module CFManifests
182
183
  unless services.empty?
183
184
  meta["services"] = {}
184
185
 
185
- services.each do |i|
186
- p = i.service_plan
187
- s = p.service
188
-
189
- meta["services"][i.name] = {
190
- "label" => s.label,
191
- "provider" => s.provider,
192
- "version" => s.version,
193
- "plan" => p.name
194
- }
186
+ services.each do |service_instance|
187
+ if service_instance.is_a?(CFoundry::V2::UserProvidedServiceInstance)
188
+ meta["services"][service_instance.name] = {
189
+ "label" => "user-provided",
190
+ "credentials" => service_instance.credentials.stringify_keys,
191
+ }
192
+ else
193
+ service_plan = service_instance.service_plan
194
+ service = service_plan.service
195
+
196
+ meta["services"][service_instance.name] = {
197
+ "label" => service.label,
198
+ "provider" => service.provider,
199
+ "version" => service.version,
200
+ "plan" => service_plan.name
201
+ }
202
+ end
195
203
  end
196
204
  end
197
205
 
@@ -292,25 +300,33 @@ module CFManifests
292
300
  if instance = client.service_instance_by_name(name)
293
301
  to_bind << instance
294
302
  else
295
- offering = offerings.find { |o|
296
- o.label == (svc[:label] || svc[:type] || svc[:vendor]) &&
297
- (!svc[:version] || o.version == svc[:version]) &&
298
- (o.provider == (svc[:provider] || "core"))
299
- }
303
+ if svc[:label] == "user-provided"
304
+ invoke :create_service,
305
+ name: name,
306
+ offering: CF::Service::UPDummy.new,
307
+ app: app,
308
+ credentials: svc[:credentials]
309
+ else
310
+ offering = offerings.find { |o|
311
+ o.label == (svc[:label] || svc[:type] || svc[:vendor]) &&
312
+ (!svc[:version] || o.version == svc[:version]) &&
313
+ (o.provider == (svc[:provider] || "core"))
314
+ }
300
315
 
301
- fail "Unknown service offering: #{svc.inspect}." unless offering
316
+ fail "Unknown service offering: #{svc.inspect}." unless offering
302
317
 
303
- plan = offering.service_plans.find { |p|
304
- p.name == (svc[:plan] || "D100")
305
- }
318
+ plan = offering.service_plans.find { |p|
319
+ p.name == (svc[:plan] || "D100")
320
+ }
306
321
 
307
- fail "Unknown service plan: #{svc[:plan]}." unless plan
322
+ fail "Unknown service plan: #{svc[:plan]}." unless plan
308
323
 
309
- invoke :create_service,
310
- :name => name,
311
- :offering => offering,
312
- :plan => plan,
313
- :app => app
324
+ invoke :create_service,
325
+ :name => name,
326
+ :offering => offering,
327
+ :plan => plan,
328
+ :app => app
329
+ end
314
330
  end
315
331
  end
316
332
 
@@ -10,7 +10,7 @@ namespace :gem do
10
10
  sh! "git add lib/cf/version.rb"
11
11
 
12
12
  print_with_purpose "Bumping to version #{gem_version}"
13
- #generate_release_notes(old_version)
13
+ generate_release_notes(old_version)
14
14
  sh!("git commit -m 'Bumping to version #{gem_version}.'")
15
15
  sh!("git push")
16
16
  sh!("gem release --tag")
@@ -20,8 +20,8 @@ namespace :gem do
20
20
  def generate_release_notes(old_version)
21
21
  print_with_purpose "Generating release notes..."
22
22
  file_name = "release_#{gem_version}"
23
- sh!("anchorman notes --name=#{file_name} --from=v#{old_version}")
24
- sh!("git add release_notes")
23
+ #sh!("anchorman notes --name=#{file_name} --from=v#{old_version}")
24
+ #sh!("git add release_notes")
25
25
  end
26
26
 
27
27
  def sh!(cmd)
@@ -0,0 +1,17 @@
1
+ ---
2
+ applications:
3
+ - name: hello-sinatra-1375741878_010056
4
+ memory: 256M
5
+ instances: 1
6
+ host: hello-sinatra-subdomain-1375741878_010056
7
+ domain: a1-app.cf-app.com
8
+ path: .
9
+ services:
10
+ user-provided-1375741878_010056:
11
+ label: user-provided
12
+ credentials:
13
+ username: abc123
14
+ password: sunshine
15
+ hostname: oracle.enterprise.com
16
+ port: 1234
17
+ name: myoracledb2
@@ -124,6 +124,23 @@ module CF
124
124
  instance.credentials['host'].should == 'example.com'
125
125
  instance.credentials['port'].should == '8080'
126
126
  end
127
+
128
+ # lame, i know
129
+ context "when invoked from another command" do
130
+ let(:params) { {
131
+ :credentials => {"k" => "v"},
132
+ :name => "service-name",
133
+ :offering => UPDummy.new,
134
+ } }
135
+
136
+ it "creates a user-provided service" do
137
+ instance = client.user_provided_service_instance
138
+ client.should_receive(:user_provided_service_instance).and_return(instance)
139
+ instance.should_receive(:create!)
140
+
141
+ Mothership.new.invoke(:create_service, params, {})
142
+ end
143
+ end
127
144
  end
128
145
  end
129
146
  end
@@ -0,0 +1,86 @@
1
+ require "spec_helper"
2
+ require "webmock/rspec"
3
+
4
+ if ENV["CF_V2_RUN_INTEGRATION"]
5
+ describe "A user pushing a new sinatra app" do
6
+
7
+ let(:run_id) { TRAVIS_BUILD_ID.to_s + Time.new.to_f.to_s.gsub(".", "_") }
8
+ let(:app) { "hello-sinatra-#{run_id}" }
9
+ let(:subdomain) { "hello-sinatra-subdomain-#{run_id}" }
10
+ let(:user_provided_name) { "user-provided-#{run_id}"}
11
+
12
+ before do
13
+ FileUtils.rm_rf File.expand_path(CF::CONFIG_DIR)
14
+ WebMock.allow_net_connect!
15
+ login
16
+ end
17
+
18
+ after do
19
+ `#{cf_bin} unbind-service -f --no-script #{user_provided_name} #{app}`
20
+ `#{cf_bin} delete-service -f --no-script #{user_provided_name}`
21
+
22
+ `#{cf_bin} delete #{app} -f --routes --no-script`
23
+ logout
24
+ end
25
+
26
+ context "with user-provided service" do
27
+ it "reads the manifest when pushing" do
28
+ Dir.chdir("#{SPEC_ROOT}/assets/hello-sinatra") do
29
+ FileUtils.rm("manifest.yml", force: true)
30
+ File.open("manifest.yml", "w") do |f|
31
+ f.write(<<-MANIFEST)
32
+ ---
33
+ applications:
34
+ - name: #{app}
35
+ memory: 256M
36
+ instances: 1
37
+ host: #{subdomain}
38
+ domain: a1-app.cf-app.com
39
+ path: .
40
+ services:
41
+ #{user_provided_name}:
42
+ label: user-provided
43
+ credentials:
44
+ username: abc123
45
+ password: sunshine
46
+ hostname: oracle.enterprise.com
47
+ port: 1234
48
+ name: myoracledb2
49
+ MANIFEST
50
+ end
51
+
52
+ BlueShell::Runner.run("#{cf_bin} push") do |runner|
53
+ expect(runner).to say "Using manifest file manifest.yml"
54
+ expect(runner).to say "Creating #{app}... OK"
55
+
56
+ expect(runner).to say(/Creating route #{subdomain}\..*\.\.\. OK/)
57
+ expect(runner).to say(/Binding #{subdomain}\..* to #{app}\.\.\. OK/)
58
+
59
+ expect(runner).to say /Creating service #{user_provided_name}.*OK/
60
+ expect(runner).to say /Binding #{user_provided_name} to #{app}... OK/
61
+
62
+ expect(runner).to say "Uploading #{app}... OK", 180
63
+ expect(runner).to say "Preparing to start #{app}... OK", 180
64
+ expect(runner).to say "Checking status of app '#{app}'...", 180
65
+ expect(runner).to say "1 of 1 instances running"
66
+ expect(runner).to say "Push successful! App '#{app}' available at http://#{subdomain}.a1-app.cf-app.com", 30
67
+ end
68
+ end
69
+
70
+ BlueShell::Runner.run("#{cf_bin} services") do |runner|
71
+ expect(runner).to say /name\s+service\s+provider\s+version\s+plan\s+bound apps/
72
+ expect(runner).to say /#{user_provided_name}\s+ # name
73
+ user-provided\s+ # service
74
+ n\/a\s+ # provider
75
+ n\/a\s+ # version
76
+ n\/a\s+ # plan
77
+ #{app} # bound apps
78
+ /x
79
+ end
80
+ end
81
+ end
82
+
83
+ end
84
+ else
85
+ $stderr.puts 'Skipping v2 integration specs; please provide necessary environment variables'
86
+ end
@@ -21,6 +21,10 @@ if ENV["CF_V2_RUN_INTEGRATION"]
21
21
  after do
22
22
  `#{cf_bin} unbind-service -f --no-script #{service_name} #{app}`
23
23
  `#{cf_bin} delete-service -f --no-script #{service_name}`
24
+
25
+ `#{cf_bin} unbind-service -f --no-script #{user_provided_name} #{app}`
26
+ `#{cf_bin} delete-service -f --no-script #{user_provided_name}`
27
+
24
28
  `#{cf_bin} delete #{app} -f --routes --no-script`
25
29
  logout
26
30
  Interact::Progress::Dots.stop!
@@ -71,7 +71,23 @@ describe CFManifests do
71
71
  build(
72
72
  :service_plan,
73
73
  :name => "P200",
74
- :service => build(:service))))
74
+ :service => build(:service,
75
+ label: "managed",
76
+ provider: "hamazon",
77
+ version: "v3"
78
+ )
79
+ )
80
+ )
81
+ ),
82
+ build(
83
+ :service_binding,
84
+ :service_instance =>
85
+ build(
86
+ :user_provided_service_instance,
87
+ :name => "service-2",
88
+ :credentials => { uri: "mysql://example.com" }
89
+ )
90
+ )
75
91
  ]
76
92
  end
77
93
 
@@ -87,28 +103,18 @@ describe CFManifests do
87
103
  its(["buildpack"]) { should eq "git://example.com/foo.git" }
88
104
 
89
105
  it "contains the service information" do
90
- expect(subject["services"]).to be_a Hash
91
-
92
- services = subject["services"]
93
- app.service_bindings.each do |b|
94
- service = b.service_instance
95
-
96
- expect(services).to include service.name
97
-
98
- info = services[service.name]
99
-
100
- plan = service.service_plan
101
- offering = plan.service
102
-
103
- {"plan" => plan.name,
104
- "label" => offering.label,
105
- "provider" => offering.provider,
106
- "version" => offering.version
107
- }.each do |attr, val|
108
- expect(info).to include attr
109
- expect(info[attr]).to eq val
110
- end
111
- end
106
+ expect(subject["services"]).to eq(
107
+ "service-1" => {
108
+ "plan" => "P200",
109
+ "label" => "managed",
110
+ "provider" => "hamazon",
111
+ "version" => "v3",
112
+ },
113
+ "service-2" => {
114
+ "credentials" => {"uri" => "mysql://example.com"},
115
+ "label" => "user-provided"
116
+ },
117
+ )
112
118
  end
113
119
 
114
120
  context "with only minimum configuration" do
@@ -135,6 +141,21 @@ describe CFManifests do
135
141
  dont_allow_ask(anything, anything)
136
142
  end
137
143
 
144
+ context "when user-provided services are defined in the manifest" do
145
+ let(:client) do
146
+ build(:client).tap { |client| client.stub(:services => [], :service_instances => []) }
147
+ end
148
+
149
+ let(:info) { {:services => {'moracle' => {:label => "user-provided", :credentials =>{"k" => "v"}}}}}
150
+
151
+ it "creates the service with label user-provided" do
152
+ cmd.should_receive(:invoke).with(:create_service,
153
+ :name => 'moracle', :offering => has_label("user-provided"), :app => app, :credentials => {"k" => "v"}
154
+ )
155
+ cmd.send("setup_services", app, info)
156
+ end
157
+ end
158
+
138
159
  context "when services are defined in the manifest" do
139
160
  let(:info) do
140
161
  {:services => {"service-1" => {:label => "mysql", :plan => "100"}}}
@@ -1,5 +1,16 @@
1
- RSpec::Matchers.define :has_label do |expected|
2
- match do |actual|
3
- actual.label == expected
1
+ class HasLabelMatcher
2
+ def initialize(expected_label)
3
+ @expected = expected_label
4
4
  end
5
+ def failure_message_for_should
6
+ "#{actual} does not have label #{@expected}"
7
+ end
8
+ def ==(actual)
9
+ actual.label == @expected
10
+ end
11
+ alias_method :matches?, :==
12
+ end
13
+
14
+ def has_label(expected_label)
15
+ HasLabelMatcher.new(expected_label)
5
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.9.rc3
4
+ version: 4.2.9.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloud Foundry Team
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-02 00:00:00.000000000 Z
12
+ date: 2013-08-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -406,6 +406,7 @@ files:
406
406
  - spec/assets/hello-sinatra/Gemfile
407
407
  - spec/assets/hello-sinatra/Gemfile.lock
408
408
  - spec/assets/hello-sinatra/main.rb
409
+ - spec/assets/hello-sinatra/manifest.yml
409
410
  - spec/assets/rails328_ruby187_app/app/assets/images/rails.png
410
411
  - spec/assets/rails328_ruby187_app/app/assets/javascripts/application.js
411
412
  - spec/assets/rails328_ruby187_app/app/assets/stylesheets/application.css
@@ -528,6 +529,7 @@ files:
528
529
  - spec/features/account_lifecycle_spec.rb
529
530
  - spec/features/create_user_spec.rb
530
531
  - spec/features/login_spec.rb
532
+ - spec/features/manifests_spec.rb
531
533
  - spec/features/org_spec.rb
532
534
  - spec/features/services_spec.rb
533
535
  - spec/features/space_spec.rb
@@ -588,6 +590,7 @@ test_files:
588
590
  - spec/assets/hello-sinatra/Gemfile
589
591
  - spec/assets/hello-sinatra/Gemfile.lock
590
592
  - spec/assets/hello-sinatra/main.rb
593
+ - spec/assets/hello-sinatra/manifest.yml
591
594
  - spec/assets/rails328_ruby187_app/app/assets/images/rails.png
592
595
  - spec/assets/rails328_ruby187_app/app/assets/javascripts/application.js
593
596
  - spec/assets/rails328_ruby187_app/app/assets/stylesheets/application.css
@@ -710,6 +713,7 @@ test_files:
710
713
  - spec/features/account_lifecycle_spec.rb
711
714
  - spec/features/create_user_spec.rb
712
715
  - spec/features/login_spec.rb
716
+ - spec/features/manifests_spec.rb
713
717
  - spec/features/org_spec.rb
714
718
  - spec/features/services_spec.rb
715
719
  - spec/features/space_spec.rb