mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
Merge pull request #121 from 6543-forks/vendor_gitea-sdk
update code.gitea.io/sdk/gitea to v0.12.0
This commit is contained in:
commit
c8d899f40d
3 changed files with 20 additions and 20 deletions
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module github.com/laszlocph/woodpecker
|
|||
go 1.12
|
||||
|
||||
require (
|
||||
code.gitea.io/sdk v0.0.0-20170506013721-8cff72208aa4
|
||||
code.gitea.io/sdk/gitea v0.12.0
|
||||
docker.io/go-docker v1.0.0
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
|
||||
github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 // indirect
|
||||
|
|
6
go.sum
6
go.sum
|
@ -1,7 +1,7 @@
|
|||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
code.gitea.io/sdk v0.0.0-20170506013721-8cff72208aa4 h1:d2Bvt1ZWu+9LY3djKb/JYEX8Cg1LjsS6FOmCVmed/9s=
|
||||
code.gitea.io/sdk v0.0.0-20170506013721-8cff72208aa4/go.mod h1:5bZt0dRznpn2JysytQnV0yCru3FwDv9O5G91jo+lDAk=
|
||||
code.gitea.io/sdk/gitea v0.12.0 h1:hvDCz4wtFvo7rf5Ebj8tGd4aJ4wLPKX3BKFX9Dk1Pgs=
|
||||
code.gitea.io/sdk/gitea v0.12.0/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
|
||||
docker.io/go-docker v1.0.0 h1:VdXS/aNYQxyA9wdLD5z8Q8Ro688/hG8HzKxYVEVbE6s=
|
||||
docker.io/go-docker v1.0.0/go.mod h1:7tiAn5a0LFmjbPDbyTPOaTTOuG1ZRNXdPA6RvKY+fpY=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=
|
||||
|
@ -127,6 +127,8 @@ github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+
|
|||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/jackspirou/syscerts v0.0.0-20160531025014-b68f5469dff1 h1:9Xm8CKtMZIXgcopfdWk/qZ1rt0HjMgfMR9nxxSeK6vk=
|
||||
github.com/jackspirou/syscerts v0.0.0-20160531025014-b68f5469dff1/go.mod h1:zuHl3Hh+e9P6gmBPvcqR1HjkaWHC/csgyskg6IaFKFo=
|
||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||
|
|
|
@ -138,30 +138,28 @@ func (c *client) Login(res http.ResponseWriter, req *http.Request) (*model.User,
|
|||
|
||||
client := c.newClient()
|
||||
|
||||
// try to fetch drone token if it exists
|
||||
// since api does not return token secret, if drone token exists create new one
|
||||
var accessToken string
|
||||
tokens, err := client.ListAccessTokens(username, password)
|
||||
client.SetBasicAuth(username, password)
|
||||
tokens, err := client.ListAccessTokens(gitea.ListAccessTokensOptions{})
|
||||
if err == nil {
|
||||
for _, token := range tokens {
|
||||
if token.Name == "drone" {
|
||||
accessToken = token.Sha1
|
||||
if err := client.DeleteAccessToken(token.ID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if drone token not found, create it
|
||||
if accessToken == "" {
|
||||
token, terr := client.CreateAccessToken(
|
||||
username,
|
||||
password,
|
||||
gitea.CreateAccessTokenOption{Name: "drone"},
|
||||
)
|
||||
if terr != nil {
|
||||
return nil, terr
|
||||
}
|
||||
accessToken = token.Sha1
|
||||
token, terr := client.CreateAccessToken(
|
||||
gitea.CreateAccessTokenOption{Name: "drone"},
|
||||
)
|
||||
if terr != nil {
|
||||
return nil, terr
|
||||
}
|
||||
accessToken = token.Token
|
||||
|
||||
client = c.newClientToken(accessToken)
|
||||
account, err := client.GetUserInfo(username)
|
||||
|
@ -185,7 +183,7 @@ func (c *client) Auth(token, secret string) (string, error) {
|
|||
// Teams is supported by the Gitea driver.
|
||||
func (c *client) Teams(u *model.User) ([]*model.Team, error) {
|
||||
client := c.newClientToken(u.Token)
|
||||
orgs, err := client.ListMyOrgs()
|
||||
orgs, err := client.ListMyOrgs(gitea.ListOrgsOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -221,7 +219,7 @@ func (c *client) Repos(u *model.User) ([]*model.Repo, error) {
|
|||
repos := []*model.Repo{}
|
||||
|
||||
client := c.newClientToken(u.Token)
|
||||
all, err := client.ListMyRepos()
|
||||
all, err := client.ListMyRepos(gitea.ListReposOptions{})
|
||||
if err != nil {
|
||||
return repos, err
|
||||
}
|
||||
|
@ -318,7 +316,7 @@ func (c *client) Activate(u *model.User, r *model.Repo, link string) error {
|
|||
func (c *client) Deactivate(u *model.User, r *model.Repo, link string) error {
|
||||
client := c.newClientToken(u.Token)
|
||||
|
||||
hooks, err := client.ListRepoHooks(r.Owner, r.Name)
|
||||
hooks, err := client.ListRepoHooks(r.Owner, r.Name, gitea.ListHooksOptions{})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue