package main import ( "net/http" "github.com/drone/drone-go/plugin/config" "github.com/sirupsen/logrus" "git.icechen.cn/pkg/drone_plugin/go_coverter" "github.com/kelseyhightower/envconfig" ) // spec provides the plugin settings. type spec struct { Bind string `envconfig:"DRONE_BIND"` Debug bool `envconfig:"DRONE_DEBUG"` Secret string `envconfig:"DRONE_SECRET"` } func main() { spec := new(spec) err := envconfig.Process("", spec) if err != nil { logrus.Fatal(err) } if spec.Debug { logrus.SetLevel(logrus.DebugLevel) } if spec.Secret == "" { logrus.Fatalln("missing secret key") } if spec.Bind == "" { spec.Bind = ":3000" } handler := config.Handler( go_coverter.New(), spec.Secret, logrus.StandardLogger(), ) logrus.Infof("server listening on address %s", spec.Bind) http.Handle("/", handler) logrus.Fatal(http.ListenAndServe(spec.Bind, nil)) }