cf 3.0.1.rc1 → 3.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ require "cf/cli/app/base"
2
+
3
+ module CF::App
4
+ class Events < Base
5
+ desc "Display application events"
6
+ group :apps, :info, :hidden => true
7
+ input :app, :desc => "Application to get the events for",
8
+ :argument => true, :from_given => by_name(:app)
9
+ def events
10
+ app = input[:app]
11
+
12
+ events =
13
+ with_progress("Getting events for #{c(app.name, :name)}") do
14
+ format_events(app.events)
15
+ end
16
+
17
+ line unless quiet?
18
+ table(%w{time instance\ index description exit\ status}, events)
19
+
20
+ end
21
+
22
+ private
23
+
24
+ def sort_events(events)
25
+ events.sort_by { |event| DateTime.parse(event.timestamp) }
26
+ end
27
+
28
+ def format_events(events)
29
+ sort_events(events).map do |event|
30
+ [event.timestamp,
31
+ c(event.instance_index.to_s, :warning),
32
+ event.exit_description,
33
+ format_status(event)]
34
+ end
35
+ end
36
+
37
+ def format_status(event)
38
+ if event.exit_status == 0
39
+ c("Success (#{event.exit_status})", :good)
40
+ else
41
+ c("Failure (#{event.exit_status})", :bad)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -8,11 +8,22 @@ module CF::App
8
8
  :singular => :app, :from_given => by_name(:app)
9
9
  input :debug_mode, :desc => "Debug mode to start in", :aliases => "-d"
10
10
  input :all, :desc => "Restart all applications", :default => false
11
+
12
+ ############# Uncomment to complete 50543607
13
+ #input :command, :desc => "Command to restart application", :default => nil
14
+
11
15
  def restart
12
16
  invoke :stop, :all => input[:all], :apps => input[:apps]
13
17
 
14
18
  line unless quiet?
15
19
 
20
+ input[:apps].each do |app|
21
+ unless input[:command].nil?
22
+ app.command = input[:command]
23
+ end
24
+ app.update!
25
+ end
26
+
16
27
  invoke :start, :all => input[:all], :apps => input[:apps],
17
28
  :debug_mode => input[:debug_mode]
18
29
  end
@@ -1,3 +1,3 @@
1
1
  module CF
2
- VERSION = "3.0.1.rc1".freeze
2
+ VERSION = "3.1.0.rc1".freeze
3
3
  end
@@ -149,7 +149,8 @@ module CFManifests
149
149
  "name" => app.name,
150
150
  "memory" => human_size(app.memory * 1024 * 1024, 0),
151
151
  "instances" => app.total_instances,
152
- "url" => app.url ? app.url.sub(target_base, '${target-base}') : "none",
152
+ "host" => app.host,
153
+ "domain" => app.domain,
153
154
  "path" => path
154
155
  }
155
156
 
@@ -10,7 +10,7 @@ class ManifestsPlugin < CF::App::Base
10
10
 
11
11
 
12
12
  [ :start, :restart, :instances, :logs, :env, :health, :stats,
13
- :scale, :app, :stop, :delete
13
+ :scale, :app, :stop, :delete, :events
14
14
  ].each do |wrap|
15
15
  name_made_optional = change_argument(wrap, :app, :optional)
16
16
 
@@ -0,0 +1,72 @@
1
+ require "spec_helper"
2
+
3
+ module CF
4
+ module App
5
+ describe Events do
6
+ let(:global) { {} }
7
+ let(:given) { {} }
8
+ let(:inputs) { {:app => apps[0]} }
9
+ let(:apps) { [build(:app)] }
10
+
11
+ before do
12
+ inputs[:app].stub(:events) do
13
+ [double("AppEvent", {
14
+ :instance_guid => "some_guid",
15
+ :instance_index => 1,
16
+ :exit_status => -1,
17
+ :exit_description => "Something very interesting",
18
+ :timestamp => "2013-05-15 18:52:17 +0000" }),
19
+ double("AppEvent", {
20
+ :instance_guid => "some_other_guid",
21
+ :instance_index => 0,
22
+ :exit_status => 0,
23
+ :exit_description => "Something less interesting",
24
+ :timestamp => "2013-05-15 18:52:15 +0000" })]
25
+ end
26
+ end
27
+
28
+ subject do
29
+ capture_output { Mothership.new.invoke(:events, inputs, given, global) }
30
+ end
31
+
32
+ describe "metadata" do
33
+ let(:command) { Mothership.commands[:events] }
34
+
35
+ describe "command" do
36
+ subject { command }
37
+ its(:description) { should eq "Display application events" }
38
+ it { expect(Mothership::Help.group(:apps, :info)).to include(subject) }
39
+ end
40
+
41
+ include_examples "inputs must have descriptions"
42
+
43
+ describe "arguments" do
44
+ subject { command.arguments }
45
+ it "has arguments that are not needed with a manifest" do
46
+ should eq([:name => :app, :type => :optional, :value => nil])
47
+ end
48
+ end
49
+ end
50
+
51
+ it "prints out progress" do
52
+ subject
53
+ stdout.rewind
54
+ expect(stdout.readlines.first).to match /Getting events for #{apps.first.name}/
55
+ end
56
+
57
+ it "prints out headers" do
58
+ subject
59
+ stdout.rewind
60
+ expect(stdout.readlines[2]).to match /time\s+instance\s+index\s+description\s+exit\s+status/
61
+ end
62
+
63
+ it "prints out the events in order" do
64
+ subject
65
+ stdout.rewind
66
+ expect(stdout.readlines[3]).to match /.*2013-05-15 18:52:15 \+0000\s+0\s+Something less interesting\s+Success \(0\).*/
67
+ stdout.rewind
68
+ expect(stdout.readlines[4]).to match /.*2013-05-15 18:52:17 \+0000\s+1\s+Something very interesting\s+Failure \(-1\).*/
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,47 @@
1
+ require "spec_helper"
2
+
3
+ module CF
4
+ module App
5
+ describe Restart do
6
+ let(:restart_command) { CF::App::Restart.new(Mothership.commands[:restart]) }
7
+ let(:inputs) { {:apps => [app]} }
8
+ let(:app) { build(:app, :command => "rails s") }
9
+
10
+ before do
11
+ restart_command.input = Mothership::Inputs.new(nil, restart_command, inputs, {}, {})
12
+ app.stub(:update!)
13
+ end
14
+
15
+ it "restarts the application" do
16
+ restart_command.should_receive(:invoke).with(:stop, anything) do
17
+ restart_command.should_receive(:invoke).with(:start, anything)
18
+ end
19
+ restart_command.restart
20
+ end
21
+
22
+ it "does not change the command if we do not pass the command argument" do
23
+ restart_command.stub(:invoke).with(:start, anything)
24
+ restart_command.stub(:invoke).with(:stop, anything)
25
+ restart_command.restart
26
+ app.command.should == "rails s"
27
+ end
28
+
29
+ context "when passing in a new start command" do
30
+ let(:inputs) { {:apps => [app], :command => 'rake db:migrate'} }
31
+
32
+ before do
33
+ restart_command.stub(:invoke).with(:stop, anything)
34
+ restart_command.input = Mothership::Inputs.new(nil, restart_command, inputs, {}, {})
35
+ end
36
+
37
+ it "updates the start command" do
38
+ app.should_receive(:update!) do
39
+ restart_command.should_receive(:invoke).with(:start, anything)
40
+ end
41
+ restart_command.restart
42
+ app.command.should == "rake db:migrate"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -76,7 +76,9 @@ describe CFManifests do
76
76
  its(["memory"]) { should eq "2G" }
77
77
  its(["instances"]) { should eq 2 }
78
78
  its(["path"]) { should eq "some-path" }
79
- its(["url"]) { should eq "some-app-name.${target-base}" }
79
+ #its(["url"]) { should eq "some-app-name.${target-base}" }
80
+ its(["host"]) { should eq "some-app-name" }
81
+ its(["domain"]) { should eq "${target-base}" }
80
82
  its(["command"]) { should eq "ruby main.rb" }
81
83
  its(["buildpack"]) { should eq "git://example.com/foo.git" }
82
84
 
@@ -114,7 +116,8 @@ describe CFManifests do
114
116
  :service_bindings => []
115
117
  }
116
118
 
117
- its(["url"]) { should eq "none" }
119
+ its(["host"]) { should eq "none" }
120
+ its(["domain"]) { should eq "none" }
118
121
  it { should_not include "command" }
119
122
  it { should_not include "services" }
120
123
  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: 3.0.1.rc1
4
+ version: 3.1.0.rc1
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-20 00:00:00.000000000 Z
13
+ date: 2013-06-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -51,7 +51,7 @@ dependencies:
51
51
  requirements:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.2.rc1
54
+ version: 2.2.0.rc1
55
55
  - - <
56
56
  - !ruby/object:Gem::Version
57
57
  version: '3.0'
@@ -62,7 +62,7 @@ dependencies:
62
62
  requirements:
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
- version: 2.1.2.rc1
65
+ version: 2.2.0.rc1
66
66
  - - <
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
@@ -329,6 +329,7 @@ files:
329
329
  - lib/cf/cli/app/delete.rb
330
330
  - lib/cf/cli/app/deprecated.rb
331
331
  - lib/cf/cli/app/env.rb
332
+ - lib/cf/cli/app/events.rb
332
333
  - lib/cf/cli/app/files.rb
333
334
  - lib/cf/cli/app/health.rb
334
335
  - lib/cf/cli/app/instances.rb
@@ -474,11 +475,13 @@ files:
474
475
  - spec/assets/rails328_ruby187_app/test/test_helper.rb
475
476
  - spec/cf/cli/app/base_spec.rb
476
477
  - spec/cf/cli/app/delete_spec.rb
478
+ - spec/cf/cli/app/events_spec.rb
477
479
  - spec/cf/cli/app/instances_spec.rb
478
480
  - spec/cf/cli/app/push/create_spec.rb
479
481
  - spec/cf/cli/app/push/interactions_spec.rb
480
482
  - spec/cf/cli/app/push_spec.rb
481
483
  - spec/cf/cli/app/rename_spec.rb
484
+ - spec/cf/cli/app/restart_spec.rb
482
485
  - spec/cf/cli/app/scale_spec.rb
483
486
  - spec/cf/cli/app/start_spec.rb
484
487
  - spec/cf/cli/app/stats_spec.rb
@@ -566,9 +569,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
566
569
  - - ! '>='
567
570
  - !ruby/object:Gem::Version
568
571
  version: '0'
569
- segments:
570
- - 0
571
- hash: 428685765814888758
572
572
  required_rubygems_version: !ruby/object:Gem::Requirement
573
573
  none: false
574
574
  requirements:
@@ -577,7 +577,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
577
577
  version: 1.3.1
578
578
  requirements: []
579
579
  rubyforge_project: cf
580
- rubygems_version: 1.8.25
580
+ rubygems_version: 1.8.24
581
581
  signing_key:
582
582
  specification_version: 3
583
583
  summary: Friendly command-line interface for Cloud Foundry.
@@ -637,11 +637,13 @@ test_files:
637
637
  - spec/assets/rails328_ruby187_app/test/test_helper.rb
638
638
  - spec/cf/cli/app/base_spec.rb
639
639
  - spec/cf/cli/app/delete_spec.rb
640
+ - spec/cf/cli/app/events_spec.rb
640
641
  - spec/cf/cli/app/instances_spec.rb
641
642
  - spec/cf/cli/app/push/create_spec.rb
642
643
  - spec/cf/cli/app/push/interactions_spec.rb
643
644
  - spec/cf/cli/app/push_spec.rb
644
645
  - spec/cf/cli/app/rename_spec.rb
646
+ - spec/cf/cli/app/restart_spec.rb
645
647
  - spec/cf/cli/app/scale_spec.rb
646
648
  - spec/cf/cli/app/start_spec.rb
647
649
  - spec/cf/cli/app/stats_spec.rb