vmc 0.4.7 → 0.5.0.beta.1

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.
Files changed (73) hide show
  1. data/lib/vmc.rb +1 -2
  2. data/lib/vmc/cli.rb +33 -31
  3. data/lib/vmc/cli/app/app.rb +2 -2
  4. data/lib/vmc/cli/app/apps.rb +4 -5
  5. data/lib/vmc/cli/app/crashes.rb +2 -3
  6. data/lib/vmc/cli/app/delete.rb +28 -25
  7. data/lib/vmc/cli/app/env.rb +11 -19
  8. data/lib/vmc/cli/app/files.rb +11 -15
  9. data/lib/vmc/cli/app/health.rb +2 -3
  10. data/lib/vmc/cli/app/instances.rb +3 -3
  11. data/lib/vmc/cli/app/logs.rb +7 -10
  12. data/lib/vmc/cli/app/push.rb +17 -89
  13. data/lib/vmc/cli/app/push/create.rb +2 -0
  14. data/lib/vmc/cli/app/rename.rb +17 -13
  15. data/lib/vmc/cli/app/restart.rb +4 -7
  16. data/lib/vmc/cli/app/routes.rb +14 -11
  17. data/lib/vmc/cli/app/scale.rb +17 -15
  18. data/lib/vmc/cli/app/start.rb +4 -7
  19. data/lib/vmc/cli/app/stats.rb +2 -3
  20. data/lib/vmc/cli/app/stop.rb +3 -5
  21. data/lib/vmc/cli/domain/add_domain.rb +3 -5
  22. data/lib/vmc/cli/domain/create_domain.rb +5 -8
  23. data/lib/vmc/cli/domain/delete_domain.rb +23 -18
  24. data/lib/vmc/cli/domain/domains.rb +4 -7
  25. data/lib/vmc/cli/domain/remove_domain.rb +12 -10
  26. data/lib/vmc/cli/organization/org.rb +6 -7
  27. data/lib/vmc/cli/organization/orgs.rb +19 -19
  28. data/lib/vmc/cli/organization/rename.rb +18 -14
  29. data/lib/vmc/cli/route/create_route.rb +20 -13
  30. data/lib/vmc/cli/route/{delete_route.rb → delete.rb} +22 -17
  31. data/lib/vmc/cli/service/bind.rb +2 -2
  32. data/lib/vmc/cli/service/create.rb +57 -53
  33. data/lib/vmc/cli/service/delete.rb +33 -31
  34. data/lib/vmc/cli/service/rename.rb +17 -14
  35. data/lib/vmc/cli/service/service.rb +5 -8
  36. data/lib/vmc/cli/service/services.rb +14 -18
  37. data/lib/vmc/cli/service/unbind.rb +4 -4
  38. data/lib/vmc/cli/space/create.rb +16 -17
  39. data/lib/vmc/cli/space/delete.rb +34 -31
  40. data/lib/vmc/cli/space/rename.rb +20 -17
  41. data/lib/vmc/cli/space/space.rb +11 -14
  42. data/lib/vmc/cli/space/spaces.rb +14 -16
  43. data/lib/vmc/cli/space/take.rb +1 -3
  44. data/lib/vmc/cli/start/base.rb +2 -0
  45. data/lib/vmc/cli/start/colors.rb +0 -1
  46. data/lib/vmc/cli/start/info.rb +8 -10
  47. data/lib/vmc/cli/start/login.rb +11 -40
  48. data/lib/vmc/cli/start/logout.rb +0 -1
  49. data/lib/vmc/cli/start/register.rb +18 -12
  50. data/lib/vmc/cli/start/target.rb +7 -36
  51. data/lib/vmc/cli/start/target_interactions.rb +3 -1
  52. data/lib/vmc/cli/start/targets.rb +0 -1
  53. data/lib/vmc/cli/user/create.rb +4 -2
  54. data/lib/vmc/version.rb +1 -1
  55. data/spec/factories/organization_factory.rb +5 -0
  56. data/spec/factories/space_factory.rb +15 -0
  57. data/spec/spec_helper.rb +16 -0
  58. data/spec/vmc/cli/app/push/create_spec.rb +2 -1
  59. data/spec/vmc/cli/app/push_spec.rb +1 -1
  60. data/spec/vmc/cli/organization/orgs_spec.rb +119 -0
  61. data/spec/vmc/cli/route/delete_route_spec.rb +3 -3
  62. data/spec/vmc/cli/service/bind_spec.rb +34 -0
  63. data/spec/vmc/cli/service/delete_spec.rb +32 -0
  64. data/spec/vmc/cli/service/service_spec.rb +32 -0
  65. data/spec/vmc/cli/service/unbind_spec.rb +34 -0
  66. data/spec/vmc/cli/space/spaces_spec.rb +120 -0
  67. data/spec/vmc/cli/start/info_spec.rb +38 -0
  68. data/spec/vmc/cli/start/login_spec.rb +40 -0
  69. metadata +127 -113
  70. data/lib/vmc/cli/organization/create_org.rb +0 -28
  71. data/lib/vmc/cli/organization/delete_org.rb +0 -65
  72. data/lib/vmc/cli/service/binding.rb +0 -66
  73. data/lib/vmc/cli/user.rb +0 -118
@@ -1,28 +0,0 @@
1
- require "vmc/cli/organization/base"
2
-
3
- module VMC::Organization
4
- class CreateOrg < Base
5
- desc "Create an organization"
6
- group :organizations
7
- input(:name, :argument => :optional, :desc => "Organization name") {
8
- ask("Name")
9
- }
10
- input :target, :alias => "-t", :type => :boolean,
11
- :desc => "Switch to the organization after creation"
12
- input :add_self, :type => :boolean, :default => true,
13
- :desc => "Add yourself to the organization"
14
- def create_org
15
- org = client.organization
16
- org.name = input[:name]
17
- org.users = [client.current_user] if input[:add_self]
18
-
19
- with_progress("Creating organization #{c(org.name, :name)}") do
20
- org.create!
21
- end
22
-
23
- if input[:target]
24
- invoke :target, :organization => org
25
- end
26
- end
27
- end
28
- end
@@ -1,65 +0,0 @@
1
- require "vmc/cli/organization/base"
2
-
3
- module VMC::Organization
4
- class DeleteOrg < Base
5
- desc "Delete an organization"
6
- group :organizations
7
- input(:organization, :aliases => ["--org", "-o"],
8
- :argument => :optional,
9
- :from_given => by_name("organization"),
10
- :desc => "Organization to delete") { |orgs|
11
- ask "Which organization?", :choices => orgs,
12
- :display => proc(&:name)
13
- }
14
- input(:really, :type => :boolean, :forget => true,
15
- :default => proc { force? || interact }) { |org|
16
- ask("Really delete #{c(org.name, :name)}?", :default => false)
17
- }
18
- input(:recursive, :alias => "-r", :type => :boolean, :forget => true) {
19
- ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
20
- }
21
- input :warn, :type => :boolean, :default => true,
22
- :desc => "Show warning if it was the last org"
23
- def delete_org
24
- orgs = client.organizations
25
- fail "No organizations." if orgs.empty?
26
-
27
- org = input[:organization, orgs]
28
- return unless input[:really, org]
29
-
30
- spaces = org.spaces
31
- unless spaces.empty?
32
- unless force?
33
- line "This organization is not empty!"
34
- line
35
- line "spaces: #{name_list(spaces)}"
36
- line
37
-
38
- return unless input[:recursive]
39
- end
40
-
41
- spaces.each do |s|
42
- invoke :delete_space, :space => s, :really => true,
43
- :recursive => true, :warn => false
44
- end
45
- end
46
-
47
- is_current = org == client.current_organization
48
-
49
- with_progress("Deleting organization #{c(org.name, :name)}") do
50
- org.delete!
51
- end
52
-
53
- if orgs.size == 1
54
- return unless input[:warn]
55
-
56
- line
57
- line c("There are no longer any organizations.", :warning)
58
- line "You may want to create one with #{c("create-org", :good)}."
59
- elsif is_current
60
- invalidate_target
61
- invoke :target
62
- end
63
- end
64
- end
65
- end
@@ -1,66 +0,0 @@
1
- require "vmc/detect"
2
-
3
- require "vmc/cli/service/base"
4
-
5
- module VMC::Service
6
- class Binding < Base
7
- desc "Bind a service instance to an application"
8
- group :services, :manage
9
- input(:instance, :argument => true,
10
- :from_given => by_name("service instance", :service_instance),
11
- :desc => "Service to bind") { |app|
12
- instances = client.service_instances
13
- fail "No service instances." if instances.empty?
14
-
15
- ask "Which service instance?",
16
- :choices => instances - app.services,
17
- :display => proc(&:name)
18
- }
19
- input(:app, :argument => true,
20
- :from_given => by_name("app"),
21
- :desc => "Application to bind to") {
22
- ask "Which application?", :choices => client.apps(:depth => 2),
23
- :display => proc(&:name)
24
- }
25
- def bind_service
26
- app = input[:app]
27
- instance = input[:instance, app]
28
-
29
- with_progress(
30
- "Binding #{c(instance.name, :name)} to #{c(app.name, :name)}") do |s|
31
- if app.binds?(instance)
32
- s.skip do
33
- err "App #{b(app.name)} already binds #{b(instance.name)}."
34
- end
35
- else
36
- app.bind(instance)
37
- end
38
- end
39
- end
40
-
41
-
42
- desc "Unbind a service from an application"
43
- group :services, :manage
44
- input(:instance, :argument => true,
45
- :from_given => find_by_name("service instance"),
46
- :desc => "Service to bind") { |services|
47
- ask "Which service instance?", :choices => services,
48
- :display => proc(&:name)
49
- }
50
- input(:app, :argument => true,
51
- :from_given => by_name("app"),
52
- :desc => "Application to bind to") {
53
- ask "Which application?", :choices => client.apps(:depth => 2),
54
- :display => proc(&:name)
55
- }
56
- def unbind_service
57
- app = input[:app]
58
- instance = input[:instance, app.services]
59
-
60
- with_progress(
61
- "Unbinding #{c(instance.name, :name)} from #{c(app.name, :name)}") do
62
- app.unbind(instance)
63
- end
64
- end
65
- end
66
- end
data/lib/vmc/cli/user.rb DELETED
@@ -1,118 +0,0 @@
1
- require "vmc/cli"
2
-
3
- module VMC
4
- class User < CLI
5
- desc "List all users"
6
- group :admin, :hidden => true
7
- def users
8
- users =
9
- with_progress("Getting users") do
10
- client.users(:depth => 0)
11
- end
12
-
13
- spaced(users) do |u|
14
- display_user(u)
15
- end
16
- end
17
-
18
-
19
- desc "Create a user"
20
- group :admin, :user, :hidden => true
21
- input(:email, :argument => true, :desc => "User email") {
22
- ask("Email")
23
- }
24
- input(:password, :desc => "User password") {
25
- ask("Password", :echo => "*", :forget => true)
26
- }
27
- input(:verify, :desc => "Repeat password") {
28
- ask("Verify Password", :echo => "*", :forget => true)
29
- }
30
- def create_user
31
- email = input[:email]
32
- password = input[:password]
33
-
34
- if !force? && password != input[:verify]
35
- fail "Passwords don't match."
36
- end
37
-
38
- with_progress("Creating user") do
39
- client.register(email, password)
40
- end
41
- end
42
-
43
- alias_command :create_user, :add_user
44
-
45
-
46
- desc "Delete a user"
47
- group :admin, :user, :hidden => true
48
- input :email, :argument => true, :desc => "User to delete"
49
- input(:really, :type => :boolean, :forget => true,
50
- :default => proc { force? || interact }) { |email|
51
- ask("Really delete user #{c(email, :name)}?", :default => false)
52
- }
53
- def delete_user
54
- email = input[:email]
55
- return unless input[:really, email]
56
-
57
- with_progress("Deleting #{c(email, :name)}") do
58
- client.user(email).delete!
59
- end
60
- end
61
-
62
-
63
- desc "Update a user's password"
64
- group :admin, :user, :hidden => true
65
- input :user, :argument => :optional,
66
- :from_given => proc { |email|
67
- if v2? && client.current_user.email != email
68
- fail "You can only change your own password on V2."
69
- else
70
- client.user(email)
71
- end
72
- },
73
- :desc => "User to update",
74
- :default => proc { client.current_user }
75
- input(:password, :desc => "New password") {
76
- ask("Current Password", :echo => "*", :forget => true)
77
- }
78
- input(:new_password, :desc => "New password") {
79
- ask("New Password", :echo => "*", :forget => true)
80
- }
81
- input(:verify, :desc => "Repeat new password") {
82
- ask("Verify Password", :echo => "*", :forget => true)
83
- }
84
- def passwd
85
- user = input[:user]
86
- password = input[:password] if v2?
87
- new_password = input[:new_password]
88
- verify = input[:verify]
89
-
90
- if new_password != verify
91
- fail "Passwords don't match."
92
- end
93
-
94
- with_progress("Changing password") do
95
- if v2?
96
- user.change_password!(new_password, password)
97
- else
98
- user.password = new_password
99
- user.update!
100
- end
101
- end
102
- end
103
-
104
- private
105
-
106
- def display_user(u)
107
- if quiet?
108
- puts u.email
109
- else
110
- line "#{c(u.email, :name)}:"
111
-
112
- indented do
113
- line "admin?: #{c(u.admin?, u.admin? ? :yes : :no)}"
114
- end
115
- end
116
- end
117
- end
118
- end