55 "net/http"
66
77 "github.com/cli/cli/api"
8- "github.com/cli/cli/internal/ghinstance"
98)
109
1110// repoCreateInput represents input parameters for repoCreate
@@ -23,7 +22,7 @@ type repoCreateInput struct {
2322}
2423
2524// repoCreate creates a new GitHub repository
26- func repoCreate (client * http.Client , input repoCreateInput ) (* api.Repository , error ) {
25+ func repoCreate (client * http.Client , hostname string , input repoCreateInput ) (* api.Repository , error ) {
2726 apiClient := api .NewClientFromHTTP (client )
2827
2928 var response struct {
@@ -33,14 +32,14 @@ func repoCreate(client *http.Client, input repoCreateInput) (*api.Repository, er
3332 }
3433
3534 if input .TeamID != "" {
36- orgID , teamID , err := resolveOrganizationTeam (apiClient , input .OwnerID , input .TeamID )
35+ orgID , teamID , err := resolveOrganizationTeam (apiClient , hostname , input .OwnerID , input .TeamID )
3736 if err != nil {
3837 return nil , err
3938 }
4039 input .TeamID = teamID
4140 input .OwnerID = orgID
4241 } else if input .OwnerID != "" {
43- orgID , err := resolveOrganization (apiClient , input .OwnerID )
42+ orgID , err := resolveOrganization (apiClient , hostname , input .OwnerID )
4443 if err != nil {
4544 return nil , err
4645 }
@@ -51,9 +50,6 @@ func repoCreate(client *http.Client, input repoCreateInput) (*api.Repository, er
5150 "input" : input ,
5251 }
5352
54- // TODO: GHE support
55- hostname := ghinstance .Default ()
56-
5753 err := apiClient .GraphQL (hostname , `
5854 mutation RepositoryCreate($input: CreateRepositoryInput!) {
5955 createRepository(input: $input) {
@@ -74,24 +70,22 @@ func repoCreate(client *http.Client, input repoCreateInput) (*api.Repository, er
7470}
7571
7672// using API v3 here because the equivalent in GraphQL needs `read:org` scope
77- func resolveOrganization (client * api.Client , orgName string ) (string , error ) {
73+ func resolveOrganization (client * api.Client , hostname , orgName string ) (string , error ) {
7874 var response struct {
7975 NodeID string `json:"node_id"`
8076 }
81- // TODO: GHE support
82- err := client .REST (ghinstance .Default (), "GET" , fmt .Sprintf ("users/%s" , orgName ), nil , & response )
77+ err := client .REST (hostname , "GET" , fmt .Sprintf ("users/%s" , orgName ), nil , & response )
8378 return response .NodeID , err
8479}
8580
8681// using API v3 here because the equivalent in GraphQL needs `read:org` scope
87- func resolveOrganizationTeam (client * api.Client , orgName , teamSlug string ) (string , string , error ) {
82+ func resolveOrganizationTeam (client * api.Client , hostname , orgName , teamSlug string ) (string , string , error ) {
8883 var response struct {
8984 NodeID string `json:"node_id"`
9085 Organization struct {
9186 NodeID string `json:"node_id"`
9287 }
9388 }
94- // TODO: GHE support
95- err := client .REST (ghinstance .Default (), "GET" , fmt .Sprintf ("orgs/%s/teams/%s" , orgName , teamSlug ), nil , & response )
89+ err := client .REST (hostname , "GET" , fmt .Sprintf ("orgs/%s/teams/%s" , orgName , teamSlug ), nil , & response )
9690 return response .Organization .NodeID , response .NodeID , err
9791}
0 commit comments