drone_plugin/go_coverter/go_coverter.go

30 lines
543 B
Go
Raw Normal View History

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"
"github.com/drone/drone-go/drone"
"github.com/drone/drone-go/plugin/converter"
)
// New returns a new conversion plugin.
func New() converter.Plugin {
return &plugin{}
}
type plugin struct{}
func (p *plugin) Convert(ctx context.Context, req *converter.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{
Data: req.Config.Data,
}, nil
}