harness-drone/shared/remote/remote.go

97 lines
2.2 KiB
Go
Raw Normal View History

2014-06-04 21:25:38 +00:00
package remote
import (
"net/http"
)
type Remote interface {
// Name returns the name of this remote system.
GetName() string
// GetHook parses the post-commit hook from the Request body
// and returns the required data in a standard format.
GetHook(*http.Request) (*Hook, error)
// GetLogin handles authentication to third party, remote services
// and returns the required user data in a standard format.
GetLogin(http.ResponseWriter, *http.Request) (*Login, error)
// NewClient returns a new Bitbucket remote client.
GetClient(access, secret string) Client
// Match returns true if the hostname matches the
// hostname of this remote client.
IsMatch(hostname string) bool
}
type Client interface {
// GetUser fetches the user by ID (login name).
GetUser(login string) (*User, error)
// GetRepos fetches all repositories that the specified
// user has access to in the remote system.
GetRepos(owner string) ([]*Repo, error)
// GetScript fetches the build script (.drone.yml) from the remote
// repository and returns in string format.
GetScript(*Hook) (string, error)
// SetStatus
SetStatus(owner, repo, sha, status string) error
// SetActive
SetActive(owner, repo, hook, key string) error
}
// Hook represents a subset of commit meta-data provided
// by post-commit and pull request hooks.
type Hook struct {
Owner string
Repo string
Sha string
Branch string
PullRequest string
Author string
Gravatar string
Timestamp string
Message string
}
// Login represents a standard subset of user meta-data
// provided by OAuth login services.
type Login struct {
ID int64
Login string
Access string
Secret string
Name string
Email string
}
// User represents a standard subset of user meta-data
// returned by REST API user endpoints (ie github user api).
type User struct {
ID int64
Login string
Name string
Gravatar string
}
// Repo represents a standard subset of repository meta-data
// returned by REST API endpoints (ie github repo api).
type Repo struct {
ID int64
Host string
Owner string
Name string
Kind string
Clone string
Git string
SSH string
URL string
Private bool
Pull bool
Push bool
Admin bool
2014-06-04 21:25:38 +00:00
}