github.com/alloyci/alloy-runner@v1.0.1-0.20180222164613-925503ccafd6/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  	"gitlab.com/gitlab-org/gitlab-runner/common"
    10  	"gitlab.com/gitlab-org/gitlab-runner/helpers/cli"
    11  	"gitlab.com/gitlab-org/gitlab-runner/helpers/formatter"
    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  	formatter.SetRunnerFormatter()
    28  	cli_helpers.AddSecretsCleanupLogHook()
    29  
    30  	app := cli.NewApp()
    31  	app.Name = path.Base(os.Args[0])
    32  	app.Usage = "an Alloy Runner Helper"
    33  	app.Version = common.AppVersion.ShortLine()
    34  	cli.VersionPrinter = common.AppVersion.Printer
    35  	app.Authors = []cli.Author{
    36  		{
    37  			Name:  "Patricio Cano",
    38  			Email: "admin@alloy-ci.com",
    39  		},
    40  	}
    41  	cli_helpers.SetupLogLevelOptions(app)
    42  	app.Commands = common.GetCommands()
    43  	app.CommandNotFound = func(context *cli.Context, command string) {
    44  		logrus.Fatalln("Command", command, "not found")
    45  	}
    46  
    47  	if err := app.Run(os.Args); err != nil {
    48  		logrus.Fatal(err)
    49  	}
    50  }