Skip to content

Commit cb31118

Browse files
authored
Merge pull request #33 from github/organization-interface
Use the go-github admin interface for creating organizations rather than implementing it manually.
2 parents 12060fe + 172bec5 commit cb31118

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

internal/push/push.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,10 @@ func (pushService *pushService) createRepository() (*github.Repository, error) {
6060
}
6161
if response.StatusCode == http.StatusNotFound {
6262
log.Printf("The organization %s does not exist. Creating it...", pushService.destinationRepositoryOwner)
63-
createOrganizationRequest, err := pushService.githubEnterpriseClient.NewRequest("POST", "admin/organizations", map[string]interface{}{
64-
"login": pushService.destinationRepositoryOwner,
65-
"profile_name": pushService.destinationRepositoryOwner,
66-
"admin": user.GetLogin(),
67-
})
68-
if err != nil {
69-
return nil, errors.Wrap(err, "Error checking if destination organization exists.")
70-
}
71-
response, err = pushService.githubEnterpriseClient.Do(pushService.ctx, createOrganizationRequest, nil)
63+
_, _, err := pushService.githubEnterpriseClient.Admin.CreateOrg(pushService.ctx, &github.Organization{
64+
Login: github.String(pushService.destinationRepositoryOwner),
65+
Name: github.String(pushService.destinationRepositoryOwner),
66+
}, user.GetLogin())
7267
if err != nil {
7368
return nil, errors.Wrap(err, "Error creating organization.")
7469
}

0 commit comments

Comments
 (0)