veyron/tools/mgmt/device,veyron/services/mgmt/device/impl: config override
for local-install

This changelist enables updates for apps installed with local-install. There are
two changes that make this work:

1. allow install-local to specify a config override (like install), so we can
specify configuration for the app independently of what will be present in the
app envelope downloaded during update. We use a command-line flag for this (and
change the "install" command to also use the flag instead of a positional arg).

2. allow install-local to specify an origin for the app (to override the default
origin which points back to the server run by the command-line tool). We use a
setting in the config to convey this information.
This is a convenient way to use for now to get things working. Long-term, we may
drop this in favor of other mechanisms (e.g. UpdateTo)

Change-Id: I363737c5013f510b3cdf6e3544e96f8d13c6ae2a
diff --git a/tools/mgmt/device/impl/local_install.go b/tools/mgmt/device/impl/local_install.go
index a8b8fb9..1598559 100644
--- a/tools/mgmt/device/impl/local_install.go
+++ b/tools/mgmt/device/impl/local_install.go
@@ -23,9 +23,6 @@
 	"v.io/lib/cmdline"
 )
 
-// TODO(caprita): Add a way to provide an origin for the app, so we can do
-// updates after it's been installed.
-
 var cmdInstallLocal = &cmdline.Command{
 	Run:      runInstallLocal,
 	Name:     "install-local",
@@ -41,6 +38,10 @@
 local path for the binary to install, and arbitrary flag settings.`,
 }
 
+func init() {
+	cmdInstallLocal.Flags.Var(&configOverride, "config", "JSON-encoded device.Config object, of the form: '{\"flag1\":\"value1\",\"flag2\":\"value2\"}'")
+}
+
 type openAuthorizer struct{}
 
 func (openAuthorizer) Authorize(security.Context) error { return nil }
@@ -226,7 +227,11 @@
 
 	objects["application"] = repository.ApplicationServer(envelopeInvoker(envelope))
 	appName := naming.Join(name, "application")
-	appID, err := device.ApplicationClient(deviceName).Install(gctx, appName, nil)
+	appID, err := device.ApplicationClient(deviceName).Install(gctx, appName, device.Config(configOverride))
+	// Reset the value for any future invocations of "install" or
+	// "install-local" (we run more than one command per process in unit
+	// tests).
+	configOverride = configFlag{}
 	if err != nil {
 		return fmt.Errorf("Install failed: %v", err)
 	}