2021-12-28 15:20:31 +08:00
|
|
|
package go_coverter
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-12-28 16:09:37 +08:00
|
|
|
"encoding/json"
|
2021-12-28 15:20:31 +08:00
|
|
|
"fmt"
|
|
|
|
|
2021-12-28 16:23:53 +08:00
|
|
|
"github.com/drone/drone-go/plugin/config"
|
|
|
|
|
2021-12-28 15:20:31 +08:00
|
|
|
"github.com/drone/drone-go/drone"
|
|
|
|
)
|
|
|
|
|
2021-12-28 16:23:53 +08:00
|
|
|
const defaultPipeline = `
|
|
|
|
kind: pipeline
|
|
|
|
name: default
|
|
|
|
steps:
|
|
|
|
- name: build
|
|
|
|
image: golang
|
|
|
|
commands:
|
|
|
|
- go build
|
|
|
|
- go test -v
|
|
|
|
`
|
|
|
|
|
2021-12-28 15:20:31 +08:00
|
|
|
// New returns a new conversion plugin.
|
2021-12-28 16:23:53 +08:00
|
|
|
func New() config.Plugin {
|
2021-12-28 15:20:31 +08:00
|
|
|
return &plugin{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type plugin struct{}
|
|
|
|
|
2021-12-28 16:23:53 +08:00
|
|
|
func (p *plugin) Find(ctx context.Context, req *config.Request) (*drone.Config, error) {
|
2021-12-28 16:09:37 +08:00
|
|
|
resp, err := json.Marshal(req)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("%+v", err)
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
fmt.Printf("%s", string(resp))
|
2021-12-28 15:20:31 +08:00
|
|
|
return &drone.Config{
|
2021-12-28 16:23:53 +08:00
|
|
|
Data: defaultPipeline,
|
2021-12-28 15:20:31 +08:00
|
|
|
}, nil
|
|
|
|
}
|