-
Notifications
You must be signed in to change notification settings - Fork 1
/
list.go
45 lines (38 loc) · 950 Bytes
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package repos
import (
"fmt"
"github.com/Mirantis/dataeng/dataengctl/pkg/client"
"io"
"net/http"
)
// List Repos Defined on Organization
// curl -s \
// -H "Accept: application/vnd.github.v3+json" \
// https://api.github.com/orgs/Mirantis/repos
// github list repos --organization {ORG_NAME}
// github list repos --organization Mirantis
// Options Struct
type Options struct {
Output string
Client client.DataClientInterface
Org string
Repo string
}
// github get repos --org $ORG --repo $REPO
func (lo *Options) ListRepos(w io.Writer) error {
req, err := http.NewRequest("GET", "https://api.github.com/orgs/Mirantis/repos", nil)
if err != nil {
// Error Handle
fmt.Printf("ERROR: %s", err)
return err
}
req.Header.Set("Accept", "application/vnd.github.v3+json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
// Error Handle
fmt.Printf("ERROR: %s", err)
return err
}
defer resp.Body.Close()
return nil
}