woodpecker/pkg/remote/client/client.go

75 lines
1.6 KiB
Go
Raw Normal View History

2015-04-08 22:00:27 +00:00
package client
import (
"net"
"net/http"
"net/rpc"
2015-05-30 05:04:41 +00:00
"github.com/drone/drone/pkg/config"
2015-05-17 20:51:42 +00:00
common "github.com/drone/drone/pkg/types"
2015-04-08 22:00:27 +00:00
)
// Client communicates with a Remote plugin using the
// net/rpc protocol.
type Client struct {
*rpc.Client
}
// New returns a new, remote datastore backend that connects
// via tcp and exchanges data using Go's RPC mechanism.
2015-05-30 05:04:41 +00:00
func New(conf *config.Config) (*Client, error) {
conn, err := net.Dial("tcp", conf.Server.Addr)
2015-04-08 22:00:27 +00:00
if err != nil {
return nil, err
}
client := &Client{
rpc.NewClient(conn),
}
return client, nil
}
func (c *Client) Login(token, secret string) (*common.User, error) {
return nil, nil
}
// Repo fetches the named repository from the remote system.
func (c *Client) Repo(u *common.User, owner, repo string) (*common.Repo, error) {
return nil, nil
}
func (c *Client) Perm(u *common.User, owner, repo string) (*common.Perm, error) {
return nil, nil
}
func (c *Client) Script(u *common.User, r *common.Repo, b *common.Build) ([]byte, error) {
return nil, nil
}
func (c *Client) Status(u *common.User, r *common.Repo, b *common.Build, link string) error {
return nil
}
func (c *Client) Activate(u *common.User, r *common.Repo, k *common.Keypair, link string) error {
return nil
}
func (c *Client) Deactivate(u *common.User, r *common.Repo, link string) error {
return nil
}
func (c *Client) Hook(r *http.Request) (*common.Hook, error) {
hook := new(common.Hook)
header := make(http.Header)
copyHeader(r.Header, header)
return hook, nil
}
func copyHeader(dst, src http.Header) {
for k, vv := range src {
for _, v := range vv {
dst.Add(k, v)
}
}
}