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,
|
func getRepoAccessors(ctx context.Context, uri string, logger *zap.Logger) (
|
||||||
clients.RepoClient, string, error) {
|
repo clients.Repo,
|
||||||
var repo clients.Repo
|
repoClient clients.RepoClient,
|
||||||
var errLocal error
|
ossFuzzRepoClient clients.RepoClient,
|
||||||
var errGitHub error
|
ciiClient clients.CIIBestPracticesClient,
|
||||||
if repo, errLocal = localdir.MakeLocalDirRepo(uri); errLocal == nil {
|
repoType string,
|
||||||
|
err error) {
|
||||||
|
var localRepo, githubRepo clients.Repo
|
||||||
|
var errLocal, errGitHub error
|
||||||
|
if localRepo, errLocal = localdir.MakeLocalDirRepo(uri); errLocal == nil {
|
||||||
// Local directory.
|
// Local directory.
|
||||||
return repo, localdir.CreateLocalDirClient(ctx, logger), repoTypeLocal, nil
|
repoType = repoTypeLocal
|
||||||
|
repo = localRepo
|
||||||
|
repoClient = localdir.CreateLocalDirClient(ctx, logger)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
if githubRepo, errGitHub = githubrepo.MakeGithubRepo(uri); errGitHub == nil {
|
||||||
if repo, errGitHub = githubrepo.MakeGithubRepo(uri); errGitHub == nil {
|
|
||||||
// GitHub URL.
|
// 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, "",
|
err = sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("unspported URI: %s: [%v, %v]", uri, errLocal, errGitHub))
|
||||||
sce.WithMessage(sce.ErrScorecardInternal, fmt.Sprintf("unspported URI: %s: [%v, %v]", uri, errLocal, errGitHub))
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getURI(repo, local string) (string, error) {
|
func getURI(repo, local string) (string, error) {
|
||||||
@ -313,18 +324,14 @@ var rootCmd = &cobra.Command{
|
|||||||
// nolint
|
// nolint
|
||||||
defer logger.Sync() // Flushes buffer, if any.
|
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 {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
defer repoClient.Close()
|
defer repoClient.Close()
|
||||||
|
if ossFuzzRepoClient != nil {
|
||||||
ciiClient := clients.DefaultCIIBestPracticesClient()
|
defer ossFuzzRepoClient.Close()
|
||||||
ossFuzzRepoClient, err := githubrepo.CreateOssFuzzRepoClient(ctx, logger)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
}
|
||||||
defer ossFuzzRepoClient.Close()
|
|
||||||
|
|
||||||
// Read docs.
|
// Read docs.
|
||||||
checkDocs, err := docs.Read()
|
checkDocs, err := docs.Read()
|
||||||
|
Loading…
Reference in New Issue
Block a user