Skip to content

Commit

Permalink
get workflow from http url
Browse files Browse the repository at this point in the history
  • Loading branch information
sotomskir committed Feb 19, 2019
1 parent 944d534 commit 19271f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ Atlassian's Jira REST API client written in Go for use with CI/CD tools to autom
## Install
### Linux
```bash
sudo curl -L "https://github.com/sotomskir/jira-cli/releases/download/0.3.0/jira-cli-$(uname -s)-$(uname -m)" -o /usr/local/bin/jira-cli
sudo chmod +x /usr/local/bin/jira-cli
sudo curl -L "https://github.com/sotomskir/jira-cli/releases/download/0.4.0/jira-cli-$(uname -s)-$(uname -m)" -o /usr/local/bin/jira-cli && sudo chmod +x /usr/local/bin/jira-cli
```
### Other platforms
You can download pre-build binary here: https://github.com/sotomskir/jira-cli/releases
Expand Down
2 changes: 1 addition & 1 deletion cmd/issueTransition.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func init() {
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// issueTransitionCmd.PersistentFlags().String("foo", "", "A help for foo")
issueTransitionCmd.Flags().StringP("workflow", "w", "workflow.yaml", "Workflow definition file")
issueTransitionCmd.Flags().StringP("workflow", "w", "workflow.yaml", "Workflow definition local file or http URL")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// issueTransitionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
Expand Down
9 changes: 9 additions & 0 deletions jiraApi/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/sirupsen/logrus"
"github.com/sotomskir/jira-cli/logger"
"github.com/spf13/cast"
"github.com/spf13/viper"
Expand Down Expand Up @@ -305,6 +306,14 @@ func readWorkflow(workflowPath string) {
viper.MergeConfig(bytes.NewBuffer([]byte(workflowContent)))
return
}
if strings.HasPrefix(workflowPath, "http://") || strings.HasPrefix(workflowPath, "https://") {
response, err := resty.R().Get(workflowPath)
if err != nil {
logrus.Fatalln(response.Body(), err)
}
viper.MergeConfig(bytes.NewBuffer(response.Body()))
return
}
if _, err := os.Stat(workflowPath); err != nil {
if os.IsNotExist(err) {
logger.ErrorF("Workflow file not found: %s\n", workflowPath)
Expand Down

0 comments on commit 19271f9

Please sign in to comment.