trucker-cli 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +1277 -0
- data/Rakefile +13 -0
- data/bin/truck +18 -0
- data/lib/admin/README.md +30 -0
- data/lib/admin/curl.rb +59 -0
- data/lib/admin/guid.rb +89 -0
- data/lib/admin/plugin.rb +8 -0
- data/lib/admin/service_auth_token.rb +93 -0
- data/lib/admin/service_broker/add.rb +54 -0
- data/lib/admin/service_broker/remove.rb +33 -0
- data/lib/admin/service_broker/service_brokers.rb +29 -0
- data/lib/admin/service_broker/update.rb +60 -0
- data/lib/admin/set_quota.rb +44 -0
- data/lib/cf.rb +14 -0
- data/lib/cf/cli.rb +495 -0
- data/lib/cf/cli/app/app.rb +43 -0
- data/lib/cf/cli/app/apps.rb +87 -0
- data/lib/cf/cli/app/base.rb +72 -0
- data/lib/cf/cli/app/delete.rb +95 -0
- data/lib/cf/cli/app/deprecated.rb +11 -0
- data/lib/cf/cli/app/env.rb +99 -0
- data/lib/cf/cli/app/events.rb +45 -0
- data/lib/cf/cli/app/files.rb +137 -0
- data/lib/cf/cli/app/health.rb +26 -0
- data/lib/cf/cli/app/instances.rb +53 -0
- data/lib/cf/cli/app/logs.rb +76 -0
- data/lib/cf/cli/app/push.rb +104 -0
- data/lib/cf/cli/app/push/create.rb +108 -0
- data/lib/cf/cli/app/push/interactions.rb +90 -0
- data/lib/cf/cli/app/push/sync.rb +57 -0
- data/lib/cf/cli/app/rename.rb +35 -0
- data/lib/cf/cli/app/restart.rb +31 -0
- data/lib/cf/cli/app/scale.rb +63 -0
- data/lib/cf/cli/app/start.rb +175 -0
- data/lib/cf/cli/app/stats.rb +66 -0
- data/lib/cf/cli/app/stop.rb +27 -0
- data/lib/cf/cli/domain/base.rb +9 -0
- data/lib/cf/cli/domain/domains.rb +40 -0
- data/lib/cf/cli/domain/map.rb +55 -0
- data/lib/cf/cli/domain/unmap.rb +56 -0
- data/lib/cf/cli/help.rb +15 -0
- data/lib/cf/cli/interactive.rb +104 -0
- data/lib/cf/cli/login_requirements.rb +13 -0
- data/lib/cf/cli/organization/base.rb +12 -0
- data/lib/cf/cli/organization/create.rb +36 -0
- data/lib/cf/cli/organization/delete.rb +61 -0
- data/lib/cf/cli/organization/org.rb +45 -0
- data/lib/cf/cli/organization/orgs.rb +30 -0
- data/lib/cf/cli/organization/rename.rb +36 -0
- data/lib/cf/cli/populators/base.rb +16 -0
- data/lib/cf/cli/populators/organization.rb +32 -0
- data/lib/cf/cli/populators/populator_methods.rb +64 -0
- data/lib/cf/cli/populators/space.rb +33 -0
- data/lib/cf/cli/populators/target.rb +14 -0
- data/lib/cf/cli/route/base.rb +9 -0
- data/lib/cf/cli/route/delete.rb +28 -0
- data/lib/cf/cli/route/map.rb +68 -0
- data/lib/cf/cli/route/routes.rb +26 -0
- data/lib/cf/cli/route/unmap.rb +56 -0
- data/lib/cf/cli/service/base.rb +9 -0
- data/lib/cf/cli/service/bind.rb +43 -0
- data/lib/cf/cli/service/create.rb +158 -0
- data/lib/cf/cli/service/delete.rb +82 -0
- data/lib/cf/cli/service/rename.rb +35 -0
- data/lib/cf/cli/service/service.rb +40 -0
- data/lib/cf/cli/service/service_helper.rb +25 -0
- data/lib/cf/cli/service/service_instance_helper.rb +100 -0
- data/lib/cf/cli/service/services.rb +110 -0
- data/lib/cf/cli/service/unbind.rb +36 -0
- data/lib/cf/cli/space/base.rb +27 -0
- data/lib/cf/cli/space/create.rb +66 -0
- data/lib/cf/cli/space/delete.rb +55 -0
- data/lib/cf/cli/space/rename.rb +38 -0
- data/lib/cf/cli/space/space.rb +66 -0
- data/lib/cf/cli/space/spaces.rb +57 -0
- data/lib/cf/cli/space/switch.rb +18 -0
- data/lib/cf/cli/start/base.rb +35 -0
- data/lib/cf/cli/start/colors.rb +13 -0
- data/lib/cf/cli/start/login.rb +104 -0
- data/lib/cf/cli/start/logout.rb +17 -0
- data/lib/cf/cli/start/target.rb +50 -0
- data/lib/cf/cli/start/target_prettifier.rb +35 -0
- data/lib/cf/cli/start/targets.rb +16 -0
- data/lib/cf/cli/user/base.rb +29 -0
- data/lib/cf/cli/user/create.rb +51 -0
- data/lib/cf/cli/user/passwd.rb +36 -0
- data/lib/cf/cli/user/register.rb +42 -0
- data/lib/cf/cli/user/users.rb +32 -0
- data/lib/cf/constants.rb +10 -0
- data/lib/cf/errors.rb +19 -0
- data/lib/cf/plugin.rb +56 -0
- data/lib/cf/spacing.rb +89 -0
- data/lib/cf/spec_helper.rb +1 -0
- data/lib/cf/test_support.rb +6 -0
- data/lib/cf/version.rb +3 -0
- data/lib/console/README.md +16 -0
- data/lib/console/console.rb +187 -0
- data/lib/console/plugin.rb +32 -0
- data/lib/manifests/errors.rb +35 -0
- data/lib/manifests/loader.rb +31 -0
- data/lib/manifests/loader/builder.rb +39 -0
- data/lib/manifests/loader/normalizer.rb +145 -0
- data/lib/manifests/loader/resolver.rb +79 -0
- data/lib/manifests/manifests.rb +343 -0
- data/lib/manifests/plugin.rb +140 -0
- data/lib/micro/README.md +25 -0
- data/lib/micro/errors.rb +4 -0
- data/lib/micro/micro.rb +56 -0
- data/lib/micro/plugin.rb +197 -0
- data/lib/micro/switcher/base.rb +79 -0
- data/lib/micro/switcher/darwin.rb +21 -0
- data/lib/micro/switcher/dummy.rb +15 -0
- data/lib/micro/switcher/linux.rb +16 -0
- data/lib/micro/switcher/windows.rb +31 -0
- data/lib/micro/vmrun.rb +175 -0
- data/lib/tasks/gem_release.rake +56 -0
- data/lib/tasks/windows_build.rake +14 -0
- data/lib/tunnel/README.md +29 -0
- data/lib/tunnel/config/clients.yml +17 -0
- data/lib/tunnel/helper-app/Gemfile +10 -0
- data/lib/tunnel/helper-app/Gemfile.lock +48 -0
- data/lib/tunnel/helper-app/server.rb +43 -0
- data/lib/tunnel/plugin.rb +183 -0
- data/lib/tunnel/tunnel.rb +295 -0
- data/spec/admin/curl_spec.rb +52 -0
- data/spec/admin/guid_spec.rb +85 -0
- data/spec/admin/service_broker/add_spec.rb +64 -0
- data/spec/admin/service_broker/remove_spec.rb +46 -0
- data/spec/admin/service_broker/service_brokers_spec.rb +34 -0
- data/spec/admin/service_broker/update_spec.rb +51 -0
- data/spec/admin/set_quota_spec.rb +89 -0
- data/spec/assets/env/Gemfile +4 -0
- data/spec/assets/env/Gemfile.lock +20 -0
- data/spec/assets/env/env_test.rb +58 -0
- data/spec/assets/hello-sinatra/Gemfile +3 -0
- data/spec/assets/hello-sinatra/Gemfile.lock +17 -0
- data/spec/assets/hello-sinatra/config.ru +3 -0
- data/spec/assets/hello-sinatra/fat-cat-makes-app-larger.png +0 -0
- data/spec/assets/hello-sinatra/main.rb +8 -0
- data/spec/assets/rails328_ruby187_app/Gemfile +39 -0
- data/spec/assets/rails328_ruby187_app/README.rdoc +261 -0
- data/spec/assets/rails328_ruby187_app/Rakefile +7 -0
- data/spec/assets/rails328_ruby187_app/app/assets/images/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/app/assets/javascripts/application.js +15 -0
- data/spec/assets/rails328_ruby187_app/app/assets/stylesheets/application.css +13 -0
- data/spec/assets/rails328_ruby187_app/app/controllers/application_controller.rb +3 -0
- data/spec/assets/rails328_ruby187_app/app/helpers/application_helper.rb +2 -0
- data/spec/assets/rails328_ruby187_app/app/views/layouts/application.html.erb +14 -0
- data/spec/assets/rails328_ruby187_app/config.ru +4 -0
- data/spec/assets/rails328_ruby187_app/config/application.rb +62 -0
- data/spec/assets/rails328_ruby187_app/config/boot.rb +6 -0
- data/spec/assets/rails328_ruby187_app/config/database.yml +25 -0
- data/spec/assets/rails328_ruby187_app/config/environment.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/environments/development.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/environments/production.rb +67 -0
- data/spec/assets/rails328_ruby187_app/config/environments/test.rb +37 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/inflections.rb +15 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/mime_types.rb +5 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/secret_token.rb +7 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/session_store.rb +8 -0
- data/spec/assets/rails328_ruby187_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/assets/rails328_ruby187_app/config/locales/en.yml +5 -0
- data/spec/assets/rails328_ruby187_app/config/routes.rb +58 -0
- data/spec/assets/rails328_ruby187_app/db/seeds.rb +7 -0
- data/spec/assets/rails328_ruby187_app/doc/README_FOR_APP +2 -0
- data/spec/assets/rails328_ruby187_app/manifest.yml +7 -0
- data/spec/assets/rails328_ruby187_app/public/404.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/422.html +26 -0
- data/spec/assets/rails328_ruby187_app/public/500.html +25 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-7270767b2a9e9fff880aa5de378ca791.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application-ccab98dc1abdf097c0af693e20aed861.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.css.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js +17 -0
- data/spec/assets/rails328_ruby187_app/public/assets/application.js.gz +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/manifest.yml +4 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails-be8732dac73d845ac5b142c8fb5f9fb0.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/assets/rails.png +0 -0
- data/spec/assets/rails328_ruby187_app/public/favicon.ico +0 -0
- data/spec/assets/rails328_ruby187_app/public/index.html +241 -0
- data/spec/assets/rails328_ruby187_app/public/robots.txt +5 -0
- data/spec/assets/rails328_ruby187_app/script/rails +6 -0
- data/spec/assets/rails328_ruby187_app/test/performance/browsing_test.rb +12 -0
- data/spec/assets/rails328_ruby187_app/test/test_helper.rb +13 -0
- data/spec/cf/cli/app/base_spec.rb +17 -0
- data/spec/cf/cli/app/delete_spec.rb +197 -0
- data/spec/cf/cli/app/env_spec.rb +261 -0
- data/spec/cf/cli/app/events_spec.rb +72 -0
- data/spec/cf/cli/app/help_spec.rb +39 -0
- data/spec/cf/cli/app/instances_spec.rb +69 -0
- data/spec/cf/cli/app/push/create_spec.rb +444 -0
- data/spec/cf/cli/app/push/interactions_spec.rb +32 -0
- data/spec/cf/cli/app/push_spec.rb +332 -0
- data/spec/cf/cli/app/rename_spec.rb +108 -0
- data/spec/cf/cli/app/restart_spec.rb +47 -0
- data/spec/cf/cli/app/scale_spec.rb +63 -0
- data/spec/cf/cli/app/start_spec.rb +255 -0
- data/spec/cf/cli/app/stats_spec.rb +66 -0
- data/spec/cf/cli/domain/help_spec.rb +39 -0
- data/spec/cf/cli/domain/map_spec.rb +140 -0
- data/spec/cf/cli/domain/unmap_spec.rb +77 -0
- data/spec/cf/cli/help_spec.rb +21 -0
- data/spec/cf/cli/organization/create_spec.rb +121 -0
- data/spec/cf/cli/organization/delete_spec.rb +105 -0
- data/spec/cf/cli/organization/help_spec.rb +39 -0
- data/spec/cf/cli/organization/orgs_spec.rb +116 -0
- data/spec/cf/cli/organization/rename_spec.rb +116 -0
- data/spec/cf/cli/populators/organization_spec.rb +179 -0
- data/spec/cf/cli/populators/space_spec.rb +156 -0
- data/spec/cf/cli/populators/target_spec.rb +39 -0
- data/spec/cf/cli/route/delete_spec.rb +92 -0
- data/spec/cf/cli/route/help_spec.rb +32 -0
- data/spec/cf/cli/route/map_spec.rb +148 -0
- data/spec/cf/cli/route/unmap_spec.rb +114 -0
- data/spec/cf/cli/service/bind_spec.rb +25 -0
- data/spec/cf/cli/service/create_spec.rb +147 -0
- data/spec/cf/cli/service/delete_spec.rb +22 -0
- data/spec/cf/cli/service/help_spec.rb +39 -0
- data/spec/cf/cli/service/rename_spec.rb +103 -0
- data/spec/cf/cli/service/service_helper_spec.rb +66 -0
- data/spec/cf/cli/service/service_instance_helper_spec.rb +155 -0
- data/spec/cf/cli/service/service_spec.rb +23 -0
- data/spec/cf/cli/service/services_spec.rb +156 -0
- data/spec/cf/cli/service/unbind_spec.rb +25 -0
- data/spec/cf/cli/space/base_spec.rb +49 -0
- data/spec/cf/cli/space/create_spec.rb +144 -0
- data/spec/cf/cli/space/delete_spec.rb +109 -0
- data/spec/cf/cli/space/help_spec.rb +39 -0
- data/spec/cf/cli/space/rename_spec.rb +110 -0
- data/spec/cf/cli/space/space_spec.rb +80 -0
- data/spec/cf/cli/space/spaces_spec.rb +107 -0
- data/spec/cf/cli/space/switch_space_spec.rb +57 -0
- data/spec/cf/cli/start/help_spec.rb +39 -0
- data/spec/cf/cli/start/login_spec.rb +142 -0
- data/spec/cf/cli/start/logout_spec.rb +49 -0
- data/spec/cf/cli/start/target_prettifier_spec.rb +78 -0
- data/spec/cf/cli/start/target_spec.rb +123 -0
- data/spec/cf/cli/user/create_spec.rb +98 -0
- data/spec/cf/cli/user/help_spec.rb +32 -0
- data/spec/cf/cli/user/passwd_spec.rb +94 -0
- data/spec/cf/cli/user/register_spec.rb +145 -0
- data/spec/cf/cli_spec.rb +474 -0
- data/spec/console/console_spec.rb +189 -0
- data/spec/factories/cfoundry/v2/apps_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/clients_factory.rb +7 -0
- data/spec/factories/cfoundry/v2/domains_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/managed_service_instances_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/organizations_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/quota_definitions.rb +13 -0
- data/spec/factories/cfoundry/v2/routes_factory.rb +8 -0
- data/spec/factories/cfoundry/v2/service_bindings_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_brokers_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/service_plans_factory.rb +17 -0
- data/spec/factories/cfoundry/v2/services_factory.rb +14 -0
- data/spec/factories/cfoundry/v2/spaces_factory.rb +13 -0
- data/spec/factories/cfoundry/v2/stacks_factory.rb +11 -0
- data/spec/factories/cfoundry/v2/user_provided_service_instances_factory.rb +12 -0
- data/spec/factories/cfoundry/v2/users_factory.rb +7 -0
- data/spec/features/backspace_spec.rb +46 -0
- data/spec/features/create_user_spec.rb +74 -0
- data/spec/features/delete_orphaned_service_spec.rb +64 -0
- data/spec/features/login_spec.rb +65 -0
- data/spec/features/manifests_spec.rb +86 -0
- data/spec/features/org_spec.rb +50 -0
- data/spec/features/push_flow_spec.rb +169 -0
- data/spec/features/service_brokers_spec.rb +173 -0
- data/spec/features/services_spec.rb +122 -0
- data/spec/features/space_spec.rb +107 -0
- data/spec/features/switching_targets_spec.rb +70 -0
- data/spec/manifests/errors_spec.rb +43 -0
- data/spec/manifests/loader/builder_spec.rb +80 -0
- data/spec/manifests/loader/normalizer_spec.rb +158 -0
- data/spec/manifests/manifests_spec.rb +335 -0
- data/spec/manifests/plugin_spec.rb +410 -0
- data/spec/micro/plugin_spec.rb +64 -0
- data/spec/spec_helper.rb +69 -0
- data/spec/support/cli_helper.rb +87 -0
- data/spec/support/config_helper.rb +15 -0
- data/spec/support/factory_girl.rb +6 -0
- data/spec/support/fake_home_dir.rb +55 -0
- data/spec/support/features_helper.rb +99 -0
- data/spec/support/interact_helper.rb +27 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/mock_commands/mock_restart.rb +16 -0
- data/spec/support/mock_commands/mock_start.rb +17 -0
- data/spec/support/shared_examples/errors.rb +40 -0
- data/spec/support/shared_examples/input.rb +14 -0
- data/spec/tunnel/plugin_spec.rb +31 -0
- data/spec/tunnel/tunnel_spec.rb +54 -0
- metadata +814 -0
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
Dir.glob("lib/tasks/**/*").sort.each { |ext| load(ext) }
|
4
|
+
|
5
|
+
specfile, _ = Dir["*.gemspec"]
|
6
|
+
SPEC = Gem::Specification.load(specfile)
|
7
|
+
CURRENT_VERSION = SPEC.version.to_s.freeze
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
|
+
task :default => :spec
|
11
|
+
|
12
|
+
# looking for a way to push gems? check out the new frontend-release git repo!
|
13
|
+
# git@github.com:pivotal-vmware/frontend-release.git
|
data/bin/truck
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# vim: ft=ruby
|
3
|
+
libdir = File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
|
4
|
+
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
5
|
+
|
6
|
+
require "rubygems"
|
7
|
+
|
8
|
+
require "cf"
|
9
|
+
require "cf/plugin"
|
10
|
+
|
11
|
+
$stdout.sync = true
|
12
|
+
|
13
|
+
CF::Plugin.load_all
|
14
|
+
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new("1.9.3")
|
15
|
+
warn "ERROR: \033[31mRuby version #{RUBY_VERSION} is not supported.\033[0m Please install 1.9.3 or later."
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
CF::CLI.start(ARGV)
|
data/lib/admin/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/cloudfoundry/admin-cf-plugin.png)](https://travis-ci.org/cloudfoundry/admin-cf-plugin)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/admin-cf-plugin.png)](http://badge.fury.io/rb/admin-cf-plugin)
|
3
|
+
|
4
|
+
## Admin
|
5
|
+
### Info
|
6
|
+
This plugin allows you to make manual HTTP requests to the Cloud Foundry REST API.
|
7
|
+
|
8
|
+
### Installation
|
9
|
+
|
10
|
+
If you have installed CF via gem install, use:
|
11
|
+
```
|
12
|
+
gem install admin-cf-plugin
|
13
|
+
```
|
14
|
+
|
15
|
+
If you have installed CF through bundler and the Gemfile, add the following to your Gemfile:
|
16
|
+
```
|
17
|
+
gem "admin-cf-plugin"
|
18
|
+
```
|
19
|
+
|
20
|
+
### Usage
|
21
|
+
|
22
|
+
```
|
23
|
+
curl MODE PATH HEADERS... Execute a raw request
|
24
|
+
guid TYPE [NAME] Obtain guid of an object(s)
|
25
|
+
set-quota [QUOTA_DEFINITION] [ORGANIZATION] Change the quota definition for the given (or current) organization.
|
26
|
+
service-auth-tokens List service auth tokens
|
27
|
+
create-service-auth-token [LABEL] [PROVIDER] Create a service auth token
|
28
|
+
update-service-auth-token [SERVICE_AUTH_TOKEN] Update a service auth token
|
29
|
+
delete-service-auth-token [SERVICE_AUTH_TOKEN] Delete a service auth token
|
30
|
+
```
|
data/lib/admin/curl.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "multi_json"
|
2
|
+
|
3
|
+
require "cf/cli"
|
4
|
+
|
5
|
+
module CFAdmin
|
6
|
+
class Curl < CF::CLI
|
7
|
+
def precondition
|
8
|
+
check_target
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Execute a raw request"
|
12
|
+
group :admin
|
13
|
+
input :mode, :argument => :required, :desc => "Request mode (Get/Put/etc.)"
|
14
|
+
input :path, :argument => :required, :desc => "Request path"
|
15
|
+
input :headers, :argument => :splat, :desc => "Headers (i.e. Foo: bar)"
|
16
|
+
input :body, :alias => "-b", :desc => "Request body"
|
17
|
+
def curl
|
18
|
+
mode = input[:mode].upcase
|
19
|
+
path = input[:path]
|
20
|
+
body = input[:body]
|
21
|
+
|
22
|
+
headers = {}
|
23
|
+
input[:headers].each do |h|
|
24
|
+
k, v = h.split(/\s*:\s*/, 2)
|
25
|
+
headers[k.downcase] = v
|
26
|
+
end
|
27
|
+
|
28
|
+
content = headers["content-type"]
|
29
|
+
accept = headers["accept"]
|
30
|
+
|
31
|
+
content ||= :json if body
|
32
|
+
accept ||= :json unless %w(DELETE HEAD).include?(mode)
|
33
|
+
|
34
|
+
req, res =
|
35
|
+
client.base.rest_client.request(
|
36
|
+
mode,
|
37
|
+
remove_leading_slash(path),
|
38
|
+
:headers => headers,
|
39
|
+
:accept => accept,
|
40
|
+
:payload => body,
|
41
|
+
:content => body && content)
|
42
|
+
|
43
|
+
body = res[:body]
|
44
|
+
|
45
|
+
type = res[:headers]["content-type"]
|
46
|
+
|
47
|
+
if type && type.include?("application/json")
|
48
|
+
json = MultiJson.load(body)
|
49
|
+
puts MultiJson.dump(json, :pretty => true)
|
50
|
+
else
|
51
|
+
puts body
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def remove_leading_slash(path)
|
56
|
+
path.sub(%r{^/}, '')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/lib/admin/guid.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
|
3
|
+
module CFAdmin
|
4
|
+
class Guid < CF::CLI
|
5
|
+
def precondition
|
6
|
+
check_target
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Obtain guid of an object(s)"
|
10
|
+
group :admin
|
11
|
+
input :type, :argument => :required, :desc => "Object type (e.g. org, space, app, domain, ...)"
|
12
|
+
input :name, :argument => :optional, :desc => "Object name (e.g. some-app, ...)"
|
13
|
+
def guid
|
14
|
+
type = expand_type(input[:type])
|
15
|
+
name = input[:name]
|
16
|
+
|
17
|
+
_, res = client.base.rest_client.request("GET", api_path(type, name))
|
18
|
+
|
19
|
+
puts "Listing #{type} for '#{name}'...\n\n"
|
20
|
+
puts_response(res[:body])
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def api_path(type, name)
|
26
|
+
"".tap do |url|
|
27
|
+
url << "v2/#{type}?"
|
28
|
+
url << "q=name:#{name}" if name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
EXPANDED_TYPES = %w(
|
33
|
+
organizations
|
34
|
+
spaces
|
35
|
+
domains
|
36
|
+
routes
|
37
|
+
apps
|
38
|
+
services
|
39
|
+
service_instances
|
40
|
+
users
|
41
|
+
)
|
42
|
+
|
43
|
+
def expand_type(type)
|
44
|
+
EXPANDED_TYPES.detect do |expanded_type|
|
45
|
+
expanded_type.start_with?(type)
|
46
|
+
end || type
|
47
|
+
end
|
48
|
+
|
49
|
+
def puts_response(body)
|
50
|
+
# passing nil to load causes segfault
|
51
|
+
hash = MultiJson.load(body || "{}") rescue {}
|
52
|
+
|
53
|
+
puts_pagination(*hash.values_at("total_results", "total_pages"))
|
54
|
+
puts_resources(hash["resources"])
|
55
|
+
end
|
56
|
+
|
57
|
+
def puts_pagination(results, pages)
|
58
|
+
if results.nil?
|
59
|
+
puts "Unexpected response."
|
60
|
+
elsif results == 0
|
61
|
+
puts "No results."
|
62
|
+
else
|
63
|
+
puts "Found #{results} results on #{pages} pages. First page:"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def puts_resources(resources)
|
68
|
+
resources ||= []
|
69
|
+
|
70
|
+
sorted_resources = \
|
71
|
+
resources.sort_by { |r| [r["entity"]["name"].downcase] }
|
72
|
+
|
73
|
+
max_name_size = \
|
74
|
+
resources.map { |r| r["entity"]["name"].size }.max
|
75
|
+
|
76
|
+
sorted_resources.each_with_index do |resource, i|
|
77
|
+
puts_resource(resource, :max_name_size => max_name_size)
|
78
|
+
puts "---" if i % 3 == 2
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def puts_resource(resource, opts={})
|
83
|
+
puts [
|
84
|
+
resource["entity"]["name"].ljust(opts[:max_name_size] + 2),
|
85
|
+
resource["metadata"]["guid"],
|
86
|
+
].join
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/admin/plugin.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require "admin/curl"
|
2
|
+
require "admin/guid"
|
3
|
+
require "admin/set_quota"
|
4
|
+
require "admin/service_auth_token"
|
5
|
+
require "admin/service_broker/add"
|
6
|
+
require "admin/service_broker/remove"
|
7
|
+
require "admin/service_broker/service_brokers"
|
8
|
+
require "admin/service_broker/update"
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
|
3
|
+
module CFAdmin
|
4
|
+
class ServiceAuthToken < CF::CLI
|
5
|
+
def precondition
|
6
|
+
unless File.exists? target_file
|
7
|
+
fail "Please select a target with 'truck target'."
|
8
|
+
end
|
9
|
+
|
10
|
+
unless client.logged_in?
|
11
|
+
fail "Please log in with 'truck login'."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
desc "List service auth tokens"
|
17
|
+
group :admin
|
18
|
+
def service_auth_tokens
|
19
|
+
spaced(client.service_auth_tokens) do |t|
|
20
|
+
line "#{c(t.label, :name)}:"
|
21
|
+
|
22
|
+
indented do
|
23
|
+
line "guid: #{t.guid}"
|
24
|
+
line "provider: #{t.provider}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
desc "Create a service auth token"
|
31
|
+
group :admin
|
32
|
+
input(:label, :argument => :optional, :desc => "Auth token label") {
|
33
|
+
ask("Label")
|
34
|
+
}
|
35
|
+
input :provider, :argument => :optional, :default => "core",
|
36
|
+
:desc => "Auth token provider"
|
37
|
+
input(:token, :desc => "Auth token value") {
|
38
|
+
ask("Token")
|
39
|
+
}
|
40
|
+
def create_service_auth_token
|
41
|
+
sat = client.service_auth_token
|
42
|
+
sat.label = input[:label]
|
43
|
+
sat.provider = input[:provider]
|
44
|
+
sat.token = input[:token]
|
45
|
+
|
46
|
+
with_progress("Creating service auth token") do
|
47
|
+
sat.create!
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
desc "Update a service auth token"
|
53
|
+
group :admin
|
54
|
+
input(:service_auth_token, :argument => :optional,
|
55
|
+
:from_given => proc { |guid| client.service_auth_token(guid) },
|
56
|
+
:desc => "Auth token to delete") {
|
57
|
+
tokens = client.service_auth_tokens
|
58
|
+
fail "No tokens!" if tokens.empty?
|
59
|
+
|
60
|
+
ask("Which token?", :choices => tokens, :display => proc(&:label))
|
61
|
+
}
|
62
|
+
input(:token, :desc => "Auth token value") {
|
63
|
+
ask("Token")
|
64
|
+
}
|
65
|
+
def update_service_auth_token
|
66
|
+
sat = input[:service_auth_token]
|
67
|
+
sat.token = input[:token]
|
68
|
+
|
69
|
+
with_progress("Updating token #{c(sat.label, :name)}") do
|
70
|
+
sat.update!
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
desc "Delete a service auth token"
|
76
|
+
group :admin
|
77
|
+
input(:service_auth_token, :argument => :optional,
|
78
|
+
:from_given => proc { |guid| client.service_auth_token(guid) },
|
79
|
+
:desc => "Auth token to delete") {
|
80
|
+
tokens = client.service_auth_tokens
|
81
|
+
fail "No tokens!" if tokens.empty?
|
82
|
+
|
83
|
+
ask("Which token?", :choices => tokens, :display => proc(&:label))
|
84
|
+
}
|
85
|
+
def delete_service_auth_token
|
86
|
+
sat = input[:service_auth_token]
|
87
|
+
|
88
|
+
with_progress("Deleting token #{c(sat.label, :name)}") do
|
89
|
+
sat.delete!
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
|
3
|
+
module CFAdmin::ServiceBroker
|
4
|
+
class Add < CF::CLI
|
5
|
+
def precondition
|
6
|
+
check_target
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Add a service broker"
|
10
|
+
group :admin
|
11
|
+
input :name, :argument => :optional,
|
12
|
+
:desc => "Broker name"
|
13
|
+
input :url,
|
14
|
+
:desc => "Broker URL"
|
15
|
+
input :username,
|
16
|
+
:desc => "Broker basic authentication username"
|
17
|
+
input :password,
|
18
|
+
:desc => "Broker basic authentication password"
|
19
|
+
|
20
|
+
def add_service_broker
|
21
|
+
broker = client.service_broker
|
22
|
+
|
23
|
+
broker.name = input[:name]
|
24
|
+
finalize
|
25
|
+
broker.broker_url = input[:url]
|
26
|
+
finalize
|
27
|
+
broker.auth_username = input[:username]
|
28
|
+
finalize
|
29
|
+
broker.auth_password = input[:password]
|
30
|
+
finalize
|
31
|
+
|
32
|
+
with_progress("Adding service broker #{c(broker.name, :name)}") do
|
33
|
+
broker.create!
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
def ask_name
|
39
|
+
ask("Name")
|
40
|
+
end
|
41
|
+
|
42
|
+
def ask_url
|
43
|
+
ask("URL")
|
44
|
+
end
|
45
|
+
|
46
|
+
def ask_username
|
47
|
+
ask("Username")
|
48
|
+
end
|
49
|
+
|
50
|
+
def ask_password
|
51
|
+
ask("Password")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
|
3
|
+
module CFAdmin::ServiceBroker
|
4
|
+
class Remove < CF::CLI
|
5
|
+
def precondition
|
6
|
+
check_target
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Remove a service broker"
|
10
|
+
group :admin
|
11
|
+
input :name, :argument => :required,
|
12
|
+
:desc => "Service broker to remove",
|
13
|
+
:from_given => by_name(:service_broker)
|
14
|
+
input :really, :type => :boolean, :forget => true, :hidden => true,
|
15
|
+
:default => proc { force? || interact }
|
16
|
+
|
17
|
+
def remove_service_broker
|
18
|
+
broker = input[:name]
|
19
|
+
return unless input[:really, broker]
|
20
|
+
|
21
|
+
with_progress("Removing service broker #{c(broker.name, :name)}") do
|
22
|
+
broker.delete!
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def ask_really(broker)
|
29
|
+
ask("Really remove #{c(broker.name, :name)}?", :default => false)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
|
3
|
+
module CFAdmin::ServiceBroker
|
4
|
+
class ServiceBrokers < CF::CLI
|
5
|
+
def precondition
|
6
|
+
check_target
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "List registered service brokers"
|
10
|
+
group :admin
|
11
|
+
|
12
|
+
def service_brokers
|
13
|
+
brokers = nil
|
14
|
+
with_progress('Getting service brokers') do
|
15
|
+
brokers = client.service_brokers
|
16
|
+
end
|
17
|
+
|
18
|
+
line unless quiet?
|
19
|
+
|
20
|
+
table(
|
21
|
+
%w(Name URL),
|
22
|
+
brokers.collect { |broker|
|
23
|
+
[c(broker.name, :name), broker.broker_url]
|
24
|
+
}
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
|
3
|
+
module CFAdmin::ServiceBroker
|
4
|
+
class Update < CF::CLI
|
5
|
+
def precondition
|
6
|
+
check_target
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Update a service broker"
|
10
|
+
group :admin
|
11
|
+
input :broker, :argument => :required,
|
12
|
+
:desc => "Service broker to update",
|
13
|
+
:from_given => by_name(:service_broker, 'service broker')
|
14
|
+
input :name, :argument => :optional,
|
15
|
+
:desc => "New name"
|
16
|
+
input :url,
|
17
|
+
:desc => "New URL"
|
18
|
+
input :username,
|
19
|
+
:desc => "New basic authentication username"
|
20
|
+
input :password,
|
21
|
+
:desc => "New basic authentication password"
|
22
|
+
|
23
|
+
def update_service_broker
|
24
|
+
@broker = input[:broker]
|
25
|
+
|
26
|
+
old_name = @broker.name
|
27
|
+
|
28
|
+
@broker.name = input[:name]
|
29
|
+
finalize
|
30
|
+
@broker.broker_url = input[:url]
|
31
|
+
finalize
|
32
|
+
@broker.auth_username = input[:username]
|
33
|
+
finalize
|
34
|
+
@broker.auth_password = input[:password]
|
35
|
+
finalize
|
36
|
+
|
37
|
+
with_progress("Updating service broker #{old_name}") do
|
38
|
+
@broker.update!
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def ask_name
|
45
|
+
ask("Name", :default => @broker.name)
|
46
|
+
end
|
47
|
+
|
48
|
+
def ask_url
|
49
|
+
ask("URL", :default => @broker.broker_url)
|
50
|
+
end
|
51
|
+
|
52
|
+
def ask_username
|
53
|
+
ask("Username", :default => @broker.auth_username)
|
54
|
+
end
|
55
|
+
|
56
|
+
def ask_password
|
57
|
+
ask("Password", :default => @broker.auth_password)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|