list-*: Ensure we list all entries on error

Return some formatted string and return nil instead of aborting the
entire listing when we encounter an error.

Fixes: https://github.com/Foxboron/sbctl/issues/88

Signed-off-by: Morten Linderud <morten@linderud.pw>
This commit is contained in:
Morten Linderud 2021-09-05 14:54:03 +02:00
parent 947b6ba8e8
commit 9ff60964d5
No known key found for this signature in database
GPG Key ID: E742683BA08CB2FF
3 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"strings"
"github.com/foxboron/sbctl"
@ -23,7 +24,8 @@ var listBundlesCmd = &cobra.Command{
func(s *sbctl.Bundle) error {
ok, err := sbctl.VerifyFile(sbctl.DBCert, s.Output)
if err != nil {
return err
logging.Error(fmt.Errorf("%s: %w\n", s.Output, err))
return nil
}
logging.Println("Enrolled bundles:\n")
logging.Println(s.Output)

View File

@ -1,6 +1,8 @@
package main
import (
"fmt"
"github.com/foxboron/sbctl"
"github.com/foxboron/sbctl/logging"
"github.com/spf13/cobra"
@ -24,7 +26,8 @@ func RunList(_ *cobra.Command, args []string) error {
func(s *sbctl.SigningEntry) error {
ok, err := sbctl.VerifyFile(sbctl.DBCert, s.OutputFile)
if err != nil {
return err
logging.Error(fmt.Errorf("%s: %w\n", s.OutputFile, err))
return nil
}
logging.Println(s.File)
logging.Print("Signed:\t\t")

View File

@ -2,6 +2,7 @@ package main
import (
"errors"
"fmt"
"github.com/foxboron/sbctl"
"github.com/foxboron/sbctl/logging"