brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertgmoss <...@git.apache.org>
Subject [GitHub] brooklyn-client pull request: Adds support for Plugins
Date Tue, 26 Apr 2016 21:05:15 GMT
GitHub user robertgmoss opened a pull request:

    https://github.com/apache/brooklyn-client/pull/18

    Adds support for Plugins

    A sample plugin would look like this:
    
    ```go
    package main
    
    import (
    	"github.com/apache/brooklyn-client/plugin"
    	"fmt"
    	"strings"
    )
    
    type SamplePlugin struct {}
    
    func (c *SamplePlugin) Run(plugin plugin.Connection, args []string)  {
    	if args[0] == "sample-command" {
    		fmt.Println("Running the sample plugin")
    		out := plugin.CoreCommand(strings.Split("br apps", " ")...)
    		for i, e := range out {
    			fmt.Printf("%v %v\n", i, e)
    		}
    	}
    }
    
    func (c *SamplePlugin) GetMetadata() plugin.PluginMetadata {
    	return plugin.PluginMetadata{
    		Name: "SamplePlugin",
    		Commands: []plugin.Command{
    			plugin.Command{
    				Name: "sample-command",
    				Alias: "sc",
    				HelpText: "A Sample Command",
    				UsageDetails: plugin.Usage{
    					Usage: "sample-command\n br sample-command",
    				},
    			},
    		},
    	}
    }
    
    func main() {
    	plugin.Start(new(SamplePlugin))
    }
    ```
    
    which should be compiled with `go build`.  The resulting artifact should be installed
with `br install-plugin <artifact-location>`, which will copy the artifact to either
`$HOME` or `$BRCLI_HOME/plugins` if it is set; this location is required to on `$PATH` for
the plugin to be executed.    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/robertgmoss/brooklyn-client plugin-support

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-client/pull/18.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #18
    
----
commit 78030a2f4d896507e0d2ee6643dafbb925185947
Author: Robert Moss <robert.moss@cloudsoftcorp.com>
Date:   2016-04-26T20:49:35Z

    Adds support for Plugins

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message