displayMissingSecrets shows information about missing secrets with setup instructions
(requirements []SecretRequirement, repoSlug string, existingSecrets map[string]struct {
})
| 576 | |
| 577 | // displayMissingSecrets shows information about missing secrets with setup instructions |
| 578 | func displayMissingSecrets(requirements []SecretRequirement, repoSlug string, existingSecrets map[string]struct { |
| 579 | }) { |
| 580 | var requiredMissing, optionalMissing []SecretRequirement |
| 581 | |
| 582 | for _, req := range requirements { |
| 583 | // Check if secret exists |
| 584 | exists := setutil.Contains(existingSecrets, req.Name) || sliceutil.Any(req.AlternativeEnvVars, func(alt string) bool { |
| 585 | return setutil.Contains(existingSecrets, alt) |
| 586 | }) |
| 587 | |
| 588 | if !exists { |
| 589 | if req.Optional { |
| 590 | optionalMissing = append(optionalMissing, req) |
| 591 | } else { |
| 592 | requiredMissing = append(requiredMissing, req) |
| 593 | } |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | // Extract owner and repo from slug for command examples |
| 598 | parts := splitRepoSlug(repoSlug) |
| 599 | cmdOwner := parts[0] |
| 600 | cmdRepo := parts[1] |
| 601 | |
| 602 | if len(requiredMissing) > 0 { |
| 603 | fmt.Fprintln(os.Stderr, console.FormatErrorMessage("Required secrets are missing:")) |
| 604 | for _, req := range requiredMissing { |
| 605 | fmt.Fprintln(os.Stderr, "") |
| 606 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Secret: "+req.Name)) |
| 607 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("When needed: "+req.WhenNeeded)) |
| 608 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Recommended scopes: "+req.Description)) |
| 609 | fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf("gh aw secrets set %s --owner %s --repo %s", req.Name, cmdOwner, cmdRepo))) |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | if len(optionalMissing) > 0 { |
| 614 | fmt.Fprintln(os.Stderr, "") |
| 615 | fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Optional secrets are missing:")) |
| 616 | for _, req := range optionalMissing { |
| 617 | fmt.Fprintln(os.Stderr, "") |
| 618 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage(fmt.Sprintf("Secret: %s (optional)", req.Name))) |
| 619 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("When needed: "+req.WhenNeeded)) |
| 620 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Recommended scopes: "+req.Description)) |
| 621 | fmt.Fprintln(os.Stderr, console.FormatCommandMessage(fmt.Sprintf("gh aw secrets set %s --owner %s --repo %s", req.Name, cmdOwner, cmdRepo))) |
| 622 | } |
| 623 | } |
| 624 | |
| 625 | fmt.Fprintln(os.Stderr, "") |
| 626 | } |
| 627 | |
| 628 | // displaySecretsSummaryTable displays a summary table of all required secrets with their status |
| 629 | func displaySecretsSummaryTable(requirements []SecretRequirement, existingSecrets map[string]struct { |
no test coverage detected