Browse Source

Report keyfiles that were found but failed import

Hidde Beydals 7 months ago
parent
commit
7f3ac80599
2 changed files with 8 additions and 2 deletions
  1. 2
    1
      cmd/fluxd/main.go
  2. 6
    1
      gpg/gpg.go

+ 2
- 1
cmd/fluxd/main.go View File

@@ -200,7 +200,8 @@ func main() {
200 200
 		keyfiles, err := gpg.ImportKeys(*gitImportGPG)
201 201
 		if err != nil {
202 202
 			logger.Log("error", "failed to import GPG keys", "err", err.Error())
203
-		} else {
203
+		}
204
+		if keyfiles != nil {
204 205
 			logger.Log("info", "imported GPG keys", "files", fmt.Sprintf("%v", keyfiles))
205 206
 		}
206 207
 	}

+ 6
- 1
gpg/gpg.go View File

@@ -40,15 +40,20 @@ func ImportKeys(src string) ([]string, error) {
40 40
 		files = []string{src}
41 41
 	}
42 42
 
43
-
44 43
 	var imported []string
44
+	var failed []string
45 45
 	for _, path := range files {
46 46
 		if err := gpgImport(path); err != nil {
47
+			failed = append(failed, filepath.Base(path))
47 48
 			continue
48 49
 		}
49 50
 		imported = append(imported, filepath.Base(path))
50 51
 	}
51 52
 
53
+	if failed != nil {
54
+		return imported, fmt.Errorf("errored importing keys: %v", failed)
55
+	}
56
+
52 57
 	return imported, nil
53 58
 }
54 59
 

Loading…
Cancel
Save