cf 4.2.9.rc5 → 4.2.10.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. data/lib/cf/cli.rb +3 -6
  2. data/lib/cf/cli/app/env.rb +3 -3
  3. data/lib/cf/cli/app/events.rb +1 -1
  4. data/lib/cf/cli/app/files.rb +3 -3
  5. data/lib/cf/cli/app/health.rb +1 -1
  6. data/lib/cf/cli/app/instances.rb +1 -1
  7. data/lib/cf/cli/app/logs.rb +2 -2
  8. data/lib/cf/cli/app/rename.rb +1 -1
  9. data/lib/cf/cli/app/scale.rb +1 -1
  10. data/lib/cf/cli/app/stats.rb +1 -1
  11. data/lib/cf/cli/organization/rename.rb +1 -1
  12. data/lib/cf/cli/route/map.rb +1 -1
  13. data/lib/cf/cli/route/unmap.rb +1 -1
  14. data/lib/cf/cli/service/create.rb +20 -69
  15. data/lib/cf/cli/service/delete.rb +1 -1
  16. data/lib/cf/cli/service/rename.rb +1 -1
  17. data/lib/cf/cli/service/services.rb +32 -12
  18. data/lib/cf/cli/space/rename.rb +1 -1
  19. data/lib/cf/cli/space/switch.rb +1 -1
  20. data/lib/cf/cli/start/colors.rb +1 -1
  21. data/lib/cf/cli/start/targets.rb +1 -1
  22. data/lib/cf/cli/user/create.rb +1 -1
  23. data/lib/cf/cli/user/passwd.rb +1 -1
  24. data/lib/cf/cli/user/register.rb +1 -1
  25. data/lib/cf/cli/user/users.rb +1 -1
  26. data/lib/cf/version.rb +1 -1
  27. data/lib/manifests/manifests.rb +25 -41
  28. data/lib/tasks/gem_release.rake +2 -2
  29. data/spec/cf/cli/app/delete_spec.rb +2 -2
  30. data/spec/cf/cli/app/push/create_spec.rb +1 -1
  31. data/spec/cf/cli/service/create_spec.rb +4 -52
  32. data/spec/cf/cli/service/rename_spec.rb +1 -1
  33. data/spec/cf/cli/service/services_spec.rb +34 -63
  34. data/spec/cf/cli/space/space_spec.rb +1 -1
  35. data/spec/cf/cli/space/spaces_spec.rb +3 -3
  36. data/spec/factories/cfoundry/v2/{managed_service_instances_factory.rb → service_instances_factory.rb} +2 -2
  37. data/spec/features/services_spec.rb +0 -96
  38. data/spec/integration/push_flow_spec.rb +1 -26
  39. data/spec/manifests/manifests_spec.rb +25 -46
  40. data/spec/support/features_helper.rb +3 -36
  41. data/spec/support/matchers.rb +3 -14
  42. metadata +66 -24
  43. checksums.yaml +0 -7
  44. data/lib/cf/cli/service/service_instance_helper.rb +0 -99
  45. data/spec/assets/env/Gemfile +0 -4
  46. data/spec/assets/env/Gemfile.lock +0 -17
  47. data/spec/assets/env/env_test.rb +0 -58
  48. data/spec/assets/hello-sinatra/manifest.yml +0 -17
  49. data/spec/cf/cli/service/service_instance_helper_spec.rb +0 -155
  50. data/spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb +0 -12
  51. data/spec/features/manifests_spec.rb +0 -86
@@ -88,7 +88,6 @@ module CF
88
88
 
89
89
  desc "Help!"
90
90
  input :command, :argument => :optional
91
- input :all, :type => :boolean
92
91
  def help
93
92
  if name = input[:command]
94
93
  if cmd = @@commands[name.gsub("-", "_").to_sym]
@@ -97,11 +96,9 @@ module CF
97
96
  unknown_command(name)
98
97
  end
99
98
  elsif Help.has_groups?
100
- unless input[:all]
101
- puts "#{help_header}"
102
- end
99
+ puts "#{help_header}"
103
100
 
104
- Mothership::Help.print_help_groups(@@global, input[:all])
101
+ Mothership::Help.print_help_groups(@@global, true)
105
102
  else
106
103
  Mothership::Help.basic_help(@@commands, @@global)
107
104
  end
@@ -110,7 +107,7 @@ module CF
110
107
  def help_header
111
108
  <<EOS
112
109
  Cloud Foundry Command Line Interface, version [#{CF::VERSION}]
113
- Use 'cf help' for basic help, 'cf help --all' for all commands, 'cf help [command]' for command details.
110
+ Use 'cf help [command]' for command details.
114
111
  For docs and support visit http://support.cloudfoundry.com
115
112
 
116
113
  USAGE EXAMPLES
@@ -5,7 +5,7 @@ module CF::App
5
5
  VALID_ENV_VAR = /^[a-zA-Za-z_][[:alnum:]_]*$/
6
6
 
7
7
  desc "Show all environment variables set for an app"
8
- group :apps, :info, :hidden => true
8
+ group :apps, :info
9
9
  input :app, :desc => "Application to inspect the environment of",
10
10
  :argument => true, :from_given => by_name(:app)
11
11
  def env
@@ -24,7 +24,7 @@ module CF::App
24
24
  end
25
25
 
26
26
  desc "Set an environment variable"
27
- group :apps, :info, :hidden => true
27
+ group :apps, :info
28
28
  input :app, :desc => "Application to set the variable for",
29
29
  :argument => true, :from_given => by_name(:app)
30
30
  input :name, :desc => "Variable name", :argument => true
@@ -56,7 +56,7 @@ module CF::App
56
56
 
57
57
 
58
58
  desc "Remove an environment variable"
59
- group :apps, :info, :hidden => true
59
+ group :apps, :info
60
60
  input :app, :desc => "Application to set the variable for",
61
61
  :argument => true, :from_given => by_name(:app)
62
62
  input :name, :desc => "Variable name", :argument => true
@@ -3,7 +3,7 @@ require "cf/cli/app/base"
3
3
  module CF::App
4
4
  class Events < Base
5
5
  desc "Display application events"
6
- group :apps, :info, :hidden => true
6
+ group :apps, :info
7
7
  input :app, :desc => "Application to get the events for",
8
8
  :argument => true, :from_given => by_name(:app)
9
9
  def events
@@ -4,7 +4,7 @@ require "cf/cli/app/base"
4
4
  module CF::App
5
5
  class Files < Base
6
6
  desc "Print out an app's file contents"
7
- group :apps, :info, :hidden => true
7
+ group :apps, :info
8
8
  input :app, :desc => "Application to inspect the files of",
9
9
  :argument => true, :from_given => by_name(:app)
10
10
  input :path, :desc => "Path of file to read", :argument => :optional,
@@ -34,7 +34,7 @@ module CF::App
34
34
  end
35
35
 
36
36
  desc "Examine an app's files"
37
- group :apps, :info, :hidden => true
37
+ group :apps, :info
38
38
  input :app, :desc => "Application to inspect the files of",
39
39
  :argument => true, :from_given => by_name(:app)
40
40
  input :path, :desc => "Path of directory to list", :argument => :optional,
@@ -62,7 +62,7 @@ module CF::App
62
62
  end
63
63
 
64
64
  desc "Stream an app's file contents"
65
- group :apps, :info, :hidden => true
65
+ group :apps, :info
66
66
  input :app, :desc => "Application to inspect the files of",
67
67
  :argument => true, :from_given => by_name(:app)
68
68
  input :path, :desc => "Path of file to stream", :argument => :optional
@@ -3,7 +3,7 @@ require "cf/cli/app/base"
3
3
  module CF::App
4
4
  class Health < Base
5
5
  desc "Get application health"
6
- group :apps, :info, :hidden => true
6
+ group :apps, :info
7
7
  input :apps, :desc => "Show the health information for one or more applications", :argument => :splat,
8
8
  :singular => :app, :from_given => by_name(:app)
9
9
  def health
@@ -3,7 +3,7 @@ require "cf/cli/app/base"
3
3
  module CF::App
4
4
  class Instances < Base
5
5
  desc "List an app's instances"
6
- group :apps, :info, :hidden => true
6
+ group :apps, :info
7
7
  input :apps, :desc => "Applications whose instances to list",
8
8
  :argument => :splat, :singular => :app,
9
9
  :from_given => by_name(:app)
@@ -3,7 +3,7 @@ require "cf/cli/app/base"
3
3
  module CF::App
4
4
  class Logs < Base
5
5
  desc "Print out an app's logs"
6
- group :apps, :info, :hidden => true
6
+ group :apps, :info
7
7
  input :app, :desc => "Application to get the logs of", :argument => true,
8
8
  :from_given => by_name(:app)
9
9
  input :instance, :desc => "Instance of application to get the logs of",
@@ -33,7 +33,7 @@ module CF::App
33
33
  end
34
34
 
35
35
  desc "Print out the logs for an app's crashed instances"
36
- group :apps, :info, :hidden => true
36
+ group :apps, :info
37
37
  input :app, :desc => "Application to get the logs of", :argument => true,
38
38
  :from_given => by_name(:app)
39
39
  def crashlogs
@@ -3,7 +3,7 @@ require "cf/cli/app/base"
3
3
  module CF::App
4
4
  class Rename < Base
5
5
  desc "Rename an application"
6
- group :apps, :manage, :hidden => true
6
+ group :apps, :manage
7
7
  input :app, :desc => "Application to rename", :argument => :optional,
8
8
  :from_given => by_name(:app)
9
9
  input :name, :desc => "New application name", :argument => :optional
@@ -3,7 +3,7 @@ require "cf/cli/app/base"
3
3
  module CF::App
4
4
  class Scale < Base
5
5
  desc "Update the instances/memory limit for an application"
6
- group :apps, :info, :hidden => true
6
+ group :apps, :info
7
7
  input :app, :desc => "Application to update", :argument => true,
8
8
  :from_given => by_name(:app)
9
9
  input :instances, :desc => "Number of instances to run",
@@ -3,7 +3,7 @@ require "cf/cli/app/base"
3
3
  module CF::App
4
4
  class Stats < Base
5
5
  desc "Display application instance status"
6
- group :apps, :info, :hidden => true
6
+ group :apps, :info
7
7
  input :app, :desc => "Application to get the stats for",
8
8
  :argument => true, :from_given => by_name(:app)
9
9
  def stats
@@ -3,7 +3,7 @@ require "cf/cli/organization/base"
3
3
  module CF::Organization
4
4
  class Rename < Base
5
5
  desc "Rename an organization"
6
- group :organizations, :hidden => true
6
+ group :organizations
7
7
  input :organization, :desc => "Organization to rename",
8
8
  :aliases => ["--org", "-o"], :argument => :optional,
9
9
  :from_given => by_name(:organization)
@@ -3,7 +3,7 @@ require "cf/cli/route/base"
3
3
  module CF::Route
4
4
  class Map < Base
5
5
  desc "Add a URL mapping"
6
- group :apps, :info, :hidden => true
6
+ group :apps, :info
7
7
  input :app, :desc => "Application to add the URL to",
8
8
  :argument => :optional, :from_given => by_name(:app)
9
9
  input :host, :desc => "Host name for the route",
@@ -3,7 +3,7 @@ require "cf/cli/route/base"
3
3
  module CF::Route
4
4
  class Unmap < Base
5
5
  desc "Remove a URL mapping"
6
- group :apps, :info, :hidden => true
6
+ group :apps, :info
7
7
  input :url, :desc => "URL to unmap", :argument => :optional,
8
8
  :from_given => find_by_name("route") { client.routes }
9
9
  input :app, :desc => "Application to remove the URL from",
@@ -1,16 +1,6 @@
1
1
  require "cf/cli/service/base"
2
2
 
3
3
  module CF::Service
4
- USER_PROVIDED_OFFERING = "user-provided" # I'd rather move this to CFoundry
5
-
6
- class UPDummy
7
- def label
8
- "user-provided"
9
- end
10
-
11
- attr_reader :version, :provider
12
- end
13
-
14
4
  class Create < Base
15
5
  offerings_from_label = proc { |label, offerings|
16
6
  offerings.select { |s| s.label == label }
@@ -56,8 +46,6 @@ module CF::Service
56
46
  end
57
47
  finalize
58
48
 
59
- offerings << UPDummy.new
60
-
61
49
  selected_offerings = offerings.any? ? Array(input[:offering, offerings.sort_by(&:label)]) : []
62
50
  finalize
63
51
 
@@ -67,85 +55,48 @@ module CF::Service
67
55
 
68
56
  offering = selected_offerings.first
69
57
 
70
- if offering.label == CF::Service::USER_PROVIDED_OFFERING
71
- service_instance = client.user_provided_service_instance
72
- service_instance.name = input[:name, offering]
73
- finalize
74
-
75
- # at this point there's no way input[:credentials] can work interactively...
76
- service_instance.credentials = input[:credentials, nil] || ask_credentials
77
- else
78
- service_instance = client.managed_service_instance
79
- service_instance.name = input[:name, offering]
80
- finalize
81
-
82
- plan = input[:plan, offering.service_plans]
83
- finalize
84
- service_instance.service_plan = if plan.is_a?(String)
85
- offering.service_plans.find { |p| p.name.casecmp(plan) == 0 }
86
- else
87
- plan
88
- end
89
- end
90
-
91
- service_instance.space = client.current_space
92
-
93
- with_progress("Creating service #{c(service_instance.name, :name)}") do
94
- service_instance.create!
58
+ service = client.service_instance
59
+ service.name = input[:name, offering]
60
+ finalize
61
+ plan = input[:plan, offering.service_plans]
62
+ finalize
63
+ service.service_plan = if plan.is_a?(String)
64
+ offering.service_plans.find { |p| p.name.casecmp(plan) == 0 }
65
+ else
66
+ plan
67
+ end
68
+ service.space = client.current_space
69
+
70
+ with_progress("Creating service #{c(service.name, :name)}") do
71
+ service.create!
95
72
  end
96
73
 
97
74
  app = input[:app]
98
75
  finalize
99
76
 
100
77
  if app
101
- invoke :bind_service, :service => service_instance, :app => app
78
+ invoke :bind_service, :service => service, :app => app
102
79
  end
103
- service_instance
80
+ service
104
81
  end
105
82
 
106
83
  private
107
84
 
108
- def ask_credentials
109
- credentials = {}
110
- line("What credential parameters should applications use to connect to this service instance? (e.g. hostname, port, password)")
111
-
112
- while keys = ask("Keys").split(/\s*,\s*/).map(&:strip)
113
- if bad_key = keys.detect { |key| key !~ /^[-\w]+$/ }
114
- line("'#{bad_key}' is not a valid key")
115
- else
116
- break
117
- end
118
- end
119
- finalize
120
- keys.each do |key|
121
- value = ask(key)
122
- finalize
123
- credentials[key] = value
124
- end
125
-
126
- credentials
127
- end
128
-
129
85
  def ask_offering(offerings)
130
86
  [ask("What kind?", :choices => offerings.sort_by(&:label),
131
- :display => proc do |s|
87
+ :display => proc { |s|
132
88
  str = "#{c(s.label, :name)} #{s.version}"
133
89
  if s.provider != "core"
134
90
  str << ", via #{s.provider}"
135
91
  end
136
92
  str
137
- end,
93
+ },
138
94
  :complete => proc { |s| "#{s.label} #{s.version}" })]
139
95
  end
140
96
 
141
97
  def ask_name(offering)
142
- default = nil
143
- unless offering == CF::Service::USER_PROVIDED_OFFERING
144
- random = sprintf("%x", rand(1000000))
145
- default = "#{offering.label}-#{random}"
146
- end
147
-
148
- ask "Name?", :default => default
98
+ random = sprintf("%x", rand(1000000))
99
+ ask "Name?", :default => "#{offering.label}-#{random}"
149
100
  end
150
101
 
151
102
  def ask_plan(plans)
@@ -4,7 +4,7 @@ module CF::Service
4
4
  class Delete < Base
5
5
  desc "Delete a service"
6
6
  group :services, :manage
7
- input :service, :desc => "Service to delete", :argument => :optional,
7
+ input :service, :desc => "Service to bind", :argument => :optional,
8
8
  :from_given => by_name(:service_instance, :service)
9
9
  input :unbind, :desc => "Unbind from applications before deleting?",
10
10
  :type => :boolean, :default => proc { force? || interact }
@@ -3,7 +3,7 @@ require "cf/cli/service/base"
3
3
  module CF::Service
4
4
  class Rename < Base
5
5
  desc "Rename a service"
6
- group :services, :manage, :hidden => true
6
+ group :services, :manage
7
7
  input :service, :desc => "Service to rename", :argument => :optional,
8
8
  :from_given => by_name(:service_instance, :service)
9
9
  input :name, :desc => "New service name", :argument => :optional
@@ -71,16 +71,19 @@ module CF::Service
71
71
  def show_services_table
72
72
  table(
73
73
  ["name", "service", "provider", "version", "plan", "bound apps"],
74
- @services.collect { |instance|
75
- presenter = ServiceInstanceHelper.new(instance)
76
- apps = name_list(presenter.service_bindings.collect(&:app))
77
-
78
- label = presenter.service_label
79
- provider = presenter.service_provider
80
- version = presenter.version
81
- plan_name = presenter.plan_name
82
-
83
- [ c(presenter.name, :name), label, provider, version, plan_name, apps]
74
+ @services.collect { |i|
75
+ apps = name_list(i.service_bindings.collect(&:app))
76
+ plan = i.service_plan
77
+
78
+ unless plan
79
+ [ c(i.name, :name), "none", "none", "none", "none", apps]
80
+ else
81
+ service = plan.service
82
+ label = service.label
83
+ version = service.version
84
+ provider = service.provider
85
+ [ c(i.name, :name), label, provider, version, plan.name, apps]
86
+ end
84
87
  })
85
88
 
86
89
  end
@@ -102,8 +105,25 @@ module CF::Service
102
105
  return false unless File.fnmatch(name, i.name)
103
106
  end
104
107
 
105
- helper = ServiceInstanceHelper.new(i)
106
- return helper.matches(options)
108
+ plan = i.service_plan
109
+
110
+ if service = options[:service]
111
+ return false unless File.fnmatch(service, plan.service.label)
112
+ end
113
+
114
+ if plan = options[:plan]
115
+ return false unless File.fnmatch(plan.upcase, plan.name.upcase)
116
+ end
117
+
118
+ if provider = options[:provider]
119
+ return false unless File.fnmatch(provider, plan.service.provider)
120
+ end
121
+
122
+ if version = options[:version]
123
+ return false unless File.fnmatch(version, plan.service.version)
124
+ end
125
+
126
+ true
107
127
  end
108
128
  end
109
129
  end
@@ -3,7 +3,7 @@ require "cf/cli/space/base"
3
3
  module CF::Space
4
4
  class Rename < Base
5
5
  desc "Rename a space"
6
- group :spaces, :hidden => true
6
+ group :spaces
7
7
  input :organization, :desc => "Space's organization",
8
8
  :aliases => ["--org", "-o"], :from_given => by_name(:organization),
9
9
  :default => proc { client.current_organization }
@@ -3,7 +3,7 @@ require "cf/cli/space/base"
3
3
  module CF::Space
4
4
  class Switch < Base
5
5
  desc "Switch to a space"
6
- group :spaces, :hidden => true
6
+ group :spaces
7
7
  input :name, :desc => "Space name", :argument => true
8
8
  def switch_space
9
9
  space = client.space_by_name(input[:name])
@@ -3,7 +3,7 @@ require "cf/cli/start/base"
3
3
  module CF::Start
4
4
  class Colors < Base
5
5
  desc "Show color configuration"
6
- group :start, :hidden => true
6
+ group :start
7
7
  def colors
8
8
  user_colors.each do |n, c|
9
9
  line "#{n}: #{c(c.to_s, n)}"
@@ -3,7 +3,7 @@ require "cf/cli/start/base"
3
3
  module CF::Start
4
4
  class Targets < Base
5
5
  desc "List known targets."
6
- group :start, :hidden => true
6
+ group :start
7
7
  def targets
8
8
  targets_info.each do |target, _|
9
9
  line target
@@ -3,7 +3,7 @@ require "cf/cli/user/base"
3
3
  module CF::User
4
4
  class Create < Base
5
5
  desc "Create a user"
6
- group :admin, :user, :hidden => true
6
+ group :admin, :user
7
7
  input :email, :desc => "User email", :argument => :optional
8
8
  input :password, :desc => "User password"
9
9
  input :verify, :desc => "Repeat password"