mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 03:41:01 +00:00
Replace drone strings with woodpecker (#391)
Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
ba0286d055
commit
bb37836600
34 changed files with 126 additions and 126 deletions
|
@ -31,7 +31,7 @@ import (
|
|||
var Command = cli.Command{
|
||||
Name: "exec",
|
||||
Usage: "execute a local build",
|
||||
ArgsUsage: "[path/to/.drone.yml]",
|
||||
ArgsUsage: "[path/to/.woodpecker.yml]",
|
||||
Action: func(c *cli.Context) {
|
||||
if err := exec(c); err != nil {
|
||||
log.Fatalln(err)
|
||||
|
@ -62,8 +62,8 @@ var Command = cli.Command{
|
|||
cli.StringFlag{
|
||||
EnvVar: "WOODPECKER_DOCKER_PREFIX",
|
||||
Name: "prefix",
|
||||
Value: "drone",
|
||||
Usage: "prefix containers created by drone",
|
||||
Value: "woodpecker",
|
||||
Usage: "prefix containers created by woodpecker",
|
||||
Hidden: true,
|
||||
},
|
||||
cli.StringSliceFlag{
|
||||
|
@ -88,7 +88,7 @@ var Command = cli.Command{
|
|||
cli.StringFlag{
|
||||
EnvVar: "WOODPECKER_WORKSPACE_BASE",
|
||||
Name: "workspace-base",
|
||||
Value: "/drone",
|
||||
Value: "/woodpecker",
|
||||
},
|
||||
cli.StringFlag{
|
||||
EnvVar: "WOODPECKER_WORKSPACE_PATH",
|
||||
|
|
|
@ -320,7 +320,7 @@ var flags = []cli.Flag{
|
|||
EnvVar: "WOODPECKER_GITEA_CONTEXT",
|
||||
Name: "gitea-context",
|
||||
Usage: "gitea status context",
|
||||
Value: "continuous-integration/drone",
|
||||
Value: "continuous-integration/woodpecker",
|
||||
},
|
||||
cli.StringFlag{
|
||||
EnvVar: "WOODPECKER_GITEA_GIT_USERNAME",
|
||||
|
|
|
@ -91,7 +91,7 @@ func TestWithResourceLimit(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWithPrefix(t *testing.T) {
|
||||
if New(WithPrefix("drone_")).prefix != "drone_" {
|
||||
if New(WithPrefix("someprefix_")).prefix != "someprefix_" {
|
||||
t.Errorf("WithPrefix must set the prefix")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -410,13 +410,13 @@ func TestConstraints(t *testing.T) {
|
|||
// },
|
||||
// repo constraint
|
||||
{
|
||||
conf: "{ repo: drone/* }",
|
||||
with: frontend.Metadata{Repo: frontend.Repo{Name: "drone/drone"}},
|
||||
conf: "{ repo: owner/* }",
|
||||
with: frontend.Metadata{Repo: frontend.Repo{Name: "owner/repo"}},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
conf: "{ repo: octocat/* }",
|
||||
with: frontend.Metadata{Repo: frontend.Repo{Name: "drone/drone"}},
|
||||
with: frontend.Metadata{Repo: frontend.Repo{Name: "owner/repo"}},
|
||||
want: false,
|
||||
},
|
||||
// ref constraint
|
||||
|
@ -443,13 +443,13 @@ func TestConstraints(t *testing.T) {
|
|||
},
|
||||
// instance constraint
|
||||
{
|
||||
conf: "{ instance: drone.io }",
|
||||
with: frontend.Metadata{Sys: frontend.System{Host: "drone.io"}},
|
||||
conf: "{ instance: agent.tld }",
|
||||
with: frontend.Metadata{Sys: frontend.System{Host: "agent.tld"}},
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
conf: "{ instance: drone.io }",
|
||||
with: frontend.Metadata{Sys: frontend.System{Host: "beta.drone.io"}},
|
||||
conf: "{ instance: agent.tld }",
|
||||
with: frontend.Metadata{Sys: frontend.System{Host: "beta.agent.tld"}},
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ func FileGet(c *gin.Context) {
|
|||
defer rc.Close()
|
||||
|
||||
switch file.Mime {
|
||||
case "application/vnd.drone.test+json":
|
||||
case "application/vnd.test+json":
|
||||
c.Header("Content-Type", "application/json")
|
||||
}
|
||||
|
||||
|
|
|
@ -486,12 +486,12 @@ type WoodpeckerServer struct {
|
|||
|
||||
func NewWoodpeckerServer(remote remote.Remote, queue queue.Queue, logger logging.Log, pubsub pubsub.Publisher, store store.Store, host string) *WoodpeckerServer {
|
||||
buildTime := promauto.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: "drone",
|
||||
Namespace: "woodpecker",
|
||||
Name: "build_time",
|
||||
Help: "Build time.",
|
||||
}, []string{"repo", "branch", "status", "pipeline"})
|
||||
buildCount := promauto.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: "drone",
|
||||
Namespace: "woodpecker",
|
||||
Name: "build_count",
|
||||
Help: "Build count.",
|
||||
}, []string{"repo", "branch", "status", "pipeline"})
|
||||
|
|
|
@ -69,7 +69,7 @@ func (c *config) Login(ctx context.Context, w http.ResponseWriter, req *http.Req
|
|||
// get the OAuth code
|
||||
code := req.FormValue("code")
|
||||
if len(code) == 0 {
|
||||
http.Redirect(w, req, config.AuthCodeURL("drone"), http.StatusSeeOther)
|
||||
http.Redirect(w, req, config.AuthCodeURL("woodpecker"), http.StatusSeeOther)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ func (c *config) Status(ctx context.Context, u *model.User, r *model.Repo, b *mo
|
|||
status := internal.BuildStatus{
|
||||
State: convertStatus(b.Status),
|
||||
Desc: convertDesc(b.Status),
|
||||
Key: "Drone",
|
||||
Key: "Woodpecker",
|
||||
Url: link,
|
||||
}
|
||||
return c.newClient(ctx, u).CreateStatus(r.Owner, r.Name, b.Commit, &status)
|
||||
|
|
|
@ -41,7 +41,7 @@ const (
|
|||
descError = "oops, something went wrong"
|
||||
)
|
||||
|
||||
// convertStatus is a helper function used to convert a Drone status to a
|
||||
// convertStatus is a helper function used to convert a Woodpecker status to a
|
||||
// Bitbucket commit status.
|
||||
func convertStatus(status string) string {
|
||||
switch status {
|
||||
|
@ -54,7 +54,7 @@ func convertStatus(status string) string {
|
|||
}
|
||||
}
|
||||
|
||||
// convertDesc is a helper function used to convert a Drone status to a
|
||||
// convertDesc is a helper function used to convert a Woodpecker status to a
|
||||
// Bitbucket status description.
|
||||
func convertDesc(status string) string {
|
||||
switch status {
|
||||
|
@ -74,7 +74,7 @@ func convertDesc(status string) string {
|
|||
}
|
||||
|
||||
// convertRepo is a helper function used to convert a Bitbucket repository
|
||||
// structure to the common Drone repository structure.
|
||||
// structure to the common Woodpecker repository structure.
|
||||
func convertRepo(from *internal.Repo) *model.Repo {
|
||||
repo := model.Repo{
|
||||
Clone: cloneLink(from),
|
||||
|
@ -125,7 +125,7 @@ func cloneLink(repo *internal.Repo) string {
|
|||
}
|
||||
|
||||
// convertUser is a helper function used to convert a Bitbucket user account
|
||||
// structure to the Drone User structure.
|
||||
// structure to the Woodpecker User structure.
|
||||
func convertUser(from *internal.Account, token *oauth2.Token) *model.User {
|
||||
return &model.User{
|
||||
Login: from.Login,
|
||||
|
@ -137,7 +137,7 @@ func convertUser(from *internal.Account, token *oauth2.Token) *model.User {
|
|||
}
|
||||
|
||||
// convertTeamList is a helper function used to convert a Bitbucket team list
|
||||
// structure to the Drone Team structure.
|
||||
// structure to the Woodpecker Team structure.
|
||||
func convertTeamList(from []*internal.Account) []*model.Team {
|
||||
var teams []*model.Team
|
||||
for _, team := range from {
|
||||
|
@ -147,7 +147,7 @@ func convertTeamList(from []*internal.Account) []*model.Team {
|
|||
}
|
||||
|
||||
// convertTeam is a helper function used to convert a Bitbucket team account
|
||||
// structure to the Drone Team structure.
|
||||
// structure to the Woodpecker Team structure.
|
||||
func convertTeam(from *internal.Account) *model.Team {
|
||||
return &model.Team{
|
||||
Login: from.Login,
|
||||
|
@ -156,7 +156,7 @@ func convertTeam(from *internal.Account) *model.Team {
|
|||
}
|
||||
|
||||
// convertPullHook is a helper function used to convert a Bitbucket pull request
|
||||
// hook to the Drone build struct holding commit information.
|
||||
// hook to the Woodpecker build struct holding commit information.
|
||||
func convertPullHook(from *internal.PullRequestHook) *model.Build {
|
||||
return &model.Build{
|
||||
Event: model.EventPull,
|
||||
|
@ -178,7 +178,7 @@ func convertPullHook(from *internal.PullRequestHook) *model.Build {
|
|||
}
|
||||
|
||||
// convertPushHook is a helper function used to convert a Bitbucket push
|
||||
// hook to the Drone build struct holding commit information.
|
||||
// hook to the Woodpecker build struct holding commit information.
|
||||
func convertPushHook(hook *internal.PushHook, change *internal.Change) *model.Build {
|
||||
build := &model.Build{
|
||||
Commit: change.New.Target.Hash,
|
||||
|
|
|
@ -189,8 +189,8 @@ func (c *Config) Status(ctx context.Context, u *model.User, r *model.Repo, b *mo
|
|||
status := internal.BuildStatus{
|
||||
State: convertStatus(b.Status),
|
||||
Desc: convertDesc(b.Status),
|
||||
Name: fmt.Sprintf("Drone #%d - %s", b.Number, b.Branch),
|
||||
Key: "Drone",
|
||||
Name: fmt.Sprintf("Woodpecker #%d - %s", b.Number, b.Branch),
|
||||
Key: "Woodpecker",
|
||||
Url: link,
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ const (
|
|||
descError = "oops, something went wrong"
|
||||
)
|
||||
|
||||
// convertStatus is a helper function used to convert a Drone status to a
|
||||
// convertStatus is a helper function used to convert a Woodpecker status to a
|
||||
// Bitbucket commit status.
|
||||
func convertStatus(status string) string {
|
||||
switch status {
|
||||
|
@ -53,7 +53,7 @@ func convertStatus(status string) string {
|
|||
}
|
||||
}
|
||||
|
||||
// convertDesc is a helper function used to convert a Drone status to a
|
||||
// convertDesc is a helper function used to convert a Woodpecker status to a
|
||||
// Bitbucket status description.
|
||||
func convertDesc(status string) string {
|
||||
switch status {
|
||||
|
@ -69,7 +69,7 @@ func convertDesc(status string) string {
|
|||
}
|
||||
|
||||
// convertRepo is a helper function used to convert a Bitbucket server repository
|
||||
// structure to the common Drone repository structure.
|
||||
// structure to the common Woodpecker repository structure.
|
||||
func convertRepo(from *internal.Repo) *model.Repo {
|
||||
|
||||
repo := model.Repo{
|
||||
|
@ -101,7 +101,7 @@ func convertRepo(from *internal.Repo) *model.Repo {
|
|||
}
|
||||
|
||||
// convertPushHook is a helper function used to convert a Bitbucket push
|
||||
// hook to the Drone build struct holding commit information.
|
||||
// hook to the Woodpecker build struct holding commit information.
|
||||
func convertPushHook(hook *internal.PostHook, baseURL string) *model.Build {
|
||||
branch := strings.TrimPrefix(
|
||||
strings.TrimPrefix(
|
||||
|
@ -138,7 +138,7 @@ func convertPushHook(hook *internal.PostHook, baseURL string) *model.Build {
|
|||
}
|
||||
|
||||
// convertUser is a helper function used to convert a Bitbucket user account
|
||||
// structure to the Drone User structure.
|
||||
// structure to the Woodpecker User structure.
|
||||
func convertUser(from *internal.User, token *oauth.AccessToken) *model.User {
|
||||
return &model.User{
|
||||
Login: from.Slug,
|
||||
|
|
|
@ -93,7 +93,7 @@ func (c *Coding) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
|||
// get the OAuth code
|
||||
code := req.FormValue("code")
|
||||
if len(code) == 0 {
|
||||
http.Redirect(res, req, config.AuthCodeURL("drone"), http.StatusSeeOther)
|
||||
http.Redirect(res, req, config.AuthCodeURL("woodpecker"), http.StatusSeeOther)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ func (c *Coding) newClientToken(ctx context.Context, token string) *internal.Cli
|
|||
},
|
||||
},
|
||||
}
|
||||
return internal.NewClient(ctx, c.URL, "/api", token, "drone", client)
|
||||
return internal.NewClient(ctx, c.URL, "/api", token, "woodpecker", client)
|
||||
}
|
||||
|
||||
func (c *Coding) resourceLink(resourcePath string) string {
|
||||
|
|
|
@ -164,7 +164,7 @@ func Test_coding(t *testing.T) {
|
|||
|
||||
g.Describe("When downloading a file", func() {
|
||||
g.It("Should return file for specified build", func() {
|
||||
data, err := c.File(ctx, fakeUser, fakeRepo, fakeBuild, ".drone.yml")
|
||||
data, err := c.File(ctx, fakeUser, fakeRepo, fakeBuild, ".woodpecker.yml")
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(string(data)).Equal("pipeline:\n test:\n image: golang:1.6\n commands:\n - go test\n")
|
||||
})
|
||||
|
|
|
@ -108,7 +108,7 @@ func getProjects(c *gin.Context) {
|
|||
func getFile(c *gin.Context) {
|
||||
c.Header("Content-Type", "application/json;charset=UTF-8")
|
||||
switch fmt.Sprintf("%s/%s/%s/%s", c.Param("gk"), c.Param("prj"), c.Param("ref"), c.Param("path")) {
|
||||
case "demo1/test1/master/.drone.yml", "demo1/test1/4504a072cc/.drone.yml":
|
||||
case "demo1/test1/master/.woodpecker.yml", "demo1/test1/4504a072cc/.woodpecker.yml":
|
||||
c.String(200, fakeFilePayload)
|
||||
default:
|
||||
c.String(200, fileNotFoundPayload)
|
||||
|
|
|
@ -25,7 +25,7 @@ const PushHook = `
|
|||
"email": "demo1@gmail.com"
|
||||
},
|
||||
"web_url": "https://coding.net/u/demo1/p/test1/git/commit/5b9912a6ff272e9c93a4c44c278fe9b359ed1ab4",
|
||||
"short_message": "new file .drone.yml\n",
|
||||
"short_message": "new file .woodpecker.yml\n",
|
||||
"sha": "5b9912a6ff272e9c93a4c44c278fe9b359ed1ab4"
|
||||
}
|
||||
],
|
||||
|
|
|
@ -55,7 +55,7 @@ func Test_hook(t *testing.T) {
|
|||
Ref: "refs/heads/master",
|
||||
Link: "https://coding.net/u/demo1/p/test1/git/commit/5b9912a6ff272e9c93a4c44c278fe9b359ed1ab4",
|
||||
Branch: "master",
|
||||
Message: "new file .drone.yml\n",
|
||||
Message: "new file .woodpecker.yml\n",
|
||||
Email: "demo1@gmail.com",
|
||||
Avatar: "/static/fruit_avatar/Fruit-20.png",
|
||||
Author: "demo1",
|
||||
|
@ -122,7 +122,7 @@ func Test_hook(t *testing.T) {
|
|||
Ref: "refs/heads/master",
|
||||
Link: "https://coding.net/u/demo1/p/test1/git/commit/5b9912a6ff272e9c93a4c44c278fe9b359ed1ab4",
|
||||
Branch: "master",
|
||||
Message: "new file .drone.yml\n",
|
||||
Message: "new file .woodpecker.yml\n",
|
||||
Email: "demo1@gmail.com",
|
||||
Avatar: "/static/fruit_avatar/Fruit-20.png",
|
||||
Author: "demo1",
|
||||
|
|
|
@ -114,7 +114,7 @@ func (c *Gitea) Login(ctx context.Context, w http.ResponseWriter, req *http.Requ
|
|||
// get the OAuth code
|
||||
code := req.FormValue("code")
|
||||
if len(code) == 0 {
|
||||
http.Redirect(w, req, config.AuthCodeURL("drone"), http.StatusSeeOther)
|
||||
http.Redirect(w, req, config.AuthCodeURL("woodpecker"), http.StatusSeeOther)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
@ -451,7 +451,7 @@ const (
|
|||
DescDeclined = "the build was rejected"
|
||||
)
|
||||
|
||||
// getStatus is a helper function that converts a Drone
|
||||
// getStatus is a helper function that converts a Woodpecker
|
||||
// status to a Gitea status.
|
||||
func getStatus(status string) gitea.StatusState {
|
||||
switch status {
|
||||
|
|
|
@ -145,7 +145,7 @@ func Test_gitea(t *testing.T) {
|
|||
})
|
||||
|
||||
g.It("Should return a repository file", func() {
|
||||
raw, err := c.File(ctx, fakeUser, fakeRepo, fakeBuild, ".drone.yml")
|
||||
raw, err := c.File(ctx, fakeUser, fakeRepo, fakeBuild, ".woodpecker.yml")
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(string(raw)).Equal("{ platform: linux/amd64 }")
|
||||
})
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
||||
// helper function that converts a Gitea repository to a Drone repository.
|
||||
// helper function that converts a Gitea repository to a Woodpecker repository.
|
||||
func toRepo(from *gitea.Repository, privateMode bool) *model.Repo {
|
||||
name := strings.Split(from.FullName, "/")[1]
|
||||
avatar := expandAvatar(
|
||||
|
@ -50,7 +50,7 @@ func toRepo(from *gitea.Repository, privateMode bool) *model.Repo {
|
|||
}
|
||||
}
|
||||
|
||||
// helper function that converts a Gitea permission to a Drone permission.
|
||||
// helper function that converts a Gitea permission to a Woodpecker permission.
|
||||
func toPerm(from *gitea.Permission) *model.Perm {
|
||||
return &model.Perm{
|
||||
Pull: from.Pull,
|
||||
|
@ -59,7 +59,7 @@ func toPerm(from *gitea.Permission) *model.Perm {
|
|||
}
|
||||
}
|
||||
|
||||
// helper function that converts a Gitea team to a Drone team.
|
||||
// helper function that converts a Gitea team to a Woodpecker team.
|
||||
func toTeam(from *gitea.Organization, link string) *model.Team {
|
||||
return &model.Team{
|
||||
Login: from.UserName,
|
||||
|
|
|
@ -186,7 +186,7 @@ func Test_parse(t *testing.T) {
|
|||
|
||||
g.It("Should return a Team struct from a Gitea Org", func() {
|
||||
from := &gitea.Organization{
|
||||
UserName: "drone",
|
||||
UserName: "woodpecker",
|
||||
AvatarURL: "/avatars/1",
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ const (
|
|||
refspec = "%s:%s"
|
||||
)
|
||||
|
||||
// convertStatus is a helper function used to convert a Drone status to a
|
||||
// convertStatus is a helper function used to convert a Woodpecker status to a
|
||||
// GitHub commit status.
|
||||
func convertStatus(status string) string {
|
||||
switch status {
|
||||
|
@ -62,7 +62,7 @@ func convertStatus(status string) string {
|
|||
}
|
||||
}
|
||||
|
||||
// convertDesc is a helper function used to convert a Drone status to a
|
||||
// convertDesc is a helper function used to convert a Woodpecker status to a
|
||||
// GitHub status description.
|
||||
func convertDesc(status string) string {
|
||||
switch status {
|
||||
|
@ -82,7 +82,7 @@ func convertDesc(status string) string {
|
|||
}
|
||||
|
||||
// convertRepo is a helper function used to convert a GitHub repository
|
||||
// structure to the common Drone repository structure.
|
||||
// structure to the common Woodpecker repository structure.
|
||||
func convertRepo(from *github.Repository, private bool) *model.Repo {
|
||||
repo := &model.Repo{
|
||||
Owner: *from.Owner.Login,
|
||||
|
@ -106,7 +106,7 @@ func convertRepo(from *github.Repository, private bool) *model.Repo {
|
|||
}
|
||||
|
||||
// convertPerm is a helper function used to convert a GitHub repository
|
||||
// permissions to the common Drone permissions structure.
|
||||
// permissions to the common Woodpecker permissions structure.
|
||||
func convertPerm(from *github.Repository) *model.Perm {
|
||||
return &model.Perm{
|
||||
Admin: from.Permissions["admin"],
|
||||
|
@ -116,7 +116,7 @@ func convertPerm(from *github.Repository) *model.Perm {
|
|||
}
|
||||
|
||||
// convertTeamPerm is a helper function used to convert a GitHub organization
|
||||
// permissions to the common Drone permissions structure.
|
||||
// permissions to the common Woodpecker permissions structure.
|
||||
func convertTeamPerm(from *github.Membership) *model.Perm {
|
||||
admin := false
|
||||
if *from.Role == "admin" {
|
||||
|
@ -128,7 +128,7 @@ func convertTeamPerm(from *github.Membership) *model.Perm {
|
|||
}
|
||||
|
||||
// convertRepoList is a helper function used to convert a GitHub repository
|
||||
// list to the common Drone repository structure.
|
||||
// list to the common Woodpecker repository structure.
|
||||
func convertRepoList(from []*github.Repository, private bool) []*model.Repo {
|
||||
var repos []*model.Repo
|
||||
for _, repo := range from {
|
||||
|
@ -138,7 +138,7 @@ func convertRepoList(from []*github.Repository, private bool) []*model.Repo {
|
|||
}
|
||||
|
||||
// convertTeamList is a helper function used to convert a GitHub team list to
|
||||
// the common Drone repository structure.
|
||||
// the common Woodpecker repository structure.
|
||||
func convertTeamList(from []*github.Organization) []*model.Team {
|
||||
var teams []*model.Team
|
||||
for _, team := range from {
|
||||
|
@ -148,7 +148,7 @@ func convertTeamList(from []*github.Organization) []*model.Team {
|
|||
}
|
||||
|
||||
// convertTeam is a helper function used to convert a GitHub team structure
|
||||
// to the common Drone repository structure.
|
||||
// to the common Woodpecker repository structure.
|
||||
func convertTeam(from *github.Organization) *model.Team {
|
||||
return &model.Team{
|
||||
Login: *from.Login,
|
||||
|
@ -157,7 +157,7 @@ func convertTeam(from *github.Organization) *model.Team {
|
|||
}
|
||||
|
||||
// convertRepoHook is a helper function used to extract the Repository details
|
||||
// from a webhook and convert to the common Drone repository structure.
|
||||
// from a webhook and convert to the common Woodpecker repository structure.
|
||||
func convertRepoHook(from *webhook) *model.Repo {
|
||||
repo := &model.Repo{
|
||||
Owner: from.Repo.Owner.Login,
|
||||
|
@ -182,7 +182,7 @@ func convertRepoHook(from *webhook) *model.Repo {
|
|||
}
|
||||
|
||||
// convertPushHook is a helper function used to extract the Build details
|
||||
// from a push webhook and convert to the common Drone Build structure.
|
||||
// from a push webhook and convert to the common Woodpecker Build structure.
|
||||
func convertPushHook(from *webhook) *model.Build {
|
||||
files := getChangedFilesFromWebhook(from)
|
||||
build := &model.Build{
|
||||
|
@ -219,7 +219,7 @@ func convertPushHook(from *webhook) *model.Build {
|
|||
}
|
||||
|
||||
// convertPushHook is a helper function used to extract the Build details
|
||||
// from a deploy webhook and convert to the common Drone Build structure.
|
||||
// from a deploy webhook and convert to the common Woodpecker Build structure.
|
||||
func convertDeployHook(from *webhook) *model.Build {
|
||||
build := &model.Build{
|
||||
Event: model.EventDeploy,
|
||||
|
@ -249,7 +249,7 @@ func convertDeployHook(from *webhook) *model.Build {
|
|||
}
|
||||
|
||||
// convertPullHook is a helper function used to extract the Build details
|
||||
// from a pull request webhook and convert to the common Drone Build structure.
|
||||
// from a pull request webhook and convert to the common Woodpecker Build structure.
|
||||
func convertPullHook(from *webhook, merge bool) *model.Build {
|
||||
build := &model.Build{
|
||||
Event: model.EventPull,
|
||||
|
|
|
@ -119,7 +119,7 @@ func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
|||
// TODO(bradrydzewski) we really should be using a random value here and
|
||||
// storing in a cookie for verification in the next stage of the workflow.
|
||||
|
||||
http.Redirect(res, req, config.AuthCodeURL("drone"), http.StatusSeeOther)
|
||||
http.Redirect(res, req, config.AuthCodeURL("woodpecker"), http.StatusSeeOther)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -83,24 +83,24 @@ func (c *client) Login(ctx context.Context, res http.ResponseWriter, req *http.R
|
|||
|
||||
client := c.newClient()
|
||||
|
||||
// try to fetch drone token if it exists
|
||||
// try to fetch woodpecker token if it exists
|
||||
var accessToken string
|
||||
tokens, err := client.ListAccessTokens(username, password)
|
||||
if err == nil {
|
||||
for _, token := range tokens {
|
||||
if token.Name == "drone" {
|
||||
if token.Name == "woodpecker" {
|
||||
accessToken = token.Sha1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if drone token not found, create it
|
||||
// if woodpecker token not found, create it
|
||||
if accessToken == "" {
|
||||
token, terr := client.CreateAccessToken(
|
||||
username,
|
||||
password,
|
||||
gogs.CreateAccessTokenOption{Name: "drone"},
|
||||
gogs.CreateAccessTokenOption{Name: "woodpecker"},
|
||||
)
|
||||
if terr != nil {
|
||||
return nil, terr
|
||||
|
|
|
@ -139,13 +139,13 @@ func Test_gogs(t *testing.T) {
|
|||
})
|
||||
|
||||
g.It("Should return a repository file", func() {
|
||||
raw, err := c.File(ctx, fakeUser, fakeRepo, fakeBuild, ".drone.yml")
|
||||
raw, err := c.File(ctx, fakeUser, fakeRepo, fakeBuild, ".woodpecker.yml")
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(string(raw)).Equal("{ platform: linux/amd64 }")
|
||||
})
|
||||
|
||||
g.It("Should return a repository file from a ref", func() {
|
||||
raw, err := c.File(ctx, fakeUser, fakeRepo, fakeBuildWithRef, ".drone.yml")
|
||||
raw, err := c.File(ctx, fakeUser, fakeRepo, fakeBuildWithRef, ".woodpecker.yml")
|
||||
g.Assert(err == nil).IsTrue()
|
||||
g.Assert(string(raw)).Equal("{ platform: linux/amd64 }")
|
||||
})
|
||||
|
|
|
@ -26,7 +26,7 @@ import (
|
|||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
||||
// helper function that converts a Gogs repository to a Drone repository.
|
||||
// helper function that converts a Gogs repository to a Woodpecker repository.
|
||||
func toRepo(from *gogs.Repository, privateMode bool) *model.Repo {
|
||||
name := strings.Split(from.FullName, "/")[1]
|
||||
avatar := expandAvatar(
|
||||
|
@ -50,7 +50,7 @@ func toRepo(from *gogs.Repository, privateMode bool) *model.Repo {
|
|||
}
|
||||
}
|
||||
|
||||
// helper function that converts a Gogs permission to a Drone permission.
|
||||
// helper function that converts a Gogs permission to a Woodpecker permission.
|
||||
func toPerm(from gogs.Permission) *model.Perm {
|
||||
return &model.Perm{
|
||||
Pull: from.Pull,
|
||||
|
@ -59,7 +59,7 @@ func toPerm(from gogs.Permission) *model.Perm {
|
|||
}
|
||||
}
|
||||
|
||||
// helper function that converts a Gogs team to a Drone team.
|
||||
// helper function that converts a Gogs team to a Woodpecker team.
|
||||
func toTeam(from *gogs.Organization, link string) *model.Team {
|
||||
return &model.Team{
|
||||
Login: from.UserName,
|
||||
|
|
|
@ -159,7 +159,7 @@ func Test_parse(t *testing.T) {
|
|||
|
||||
g.It("Should return a Team struct from a Gogs Org", func() {
|
||||
from := &gogs.Organization{
|
||||
UserName: "drone",
|
||||
UserName: "woodpecker",
|
||||
AvatarUrl: "/avatars/1",
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ import (
|
|||
"github.com/woodpecker-ci/woodpecker/version"
|
||||
)
|
||||
|
||||
// Version is a middleware function that appends the Drone version information
|
||||
// Version is a middleware function that appends the Woodpecker version information
|
||||
// to the HTTP response. This is intended for debugging and troubleshooting.
|
||||
func Version(c *gin.Context) {
|
||||
c.Header("X-DRONE-VERSION", version.String())
|
||||
c.Header("X-WOODPECKER-VERSION", version.String())
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ func TestFetch(t *testing.T) {
|
|||
|
||||
for _, tt := range testTable {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
repo := &model.Repo{Owner: "laszlocph", Name: "drone-multipipeline", Config: tt.repoConfig}
|
||||
repo := &model.Repo{Owner: "laszlocph", Name: "multipipeline", Config: tt.repoConfig}
|
||||
|
||||
r := new(mocks.Remote)
|
||||
dirs := map[string][]*remote.FileMeta{}
|
||||
|
|
|
@ -352,7 +352,7 @@ func metadataFromStruct(repo *model.Repo, build, last *model.Build, proc *model.
|
|||
Matrix: proc.Environ,
|
||||
},
|
||||
Sys: frontend.System{
|
||||
Name: "drone",
|
||||
Name: "woodpecker",
|
||||
Link: link,
|
||||
Host: host,
|
||||
Arch: "linux/amd64",
|
||||
|
|
|
@ -25,9 +25,9 @@ import (
|
|||
func TestBuilds(t *testing.T) {
|
||||
repo := &model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
|
||||
s := newTest()
|
||||
|
@ -287,9 +287,9 @@ func TestBuildIncrement(t *testing.T) {
|
|||
|
||||
repo := &model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
if err := s.CreateRepo(repo); err != nil {
|
||||
t.Error(err)
|
||||
|
|
|
@ -37,9 +37,9 @@ func TestConfig(t *testing.T) {
|
|||
|
||||
repo := &model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
if err := s.CreateRepo(repo); err != nil {
|
||||
t.Errorf("Unexpected error: insert repo: %s", err)
|
||||
|
@ -120,9 +120,9 @@ func TestConfigApproved(t *testing.T) {
|
|||
|
||||
repo := &model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
if err := s.CreateRepo(repo); err != nil {
|
||||
t.Errorf("Unexpected error: insert repo: %s", err)
|
||||
|
|
|
@ -31,9 +31,9 @@ func TestPermFind(t *testing.T) {
|
|||
user := &model.User{ID: 1}
|
||||
repo := &model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
s.CreateRepo(repo)
|
||||
|
||||
|
@ -79,9 +79,9 @@ func TestPermUpsert(t *testing.T) {
|
|||
user := &model.User{ID: 1}
|
||||
repo := &model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
s.CreateRepo(repo)
|
||||
|
||||
|
@ -162,9 +162,9 @@ func TestPermDelete(t *testing.T) {
|
|||
user := &model.User{ID: 1}
|
||||
repo := &model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
s.CreateRepo(repo)
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@ func TestRepos(t *testing.T) {
|
|||
g.It("Should Set a Repo", func() {
|
||||
repo := model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
err1 := s.CreateRepo(&repo)
|
||||
err2 := s.UpdateRepo(&repo)
|
||||
|
@ -57,9 +57,9 @@ func TestRepos(t *testing.T) {
|
|||
g.It("Should Add a Repo", func() {
|
||||
repo := model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
err := s.CreateRepo(&repo)
|
||||
g.Assert(err == nil).IsTrue()
|
||||
|
@ -69,9 +69,9 @@ func TestRepos(t *testing.T) {
|
|||
g.It("Should Get a Repo by ID", func() {
|
||||
repo := model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
s.CreateRepo(&repo)
|
||||
getrepo, err := s.GetRepo(repo.ID)
|
||||
|
@ -85,9 +85,9 @@ func TestRepos(t *testing.T) {
|
|||
g.It("Should Get a Repo by Name", func() {
|
||||
repo := model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
s.CreateRepo(&repo)
|
||||
getrepo, err := s.GetRepoName(repo.FullName)
|
||||
|
@ -101,15 +101,15 @@ func TestRepos(t *testing.T) {
|
|||
g.It("Should Enforce Unique Repo Name", func() {
|
||||
repo1 := model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
repo2 := model.Repo{
|
||||
UserID: 2,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
err1 := s.CreateRepo(&repo1)
|
||||
err2 := s.CreateRepo(&repo2)
|
||||
|
@ -141,13 +141,13 @@ func TestRepoList(t *testing.T) {
|
|||
|
||||
repo1 := &model.Repo{
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
FullName: "bradrydzewski/drone",
|
||||
Name: "test",
|
||||
FullName: "bradrydzewski/test",
|
||||
}
|
||||
repo2 := &model.Repo{
|
||||
Owner: "drone",
|
||||
Name: "drone",
|
||||
FullName: "drone/drone",
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
FullName: "test/test",
|
||||
}
|
||||
repo3 := &model.Repo{
|
||||
Owner: "octocat",
|
||||
|
@ -197,14 +197,14 @@ func TestRepoListLatest(t *testing.T) {
|
|||
|
||||
repo1 := &model.Repo{
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
FullName: "bradrydzewski/drone",
|
||||
Name: "test",
|
||||
FullName: "bradrydzewski/test",
|
||||
IsActive: true,
|
||||
}
|
||||
repo2 := &model.Repo{
|
||||
Owner: "drone",
|
||||
Name: "drone",
|
||||
FullName: "drone/drone",
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
FullName: "test/test",
|
||||
IsActive: true,
|
||||
}
|
||||
repo3 := &model.Repo{
|
||||
|
@ -276,20 +276,20 @@ func TestRepoCount(t *testing.T) {
|
|||
|
||||
repo1 := &model.Repo{
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
FullName: "bradrydzewski/drone",
|
||||
Name: "test",
|
||||
FullName: "bradrydzewski/test",
|
||||
IsActive: true,
|
||||
}
|
||||
repo2 := &model.Repo{
|
||||
Owner: "drone",
|
||||
Name: "drone",
|
||||
FullName: "drone/drone",
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
FullName: "test/test",
|
||||
IsActive: true,
|
||||
}
|
||||
repo3 := &model.Repo{
|
||||
Owner: "drone",
|
||||
Name: "drone-ui",
|
||||
FullName: "drone/drone-ui",
|
||||
Owner: "test",
|
||||
Name: "test-ui",
|
||||
FullName: "test/test-ui",
|
||||
IsActive: false,
|
||||
}
|
||||
s.CreateRepo(repo1)
|
||||
|
@ -373,9 +373,9 @@ func TestRepoCrud(t *testing.T) {
|
|||
|
||||
repo := model.Repo{
|
||||
UserID: 1,
|
||||
FullName: "bradrydzewski/drone",
|
||||
FullName: "bradrydzewski/test",
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
Name: "test",
|
||||
}
|
||||
s.CreateRepo(&repo)
|
||||
_, err1 := s.GetRepo(repo.ID)
|
||||
|
|
|
@ -189,14 +189,14 @@ func TestUsers(t *testing.T) {
|
|||
|
||||
repo1 := &model.Repo{
|
||||
Owner: "bradrydzewski",
|
||||
Name: "drone",
|
||||
FullName: "bradrydzewski/drone",
|
||||
Name: "test",
|
||||
FullName: "bradrydzewski/test",
|
||||
IsActive: true,
|
||||
}
|
||||
repo2 := &model.Repo{
|
||||
Owner: "drone",
|
||||
Name: "drone",
|
||||
FullName: "drone/drone",
|
||||
Owner: "test",
|
||||
Name: "test",
|
||||
FullName: "test/test",
|
||||
IsActive: true,
|
||||
}
|
||||
repo3 := &model.Repo{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
swagger: "2.0"
|
||||
info:
|
||||
version: 1.0.0
|
||||
title: Drone API
|
||||
title: Woodpecker API
|
||||
license:
|
||||
name: Creative Commons 4.0 International
|
||||
url: "http://creativecommons.org/licenses/by/4.0/"
|
||||
|
|
Loading…
Reference in a new issue