cf 0.1.5 → 0.6.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. data/LICENSE +1277 -30
  2. data/Rakefile +12 -1
  3. data/bin/cf +0 -3
  4. data/lib/cf.rb +6 -0
  5. data/lib/cf/cli.rb +389 -190
  6. data/lib/cf/cli/app/app.rb +45 -0
  7. data/lib/cf/cli/app/apps.rb +99 -0
  8. data/lib/cf/cli/app/base.rb +90 -0
  9. data/lib/cf/cli/app/crashes.rb +42 -0
  10. data/lib/cf/cli/app/delete.rb +95 -0
  11. data/lib/cf/cli/app/deprecated.rb +11 -0
  12. data/lib/cf/cli/app/env.rb +78 -0
  13. data/lib/cf/cli/app/files.rb +137 -0
  14. data/lib/cf/cli/app/health.rb +26 -0
  15. data/lib/cf/cli/app/instances.rb +53 -0
  16. data/lib/cf/cli/app/logs.rb +76 -0
  17. data/lib/cf/cli/app/push.rb +105 -0
  18. data/lib/cf/cli/app/push/create.rb +149 -0
  19. data/lib/cf/cli/app/push/interactions.rb +94 -0
  20. data/lib/cf/cli/app/push/sync.rb +64 -0
  21. data/lib/cf/cli/app/rename.rb +35 -0
  22. data/lib/cf/cli/app/restart.rb +20 -0
  23. data/lib/cf/cli/app/scale.rb +69 -0
  24. data/lib/cf/cli/app/start.rb +143 -0
  25. data/lib/cf/cli/app/stats.rb +67 -0
  26. data/lib/cf/cli/app/stop.rb +27 -0
  27. data/lib/cf/cli/domain/base.rb +8 -0
  28. data/lib/cf/cli/domain/domains.rb +40 -0
  29. data/lib/cf/cli/domain/map.rb +55 -0
  30. data/lib/cf/cli/domain/unmap.rb +56 -0
  31. data/lib/cf/cli/help.rb +15 -0
  32. data/lib/cf/cli/interactive.rb +105 -0
  33. data/lib/cf/cli/organization/base.rb +12 -0
  34. data/lib/cf/cli/organization/create.rb +32 -0
  35. data/lib/cf/cli/organization/delete.rb +73 -0
  36. data/lib/cf/cli/organization/org.rb +45 -0
  37. data/lib/cf/cli/organization/orgs.rb +35 -0
  38. data/lib/cf/cli/organization/rename.rb +36 -0
  39. data/lib/cf/cli/route/base.rb +8 -0
  40. data/lib/cf/cli/route/map.rb +70 -0
  41. data/lib/cf/cli/route/routes.rb +26 -0
  42. data/lib/cf/cli/route/unmap.rb +62 -0
  43. data/lib/cf/cli/service/base.rb +8 -0
  44. data/lib/cf/cli/service/bind.rb +44 -0
  45. data/lib/cf/cli/service/create.rb +107 -0
  46. data/lib/cf/cli/service/delete.rb +82 -0
  47. data/lib/cf/cli/service/rename.rb +35 -0
  48. data/lib/cf/cli/service/service.rb +40 -0
  49. data/lib/cf/cli/service/services.rb +99 -0
  50. data/lib/cf/cli/service/unbind.rb +38 -0
  51. data/lib/cf/cli/space/base.rb +19 -0
  52. data/lib/cf/cli/space/create.rb +63 -0
  53. data/lib/cf/cli/space/delete.rb +95 -0
  54. data/lib/cf/cli/space/rename.rb +39 -0
  55. data/lib/cf/cli/space/space.rb +64 -0
  56. data/lib/cf/cli/space/spaces.rb +55 -0
  57. data/lib/cf/cli/space/switch.rb +16 -0
  58. data/lib/cf/cli/start/base.rb +93 -0
  59. data/lib/cf/cli/start/colors.rb +13 -0
  60. data/lib/cf/cli/start/info.rb +124 -0
  61. data/lib/cf/cli/start/login.rb +94 -0
  62. data/lib/cf/cli/start/logout.rb +17 -0
  63. data/lib/cf/cli/start/target.rb +69 -0
  64. data/lib/cf/cli/start/target_interactions.rb +37 -0
  65. data/lib/cf/cli/start/targets.rb +16 -0
  66. data/lib/cf/cli/user/base.rb +29 -0
  67. data/lib/cf/cli/user/create.rb +39 -0
  68. data/lib/cf/cli/user/passwd.rb +43 -0
  69. data/lib/cf/cli/user/register.rb +42 -0
  70. data/lib/cf/cli/user/users.rb +32 -0
  71. data/lib/cf/constants.rb +10 -7
  72. data/lib/cf/detect.rb +113 -48
  73. data/lib/cf/errors.rb +17 -0
  74. data/lib/cf/plugin.rb +28 -12
  75. data/lib/cf/spacing.rb +89 -0
  76. data/lib/cf/spec_helper.rb +1 -0
  77. data/lib/cf/test_support.rb +6 -0
  78. data/lib/cf/version.rb +1 -1
  79. data/spec/assets/hello-sinatra/Gemfile +3 -0
  80. data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
  81. data/spec/assets/hello-sinatra/config.ru +3 -0
  82. data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
  83. data/spec/assets/hello-sinatra/main.rb +6 -0
  84. data/spec/assets/specker_runner/specker_runner_input.rb +6 -0
  85. data/spec/assets/specker_runner/specker_runner_pause.rb +5 -0
  86. data/spec/cf/cli/app/base_spec.rb +17 -0
  87. data/spec/cf/cli/app/delete_spec.rb +188 -0
  88. data/spec/cf/cli/app/instances_spec.rb +65 -0
  89. data/spec/cf/cli/app/push/create_spec.rb +661 -0
  90. data/spec/cf/cli/app/push_spec.rb +369 -0
  91. data/spec/cf/cli/app/rename_spec.rb +104 -0
  92. data/spec/cf/cli/app/scale_spec.rb +75 -0
  93. data/spec/cf/cli/app/start_spec.rb +208 -0
  94. data/spec/cf/cli/app/stats_spec.rb +68 -0
  95. data/spec/cf/cli/domain/map_spec.rb +130 -0
  96. data/spec/cf/cli/domain/unmap_spec.rb +69 -0
  97. data/spec/cf/cli/organization/orgs_spec.rb +108 -0
  98. data/spec/cf/cli/organization/rename_spec.rb +113 -0
  99. data/spec/cf/cli/route/map_spec.rb +121 -0
  100. data/spec/cf/cli/route/unmap_spec.rb +155 -0
  101. data/spec/cf/cli/service/bind_spec.rb +25 -0
  102. data/spec/cf/cli/service/delete_spec.rb +22 -0
  103. data/spec/cf/cli/service/rename_spec.rb +105 -0
  104. data/spec/cf/cli/service/service_spec.rb +23 -0
  105. data/spec/cf/cli/service/unbind_spec.rb +25 -0
  106. data/spec/cf/cli/space/create_spec.rb +93 -0
  107. data/spec/cf/cli/space/rename_spec.rb +102 -0
  108. data/spec/cf/cli/space/spaces_spec.rb +104 -0
  109. data/spec/cf/cli/space/switch_space_spec.rb +55 -0
  110. data/spec/cf/cli/start/info_spec.rb +160 -0
  111. data/spec/cf/cli/start/login_spec.rb +142 -0
  112. data/spec/cf/cli/start/logout_spec.rb +50 -0
  113. data/spec/cf/cli/start/target_spec.rb +123 -0
  114. data/spec/cf/cli/user/create_spec.rb +54 -0
  115. data/spec/cf/cli/user/passwd_spec.rb +102 -0
  116. data/spec/cf/cli/user/register_spec.rb +140 -0
  117. data/spec/cf/cli_spec.rb +442 -0
  118. data/spec/cf/detect_spec.rb +54 -0
  119. data/spec/console_app_specker/console_app_specker_matchers_spec.rb +173 -0
  120. data/spec/console_app_specker/specker_runner_spec.rb +167 -0
  121. data/spec/features/account_lifecycle_spec.rb +85 -0
  122. data/spec/features/login_spec.rb +66 -0
  123. data/spec/features/push_flow_spec.rb +125 -0
  124. data/spec/features/switching_targets_spec.rb +32 -0
  125. data/spec/spec_helper.rb +72 -0
  126. data/spec/support/command_helper.rb +81 -0
  127. data/spec/support/config_helper.rb +15 -0
  128. data/spec/support/console_app_specker_matchers.rb +86 -0
  129. data/spec/support/fake_home_dir.rb +55 -0
  130. data/spec/support/interact_helper.rb +29 -0
  131. data/spec/support/shared_examples/errors.rb +40 -0
  132. data/spec/support/shared_examples/input.rb +14 -0
  133. data/spec/support/specker_runner.rb +80 -0
  134. data/spec/support/tracking_expector.rb +71 -0
  135. metadata +427 -66
  136. data/lib/cf/cli/app.rb +0 -595
  137. data/lib/cf/cli/command.rb +0 -444
  138. data/lib/cf/cli/dots.rb +0 -133
  139. data/lib/cf/cli/service.rb +0 -112
  140. data/lib/cf/cli/user.rb +0 -71
@@ -1,112 +0,0 @@
1
- require "cf/cli/command"
2
-
3
- module CF
4
- class Service < Command
5
- desc "delete", "Delete a service"
6
- flag(:really) { |name, color = :blue|
7
- force? || ask("Really delete #{c(name, color)}?", :default => false)
8
- }
9
- flag(:name) { |choices|
10
- ask "Delete which service?", :choices => choices
11
- }
12
- flag(:all, :default => false)
13
- def delete(name = nil)
14
- if input(:all)
15
- return unless input(:really, "ALL SERVICES", :red)
16
-
17
- with_progress("Deleting all services") do
18
- client.services.collect(&:delete!)
19
- end
20
-
21
- return
22
- end
23
-
24
- unless name
25
- services = client.services
26
- return err "No services." if services.empty?
27
-
28
- name = input(:name, services.collect(&:name))
29
- end
30
-
31
- return unless input(:really, name)
32
-
33
- with_progress("Deleting #{c(name, :blue)}") do
34
- client.service(name).delete!
35
- end
36
- end
37
-
38
- desc "bind", "Bind a service to an application"
39
- flag(:name) { |choices|
40
- ask "Which service?", :choices => choices
41
- }
42
- flag(:app) { |choices|
43
- ask "Which application?", :choices => choices
44
- }
45
- def bind(name = nil, appname = nil)
46
- name ||= input(:name, client.services.collect(&:name))
47
- appname ||= input(:app, client.apps.collect(&:name))
48
-
49
- with_progress("Binding #{c(name, :blue)} to #{c(appname, :blue)}") do
50
- client.app(appname).bind(name)
51
- end
52
- end
53
-
54
- desc "unbind", "Unbind a service from an application"
55
- flag(:name) { |choices|
56
- ask "Which service?", :choices => choices
57
- }
58
- flag(:app) { |choices|
59
- ask "Which application?", :choices => choices
60
- }
61
- def unbind(name = nil, appname = nil)
62
- appname ||= input(:app, client.apps.collect(&:name))
63
-
64
- app = client.app(appname)
65
- name ||= input(:name, app.services)
66
-
67
- with_progress("Unbinding #{c(name, :blue)} from #{c(appname, :blue)}") do
68
- app.unbind(name)
69
- end
70
- end
71
-
72
- desc "create", "Create a service"
73
- flag(:type) { |choices|
74
- ask "What kind?", :choices => choices
75
- }
76
- flag(:name) { |vendor|
77
- random = sprintf("%x", rand(1000000))
78
- ask "Name?", :default => "#{vendor}-#{random}"
79
- }
80
- def create
81
- choices = []
82
- manifests = {}
83
- client.system_services.each do |type, vendors|
84
- vendors.each do |vendor, versions|
85
- versions.each do |version, _|
86
- choice = "#{vendor} #{version}"
87
- manifests[choice] = {
88
- :type => type,
89
- :vendor => vendor,
90
- :version => version
91
- }
92
-
93
- choices << choice
94
- end
95
- end
96
- end
97
-
98
- type = input(:type, choices)
99
- meta = manifests[type]
100
-
101
- service = client.service(input(:name, meta[:vendor]))
102
- service.type = meta[:type]
103
- service.vendor = meta[:vendor]
104
- service.version = meta[:version]
105
- service.tier = "free"
106
-
107
- with_progress("Creating service") do
108
- service.create!
109
- end
110
- end
111
- end
112
- end
@@ -1,71 +0,0 @@
1
- require "cf/cli/command"
2
-
3
- module CF
4
- class User < Command
5
- desc "create [EMAIL]", "Create a user"
6
- flag(:email) {
7
- ask("Email")
8
- }
9
- flag(:password) {
10
- ask("Password", :echo => "*", :forget => true)
11
- }
12
- flag(:verify) {
13
- ask("Verify Password", :echo => "*", :forget => true)
14
- }
15
- def create(email = nil)
16
- email ||= input(:email)
17
- password = input(:password)
18
- verify = input(:verify)
19
-
20
- if password != verify
21
- err "Passwords don't match."
22
- return
23
- end
24
-
25
- with_progress("Creating user") do
26
- client.register(email, password)
27
- end
28
- end
29
-
30
- desc "delete [EMAIL]", "Delete a user"
31
- flag(:really) { |email|
32
- force? || ask("Really delete user #{c(email, :blue)}?", :default => false)
33
- }
34
- def delete(email)
35
- return unless input(:really, email)
36
-
37
- with_progress("Deleting #{c(email, :blue)}") do
38
- client.user(email).delete!
39
- end
40
- ensure
41
- forget(:really)
42
- end
43
-
44
- desc "passwd [EMAIL]", "Update a user's password"
45
- flag(:email) {
46
- ask("Email")
47
- }
48
- flag(:password) {
49
- ask("Password", :echo => "*", :forget => true)
50
- }
51
- flag(:verify) {
52
- ask("Verify Password", :echo => "*", :forget => true)
53
- }
54
- def passwd(email = nil)
55
- email ||= input(:email)
56
- password = input(:password)
57
- verify = input(:verify)
58
-
59
- if password != verify
60
- err "Passwords don't match."
61
- return
62
- end
63
-
64
- with_progress("Changing password") do
65
- user = client.user(email)
66
- user.password = password
67
- user.update!
68
- end
69
- end
70
- end
71
- end