forked from railwayapp/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscope.go
More file actions
30 lines (25 loc) · 643 Bytes
/
Copy pathscope.go
File metadata and controls
30 lines (25 loc) · 643 Bytes
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
package gateway
import (
"context"
gql "github.com/machinebox/graphql"
"github.com/railwayapp/cli/errors"
)
// GetWritableGithubScopes returns scopes associated with Railway user
func (g *Gateway) GetWritableGithubScopes(ctx context.Context) ([]string, error) {
gqlReq := gql.NewRequest(`
query {
getWritableGithubScopes
}
`)
err := g.authorize(ctx, gqlReq.Header)
if err != nil {
return nil, err
}
var resp struct {
Scopes []string `json:"getWritableGithubScopes"`
}
if err := g.gqlClient.Run(ctx, gqlReq, &resp); err != nil {
return nil, errors.ProblemFetchingWritableGithubScopes
}
return resp.Scopes, nil
}