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,24 +1,20 @@
1
- require "vmc/detect"
2
-
3
1
  require "vmc/cli/service/base"
4
2
 
5
3
  module VMC::Service
6
4
  class Services < Base
7
- desc "List your service instances"
5
+ desc "List your service"
8
6
  group :services
9
- input :space,
10
- :from_given => by_name("space"),
11
- :default => proc { client.current_space },
12
- :desc => "Show services in given space"
7
+ input :space, :desc => "Show services in given space",
8
+ :from_given => by_name(:space),
9
+ :default => proc { client.current_space }
13
10
  input :name, :desc => "Filter by name"
14
11
  input :service, :desc => "Filter by service type"
15
12
  input :plan, :desc => "Filter by service plan"
16
13
  input :provider, :desc => "Filter by service provider"
17
14
  input :version, :desc => "Filter by service version"
18
15
  input :app, :desc => "Limit to application's service bindings",
19
- :from_given => by_name("app")
20
- input :full, :type => :boolean, :default => false,
21
- :desc => "Verbose output format"
16
+ :from_given => by_name(:app)
17
+ input :full, :desc => "Verbose output format", :default => false
22
18
  def services
23
19
  msg =
24
20
  if space = input[:space]
@@ -27,30 +23,30 @@ module VMC::Service
27
23
  "Getting services"
28
24
  end
29
25
 
30
- instances =
26
+ services =
31
27
  with_progress(msg) do
32
28
  client.service_instances(:depth => 2)
33
29
  end
34
30
 
35
31
  line unless quiet?
36
32
 
37
- if instances.empty? and !quiet?
33
+ if services.empty? and !quiet?
38
34
  line "No services."
39
35
  return
40
36
  end
41
37
 
42
- instances.reject! do |i|
43
- !instance_matches(i, input)
38
+ services.reject! do |i|
39
+ !service_matches(i, input)
44
40
  end
45
41
 
46
42
  if input[:full]
47
- spaced(instances) do |i|
48
- display_service_instance(i)
43
+ spaced(services) do |s|
44
+ invoke :service, :service => s
49
45
  end
50
46
  else
51
47
  table(
52
48
  ["name", "service", "version", v2? && "plan", v2? && "bound apps"],
53
- instances.collect { |i|
49
+ services.collect { |i|
54
50
  if v2?
55
51
  plan = i.service_plan
56
52
  service = plan.service
@@ -75,7 +71,7 @@ module VMC::Service
75
71
 
76
72
  private
77
73
 
78
- def instance_matches(i, options)
74
+ def service_matches(i, options)
79
75
  if app = options[:app]
80
76
  return false unless app.services.include? i
81
77
  end
@@ -3,12 +3,12 @@ require "vmc/detect"
3
3
  require "vmc/cli/service/base"
4
4
 
5
5
  module VMC::Service
6
- class Binding < Base
6
+ class Unbind < Base
7
7
  desc "Unbind a service from an application"
8
8
  group :services, :manage
9
- input :service, :desc => "Service to unbind", :argument => true,
10
- :from_given => by_name(:service, :service_instance)
11
- input :app, :desc => "Application to unbind from", :argument => true,
9
+ input :service, :desc => "Service to unbind", :argument => :optional,
10
+ :from_given => by_name(:service_instance, :service)
11
+ input :app, :desc => "Application to unbind from", :argument => :optional,
12
12
  :from_given => by_name(:app)
13
13
  def unbind_service
14
14
  app = input[:app]
@@ -1,26 +1,19 @@
1
- require "vmc/detect"
2
-
3
1
  require "vmc/cli/space/base"
4
2
 
5
3
  module VMC::Space
6
4
  class Create < Base
7
5
  desc "Create a space in an organization"
8
6
  group :spaces
9
- input(:name, :argument => :optional, :desc => "Space name") {
10
- ask("Name")
11
- }
12
- input :organization, :argument => :optional, :aliases => ["--org", "-o"],
13
- :from_given => by_name("organization"),
14
- :default => proc { client.current_organization },
15
- :desc => "Parent organization"
16
- input :target, :alias => "-t", :type => :boolean,
17
- :desc => "Switch to the space after creation"
18
- input :manager, :type => :boolean, :default => true,
19
- :desc => "Add current user as manager"
20
- input :developer, :type => :boolean, :default => true,
21
- :desc => "Add current user as developer"
22
- input :auditor, :type => :boolean, :default => false,
23
- :desc => "Add current user as auditor"
7
+ input :name, :desc => "Space name", :argument => :optional
8
+ input :organization, :desc => "Parent organization",
9
+ :argument => :optional, :aliases => ["--org", "-o"],
10
+ :from_given => by_name(:organization),
11
+ :default => proc { client.current_organization }
12
+ input :target, :desc => "Switch to the space after creation",
13
+ :alias => "-t", :default => false
14
+ input :manager, :desc => "Add yourself as manager", :default => true
15
+ input :developer, :desc => "Add yourself as developer", :default => true
16
+ input :auditor, :desc => "Add yourself as auditor", :default => false
24
17
  def create_space
25
18
  space = client.space
26
19
  space.organization = input[:organization]
@@ -53,5 +46,11 @@ module VMC::Space
53
46
  :space => space
54
47
  end
55
48
  end
49
+
50
+ private
51
+
52
+ def ask_name
53
+ ask("Name")
54
+ end
56
55
  end
57
56
  end
@@ -1,33 +1,20 @@
1
- require "vmc/detect"
2
-
3
1
  require "vmc/cli/space/base"
4
2
 
5
3
  module VMC::Space
6
4
  class Delete < Base
7
5
  desc "Delete a space and its contents"
8
6
  group :spaces
9
- input(:spaces, :argument => :splat,
10
- :from_given => space_by_name,
11
- :desc => "Space to delete") { |org|
12
- spaces = org.spaces
13
- fail "No spaces." if spaces.empty?
14
-
15
- [ask("Which space in #{c(org.name, :name)}?", :choices => spaces,
16
- :display => proc(&:name))]
17
- }
18
- input :organization, :aliases => ["--org", "-o"],
19
- :from_given => by_name("organization"),
20
- :default => proc { client.current_organization },
21
- :desc => "Space's organization"
22
- input(:really, :type => :boolean, :forget => true,
23
- :default => proc { force? || interact }) { |space|
24
- ask("Really delete #{c(space.name, :name)}?", :default => false)
25
- }
26
- input(:recursive, :alias => "-r", :type => :boolean, :forget => true) {
27
- ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
28
- }
29
- input :warn, :type => :boolean, :default => true,
30
- :desc => "Show warning if it was the last space"
7
+ input :organization, :desc => "Space's organization",
8
+ :aliases => ["--org", "-o"], :from_given => by_name(:organization),
9
+ :default => proc { client.current_organization }
10
+ input :spaces, :desc => "Spaces to delete", :argument => :splat,
11
+ :singular => :space, :from_given => space_by_name
12
+ input :recursive, :desc => "Delete recursively", :alias => "-r",
13
+ :default => false, :forget => true
14
+ input :warn, :desc => "Show warning if it was the last space",
15
+ :default => true
16
+ input :really, :type => :boolean, :forget => true, :hidden => true,
17
+ :default => proc { force? || interact }
31
18
  def delete_space
32
19
  org = input[:organization]
33
20
  spaces = input[:spaces, org]
@@ -60,19 +47,17 @@ module VMC::Space
60
47
  end
61
48
  end
62
49
 
63
- private
64
-
65
50
  def clear_space(space)
66
51
  apps = space.apps
67
- instances = space.service_instances
52
+ services = space.service_instances
68
53
 
69
- return true if apps.empty? && instances.empty?
54
+ return true if apps.empty? && services.empty?
70
55
 
71
56
  unless force?
72
57
  line "This space is not empty!"
73
58
  line
74
59
  line "apps: #{name_list(apps)}"
75
- line "service instances: #{name_list(instances)}"
60
+ line "service: #{name_list(services)}"
76
61
  line
77
62
 
78
63
  return unless input[:recursive]
@@ -82,11 +67,29 @@ module VMC::Space
82
67
  invoke :delete, :app => a, :really => true
83
68
  end
84
69
 
85
- instances.each do |i|
86
- invoke :delete_service, :instance => i, :really => true
70
+ services.each do |i|
71
+ invoke :delete_service, :service => i, :really => true
87
72
  end
88
73
 
89
74
  true
90
75
  end
76
+
77
+ private
78
+
79
+ def ask_spaces(org)
80
+ spaces = org.spaces
81
+ fail "No spaces." if spaces.empty?
82
+
83
+ [ask("Which space in #{c(org.name, :name)}?", :choices => spaces,
84
+ :display => proc(&:name))]
85
+ end
86
+
87
+ def ask_really(space)
88
+ ask("Really delete #{c(space.name, :name)}?", :default => false)
89
+ end
90
+
91
+ def ask_recursive
92
+ ask "Delete #{c("EVERYTHING", :bad)}?", :default => false
93
+ end
91
94
  end
92
95
  end
@@ -1,26 +1,15 @@
1
- require "vmc/detect"
2
-
3
1
  require "vmc/cli/space/base"
4
2
 
5
3
  module VMC::Space
6
4
  class Rename < Base
7
5
  desc "Rename a space"
8
6
  group :spaces, :hidden => true
9
- input :organization, :aliases => ["--org", "-o"],
10
- :from_given => by_name("organization"),
11
- :default => proc { client.current_organization },
12
- :desc => "Space's organization"
13
- input(:space, :argument => :optional, :from_given => space_by_name,
14
- :desc => "Space to rename") {
15
- spaces = client.spaces
16
- fail "No spaces." if spaces.empty?
17
-
18
- ask("Rename which space?", :choices => spaces.sort_by(&:name),
19
- :display => proc(&:name))
20
- }
21
- input(:name, :argument => :optional, :desc => "New space name") {
22
- ask("New name")
23
- }
7
+ input :organization, :desc => "Space's organization",
8
+ :aliases => ["--org", "-o"], :from_given => by_name(:organization),
9
+ :default => proc { client.current_organization }
10
+ input :space, :desc => "Space to rename", :argument => :optional,
11
+ :from_given => by_name(:space)
12
+ input :name, :desc => "New space name", :argument => :optional
24
13
  def rename_space
25
14
  org = input[:organization]
26
15
  space = input[:space, org]
@@ -32,5 +21,19 @@ module VMC::Space
32
21
  space.update!
33
22
  end
34
23
  end
24
+
25
+ private
26
+
27
+ def ask_space(org)
28
+ spaces = org.spaces
29
+ fail "No spaces." if spaces.empty?
30
+
31
+ ask("Rename which space?", :choices => spaces.sort_by(&:name),
32
+ :display => proc(&:name))
33
+ end
34
+
35
+ def ask_name
36
+ ask("New name")
37
+ end
35
38
  end
36
39
  end
@@ -1,21 +1,18 @@
1
- require "vmc/detect"
2
-
3
1
  require "vmc/cli/space/base"
4
2
 
5
3
  module VMC::Space
6
4
  class Space < Base
7
5
  desc "Show space information"
8
6
  group :spaces
9
- input :organization, :aliases => ["--org", "-o"],
10
- :from_given => by_name("organization"),
11
- :default => proc { client.current_organization },
12
- :desc => "Space's organization"
13
- input :space, :argument => :optional,
14
- :from_given => space_by_name,
15
- :default => proc { client.current_space },
16
- :desc => "Space to show"
17
- input :full, :type => :boolean,
18
- :desc => "Show full information for apps, service instances, etc."
7
+ input :organization, :desc => "Space's organization",
8
+ :aliases => %w{--org -o},
9
+ :default => proc { client.current_organization },
10
+ :from_given => by_name(:organization)
11
+ input :space, :desc => "Space to show", :argument => :optional,
12
+ :default => proc { client.current_space },
13
+ :from_given => space_by_name
14
+ input :full, :desc => "Show full information for apps, services, etc.",
15
+ :default => false
19
16
  def space
20
17
  org = input[:organization]
21
18
  space = input[:space, org]
@@ -51,9 +48,9 @@ module VMC::Space
51
48
  if input[:full]
52
49
  line
53
50
  line "services:"
54
- spaced(space.service_instances(:depth => 2)) do |i|
51
+ spaced(space.service_instances(:depth => 2)) do |s|
55
52
  indented do
56
- invoke :service, :instance => i
53
+ invoke :service, :service => s
57
54
  end
58
55
  end
59
56
  else
@@ -1,34 +1,36 @@
1
- require "vmc/detect"
2
-
3
1
  require "vmc/cli/space/base"
4
2
 
5
3
  module VMC::Space
6
4
  class Spaces < Base
7
5
  desc "List spaces in an organization"
8
6
  group :spaces
9
- input :organization, :argument => :optional, :aliases => ["--org", "-o"],
10
- :from_given => by_name("organization"),
11
- :default => proc { client.current_organization },
12
- :desc => "Organization to list spaces from"
7
+ input :organization, :desc => "Organization to list spaces from",
8
+ :aliases => %w{--org -o}, :argument => :optional,
9
+ :from_given => by_name(:organization),
10
+ :default => proc { client.current_organization }
13
11
  input :name, :desc => "Filter by name"
14
- input :one_line, :alias => "-l", :type => :boolean, :default => false,
15
- :desc => "Single-line tabular format"
16
- input :full, :type => :boolean, :default => false,
17
- :desc => "Show full information for apps, service instances, etc."
12
+ input :full, :desc => "Show full information for apps, services, etc.",
13
+ :default => false
18
14
  def spaces
19
15
  org = input[:organization]
20
16
  spaces =
21
17
  with_progress("Getting spaces in #{c(org.name, :name)}") do
22
- org.spaces(:depth => quiet? ? 0 : 1)
18
+ org.spaces(:depth => quiet? ? 0 : 1).sort_by(&:name)
23
19
  end
24
20
 
21
+ return if spaces.empty?
22
+
25
23
  line unless quiet?
26
24
 
27
25
  spaces.reject! do |s|
28
26
  !space_matches?(s, input)
29
27
  end
30
28
 
31
- if input[:one_line]
29
+ if input[:full]
30
+ spaced(spaces) do |s|
31
+ invoke :space, :space => s, :full => input[:full]
32
+ end
33
+ else
32
34
  table(
33
35
  %w{name apps services},
34
36
  spaces.collect { |s|
@@ -37,10 +39,6 @@ module VMC::Space
37
39
  name_list(s.service_instances)
38
40
  ]
39
41
  })
40
- else
41
- spaced(spaces) do |s|
42
- invoke :space, :space => s, :full => input[:full]
43
- end
44
42
  end
45
43
  end
46
44
 
@@ -1,12 +1,10 @@
1
- require "vmc/detect"
2
-
3
1
  require "vmc/cli/space/base"
4
2
 
5
3
  module VMC::Space
6
4
  class Take < Base
7
5
  desc "Switch to a space, creating it if it doesn't exist"
8
6
  group :spaces, :hidden => true
9
- input :name, :argument => true, :desc => "Space name"
7
+ input :name, :desc => "Space name", :argument => true
10
8
  def take_space
11
9
  if space = client.space_by_name(input[:name])
12
10
  invoke :target, :space => space
@@ -51,6 +51,8 @@ module VMC
51
51
 
52
52
  # switching org means switching space
53
53
  if changed_org || input.given?(:space) || !space_valid?(info[:space])
54
+ line if changed_org && !quiet?
55
+
54
56
  space = input[:space, org]
55
57
  return unless space
56
58
 
@@ -1,4 +1,3 @@
1
- require "vmc/detect"
2
1
  require "vmc/cli/start/base"
3
2
 
4
3
  module VMC::Start
@@ -1,19 +1,17 @@
1
- require "vmc/detect"
2
1
  require "vmc/cli/start/base"
3
2
 
4
3
  module VMC::Start
5
4
  class Info < Base
6
5
  desc "Display information on the current target, user, etc."
7
6
  group :start
8
- input :runtimes, :type => :boolean,
9
- :desc => "List supported runtimes"
10
- input :frameworks, :type => :boolean,
11
- :desc => "List supported frameworks"
12
- input :services, :type => :boolean,
13
- :desc => "List supported services"
14
- input :all, :type => :boolean, :alias => "-a",
15
- :desc => "Show all information"
16
-
7
+ input :runtimes, :desc => "List supported runtimes", :alias => "-r",
8
+ :default => false
9
+ input :frameworks, :desc => "List supported frameworks", :alias => "-f",
10
+ :default => false
11
+ input :services, :desc => "List supported services", :alias => "-s",
12
+ :default => false
13
+ input :all, :desc => "Show all information", :alias => "-a",
14
+ :default => false
17
15
  def info
18
16
  all = input[:all]
19
17