jdc 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/LICENSE +1277 -24
  2. data/Rakefile +13 -0
  3. data/bin/jdc +12 -2
  4. data/lib/admin/README.md +15 -0
  5. data/lib/admin/curl.rb +60 -0
  6. data/lib/admin/guid.rb +89 -0
  7. data/lib/admin/plugin.rb +6 -0
  8. data/lib/admin/service_auth_token.rb +94 -0
  9. data/lib/admin/service_broker/add.rb +47 -0
  10. data/lib/admin/service_broker/service_brokers.rb +24 -0
  11. data/lib/admin/set_quota.rb +44 -0
  12. data/lib/console/README.md +8 -0
  13. data/lib/console/console.rb +187 -0
  14. data/lib/console/plugin.rb +33 -0
  15. data/lib/jdc/cli/app/app.rb +43 -0
  16. data/lib/jdc/cli/app/apps.rb +87 -0
  17. data/lib/jdc/cli/app/base.rb +72 -0
  18. data/lib/jdc/cli/app/delete.rb +95 -0
  19. data/lib/jdc/cli/app/deprecated.rb +11 -0
  20. data/lib/jdc/cli/app/env.rb +78 -0
  21. data/lib/jdc/cli/app/events.rb +45 -0
  22. data/lib/jdc/cli/app/files.rb +137 -0
  23. data/lib/jdc/cli/app/health.rb +26 -0
  24. data/lib/jdc/cli/app/instances.rb +53 -0
  25. data/lib/jdc/cli/app/logs.rb +76 -0
  26. data/lib/jdc/cli/app/push/create.rb +108 -0
  27. data/lib/jdc/cli/app/push/interactions.rb +86 -0
  28. data/lib/jdc/cli/app/push/sync.rb +57 -0
  29. data/lib/jdc/cli/app/push.rb +103 -0
  30. data/lib/jdc/cli/app/rename.rb +35 -0
  31. data/lib/jdc/cli/app/restart.rb +31 -0
  32. data/lib/jdc/cli/app/scale.rb +63 -0
  33. data/lib/jdc/cli/app/start.rb +161 -0
  34. data/lib/jdc/cli/app/stats.rb +67 -0
  35. data/lib/jdc/cli/app/stop.rb +27 -0
  36. data/lib/jdc/cli/domain/base.rb +9 -0
  37. data/lib/jdc/cli/domain/domains.rb +40 -0
  38. data/lib/jdc/cli/domain/map.rb +55 -0
  39. data/lib/jdc/cli/domain/unmap.rb +56 -0
  40. data/lib/jdc/cli/help.rb +15 -0
  41. data/lib/jdc/cli/interactive.rb +105 -0
  42. data/lib/jdc/cli/login_requirements.rb +15 -0
  43. data/lib/jdc/cli/organization/base.rb +14 -0
  44. data/lib/jdc/cli/organization/create.rb +37 -0
  45. data/lib/jdc/cli/organization/delete.rb +63 -0
  46. data/lib/jdc/cli/organization/org.rb +45 -0
  47. data/lib/jdc/cli/organization/orgs.rb +30 -0
  48. data/lib/jdc/cli/organization/rename.rb +37 -0
  49. data/lib/jdc/cli/populators/base.rb +16 -0
  50. data/lib/jdc/cli/populators/organization.rb +32 -0
  51. data/lib/jdc/cli/populators/populator_methods.rb +64 -0
  52. data/lib/jdc/cli/populators/space.rb +33 -0
  53. data/lib/jdc/cli/populators/target.rb +13 -0
  54. data/lib/jdc/cli/route/base.rb +9 -0
  55. data/lib/jdc/cli/route/delete.rb +28 -0
  56. data/lib/jdc/cli/route/map.rb +68 -0
  57. data/lib/jdc/cli/route/routes.rb +26 -0
  58. data/lib/jdc/cli/route/unmap.rb +56 -0
  59. data/lib/jdc/cli/service/base.rb +9 -0
  60. data/lib/jdc/cli/service/bind.rb +44 -0
  61. data/lib/jdc/cli/service/create.rb +159 -0
  62. data/lib/jdc/cli/service/delete.rb +83 -0
  63. data/lib/jdc/cli/service/rename.rb +36 -0
  64. data/lib/jdc/cli/service/service.rb +42 -0
  65. data/lib/jdc/cli/service/service_instance_helper.rb +99 -0
  66. data/lib/jdc/cli/service/services.rb +111 -0
  67. data/lib/jdc/cli/service/unbind.rb +37 -0
  68. data/lib/jdc/cli/space/base.rb +29 -0
  69. data/lib/jdc/cli/space/create.rb +67 -0
  70. data/lib/jdc/cli/space/delete.rb +56 -0
  71. data/lib/jdc/cli/space/rename.rb +38 -0
  72. data/lib/jdc/cli/space/space.rb +66 -0
  73. data/lib/jdc/cli/space/spaces.rb +57 -0
  74. data/lib/jdc/cli/space/switch.rb +19 -0
  75. data/lib/jdc/cli/start/base.rb +41 -0
  76. data/lib/jdc/cli/start/colors.rb +13 -0
  77. data/lib/jdc/cli/start/target.rb +50 -0
  78. data/lib/jdc/cli/start/target_prettifier.rb +17 -0
  79. data/lib/jdc/cli/start/targets.rb +16 -0
  80. data/lib/jdc/cli/user/base.rb +30 -0
  81. data/lib/jdc/cli/user/create.rb +52 -0
  82. data/lib/jdc/cli/user/passwd.rb +37 -0
  83. data/lib/jdc/cli/user/register.rb +43 -0
  84. data/lib/jdc/cli/user/users.rb +32 -0
  85. data/lib/jdc/cli.rb +544 -0
  86. data/lib/jdc/constants.rb +11 -0
  87. data/lib/jdc/errors.rb +19 -0
  88. data/lib/jdc/object_extensions.rb +15 -0
  89. data/lib/jdc/plugin.rb +56 -0
  90. data/lib/jdc/spacing.rb +89 -0
  91. data/lib/jdc/spec_helper.rb +1 -0
  92. data/lib/jdc/test_support.rb +6 -0
  93. data/lib/jdc/version.rb +3 -0
  94. data/lib/jdc.rb +15 -2
  95. data/lib/manifests/errors.rb +35 -0
  96. data/lib/manifests/loader/builder.rb +39 -0
  97. data/lib/manifests/loader/normalizer.rb +145 -0
  98. data/lib/manifests/loader/resolver.rb +79 -0
  99. data/lib/manifests/loader.rb +31 -0
  100. data/lib/manifests/manifests.rb +344 -0
  101. data/lib/manifests/plugin.rb +140 -0
  102. data/lib/micro/README.md +9 -0
  103. data/lib/micro/errors.rb +4 -0
  104. data/lib/{jdc → micro}/micro.rb +15 -15
  105. data/lib/micro/plugin.rb +197 -0
  106. data/lib/micro/switcher/base.rb +79 -0
  107. data/lib/{jdc/micro → micro}/switcher/darwin.rb +5 -3
  108. data/lib/{jdc/micro → micro}/switcher/dummy.rb +1 -1
  109. data/lib/micro/switcher/linux.rb +16 -0
  110. data/lib/{jdc/micro → micro}/switcher/windows.rb +5 -5
  111. data/lib/{jdc/micro → micro}/vmrun.rb +26 -19
  112. data/lib/tasks/gem_release.rake +42 -0
  113. data/lib/tunnel/README.md +29 -0
  114. data/{config → lib/tunnel/config}/clients.yml +2 -2
  115. data/lib/tunnel/helper-app/Gemfile +10 -0
  116. data/lib/tunnel/helper-app/Gemfile.lock +48 -0
  117. data/{caldecott_helper → lib/tunnel/helper-app}/server.rb +5 -5
  118. data/lib/tunnel/plugin.rb +183 -0
  119. data/lib/tunnel/tunnel.rb +295 -0
  120. metadata +319 -89
  121. data/README.md +0 -102
  122. data/config/micro/paths.yml +0 -22
  123. data/config/micro/refresh_ip.rb +0 -20
  124. data/lib/cli/commands/admin.rb +0 -58
  125. data/lib/cli/commands/apps.rb +0 -1129
  126. data/lib/cli/commands/base.rb +0 -228
  127. data/lib/cli/commands/manifest.rb +0 -56
  128. data/lib/cli/commands/micro.rb +0 -115
  129. data/lib/cli/commands/misc.rb +0 -126
  130. data/lib/cli/commands/services.rb +0 -178
  131. data/lib/cli/commands/user.rb +0 -14
  132. data/lib/cli/config.rb +0 -173
  133. data/lib/cli/console_helper.rb +0 -170
  134. data/lib/cli/core_ext.rb +0 -122
  135. data/lib/cli/errors.rb +0 -19
  136. data/lib/cli/frameworks.rb +0 -265
  137. data/lib/cli/manifest_helper.rb +0 -302
  138. data/lib/cli/runner.rb +0 -505
  139. data/lib/cli/services_helper.rb +0 -84
  140. data/lib/cli/tunnel_helper.rb +0 -332
  141. data/lib/cli/usage.rb +0 -86
  142. data/lib/cli/version.rb +0 -7
  143. data/lib/cli/zip_util.rb +0 -77
  144. data/lib/cli.rb +0 -53
  145. data/lib/jdc/client.rb +0 -457
  146. data/lib/jdc/const.rb +0 -25
  147. data/lib/jdc/micro/switcher/base.rb +0 -97
  148. data/lib/jdc/micro/switcher/linux.rb +0 -16
  149. data/lib/jdc/signature/version.rb +0 -27
  150. data/lib/jdc/signer.rb +0 -13
  151. data/lib/jdc/timer.rb +0 -12
@@ -0,0 +1,17 @@
1
+ class TargetPrettifier
2
+ def self.prettify(client, outputter)
3
+ outputter.line("Target Information (where will apps be pushed):")
4
+ outputter.line(" JDC instance: #{print_var(client.try(:target), outputter)} (API version: #{print_var(client.try(:version), outputter)})")
5
+ outputter.line(" user: #{print_var(client.try(:current_user).try(:email), outputter)}")
6
+ #outputter.line(" user: #{print_var(client.try(:current_user), outputter)}")
7
+ outputter.line(" target app space: #{print_var(client.try(:current_space).try(:name), outputter)} (org: #{print_var(client.try(:current_organization).try(:name), outputter)})")
8
+ end
9
+
10
+ def self.print_var(object_name, outputter)
11
+ if object_name
12
+ outputter.c(object_name, :good)
13
+ else
14
+ outputter.c('N/A', :bad)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ require "jdc/cli/start/base"
2
+
3
+ module JDC::Start
4
+ class Targets < Base
5
+ desc "List known targets."
6
+ group :start
7
+ def targets
8
+ targets_info.each do |target, _|
9
+ line target
10
+ # TODO: print org/space
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+
@@ -0,0 +1,30 @@
1
+ require "jdc/cli"
2
+
3
+ module JDC
4
+ module User
5
+ class Base < CLI
6
+ def precondition
7
+ check_key
8
+ #check_logged_in
9
+ end
10
+
11
+ private
12
+
13
+ def validate_password!(password)
14
+ validate_password_verified!(password)
15
+ validate_password_strength!(password)
16
+ end
17
+
18
+ def validate_password_verified!(password)
19
+ fail "Passwords do not match." unless force? || password == input[:verify]
20
+ end
21
+
22
+ def validate_password_strength!(password)
23
+ strength = client.base.password_score(password)
24
+ msg = "Your password strength is: #{strength}"
25
+ fail msg if strength == :weak
26
+ line msg
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,52 @@
1
+ require "jdc/cli/user/base"
2
+ =begin
3
+ module JDC::User
4
+ class Create < Base
5
+ desc "Create a user"
6
+ group :admin, :user
7
+ input :email, :desc => "User email", :argument => :optional
8
+ input :password, :desc => "User password"
9
+ input :verify, :desc => "Repeat password"
10
+ input :organization, :desc => "User organization",
11
+ :aliases => %w{--org -o},
12
+ :default => proc { client.current_organization },
13
+ :from_given => by_name(:organization)
14
+
15
+ def create_user
16
+ org = JDC::Populators::Organization.new(input).populate_and_save!
17
+ email = input[:email]
18
+ password = input[:password]
19
+
20
+ if !force? && password != input[:verify]
21
+ fail "Passwords don't match."
22
+ end
23
+
24
+ user = nil
25
+ with_progress("Creating user") do
26
+ user = client.register(email, password)
27
+ end
28
+
29
+ with_progress("Adding user to #{org.name}") do
30
+ user.audited_organizations = user.managed_organizations = user.organizations = [org]
31
+ user.update!
32
+ end
33
+ end
34
+
35
+ alias_command :add_user, :create_user
36
+
37
+ private
38
+
39
+ def ask_email
40
+ ask("Email")
41
+ end
42
+
43
+ def ask_password
44
+ ask("Password", :echo => "*", :forget => true)
45
+ end
46
+
47
+ def ask_verify
48
+ ask("Verify Password", :echo => "*", :forget => true)
49
+ end
50
+ end
51
+ end
52
+ =end
@@ -0,0 +1,37 @@
1
+ require "jdc/cli/user/base"
2
+ =begin
3
+ module JDC::User
4
+ class Passwd < Base
5
+ desc "Update the current user's password"
6
+ group :admin, :user
7
+ input :password, :desc => "Current password"
8
+ input :new_password, :desc => "New password"
9
+ input :verify, :desc => "Repeat new password"
10
+
11
+ def passwd
12
+ password = input[:password]
13
+ new_password = input[:new_password]
14
+
15
+ validate_password! new_password
16
+
17
+ with_progress("Changing password") do
18
+ client.current_user.change_password!(new_password, password)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def ask_password
25
+ ask("Current Password", :echo => "*", :forget => true)
26
+ end
27
+
28
+ def ask_new_password
29
+ ask("New Password", :echo => "*", :forget => true)
30
+ end
31
+
32
+ def ask_verify
33
+ ask("Verify Password", :echo => "*", :forget => true)
34
+ end
35
+ end
36
+ end
37
+ =end
@@ -0,0 +1,43 @@
1
+ require "jdc/cli/user/base"
2
+ =begin
3
+ module JDC::User
4
+ class Register < Base
5
+ def precondition; end
6
+
7
+ desc "Create a user and log in"
8
+ group :admin, :user
9
+ input :email, :desc => "Desired email", :argument => :optional
10
+ input :password, :desc => "Desired password"
11
+ input :verify, :desc => "Repeat password"
12
+ input :login, :desc => "Automatically log in?", :default => true
13
+ def register
14
+ email = input[:email]
15
+ password = input[:password]
16
+
17
+ validate_password!(password)
18
+
19
+ with_progress("Creating user") do
20
+ client.register(email, password)
21
+ end
22
+
23
+ if input[:login]
24
+ invoke :login, :username => email, :password => password
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def ask_email
31
+ ask("Email")
32
+ end
33
+
34
+ def ask_password
35
+ ask("Password", :echo => "*", :forget => true)
36
+ end
37
+
38
+ def ask_verify
39
+ ask("Confirm Password", :echo => "*", :forget => true)
40
+ end
41
+ end
42
+ end
43
+ =end
@@ -0,0 +1,32 @@
1
+ require "jdc/cli/user/base"
2
+
3
+ module JDC::User
4
+ class Users < Base
5
+ desc "List all users"
6
+ group :admin
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
+ private
19
+
20
+ def display_user(u)
21
+ if quiet?
22
+ puts u.email
23
+ else
24
+ line "#{c(u.email, :name)}:"
25
+
26
+ indented do
27
+ line "admin?: #{c(u.admin?, u.admin? ? :yes : :no)}"
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end