github.com/nilium/gitlab-runner@v12.5.0+incompatible/apps/gitlab-runner-helper/main.go (about)

     1  package main
     2  
     3  import (
     4  	"os"
     5  	"path"
     6  
     7  	"github.com/sirupsen/logrus"
     8  	"github.com/urfave/cli"
     9  
    10  	"gitlab.com/gitlab-org/gitlab-runner/common"
    11  	"gitlab.com/gitlab-org/gitlab-runner/log"
    12  
    13  	_ "gitlab.com/gitlab-org/gitlab-runner/commands/helpers"
    14  )
    15  
    16  func main() {
    17  	defer func() {
    18  		if r := recover(); r != nil {
    19  			// log panics forces exit
    20  			if _, ok := r.(*logrus.Entry); ok {
    21  				os.Exit(1)
    22  			}
    23  			panic(r)
    24  		}
    25  	}()
    26  
    27  	app := cli.NewApp()
    28  	app.Name = path.Base(os.Args[0])
    29  	app.Usage = "a GitLab Runner Helper"
    30  	app.Version = common.AppVersion.ShortLine()
    31  	cli.VersionPrinter = common.AppVersion.Printer
    32  	app.Authors = []cli.Author{
    33  		{
    34  			Name:  "GitLab Inc.",
    35  			Email: "support@gitlab.com",
    36  		},
    37  	}
    38  	app.Commands = common.GetCommands()
    39  	app.CommandNotFound = func(context *cli.Context, command string) {
    40  		logrus.Fatalln("Command", command, "not found")
    41  	}
    42  
    43  	log.AddSecretsCleanupLogHook(logrus.StandardLogger())
    44  	log.ConfigureLogging(app)
    45  
    46  	if err := app.Run(os.Args); err != nil {
    47  		logrus.Fatal(err)
    48  	}
    49  }