14. community pluginを使う その3
communityの一覧経由でpluginを入れる
https://blog.starkandwayne.com/2015/03/04/installing-cloud-foundry-cli-plugins/
$ cf install-plugin Console -r community
Looking up 'Console' from repository 'community'
7974312 bytes downloaded...
Installing plugin /tmp/cf-plugin-console...
OK
Plugin Console successfully installed.
$ cf plugins
Listing Installed Plugins...
OK
Plugin name Version Command name Command Help
hoge 1.0.0 hoge cf hoge plugin
Console N/A console Start a live console
入れたいplugin名がConsoleの場合
※ -rで取得元のnameを入れる
16. Community plugin一覧 その1 (2015/5/6調べ)
Version Description
CLI-Recorder v1.0.1 Records and playbacks CLI commands.
Live Stats v1.0.0
Monitor CPU and Memory usage on an app
via the browser.
Console v1.0.0
Start a tmate session on an application
container
19. Community plugin一覧 その2 (2015/5/6調べ)
Version Description
Diego-Beta v1.3.0
Enables Diego-specific commands and
functionality
Open v1.10 Open app url in browser
autopilot v0.0.1
zero downtime deploy plugin for cf
applications
21. Community plugin一覧 その3 (2015/5/6調べ)
Version Description
Brooklyn v0.1.1
Interact with Service Broker for Apache
Brooklyn
kinaba-me-logs v0.3.0
Launches the Kibana UI (from kibana-me-
logs) for an application.
Buildpack
Usage
v1.0.0 Buildpack Usage
CF App Stack
Changer
v1.0.0
Allows admins to list and update
applications with outdated lucid64 stacks.
24. CF App Stack Changer
lucid64のstacksをcflinuxfs2に移行する為のplugin
◎ lucid64のアプリの確認
◎ stacks変更+restartが行える
https://github.com/simonleung8/cli-stack-changer
$ cf stack-list
Getting all apps with lucid64 stack...
OK
Total 14 found ...
name guid state
hogehoge 09d03ad3-24ee-44a1-8969-4abb3268aab6 STARTED
$ cf stack-change APP_NAME
25. Community plugin一覧 その4 (2015/5/6調べ)
Version Description
Targets v1.0.0 Easily manage multiple CF targets
Test User v0.0.1
Create a user and assign all possible
permissions, organisation and space are
created if they do not already exist as well.
If no organisation or space name are
specified then the default value of
'development' is used
cf-download v1.0.0
Plugin for downloading your application
contents after staging.
30. 実装する上で参考になるコード解説 2
https://github.com/cloudfoundry/cli/tree/master/plugin_examples/call_cli_cmd/main
func (c *CliCmd) GetMetadata() plugin.PluginMetadata {
return plugin.PluginMetadata{
Name: "CliCmd",
Version: plugin.VersionType{
Major: 1,
Minor: 1,
Build: 0,
},
Commands: []plugin.Command{
{
Name: "cli-command",
HelpText: "Command to call cli command. It passes all arguments
through to the command",
UsageDetails: plugin.Usage{
Usage: "cli-commandn cf cli-command CORE-
COMMAND",
},
},
},
}
}
GetMetadata()を定義しpluginの名前(uninstall時に利用するもの)や
コマンド名、およびバージョン定義を行う
31. 実装する上で参考になるコード解説 3
https://github.com/cloudfoundry/cli/tree/master/plugin_examples/call_cli_cmd/main
func (c *CliCmd) Run(cliConnection plugin.CliConnection, args []string) {
output, err := cliConnection.CliCommand(args[1:]...)
if err != nil {
fmt.Println("PLUGIN ERROR: Error from CliCommand: ", err)
}
fmt.Println("")
fmt.Println("---------- Command output from the plugin ----------")
for index, val := range output {
fmt.Println("#", index, " value: ", val)
}
fmt.Println("---------- FIN -----------")
}
Run()部分で実際に処理を行う ※以下は実際のソースのコメントアウト部分を除いたもの
cliConnection.CliCommand部分でpluginに渡ってきた引数を cliにそのまま渡す
32. 実装する上で参考になるコード解説 4
https://github.com/cloudfoundry/cli/tree/master/plugin_examples/call_cli_cmd/main
$ cf cli-command apps
Getting apps in org testOrg / space testSpace as admin...
OK
name requested state instances memory disk urls
aaa started ?/1 256M 1G aaa.10.244.0.34.xip.io
go started 1/1 256M 1G go.10.244.0.34.xip.io
dora started 1/1 256M 1G dora.10.244.0.34.xip.io
---------- Command output from the plugin ----------
# 0 value: Getting apps in org testOrg / space testSpace as admin...
# 1 value: OK
# 2 value:
# 3 value: name requested state instances memory disk urls
# 4 value: aaa started ?/1 256M 1G aaa.10.244.0.34.xip.io
# 5 value: go started 1/1 256M 1G go.10.244.0.34.xip.io
# 6 value: dora started 1/1 256M 1G dora.10.244.0.34.xip.io
---------- FIN -----------
cli-command pluginに値を渡した時の挙動
40. Credits
Special thanks to all the people who made and released
these awesome resources for free:
◎ Presentation template by SlidesCarnival
◎ Photographs by Unsplash & Death to the Stock Photo
(license)