github.com/secure-build/gitlab-runner@v12.5.0+incompatible/commands/list.go (about)

     1  package commands
     2  
     3  import (
     4  	"github.com/sirupsen/logrus"
     5  	"github.com/urfave/cli"
     6  
     7  	"gitlab.com/gitlab-org/gitlab-runner/common"
     8  )
     9  
    10  type ListCommand struct {
    11  	configOptions
    12  }
    13  
    14  func (c *ListCommand) Execute(context *cli.Context) {
    15  	err := c.loadConfig()
    16  	if err != nil {
    17  		logrus.Warningln(err)
    18  		return
    19  	}
    20  
    21  	logrus.WithFields(logrus.Fields{
    22  		"ConfigFile": c.ConfigFile,
    23  	}).Println("Listing configured runners")
    24  
    25  	for _, runner := range c.config.Runners {
    26  		logrus.WithFields(logrus.Fields{
    27  			"Executor": runner.RunnerSettings.Executor,
    28  			"Token":    runner.RunnerCredentials.Token,
    29  			"URL":      runner.RunnerCredentials.URL,
    30  		}).Println(runner.Name)
    31  	}
    32  }
    33  
    34  func init() {
    35  	common.RegisterCommand2("list", "List all configured runners", &ListCommand{})
    36  }