43 lines
688 B
Go
43 lines
688 B
Go
package go_coverter
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
"github.com/drone/drone-go/plugin/config"
|
|
|
|
"github.com/drone/drone-go/drone"
|
|
)
|
|
|
|
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() config.Plugin {
|
|
return &plugin{}
|
|
}
|
|
|
|
type plugin struct{}
|
|
|
|
func (p *plugin) Find(ctx context.Context, req *config.Request) (*drone.Config, error) {
|
|
resp, err := json.Marshal(req)
|
|
if err != nil {
|
|
logrus.Error(err)
|
|
return nil, err
|
|
}
|
|
logrus.Infof("%s", string(resp))
|
|
return &drone.Config{
|
|
Data: defaultPipeline,
|
|
}, nil
|
|
}
|