Need advice on my juju plugin

Adam Stokes adam.stokes at ubuntu.com
Wed Apr 22 14:55:59 UTC 2015


Writing a plugin in Go and attempting to re-create what a normal 'juju run'
would do

Here is my code:

https://github.com/battlemidget/juju-learnyouaplugin/blob/master/main.go

However, running it produces:

> juju lyaplugin --machine 1  "ls /"
                                          master [9d8856f]
2015-04-22 14:52:27 INFO juju.api api.go:280 connecting to API addresses:
[localhost:17070 10.0.3.1:17070 192.168.0.100:17070 192.168.122.1:17070]
2015-04-22 14:52:27 INFO juju.api apiclient.go:331 dialing
"wss://localhost:17070/environment/70815eb1-b324-4555-897e-fdd0ce0030a5/api"
2015-04-22 14:52:27 INFO juju.api apiclient.go:263 connection established
to
"wss://localhost:17070/environment/70815eb1-b324-4555-897e-fdd0ce0030a5/api"
2015-04-22 14:52:28 INFO juju.plugin.lyaplugin main.go:86 Running cmd: ls /
on machine: 1
2015-04-22 14:52:28 INFO juju.plugin.lyaplugin main.go:99 Run result: (0)
() ()

Where as `juju run --machine 1 "ls /"` shows the root level directories.

Any insight on what I'm missing is appreciated. Another note is I'm not
quite sure if there is an alternative to getting the current running
environment other than doing a `juju switch local` then running the plugin
pulling in envcmd.GetDefaultEnvironment, seen here:

https://github.com/battlemidget/juju-learnyouaplugin/blob/master/main.go#L73

This plugin is for learning purposes and I plan on writing an article for
others to write their own plugins so any best
practices/recommendations/feedback on this is welcomed!

Thanks

-- 
[ Adam Stokes ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju-dev/attachments/20150422/8a3f9505/attachment.html>


More information about the Juju-dev mailing list