Skip to content

Commit c369cb8

Browse files
author
thisisaaronland
committed
pass in org name in the correct place
1 parent 712a98b commit c369cb8

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

cmd/wof-create-repo/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package main
22

33
import (
4-
"log"
54
"flag"
6-
"github.com/whosonfirst/go-whosonfirst-github/organizations"
5+
"github.com/whosonfirst/go-whosonfirst-github/organizations"
6+
"log"
77
)
88

99
func main() {
@@ -23,9 +23,9 @@ func main() {
2323

2424
opts := &organizations.CreateOptions{
2525
AccessToken: *token,
26-
Name: *name,
26+
Name: *name,
2727
Description: *description,
28-
Private: *private,
28+
Private: *private,
2929
}
3030

3131
err := organizations.CreateRepo(*org, opts)

organizations/organizations.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ type ListOptions struct {
2121

2222
type CreateOptions struct {
2323
AccessToken string
24-
Name string
24+
Name string
2525
Description string
26-
Private bool
26+
Private bool
2727
}
2828

2929
func NewDefaultListOptions() *ListOptions {
@@ -41,33 +41,26 @@ func NewDefaultListOptions() *ListOptions {
4141
return &opts
4242
}
4343

44-
// CreateRepo is a helper method for creating a new
44+
// CreateRepo is a helper method for creating a new
4545
func CreateRepo(org_name string, opts *CreateOptions) error {
4646

47-
4847
// https://docs.github.com/en/rest/reference/repos#create-an-organization-repository
4948
// https://github.com/google/go-github/blob/v17.0.0/example/newrepo/main.go
49+
// https://github.com/google/go-github/blob/v17.0.0/github/repos.go#L262
5050

5151
client, ctx, err := util.NewClientAndContext(opts.AccessToken)
5252

5353
if err != nil {
5454
return fmt.Errorf("Failed to create new client, %w", err)
5555
}
5656

57-
org, _, err := client.Organizations.Get(ctx, org_name)
58-
59-
if err != nil {
60-
return fmt.Errorf("Failed to retrieve organization, %w", err)
61-
}
62-
6357
r := &github.Repository{
64-
Name: &opts.Name,
65-
Private: &opts.Private,
58+
Name: &opts.Name,
59+
Private: &opts.Private,
6660
Description: &opts.Description,
67-
Organization: org,
6861
}
69-
70-
_, _, err = client.Repositories.Create(ctx, "", r)
62+
63+
_, _, err = client.Repositories.Create(ctx, org_name, r)
7164

7265
if err != nil {
7366
return fmt.Errorf("Failed to create repository, %w", err)

0 commit comments

Comments
 (0)