diff --git a/cmd/fluxd/main.go b/cmd/fluxd/main.go index 422531700..9cd41930d 100644 --- a/cmd/fluxd/main.go +++ b/cmd/fluxd/main.go @@ -200,7 +200,8 @@ func main() { keyfiles, err := gpg.ImportKeys(*gitImportGPG) if err != nil { logger.Log("error", "failed to import GPG keys", "err", err.Error()) - } else { + } + if keyfiles != nil { logger.Log("info", "imported GPG keys", "files", fmt.Sprintf("%v", keyfiles)) } } diff --git a/gpg/gpg.go b/gpg/gpg.go index 11d7d6ca8..b5ccb4138 100644 --- a/gpg/gpg.go +++ b/gpg/gpg.go @@ -40,15 +40,20 @@ func ImportKeys(src string) ([]string, error) { files = []string{src} } - var imported []string + var failed []string for _, path := range files { if err := gpgImport(path); err != nil { + failed = append(failed, filepath.Base(path)) continue } imported = append(imported, filepath.Base(path)) } + if failed != nil { + return imported, fmt.Errorf("errored importing keys: %v", failed) + } + return imported, nil }