-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
63 lines (51 loc) · 1.47 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"flag"
"fmt"
"sync"
"time"
"github.com/rs/zerolog"
)
var (
logger = zerolog.New(zerolog.NewConsoleWriter(func(w *zerolog.ConsoleWriter) {
w.TimeFormat = time.RFC3339
})).With().Timestamp().Logger()
)
func main() {
logger.Info().Msg("Loading configuration for notarization")
config, err := loadConfiguration()
switch {
case err == errBadFlags:
logger.Error().Msg("Some required flags are missing, please see usage for more help:")
fmt.Println()
flag.Usage()
return
case err != nil:
logger.Fatal().Err(err).Msg("Encountered error while parsing configuration")
}
var wait sync.WaitGroup
workers := make([]*Worker, len(config.Packages))
for i, p := range config.Packages {
wLogger := logger.With().Str("file", p.File).Logger()
wLogger.Info().Str("file", p.File).Msg("Spawning notarization worker")
worker, err := NewWorker(config, p, &wait, wLogger)
if err != nil {
logger.Error().Err(err).Msg("Failed to spawn notarization worker")
continue
}
workers[i] = worker
}
wait.Wait()
logger.Info().Msg("Notarization completed, saving log files")
for _, worker := range workers {
if worker.log == nil {
worker.logger.Error().Msg("No notarization log file available to save")
continue
}
if path, err := worker.saveLog(); err != nil {
worker.logger.Error().Err(err).Msg("Encountered error while saving notarization log")
} else {
worker.logger.Info().Str("log-file", path).Msg("Saved notarization log")
}
}
}