-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
58 lines (45 loc) · 1.42 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// 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-testng/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.Fatalf("\nFailed to process arguments: %s", err)
}
switch args.Level {
case "debug":
logrus.SetFormatter(textFormatter)
logrus.SetLevel(logrus.DebugLevel)
case "trace":
logrus.SetFormatter(textFormatter)
logrus.SetLevel(logrus.TraceLevel)
}
logrus.Info("Starting TestNG to JUnit plugin execution\n")
// Validate user inputs
if err := plugin.ValidateInputs(args); err != nil {
logrus.Fatalf("\nInput validation failed: %s", err)
}
// Execute the plugin logic
if err := plugin.Exec(context.Background(), args); err != nil {
logrus.Fatalf("\nPlugin execution failed")
}
logrus.Info("\nPlugin execution completed successfully")
}
// 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,
}