From ffaec04ccd6a0e8f2c1ff47f21c02a17cb42688f Mon Sep 17 00:00:00 2001 From: icechen Date: Tue, 28 Dec 2021 16:23:53 +0800 Subject: [PATCH] init --- go.mod | 10 +++++++--- go.sum | 1 + go_coverter/go_coverter.go | 20 ++++++++++++++++---- main.go | 5 +++-- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 38169aa..04cab85 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,12 @@ module git.icechen.cn/pkg/drone_plugin go 1.17 require ( - github.com/drone/drone-go v1.7.1 // indirect - github.com/kelseyhightower/envconfig v1.4.0 // indirect - github.com/sirupsen/logrus v1.8.1 // indirect + github.com/drone/drone-go v1.7.1 + github.com/kelseyhightower/envconfig v1.4.0 + github.com/sirupsen/logrus v1.8.1 +) + +require ( + github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e // indirect golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect ) diff --git a/go.sum b/go.sum index a4b2c7c..c2d34a9 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e h1:rl2Aq4ZODqTDkeSqQBy+fzpZPamacO1Srp8zq7jf2Sc= github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e/go.mod h1:Xa6lInWHNQnuWoF0YPSsx+INFA9qk7/7pTjwb3PInkY= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw= diff --git a/go_coverter/go_coverter.go b/go_coverter/go_coverter.go index 1864799..6d03800 100644 --- a/go_coverter/go_coverter.go +++ b/go_coverter/go_coverter.go @@ -5,18 +5,30 @@ import ( "encoding/json" "fmt" + "github.com/drone/drone-go/plugin/config" + "github.com/drone/drone-go/drone" - "github.com/drone/drone-go/plugin/converter" ) +const defaultPipeline = ` +kind: pipeline +name: default +steps: +- name: build + image: golang + commands: + - go build + - go test -v +` + // New returns a new conversion plugin. -func New() converter.Plugin { +func New() config.Plugin { return &plugin{} } type plugin struct{} -func (p *plugin) Convert(ctx context.Context, req *converter.Request) (*drone.Config, error) { +func (p *plugin) Find(ctx context.Context, req *config.Request) (*drone.Config, error) { resp, err := json.Marshal(req) if err != nil { fmt.Printf("%+v", err) @@ -24,6 +36,6 @@ func (p *plugin) Convert(ctx context.Context, req *converter.Request) (*drone.Co } fmt.Printf("%s", string(resp)) return &drone.Config{ - Data: req.Config.Data, + Data: defaultPipeline, }, nil } diff --git a/main.go b/main.go index 4a257bb..79da67c 100644 --- a/main.go +++ b/main.go @@ -3,10 +3,11 @@ 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/drone/drone-go/plugin/converter" "github.com/kelseyhightower/envconfig" ) @@ -34,7 +35,7 @@ func main() { spec.Bind = ":3000" } - handler := converter.Handler( + handler := config.Handler( go_coverter.New(), spec.Secret, logrus.StandardLogger(),