From f9508e37e04c87a1f2ddfa0b1886b26702b4cd9f Mon Sep 17 00:00:00 2001 From: Christophe Labouisse Date: Sat, 19 Sep 2015 17:06:30 +0200 Subject: [PATCH] Add env var for default server url The default server URL can now be set using the `NOTARY_SERVER_URL` environment variable. Specifying the `--server` parameter still override this value. Signed-off-by: Christophe Labouisse --- cmd/notary/main.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/notary/main.go b/cmd/notary/main.go index f971bc1011..d2dd35812e 100644 --- a/cmd/notary/main.go +++ b/cmd/notary/main.go @@ -72,6 +72,11 @@ func parseConfig() { } func main() { + serverURL := os.Getenv("NOTARY_SERVER_URL") + if serverURL == "" { + serverURL = defaultServerURL + } + var notaryCmd = &cobra.Command{ Use: "notary", Short: "notary allows the creation of trusted collections.", @@ -95,19 +100,19 @@ func main() { notaryCmd.AddCommand(cmdKey) notaryCmd.AddCommand(cmdCert) notaryCmd.AddCommand(cmdTufInit) - cmdTufInit.Flags().StringVarP(&remoteTrustServer, "server", "s", defaultServerURL, "Remote trust server location") + cmdTufInit.Flags().StringVarP(&remoteTrustServer, "server", "s", serverURL, "Remote trust server location") notaryCmd.AddCommand(cmdTufList) cmdTufList.Flags().BoolVarP(&rawOutput, "raw", "", false, "Instructs notary list to output a nonpretty printed version of the targets list. Useful if you need to parse the list.") - cmdTufList.Flags().StringVarP(&remoteTrustServer, "server", "s", defaultServerURL, "Remote trust server location") + cmdTufList.Flags().StringVarP(&remoteTrustServer, "server", "s", serverURL, "Remote trust server location") notaryCmd.AddCommand(cmdTufAdd) notaryCmd.AddCommand(cmdTufRemove) notaryCmd.AddCommand(cmdTufPublish) - cmdTufPublish.Flags().StringVarP(&remoteTrustServer, "server", "s", defaultServerURL, "Remote trust server location") + cmdTufPublish.Flags().StringVarP(&remoteTrustServer, "server", "s", serverURL, "Remote trust server location") notaryCmd.AddCommand(cmdTufLookup) cmdTufLookup.Flags().BoolVarP(&rawOutput, "raw", "", false, "Instructs notary lookup to output a nonpretty printed version of the targets list. Useful if you need to parse the list.") - cmdTufLookup.Flags().StringVarP(&remoteTrustServer, "server", "s", defaultServerURL, "Remote trust server location") + cmdTufLookup.Flags().StringVarP(&remoteTrustServer, "server", "s", serverURL, "Remote trust server location") notaryCmd.AddCommand(cmdVerify) - cmdVerify.Flags().StringVarP(&remoteTrustServer, "server", "s", defaultServerURL, "Remote trust server location") + cmdVerify.Flags().StringVarP(&remoteTrustServer, "server", "s", serverURL, "Remote trust server location") notaryCmd.Execute() }