From 539548c26d3a8435e430b998fccfb4166b5bb0ea Mon Sep 17 00:00:00 2001 From: Robert Sotomski Date: Mon, 18 Feb 2019 08:46:37 +0100 Subject: [PATCH] removed jira prefix --- cmd/root.go | 3 +-- jiraApi/root.go | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 3e00055..d11bcfa 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -83,7 +83,6 @@ func initConfig() { viper.SetConfigName(".jira-cli") } - viper.SetEnvPrefix("JIRA") viper.SetConfigType("yaml") viper.AutomaticEnv() // read in environment variables that match @@ -98,5 +97,5 @@ func initConfig() { } viper.WriteConfigAs(path.Join(home, "/.jira-cli.yaml")) } - jiraApi.Initialize() + jiraApi.Initialize(viper.GetString("server_url"), viper.GetString("user"), viper.GetString("password")) } diff --git a/jiraApi/root.go b/jiraApi/root.go index 1e28553..97e1c00 100644 --- a/jiraApi/root.go +++ b/jiraApi/root.go @@ -70,10 +70,10 @@ type Transitions struct { Transition Transition `json:"transition,omitempty"` } -func Initialize() { - resty.SetHostURL(viper.GetString("server_url")) +func Initialize(serverUrl string, username string, password string) { + resty.SetHostURL(serverUrl) resty.SetTimeout(1 * time.Minute) - resty.SetBasicAuth(viper.GetString("user"), viper.GetString("password")) + resty.SetBasicAuth(username, password) // Headers for all request resty.SetHeader("Accept", "application/json") resty.SetHeaders(map[string]string{ @@ -300,14 +300,14 @@ func TestTransitions(workflowPath string, issueKey string) { } func readWorkflow(workflowPath string) { - workflowContent := viper.GetString("WORKFLOW_CONTENT") + workflowContent := viper.GetString("JIRA_WORKFLOW_CONTENT") if workflowContent != "" { viper.MergeConfig(bytes.NewBuffer([]byte(workflowContent))) return } if _, err := os.Stat(workflowPath); err != nil { if os.IsNotExist(err) { - logger.ErrorF("File not found: %s\n", workflowPath) + logger.ErrorF("Workflow file not found: %s\n", workflowPath) os.Exit(1) } }