11package api
22
3- import "fmt"
4-
53func IssueCreate (client * Client , ghRepo Repo , params map [string ]interface {}) (* Issue , error ) {
6- repoId , err := GitHubRepoId (client , ghRepo )
4+ repoID , err := GitHubRepoId (client , ghRepo )
75 if err != nil {
86 return nil , err
97 }
@@ -18,7 +16,7 @@ func IssueCreate(client *Client, ghRepo Repo, params map[string]interface{}) (*I
1816 }`
1917
2018 inputParams := map [string ]interface {}{
21- "repositoryId" : repoId ,
19+ "repositoryId" : repoID ,
2220 }
2321 for key , val := range params {
2422 inputParams [key ] = val
@@ -40,31 +38,3 @@ func IssueCreate(client *Client, ghRepo Repo, params map[string]interface{}) (*I
4038
4139 return & result .CreateIssue .Issue , nil
4240}
43-
44- func GitHubRepoId (client * Client , ghRepo Repo ) (string , error ) {
45- owner := ghRepo .RepoOwner ()
46- repo := ghRepo .RepoName ()
47-
48- query := `
49- query FindRepoID($owner:String!, $name:String!) {
50- repository(owner:$owner, name:$name) {
51- id
52- }
53- }`
54- variables := map [string ]interface {}{
55- "owner" : owner ,
56- "name" : repo ,
57- }
58-
59- result := struct {
60- Repository struct {
61- Id string
62- }
63- }{}
64- err := client .GraphQL (query , variables , & result )
65- if err != nil || result .Repository .Id == "" {
66- return "" , fmt .Errorf ("failed to determine GH repo ID: %s" , err )
67- }
68-
69- return result .Repository .Id , nil
70- }
0 commit comments