func main()

in tools/eksDistroBuildToolingOpsTools/cmd/eksDistroOpsProwPlugin/main.go [86:162]


func main() {
	logrusutil.ComponentInit()
	o := gatherOptions()
	if err := o.Validate(); err != nil {
		logrus.Fatalf("Invalid options: %v", err)
	}

	logLevel, err := logrus.ParseLevel(o.logLevel)
	if err != nil {
		logrus.WithError(err).Fatal("Failed to parse loglevel")
	}
	logrus.SetLevel(logLevel)
	log := logrus.StandardLogger().WithField("plugin", opstool.PluginName)

	if err := secret.Add(o.webhookSecretFile); err != nil {
		logrus.WithError(err).Fatal("Error starting secrets agent.")
	}

	githubClient, err := o.github.GitHubClient(o.dryRun)
	if err != nil {
		logrus.WithError(err).Fatal("Error getting GitHub client.")
	}
	gitClient, err := o.github.GitClientFactory("", nil, o.dryRun, false)
	if err != nil {
		logrus.WithError(err).Fatal("Error getting Git client.")
	}
	interrupts.OnInterrupt(func() {
		if err := gitClient.Clean(); err != nil {
			logrus.WithError(err).Error("Could not clean up git client cache.")
		}
	})

	email, err := githubClient.Email()
	if err != nil {
		log.WithError(err).Fatal("Error getting bot e-mail.")
	}

	botUser, err := githubClient.BotUser()
	if err != nil {
		logrus.WithError(err).Fatal("Error getting bot name.")
	}
	repos, err := githubClient.GetRepos(botUser.Login, true)
	if err != nil {
		log.WithError(err).Fatal("Error listing bot repositories.")
	}

	s := &opstool.Server{
		TokenGenerator: secret.GetTokenGenerator(o.webhookSecretFile),
		BotUser:        botUser,
		Email:          email,

		Gc:  gitClient,
		Ghc: githubClient,
		Log: log,

		Labels:          o.labels.Strings(),
		ProwAssignments: o.prowAssignments,
		AllowAll:        o.allowAll,
		IssueOnConflict: o.issueOnConflict,
		LabelPrefix:     o.labelPrefix,

		Bare:     &http.Client{},
		PatchURL: "https://patch-diff.githubusercontent.com",

		Repos: repos,
	}

	health := pjutil.NewHealthOnPort(o.instrumentationOptions.HealthPort)
	health.ServeReady()

	mux := http.NewServeMux()
	mux.Handle("/", s)
	externalplugins.ServeExternalPluginHelp(mux, log, opstool.HelpProvider)
	httpServer := &http.Server{Addr: ":" + strconv.Itoa(o.port), Handler: mux}
	defer interrupts.WaitForGracefulShutdown()
	interrupts.ListenAndServe(httpServer, 5*time.Second)
}