Skip to content

Commit

Permalink
Report keyfiles that were found but failed import
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddeco committed Mar 1, 2019
1 parent 2723bfe commit 7f3ac80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/fluxd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
7 changes: 6 additions & 1 deletion gpg/gpg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 7f3ac80

Please sign in to comment.