MCPcopy Create free account
hub / github.com/crashappsec/github-analyzer / NewOrganization

Function NewOrganization

pkg/github/org/org.go:47–82  ·  view source on GitHub ↗
(
	ctx context.Context,
	client *github.Client,
	backoff *backoff.Backoff,
	name string)

Source from the content-addressed store, hash-verified

45}
46
47func NewOrganization(
48 ctx context.Context,
49 client *github.Client,
50 backoff *backoff.Backoff,
51 name string) (*Organization, error) {
52 orgInfo, resp, err := client.Organizations.Get(ctx, name)
53
54 if err != nil {
55 if resp.StatusCode == 403 {
56 log.Logger.Errorf(
57 "Unable to retrieve organization information. It appears the token being used doesn't have access to this information.",
58 )
59 } else if resp.StatusCode == 404 {
60 log.Logger.Errorf(
61 "Organization not found. Perhaps there's a typo in the org name?",
62 )
63 } else {
64 log.Logger.Error(err)
65 }
66 return nil, err
67 }
68
69 // FIXME change to not use unmarshal w/ reflection or plain initializer
70 var stats types.OrgCoreStats
71 orgJson, _ := json.Marshal(orgInfo)
72 _ = json.Unmarshal(orgJson, &stats)
73
74 org := Organization{
75 info: orgInfo,
76 client: client,
77 backoff: backoff,
78 paginationSize: 100,
79 CoreStats: &stats,
80 }
81 return &org, nil
82}
83
84// GetWebhook returns the webhooks for a given org. Upon first call,
85// it lazily updates the Organization with the webhook information

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected