2015-04-08 22:00:27 +00:00
|
|
|
package github
|
|
|
|
|
|
|
|
import (
|
2015-07-23 17:36:23 +00:00
|
|
|
"crypto/tls"
|
2015-04-08 22:00:27 +00:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
2015-04-28 21:39:48 +00:00
|
|
|
"net/url"
|
2015-04-08 22:00:27 +00:00
|
|
|
"strings"
|
2015-05-11 07:45:31 +00:00
|
|
|
"time"
|
2015-04-08 22:00:27 +00:00
|
|
|
|
2015-05-22 18:37:40 +00:00
|
|
|
"github.com/drone/drone/Godeps/_workspace/src/github.com/hashicorp/golang-lru"
|
2015-05-28 07:18:46 +00:00
|
|
|
"github.com/drone/drone/pkg/config"
|
2015-07-23 17:36:23 +00:00
|
|
|
"github.com/drone/drone/pkg/oauth2"
|
2015-05-17 20:51:42 +00:00
|
|
|
common "github.com/drone/drone/pkg/types"
|
2015-07-23 17:36:23 +00:00
|
|
|
"github.com/drone/drone/pkg/utils/httputil"
|
2015-04-08 22:00:27 +00:00
|
|
|
|
2015-05-22 18:37:40 +00:00
|
|
|
"github.com/drone/drone/Godeps/_workspace/src/github.com/google/go-github/github"
|
2015-04-08 22:00:27 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
DefaultScope = "repo,repo:status,user:email"
|
|
|
|
)
|
|
|
|
|
|
|
|
type GitHub struct {
|
|
|
|
URL string
|
|
|
|
API string
|
|
|
|
Client string
|
|
|
|
Secret string
|
2015-07-23 17:36:23 +00:00
|
|
|
AllowedOrgs []string
|
|
|
|
Open bool
|
2015-04-08 22:00:27 +00:00
|
|
|
PrivateMode bool
|
|
|
|
SkipVerify bool
|
|
|
|
|
|
|
|
cache *lru.Cache
|
|
|
|
}
|
|
|
|
|
2015-05-28 07:18:46 +00:00
|
|
|
func New(conf *config.Config) *GitHub {
|
2015-04-08 22:00:27 +00:00
|
|
|
var github = GitHub{
|
2015-07-23 17:36:23 +00:00
|
|
|
API: conf.Github.API,
|
|
|
|
URL: conf.Github.Host,
|
|
|
|
Client: conf.Github.Client,
|
|
|
|
Secret: conf.Github.Secret,
|
|
|
|
AllowedOrgs: conf.Github.Orgs,
|
|
|
|
Open: conf.Github.Open,
|
|
|
|
PrivateMode: conf.Github.PrivateMode,
|
|
|
|
SkipVerify: conf.Github.SkipVerify,
|
2015-04-08 22:00:27 +00:00
|
|
|
}
|
|
|
|
var err error
|
|
|
|
github.cache, err = lru.New(1028)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
// the API must have a trailing slash
|
|
|
|
if !strings.HasSuffix(github.API, "/") {
|
|
|
|
github.API += "/"
|
|
|
|
}
|
|
|
|
// the URL must NOT have a trailing slash
|
|
|
|
if strings.HasSuffix(github.URL, "/") {
|
|
|
|
github.URL = github.URL[:len(github.URL)-1]
|
|
|
|
}
|
|
|
|
return &github
|
|
|
|
}
|
|
|
|
|
|
|
|
func (g *GitHub) Login(token, secret string) (*common.User, error) {
|
|
|
|
client := NewClient(g.API, token, g.SkipVerify)
|
2015-07-23 17:36:23 +00:00
|
|
|
login, err := GetUserEmail(client, g.URL)
|
2015-04-08 22:00:27 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
user := common.User{}
|
|
|
|
user.Login = *login.Login
|
|
|
|
user.Email = *login.Email
|
|
|
|
user.Token = token
|
|
|
|
user.Secret = secret
|
|
|
|
return &user, nil
|
|
|
|
}
|
|
|
|
|
2015-04-15 07:20:00 +00:00
|
|
|
// Orgs fetches the organizations for the given user.
|
|
|
|
func (g *GitHub) Orgs(u *common.User) ([]string, error) {
|
|
|
|
client := NewClient(g.API, u.Token, g.SkipVerify)
|
|
|
|
orgs_ := []string{}
|
|
|
|
orgs, err := GetOrgs(client)
|
|
|
|
if err != nil {
|
|
|
|
return orgs_, err
|
|
|
|
}
|
|
|
|
for _, org := range orgs {
|
|
|
|
orgs_ = append(orgs_, *org.Login)
|
|
|
|
}
|
|
|
|
return orgs_, nil
|
|
|
|
}
|
|
|
|
|
2015-07-23 17:36:23 +00:00
|
|
|
// Accessor method, to allowed remote organizations field.
|
|
|
|
func (g *GitHub) GetOrgs() []string {
|
|
|
|
return g.AllowedOrgs
|
|
|
|
}
|
|
|
|
|
|
|
|
// Accessor method, to open field.
|
|
|
|
func (g *GitHub) GetOpen() bool {
|
|
|
|
return g.Open
|
|
|
|
}
|
|
|
|
|
2015-04-08 22:00:27 +00:00
|
|
|
// Repo fetches the named repository from the remote system.
|
|
|
|
func (g *GitHub) Repo(u *common.User, owner, name string) (*common.Repo, error) {
|
|
|
|
client := NewClient(g.API, u.Token, g.SkipVerify)
|
|
|
|
repo_, err := GetRepo(client, owner, name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
repo := &common.Repo{}
|
|
|
|
repo.Owner = owner
|
|
|
|
repo.Name = name
|
|
|
|
repo.FullName = *repo_.FullName
|
|
|
|
repo.Link = *repo_.HTMLURL
|
|
|
|
repo.Private = *repo_.Private
|
|
|
|
repo.Clone = *repo_.CloneURL
|
2015-06-19 01:50:57 +00:00
|
|
|
repo.Branch = "master"
|
2015-04-08 22:00:27 +00:00
|
|
|
|
2015-05-11 07:45:31 +00:00
|
|
|
if repo_.DefaultBranch != nil {
|
|
|
|
repo.Branch = *repo_.DefaultBranch
|
|
|
|
}
|
|
|
|
|
2015-04-08 22:00:27 +00:00
|
|
|
if g.PrivateMode {
|
|
|
|
repo.Private = true
|
|
|
|
}
|
|
|
|
return repo, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Perm fetches the named repository from the remote system.
|
|
|
|
func (g *GitHub) Perm(u *common.User, owner, name string) (*common.Perm, error) {
|
|
|
|
key := fmt.Sprintf("%s/%s/%s", u.Login, owner, name)
|
|
|
|
val, ok := g.cache.Get(key)
|
|
|
|
if ok {
|
|
|
|
return val.(*common.Perm), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
client := NewClient(g.API, u.Token, g.SkipVerify)
|
|
|
|
repo, err := GetRepo(client, owner, name)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
m := &common.Perm{}
|
|
|
|
m.Admin = (*repo.Permissions)["admin"]
|
|
|
|
m.Push = (*repo.Permissions)["push"]
|
|
|
|
m.Pull = (*repo.Permissions)["pull"]
|
|
|
|
g.cache.Add(key, m)
|
|
|
|
return m, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Script fetches the build script (.drone.yml) from the remote
|
|
|
|
// repository and returns in string format.
|
2015-06-23 03:45:08 +00:00
|
|
|
func (g *GitHub) Script(u *common.User, r *common.Repo, b *common.Build) ([]byte, error) {
|
2015-04-08 22:00:27 +00:00
|
|
|
client := NewClient(g.API, u.Token, g.SkipVerify)
|
2015-06-23 03:45:08 +00:00
|
|
|
return GetFile(client, r.Owner, r.Name, ".drone.yml", b.Commit.Sha)
|
2015-04-08 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
2015-04-28 21:39:48 +00:00
|
|
|
// Netrc returns a .netrc file that can be used to clone
|
|
|
|
// private repositories from a remote system.
|
2015-04-28 22:08:21 +00:00
|
|
|
func (g *GitHub) Netrc(u *common.User) (*common.Netrc, error) {
|
2015-04-28 21:39:48 +00:00
|
|
|
url_, err := url.Parse(g.URL)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
netrc := &common.Netrc{}
|
|
|
|
netrc.Login = u.Token
|
|
|
|
netrc.Password = "x-oauth-basic"
|
|
|
|
netrc.Machine = url_.Host
|
|
|
|
return netrc, nil
|
|
|
|
}
|
|
|
|
|
2015-04-08 22:00:27 +00:00
|
|
|
// Activate activates a repository by creating the post-commit hook and
|
|
|
|
// adding the SSH deploy key, if applicable.
|
|
|
|
func (g *GitHub) Activate(u *common.User, r *common.Repo, k *common.Keypair, link string) error {
|
|
|
|
client := NewClient(g.API, u.Token, g.SkipVerify)
|
|
|
|
title, err := GetKeyTitle(link)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the CloneURL is using the SSHURL then we know that
|
|
|
|
// we need to add an SSH key to GitHub.
|
|
|
|
if r.Private || g.PrivateMode {
|
|
|
|
_, err = CreateUpdateKey(client, r.Owner, r.Name, title, k.Public)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = CreateUpdateHook(client, r.Owner, r.Name, link)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Deactivate removes a repository by removing all the post-commit hooks
|
|
|
|
// which are equal to link and removing the SSH deploy key.
|
|
|
|
func (g *GitHub) Deactivate(u *common.User, r *common.Repo, link string) error {
|
|
|
|
client := NewClient(g.API, u.Token, g.SkipVerify)
|
|
|
|
title, err := GetKeyTitle(link)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove the deploy-key if it is installed remote.
|
|
|
|
if r.Private || g.PrivateMode {
|
|
|
|
if err := DeleteKey(client, r.Owner, r.Name, title); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return DeleteHook(client, r.Owner, r.Name, link)
|
|
|
|
}
|
|
|
|
|
2015-06-23 03:45:08 +00:00
|
|
|
func (g *GitHub) Status(u *common.User, r *common.Repo, b *common.Build) error {
|
2015-04-08 22:00:27 +00:00
|
|
|
client := NewClient(g.API, u.Token, g.SkipVerify)
|
2015-06-08 15:26:58 +00:00
|
|
|
|
2015-06-23 03:45:08 +00:00
|
|
|
link := fmt.Sprintf("%s/%v", r.Self, b.Number)
|
|
|
|
status := getStatus(b.Status)
|
|
|
|
desc := getDesc(b.Status)
|
2015-04-08 22:00:27 +00:00
|
|
|
data := github.RepoStatus{
|
|
|
|
Context: github.String("Drone"),
|
|
|
|
State: github.String(status),
|
|
|
|
Description: github.String(desc),
|
|
|
|
TargetURL: github.String(link),
|
|
|
|
}
|
2015-06-23 03:45:08 +00:00
|
|
|
_, _, err := client.Repositories.CreateStatus(r.Owner, r.Name, b.Commit.Sha, &data)
|
2015-04-08 22:00:27 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hook parses the post-commit hook from the Request body
|
|
|
|
// and returns the required data in a standard format.
|
|
|
|
func (g *GitHub) Hook(r *http.Request) (*common.Hook, error) {
|
|
|
|
switch r.Header.Get("X-Github-Event") {
|
|
|
|
case "pull_request":
|
|
|
|
return g.pullRequest(r)
|
|
|
|
case "push":
|
|
|
|
return g.push(r)
|
|
|
|
default:
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-11 22:08:04 +00:00
|
|
|
// return default scope for GitHub
|
|
|
|
func (g *GitHub) Scope() string {
|
|
|
|
return DefaultScope
|
|
|
|
}
|
|
|
|
|
2015-04-08 22:00:27 +00:00
|
|
|
// push parses a hook with event type `push` and returns
|
|
|
|
// the commit data.
|
|
|
|
func (g *GitHub) push(r *http.Request) (*common.Hook, error) {
|
|
|
|
payload := GetPayload(r)
|
|
|
|
hook := &pushHook{}
|
|
|
|
err := json.Unmarshal(payload, hook)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2015-06-11 17:17:14 +00:00
|
|
|
if hook.Deleted {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2015-04-08 22:00:27 +00:00
|
|
|
repo := &common.Repo{}
|
|
|
|
repo.Owner = hook.Repo.Owner.Login
|
2015-05-11 07:45:31 +00:00
|
|
|
if len(repo.Owner) == 0 {
|
|
|
|
repo.Owner = hook.Repo.Owner.Name
|
|
|
|
}
|
2015-04-08 22:00:27 +00:00
|
|
|
repo.Name = hook.Repo.Name
|
|
|
|
repo.FullName = hook.Repo.FullName
|
|
|
|
repo.Link = hook.Repo.HTMLURL
|
|
|
|
repo.Private = hook.Repo.Private
|
|
|
|
repo.Clone = hook.Repo.CloneURL
|
2015-05-11 07:45:31 +00:00
|
|
|
repo.Branch = hook.Repo.DefaultBranch
|
2015-04-08 22:00:27 +00:00
|
|
|
|
|
|
|
commit := &common.Commit{}
|
|
|
|
commit.Sha = hook.Head.ID
|
|
|
|
commit.Ref = hook.Ref
|
2015-05-11 07:45:31 +00:00
|
|
|
commit.Branch = strings.Replace(commit.Ref, "refs/heads/", "", -1)
|
2015-04-08 22:00:27 +00:00
|
|
|
commit.Message = hook.Head.Message
|
|
|
|
commit.Timestamp = hook.Head.Timestamp
|
2015-06-23 03:45:08 +00:00
|
|
|
commit.Author = &common.Author{}
|
|
|
|
commit.Author.Email = hook.Head.Author.Email
|
|
|
|
commit.Author.Login = hook.Head.Author.Username
|
|
|
|
commit.Remote = hook.Repo.CloneURL
|
2015-04-08 22:00:27 +00:00
|
|
|
|
|
|
|
// we should ignore github pages
|
|
|
|
if commit.Ref == "refs/heads/gh-pages" {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return &common.Hook{Repo: repo, Commit: commit}, nil
|
|
|
|
}
|
|
|
|
|
2015-07-23 17:36:23 +00:00
|
|
|
// ¯\_(ツ)_/¯
|
|
|
|
func (g *GitHub) Oauth2Transport(r *http.Request) *oauth2.Transport {
|
|
|
|
return &oauth2.Transport{
|
|
|
|
Config: &oauth2.Config{
|
|
|
|
ClientId: g.Client,
|
|
|
|
ClientSecret: g.Secret,
|
|
|
|
Scope: DefaultScope,
|
|
|
|
AuthURL: fmt.Sprintf("%s/login/oauth/authorize", g.URL),
|
|
|
|
TokenURL: fmt.Sprintf("%s/login/oauth/access_token", g.URL),
|
|
|
|
RedirectURL: fmt.Sprintf("%s/authorize", httputil.GetURL(r)),
|
|
|
|
//settings.Server.Scheme, settings.Server.Hostname),
|
|
|
|
},
|
|
|
|
Transport: &http.Transport{
|
|
|
|
Proxy: http.ProxyFromEnvironment,
|
|
|
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: g.SkipVerify},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-08 22:00:27 +00:00
|
|
|
// pullRequest parses a hook with event type `pullRequest`
|
|
|
|
// and returns the commit data.
|
|
|
|
func (g *GitHub) pullRequest(r *http.Request) (*common.Hook, error) {
|
|
|
|
payload := GetPayload(r)
|
|
|
|
hook := &struct {
|
|
|
|
Action string `json:"action"`
|
|
|
|
PullRequest *github.PullRequest `json:"pull_request"`
|
|
|
|
Repo *github.Repository `json:"repository"`
|
|
|
|
}{}
|
|
|
|
err := json.Unmarshal(payload, hook)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// ignore these
|
|
|
|
if hook.Action != "opened" && hook.Action != "synchronize" {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2015-06-08 15:42:45 +00:00
|
|
|
if *hook.PullRequest.State != "open" {
|
|
|
|
return nil, nil
|
|
|
|
}
|
2015-04-08 22:00:27 +00:00
|
|
|
|
|
|
|
repo := &common.Repo{}
|
|
|
|
repo.Owner = *hook.Repo.Owner.Login
|
|
|
|
repo.Name = *hook.Repo.Name
|
|
|
|
repo.FullName = *hook.Repo.FullName
|
|
|
|
repo.Link = *hook.Repo.HTMLURL
|
|
|
|
repo.Private = *hook.Repo.Private
|
|
|
|
repo.Clone = *hook.Repo.CloneURL
|
2015-06-19 01:50:57 +00:00
|
|
|
repo.Branch = "master"
|
2015-05-11 07:45:31 +00:00
|
|
|
if hook.Repo.DefaultBranch != nil {
|
|
|
|
repo.Branch = *hook.Repo.DefaultBranch
|
|
|
|
}
|
2015-04-08 22:00:27 +00:00
|
|
|
|
2015-05-11 07:45:31 +00:00
|
|
|
c := &common.Commit{}
|
2015-06-23 03:45:08 +00:00
|
|
|
c.Sha = *hook.PullRequest.Head.SHA
|
|
|
|
c.Ref = *hook.PullRequest.Head.Ref
|
|
|
|
c.Ref = fmt.Sprintf("refs/pull/%s/merge", *hook.PullRequest.Number)
|
|
|
|
c.Branch = *hook.PullRequest.Head.Ref
|
2015-05-11 07:45:31 +00:00
|
|
|
c.Timestamp = time.Now().UTC().Format("2006-01-02 15:04:05.000000000 +0000 MST")
|
2015-06-23 03:45:08 +00:00
|
|
|
c.Remote = *hook.PullRequest.Head.Repo.CloneURL
|
|
|
|
c.Author = &common.Author{}
|
|
|
|
c.Author.Login = *hook.PullRequest.Head.User.Login
|
|
|
|
// Author.Email
|
|
|
|
// Message
|
|
|
|
|
|
|
|
pr := &common.PullRequest{}
|
|
|
|
pr.Number = *hook.PullRequest.Number
|
|
|
|
pr.Title = *hook.PullRequest.Title
|
|
|
|
pr.Base = &common.Commit{}
|
|
|
|
pr.Base.Sha = *hook.PullRequest.Base.SHA
|
|
|
|
pr.Base.Ref = *hook.PullRequest.Base.Ref
|
|
|
|
pr.Base.Remote = *hook.PullRequest.Base.Repo.CloneURL
|
|
|
|
// Branch
|
|
|
|
// Message
|
|
|
|
// Timestamp
|
|
|
|
// Author.Login
|
|
|
|
// Author.Email
|
|
|
|
|
|
|
|
return &common.Hook{Repo: repo, Commit: c, PullRequest: pr}, nil
|
2015-04-08 22:00:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type pushHook struct {
|
2015-06-11 17:17:14 +00:00
|
|
|
Ref string `json:"ref"`
|
|
|
|
Deleted bool `json:"deleted"`
|
2015-04-08 22:00:27 +00:00
|
|
|
|
|
|
|
Head struct {
|
|
|
|
ID string `json:"id"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Timestamp string `json:"timestamp"`
|
|
|
|
|
|
|
|
Author struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Email string `json:"name"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
} `json:"author"`
|
|
|
|
|
|
|
|
Committer struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Email string `json:"name"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
} `json:"committer"`
|
|
|
|
} `json:"head_commit"`
|
|
|
|
|
|
|
|
Repo struct {
|
|
|
|
Owner struct {
|
|
|
|
Login string `json:"login"`
|
2015-05-11 07:45:31 +00:00
|
|
|
Name string `json:"name"`
|
2015-04-08 22:00:27 +00:00
|
|
|
} `json:"owner"`
|
2015-05-11 07:45:31 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
FullName string `json:"full_name"`
|
|
|
|
Language string `json:"language"`
|
|
|
|
Private bool `json:"private"`
|
|
|
|
HTMLURL string `json:"html_url"`
|
|
|
|
CloneURL string `json:"clone_url"`
|
|
|
|
DefaultBranch string `json:"default_branch"`
|
2015-04-08 22:00:27 +00:00
|
|
|
} `json:"repository"`
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
|
|
StatusPending = "pending"
|
|
|
|
StatusSuccess = "success"
|
|
|
|
StatusFailure = "failure"
|
|
|
|
StatusError = "error"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
DescPending = "this build is pending"
|
|
|
|
DescSuccess = "the build was successful"
|
|
|
|
DescFailure = "the build failed"
|
|
|
|
DescError = "oops, something went wrong"
|
|
|
|
)
|
|
|
|
|
|
|
|
// getStatus is a helper functin that converts a Drone
|
|
|
|
// status to a GitHub status.
|
|
|
|
func getStatus(status string) string {
|
|
|
|
switch status {
|
|
|
|
case common.StatePending, common.StateRunning:
|
|
|
|
return StatusPending
|
|
|
|
case common.StateSuccess:
|
|
|
|
return StatusSuccess
|
|
|
|
case common.StateFailure:
|
|
|
|
return StatusFailure
|
|
|
|
case common.StateError, common.StateKilled:
|
|
|
|
return StatusError
|
|
|
|
default:
|
|
|
|
return StatusError
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// getDesc is a helper function that generates a description
|
|
|
|
// message for the build based on the status.
|
|
|
|
func getDesc(status string) string {
|
|
|
|
switch status {
|
|
|
|
case common.StatePending, common.StateRunning:
|
|
|
|
return DescPending
|
|
|
|
case common.StateSuccess:
|
|
|
|
return DescSuccess
|
|
|
|
case common.StateFailure:
|
|
|
|
return DescFailure
|
|
|
|
case common.StateError, common.StateKilled:
|
|
|
|
return DescError
|
|
|
|
default:
|
|
|
|
return DescError
|
|
|
|
}
|
|
|
|
}
|