remove vestigial return from HasMinimumScopes
This commit is contained in:
parent
36b2d3f6a7
commit
6c64cb8d23
3 changed files with 9 additions and 9 deletions
|
|
@ -200,18 +200,18 @@ type MissingScopesError struct {
|
|||
error
|
||||
}
|
||||
|
||||
func (c Client) HasMinimumScopes(hostname string) (bool, error) {
|
||||
func (c Client) HasMinimumScopes(hostname string) error {
|
||||
apiEndpoint := ghinstance.RESTPrefix(hostname)
|
||||
|
||||
req, err := http.NewRequest("GET", apiEndpoint, nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
|
||||
req.Header.Set("Content-Type", "application/json; charset=utf-8")
|
||||
res, err := c.http.Do(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
|
@ -222,7 +222,7 @@ func (c Client) HasMinimumScopes(hostname string) (bool, error) {
|
|||
}()
|
||||
|
||||
if res.StatusCode != 200 {
|
||||
return false, handleHTTPError(res)
|
||||
return handleHTTPError(res)
|
||||
}
|
||||
|
||||
hasScopes := strings.Split(res.Header.Get("X-Oauth-Scopes"), ",")
|
||||
|
|
@ -247,10 +247,10 @@ func (c Client) HasMinimumScopes(hostname string) (bool, error) {
|
|||
}
|
||||
|
||||
if len(errorMsgs) > 0 {
|
||||
return false, &MissingScopesError{error: errors.New(strings.Join(errorMsgs, ";"))}
|
||||
return &MissingScopesError{error: errors.New(strings.Join(errorMsgs, ";"))}
|
||||
}
|
||||
|
||||
return true, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// GraphQL performs a GraphQL request and parses the response
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ func ValidateHostCfg(hostname string, cfg config.Config) error {
|
|||
return err
|
||||
}
|
||||
|
||||
_, err = apiClient.HasMinimumScopes(hostname)
|
||||
err = apiClient.HasMinimumScopes(hostname)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not validate token: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func statusRun(opts *StatusOptions) error {
|
|||
return err
|
||||
}
|
||||
|
||||
_, err = apiClient.HasMinimumScopes(hostname)
|
||||
err = apiClient.HasMinimumScopes(hostname)
|
||||
if err != nil {
|
||||
var missingScopes *api.MissingScopesError
|
||||
if errors.As(err, &missingScopes) {
|
||||
|
|
@ -145,7 +145,7 @@ func statusRun(opts *StatusOptions) error {
|
|||
statusInfo[hostname] = append(statusInfo[hostname], fmt.Sprintf(x, ys...))
|
||||
}
|
||||
|
||||
_, err = apiClient.HasMinimumScopes(hostname)
|
||||
err = apiClient.HasMinimumScopes(hostname)
|
||||
if err != nil {
|
||||
var missingScopes *api.MissingScopesError
|
||||
if errors.As(err, &missingScopes) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue