MCPcopy Create free account
hub / github.com/cli/cli / printInspectionSummary

Function printInspectionSummary

pkg/cmd/attestation/inspect/inspect.go:252–282  ·  view source on GitHub ↗
(logger *io.Handler, bundles []BundleInspection)

Source from the content-addressed store, hash-verified

250}
251
252func printInspectionSummary(logger *io.Handler, bundles []BundleInspection) {
253 logger.Printf("Inspecting bundles…\n")
254 logger.Printf("Found %s:\n---\n", text.Pluralize(len(bundles), "attestation"))
255
256 bundleSummaries := make([][][]string, len(bundles))
257 for i, iB := range bundles {
258 bundleSummaries[i] = [][]string{
259 {"Authentic", formatAuthentic(iB.Authentic, iB.Certificate.CertificateIssuer)},
260 {"Source Repo", formatNwo(iB.Certificate.SourceRepositoryURI)},
261 {"PredicateType", iB.Statement.GetPredicateType()},
262 {"SubjectAlternativeName", iB.Certificate.SubjectAlternativeName},
263 {"RunInvocationURI", iB.Certificate.RunInvocationURI},
264 {"CertificateNotBefore", iB.Certificate.NotBefore.Format(time.RFC3339)},
265 }
266 }
267
268 // "SubjectAlternativeName" has 22 chars
269 maxNameLength := 22
270
271 scheme := logger.ColorScheme
272 for i, bundle := range bundleSummaries {
273 for _, pair := range bundle {
274 colName := pair[0]
275 dots := maxNameLength - len(colName)
276 logger.OutPrintf("%s:%s %s\n", scheme.Bold(colName), strings.Repeat(".", dots), pair[1])
277 }
278 if i < len(bundleSummaries)-1 {
279 logger.OutPrintln("---")
280 }
281 }
282}
283
284func formatNwo(longUrl string) string {
285 repo, err := ghrepo.FromFullName(longUrl)

Callers 1

runInspectFunction · 0.85

Calls 7

PluralizeFunction · 0.92
formatAuthenticFunction · 0.85
formatNwoFunction · 0.85
OutPrintfMethod · 0.80
BoldMethod · 0.80
OutPrintlnMethod · 0.80
PrintfMethod · 0.65

Tested by

no test coverage detected