mirror of
https://github.com/ossf/scorecard.git
synced 2024-09-19 21:18:09 +03:00
Use updated clients for local
(#1355)
Co-authored-by: Azeem Shaikh <azeems@google.com>
This commit is contained in:
parent
aed511670f
commit
84d169bf23
45
cmd/root.go
45
cmd/root.go
@ -210,22 +210,33 @@ func validateFormat(format string) bool {
|
||||
}
|
||||
}
|
||||
|
||||
func getRepoAccessors(ctx context.Context, uri string, logger *zap.Logger) (clients.Repo,
|
||||
clients.RepoClient, string, error) {
|
||||
var repo clients.Repo
|
||||
var errLocal error
|
||||
var errGitHub error
|
||||
if repo, errLocal = localdir.MakeLocalDirRepo(uri); errLocal == nil {
|
||||
func getRepoAccessors(ctx context.Context, uri string, logger *zap.Logger) (
|
||||
repo clients.Repo,
|
||||
repoClient clients.RepoClient,
|
||||
ossFuzzRepoClient clients.RepoClient,
|
||||
ciiClient clients.CIIBestPracticesClient,
|
||||
repoType string,
|
||||
err error) {
|
||||
var localRepo, githubRepo clients.Repo
|
||||
var errLocal, errGitHub error
|
||||
if localRepo, errLocal = localdir.MakeLocalDirRepo(uri); errLocal == nil {
|
||||
// Local directory.
|
||||
return repo, localdir.CreateLocalDirClient(ctx, logger), repoTypeLocal, nil
|
||||
repoType = repoTypeLocal
|
||||
repo = localRepo
|
||||
repoClient = localdir.CreateLocalDirClient(ctx, logger)
|
||||
return
|
||||
}
|
||||
|
||||
if repo, errGitHub = githubrepo.MakeGithubRepo(uri); errGitHub == nil {
|
||||
if githubRepo, errGitHub = githubrepo.MakeGithubRepo(uri); errGitHub == nil {
|
||||
// GitHub URL.
|
||||
return repo, githubrepo.CreateGithubRepoClient(ctx, logger), repoTypeGitHub, nil
|
||||
repoType = repoTypeGitHub
|
||||
repo = githubRepo
|
||||
repoClient = githubrepo.CreateGithubRepoClient(ctx, logger)
|
||||
ciiClient = clients.DefaultCIIBestPracticesClient()
|
||||
ossFuzzRepoClient, err = githubrepo.CreateOssFuzzRepoClient(ctx, logger)
|
||||
return
|
||||
}
|
||||
return nil, nil, "",
|
||||
sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("unspported URI: %s: [%v, %v]", uri, errLocal, errGitHub))
|
||||
err = sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("unspported URI: %s: [%v, %v]", uri, errLocal, errGitHub))
|
||||
return
|
||||
}
|
||||
|
||||
func getURI(repo, local string) (string, error) {
|
||||
@ -313,18 +324,14 @@ var rootCmd = &cobra.Command{
|
||||
// nolint
|
||||
defer logger.Sync() // Flushes buffer, if any.
|
||||
|
||||
repoURI, repoClient, repoType, err := getRepoAccessors(ctx, uri, logger)
|
||||
repoURI, repoClient, ossFuzzRepoClient, ciiClient, repoType, err := getRepoAccessors(ctx, uri, logger)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer repoClient.Close()
|
||||
|
||||
ciiClient := clients.DefaultCIIBestPracticesClient()
|
||||
ossFuzzRepoClient, err := githubrepo.CreateOssFuzzRepoClient(ctx, logger)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
if ossFuzzRepoClient != nil {
|
||||
defer ossFuzzRepoClient.Close()
|
||||
}
|
||||
defer ossFuzzRepoClient.Close()
|
||||
|
||||
// Read docs.
|
||||
checkDocs, err := docs.Read()
|
||||
|
Loading…
Reference in New Issue
Block a user