func main()

in cmd/summarizer/main.go [107:168]


func main() {

	opt := gatherOptions()
	if err := opt.validate(); err != nil {
		logrus.Fatalf("Invalid flags: %v", err)
	}
	if !opt.confirm {
		logrus.Warning("--confirm=false (DRY-RUN): will not write to gcs")
	}

	switch {
	case opt.trace:
		logrus.SetLevel(logrus.TraceLevel)
	case opt.debug:
		logrus.SetLevel(logrus.DebugLevel)
	}

	if opt.jsonLogs {
		logrus.SetFormatter(&logrus.JSONFormatter{})
	}
	logrus.SetReportCaller(true)

	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()
	storageClient, err := gcs.ClientWithCreds(ctx, opt.creds)
	if err != nil {
		logrus.WithError(err).Fatal("Failed to read storage client")
	}

	client := gcs.NewClient(storageClient)
	metrics := summarizer.CreateMetrics(prometheus.NewFactory())
	fixer, err := gcsFixer(ctx, opt.pubsub, opt.config, opt.tabPathPrefix, opt.creds)
	if err != nil {
		logrus.WithError(err).WithField("subscription", opt.pubsub).Fatal("Failed to configure pubsub")
	}

	fixers := make([]summarizer.Fixer, 0, 2)
	if fixer != nil {
		fixers = append(fixers, fixer)
	}
	if path := opt.persistQueue; path.String() != "" {
		const freq = time.Minute
		ticker := time.NewTicker(freq)
		log := logrus.WithField("frequency", freq)
		fixers = append(fixers, summarizer.FixPersistent(log, client, path, ticker.C))
	}

	opts := &summarizer.UpdateOptions{
		ConfigPath:        opt.config,
		Concurrency:       opt.concurrency,
		TabPathPrefix:     opt.tabPathPrefix,
		SummaryPathPrefix: opt.summaryPathPrefix,
		AllowedDashboards: opt.dashboards.Strings(),
		Confirm:           opt.confirm,
		Features:          opt.features,
		Freq:              opt.wait,
	}

	if err := summarizer.Update(ctx, client, metrics, opts, fixers...); err != nil {
		logrus.WithError(err).Error("Could not summarize")
	}
}