-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from 030/1-create-issue
[GH-1] Create a Jira issue.
- Loading branch information
Showing
9 changed files
with
111 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
|
||
"github.com/030/jops/internal/jira/v2/issue/create" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// createCmd represents the create command | ||
var createCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "Create a Jira issue", | ||
Long: `A longer description that spans multiple lines and likely contains examples | ||
and usage of using your command. For example: | ||
Cobra is a CLI library for Go that empowers applications. | ||
This application is a tool to generate the needed files | ||
to quickly create a Cobra application.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("create called") | ||
j := create.Jira{User: user, Pass: pass, FQDN: fqdn, Project: project, Summary: summary, Description: description} | ||
if err := j.Create(); err != nil { | ||
log.Fatal(err) | ||
} | ||
}, | ||
} | ||
|
||
var description, summary string | ||
|
||
func init() { | ||
rootCmd.AddCommand(createCmd) | ||
|
||
// Here you will define your flags and configuration settings. | ||
|
||
// Cobra supports Persistent Flags which will work for this command | ||
// and all subcommands, e.g.: | ||
// createCmd.PersistentFlags().String("foo", "", "A help for foo") | ||
|
||
// Cobra supports local flags which will only run when this command | ||
// is called directly, e.g.: | ||
// createCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
|
||
createCmd.PersistentFlags().StringVarP(&summary, "summary", "s", "", "The summary of the Jira issue") | ||
if err := createCmd.MarkPersistentFlagRequired("summary"); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
createCmd.PersistentFlags().StringVarP(&description, "description", "d", "", "The description of the Jira issue") | ||
if err := createCmd.MarkPersistentFlagRequired("description"); err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package create | ||
|
||
import "github.com/030/jops/internal/pkg/httprequest" | ||
|
||
func (j *Jira) Create() error { | ||
fields := Fields{ | ||
Description: j.Description, | ||
Summary: j.Summary, | ||
Issuetype: Issuetype{"Story"}, | ||
Project: Project{j.Project}, | ||
} | ||
data := Payload{ | ||
Fields: fields, | ||
} | ||
|
||
htj := httprequest.Jira{APIVersion: "2", Data: data, Method: "POST", FQDN: j.FQDN, User: j.User, Pass: j.Pass} | ||
if err := htj.ConstructAndInitiate(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package create | ||
|
||
type Jira struct { | ||
User, Pass, FQDN, Project, Summary, Description string | ||
} | ||
|
||
type Payload struct { | ||
Fields Fields `json:"fields"` | ||
} | ||
type Issuetype struct { | ||
ID string `json:"name"` | ||
} | ||
type Project struct { | ||
ID string `json:"key"` | ||
} | ||
|
||
type Fields struct { | ||
Description string `json:"description"` | ||
Issuetype Issuetype `json:"issuetype"` | ||
Project Project `json:"project"` | ||
Summary string `json:"summary"` | ||
} |
File renamed without changes.
File renamed without changes.