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:
John Olheiser 2021-10-12 02:25:13 -05:00 committed by GitHub
parent 9c85c8fd68
commit 4276a04f0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
160 changed files with 4982 additions and 397 deletions

View file

@ -23,15 +23,14 @@ import (
"sync" "sync"
"time" "time"
"github.com/rs/zerolog/log"
"github.com/tevino/abool"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"github.com/woodpecker-ci/woodpecker/pipeline" "github.com/woodpecker-ci/woodpecker/pipeline"
"github.com/woodpecker-ci/woodpecker/pipeline/backend" "github.com/woodpecker-ci/woodpecker/pipeline/backend"
"github.com/woodpecker-ci/woodpecker/pipeline/multipart" "github.com/woodpecker-ci/woodpecker/pipeline/multipart"
"github.com/woodpecker-ci/woodpecker/pipeline/rpc" "github.com/woodpecker-ci/woodpecker/pipeline/rpc"
"github.com/rs/zerolog/log"
"github.com/tevino/abool"
) )
// TODO: Implement log streaming. // TODO: Implement log streaming.

View file

@ -5,6 +5,7 @@ import (
"strconv" "strconv"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -5,6 +5,7 @@ import (
"strconv" "strconv"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -6,6 +6,7 @@ import (
"text/template" "text/template"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -5,6 +5,7 @@ import (
"strconv" "strconv"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -5,6 +5,7 @@ import (
"text/template" "text/template"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -5,6 +5,7 @@ import (
"text/template" "text/template"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -6,6 +6,7 @@ import (
"text/template" "text/template"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -6,6 +6,7 @@ import (
"text/template" "text/template"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -6,6 +6,7 @@ import (
"strconv" "strconv"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -5,6 +5,7 @@ import (
"strconv" "strconv"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -6,10 +6,10 @@ import (
"os" "os"
"strconv" "strconv"
"github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" "github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"github.com/urfave/cli"
) )
// Command exports the deploy command. // Command exports the deploy command.

View file

@ -5,13 +5,15 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
"path" "path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strings" "strings"
"github.com/drone/envsubst" "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"
"github.com/woodpecker-ci/woodpecker/pipeline/backend" "github.com/woodpecker-ci/woodpecker/pipeline/backend"
"github.com/woodpecker-ci/woodpecker/pipeline/backend/docker" "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/frontend/yaml/matrix"
"github.com/woodpecker-ci/woodpecker/pipeline/interrupt" "github.com/woodpecker-ci/woodpecker/pipeline/interrupt"
"github.com/woodpecker-ci/woodpecker/pipeline/multipart" "github.com/woodpecker-ci/woodpecker/pipeline/multipart"
"github.com/urfave/cli"
) )
// Command exports the exec command. // Command exports the exec command.
@ -33,7 +33,7 @@ var Command = cli.Command{
ArgsUsage: "[path/to/.woodpecker.yml]", ArgsUsage: "[path/to/.woodpecker.yml]",
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
if err := exec(c); err != nil { if err := exec(c); err != nil {
log.Fatalln(err) log.Fatal().Err(err).Msg("")
} }
}, },
Flags: flags, Flags: flags,

View file

@ -7,6 +7,7 @@ import (
"strings" "strings"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/pipeline/schema" "github.com/woodpecker-ci/woodpecker/pipeline/schema"
) )

View file

@ -5,6 +5,7 @@ import (
"strconv" "strconv"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -4,10 +4,10 @@ import (
"io/ioutil" "io/ioutil"
"strings" "strings"
"github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" "github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"github.com/urfave/cli"
) )
var registryCreateCmd = cli.Command{ var registryCreateCmd = cli.Command{

View file

@ -4,9 +4,9 @@ import (
"html/template" "html/template"
"os" "os"
"github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal"
) )
var registryInfoCmd = cli.Command{ var registryInfoCmd = cli.Command{

View file

@ -1,9 +1,9 @@
package registry package registry
import ( import (
"github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal"
) )
var registryDeleteCmd = cli.Command{ var registryDeleteCmd = cli.Command{

View file

@ -4,10 +4,10 @@ import (
"io/ioutil" "io/ioutil"
"strings" "strings"
"github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" "github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"github.com/urfave/cli"
) )
var registryUpdateCmd = cli.Command{ var registryUpdateCmd = cli.Command{

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -5,6 +5,7 @@ import (
"text/template" "text/template"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -5,6 +5,7 @@ import (
"text/template" "text/template"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -2,6 +2,7 @@ package repo
import ( import (
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -3,9 +3,9 @@ package repo
import ( import (
"fmt" "fmt"
"github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal"
) )
var repoRemoveCmd = cli.Command{ var repoRemoveCmd = cli.Command{

View file

@ -5,6 +5,7 @@ import (
"text/template" "text/template"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
) )

View file

@ -4,10 +4,10 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" "github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"github.com/urfave/cli"
) )
var repoUpdateCmd = cli.Command{ var repoUpdateCmd = cli.Command{

View file

@ -4,10 +4,10 @@ import (
"io/ioutil" "io/ioutil"
"strings" "strings"
"github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" "github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"github.com/urfave/cli"
) )
var secretCreateCmd = cli.Command{ var secretCreateCmd = cli.Command{

View file

@ -4,10 +4,10 @@ import (
"io/ioutil" "io/ioutil"
"strings" "strings"
"github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker" "github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"github.com/urfave/cli"
) )
var secretUpdateCmd = cli.Command{ var secretUpdateCmd = cli.Command{

View file

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
"github.com/woodpecker-ci/woodpecker/cli/internal" "github.com/woodpecker-ci/woodpecker/cli/internal"
"github.com/woodpecker-ci/woodpecker/woodpecker-go/woodpecker"
) )
var userAddCmd = cli.Command{ var userAddCmd = cli.Command{

View file

@ -21,21 +21,19 @@ import (
"os" "os"
"sync" "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" "google.golang.org/grpc"
grpccredentials "google.golang.org/grpc/credentials"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"github.com/woodpecker-ci/woodpecker/agent" "github.com/woodpecker-ci/woodpecker/agent"
"github.com/woodpecker-ci/woodpecker/pipeline/backend/docker" "github.com/woodpecker-ci/woodpecker/pipeline/backend/docker"
"github.com/woodpecker-ci/woodpecker/pipeline/rpc" "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 { func loop(c *cli.Context) error {

View file

@ -20,6 +20,7 @@ import (
"net/http" "net/http"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/agent" "github.com/woodpecker-ci/woodpecker/agent"
"github.com/woodpecker-ci/woodpecker/version" "github.com/woodpecker-ci/woodpecker/version"
) )

View file

@ -18,10 +18,10 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/woodpecker-ci/woodpecker/version"
_ "github.com/joho/godotenv/autoload" _ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/version"
) )
func main() { func main() {

View file

@ -18,6 +18,9 @@ import (
"fmt" "fmt"
"os" "os"
_ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/cli/build" "github.com/woodpecker-ci/woodpecker/cli/build"
"github.com/woodpecker-ci/woodpecker/cli/deploy" "github.com/woodpecker-ci/woodpecker/cli/deploy"
"github.com/woodpecker-ci/woodpecker/cli/exec" "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/secret"
"github.com/woodpecker-ci/woodpecker/cli/user" "github.com/woodpecker-ci/woodpecker/cli/user"
"github.com/woodpecker-ci/woodpecker/version" "github.com/woodpecker-ci/woodpecker/version"
_ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli"
) )
func main() { func main() {

View file

@ -26,6 +26,16 @@ var flags = []cli.Flag{
Name: "debug", Name: "debug",
Usage: "enable server debug mode", 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{ cli.StringFlag{
EnvVar: "WOODPECKER_HOST", EnvVar: "WOODPECKER_HOST",
Name: "server-host", Name: "server-host",

View file

@ -18,11 +18,11 @@ import (
"fmt" "fmt"
"os" "os"
"github.com/woodpecker-ci/woodpecker/version"
"github.com/joho/godotenv" "github.com/joho/godotenv"
_ "github.com/joho/godotenv/autoload" _ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli" "github.com/urfave/cli"
"github.com/woodpecker-ci/woodpecker/version"
) )
func main() { func main() {

View file

@ -27,13 +27,16 @@ import (
"strings" "strings"
"time" "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"
"google.golang.org/grpc/keepalive" "google.golang.org/grpc/keepalive"
"google.golang.org/grpc/metadata" "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/pipeline/rpc/proto"
"github.com/woodpecker-ci/woodpecker/server" "github.com/woodpecker-ci/woodpecker/server"
woodpeckerGrpcServer "github.com/woodpecker-ci/woodpecker/server/grpc" 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/remote"
"github.com/woodpecker-ci/woodpecker/server/router" "github.com/woodpecker-ci/woodpecker/server/router"
"github.com/woodpecker-ci/woodpecker/server/router/middleware" "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/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 { func loop(c *cli.Context) error {
@ -56,37 +55,45 @@ func loop(c *cli.Context) error {
// debug level if requested by user // debug level if requested by user
// TODO: format output & options to switch to json aka. option to add channels to send logs to // TODO: format output & options to switch to json aka. option to add channels to send logs to
if c.Bool("debug") { if c.Bool("debug") {
logrus.SetReportCaller(true) zerolog.SetGlobalLevel(zerolog.DebugLevel)
logrus.SetLevel(logrus.DebugLevel)
} else { } 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") == "" { 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"), "://") { if !strings.Contains(c.String("server-host"), "://") {
logrus.Fatalln( log.Fatal().Msg(
"WOODPECKER_HOST must be <scheme>://<hostname> format", "WOODPECKER_HOST must be <scheme>://<hostname> format",
) )
} }
if strings.Contains(c.String("server-host"), "://localhost") { if strings.Contains(c.String("server-host"), "://localhost") {
logrus.Warningln( log.Warn().Msg(
"WOODPECKER_HOST should probably be publicly accessible (not localhost)", "WOODPECKER_HOST should probably be publicly accessible (not localhost)",
) )
} }
if strings.HasSuffix(c.String("server-host"), "/") { if strings.HasSuffix(c.String("server-host"), "/") {
logrus.Fatalln( log.Fatal().Msg(
"WOODPECKER_HOST must not have trailing slash", "WOODPECKER_HOST must not have trailing slash",
) )
} }
remote_, err := SetupRemote(c) remote_, err := SetupRemote(c)
if err != nil { if err != nil {
logrus.Fatal(err) log.Fatal().Err(err).Msg("")
} }
store_ := setupStore(c) store_ := setupStore(c)
@ -116,7 +123,7 @@ func loop(c *cli.Context) error {
// setup the server and start the listener // setup the server and start the listener
handler := router.Load( handler := router.Load(
webUIServe, webUIServe,
ginrus.Ginrus(logrus.StandardLogger(), time.RFC3339, true), logger.Logger(time.RFC3339, true),
middleware.Version, middleware.Version,
middleware.Config(c), middleware.Config(c),
middleware.Store(c, store_), middleware.Store(c, store_),
@ -130,7 +137,7 @@ func loop(c *cli.Context) error {
lis, err := net.Listen("tcp", c.String("grpc-addr")) lis, err := net.Listen("tcp", c.String("grpc-addr"))
if err != nil { if err != nil {
logrus.Error(err) log.Err(err).Msg("")
return err return err
} }
auther := &authorizer{ auther := &authorizer{
@ -155,7 +162,7 @@ func loop(c *cli.Context) error {
err = grpcServer.Serve(lis) err = grpcServer.Serve(lis)
if err != nil { if err != nil {
logrus.Error(err) log.Err(err).Msg("")
return err return err
} }
return nil return nil

View file

@ -19,6 +19,12 @@ import (
"time" "time"
"github.com/gin-gonic/gin" "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"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/plugins/environments" "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"
"github.com/woodpecker-ci/woodpecker/server/store/datastore" "github.com/woodpecker-ci/woodpecker/server/store/datastore"
"github.com/woodpecker-ci/woodpecker/server/web" "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 { 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"), SkipVerify: c.Bool("gitea-skip-verify"),
} }
if len(opts.URL) == 0 { 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) return gitea.New(opts)
} }

2
go.mod
View file

@ -19,7 +19,6 @@ require (
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
github.com/franela/goblin v0.0.0-20200512143142-b260c999b2d7 github.com/franela/goblin v0.0.0-20200512143142-b260c999b2d7
github.com/ghodss/yaml v1.0.0 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/gin-gonic/gin v1.7.4
github.com/go-playground/validator/v10 v10.9.0 // indirect github.com/go-playground/validator/v10 v10.9.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 github.com/go-sql-driver/mysql v1.6.0
@ -43,7 +42,6 @@ require (
github.com/prometheus/client_golang v1.7.1 github.com/prometheus/client_golang v1.7.1
github.com/rs/zerolog v1.25.0 github.com/rs/zerolog v1.25.0
github.com/russross/meddler v1.0.1 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/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
github.com/tevino/abool v0.0.0-20170917061928-9b9efcf221b5 github.com/tevino/abool v0.0.0-20170917061928-9b9efcf221b5

2
go.sum
View file

@ -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/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 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= 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 h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=
github.com/gin-gonic/gin v1.7.4/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= 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= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=

View file

@ -1,9 +1,7 @@
package docker package docker
// import ( // import (
// "context"
//
// "github.com/woodpecker-ci/woodpecker/pipeline/backend"
// ) // )
// //
// // Pool manages a pool of Docker clients. // // Pool manages a pool of Docker clients.

View file

@ -4,9 +4,9 @@ import (
"path" "path"
"strings" "strings"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml"
libcompose "github.com/docker/libcompose/yaml" libcompose "github.com/docker/libcompose/yaml"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml"
) )
// Cacher defines a compiler transform that can be used // Cacher defines a compiler transform that can be used

View file

@ -25,7 +25,7 @@ func (c *Compiler) createProcess(name string, container *yaml.Container, section
) )
networks := []backend.Conn{ networks := []backend.Conn{
backend.Conn{ {
Name: fmt.Sprintf("%s_default", c.prefix), Name: fmt.Sprintf("%s_default", c.prefix),
Aliases: []string{container.Name}, Aliases: []string{container.Name},
}, },

View file

@ -7,9 +7,10 @@ import (
"github.com/bmatcuk/doublestar/v4" "github.com/bmatcuk/doublestar/v4"
libcompose "github.com/docker/libcompose/yaml" libcompose "github.com/docker/libcompose/yaml"
"gopkg.in/yaml.v3"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend" "github.com/woodpecker-ci/woodpecker/pipeline/frontend"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types" "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
"gopkg.in/yaml.v3"
) )
type ( type (

View file

@ -3,9 +3,9 @@ package yaml
import ( import (
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend"
) )
func TestConstraint(t *testing.T) { func TestConstraint(t *testing.T) {

View file

@ -3,10 +3,9 @@ package coverage
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"strconv"
"mime/multipart" "mime/multipart"
"net/textproto" "net/textproto"
"strconv"
) )
// MimeType used by coverage reports. // MimeType used by coverage reports.

View file

@ -3,15 +3,15 @@ package rpc
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"log"
"time" "time"
"github.com/woodpecker-ci/woodpecker/pipeline/backend" "github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"github.com/woodpecker-ci/woodpecker/pipeline/backend"
"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto"
) )
var backoff = time.Second var backoff = time.Second
@ -46,7 +46,7 @@ func (c *client) Next(ctx context.Context, f Filter) (*Pipeline, error) {
if err == nil { if err == nil {
break break
} else { } 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) { switch status.Code(err) {
case case
@ -86,7 +86,7 @@ func (c *client) Wait(ctx context.Context, id string) (err error) {
if err == nil { if err == nil {
break break
} else { } 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) { switch status.Code(err) {
case case
@ -120,7 +120,7 @@ func (c *client) Init(ctx context.Context, id string, state State) (err error) {
if err == nil { if err == nil {
break break
} else { } 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) { switch status.Code(err) {
case case
@ -154,7 +154,7 @@ func (c *client) Done(ctx context.Context, id string, state State) (err error) {
if err == nil { if err == nil {
break break
} else { } 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) { switch status.Code(err) {
case case
@ -181,7 +181,7 @@ func (c *client) Extend(ctx context.Context, id string) (err error) {
if err == nil { if err == nil {
break break
} else { } 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) { switch status.Code(err) {
case case
@ -215,7 +215,7 @@ func (c *client) Update(ctx context.Context, id string, state State) (err error)
if err == nil { if err == nil {
break break
} else { } 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) { switch status.Code(err) {
case case
@ -250,7 +250,7 @@ func (c *client) Upload(ctx context.Context, id string, file *File) (err error)
if err == nil { if err == nil {
break break
} else { } 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) { switch status.Code(err) {
case case
@ -282,7 +282,7 @@ func (c *client) Log(ctx context.Context, id string, line *Line) (err error) {
if err == nil { if err == nil {
break break
} else { } 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) { switch status.Code(err) {
case case

View file

@ -2,15 +2,13 @@ package rpc
import ( import (
"context" "context"
// "encoding/json"
"time" "time"
// "github.com/woodpecker-ci/woodpecker/pipeline/backend"
"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto"
) )
// generate protobuffs // generate protobuffs

View file

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.27.1 // protoc-gen-go v1.27.1
// protoc v3.17.3 // protoc v3.18.1
// source: woodpecker.proto // source: woodpecker.proto
package proto package proto

View file

@ -1,4 +1,8 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT. // 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 package proto

View file

@ -4,8 +4,9 @@ import (
_ "embed" _ "embed"
"fmt" "fmt"
"github.com/woodpecker-ci/woodpecker/shared/yml"
"github.com/xeipuuv/gojsonschema" "github.com/xeipuuv/gojsonschema"
"github.com/woodpecker-ci/woodpecker/shared/yml"
) )
//go:embed schema.json //go:embed schema.json

View file

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/pipeline/schema"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/woodpecker-ci/woodpecker/pipeline/schema"
) )
func TestSchema(t *testing.T) { func TestSchema(t *testing.T) {

View file

@ -20,8 +20,9 @@ package api
import ( import (
"fmt" "fmt"
"github.com/rs/zerolog/log"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"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"
@ -60,7 +61,7 @@ func GetBadge(c *gin.Context) {
build, err := store.GetBuildLast(c, repo, branch) build, err := store.GetBuildLast(c, repo, branch)
if err != nil { if err != nil {
log.Warning(err) log.Warn().Err(err).Msg("")
c.String(200, badgeNone) c.String(200, badgeNone)
return return
} }

View file

@ -22,13 +22,13 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"log"
"net/http" "net/http"
"strconv" "strconv"
"time" "time"
"github.com/gin-gonic/gin" "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"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/queue" "github.com/woodpecker-ci/woodpecker/server/queue"
@ -208,11 +208,11 @@ func DeleteBuild(c *gin.Context) {
if proc.State == model.StatusPending { if proc.State == model.StatusPending {
if proc.PPID != 0 { if proc.PPID != 0 {
if _, err = shared.UpdateProcToStatusSkipped(store.FromContext(c), *proc, 0); err != nil { 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 { } else {
if _, err = shared.UpdateProcToStatusKilled(store.FromContext(c), *proc); err != nil { 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 // fetch the build file from the database
configs, err := server.Config.Storage.Config.ConfigsForBuild(build.ID) configs, err := server.Config.Storage.Config.ConfigsForBuild(build.ID)
if err != nil { 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) c.AbortWithError(404, err)
return return
} }
@ -285,11 +285,11 @@ func PostApproval(c *gin.Context) {
last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID) last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID)
secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build) secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build)
if err != nil { 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) regs, err := server.Config.Services.Registries.RegistryList(repo)
if err != nil { 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{} envs := map[string]string{}
if server.Config.Services.Environ != nil { if server.Config.Services.Environ != nil {
@ -318,7 +318,7 @@ func PostApproval(c *gin.Context) {
buildItems, err := b.Build() buildItems, err := b.Build()
if err != nil { if err != nil {
if _, err = shared.UpdateToStatusError(store.FromContext(c), *build, err); 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 return
} }
@ -326,7 +326,7 @@ func PostApproval(c *gin.Context) {
err = store.FromContext(c).ProcCreate(build.Procs) err = store.FromContext(c).ProcCreate(build.Procs)
if err != nil { 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() { defer func() {
@ -338,7 +338,7 @@ func PostApproval(c *gin.Context) {
err = remote_.Status(c, user, repo, build, uri, nil) err = remote_.Status(c, user, repo, build, uri, nil)
} }
if err != 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) uri := fmt.Sprintf("%s/%s/%d", server.Config.Server.Host, repo.FullName, build.Number)
err = remote_.Status(c, user, repo, build, uri, nil) err = remote_.Status(c, user, repo, build, uri, nil)
if err != 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) c.JSON(200, build)
@ -403,14 +403,14 @@ func PostBuild(c *gin.Context) {
user, err := store.GetUser(c, repo.UserID) user, err := store.GetUser(c, repo.UserID)
if err != nil { 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) c.AbortWithError(500, err)
return return
} }
build, err := store.GetBuildNumber(c, repo, num) build, err := store.GetBuildNumber(c, repo, num)
if err != nil { 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) c.AbortWithError(404, err)
return return
} }
@ -435,14 +435,14 @@ func PostBuild(c *gin.Context) {
// fetch the pipeline config from database // fetch the pipeline config from database
configs, err := server.Config.Storage.Config.ConfigsForBuild(build.ID) configs, err := server.Config.Storage.Config.ConfigsForBuild(build.ID)
if err != nil { 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) c.AbortWithError(404, err)
return return
} }
netrc, err := remote_.Netrc(user, repo) netrc, err := remote_.Netrc(user, repo)
if err != nil { 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) c.AbortWithError(500, err)
return return
} }
@ -473,7 +473,7 @@ func PostBuild(c *gin.Context) {
err = persistBuildConfigs(configs, build.ID) err = persistBuildConfigs(configs, build.ID)
if err != nil { 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) c.AbortWithError(500, err)
return return
} }
@ -495,11 +495,11 @@ func PostBuild(c *gin.Context) {
last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID) last, _ := store.GetBuildLastBefore(c, repo, build.Branch, build.ID)
secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build) secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build)
if err != nil { 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) regs, err := server.Config.Services.Registries.RegistryList(repo)
if err != nil { 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 { if server.Config.Services.Environ != nil {
globals, _ := server.Config.Services.Environ.EnvironList(repo) globals, _ := server.Config.Services.Environ.EnvironList(repo)
@ -537,7 +537,7 @@ func PostBuild(c *gin.Context) {
err = store.FromContext(c).ProcCreate(build.Procs) err = store.FromContext(c).ProcCreate(build.Procs)
if err != nil { 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.Status = model.StatusError
build.Started = time.Now().Unix() build.Started = time.Now().Unix()
build.Finished = build.Started build.Finished = build.Started

View file

@ -21,6 +21,7 @@ import (
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"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

@ -29,19 +29,18 @@ import (
"time" "time"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"github.com/sirupsen/logrus"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/shared/token"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml" "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml"
"github.com/woodpecker-ci/woodpecker/pipeline/rpc" "github.com/woodpecker-ci/woodpecker/pipeline/rpc"
"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/pubsub" "github.com/woodpecker-ci/woodpecker/server/pubsub"
"github.com/woodpecker-ci/woodpecker/server/queue" "github.com/woodpecker-ci/woodpecker/server/queue"
"github.com/woodpecker-ci/woodpecker/server/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/woodpecker-ci/woodpecker/server/shared" "github.com/woodpecker-ci/woodpecker/server/shared"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
"github.com/woodpecker-ci/woodpecker/shared/token"
) )
var skipRe = regexp.MustCompile(`\[(?i:ci *skip|skip *ci)\]`) 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) tmpRepo, build, err := remote_.Hook(c.Request)
if err != nil { if err != nil {
logrus.Errorf("failure to parse hook. %s", err) log.Error().Msgf("failure to parse hook. %s", err)
c.AbortWithError(400, err) c.AbortWithError(400, err)
return return
} }
@ -90,7 +89,7 @@ func PostHook(c *gin.Context) {
return return
} }
if tmpRepo == nil { if tmpRepo == nil {
logrus.Errorf("failure to ascertain repo from hook.") log.Error().Msgf("failure to ascertain repo from hook.")
c.Writer.WriteHeader(400) c.Writer.WriteHeader(400)
return return
} }
@ -99,19 +98,19 @@ func PostHook(c *gin.Context) {
// wrapped in square brackets appear in the commit message // wrapped in square brackets appear in the commit message
skipMatch := skipRe.FindString(build.Message) skipMatch := skipRe.FindString(build.Message)
if len(skipMatch) > 0 { 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) c.Writer.WriteHeader(204)
return return
} }
repo, err := store.GetRepoOwnerName(c, tmpRepo.Owner, tmpRepo.Name) repo, err := store.GetRepoOwnerName(c, tmpRepo.Owner, tmpRepo.Name)
if err != nil { 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) c.AbortWithError(404, err)
return return
} }
if !repo.IsActive { 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) c.AbortWithError(204, err)
return return
} }
@ -121,24 +120,24 @@ func PostHook(c *gin.Context) {
return repo.Hash, nil return repo.Hash, nil
}) })
if err != 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) c.AbortWithError(400, err)
return return
} }
if parsed.Text != repo.FullName { 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) c.AbortWithStatus(403)
return return
} }
if repo.UserID == 0 { 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) c.Writer.WriteHeader(204)
return return
} }
if build.Event == model.EventPull && !repo.AllowPull { 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.Write([]byte("pulls are disabled on woodpecker for this repo"))
c.Writer.WriteHeader(204) c.Writer.WriteHeader(204)
return return
@ -146,7 +145,7 @@ func PostHook(c *gin.Context) {
user, err := store.GetUser(c, repo.UserID) user, err := store.GetUser(c, repo.UserID)
if err != nil { 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) c.AbortWithError(500, err)
return return
} }
@ -157,10 +156,10 @@ func PostHook(c *gin.Context) {
if refresher, ok := remote_.(remote.Refresher); ok { if refresher, ok := remote_.(remote.Refresher); ok {
ok, err := refresher.Refresh(c, user) ok, err := refresher.Refresh(c, user)
if err != nil { 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 { } else if ok {
if err := store.UpdateUser(c, user); err != nil { 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 // move forward
} }
} }
@ -170,14 +169,14 @@ func PostHook(c *gin.Context) {
configFetcher := shared.NewConfigFetcher(remote_, user, repo, build) configFetcher := shared.NewConfigFetcher(remote_, user, repo, build)
remoteYamlConfigs, err := configFetcher.Fetch(c) remoteYamlConfigs, err := configFetcher.Fetch(c)
if err != nil { 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) c.AbortWithError(404, err)
return return
} }
filtered, err := branchFiltered(build, remoteYamlConfigs) filtered, err := branchFiltered(build, remoteYamlConfigs)
if err != nil { 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) c.AbortWithError(400, err)
} }
if filtered { if filtered {
@ -201,7 +200,7 @@ func PostHook(c *gin.Context) {
err = store.CreateBuild(c, build, build.Procs...) err = store.CreateBuild(c, build, build.Procs...)
if err != nil { 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) c.AbortWithError(500, err)
return return
} }
@ -210,7 +209,7 @@ func PostHook(c *gin.Context) {
for _, remoteYamlConfig := range remoteYamlConfigs { for _, remoteYamlConfig := range remoteYamlConfigs {
_, err := findOrPersistPipelineConfig(repo, build, remoteYamlConfig) _, err := findOrPersistPipelineConfig(repo, build, remoteYamlConfig)
if err != nil { 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) c.AbortWithError(500, err)
return return
} }
@ -238,12 +237,12 @@ func PostHook(c *gin.Context) {
secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build) secs, err := server.Config.Services.Secrets.SecretListBuild(repo, build)
if err != nil { 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) regs, err := server.Config.Services.Registries.RegistryList(repo)
if err != nil { 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 // 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() buildItems, err := b.Build()
if err != nil { if err != nil {
if _, err = shared.UpdateToStatusError(store.FromContext(c), *build, err); 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 return
} }
@ -271,7 +270,7 @@ func PostHook(c *gin.Context) {
err = store.FromContext(c).ProcCreate(build.Procs) err = store.FromContext(c).ProcCreate(build.Procs)
if err != nil { 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() { defer func() {
@ -283,7 +282,7 @@ func PostHook(c *gin.Context) {
err = remote_.Status(c, user, repo, build, uri, nil) err = remote_.Status(c, user, repo, build, uri, nil)
} }
if err != 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 // TODO: parse yaml once and not for each filter function
func branchFiltered(build *model.Build, remoteYamlConfigs []*remote.FileMeta) (bool, error) { 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 { for _, remoteYamlConfig := range remoteYamlConfigs {
parsedPipelineConfig, err := yaml.ParseString(string(remoteYamlConfig.Data)) parsedPipelineConfig, err := yaml.ParseString(string(remoteYamlConfig.Data))
if err != nil { 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 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 { if !parsedPipelineConfig.Branches.Match(build.Branch) && build.Event != model.EventTag && build.Event != model.EventDeploy {
} else { } else {

View file

@ -19,16 +19,16 @@ import (
"net/http" "net/http"
"time" "time"
"github.com/gin-gonic/gin"
"github.com/gorilla/securecookie" "github.com/gorilla/securecookie"
"github.com/rs/zerolog/log"
"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/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
"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"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
) )
func HandleLogin(c *gin.Context) { func HandleLogin(c *gin.Context) {
@ -56,7 +56,7 @@ func HandleAuth(c *gin.Context) {
tmpuser, err := remote.Login(c, c.Writer, c.Request) tmpuser, err := remote.Login(c, c.Writer, c.Request)
if err != nil { 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") c.Redirect(303, "/login?error=oauth_error")
return return
} }
@ -73,7 +73,7 @@ func HandleAuth(c *gin.Context) {
// if self-registration is disabled we should return a not authorized error // if self-registration is disabled we should return a not authorized error
if !config.Open && !config.IsAdmin(tmpuser) { 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") c.Redirect(303, "/login?error=access_denied")
return return
} }
@ -83,7 +83,7 @@ func HandleAuth(c *gin.Context) {
if len(config.Orgs) != 0 { if len(config.Orgs) != 0 {
teams, terr := remote.Teams(c, tmpuser) teams, terr := remote.Teams(c, tmpuser)
if terr != nil || config.IsMember(teams) == false { 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") c.Redirect(303, "/login?error=access_denied")
return return
} }
@ -103,7 +103,7 @@ func HandleAuth(c *gin.Context) {
// insert the user into the database // insert the user into the database
if err := store.CreateUser(c, u); err != nil { 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") c.Redirect(303, "/login?error=internal_error")
return return
} }
@ -120,14 +120,14 @@ func HandleAuth(c *gin.Context) {
if len(config.Orgs) != 0 { if len(config.Orgs) != 0 {
teams, terr := remote.Teams(c, u) teams, terr := remote.Teams(c, u)
if terr != nil || config.IsMember(teams) == false { 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") c.Redirect(303, "/login?error=access_denied")
return return
} }
} }
if err := store.UpdateUser(c, u); err != nil { 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") c.Redirect(303, "/login?error=internal_error")
return return
} }
@ -135,7 +135,7 @@ func HandleAuth(c *gin.Context) {
exp := time.Now().Add(server.Config.Server.SessionExpires).Unix() exp := time.Now().Add(server.Config.Server.SessionExpires).Unix()
tokenString, err := token.New(token.SessToken, u.Login).SignExpires(u.Hash, exp) tokenString, err := token.New(token.SessToken, u.Login).SignExpires(u.Hash, exp)
if err != nil { 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") c.Redirect(303, "/login?error=internal_error")
return return
} }

View file

@ -20,6 +20,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/woodpecker-ci/woodpecker/server" "github.com/woodpecker-ci/woodpecker/server"
) )

View file

@ -17,11 +17,11 @@ package api
import ( import (
"net/http" "net/http"
"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"
"github.com/gin-gonic/gin"
) )
// GetRegistry gets the name registry from the database and writes // GetRegistry gets the name registry from the database and writes

View file

@ -17,11 +17,11 @@ package api
import ( import (
"net/http" "net/http"
"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"
"github.com/gin-gonic/gin"
) )
// GetSecret gets the named secret from the database and writes // GetSecret gets the named secret from the database and writes

View file

@ -22,15 +22,15 @@ import (
"strconv" "strconv"
"time" "time"
"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/logging" "github.com/woodpecker-ci/woodpecker/server/logging"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/pubsub" "github.com/woodpecker-ci/woodpecker/server/pubsub"
"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"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
) )
// //
@ -55,7 +55,7 @@ func EventStreamSSE(c *gin.Context) {
io.WriteString(rw, ": ping\n\n") io.WriteString(rw, ": ping\n\n")
flusher.Flush() flusher.Flush()
logrus.Debugf("user feed: connection opened") log.Debug().Msg("user feed: connection opened")
user := session.User(c) user := session.User(c)
repo := map[string]bool{} repo := map[string]bool{}
@ -74,7 +74,7 @@ func EventStreamSSE(c *gin.Context) {
defer func() { defer func() {
cancel() cancel()
close(eventc) close(eventc)
logrus.Debugf("user feed: connection closed") log.Debug().Msg("user feed: connection closed")
}() }()
go func() { go func() {
@ -159,18 +159,18 @@ func LogStreamSSE(c *gin.Context) {
build, err := store.GetBuildNumber(c, repo, buildn) build, err := store.GetBuildNumber(c, repo, buildn)
if err != nil { 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") io.WriteString(rw, "event: error\ndata: build not found\n\n")
return return
} }
proc, err := store.FromContext(c).ProcFind(build, jobn) proc, err := store.FromContext(c).ProcFind(build, jobn)
if err != nil { 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") io.WriteString(rw, "event: error\ndata: process not found\n\n")
return return
} }
if proc.State != model.StatusRunning { 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") io.WriteString(rw, "event: error\ndata: stream not found\n\n")
return return
} }
@ -180,12 +180,12 @@ func LogStreamSSE(c *gin.Context) {
context.Background(), context.Background(),
) )
logrus.Debugf("log stream: connection opened") log.Debug().Msgf("log stream: connection opened")
defer func() { defer func() {
cancel() cancel()
close(logc) close(logc)
logrus.Debugf("log stream: connection closed") log.Debug().Msgf("log stream: connection closed")
}() }()
go func() { go func() {
@ -214,7 +214,7 @@ func LogStreamSSE(c *gin.Context) {
c.Request.Header.Get("Last-Event-ID"), c.Request.Header.Get("Last-Event-ID"),
) )
if last != 0 { 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 // retry: 10000\n

View file

@ -22,7 +22,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/gorilla/securecookie" "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/model"
"github.com/woodpecker-ci/woodpecker/server/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
@ -41,7 +41,7 @@ func GetFeed(c *gin.Context) {
latest, _ := strconv.ParseBool(c.Query("latest")) latest, _ := strconv.ParseBool(c.Query("latest"))
if time.Unix(user.Synced, 0).Add(time.Hour * 72).Before(time.Now()) { 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() user.Synced = time.Now().Unix()
store.FromContext(c).UpdateUser(user) store.FromContext(c).UpdateUser(user)
@ -55,9 +55,9 @@ func GetFeed(c *gin.Context) {
Match: shared.NamespaceFilter(config.OwnersWhitelist), Match: shared.NamespaceFilter(config.OwnersWhitelist),
} }
if err := sync.Sync(c, user); err != nil { 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 { } 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()) { 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() user.Synced = time.Now().Unix()
store.FromContext(c).UpdateUser(user) store.FromContext(c).UpdateUser(user)
@ -101,9 +101,9 @@ func GetRepos(c *gin.Context) {
} }
if err := sync.Sync(c, user); err != nil { 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 { } else {
logrus.Debugf("sync complete: %s", user.Login) log.Debug().Msgf("sync complete: %s", user.Login)
} }
} }

View file

@ -15,10 +15,10 @@
package api package api
import ( import (
"github.com/gin-gonic/gin"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
"github.com/woodpecker-ci/woodpecker/version" "github.com/woodpecker-ci/woodpecker/version"
"github.com/gin-gonic/gin"
) )
// Health endpoint returns a 500 if the server state is unhealthy. // Health endpoint returns a 500 if the server state is unhealthy.

View file

@ -22,29 +22,26 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"log"
"strconv" "strconv"
oldcontext "golang.org/x/net/context" "github.com/rs/zerolog/log"
grpcMetadata "google.golang.org/grpc/metadata"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto" "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"
"github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto" "github.com/woodpecker-ci/woodpecker/pipeline/rpc/proto"
"github.com/woodpecker-ci/woodpecker/server" "github.com/woodpecker-ci/woodpecker/server"
"github.com/woodpecker-ci/woodpecker/server/logging" "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/pubsub"
"github.com/woodpecker-ci/woodpecker/server/queue" "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/remote"
"github.com/woodpecker-ci/woodpecker/server/shared"
"github.com/woodpecker-ci/woodpecker/server/store" "github.com/woodpecker-ci/woodpecker/server/store"
"github.com/woodpecker-ci/expr"
) )
type RPC struct { type RPC struct {
@ -64,7 +61,7 @@ func (s *RPC) Next(c context.Context, filter rpc.Filter) (*rpc.Pipeline, error)
if ok { if ok {
hostname, ok := metadata["hostname"] hostname, ok := metadata["hostname"]
if ok && len(hostname) != 0 { 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) pproc, err := s.store.ProcLoad(procID)
if err != nil { 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 return err
} }
build, err := s.store.GetBuild(pproc.BuildID) build, err := s.store.GetBuild(pproc.BuildID)
if err != nil { 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 return err
} }
proc, err := s.store.ProcChild(build, pproc.PID, state.Proc) proc, err := s.store.ProcChild(build, pproc.PID, state.Proc)
if err != nil { 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 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) repo, err := s.store.GetRepo(build.RepoID)
if err != nil { 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 return err
} }
if proc, err = shared.UpdateProcStatus(s.store, *proc, state, build.Started); err != nil { 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) 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) pproc, err := s.store.ProcLoad(procID)
if err != nil { 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 return err
} }
build, err := s.store.GetBuild(pproc.BuildID) build, err := s.store.GetBuild(pproc.BuildID)
if err != nil { 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 return err
} }
proc, err := s.store.ProcChild(build, pproc.PID, file.Proc) proc, err := s.store.ProcChild(build, pproc.PID, file.Proc)
if err != nil { 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 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) proc, err := s.store.ProcLoad(procID)
if err != nil { 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 return err
} }
metadata, ok := grpcMetadata.FromIncomingContext(c) 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) build, err := s.store.GetBuild(proc.BuildID)
if err != nil { 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 return err
} }
repo, err := s.store.GetRepo(build.RepoID) repo, err := s.store.GetRepo(build.RepoID)
if err != nil { 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 return err
} }
if build.Status == model.StatusPending { if build.Status == model.StatusPending {
if build, err = shared.UpdateToStatusRunning(s.store, *build, state.Started); err != nil { 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) proc, err := s.store.ProcLoad(procID)
if err != nil { 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 return err
} }
build, err := s.store.GetBuild(proc.BuildID) build, err := s.store.GetBuild(proc.BuildID)
if err != nil { 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 return err
} }
repo, err := s.store.GetRepo(build.RepoID) repo, err := s.store.GetRepo(build.RepoID)
if err != nil { 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 return err
} }
if proc, err = shared.UpdateProcStatusToDone(s.store, *proc, state); err != nil { 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 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) queueErr = s.queue.Done(c, id, proc.State)
} }
if queueErr != nil { 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) 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 !isThereRunningStage(procs) {
if build, err = shared.UpdateStatusToDone(s.store, *build, buildStatus(procs), proc.Stopped); err != nil { 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) { 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 { 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) s.notify(c, repo, build, procs)
@ -385,7 +382,7 @@ func (s *RPC) completeChildrenIfParentCompleted(procs []*model.Proc, completedPr
for _, p := range procs { for _, p := range procs {
if p.Running() && p.PPID == completedProc.PID { if p.Running() && p.PPID == completedProc.PID {
if _, err := shared.UpdateProcToStatusSkipped(s.store, *p, completedProc.Stopped); err != nil { 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) uri := fmt.Sprintf("%s/%s/%d", server.Config.Server.Host, repo.FullName, build.Number)
err = s.remote.Status(ctx, user, repo, build, uri, proc) err = s.remote.Status(ctx, user, repo, build, uri, proc)
if err != 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)
} }
} }
} }

View file

@ -17,7 +17,8 @@ package model
import ( import (
"context" "context"
"github.com/sirupsen/logrus" "github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/server/queue" "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) { func (q *persistentQueue) Poll(c context.Context, f queue.Filter) (*queue.Task, error) {
task, err := q.Queue.Poll(c, f) task, err := q.Queue.Poll(c, f)
if task != nil { 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 { 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 { } 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 return task, err

View file

@ -1,8 +1,9 @@
package environments package environments
import ( import (
"github.com/woodpecker-ci/woodpecker/server/model"
"strings" "strings"
"github.com/woodpecker-ci/woodpecker/server/model"
) )
type builtin struct { type builtin struct {

View file

@ -4,11 +4,13 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/docker/cli/cli/config/configfile"
"github.com/docker/cli/cli/config/types"
"github.com/woodpecker-ci/woodpecker/server/model"
"os" "os"
"strings" "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 { type filesystem struct {

View file

@ -3,12 +3,11 @@ package queue
import ( import (
"container/list" "container/list"
"context" "context"
"log"
"runtime" "runtime"
"sync" "sync"
"time" "time"
"github.com/sirupsen/logrus" "github.com/rs/zerolog/log"
) )
const ( const (
@ -237,7 +236,7 @@ func (q *fifo) process() {
const size = 64 << 10 const size = 64 << 10
buf := make([]byte, size) buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)] 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() nextPending = e.Next()
task := e.Value.(*Task) task := e.Value.(*Task)
if q.depsInQueue(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) q.waitingOnDeps.PushBack(task)
filtered = append(filtered, e) filtered = append(filtered, e)
} }
@ -290,11 +289,11 @@ func (q *fifo) assignToWorker() (*list.Element, *worker) {
for e := q.pending.Front(); e != nil; e = next { for e := q.pending.Front(); e != nil; e = next {
next = e.Next() next = e.Next()
task := e.Value.(*Task) 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 { for w := range q.workers {
if w.filter(task) { 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 return e, w
} }
} }
@ -318,7 +317,7 @@ func (q *fifo) depsInQueue(task *Task) bool {
for e := q.pending.Front(); e != nil; e = next { for e := q.pending.Front(); e != nil; e = next {
next = e.Next() next = e.Next()
possibleDep, ok := e.Value.(*Task) 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 { for _, dep := range task.Dependencies {
if ok && possibleDep.ID == dep { if ok && possibleDep.ID == dep {
return true return true
@ -326,7 +325,7 @@ func (q *fifo) depsInQueue(task *Task) bool {
} }
} }
for possibleDepID := range q.running { 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 { for _, dep := range task.Dependencies {
if possibleDepID == dep { if possibleDepID == dep {
return true return true
@ -369,13 +368,13 @@ func (q *fifo) updateDepStatusInQueue(taskID string, status string) {
} }
func (q *fifo) removeFromPending(taskID 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 var next *list.Element
for e := q.pending.Front(); e != nil; e = next { for e := q.pending.Front(); e != nil; e = next {
next = e.Next() next = e.Next()
task := e.Value.(*Task) task := e.Value.(*Task)
if task.ID == taskID { 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) q.pending.Remove(e)
return return
} }

View file

@ -246,7 +246,6 @@ func TestFifoErrors2(t *testing.T) {
} }
func TestFifoErrorsMultiThread(t *testing.T) { func TestFifoErrorsMultiThread(t *testing.T) {
//logrus.SetLevel(logrus.DebugLevel)
task1 := &Task{ task1 := &Task{
ID: "1", ID: "1",
} }

View file

@ -20,12 +20,12 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"golang.org/x/oauth2"
"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/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal" "github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal"
"golang.org/x/oauth2"
) )
// Bitbucket cloud endpoints. // Bitbucket cloud endpoints.

View file

@ -21,12 +21,12 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/franela/goblin"
"github.com/gin-gonic/gin"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/fixtures" "github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/fixtures"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal" "github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal"
"github.com/franela/goblin"
"github.com/gin-gonic/gin"
) )
func Test_bitbucket(t *testing.T) { func Test_bitbucket(t *testing.T) {

View file

@ -20,10 +20,10 @@ import (
"regexp" "regexp"
"strings" "strings"
"golang.org/x/oauth2"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal" "github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal"
"golang.org/x/oauth2"
) )
const ( const (

View file

@ -18,11 +18,11 @@ import (
"testing" "testing"
"time" "time"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/internal"
"github.com/franela/goblin" "github.com/franela/goblin"
"golang.org/x/oauth2" "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) { func Test_helper(t *testing.T) {

View file

@ -19,9 +19,9 @@ import (
"net/http" "net/http"
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/fixtures"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucket/fixtures"
) )
func Test_parser(t *testing.T) { func Test_parser(t *testing.T) {

View file

@ -30,6 +30,7 @@ import (
"strings" "strings"
"github.com/mrjones/oauth" "github.com/mrjones/oauth"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal" "github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal"

View file

@ -23,6 +23,7 @@ import (
"time" "time"
"github.com/mrjones/oauth" "github.com/mrjones/oauth"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal" "github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal"
) )

View file

@ -19,6 +19,7 @@ import (
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/mrjones/oauth" "github.com/mrjones/oauth"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal" "github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal"
) )

View file

@ -23,11 +23,11 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strconv" "strconv"
"strings" "strings"
"github.com/mrjones/oauth" "github.com/mrjones/oauth"
log "github.com/sirupsen/logrus" "github.com/rs/zerolog/log"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
) )
@ -57,7 +57,7 @@ func NewClientWithToken(ctx context.Context, url string, consumer *oauth.Consume
token.Token = AccessToken token.Token = AccessToken
client, err := consumer.MakeHttpClient(&token) client, err := consumer.MakeHttpClient(&token)
if err != nil { if err != nil {
log.Error(err) log.Err(err).Msg("")
} }
return &Client{ return &Client{
@ -113,7 +113,7 @@ func (c *Client) FindRepo(owner string, name string) (*Repo, error) {
defer response.Body.Close() defer response.Body.Close()
} }
if err != nil { if err != nil {
log.Error(err) log.Err(err).Msg("")
} }
contents, err := ioutil.ReadAll(response.Body) contents, err := ioutil.ReadAll(response.Body)
repo := Repo{} repo := Repo{}
@ -154,14 +154,14 @@ func (c *Client) FindFileForRepo(owner string, repo string, fileName string, ref
defer response.Body.Close() defer response.Body.Close()
} }
if err != nil { if err != nil {
log.Error(err) log.Err(err).Msg("")
} }
if response.StatusCode == 404 { if response.StatusCode == 404 {
return nil, nil return nil, nil
} }
responseBytes, err := ioutil.ReadAll(response.Body) responseBytes, err := ioutil.ReadAll(response.Body)
if err != nil { if err != nil {
log.Error(err) log.Err(err).Msg("")
} }
return responseBytes, nil return responseBytes, nil
} }

View file

@ -17,9 +17,10 @@ package bitbucketserver
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal" "github.com/woodpecker-ci/woodpecker/server/remote/bitbucketserver/internal"
"net/http"
) )
// parseHook parses a Bitbucket hook from an http.Request request and returns // parseHook parses a Bitbucket hook from an http.Request request and returns

View file

@ -21,12 +21,12 @@ import (
"net/http" "net/http"
"strings" "strings"
"golang.org/x/oauth2"
"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/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/woodpecker-ci/woodpecker/server/remote/coding/internal" "github.com/woodpecker-ci/woodpecker/server/remote/coding/internal"
"golang.org/x/oauth2"
) )
const ( const (

View file

@ -21,11 +21,11 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/coding/fixtures"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/gin-gonic/gin" "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) { func Test_coding(t *testing.T) {

View file

@ -20,10 +20,10 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/franela/goblin"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/coding/fixtures" "github.com/woodpecker-ci/woodpecker/server/remote/coding/fixtures"
"github.com/franela/goblin"
) )
func Test_hook(t *testing.T) { func Test_hook(t *testing.T) {

View file

@ -28,11 +28,11 @@ import (
"path/filepath" "path/filepath"
"code.gitea.io/sdk/gitea" "code.gitea.io/sdk/gitea"
"golang.org/x/oauth2"
"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/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
"golang.org/x/oauth2"
) )
const ( const (

View file

@ -21,6 +21,7 @@ import (
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures" "github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures"
) )

View file

@ -23,6 +23,7 @@ import (
"time" "time"
"code.gitea.io/sdk/gitea" "code.gitea.io/sdk/gitea"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
) )

View file

@ -20,6 +20,7 @@ import (
"code.gitea.io/sdk/gitea" "code.gitea.io/sdk/gitea"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures" "github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures"
) )

View file

@ -20,6 +20,7 @@ import (
"testing" "testing"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures" "github.com/woodpecker-ci/woodpecker/server/remote/gitea/fixtures"
) )

View file

@ -18,9 +18,9 @@ import (
"fmt" "fmt"
"strings" "strings"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/google/go-github/v39/github" "github.com/google/go-github/v39/github"
"github.com/woodpecker-ci/woodpecker/server/model"
) )
const defaultBranch = "master" const defaultBranch = "master"

View file

@ -17,10 +17,10 @@ package github
import ( import (
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/google/go-github/v39/github" "github.com/google/go-github/v39/github"
"github.com/woodpecker-ci/woodpecker/server/model"
) )
func Test_helper(t *testing.T) { func Test_helper(t *testing.T) {

View file

@ -25,12 +25,12 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/google/go-github/v39/github"
"golang.org/x/oauth2"
"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/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/google/go-github/v39/github"
"golang.org/x/oauth2"
) )
const ( const (

View file

@ -19,11 +19,11 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/github/fixtures"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/gin-gonic/gin" "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) { func Test_github(t *testing.T) {

View file

@ -20,6 +20,7 @@ import (
"testing" "testing"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/github/fixtures" "github.com/woodpecker-ci/woodpecker/server/remote/github/fixtures"
) )

View file

@ -21,9 +21,9 @@ import (
"net/http" "net/http"
"strings" "strings"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/xanzy/go-gitlab" "github.com/xanzy/go-gitlab"
"github.com/woodpecker-ci/woodpecker/server/model"
) )
func (g *Gitlab) convertGitlabRepo(repo_ *gitlab.Project) (*model.Repo, error) { func (g *Gitlab) convertGitlabRepo(repo_ *gitlab.Project) (*model.Repo, error) {

View file

@ -25,12 +25,12 @@ import (
"net/url" "net/url"
"strings" "strings"
"github.com/xanzy/go-gitlab"
"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/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
"github.com/woodpecker-ci/woodpecker/shared/oauth2" "github.com/woodpecker-ci/woodpecker/shared/oauth2"
"github.com/xanzy/go-gitlab"
) )
const ( const (

View file

@ -22,11 +22,11 @@ import (
"strconv" "strconv"
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/gitlab/testdata"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/stretchr/testify/assert" "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 { func load(config string) *Gitlab {

View file

@ -15,9 +15,9 @@
package gitlab package gitlab
import ( import (
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/xanzy/go-gitlab" "github.com/xanzy/go-gitlab"
"github.com/woodpecker-ci/woodpecker/server/model"
) )
const ( const (

View file

@ -24,6 +24,7 @@ import (
"strings" "strings"
"github.com/gogits/go-gogs-client" "github.com/gogits/go-gogs-client"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote" "github.com/woodpecker-ci/woodpecker/server/remote"
) )

View file

@ -19,11 +19,11 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/gogs/fixtures"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/gin-gonic/gin" "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) { func Test_gogs(t *testing.T) {

View file

@ -23,6 +23,7 @@ import (
"time" "time"
"github.com/gogits/go-gogs-client" "github.com/gogits/go-gogs-client"
"github.com/woodpecker-ci/woodpecker/server/model" "github.com/woodpecker-ci/woodpecker/server/model"
) )

View file

@ -18,11 +18,11 @@ import (
"bytes" "bytes"
"testing" "testing"
"github.com/woodpecker-ci/woodpecker/server/model"
"github.com/woodpecker-ci/woodpecker/server/remote/gogs/fixtures"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/gogits/go-gogs-client" "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) { func Test_parse(t *testing.T) {

Some files were not shown because too many files have changed in this diff Show more