cf 4.2.4 → 4.2.5

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.
data/lib/cf.rb CHANGED
@@ -9,8 +9,8 @@ Dir[File.expand_path(command_files, __FILE__)].each do |file|
9
9
  require file unless File.basename(file) == 'base.rb'
10
10
  end
11
11
 
12
+ require "manifests/plugin"
12
13
  require "admin/plugin"
13
14
  require "console/plugin"
14
15
  require "tunnel/plugin"
15
- require "manifests/plugin"
16
16
  require "micro/plugin"
data/lib/cf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CF
2
- VERSION = "4.2.4".freeze
2
+ VERSION = "4.2.5".freeze
3
3
  end
@@ -22,6 +22,8 @@ module CFConsolePlugin
22
22
  console.start_console
23
23
  end
24
24
 
25
+ ::ManifestsPlugin.default_to_app_from_manifest :console, true
26
+
25
27
  filter(:start, :start_app) do |app|
26
28
  app.console = true
27
29
  app
@@ -5,23 +5,21 @@ require "manifests/manifests"
5
5
  class ManifestsPlugin < CF::App::Base
6
6
  include CFManifests
7
7
 
8
- option :manifest, :aliases => "-m", :value => :file,
9
- :desc => "Path to manifest file to use"
8
+ def self.default_to_app_from_manifest(command, fail_without_app)
9
+ name_made_optional = change_argument(command, :app, :optional)
10
+ around(command) do |cmd, input|
11
+ wrap_with_optional_name(name_made_optional, cmd, input, fail_without_app)
12
+ end
13
+ end
10
14
 
15
+ option :manifest, :aliases => "-m", :value => :file, :desc => "Path to manifest file to use"
11
16
 
12
- [ :start, :restart, :instances, :logs, :env, :health, :stats,
13
- :scale, :app, :stop, :delete, :events
14
- ].each do |wrap|
15
- name_made_optional = change_argument(wrap, :app, :optional)
16
17
 
17
- around(wrap) do |cmd, input|
18
- wrap_with_optional_name(name_made_optional, cmd, input)
19
- end
18
+ [:start, :restart, :instances, :logs, :env, :health, :stats, :scale, :app, :stop, :delete, :events].each do |command|
19
+ ::ManifestsPlugin.default_to_app_from_manifest command, true
20
20
  end
21
21
 
22
-
23
- add_input :push, :reset, :desc => "Reset to values in the manifest",
24
- :default => false
22
+ add_input :push, :reset, :desc => "Reset to values in the manifest", :default => false
25
23
 
26
24
  around(:push) do |push, input|
27
25
  wrap_push(push, input)
@@ -29,12 +27,12 @@ class ManifestsPlugin < CF::App::Base
29
27
 
30
28
  private
31
29
 
32
- def wrap_with_optional_name(name_made_optional, cmd, input)
30
+ def wrap_with_optional_name(name_made_optional, cmd, input, fail_without_app)
33
31
  return cmd.call if input[:all]
34
32
 
35
33
  unless manifest
36
34
  # if the command knows how to handle this
37
- if input.has?(:app) || !name_made_optional
35
+ if input.has?(:app) || !name_made_optional || !fail_without_app
38
36
  return cmd.call
39
37
  else
40
38
  return no_apps
@@ -55,7 +53,7 @@ class ManifestsPlugin < CF::App::Base
55
53
  internal = internal.collect { |app| app[:name] }
56
54
 
57
55
  apps = internal + external
58
- return no_apps if apps.empty?
56
+ return no_apps if fail_without_app && apps.empty?
59
57
 
60
58
  apps.each.with_index do |app, num|
61
59
  line unless quiet? || num == 0
@@ -18,11 +18,27 @@ describe ManifestsPlugin do
18
18
  plugin.stub(:client) { client }
19
19
  end
20
20
 
21
+ describe ".use_manifest_for_app_input" do
22
+ it "makes the app argument optional and wraps it in an around that gets the app from the manifest" do
23
+ command = described_class.commands[:app]
24
+ command.instance_variable_set(:@arguments, [{:name => :app, :type => :required, :value => nil}])
25
+
26
+ expect(command.arguments).to eq [{:name => :app, :type => :required, :value => nil}]
27
+ expect(command.around.size).to eq 1
28
+
29
+ described_class.default_to_app_from_manifest :app, false
30
+
31
+ expect(command.arguments).to eq [{:name => :app, :type => :optional, :value => nil}]
32
+ expect(command.around.size).to eq 2
33
+ end
34
+ end
35
+
21
36
  describe "#wrap_with_optional_name" do
22
37
  let(:name_made_optional) { true }
38
+ let(:fail_without_app) { true }
23
39
  let(:wrapped) { double(:wrapped).as_null_object }
24
40
 
25
- subject { plugin.send(:wrap_with_optional_name, name_made_optional, wrapped, inputs) }
41
+ subject { plugin.send(:wrap_with_optional_name, name_made_optional, wrapped, inputs, fail_without_app) }
26
42
 
27
43
  context "when --all is given" do
28
44
  let(:inputs_hash) { { :all => true } }
@@ -55,6 +71,14 @@ describe ManifestsPlugin do
55
71
  plugin.should_receive(:no_apps)
56
72
  subject
57
73
  end
74
+
75
+ context "when it is not supposed to fail" do
76
+ let(:fail_without_app) { false }
77
+ it "doesnt fail" do
78
+ plugin.should_not_receive(:no_apps)
79
+ subject
80
+ end
81
+ end
58
82
  end
59
83
 
60
84
  context "and we did NOT make it optional" do
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.4
4
+ version: 4.2.5
5
5
  prerelease:
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-07-18 00:00:00.000000000 Z
13
+ date: 2013-07-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -429,7 +429,6 @@ files:
429
429
  - lib/manifests/loader.rb
430
430
  - lib/manifests/manifests.rb
431
431
  - lib/manifests/plugin.rb
432
- - lib/manifests/README.md
433
432
  - lib/micro/errors.rb
434
433
  - lib/micro/micro.rb
435
434
  - lib/micro/plugin.rb
@@ -614,7 +613,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
614
613
  version: '0'
615
614
  segments:
616
615
  - 0
617
- hash: -1109668810208652656
616
+ hash: -2757679513979336961
618
617
  required_rubygems_version: !ruby/object:Gem::Requirement
619
618
  none: false
620
619
  requirements:
@@ -623,7 +622,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
623
622
  version: '0'
624
623
  segments:
625
624
  - 0
626
- hash: -1109668810208652656
625
+ hash: -2757679513979336961
627
626
  requirements: []
628
627
  rubyforge_project: cf
629
628
  rubygems_version: 1.8.25
@@ -1,13 +0,0 @@
1
- [![Build Status](https://travis-ci.org/cloudfoundry/manifests-cf-plugin.png)](https://travis-ci.org/cloudfoundry/manifests-cf-plugin)
2
- [![Gem Version](https://badge.fury.io/rb/manifests-cf-plugin.png)](http://badge.fury.io/rb/manifests-cf-plugin)
3
- [![Code Climate](https://codeclimate.com/github/cloudfoundry/manifests-cf-plugin.png)](https://codeclimate.com/github/cloudfoundry/manifests-cf-plugin)
4
-
5
- ## Manifests
6
- ### Info
7
- With this plugin enabled, any configuration changes you make using the CF `start`, `restart`, `instances`, `logs`, `env`, `health`, `stats`, `scale`, and `app` commands will be saved to a file called *manifest.yml*.
8
-
9
- ### Installation
10
- ```
11
- gem install manifests-cf-plugin
12
- ```
13
-