mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-25 11:21:02 +00:00
Refactor nits (#1652)
-
https://github.com/woodpecker-ci/woodpecker/pull/1641/files#r1141405630
-
ade8e6d010 (r105091268)
-
https://github.com/woodpecker-ci/woodpecker/pull/1647/files#r1141410010
---------
Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
parent
e74c256571
commit
56e6639396
16 changed files with 35 additions and 26 deletions
4
Makefile
4
Makefile
|
@ -91,6 +91,10 @@ clean: ## Clean build artifacts
|
|||
rm -rf build
|
||||
@[ "1" != "$(shell docker image ls woodpecker/make:local -a | wc -l)" ] && docker image rm woodpecker/make:local || echo no docker image to clean
|
||||
|
||||
.PHONY: generate
|
||||
generate: ## Run all code generations
|
||||
go generate ./...
|
||||
|
||||
check-xgo: ## Check if xgo is installed
|
||||
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
|
||||
$(GO) install src.techknowlogick.com/xgo@latest; \
|
||||
|
|
|
@ -8,6 +8,7 @@ package proto
|
|||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
|
@ -163,36 +164,44 @@ type WoodpeckerServer interface {
|
|||
}
|
||||
|
||||
// UnimplementedWoodpeckerServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedWoodpeckerServer struct {
|
||||
}
|
||||
type UnimplementedWoodpeckerServer struct{}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) Next(context.Context, *NextRequest) (*NextReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Next not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) Init(context.Context, *InitRequest) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Init not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) Wait(context.Context, *WaitRequest) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Wait not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) Done(context.Context, *DoneRequest) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Done not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) Extend(context.Context, *ExtendRequest) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Extend not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) Update(context.Context, *UpdateRequest) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) Upload(context.Context, *UploadRequest) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Upload not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) Log(context.Context, *LogRequest) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Log not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) RegisterAgent(context.Context, *RegisterAgentRequest) (*RegisterAgentResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method RegisterAgent not implemented")
|
||||
}
|
||||
|
||||
func (UnimplementedWoodpeckerServer) ReportHealth(context.Context, *ReportHealthRequest) (*Empty, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ReportHealth not implemented")
|
||||
}
|
||||
|
@ -478,8 +487,7 @@ type WoodpeckerAuthServer interface {
|
|||
}
|
||||
|
||||
// UnimplementedWoodpeckerAuthServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedWoodpeckerAuthServer struct {
|
||||
}
|
||||
type UnimplementedWoodpeckerAuthServer struct{}
|
||||
|
||||
func (UnimplementedWoodpeckerAuthServer) Auth(context.Context, *AuthRequest) (*AuthReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Auth not implemented")
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/securecookie"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store"
|
||||
|
|
|
@ -23,15 +23,14 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store/types"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
"github.com/woodpecker-ci/woodpecker/server/badges"
|
||||
"github.com/woodpecker-ci/woodpecker/server/ccmenu"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store/types"
|
||||
)
|
||||
|
||||
func GetBadge(c *gin.Context) {
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rs/zerolog/log"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store"
|
||||
)
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
|
|
@ -20,13 +20,13 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store/types"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
"github.com/woodpecker-ci/woodpecker/server/forge"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
"github.com/woodpecker-ci/woodpecker/server/pipeline"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store/types"
|
||||
)
|
||||
|
||||
func handlePipelineErr(c *gin.Context, err error) {
|
||||
|
|
|
@ -23,11 +23,11 @@ import (
|
|||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/securecookie"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store/types"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store/types"
|
||||
"github.com/woodpecker-ci/woodpecker/shared/httputil"
|
||||
"github.com/woodpecker-ci/woodpecker/shared/token"
|
||||
)
|
||||
|
|
|
@ -18,6 +18,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
)
|
||||
|
|
|
@ -19,6 +19,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session"
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gorilla/securecookie"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store"
|
||||
)
|
||||
|
|
|
@ -17,7 +17,6 @@ package bitbucket
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -304,7 +303,7 @@ func (c *config) BranchHead(_ context.Context, _ *model.User, _ *model.Repo, _ s
|
|||
}
|
||||
|
||||
func (c *config) PullRequests(_ context.Context, _ *model.User, _ *model.Repo, _ *model.PaginationData) ([]*model.PullRequest, error) {
|
||||
return nil, errors.New("Bitbucket does not support pull requests yet")
|
||||
return nil, forge_types.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Hook parses the incoming Bitbucket hook and returns the Repository and
|
||||
|
|
|
@ -24,7 +24,6 @@ import (
|
|||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
@ -246,7 +245,7 @@ func (c *Config) BranchHead(_ context.Context, _ *model.User, _ *model.Repo, _ s
|
|||
}
|
||||
|
||||
func (c *Config) PullRequests(_ context.Context, _ *model.User, _ *model.Repo, _ *model.PaginationData) ([]*model.PullRequest, error) {
|
||||
return nil, errors.New("Bitbucket server does not support pull requests yet")
|
||||
return nil, forge_types.ErrNotImplemented
|
||||
}
|
||||
|
||||
func (c *Config) Deactivate(ctx context.Context, u *model.User, r *model.Repo, link string) error {
|
||||
|
|
|
@ -18,7 +18,6 @@ package gogs
|
|||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
|
@ -301,7 +300,7 @@ func (c *client) BranchHead(_ context.Context, u *model.User, r *model.Repo, bra
|
|||
}
|
||||
|
||||
func (c *client) PullRequests(_ context.Context, _ *model.User, _ *model.Repo, _ *model.PaginationData) ([]*model.PullRequest, error) {
|
||||
return nil, errors.New("Gogs does not support pull requests yet")
|
||||
return nil, forge_types.ErrNotImplemented
|
||||
}
|
||||
|
||||
// Hook parses the incoming Gogs hook and returns the Repository and Pipeline
|
||||
|
|
|
@ -21,11 +21,11 @@ import (
|
|||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store/types"
|
||||
|
||||
"github.com/woodpecker-ci/woodpecker/server"
|
||||
"github.com/woodpecker-ci/woodpecker/server/model"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store"
|
||||
"github.com/woodpecker-ci/woodpecker/server/store/types"
|
||||
)
|
||||
|
||||
func Repo(c *gin.Context) *model.Repo {
|
||||
|
|
|
@ -295,7 +295,7 @@ func (c *client) PipelineLogs(owner, name string, num, step int) ([]*Logs, error
|
|||
func (c *client) Deploy(owner, name string, num int, env string, params map[string]string) (*Pipeline, error) {
|
||||
out := new(Pipeline)
|
||||
val := mapValues(params)
|
||||
val.Set("event", "deployment")
|
||||
val.Set("event", EventDeploy)
|
||||
val.Set("deploy_to", env)
|
||||
uri := fmt.Sprintf(pathPipeline, c.addr, owner, name, num)
|
||||
err := c.post(uri+"?"+val.Encode(), nil, out)
|
||||
|
@ -521,27 +521,22 @@ func (c *client) CronGet(owner, repo string, cronID int64) (*Cron, error) {
|
|||
|
||||
// helper function for making an http GET request.
|
||||
func (c *client) get(rawurl string, out interface{}) error {
|
||||
return c.do(rawurl, "GET", nil, out)
|
||||
return c.do(rawurl, http.MethodGet, nil, out)
|
||||
}
|
||||
|
||||
// helper function for making an http POST request.
|
||||
func (c *client) post(rawurl string, in, out interface{}) error {
|
||||
return c.do(rawurl, "POST", in, out)
|
||||
return c.do(rawurl, http.MethodPost, in, out)
|
||||
}
|
||||
|
||||
// helper function for making an http PUT request.
|
||||
// func (c *client) put(rawurl string, in, out interface{}) error {
|
||||
// return c.do(rawurl, "PUT", in, out)
|
||||
// }
|
||||
|
||||
// helper function for making an http PATCH request.
|
||||
func (c *client) patch(rawurl string, in, out interface{}) error {
|
||||
return c.do(rawurl, "PATCH", in, out)
|
||||
return c.do(rawurl, http.MethodPatch, in, out)
|
||||
}
|
||||
|
||||
// helper function for making an http DELETE request.
|
||||
func (c *client) delete(rawurl string) error {
|
||||
return c.do(rawurl, "DELETE", nil, nil)
|
||||
return c.do(rawurl, http.MethodDelete, nil, nil)
|
||||
}
|
||||
|
||||
// helper function to make an http request
|
||||
|
|
Loading…
Reference in a new issue