Re: Need advice on my juju plugin

2015-04-22 Thread Aaron Bentley
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

> 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:

`juju switch` (aka `juju env`) will tell you the current environment.
 Your plugin should accept -e/--environment to override it.

I wrote a g+ post about plugins recently:
https://plus.google.com/+AaronBentley/posts/45FA3LDkcv8

Aaron
-BEGIN PGP SIGNATURE-
Version: GnuPG v1

iQEcBAEBAgAGBQJVN7kcAAoJEK84cMOcf+9h6UoIAKa1o3TMqvbfJgWZUMmkP9EN
5EzFtQ3tOxHWETa2cctoJazR7sXTzYtkgLznmHxmnBaASkWZ9ro0wjOfPzzq7NEL
m75c6ypmRraqZ/gQQMrsiVMvTE3djAoVUVB/slJ0zXqAD8tMsQ/DjwWzcPfv5xWX
ZWEV9EOnobVaSss7eqsHj7Hc7BZ7QmnrCdX803qj/7Sh1S+sN1650u87j949gfw5
w93mIhdBLTyMjKMhJaybozlMJZ8HFsMGcnnmqstBKulJS3KMLaBEbwlXuU09YBrV
zBIdP9DWs6ZBYmRqrD923EVkkB4k+A49RhSt9Syv16ViZyVJA23zPCahFZVSqfc=
=tjm2
-END PGP SIGNATURE-

-- 
Juju-dev mailing list
Juju-dev@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju-dev


Need advice on my juju plugin

2015-04-22 Thread Adam Stokes
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 ]
-- 
Juju-dev mailing list
Juju-dev@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju-dev