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

Function displaySecretsSummaryTable

pkg/cli/engine_secrets.go:629–692  ·  view source on GitHub ↗

displaySecretsSummaryTable displays a summary table of all required secrets with their status

(requirements []SecretRequirement, existingSecrets map[string]struct {
})

Source from the content-addressed store, hash-verified

627
628// displaySecretsSummaryTable displays a summary table of all required secrets with their status
629func displaySecretsSummaryTable(requirements []SecretRequirement, existingSecrets map[string]struct {
630}) {
631 // Filter to only required secrets (not optional)
632 var requiredOnly []SecretRequirement
633 for _, req := range requirements {
634 if !req.Optional {
635 requiredOnly = append(requiredOnly, req)
636 }
637 }
638
639 // If no required secrets, don't show the table
640 if len(requiredOnly) == 0 {
641 return
642 }
643
644 fmt.Fprintln(os.Stderr, "")
645 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Required secrets summary:"))
646 fmt.Fprintln(os.Stderr, "")
647
648 // Calculate max width for alignment
649 maxNameWidth := 0
650 for _, req := range requiredOnly {
651 if len(req.Name) > maxNameWidth {
652 maxNameWidth = len(req.Name)
653 }
654 }
655
656 // Display each required secret with status
657 for _, req := range requiredOnly {
658 // Check if secret exists
659 exists := setutil.Contains(existingSecrets, req.Name)
660 var altUsed string
661 if !exists {
662 // Check alternatives
663 for _, alt := range req.AlternativeEnvVars {
664 if setutil.Contains(existingSecrets, alt) {
665 exists = true
666 altUsed = alt
667 break
668 }
669 }
670 }
671
672 // Format status indicator
673 var statusLine string
674 if exists {
675 if altUsed != "" {
676 statusLine = console.FormatSuccessMessage(fmt.Sprintf("(via %s)", altUsed))
677 } else {
678 statusLine = console.FormatSuccessMessage("")
679 }
680 } else {
681 statusLine = console.FormatErrorMessage("")
682 }
683
684 // Format secret name with padding
685 nameWithPadding := fmt.Sprintf("%-*s", maxNameWidth, req.Name)
686

Callers 1

runTokensBootstrapFunction · 0.85

Calls 4

FormatInfoMessageFunction · 0.92
ContainsFunction · 0.92
FormatSuccessMessageFunction · 0.92
FormatErrorMessageFunction · 0.92

Tested by

no test coverage detected