github.com/google/go-github/v49@v49.1.0/github/repos_codeowners.go (about) 1 // Copyright 2022 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "context" 10 "fmt" 11 ) 12 13 // CodeownersErrors represents a list of syntax errors detected in the CODEOWNERS file. 14 type CodeownersErrors struct { 15 Errors []*CodeownersError `json:"errors"` 16 } 17 18 // CodeownersError represents a syntax error detected in the CODEOWNERS file. 19 type CodeownersError struct { 20 Line int `json:"line"` 21 Column int `json:"column"` 22 Kind string `json:"kind"` 23 Source string `json:"source"` 24 Suggestion *string `json:"suggestion,omitempty"` 25 Message string `json:"message"` 26 Path string `json:"path"` 27 } 28 29 // GetCodeownersErrors lists any syntax errors that are detected in the CODEOWNERS file. 30 // 31 // GitHub API docs: https://docs.github.com/en/rest/repos/repos#list-codeowners-errors 32 func (s *RepositoriesService) GetCodeownersErrors(ctx context.Context, owner, repo string) (*CodeownersErrors, *Response, error) { 33 u := fmt.Sprintf("repos/%v/%v/codeowners/errors", owner, repo) 34 req, err := s.client.NewRequest("GET", u, nil) 35 if err != nil { 36 return nil, nil, err 37 } 38 39 codeownersErrors := &CodeownersErrors{} 40 resp, err := s.client.Do(ctx, req, codeownersErrors) 41 if err != nil { 42 return nil, resp, err 43 } 44 45 return codeownersErrors, resp, nil 46 }