init
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
257a78d24a
commit
ffaec04ccd
10
go.mod
10
go.mod
|
@ -3,8 +3,12 @@ module git.icechen.cn/pkg/drone_plugin
|
||||||
go 1.17
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/drone/drone-go v1.7.1 // indirect
|
github.com/drone/drone-go v1.7.1
|
||||||
github.com/kelseyhightower/envconfig v1.4.0 // indirect
|
github.com/kelseyhightower/envconfig v1.4.0
|
||||||
github.com/sirupsen/logrus v1.8.1 // indirect
|
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
|
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
|
||||||
)
|
)
|
||||||
|
|
1
go.sum
1
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/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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw=
|
github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw=
|
||||||
|
|
|
@ -5,18 +5,30 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/drone/drone-go/plugin/config"
|
||||||
|
|
||||||
"github.com/drone/drone-go/drone"
|
"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.
|
// New returns a new conversion plugin.
|
||||||
func New() converter.Plugin {
|
func New() config.Plugin {
|
||||||
return &plugin{}
|
return &plugin{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type plugin struct{}
|
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)
|
resp, err := json.Marshal(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%+v", err)
|
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))
|
fmt.Printf("%s", string(resp))
|
||||||
return &drone.Config{
|
return &drone.Config{
|
||||||
Data: req.Config.Data,
|
Data: defaultPipeline,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
5
main.go
5
main.go
|
@ -3,10 +3,11 @@ package main
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/drone/drone-go/plugin/config"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.icechen.cn/pkg/drone_plugin/go_coverter"
|
"git.icechen.cn/pkg/drone_plugin/go_coverter"
|
||||||
"github.com/drone/drone-go/plugin/converter"
|
|
||||||
"github.com/kelseyhightower/envconfig"
|
"github.com/kelseyhightower/envconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ func main() {
|
||||||
spec.Bind = ":3000"
|
spec.Bind = ":3000"
|
||||||
}
|
}
|
||||||
|
|
||||||
handler := converter.Handler(
|
handler := config.Handler(
|
||||||
go_coverter.New(),
|
go_coverter.New(),
|
||||||
spec.Secret,
|
spec.Secret,
|
||||||
logrus.StandardLogger(),
|
logrus.StandardLogger(),
|
||||||
|
|
Loading…
Reference in New Issue