6543 2023-03-19 18:32:19 +01:00 committed by GitHub
parent e74c256571
commit 56e6639396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 35 additions and 26 deletions

View file

@ -91,6 +91,10 @@ clean: ## Clean build artifacts
rm -rf build 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 @[ "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 check-xgo: ## Check if xgo is installed
@hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ @hash xgo > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) install src.techknowlogick.com/xgo@latest; \ $(GO) install src.techknowlogick.com/xgo@latest; \

View file

@ -8,6 +8,7 @@ package proto
import ( import (
context "context" context "context"
grpc "google.golang.org/grpc" grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes" codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status" status "google.golang.org/grpc/status"
@ -163,36 +164,44 @@ type WoodpeckerServer interface {
} }
// UnimplementedWoodpeckerServer must be embedded to have forward compatible implementations. // UnimplementedWoodpeckerServer must be embedded to have forward compatible implementations.
type UnimplementedWoodpeckerServer struct { type UnimplementedWoodpeckerServer struct{}
}
func (UnimplementedWoodpeckerServer) Next(context.Context, *NextRequest) (*NextReply, error) { func (UnimplementedWoodpeckerServer) Next(context.Context, *NextRequest) (*NextReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Next not implemented") return nil, status.Errorf(codes.Unimplemented, "method Next not implemented")
} }
func (UnimplementedWoodpeckerServer) Init(context.Context, *InitRequest) (*Empty, error) { func (UnimplementedWoodpeckerServer) Init(context.Context, *InitRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Init not implemented") return nil, status.Errorf(codes.Unimplemented, "method Init not implemented")
} }
func (UnimplementedWoodpeckerServer) Wait(context.Context, *WaitRequest) (*Empty, error) { func (UnimplementedWoodpeckerServer) Wait(context.Context, *WaitRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Wait not implemented") return nil, status.Errorf(codes.Unimplemented, "method Wait not implemented")
} }
func (UnimplementedWoodpeckerServer) Done(context.Context, *DoneRequest) (*Empty, error) { func (UnimplementedWoodpeckerServer) Done(context.Context, *DoneRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Done not implemented") return nil, status.Errorf(codes.Unimplemented, "method Done not implemented")
} }
func (UnimplementedWoodpeckerServer) Extend(context.Context, *ExtendRequest) (*Empty, error) { func (UnimplementedWoodpeckerServer) Extend(context.Context, *ExtendRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Extend not implemented") return nil, status.Errorf(codes.Unimplemented, "method Extend not implemented")
} }
func (UnimplementedWoodpeckerServer) Update(context.Context, *UpdateRequest) (*Empty, error) { func (UnimplementedWoodpeckerServer) Update(context.Context, *UpdateRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented") return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
} }
func (UnimplementedWoodpeckerServer) Upload(context.Context, *UploadRequest) (*Empty, error) { func (UnimplementedWoodpeckerServer) Upload(context.Context, *UploadRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Upload not implemented") return nil, status.Errorf(codes.Unimplemented, "method Upload not implemented")
} }
func (UnimplementedWoodpeckerServer) Log(context.Context, *LogRequest) (*Empty, error) { func (UnimplementedWoodpeckerServer) Log(context.Context, *LogRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method Log not implemented") return nil, status.Errorf(codes.Unimplemented, "method Log not implemented")
} }
func (UnimplementedWoodpeckerServer) RegisterAgent(context.Context, *RegisterAgentRequest) (*RegisterAgentResponse, error) { func (UnimplementedWoodpeckerServer) RegisterAgent(context.Context, *RegisterAgentRequest) (*RegisterAgentResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RegisterAgent not implemented") return nil, status.Errorf(codes.Unimplemented, "method RegisterAgent not implemented")
} }
func (UnimplementedWoodpeckerServer) ReportHealth(context.Context, *ReportHealthRequest) (*Empty, error) { func (UnimplementedWoodpeckerServer) ReportHealth(context.Context, *ReportHealthRequest) (*Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method ReportHealth not implemented") 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. // UnimplementedWoodpeckerAuthServer must be embedded to have forward compatible implementations.
type UnimplementedWoodpeckerAuthServer struct { type UnimplementedWoodpeckerAuthServer struct{}
}
func (UnimplementedWoodpeckerAuthServer) Auth(context.Context, *AuthRequest) (*AuthReply, error) { func (UnimplementedWoodpeckerAuthServer) Auth(context.Context, *AuthRequest) (*AuthReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method Auth not implemented") return nil, status.Errorf(codes.Unimplemented, "method Auth not implemented")

View file

@ -21,6 +21,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/securecookie" "github.com/gorilla/securecookie"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session" "github.com/woodpecker-ci/woodpecker/server/router/middleware/session"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"

View file

@ -23,15 +23,14 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/server/store/types"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/server" "github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/badges" "github.com/woodpecker-ci/woodpecker/server/badges"
"github.com/woodpecker-ci/woodpecker/server/ccmenu" "github.com/woodpecker-ci/woodpecker/server/ccmenu"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
"github.com/woodpecker-ci/woodpecker/server/store/types"
) )
func GetBadge(c *gin.Context) { func GetBadge(c *gin.Context) {

View file

@ -23,6 +23,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session" "github.com/woodpecker-ci/woodpecker/server/router/middleware/session"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
) )

View file

@ -18,6 +18,7 @@ import (
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/woodpecker-ci/woodpecker/server" "github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
) )

View file

@ -20,13 +20,13 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rs/zerolog/log" "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"
"github.com/woodpecker-ci/woodpecker/server/forge" "github.com/woodpecker-ci/woodpecker/server/forge"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/pipeline" "github.com/woodpecker-ci/woodpecker/server/pipeline"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
"github.com/woodpecker-ci/woodpecker/server/store/types"
) )
func handlePipelineErr(c *gin.Context, err error) { func handlePipelineErr(c *gin.Context, err error) {

View file

@ -23,11 +23,11 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/securecookie" "github.com/gorilla/securecookie"
"github.com/rs/zerolog/log" "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"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/store" "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/httputil"
"github.com/woodpecker-ci/woodpecker/shared/token" "github.com/woodpecker-ci/woodpecker/shared/token"
) )

View file

@ -18,6 +18,7 @@ import (
"net/http" "net/http"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/woodpecker-ci/woodpecker/server" "github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
) )

View file

@ -19,6 +19,7 @@ import (
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/woodpecker-ci/woodpecker/server" "github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/router/middleware/session" "github.com/woodpecker-ci/woodpecker/server/router/middleware/session"

View file

@ -20,6 +20,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/securecookie" "github.com/gorilla/securecookie"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
) )

View file

@ -17,7 +17,6 @@ package bitbucket
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"net/http" "net/http"
"net/url" "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) { 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 // Hook parses the incoming Bitbucket hook and returns the Repository and

View file

@ -24,7 +24,6 @@ import (
"crypto/tls" "crypto/tls"
"crypto/x509" "crypto/x509"
"encoding/pem" "encoding/pem"
"errors"
"fmt" "fmt"
"net/http" "net/http"
"os" "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) { 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 { func (c *Config) Deactivate(ctx context.Context, u *model.User, r *model.Repo, link string) error {

View file

@ -18,7 +18,6 @@ package gogs
import ( import (
"context" "context"
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"net" "net"
"net/http" "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) { 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 // Hook parses the incoming Gogs hook and returns the Repository and Pipeline

View file

@ -21,11 +21,11 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rs/zerolog/log" "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"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
"github.com/woodpecker-ci/woodpecker/server/store/types"
) )
func Repo(c *gin.Context) *model.Repo { func Repo(c *gin.Context) *model.Repo {

View file

@ -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) { func (c *client) Deploy(owner, name string, num int, env string, params map[string]string) (*Pipeline, error) {
out := new(Pipeline) out := new(Pipeline)
val := mapValues(params) val := mapValues(params)
val.Set("event", "deployment") val.Set("event", EventDeploy)
val.Set("deploy_to", env) val.Set("deploy_to", env)
uri := fmt.Sprintf(pathPipeline, c.addr, owner, name, num) uri := fmt.Sprintf(pathPipeline, c.addr, owner, name, num)
err := c.post(uri+"?"+val.Encode(), nil, out) 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. // helper function for making an http GET request.
func (c *client) get(rawurl string, out interface{}) error { 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. // helper function for making an http POST request.
func (c *client) post(rawurl string, in, out interface{}) error { 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. // helper function for making an http PATCH request.
func (c *client) patch(rawurl string, in, out interface{}) error { 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. // helper function for making an http DELETE request.
func (c *client) delete(rawurl string) error { 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 // helper function to make an http request