This commit is contained in:
		
							parent
							
								
									257a78d24a
								
							
						
					
					
						commit
						ffaec04ccd
					
				
							
								
								
									
										10
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								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
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 | 
			
		||||
github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw=
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								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(),
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user