Files
plugin-drone-gitleaks/main.go
T
Brad Rydzewski b560a7c0bb initial commit
2021-11-05 21:38:28 -04:00

51 lines
1.1 KiB
Go

// Copyright 2020 the Drone Authors. All rights reserved.
// Use of this source code is governed by the Blue Oak Model License
// that can be found in the LICENSE file.
package main
import (
"context"
"github.com/drone/drone-gitleaks/plugin"
"github.com/kelseyhightower/envconfig"
"github.com/sirupsen/logrus"
)
func main() {
logrus.SetFormatter(new(formatter))
var args plugin.Args
if err := envconfig.Process("", &args); err != nil {
logrus.Fatalln(err)
}
switch args.Level {
case "debug":
logrus.SetLevel(logrus.DebugLevel)
case "trace":
logrus.SetLevel(logrus.TraceLevel)
}
// set the default formatter
logrus.SetFormatter(&logrus.TextFormatter{})
if err := plugin.Exec(context.Background(), args); err != nil {
logrus.Fatalln(err)
}
}
// default formatter that writes logs without including timestamp
// or level information.
type formatter struct{}
func (*formatter) Format(entry *logrus.Entry) ([]byte, error) {
return []byte(entry.Message), nil
}
// text formatter that writes logs with level information
var textFormatter = &logrus.TextFormatter{
DisableTimestamp: true,
}