[ARVADOS-DEV] updated: 73c0c3a6f989cacdc29a050e4a93e03ffe588398
Git user
git at public.arvados.org
Fri Nov 12 21:09:38 UTC 2021
Summary of changes:
cmd/art/cmd.go | 10 +++++-----
cmd/art/root.go | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 5 deletions(-)
via 73c0c3a6f989cacdc29a050e4a93e03ffe588398 (commit)
from d92937855928b0432d5300638c8528b92f562178 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 73c0c3a6f989cacdc29a050e4a93e03ffe588398
Author: Ward Vandewege <ward at curii.com>
Date: Fri Nov 12 16:09:14 2021 -0500
x
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>
diff --git a/cmd/art/cmd.go b/cmd/art/cmd.go
index f94a77a..167aaf1 100644
--- a/cmd/art/cmd.go
+++ b/cmd/art/cmd.go
@@ -4,14 +4,14 @@
package main
-import (
+/*import (
"log"
"git.arvados.org/arvados-dev.git/lib/redmine"
"github.com/spf13/viper"
-)
+)*/
-var (
+/* var (
conf config
r *redmine.Client
)
@@ -39,9 +39,9 @@ func loadConfig() config {
log.Fatal("the REDMINE_APIKEY environment variable must be set to your redmine API key")
}
return c
-}
+}*/
func main() {
- conf = loadConfig()
+ // conf = loadConfig()
Execute()
}
diff --git a/cmd/art/root.go b/cmd/art/root.go
index da30189..2ba0230 100644
--- a/cmd/art/root.go
+++ b/cmd/art/root.go
@@ -9,8 +9,44 @@ import (
"os"
"github.com/spf13/cobra"
+ "github.com/spf13/viper"
)
+var (
+ conf config
+
+// r *redmine.Client
+)
+
+type config struct {
+ Endpoint string `json:"endpoint"` // https://dev-dev.arvados.org
+ Apikey string `json:"apikey"` // abcde...
+}
+
+func loadConfig(cmd *cobra.Command) config {
+ var c config
+
+ Viper := viper.New()
+ Viper.SetEnvPrefix("redmine") // will be uppercased automatically
+ Viper.BindEnv("endpoint")
+ Viper.BindEnv("apikey")
+
+ c.Endpoint = Viper.GetString("endpoint")
+ c.Apikey = Viper.GetString("apikey")
+
+ if c.Endpoint == "" {
+ cmd.Help()
+ fmt.Println("the REDMINE_ENDPOINT environment variable must be set to the base URL of your redmine server")
+ os.Exit(1)
+ }
+ if c.Apikey == "" {
+ cmd.Help()
+ fmt.Println("the REDMINE_APIKEY environment variable must be set to your redmine API key")
+ os.Exit(1)
+ }
+ return c
+}
+
func init() {
rootCmd.PersistentFlags().StringP("output", "o", "", "Output format. Empty for human-readable, 'json' or 'json-line'")
rootCmd.PersistentFlags().BoolP("help", "h", false, "Print help")
@@ -24,6 +60,10 @@ var rootCmd = &cobra.Command{
art (Arvados Release Tool) supports the Arvados development process
https://git.arvados.org/arvados-dev.git/cmd/art`,
+ PreRunE: func(cmd *cobra.Command, args []string) error {
+ conf = loadConfig(cmd)
+ return nil
+ },
}
func Execute() {
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list