mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 17:34:21 +00:00
Add supports for crawling a specific git user or repo
This commit is contained in:
@@ -230,7 +230,6 @@ func kustomizationResultAdapter(gcl GhClient, k GhFileSpec) (
|
||||
RepositoryURL: k.Repository.URL,
|
||||
},
|
||||
}
|
||||
logger.Printf("Set the creationTime field")
|
||||
creationTime, err := gcl.GetFileCreationTime(k)
|
||||
if err != nil {
|
||||
logger.Printf("GetFileCreationTime failed: %v", err)
|
||||
@@ -533,7 +532,7 @@ func (gcl GhClient) parseGithubResponse(getRequest string) GhResponseInfo {
|
||||
}
|
||||
|
||||
// SearchGithubAPI performs a search query and handles rate limitting for
|
||||
// the 'code/search?' endpoint as well as timed retries in the case of abuse
|
||||
// the 'search/code?' endpoint as well as timed retries in the case of abuse
|
||||
// prevention.
|
||||
func (gcl GhClient) SearchGithubAPI(query string) (*http.Response, error) {
|
||||
throttleSearchAPI()
|
||||
|
||||
@@ -90,6 +90,17 @@ func Path(p string) queryField {
|
||||
return queryField{name: "path", value: p}
|
||||
}
|
||||
|
||||
// Repo takes a repository (i.e., kubernetes-sigs/kustomize) and formats
|
||||
// it according to the Github API.
|
||||
func Repo(r string) queryField {
|
||||
return queryField{name: "repo", value: r}
|
||||
}
|
||||
|
||||
// Path takes a github username and formats it according to the Github API.
|
||||
func User(u string) queryField {
|
||||
return queryField{name: "user", value: u}
|
||||
}
|
||||
|
||||
// RequestConfig stores common variables that must be present for the queries.
|
||||
// - CodeSearchRequests: ask Github to check the code indices given a query.
|
||||
// - ContentsRequests: ask Github where to download a resource given a repo and a
|
||||
|
||||
@@ -53,8 +53,11 @@ func TestQueryType(t *testing.T) {
|
||||
Filename("kustomization.yaml"),
|
||||
Keyword("keyword1"),
|
||||
Keyword("keyword2"),
|
||||
Repo("user1/repo1"),
|
||||
User("user1"),
|
||||
),
|
||||
expected: "q=size:24..64+filename:kustomization.yaml+keyword1+keyword2",
|
||||
expected: "q=size:24..64+filename:kustomization.yaml+keyword1+keyword2+" +
|
||||
"repo:user1/repo1+user:user1",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -243,7 +243,7 @@ func FindRangesForRepoSearch(cache cachedSearch) ([]string, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
logger.Println("total files: ", totalFiles)
|
||||
logger.Println("total kustomization files: ", totalFiles)
|
||||
|
||||
if githubMaxResultsPerQuery >= totalFiles {
|
||||
return []string{
|
||||
|
||||
Reference in New Issue
Block a user