You've already forked woodpecker
							
							
				mirror of
				https://github.com/woodpecker-ci/woodpecker.git
				synced 2025-10-30 23:27:39 +02:00 
			
		
		
		
	Move entirely to zerolog (#426)
Completely switch to zerolog (Remove usage of logrus and std logger) Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
		| @@ -23,15 +23,14 @@ import ( | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/tevino/abool" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/backend" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/multipart" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc" | ||||
|  | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/tevino/abool" | ||||
| ) | ||||
|  | ||||
| // TODO: Implement log streaming. | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"strconv" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"strconv" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import ( | ||||
| 	"text/template" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"strconv" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"text/template" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"text/template" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import ( | ||||
| 	"text/template" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import ( | ||||
| 	"text/template" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -6,6 +6,7 @@ import ( | ||||
| 	"strconv" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"strconv" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -6,10 +6,10 @@ import ( | ||||
| 	"os" | ||||
| 	"strconv" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| 	"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| ) | ||||
|  | ||||
| // Command exports the deploy command. | ||||
|   | ||||
| @@ -5,13 +5,15 @@ import ( | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"log" | ||||
| 	"path" | ||||
| 	"path/filepath" | ||||
| 	"runtime" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/drone/envsubst" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/backend" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/backend/docker" | ||||
| @@ -22,8 +24,6 @@ import ( | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/matrix" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/interrupt" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/multipart" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| ) | ||||
|  | ||||
| // Command exports the exec command. | ||||
| @@ -33,7 +33,7 @@ var Command = cli.Command{ | ||||
| 	ArgsUsage: "[path/to/.woodpecker.yml]", | ||||
| 	Action: func(c *cli.Context) { | ||||
| 		if err := exec(c); err != nil { | ||||
| 			log.Fatalln(err) | ||||
| 			log.Fatal().Err(err).Msg("") | ||||
| 		} | ||||
| 	}, | ||||
| 	Flags: flags, | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/schema" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"strconv" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -4,10 +4,10 @@ import ( | ||||
| 	"io/ioutil" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| 	"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| ) | ||||
|  | ||||
| var registryCreateCmd = cli.Command{ | ||||
|   | ||||
| @@ -4,9 +4,9 @@ import ( | ||||
| 	"html/template" | ||||
| 	"os" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
| var registryInfoCmd = cli.Command{ | ||||
|   | ||||
| @@ -1,9 +1,9 @@ | ||||
| package registry | ||||
|  | ||||
| import ( | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
| var registryDeleteCmd = cli.Command{ | ||||
|   | ||||
| @@ -4,10 +4,10 @@ import ( | ||||
| 	"io/ioutil" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| 	"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| ) | ||||
|  | ||||
| var registryUpdateCmd = cli.Command{ | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -4,6 +4,7 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"text/template" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"text/template" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -2,6 +2,7 @@ package repo | ||||
|  | ||||
| import ( | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -3,9 +3,9 @@ package repo | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
| var repoRemoveCmd = cli.Command{ | ||||
|   | ||||
| @@ -5,6 +5,7 @@ import ( | ||||
| 	"text/template" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -4,10 +4,10 @@ import ( | ||||
| 	"fmt" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| 	"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| ) | ||||
|  | ||||
| var repoUpdateCmd = cli.Command{ | ||||
|   | ||||
| @@ -4,10 +4,10 @@ import ( | ||||
| 	"io/ioutil" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| 	"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| ) | ||||
|  | ||||
| var secretCreateCmd = cli.Command{ | ||||
|   | ||||
| @@ -4,10 +4,10 @@ import ( | ||||
| 	"io/ioutil" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| 	"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| ) | ||||
|  | ||||
| var secretUpdateCmd = cli.Command{ | ||||
|   | ||||
| @@ -4,9 +4,9 @@ import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
| 	"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/internal" | ||||
| 	"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" | ||||
| ) | ||||
|  | ||||
| var userAddCmd = cli.Command{ | ||||
|   | ||||
| @@ -21,21 +21,19 @@ import ( | ||||
| 	"os" | ||||
| 	"sync" | ||||
|  | ||||
| 	grpccredentials "google.golang.org/grpc/credentials" | ||||
|  | ||||
| 	"github.com/rs/zerolog" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/tevino/abool" | ||||
| 	"github.com/urfave/cli" | ||||
| 	oldcontext "golang.org/x/net/context" | ||||
| 	"google.golang.org/grpc" | ||||
| 	grpccredentials "google.golang.org/grpc/credentials" | ||||
| 	"google.golang.org/grpc/keepalive" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/agent" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/backend/docker" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc" | ||||
|  | ||||
| 	"github.com/rs/zerolog" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/tevino/abool" | ||||
| 	"github.com/urfave/cli" | ||||
| 	oldcontext "golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| func loop(c *cli.Context) error { | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import ( | ||||
| 	"net/http" | ||||
|  | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/agent" | ||||
| 	"github.com/woodpecker-ci/woodpecker/version" | ||||
| ) | ||||
|   | ||||
| @@ -18,10 +18,10 @@ import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/version" | ||||
|  | ||||
| 	_ "github.com/joho/godotenv/autoload" | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/version" | ||||
| ) | ||||
|  | ||||
| func main() { | ||||
|   | ||||
| @@ -18,6 +18,9 @@ import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
|  | ||||
| 	_ "github.com/joho/godotenv/autoload" | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/build" | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/deploy" | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/exec" | ||||
| @@ -29,9 +32,6 @@ import ( | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/secret" | ||||
| 	"github.com/woodpecker-ci/woodpecker/cli/user" | ||||
| 	"github.com/woodpecker-ci/woodpecker/version" | ||||
|  | ||||
| 	_ "github.com/joho/godotenv/autoload" | ||||
| 	"github.com/urfave/cli" | ||||
| ) | ||||
|  | ||||
| func main() { | ||||
|   | ||||
| @@ -26,6 +26,16 @@ var flags = []cli.Flag{ | ||||
| 		Name:   "debug", | ||||
| 		Usage:  "enable server debug mode", | ||||
| 	}, | ||||
| 	cli.BoolFlag{ | ||||
| 		EnvVar: "WOODPECKER_DEBUG_PRETTY", | ||||
| 		Name:   "pretty", | ||||
| 		Usage:  "enable pretty-printed debug output", | ||||
| 	}, | ||||
| 	cli.BoolTFlag{ | ||||
| 		EnvVar: "WOODPECKER_DEBUG_NOCOLOR", | ||||
| 		Name:   "nocolor", | ||||
| 		Usage:  "disable colored debug output", | ||||
| 	}, | ||||
| 	cli.StringFlag{ | ||||
| 		EnvVar: "WOODPECKER_HOST", | ||||
| 		Name:   "server-host", | ||||
|   | ||||
| @@ -18,11 +18,11 @@ import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/version" | ||||
|  | ||||
| 	"github.com/joho/godotenv" | ||||
| 	_ "github.com/joho/godotenv/autoload" | ||||
| 	"github.com/urfave/cli" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/version" | ||||
| ) | ||||
|  | ||||
| func main() { | ||||
|   | ||||
| @@ -27,13 +27,16 @@ import ( | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/rs/zerolog" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"golang.org/x/crypto/acme/autocert" | ||||
| 	oldcontext "golang.org/x/net/context" | ||||
| 	"golang.org/x/sync/errgroup" | ||||
| 	"google.golang.org/grpc" | ||||
| 	"google.golang.org/grpc/keepalive" | ||||
| 	"google.golang.org/grpc/metadata" | ||||
|  | ||||
| 	"golang.org/x/crypto/acme/autocert" | ||||
| 	"golang.org/x/sync/errgroup" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	woodpeckerGrpcServer "github.com/woodpecker-ci/woodpecker/server/grpc" | ||||
| @@ -43,12 +46,8 @@ import ( | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/router" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/router/middleware" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/router/middleware/logger" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store" | ||||
|  | ||||
| 	"github.com/gin-gonic/contrib/ginrus" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/urfave/cli" | ||||
| 	oldcontext "golang.org/x/net/context" | ||||
| ) | ||||
|  | ||||
| func loop(c *cli.Context) error { | ||||
| @@ -56,37 +55,45 @@ func loop(c *cli.Context) error { | ||||
| 	// debug level if requested by user | ||||
| 	// TODO: format output & options to switch to json aka. option to add channels to send logs to | ||||
| 	if c.Bool("debug") { | ||||
| 		logrus.SetReportCaller(true) | ||||
| 		logrus.SetLevel(logrus.DebugLevel) | ||||
| 		zerolog.SetGlobalLevel(zerolog.DebugLevel) | ||||
| 	} else { | ||||
| 		logrus.SetLevel(logrus.WarnLevel) | ||||
| 		zerolog.SetGlobalLevel(zerolog.WarnLevel) | ||||
| 	} | ||||
|  | ||||
| 	if c.Bool("pretty") { | ||||
| 		log.Logger = log.Output( | ||||
| 			zerolog.ConsoleWriter{ | ||||
| 				Out:     os.Stderr, | ||||
| 				NoColor: c.BoolT("nocolor"), | ||||
| 			}, | ||||
| 		) | ||||
| 	} | ||||
|  | ||||
| 	if c.String("server-host") == "" { | ||||
| 		logrus.Fatalln("WOODPECKER_HOST is not properly configured") | ||||
| 		log.Fatal().Msg("WOODPECKER_HOST is not properly configured") | ||||
| 	} | ||||
|  | ||||
| 	if !strings.Contains(c.String("server-host"), "://") { | ||||
| 		logrus.Fatalln( | ||||
| 		log.Fatal().Msg( | ||||
| 			"WOODPECKER_HOST must be <scheme>://<hostname> format", | ||||
| 		) | ||||
| 	} | ||||
|  | ||||
| 	if strings.Contains(c.String("server-host"), "://localhost") { | ||||
| 		logrus.Warningln( | ||||
| 		log.Warn().Msg( | ||||
| 			"WOODPECKER_HOST should probably be publicly accessible (not localhost)", | ||||
| 		) | ||||
| 	} | ||||
|  | ||||
| 	if strings.HasSuffix(c.String("server-host"), "/") { | ||||
| 		logrus.Fatalln( | ||||
| 		log.Fatal().Msg( | ||||
| 			"WOODPECKER_HOST must not have trailing slash", | ||||
| 		) | ||||
| 	} | ||||
|  | ||||
| 	remote_, err := SetupRemote(c) | ||||
| 	if err != nil { | ||||
| 		logrus.Fatal(err) | ||||
| 		log.Fatal().Err(err).Msg("") | ||||
| 	} | ||||
|  | ||||
| 	store_ := setupStore(c) | ||||
| @@ -116,7 +123,7 @@ func loop(c *cli.Context) error { | ||||
| 	// setup the server and start the listener | ||||
| 	handler := router.Load( | ||||
| 		webUIServe, | ||||
| 		ginrus.Ginrus(logrus.StandardLogger(), time.RFC3339, true), | ||||
| 		logger.Logger(time.RFC3339, true), | ||||
| 		middleware.Version, | ||||
| 		middleware.Config(c), | ||||
| 		middleware.Store(c, store_), | ||||
| @@ -130,7 +137,7 @@ func loop(c *cli.Context) error { | ||||
|  | ||||
| 		lis, err := net.Listen("tcp", c.String("grpc-addr")) | ||||
| 		if err != nil { | ||||
| 			logrus.Error(err) | ||||
| 			log.Err(err).Msg("") | ||||
| 			return err | ||||
| 		} | ||||
| 		auther := &authorizer{ | ||||
| @@ -155,7 +162,7 @@ func loop(c *cli.Context) error { | ||||
|  | ||||
| 		err = grpcServer.Serve(lis) | ||||
| 		if err != nil { | ||||
| 			logrus.Error(err) | ||||
| 			log.Err(err).Msg("") | ||||
| 			return err | ||||
| 		} | ||||
| 		return nil | ||||
|   | ||||
| @@ -19,6 +19,12 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	"github.com/prometheus/client_golang/prometheus" | ||||
| 	"github.com/prometheus/client_golang/prometheus/promauto" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"golang.org/x/sync/errgroup" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/plugins/environments" | ||||
| @@ -36,12 +42,6 @@ import ( | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store/datastore" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/web" | ||||
|  | ||||
| 	"github.com/prometheus/client_golang/prometheus" | ||||
| 	"github.com/prometheus/client_golang/prometheus/promauto" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/urfave/cli" | ||||
| 	"golang.org/x/sync/errgroup" | ||||
| ) | ||||
|  | ||||
| func setupStore(c *cli.Context) store.Store { | ||||
| @@ -128,7 +128,7 @@ func setupGitea(c *cli.Context) (remote.Remote, error) { | ||||
| 		SkipVerify:  c.Bool("gitea-skip-verify"), | ||||
| 	} | ||||
| 	if len(opts.URL) == 0 { | ||||
| 		logrus.Fatalln("WOODPECKER_GITEA_URL must be set") | ||||
| 		log.Fatal().Msg("WOODPECKER_GITEA_URL must be set") | ||||
| 	} | ||||
| 	return gitea.New(opts) | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							| @@ -19,7 +19,6 @@ require ( | ||||
| 	github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect | ||||
| 	github.com/franela/goblin v0.0.0-20200512143142-b260c999b2d7 | ||||
| 	github.com/ghodss/yaml v1.0.0 | ||||
| 	github.com/gin-gonic/contrib v0.0.0-20191209060500-d6e26eeaa607 | ||||
| 	github.com/gin-gonic/gin v1.7.4 | ||||
| 	github.com/go-playground/validator/v10 v10.9.0 // indirect | ||||
| 	github.com/go-sql-driver/mysql v1.6.0 | ||||
| @@ -43,7 +42,6 @@ require ( | ||||
| 	github.com/prometheus/client_golang v1.7.1 | ||||
| 	github.com/rs/zerolog v1.25.0 | ||||
| 	github.com/russross/meddler v1.0.1 | ||||
| 	github.com/sirupsen/logrus v1.8.1 | ||||
| 	github.com/stretchr/objx v0.3.0 // indirect | ||||
| 	github.com/stretchr/testify v1.7.0 | ||||
| 	github.com/tevino/abool v0.0.0-20170917061928-9b9efcf221b5 | ||||
|   | ||||
							
								
								
									
										2
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.sum
									
									
									
									
									
								
							| @@ -283,8 +283,6 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= | ||||
| github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= | ||||
| github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= | ||||
| github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= | ||||
| github.com/gin-gonic/contrib v0.0.0-20191209060500-d6e26eeaa607 h1:MrIm8EEPue08JS4eh+b08IOG+wd0WRWEHWnewNfWFX0= | ||||
| github.com/gin-gonic/contrib v0.0.0-20191209060500-d6e26eeaa607/go.mod h1:iqneQ2Df3omzIVTkIfn7c1acsVnMGiSLn4XF5Blh3Yg= | ||||
| github.com/gin-gonic/gin v1.7.4 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM= | ||||
| github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= | ||||
| github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= | ||||
|   | ||||
| @@ -1,9 +1,7 @@ | ||||
| package docker | ||||
|  | ||||
| // import ( | ||||
| // 	"context" | ||||
| // | ||||
| // 	"github.com/woodpecker-ci/woodpecker/pipeline/backend" | ||||
|  | ||||
| // ) | ||||
| // | ||||
| // // Pool manages a pool of Docker clients. | ||||
|   | ||||
| @@ -4,9 +4,9 @@ import ( | ||||
| 	"path" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml" | ||||
|  | ||||
| 	libcompose "github.com/docker/libcompose/yaml" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml" | ||||
| ) | ||||
|  | ||||
| // Cacher defines a compiler transform that can be used | ||||
|   | ||||
| @@ -25,7 +25,7 @@ func (c *Compiler) createProcess(name string, container *yaml.Container, section | ||||
| 	) | ||||
|  | ||||
| 	networks := []backend.Conn{ | ||||
| 		backend.Conn{ | ||||
| 		{ | ||||
| 			Name:    fmt.Sprintf("%s_default", c.prefix), | ||||
| 			Aliases: []string{container.Name}, | ||||
| 		}, | ||||
|   | ||||
| @@ -7,9 +7,10 @@ import ( | ||||
|  | ||||
| 	"github.com/bmatcuk/doublestar/v4" | ||||
| 	libcompose "github.com/docker/libcompose/yaml" | ||||
| 	"gopkg.in/yaml.v3" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/frontend" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types" | ||||
| 	"gopkg.in/yaml.v3" | ||||
| ) | ||||
|  | ||||
| type ( | ||||
|   | ||||
| @@ -3,9 +3,9 @@ package yaml | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/frontend" | ||||
|  | ||||
| 	"gopkg.in/yaml.v3" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/frontend" | ||||
| ) | ||||
|  | ||||
| func TestConstraint(t *testing.T) { | ||||
|   | ||||
| @@ -3,10 +3,9 @@ package coverage | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"strconv" | ||||
|  | ||||
| 	"mime/multipart" | ||||
| 	"net/textproto" | ||||
| 	"strconv" | ||||
| ) | ||||
|  | ||||
| // MimeType used by coverage reports. | ||||
|   | ||||
| @@ -3,15 +3,15 @@ package rpc | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"log" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/backend" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto" | ||||
|  | ||||
| 	"github.com/rs/zerolog/log" | ||||
| 	"google.golang.org/grpc" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/status" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/backend" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto" | ||||
| ) | ||||
|  | ||||
| var backoff = time.Second | ||||
| @@ -46,7 +46,7 @@ func (c *client) Next(ctx context.Context, f Filter) (*Pipeline, error) { | ||||
| 		if err == nil { | ||||
| 			break | ||||
| 		} else { | ||||
| 			log.Printf("grpc error: done(): code: %v: %s", status.Code(err), err) | ||||
| 			log.Err(err).Msgf("grpc error: done(): code: %v: %s", status.Code(err), err) | ||||
| 		} | ||||
| 		switch status.Code(err) { | ||||
| 		case | ||||
| @@ -86,7 +86,7 @@ func (c *client) Wait(ctx context.Context, id string) (err error) { | ||||
| 		if err == nil { | ||||
| 			break | ||||
| 		} else { | ||||
| 			log.Printf("grpc error: wait(): code: %v: %s", status.Code(err), err) | ||||
| 			log.Err(err).Msgf("grpc error: wait(): code: %v: %s", status.Code(err), err) | ||||
| 		} | ||||
| 		switch status.Code(err) { | ||||
| 		case | ||||
| @@ -120,7 +120,7 @@ func (c *client) Init(ctx context.Context, id string, state State) (err error) { | ||||
| 		if err == nil { | ||||
| 			break | ||||
| 		} else { | ||||
| 			log.Printf("grpc error: init(): code: %v: %s", status.Code(err), err) | ||||
| 			log.Err(err).Msgf("grpc error: init(): code: %v: %s", status.Code(err), err) | ||||
| 		} | ||||
| 		switch status.Code(err) { | ||||
| 		case | ||||
| @@ -154,7 +154,7 @@ func (c *client) Done(ctx context.Context, id string, state State) (err error) { | ||||
| 		if err == nil { | ||||
| 			break | ||||
| 		} else { | ||||
| 			log.Printf("grpc error: done(): code: %v: %s", status.Code(err), err) | ||||
| 			log.Err(err).Msgf("grpc error: done(): code: %v: %s", status.Code(err), err) | ||||
| 		} | ||||
| 		switch status.Code(err) { | ||||
| 		case | ||||
| @@ -181,7 +181,7 @@ func (c *client) Extend(ctx context.Context, id string) (err error) { | ||||
| 		if err == nil { | ||||
| 			break | ||||
| 		} else { | ||||
| 			log.Printf("grpc error: extend(): code: %v: %s", status.Code(err), err) | ||||
| 			log.Err(err).Msgf("grpc error: extend(): code: %v: %s", status.Code(err), err) | ||||
| 		} | ||||
| 		switch status.Code(err) { | ||||
| 		case | ||||
| @@ -215,7 +215,7 @@ func (c *client) Update(ctx context.Context, id string, state State) (err error) | ||||
| 		if err == nil { | ||||
| 			break | ||||
| 		} else { | ||||
| 			log.Printf("grpc error: update(): code: %v: %s", status.Code(err), err) | ||||
| 			log.Err(err).Msgf("grpc error: update(): code: %v: %s", status.Code(err), err) | ||||
| 		} | ||||
| 		switch status.Code(err) { | ||||
| 		case | ||||
| @@ -250,7 +250,7 @@ func (c *client) Upload(ctx context.Context, id string, file *File) (err error) | ||||
| 		if err == nil { | ||||
| 			break | ||||
| 		} else { | ||||
| 			log.Printf("grpc error: upload(): code: %v: %s", status.Code(err), err) | ||||
| 			log.Err(err).Msgf("grpc error: upload(): code: %v: %s", status.Code(err), err) | ||||
| 		} | ||||
| 		switch status.Code(err) { | ||||
| 		case | ||||
| @@ -282,7 +282,7 @@ func (c *client) Log(ctx context.Context, id string, line *Line) (err error) { | ||||
| 		if err == nil { | ||||
| 			break | ||||
| 		} else { | ||||
| 			log.Printf("grpc error: log(): code: %v: %s", status.Code(err), err) | ||||
| 			log.Err(err).Msgf("grpc error: log(): code: %v: %s", status.Code(err), err) | ||||
| 		} | ||||
| 		switch status.Code(err) { | ||||
| 		case | ||||
|   | ||||
| @@ -2,15 +2,13 @@ package rpc | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	// "encoding/json" | ||||
| 	"time" | ||||
|  | ||||
| 	// "github.com/woodpecker-ci/woodpecker/pipeline/backend" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto" | ||||
|  | ||||
| 	"google.golang.org/grpc" | ||||
| 	"google.golang.org/grpc/codes" | ||||
| 	"google.golang.org/grpc/status" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto" | ||||
| ) | ||||
|  | ||||
| // generate protobuffs | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| // Code generated by protoc-gen-go. DO NOT EDIT. | ||||
| // versions: | ||||
| // 	protoc-gen-go v1.27.1 | ||||
| // 	protoc        v3.17.3 | ||||
| // 	protoc        v3.18.1 | ||||
| // source: woodpecker.proto | ||||
|  | ||||
| package proto | ||||
|   | ||||
| @@ -1,4 +1,8 @@ | ||||
| // Code generated by protoc-gen-go-grpc. DO NOT EDIT. | ||||
| // versions: | ||||
| // - protoc-gen-go-grpc v1.1.0 | ||||
| // - protoc             v3.18.1 | ||||
| // source: woodpecker.proto | ||||
|  | ||||
| package proto | ||||
|  | ||||
|   | ||||
| @@ -4,8 +4,9 @@ import ( | ||||
| 	_ "embed" | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/shared/yml" | ||||
| 	"github.com/xeipuuv/gojsonschema" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/shared/yml" | ||||
| ) | ||||
|  | ||||
| //go:embed schema.json | ||||
|   | ||||
| @@ -4,9 +4,9 @@ import ( | ||||
| 	"fmt" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/schema" | ||||
|  | ||||
| 	"github.com/stretchr/testify/assert" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/schema" | ||||
| ) | ||||
|  | ||||
| func TestSchema(t *testing.T) { | ||||
|   | ||||
| @@ -20,8 +20,9 @@ package api | ||||
| import ( | ||||
| 	"fmt" | ||||
|  | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	log "github.com/sirupsen/logrus" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| @@ -60,7 +61,7 @@ func GetBadge(c *gin.Context) { | ||||
|  | ||||
| 	build, err := store.GetBuildLast(c, repo, branch) | ||||
| 	if err != nil { | ||||
| 		log.Warning(err) | ||||
| 		log.Warn().Err(err).Msg("") | ||||
| 		c.String(200, badgeNone) | ||||
| 		return | ||||
| 	} | ||||
|   | ||||
| @@ -22,13 +22,13 @@ import ( | ||||
| 	"context" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"log" | ||||
| 	"net/http" | ||||
| 	"strconv" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/queue" | ||||
| @@ -208,11 +208,11 @@ func DeleteBuild(c *gin.Context) { | ||||
| 		if proc.State == model.StatusPending { | ||||
| 			if proc.PPID != 0 { | ||||
| 				if _, err = shared.UpdateProcToStatusSkipped(store.FromContext(c), *proc, 0); err != nil { | ||||
| 					log.Printf("error: done: cannot update proc_id %d state: %s", proc.ID, err) | ||||
| 					log.Error().Msgf("error: done: cannot update proc_id %d state: %s", proc.ID, err) | ||||
| 				} | ||||
| 			} else { | ||||
| 				if _, err = shared.UpdateProcToStatusKilled(store.FromContext(c), *proc); err != nil { | ||||
| 					log.Printf("error: done: cannot update proc_id %d state: %s", proc.ID, err) | ||||
| 					log.Error().Msgf("error: done: cannot update proc_id %d state: %s", proc.ID, err) | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| @@ -262,7 +262,7 @@ func PostApproval(c *gin.Context) { | ||||
| 	// fetch the build file from the database | ||||
| 	configs, err := server.Config.Storage.Config.ConfigsForBuild(build.ID) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to get build config for %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to get build config for %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(404, err) | ||||
| 		return | ||||
| 	} | ||||
| @@ -285,11 +285,11 @@ func PostApproval(c *gin.Context) { | ||||
| 	last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID) | ||||
| 	secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build) | ||||
| 	if err != nil { | ||||
| 		logrus.Debugf("Error getting secrets for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 		log.Debug().Msgf("Error getting secrets for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 	} | ||||
| 	regs, err := server.Config.Services.Registries.RegistryList(repo) | ||||
| 	if err != nil { | ||||
| 		logrus.Debugf("Error getting registry credentials for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 		log.Debug().Msgf("Error getting registry credentials for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 	} | ||||
| 	envs := map[string]string{} | ||||
| 	if server.Config.Services.Environ != nil { | ||||
| @@ -318,7 +318,7 @@ func PostApproval(c *gin.Context) { | ||||
| 	buildItems, err := b.Build() | ||||
| 	if err != nil { | ||||
| 		if _, err = shared.UpdateToStatusError(store.FromContext(c), *build, err); err != nil { | ||||
| 			logrus.Errorf("Error setting error status of build for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 			log.Error().Msgf("Error setting error status of build for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
| @@ -326,7 +326,7 @@ func PostApproval(c *gin.Context) { | ||||
|  | ||||
| 	err = store.FromContext(c).ProcCreate(build.Procs) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("error persisting procs %s/%d: %s", repo.FullName, build.Number, err) | ||||
| 		log.Error().Msgf("error persisting procs %s/%d: %s", repo.FullName, build.Number, err) | ||||
| 	} | ||||
|  | ||||
| 	defer func() { | ||||
| @@ -338,7 +338,7 @@ func PostApproval(c *gin.Context) { | ||||
| 				err = remote_.Status(c, user, repo, build, uri, nil) | ||||
| 			} | ||||
| 			if err != nil { | ||||
| 				logrus.Errorf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err) | ||||
| 				log.Error().Msgf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err) | ||||
| 			} | ||||
| 		} | ||||
| 	}() | ||||
| @@ -375,7 +375,7 @@ func PostDecline(c *gin.Context) { | ||||
| 	uri := fmt.Sprintf("%s/%s/%d", server.Config.Server.Host, repo.FullName, build.Number) | ||||
| 	err = remote_.Status(c, user, repo, build, uri, nil) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err) | ||||
| 		log.Error().Msgf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err) | ||||
| 	} | ||||
|  | ||||
| 	c.JSON(200, build) | ||||
| @@ -403,14 +403,14 @@ func PostBuild(c *gin.Context) { | ||||
|  | ||||
| 	user, err := store.GetUser(c, repo.UserID) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to find repo owner %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to find repo owner %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(500, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	build, err := store.GetBuildNumber(c, repo, num) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to get build %d. %s", num, err) | ||||
| 		log.Error().Msgf("failure to get build %d. %s", num, err) | ||||
| 		c.AbortWithError(404, err) | ||||
| 		return | ||||
| 	} | ||||
| @@ -435,14 +435,14 @@ func PostBuild(c *gin.Context) { | ||||
| 	// fetch the pipeline config from database | ||||
| 	configs, err := server.Config.Storage.Config.ConfigsForBuild(build.ID) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to get build config for %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to get build config for %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(404, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	netrc, err := remote_.Netrc(user, repo) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to generate netrc for %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to generate netrc for %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(500, err) | ||||
| 		return | ||||
| 	} | ||||
| @@ -473,7 +473,7 @@ func PostBuild(c *gin.Context) { | ||||
|  | ||||
| 	err = persistBuildConfigs(configs, build.ID) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to persist build config for %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to persist build config for %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(500, err) | ||||
| 		return | ||||
| 	} | ||||
| @@ -495,11 +495,11 @@ func PostBuild(c *gin.Context) { | ||||
| 	last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID) | ||||
| 	secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build) | ||||
| 	if err != nil { | ||||
| 		logrus.Debugf("Error getting secrets for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 		log.Debug().Msgf("Error getting secrets for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 	} | ||||
| 	regs, err := server.Config.Services.Registries.RegistryList(repo) | ||||
| 	if err != nil { | ||||
| 		logrus.Debugf("Error getting registry credentials for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 		log.Debug().Msgf("Error getting registry credentials for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 	} | ||||
| 	if server.Config.Services.Environ != nil { | ||||
| 		globals, _ := server.Config.Services.Environ.EnvironList(repo) | ||||
| @@ -537,7 +537,7 @@ func PostBuild(c *gin.Context) { | ||||
|  | ||||
| 	err = store.FromContext(c).ProcCreate(build.Procs) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("cannot restart %s#%d: %s", repo.FullName, build.Number, err) | ||||
| 		log.Error().Msgf("cannot restart %s#%d: %s", repo.FullName, build.Number, err) | ||||
| 		build.Status = model.StatusError | ||||
| 		build.Started = time.Now().Unix() | ||||
| 		build.Finished = build.Started | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/router/middleware/session" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store" | ||||
| ) | ||||
|   | ||||
| @@ -29,19 +29,18 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/shared/token" | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/pubsub" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/queue" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/shared" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store" | ||||
| 	"github.com/woodpecker-ci/woodpecker/shared/token" | ||||
| ) | ||||
|  | ||||
| var skipRe = regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`) | ||||
| @@ -81,7 +80,7 @@ func PostHook(c *gin.Context) { | ||||
|  | ||||
| 	tmpRepo, build, err := remote_.Hook(c.Request) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to parse hook. %s", err) | ||||
| 		log.Error().Msgf("failure to parse hook. %s", err) | ||||
| 		c.AbortWithError(400, err) | ||||
| 		return | ||||
| 	} | ||||
| @@ -90,7 +89,7 @@ func PostHook(c *gin.Context) { | ||||
| 		return | ||||
| 	} | ||||
| 	if tmpRepo == nil { | ||||
| 		logrus.Errorf("failure to ascertain repo from hook.") | ||||
| 		log.Error().Msgf("failure to ascertain repo from hook.") | ||||
| 		c.Writer.WriteHeader(400) | ||||
| 		return | ||||
| 	} | ||||
| @@ -99,19 +98,19 @@ func PostHook(c *gin.Context) { | ||||
| 	// wrapped in square brackets appear in the commit message | ||||
| 	skipMatch := skipRe.FindString(build.Message) | ||||
| 	if len(skipMatch) > 0 { | ||||
| 		logrus.Infof("ignoring hook. %s found in %s", skipMatch, build.Commit) | ||||
| 		log.Info().Msgf("ignoring hook. %s found in %s", skipMatch, build.Commit) | ||||
| 		c.Writer.WriteHeader(204) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	repo, err := store.GetRepoOwnerName(c, tmpRepo.Owner, tmpRepo.Name) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to find repo %s/%s from hook. %s", tmpRepo.Owner, tmpRepo.Name, err) | ||||
| 		log.Error().Msgf("failure to find repo %s/%s from hook. %s", tmpRepo.Owner, tmpRepo.Name, err) | ||||
| 		c.AbortWithError(404, err) | ||||
| 		return | ||||
| 	} | ||||
| 	if !repo.IsActive { | ||||
| 		logrus.Errorf("ignoring hook. %s/%s is inactive.", tmpRepo.Owner, tmpRepo.Name) | ||||
| 		log.Error().Msgf("ignoring hook. %s/%s is inactive.", tmpRepo.Owner, tmpRepo.Name) | ||||
| 		c.AbortWithError(204, err) | ||||
| 		return | ||||
| 	} | ||||
| @@ -121,24 +120,24 @@ func PostHook(c *gin.Context) { | ||||
| 		return repo.Hash, nil | ||||
| 	}) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to parse token from hook for %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to parse token from hook for %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(400, err) | ||||
| 		return | ||||
| 	} | ||||
| 	if parsed.Text != repo.FullName { | ||||
| 		logrus.Errorf("failure to verify token from hook. Expected %s, got %s", repo.FullName, parsed.Text) | ||||
| 		log.Error().Msgf("failure to verify token from hook. Expected %s, got %s", repo.FullName, parsed.Text) | ||||
| 		c.AbortWithStatus(403) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if repo.UserID == 0 { | ||||
| 		logrus.Warnf("ignoring hook. repo %s has no owner.", repo.FullName) | ||||
| 		log.Warn().Msgf("ignoring hook. repo %s has no owner.", repo.FullName) | ||||
| 		c.Writer.WriteHeader(204) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if build.Event == model.EventPull && !repo.AllowPull { | ||||
| 		logrus.Infof("ignoring hook. repo %s is disabled for pull requests.", repo.FullName) | ||||
| 		log.Info().Msgf("ignoring hook. repo %s is disabled for pull requests.", repo.FullName) | ||||
| 		c.Writer.Write([]byte("pulls are disabled on woodpecker for this repo")) | ||||
| 		c.Writer.WriteHeader(204) | ||||
| 		return | ||||
| @@ -146,7 +145,7 @@ func PostHook(c *gin.Context) { | ||||
|  | ||||
| 	user, err := store.GetUser(c, repo.UserID) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to find repo owner %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to find repo owner %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(500, err) | ||||
| 		return | ||||
| 	} | ||||
| @@ -157,10 +156,10 @@ func PostHook(c *gin.Context) { | ||||
| 	if refresher, ok := remote_.(remote.Refresher); ok { | ||||
| 		ok, err := refresher.Refresh(c, user) | ||||
| 		if err != nil { | ||||
| 			logrus.Errorf("failed to refresh oauth2 token: %s", err) | ||||
| 			log.Error().Msgf("failed to refresh oauth2 token: %s", err) | ||||
| 		} else if ok { | ||||
| 			if err := store.UpdateUser(c, user); err != nil { | ||||
| 				logrus.Errorf("error while updating user: %s", err) | ||||
| 				log.Error().Msgf("error while updating user: %s", err) | ||||
| 				// move forward | ||||
| 			} | ||||
| 		} | ||||
| @@ -170,14 +169,14 @@ func PostHook(c *gin.Context) { | ||||
| 	configFetcher := shared.NewConfigFetcher(remote_, user, repo, build) | ||||
| 	remoteYamlConfigs, err := configFetcher.Fetch(c) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("error: %s: cannot find %s in %s: %s", repo.FullName, repo.Config, build.Ref, err) | ||||
| 		log.Error().Msgf("error: %s: cannot find %s in %s: %s", repo.FullName, repo.Config, build.Ref, err) | ||||
| 		c.AbortWithError(404, err) | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	filtered, err := branchFiltered(build, remoteYamlConfigs) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to parse yaml from hook for %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to parse yaml from hook for %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(400, err) | ||||
| 	} | ||||
| 	if filtered { | ||||
| @@ -201,7 +200,7 @@ func PostHook(c *gin.Context) { | ||||
|  | ||||
| 	err = store.CreateBuild(c, build, build.Procs...) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("failure to save commit for %s. %s", repo.FullName, err) | ||||
| 		log.Error().Msgf("failure to save commit for %s. %s", repo.FullName, err) | ||||
| 		c.AbortWithError(500, err) | ||||
| 		return | ||||
| 	} | ||||
| @@ -210,7 +209,7 @@ func PostHook(c *gin.Context) { | ||||
| 	for _, remoteYamlConfig := range remoteYamlConfigs { | ||||
| 		_, err := findOrPersistPipelineConfig(repo, build, remoteYamlConfig) | ||||
| 		if err != nil { | ||||
| 			logrus.Errorf("failure to find or persist build config for %s. %s", repo.FullName, err) | ||||
| 			log.Error().Msgf("failure to find or persist build config for %s. %s", repo.FullName, err) | ||||
| 			c.AbortWithError(500, err) | ||||
| 			return | ||||
| 		} | ||||
| @@ -238,12 +237,12 @@ func PostHook(c *gin.Context) { | ||||
|  | ||||
| 	secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build) | ||||
| 	if err != nil { | ||||
| 		logrus.Debugf("Error getting secrets for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 		log.Debug().Msgf("Error getting secrets for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 	} | ||||
|  | ||||
| 	regs, err := server.Config.Services.Registries.RegistryList(repo) | ||||
| 	if err != nil { | ||||
| 		logrus.Debugf("Error getting registry credentials for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 		log.Debug().Msgf("Error getting registry credentials for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 	} | ||||
|  | ||||
| 	// get the previous build so that we can send status change notifications | ||||
| @@ -263,7 +262,7 @@ func PostHook(c *gin.Context) { | ||||
| 	buildItems, err := b.Build() | ||||
| 	if err != nil { | ||||
| 		if _, err = shared.UpdateToStatusError(store.FromContext(c), *build, err); err != nil { | ||||
| 			logrus.Errorf("Error setting error status of build for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 			log.Error().Msgf("Error setting error status of build for %s#%d. %s", repo.FullName, build.Number, err) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
| @@ -271,7 +270,7 @@ func PostHook(c *gin.Context) { | ||||
|  | ||||
| 	err = store.FromContext(c).ProcCreate(build.Procs) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("error persisting procs %s/%d: %s", repo.FullName, build.Number, err) | ||||
| 		log.Error().Msgf("error persisting procs %s/%d: %s", repo.FullName, build.Number, err) | ||||
| 	} | ||||
|  | ||||
| 	defer func() { | ||||
| @@ -283,7 +282,7 @@ func PostHook(c *gin.Context) { | ||||
| 				err = remote_.Status(c, user, repo, build, uri, nil) | ||||
| 			} | ||||
| 			if err != nil { | ||||
| 				logrus.Errorf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err) | ||||
| 				log.Error().Msgf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err) | ||||
| 			} | ||||
| 		} | ||||
| 	}() | ||||
| @@ -294,14 +293,14 @@ func PostHook(c *gin.Context) { | ||||
|  | ||||
| // TODO: parse yaml once and not for each filter function | ||||
| func branchFiltered(build *model.Build, remoteYamlConfigs []*remote.FileMeta) (bool, error) { | ||||
| 	logrus.Tracef("hook.branchFiltered(): build branch: '%s' build event: '%s' config count: %d", build.Branch, build.Event, len(remoteYamlConfigs)) | ||||
| 	log.Trace().Msgf("hook.branchFiltered(): build branch: '%s' build event: '%s' config count: %d", build.Branch, build.Event, len(remoteYamlConfigs)) | ||||
| 	for _, remoteYamlConfig := range remoteYamlConfigs { | ||||
| 		parsedPipelineConfig, err := yaml.ParseString(string(remoteYamlConfig.Data)) | ||||
| 		if err != nil { | ||||
| 			logrus.Tracef("parse config '%s': %s", remoteYamlConfig.Name, err) | ||||
| 			log.Trace().Msgf("parse config '%s': %s", remoteYamlConfig.Name, err) | ||||
| 			return false, err | ||||
| 		} | ||||
| 		logrus.Tracef("config '%s': %#v", remoteYamlConfig.Name, parsedPipelineConfig) | ||||
| 		log.Trace().Msgf("config '%s': %#v", remoteYamlConfig.Name, parsedPipelineConfig) | ||||
|  | ||||
| 		if !parsedPipelineConfig.Branches.Match(build.Branch) && build.Event != model.EventTag && build.Event != model.EventDeploy { | ||||
| 		} else { | ||||
|   | ||||
| @@ -19,16 +19,16 @@ import ( | ||||
| 	"net/http" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	"github.com/gorilla/securecookie" | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store" | ||||
| 	"github.com/woodpecker-ci/woodpecker/shared/httputil" | ||||
| 	"github.com/woodpecker-ci/woodpecker/shared/token" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| ) | ||||
|  | ||||
| func HandleLogin(c *gin.Context) { | ||||
| @@ -56,7 +56,7 @@ func HandleAuth(c *gin.Context) { | ||||
|  | ||||
| 	tmpuser, err := remote.Login(c, c.Writer, c.Request) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("cannot authenticate user. %s", err) | ||||
| 		log.Error().Msgf("cannot authenticate user. %s", err) | ||||
| 		c.Redirect(303, "/login?error=oauth_error") | ||||
| 		return | ||||
| 	} | ||||
| @@ -73,7 +73,7 @@ func HandleAuth(c *gin.Context) { | ||||
|  | ||||
| 		// if self-registration is disabled we should return a not authorized error | ||||
| 		if !config.Open && !config.IsAdmin(tmpuser) { | ||||
| 			logrus.Errorf("cannot register %s. registration closed", tmpuser.Login) | ||||
| 			log.Error().Msgf("cannot register %s. registration closed", tmpuser.Login) | ||||
| 			c.Redirect(303, "/login?error=access_denied") | ||||
| 			return | ||||
| 		} | ||||
| @@ -83,7 +83,7 @@ func HandleAuth(c *gin.Context) { | ||||
| 		if len(config.Orgs) != 0 { | ||||
| 			teams, terr := remote.Teams(c, tmpuser) | ||||
| 			if terr != nil || config.IsMember(teams) == false { | ||||
| 				logrus.Errorf("cannot verify team membership for %s.", u.Login) | ||||
| 				log.Error().Msgf("cannot verify team membership for %s.", u.Login) | ||||
| 				c.Redirect(303, "/login?error=access_denied") | ||||
| 				return | ||||
| 			} | ||||
| @@ -103,7 +103,7 @@ func HandleAuth(c *gin.Context) { | ||||
|  | ||||
| 		// insert the user into the database | ||||
| 		if err := store.CreateUser(c, u); err != nil { | ||||
| 			logrus.Errorf("cannot insert %s. %s", u.Login, err) | ||||
| 			log.Error().Msgf("cannot insert %s. %s", u.Login, err) | ||||
| 			c.Redirect(303, "/login?error=internal_error") | ||||
| 			return | ||||
| 		} | ||||
| @@ -120,14 +120,14 @@ func HandleAuth(c *gin.Context) { | ||||
| 	if len(config.Orgs) != 0 { | ||||
| 		teams, terr := remote.Teams(c, u) | ||||
| 		if terr != nil || config.IsMember(teams) == false { | ||||
| 			logrus.Errorf("cannot verify team membership for %s.", u.Login) | ||||
| 			log.Error().Msgf("cannot verify team membership for %s.", u.Login) | ||||
| 			c.Redirect(303, "/login?error=access_denied") | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if err := store.UpdateUser(c, u); err != nil { | ||||
| 		logrus.Errorf("cannot update %s. %s", u.Login, err) | ||||
| 		log.Error().Msgf("cannot update %s. %s", u.Login, err) | ||||
| 		c.Redirect(303, "/login?error=internal_error") | ||||
| 		return | ||||
| 	} | ||||
| @@ -135,7 +135,7 @@ func HandleAuth(c *gin.Context) { | ||||
| 	exp := time.Now().Add(server.Config.Server.SessionExpires).Unix() | ||||
| 	tokenString, err := token.New(token.SessToken, u.Login).SignExpires(u.Hash, exp) | ||||
| 	if err != nil { | ||||
| 		logrus.Errorf("cannot create token for %s. %s", u.Login, err) | ||||
| 		log.Error().Msgf("cannot create token for %s. %s", u.Login, err) | ||||
| 		c.Redirect(303, "/login?error=internal_error") | ||||
| 		return | ||||
| 	} | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import ( | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	"github.com/prometheus/client_golang/prometheus/promhttp" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -17,11 +17,11 @@ package api | ||||
| import ( | ||||
| 	"net/http" | ||||
|  | ||||
| 	"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" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| ) | ||||
|  | ||||
| // GetRegistry gets the name registry from the database and writes | ||||
|   | ||||
| @@ -17,11 +17,11 @@ package api | ||||
| import ( | ||||
| 	"net/http" | ||||
|  | ||||
| 	"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" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| ) | ||||
|  | ||||
| // GetSecret gets the named secret from the database and writes | ||||
|   | ||||
| @@ -22,15 +22,15 @@ import ( | ||||
| 	"strconv" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/logging" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/pubsub" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/router/middleware/session" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| ) | ||||
|  | ||||
| // | ||||
| @@ -55,7 +55,7 @@ func EventStreamSSE(c *gin.Context) { | ||||
| 	io.WriteString(rw, ": ping\n\n") | ||||
| 	flusher.Flush() | ||||
|  | ||||
| 	logrus.Debugf("user feed: connection opened") | ||||
| 	log.Debug().Msg("user feed: connection opened") | ||||
|  | ||||
| 	user := session.User(c) | ||||
| 	repo := map[string]bool{} | ||||
| @@ -74,7 +74,7 @@ func EventStreamSSE(c *gin.Context) { | ||||
| 	defer func() { | ||||
| 		cancel() | ||||
| 		close(eventc) | ||||
| 		logrus.Debugf("user feed: connection closed") | ||||
| 		log.Debug().Msg("user feed: connection closed") | ||||
| 	}() | ||||
|  | ||||
| 	go func() { | ||||
| @@ -159,18 +159,18 @@ func LogStreamSSE(c *gin.Context) { | ||||
|  | ||||
| 	build, err := store.GetBuildNumber(c, repo, buildn) | ||||
| 	if err != nil { | ||||
| 		logrus.Debugln("stream cannot get build number.", err) | ||||
| 		log.Debug().Msgf("stream cannot get build number: %v", err) | ||||
| 		io.WriteString(rw, "event: error\ndata: build not found\n\n") | ||||
| 		return | ||||
| 	} | ||||
| 	proc, err := store.FromContext(c).ProcFind(build, jobn) | ||||
| 	if err != nil { | ||||
| 		logrus.Debugln("stream cannot get proc number.", err) | ||||
| 		log.Debug().Msgf("stream cannot get proc number: %v", err) | ||||
| 		io.WriteString(rw, "event: error\ndata: process not found\n\n") | ||||
| 		return | ||||
| 	} | ||||
| 	if proc.State != model.StatusRunning { | ||||
| 		logrus.Debugln("stream not found.") | ||||
| 		log.Debug().Msg("stream not found.") | ||||
| 		io.WriteString(rw, "event: error\ndata: stream not found\n\n") | ||||
| 		return | ||||
| 	} | ||||
| @@ -180,12 +180,12 @@ func LogStreamSSE(c *gin.Context) { | ||||
| 		context.Background(), | ||||
| 	) | ||||
|  | ||||
| 	logrus.Debugf("log stream: connection opened") | ||||
| 	log.Debug().Msgf("log stream: connection opened") | ||||
|  | ||||
| 	defer func() { | ||||
| 		cancel() | ||||
| 		close(logc) | ||||
| 		logrus.Debugf("log stream: connection closed") | ||||
| 		log.Debug().Msgf("log stream: connection closed") | ||||
| 	}() | ||||
|  | ||||
| 	go func() { | ||||
| @@ -214,7 +214,7 @@ func LogStreamSSE(c *gin.Context) { | ||||
| 		c.Request.Header.Get("Last-Event-ID"), | ||||
| 	) | ||||
| 	if last != 0 { | ||||
| 		logrus.Debugf("log stream: reconnect: last-event-id: %d", last) | ||||
| 		log.Debug().Msgf("log stream: reconnect: last-event-id: %d", last) | ||||
| 	} | ||||
|  | ||||
| 	// retry: 10000\n | ||||
|   | ||||
| @@ -22,7 +22,7 @@ import ( | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| 	"github.com/gorilla/securecookie" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| @@ -41,7 +41,7 @@ func GetFeed(c *gin.Context) { | ||||
| 	latest, _ := strconv.ParseBool(c.Query("latest")) | ||||
|  | ||||
| 	if time.Unix(user.Synced, 0).Add(time.Hour * 72).Before(time.Now()) { | ||||
| 		logrus.Debugf("sync begin: %s", user.Login) | ||||
| 		log.Debug().Msgf("sync begin: %s", user.Login) | ||||
|  | ||||
| 		user.Synced = time.Now().Unix() | ||||
| 		store.FromContext(c).UpdateUser(user) | ||||
| @@ -55,9 +55,9 @@ func GetFeed(c *gin.Context) { | ||||
| 			Match:  shared.NamespaceFilter(config.OwnersWhitelist), | ||||
| 		} | ||||
| 		if err := sync.Sync(c, user); err != nil { | ||||
| 			logrus.Debugf("sync error: %s: %s", user.Login, err) | ||||
| 			log.Debug().Msgf("sync error: %s: %s", user.Login, err) | ||||
| 		} else { | ||||
| 			logrus.Debugf("sync complete: %s", user.Login) | ||||
| 			log.Debug().Msgf("sync complete: %s", user.Login) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -87,7 +87,7 @@ func GetRepos(c *gin.Context) { | ||||
| 	) | ||||
|  | ||||
| 	if flush || time.Unix(user.Synced, 0).Add(time.Hour*72).Before(time.Now()) { | ||||
| 		logrus.Debugf("sync begin: %s", user.Login) | ||||
| 		log.Debug().Msgf("sync begin: %s", user.Login) | ||||
| 		user.Synced = time.Now().Unix() | ||||
| 		store.FromContext(c).UpdateUser(user) | ||||
|  | ||||
| @@ -101,9 +101,9 @@ func GetRepos(c *gin.Context) { | ||||
| 		} | ||||
|  | ||||
| 		if err := sync.Sync(c, user); err != nil { | ||||
| 			logrus.Debugf("sync error: %s: %s", user.Login, err) | ||||
| 			log.Debug().Msgf("sync error: %s: %s", user.Login, err) | ||||
| 		} else { | ||||
| 			logrus.Debugf("sync complete: %s", user.Login) | ||||
| 			log.Debug().Msgf("sync complete: %s", user.Login) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -15,10 +15,10 @@ | ||||
| package api | ||||
|  | ||||
| import ( | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store" | ||||
| 	"github.com/woodpecker-ci/woodpecker/version" | ||||
|  | ||||
| 	"github.com/gin-gonic/gin" | ||||
| ) | ||||
|  | ||||
| // Health endpoint returns a 500 if the server state is unhealthy. | ||||
|   | ||||
| @@ -22,29 +22,26 @@ import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"log" | ||||
| 	"strconv" | ||||
|  | ||||
| 	oldcontext "golang.org/x/net/context" | ||||
|  | ||||
| 	grpcMetadata "google.golang.org/grpc/metadata" | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/prometheus/client_golang/prometheus" | ||||
| 	"github.com/prometheus/client_golang/prometheus/promauto" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	oldcontext "golang.org/x/net/context" | ||||
| 	grpcMetadata "google.golang.org/grpc/metadata" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/expr" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc" | ||||
| 	"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/logging" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/pubsub" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/queue" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/shared" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/shared" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/store" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/expr" | ||||
| ) | ||||
|  | ||||
| type RPC struct { | ||||
| @@ -64,7 +61,7 @@ func (s *RPC) Next(c context.Context, filter rpc.Filter) (*rpc.Pipeline, error) | ||||
| 	if ok { | ||||
| 		hostname, ok := metadata["hostname"] | ||||
| 		if ok && len(hostname) != 0 { | ||||
| 			logrus.Debugf("agent connected: %s: polling", hostname[0]) | ||||
| 			log.Debug().Msgf("agent connected: %s: polling", hostname[0]) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -109,19 +106,19 @@ func (s *RPC) Update(c context.Context, id string, state rpc.State) error { | ||||
|  | ||||
| 	pproc, err := s.store.ProcLoad(procID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: rpc.update: cannot find pproc with id %d: %s", procID, err) | ||||
| 		log.Error().Msgf("error: rpc.update: cannot find pproc with id %d: %s", procID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	build, err := s.store.GetBuild(pproc.BuildID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find build with id %d: %s", pproc.BuildID, err) | ||||
| 		log.Error().Msgf("error: cannot find build with id %d: %s", pproc.BuildID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	proc, err := s.store.ProcChild(build, pproc.PID, state.Proc) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find proc with name %s: %s", state.Proc, err) | ||||
| 		log.Error().Msgf("error: cannot find proc with name %s: %s", state.Proc, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| @@ -135,12 +132,12 @@ func (s *RPC) Update(c context.Context, id string, state rpc.State) error { | ||||
|  | ||||
| 	repo, err := s.store.GetRepo(build.RepoID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find repo with id %d: %s", build.RepoID, err) | ||||
| 		log.Error().Msgf("error: cannot find repo with id %d: %s", build.RepoID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if proc, err = shared.UpdateProcStatus(s.store, *proc, state, build.Started); err != nil { | ||||
| 		log.Printf("error: rpc.update: cannot update proc: %s", err) | ||||
| 		log.Error().Msgf("error: rpc.update: cannot update proc: %s", err) | ||||
| 	} | ||||
|  | ||||
| 	build.Procs, _ = s.store.ProcList(build) | ||||
| @@ -169,19 +166,19 @@ func (s *RPC) Upload(c context.Context, id string, file *rpc.File) error { | ||||
|  | ||||
| 	pproc, err := s.store.ProcLoad(procID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find parent proc with id %d: %s", procID, err) | ||||
| 		log.Error().Msgf("error: cannot find parent proc with id %d: %s", procID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	build, err := s.store.GetBuild(pproc.BuildID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find build with id %d: %s", pproc.BuildID, err) | ||||
| 		log.Error().Msgf("error: cannot find build with id %d: %s", pproc.BuildID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	proc, err := s.store.ProcChild(build, pproc.PID, file.Proc) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find child proc with name %s: %s", file.Proc, err) | ||||
| 		log.Error().Msgf("error: cannot find child proc with name %s: %s", file.Proc, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| @@ -242,7 +239,7 @@ func (s *RPC) Init(c context.Context, id string, state rpc.State) error { | ||||
|  | ||||
| 	proc, err := s.store.ProcLoad(procID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find proc with id %d: %s", procID, err) | ||||
| 		log.Error().Msgf("error: cannot find proc with id %d: %s", procID, err) | ||||
| 		return err | ||||
| 	} | ||||
| 	metadata, ok := grpcMetadata.FromIncomingContext(c) | ||||
| @@ -255,19 +252,19 @@ func (s *RPC) Init(c context.Context, id string, state rpc.State) error { | ||||
|  | ||||
| 	build, err := s.store.GetBuild(proc.BuildID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find build with id %d: %s", proc.BuildID, err) | ||||
| 		log.Error().Msgf("error: cannot find build with id %d: %s", proc.BuildID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	repo, err := s.store.GetRepo(build.RepoID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find repo with id %d: %s", build.RepoID, err) | ||||
| 		log.Error().Msgf("error: cannot find repo with id %d: %s", build.RepoID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if build.Status == model.StatusPending { | ||||
| 		if build, err = shared.UpdateToStatusRunning(s.store, *build, state.Started); err != nil { | ||||
| 			log.Printf("error: init: cannot update build_id %d state: %s", build.ID, err) | ||||
| 			log.Error().Msgf("error: init: cannot update build_id %d state: %s", build.ID, err) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -299,24 +296,24 @@ func (s *RPC) Done(c context.Context, id string, state rpc.State) error { | ||||
|  | ||||
| 	proc, err := s.store.ProcLoad(procID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find proc with id %d: %s", procID, err) | ||||
| 		log.Error().Msgf("error: cannot find proc with id %d: %s", procID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	build, err := s.store.GetBuild(proc.BuildID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find build with id %d: %s", proc.BuildID, err) | ||||
| 		log.Error().Msgf("error: cannot find build with id %d: %s", proc.BuildID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	repo, err := s.store.GetRepo(build.RepoID) | ||||
| 	if err != nil { | ||||
| 		log.Printf("error: cannot find repo with id %d: %s", build.RepoID, err) | ||||
| 		log.Error().Msgf("error: cannot find repo with id %d: %s", build.RepoID, err) | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if proc, err = shared.UpdateProcStatusToDone(s.store, *proc, state); err != nil { | ||||
| 		log.Printf("error: done: cannot update proc_id %d state: %s", proc.ID, err) | ||||
| 		log.Error().Msgf("error: done: cannot update proc_id %d state: %s", proc.ID, err) | ||||
| 	} | ||||
|  | ||||
| 	var queueErr error | ||||
| @@ -326,7 +323,7 @@ func (s *RPC) Done(c context.Context, id string, state rpc.State) error { | ||||
| 		queueErr = s.queue.Done(c, id, proc.State) | ||||
| 	} | ||||
| 	if queueErr != nil { | ||||
| 		log.Printf("error: done: cannot ack proc_id %d: %s", procID, err) | ||||
| 		log.Error().Msgf("error: done: cannot ack proc_id %d: %s", procID, err) | ||||
| 	} | ||||
|  | ||||
| 	procs, _ := s.store.ProcList(build) | ||||
| @@ -334,7 +331,7 @@ func (s *RPC) Done(c context.Context, id string, state rpc.State) error { | ||||
|  | ||||
| 	if !isThereRunningStage(procs) { | ||||
| 		if build, err = shared.UpdateStatusToDone(s.store, *build, buildStatus(procs), proc.Stopped); err != nil { | ||||
| 			log.Printf("error: done: cannot update build_id %d final state: %s", build.ID, err) | ||||
| 			log.Error().Msgf("error: done: cannot update build_id %d final state: %s", build.ID, err) | ||||
| 		} | ||||
|  | ||||
| 		if !isMultiPipeline(procs) { | ||||
| @@ -347,7 +344,7 @@ func (s *RPC) Done(c context.Context, id string, state rpc.State) error { | ||||
| 	} | ||||
|  | ||||
| 	if err := s.logger.Close(c, id); err != nil { | ||||
| 		log.Printf("error: done: cannot close build_id %d logger: %s", proc.ID, err) | ||||
| 		log.Error().Msgf("error: done: cannot close build_id %d logger: %s", proc.ID, err) | ||||
| 	} | ||||
|  | ||||
| 	s.notify(c, repo, build, procs) | ||||
| @@ -385,7 +382,7 @@ func (s *RPC) completeChildrenIfParentCompleted(procs []*model.Proc, completedPr | ||||
| 	for _, p := range procs { | ||||
| 		if p.Running() && p.PPID == completedProc.PID { | ||||
| 			if _, err := shared.UpdateProcToStatusSkipped(s.store, *p, completedProc.Stopped); err != nil { | ||||
| 				log.Printf("error: done: cannot update proc_id %d child state: %s", p.ID, err) | ||||
| 				log.Error().Msgf("error: done: cannot update proc_id %d child state: %s", p.ID, err) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| @@ -428,7 +425,7 @@ func (s *RPC) updateRemoteStatus(ctx context.Context, repo *model.Repo, build *m | ||||
| 		uri := fmt.Sprintf("%s/%s/%d", server.Config.Server.Host, repo.FullName, build.Number) | ||||
| 		err = s.remote.Status(ctx, user, repo, build, uri, proc) | ||||
| 		if err != nil { | ||||
| 			logrus.Errorf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err) | ||||
| 			log.Error().Msgf("error setting commit status for %s/%d: %v", repo.FullName, build.Number, err) | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -17,7 +17,8 @@ package model | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/queue" | ||||
| ) | ||||
|  | ||||
| @@ -101,11 +102,11 @@ func (q *persistentQueue) PushAtOnce(c context.Context, tasks []*queue.Task) err | ||||
| func (q *persistentQueue) Poll(c context.Context, f queue.Filter) (*queue.Task, error) { | ||||
| 	task, err := q.Queue.Poll(c, f) | ||||
| 	if task != nil { | ||||
| 		logrus.Debugf("pull queue item: %s: remove from backup", task.ID) | ||||
| 		log.Debug().Msgf("pull queue item: %s: remove from backup", task.ID) | ||||
| 		if derr := q.store.TaskDelete(task.ID); derr != nil { | ||||
| 			logrus.Errorf("pull queue item: %s: failed to remove from backup: %s", task.ID, derr) | ||||
| 			log.Error().Msgf("pull queue item: %s: failed to remove from backup: %s", task.ID, derr) | ||||
| 		} else { | ||||
| 			logrus.Debugf("pull queue item: %s: successfully removed from backup", task.ID) | ||||
| 			log.Debug().Msgf("pull queue item: %s: successfully removed from backup", task.ID) | ||||
| 		} | ||||
| 	} | ||||
| 	return task, err | ||||
|   | ||||
| @@ -1,8 +1,9 @@ | ||||
| package environments | ||||
|  | ||||
| import ( | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
| type builtin struct { | ||||
|   | ||||
| @@ -4,11 +4,13 @@ import ( | ||||
| 	"encoding/base64" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"github.com/docker/cli/cli/config/configfile" | ||||
| 	"github.com/docker/cli/cli/config/types" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"os" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/docker/cli/cli/config/configfile" | ||||
| 	"github.com/docker/cli/cli/config/types" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
| type filesystem struct { | ||||
|   | ||||
| @@ -3,12 +3,11 @@ package queue | ||||
| import ( | ||||
| 	"container/list" | ||||
| 	"context" | ||||
| 	"log" | ||||
| 	"runtime" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/rs/zerolog/log" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -237,7 +236,7 @@ func (q *fifo) process() { | ||||
| 			const size = 64 << 10 | ||||
| 			buf := make([]byte, size) | ||||
| 			buf = buf[:runtime.Stack(buf, false)] | ||||
| 			log.Printf("queue: unexpected panic: %v\n%s", err, buf) | ||||
| 			log.Error().Msgf("queue: unexpected panic: %v\n%s", err, buf) | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| @@ -273,7 +272,7 @@ func (q *fifo) filterWaiting() { | ||||
| 		nextPending = e.Next() | ||||
| 		task := e.Value.(*Task) | ||||
| 		if q.depsInQueue(task) { | ||||
| 			logrus.Debugf("queue: waiting due to unmet dependencies %v", task.ID) | ||||
| 			log.Debug().Msgf("queue: waiting due to unmet dependencies %v", task.ID) | ||||
| 			q.waitingOnDeps.PushBack(task) | ||||
| 			filtered = append(filtered, e) | ||||
| 		} | ||||
| @@ -290,11 +289,11 @@ func (q *fifo) assignToWorker() (*list.Element, *worker) { | ||||
| 	for e := q.pending.Front(); e != nil; e = next { | ||||
| 		next = e.Next() | ||||
| 		task := e.Value.(*Task) | ||||
| 		logrus.Debugf("queue: trying to assign task: %v with deps %v", task.ID, task.Dependencies) | ||||
| 		log.Debug().Msgf("queue: trying to assign task: %v with deps %v", task.ID, task.Dependencies) | ||||
|  | ||||
| 		for w := range q.workers { | ||||
| 			if w.filter(task) { | ||||
| 				logrus.Debugf("queue: assigned task: %v with deps %v", task.ID, task.Dependencies) | ||||
| 				log.Debug().Msgf("queue: assigned task: %v with deps %v", task.ID, task.Dependencies) | ||||
| 				return e, w | ||||
| 			} | ||||
| 		} | ||||
| @@ -318,7 +317,7 @@ func (q *fifo) depsInQueue(task *Task) bool { | ||||
| 	for e := q.pending.Front(); e != nil; e = next { | ||||
| 		next = e.Next() | ||||
| 		possibleDep, ok := e.Value.(*Task) | ||||
| 		logrus.Debugf("queue: pending right now: %v", possibleDep.ID) | ||||
| 		log.Debug().Msgf("queue: pending right now: %v", possibleDep.ID) | ||||
| 		for _, dep := range task.Dependencies { | ||||
| 			if ok && possibleDep.ID == dep { | ||||
| 				return true | ||||
| @@ -326,7 +325,7 @@ func (q *fifo) depsInQueue(task *Task) bool { | ||||
| 		} | ||||
| 	} | ||||
| 	for possibleDepID := range q.running { | ||||
| 		logrus.Debugf("queue: running right now: %v", possibleDepID) | ||||
| 		log.Debug().Msgf("queue: running right now: %v", possibleDepID) | ||||
| 		for _, dep := range task.Dependencies { | ||||
| 			if possibleDepID == dep { | ||||
| 				return true | ||||
| @@ -369,13 +368,13 @@ func (q *fifo) updateDepStatusInQueue(taskID string, status string) { | ||||
| } | ||||
|  | ||||
| func (q *fifo) removeFromPending(taskID string) { | ||||
| 	logrus.Debugf("queue: trying to remove %s", taskID) | ||||
| 	log.Debug().Msgf("queue: trying to remove %s", taskID) | ||||
| 	var next *list.Element | ||||
| 	for e := q.pending.Front(); e != nil; e = next { | ||||
| 		next = e.Next() | ||||
| 		task := e.Value.(*Task) | ||||
| 		if task.ID == taskID { | ||||
| 			logrus.Debugf("queue: %s is removed from pending", taskID) | ||||
| 			log.Debug().Msgf("queue: %s is removed from pending", taskID) | ||||
| 			q.pending.Remove(e) | ||||
| 			return | ||||
| 		} | ||||
|   | ||||
| @@ -246,7 +246,6 @@ func TestFifoErrors2(t *testing.T) { | ||||
| } | ||||
|  | ||||
| func TestFifoErrorsMultiThread(t *testing.T) { | ||||
| 	//logrus.SetLevel(logrus.DebugLevel) | ||||
| 	task1 := &Task{ | ||||
| 		ID: "1", | ||||
| 	} | ||||
|   | ||||
| @@ -20,12 +20,12 @@ import ( | ||||
| 	"net/http" | ||||
| 	"net/url" | ||||
|  | ||||
| 	"golang.org/x/oauth2" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal" | ||||
|  | ||||
| 	"golang.org/x/oauth2" | ||||
| ) | ||||
|  | ||||
| // Bitbucket cloud endpoints. | ||||
|   | ||||
| @@ -21,12 +21,12 @@ import ( | ||||
| 	"net/http/httptest" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/fixtures" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/gin-gonic/gin" | ||||
| ) | ||||
|  | ||||
| func Test_bitbucket(t *testing.T) { | ||||
|   | ||||
| @@ -20,10 +20,10 @@ import ( | ||||
| 	"regexp" | ||||
| 	"strings" | ||||
|  | ||||
| 	"golang.org/x/oauth2" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal" | ||||
|  | ||||
| 	"golang.org/x/oauth2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -18,11 +18,11 @@ import ( | ||||
| 	"testing" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"golang.org/x/oauth2" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal" | ||||
| ) | ||||
|  | ||||
| func Test_helper(t *testing.T) { | ||||
|   | ||||
| @@ -19,9 +19,9 @@ import ( | ||||
| 	"net/http" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/fixtures" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/fixtures" | ||||
| ) | ||||
|  | ||||
| func Test_parser(t *testing.T) { | ||||
|   | ||||
| @@ -30,6 +30,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/mrjones/oauth" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal" | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/mrjones/oauth" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal" | ||||
| ) | ||||
|   | ||||
| @@ -19,6 +19,7 @@ import ( | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/mrjones/oauth" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal" | ||||
| ) | ||||
|   | ||||
| @@ -23,11 +23,11 @@ import ( | ||||
| 	"io/ioutil" | ||||
| 	"net/http" | ||||
| 	"strconv" | ||||
|  | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/mrjones/oauth" | ||||
| 	log "github.com/sirupsen/logrus" | ||||
| 	"github.com/rs/zerolog/log" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
| @@ -57,7 +57,7 @@ func NewClientWithToken(ctx context.Context, url string, consumer *oauth.Consume | ||||
| 	token.Token = AccessToken | ||||
| 	client, err := consumer.MakeHttpClient(&token) | ||||
| 	if err != nil { | ||||
| 		log.Error(err) | ||||
| 		log.Err(err).Msg("") | ||||
| 	} | ||||
|  | ||||
| 	return &Client{ | ||||
| @@ -113,7 +113,7 @@ func (c *Client) FindRepo(owner string, name string) (*Repo, error) { | ||||
| 		defer response.Body.Close() | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		log.Error(err) | ||||
| 		log.Err(err).Msg("") | ||||
| 	} | ||||
| 	contents, err := ioutil.ReadAll(response.Body) | ||||
| 	repo := Repo{} | ||||
| @@ -154,14 +154,14 @@ func (c *Client) FindFileForRepo(owner string, repo string, fileName string, ref | ||||
| 		defer response.Body.Close() | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		log.Error(err) | ||||
| 		log.Err(err).Msg("") | ||||
| 	} | ||||
| 	if response.StatusCode == 404 { | ||||
| 		return nil, nil | ||||
| 	} | ||||
| 	responseBytes, err := ioutil.ReadAll(response.Body) | ||||
| 	if err != nil { | ||||
| 		log.Error(err) | ||||
| 		log.Err(err).Msg("") | ||||
| 	} | ||||
| 	return responseBytes, nil | ||||
| } | ||||
|   | ||||
| @@ -17,9 +17,10 @@ package bitbucketserver | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal" | ||||
| 	"net/http" | ||||
| ) | ||||
|  | ||||
| // parseHook parses a Bitbucket hook from an http.Request request and returns | ||||
|   | ||||
| @@ -21,12 +21,12 @@ import ( | ||||
| 	"net/http" | ||||
| 	"strings" | ||||
|  | ||||
| 	"golang.org/x/oauth2" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/coding/internal" | ||||
|  | ||||
| 	"golang.org/x/oauth2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -21,11 +21,11 @@ import ( | ||||
| 	"net/http/httptest" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/coding/fixtures" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/coding/fixtures" | ||||
| ) | ||||
|  | ||||
| func Test_coding(t *testing.T) { | ||||
|   | ||||
| @@ -20,10 +20,10 @@ import ( | ||||
| 	"strings" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/coding/fixtures" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| ) | ||||
|  | ||||
| func Test_hook(t *testing.T) { | ||||
|   | ||||
| @@ -28,11 +28,11 @@ import ( | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"golang.org/x/oauth2" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
|  | ||||
| 	"golang.org/x/oauth2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -21,6 +21,7 @@ import ( | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures" | ||||
| ) | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import ( | ||||
|  | ||||
| 	"code.gitea.io/sdk/gitea" | ||||
| 	"github.com/franela/goblin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures" | ||||
| ) | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures" | ||||
| ) | ||||
|   | ||||
| @@ -18,9 +18,9 @@ import ( | ||||
| 	"fmt" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
|  | ||||
| 	"github.com/google/go-github/v39/github" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
| const defaultBranch = "master" | ||||
|   | ||||
| @@ -17,10 +17,10 @@ package github | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/google/go-github/v39/github" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
| func Test_helper(t *testing.T) { | ||||
|   | ||||
| @@ -25,12 +25,12 @@ import ( | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/google/go-github/v39/github" | ||||
| 	"golang.org/x/oauth2" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
|  | ||||
| 	"github.com/google/go-github/v39/github" | ||||
| 	"golang.org/x/oauth2" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -19,11 +19,11 @@ import ( | ||||
| 	"net/http/httptest" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/github/fixtures" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/github/fixtures" | ||||
| ) | ||||
|  | ||||
| func Test_github(t *testing.T) { | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/github/fixtures" | ||||
| ) | ||||
|   | ||||
| @@ -21,9 +21,9 @@ import ( | ||||
| 	"net/http" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
|  | ||||
| 	"github.com/xanzy/go-gitlab" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
| func (g *Gitlab) convertGitlabRepo(repo_ *gitlab.Project) (*model.Repo, error) { | ||||
|   | ||||
| @@ -25,12 +25,12 @@ import ( | ||||
| 	"net/url" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/xanzy/go-gitlab" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| 	"github.com/woodpecker-ci/woodpecker/shared/oauth2" | ||||
|  | ||||
| 	"github.com/xanzy/go-gitlab" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -22,11 +22,11 @@ import ( | ||||
| 	"strconv" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gitlab/testdata" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/stretchr/testify/assert" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gitlab/testdata" | ||||
| ) | ||||
|  | ||||
| func load(config string) *Gitlab { | ||||
|   | ||||
| @@ -15,9 +15,9 @@ | ||||
| package gitlab | ||||
|  | ||||
| import ( | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
|  | ||||
| 	"github.com/xanzy/go-gitlab" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
|   | ||||
| @@ -24,6 +24,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/gogits/go-gogs-client" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote" | ||||
| ) | ||||
|   | ||||
| @@ -19,11 +19,11 @@ import ( | ||||
| 	"net/http/httptest" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gogs/fixtures" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/gin-gonic/gin" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gogs/fixtures" | ||||
| ) | ||||
|  | ||||
| func Test_gogs(t *testing.T) { | ||||
|   | ||||
| @@ -23,6 +23,7 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/gogits/go-gogs-client" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| ) | ||||
|  | ||||
|   | ||||
| @@ -18,11 +18,11 @@ import ( | ||||
| 	"bytes" | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gogs/fixtures" | ||||
|  | ||||
| 	"github.com/franela/goblin" | ||||
| 	"github.com/gogits/go-gogs-client" | ||||
|  | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/model" | ||||
| 	"github.com/woodpecker-ci/woodpecker/server/remote/gogs/fixtures" | ||||
| ) | ||||
|  | ||||
| func Test_parse(t *testing.T) { | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user