remove vestigial return from HasMinimumScopes

This commit is contained in:
vilmibm 2020-08-11 16:33:13 -05:00
parent 36b2d3f6a7
commit 6c64cb8d23
3 changed files with 9 additions and 9 deletions

View file

@ -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

View file

@ -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)
}

View file

@ -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) {