Skip to content

Commit

Permalink
Use out.Write consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
willdollman committed Oct 11, 2024
1 parent 8b56238 commit bf0142d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cmd/src/sbom_fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ Examples:
insecureIgnoreTransparencyLogFlag := flagSet.Bool("insecure-ignore-tlog", false, "Disable transparency log verification. Defaults to false.")

handler := func(args []string) error {
// ctx := context.Background()

c := sbomConfig{
publicKey: publicKey,
}
Expand Down Expand Up @@ -99,7 +97,7 @@ Examples:
return err
}

fmt.Printf("Fetching SBOMs and validating signatures for all %d images in the Sourcegraph %s release...\n\n", len(images), c.version)
out.Writef("Fetching SBOMs and validating signatures for all %d images in the Sourcegraph %s release...\n", len(images), c.version)

if c.insecureIgnoreTransparencyLog {
out.WriteLine(output.Line("⚠️", output.StyleWarning, "WARNING: Transparency log verification is disabled, increasing the risk that SBOMs may have been tampered with.\nThis setting should only be used for testing or under explicit instruction from Sourcegraph.\n"))
Expand All @@ -124,7 +122,7 @@ Examples:
}
}

fmt.Printf("\n")
out.Write("")
if failureCount == 0 && successCount == 0 {
out.WriteLine(output.Line("🔴", output.StyleWarning, "Failed to fetch SBOMs for any images"))
}
Expand All @@ -134,8 +132,8 @@ Examples:
out.WriteLine(output.Line("🟢", output.StyleSuccess, fmt.Sprintf("Fetched verified SBOMs for %d images", successCount)))
}

fmt.Printf("\nFetched and validated SBOMs have been written to `%s`\n", c.outputDir)
fmt.Printf("\nYour Sourcegraph deployment may not use all of these image. Please check your deployment to confirm which images are used.\n\n")
out.Writef("\nFetched and validated SBOMs have been written to `%s`.\n", c.outputDir)
out.WriteLine(output.Linef("", output.StyleBold, "Your Sourcegraph deployment may not use all of these image. Please check your deployment to confirm which images are used.\n"))

if failureCount > 0 || successCount == 0 {
return cmderrors.ExitCode1
Expand Down Expand Up @@ -178,6 +176,9 @@ func verifyCosign() error {
}

func (c sbomConfig) getImageList() ([]string, error) {

return []string{"sourcegraph/gitserver"}, nil

imageReleaseListURL := c.getImageReleaseListURL()

Check failure on line 182 in cmd/src/sbom_fetch.go

View workflow job for this annotation

GitHub Actions / go-lint

unreachable: unreachable code (govet)

resp, err := http.Get(imageReleaseListURL)
Expand Down

0 comments on commit bf0142d

Please sign in to comment.