MCPcopy Create free account
hub / github.com/github/gh-aw / fetchAuditRunWithCache

Function fetchAuditRunWithCache

pkg/cli/audit.go:531–547  ·  view source on GitHub ↗
(ctx context.Context, cfg auditRunConfig)

Source from the content-addressed store, hash-verified

529}
530
531func fetchAuditRunWithCache(ctx context.Context, cfg auditRunConfig) (WorkflowRun, bool, bool, error) {
532 hasLocalCache := fileutil.DirExists(cfg.outputDir) && !fileutil.IsDirEmpty(cfg.outputDir)
533 run, err := fetchWorkflowRunMetadata(ctx, cfg.runID, cfg.owner, cfg.repo, cfg.hostname, cfg.verbose)
534 if err == nil {
535 return run, hasLocalCache, false, nil
536 }
537 if !isPermissionError(err) {
538 return WorkflowRun{}, false, false, err
539 }
540 if !hasLocalCache {
541 return WorkflowRun{}, false, false, cacheRecoveryError(
542 "GitHub API access denied and no local cache found.", cfg.runID, cfg.outputDir, err,
543 )
544 }
545 fmt.Fprintln(os.Stderr, console.FormatWarningMessage("GitHub API access denied, but found locally cached artifacts. Processing cached data..."))
546 return run, hasLocalCache, true, nil
547}
548
549func downloadAuditArtifactsIfNeeded(ctx context.Context, cfg auditRunConfig, run WorkflowRun, hasLocalCache bool) (bool, error) {
550 if cfg.verbose {

Callers 1

prepareAuditWorkflowRunFunction · 0.85

Calls 6

DirExistsFunction · 0.92
IsDirEmptyFunction · 0.92
FormatWarningMessageFunction · 0.92
fetchWorkflowRunMetadataFunction · 0.85
isPermissionErrorFunction · 0.85
cacheRecoveryErrorFunction · 0.85

Tested by

no test coverage detected