@@ -43,12 +43,17 @@ import (
4343 "github.com/ossf/scorecard/v4/stats"
4444)
4545
46+ const (
47+ resultsFile = "results.json"
48+ rawResultsFile = "raw.json"
49+ )
50+
4651var ignoreRuntimeErrors = flag .Bool ("ignoreRuntimeErrors" , false , "if set to true any runtime errors will be ignored" )
4752
4853// nolint: gocognit
4954func processRequest (ctx context.Context ,
5055 batchRequest * data.ScorecardBatchRequest ,
51- blacklistedChecks []string , bucketURL , rawBucketURL , exportBucketURL string ,
56+ blacklistedChecks []string , bucketURL , rawBucketURL , apiBucketURL string ,
5257 checkDocs docs.Doc ,
5358 repoClient clients.RepoClient , ossFuzzRepoClient clients.RepoClient ,
5459 ciiClient clients.CIIBestPracticesClient ,
@@ -139,29 +144,29 @@ func processRequest(ctx context.Context,
139144 if err := format .AsRawJSON (& result , & exportRawBuffer ); err != nil {
140145 return fmt .Errorf ("error during result.AsRawJSON for export: %w" , err )
141146 }
142- exportPath := fmt .Sprintf ("%s/result.json " , repo .URI ())
143- exportCommitSHAPath := fmt .Sprintf ("%s/%s/result.json " , repo .URI (), result .Repo .CommitSHA )
144- exportRawPath := fmt .Sprintf ("%s/raw.json " , repo .URI ())
145- exportRawCommitSHAPath := fmt .Sprintf ("%s/%s/raw.json " , repo .URI (), result .Repo .CommitSHA )
147+ exportPath := fmt .Sprintf ("%s/%s " , repo .URI (), resultsFile )
148+ exportCommitSHAPath := fmt .Sprintf ("%s/%s/%s " , repo .URI (), result .Repo .CommitSHA , resultsFile )
149+ exportRawPath := fmt .Sprintf ("%s/%s " , repo .URI (), rawResultsFile )
150+ exportRawCommitSHAPath := fmt .Sprintf ("%s/%s/%s " , repo .URI (), result .Repo .CommitSHA , rawResultsFile )
146151
147152 // Raw result.
148153 if err := format .AsRawJSON (& result , & rawBuffer ); err != nil {
149154 return fmt .Errorf ("error during result.AsRawJSON: %w" , err )
150155 }
151156
152157 // These are results without the commit SHA which represents the latest commit.
153- if err := data .WriteToBlobStore (ctx , exportBucketURL , exportPath , exportBuffer .Bytes ()); err != nil {
158+ if err := data .WriteToBlobStore (ctx , apiBucketURL , exportPath , exportBuffer .Bytes ()); err != nil {
154159 return fmt .Errorf ("error during writing to exportBucketURL: %w" , err )
155160 }
156161 // Export result based on commitSHA.
157- if err := data .WriteToBlobStore (ctx , exportBucketURL , exportCommitSHAPath , exportBuffer .Bytes ()); err != nil {
162+ if err := data .WriteToBlobStore (ctx , apiBucketURL , exportCommitSHAPath , exportBuffer .Bytes ()); err != nil {
158163 return fmt .Errorf ("error during exportBucketURL with commit SHA: %w" , err )
159164 }
160165 // Export raw result.
161- if err := data .WriteToBlobStore (ctx , exportBucketURL , exportRawPath , exportRawBuffer .Bytes ()); err != nil {
166+ if err := data .WriteToBlobStore (ctx , apiBucketURL , exportRawPath , exportRawBuffer .Bytes ()); err != nil {
162167 return fmt .Errorf ("error during writing to exportBucketURL for raw results: %w" , err )
163168 }
164- if err := data .WriteToBlobStore (ctx , exportBucketURL , exportRawCommitSHAPath , exportRawBuffer .Bytes ()); err != nil {
169+ if err := data .WriteToBlobStore (ctx , apiBucketURL , exportRawCommitSHAPath , exportRawBuffer .Bytes ()); err != nil {
165170 return fmt .Errorf ("error during exportBucketURL for raw results with commit SHA: %w" , err )
166171 }
167172 }
@@ -238,7 +243,7 @@ func main() {
238243 panic (err )
239244 }
240245
241- exportBucketURL , err := config .GetBQExportResultsBucketURL ()
246+ apiBucketURL , err := config .GetAPIResultsBucketURL ()
242247 if err != nil {
243248 panic (err )
244249 }
@@ -278,7 +283,7 @@ func main() {
278283 break
279284 }
280285 if err := processRequest (ctx , req , blacklistedChecks ,
281- bucketURL , rawBucketURL , exportBucketURL , checkDocs ,
286+ bucketURL , rawBucketURL , apiBucketURL , checkDocs ,
282287 repoClient , ossFuzzRepoClient , ciiClient , vulnsClient , logger ); err != nil {
283288 // TODO(log): Previously Warn. Consider logging an error here.
284289 logger .Info (fmt .Sprintf ("error processing request: %v" , err ))
0 commit comments