diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 007feb4..e08672b 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -22,23 +22,23 @@ jobs: steps: - name: Log in to the container registry - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.DOCKER_REGISTRY_USER }} password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version-file: 'go.mod' cache: false - name: Lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: args: --build-tags integration -p bugs -p unused --timeout=3m @@ -49,7 +49,7 @@ jobs: [ "${GITHUB_EVENT_NAME}" == 'push' ] && echo "tag=latest" >> $GITHUB_ENV || true - name: Build and push image - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v5 with: context: . push: true diff --git a/Dockerfile b/Dockerfile index d237cd8..42fbf29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ghcr.io/metal-stack/builder:latest as builder -FROM alpine:3.18 +FROM alpine:3.19 RUN apk add --no-cache ca-certificates COPY --from=builder /work/bin/metal-robot /metal-robot CMD ["/metal-robot"] diff --git a/cmd/metal-robot/main.go b/cmd/metal-robot/main.go index f007024..cb767c5 100644 --- a/cmd/metal-robot/main.go +++ b/cmd/metal-robot/main.go @@ -4,13 +4,12 @@ import ( "errors" "fmt" "log" + "log/slog" "net/http" + "os" "strings" "time" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" - "github.com/metal-stack/metal-robot/pkg/clients" "github.com/metal-stack/metal-robot/pkg/config" "github.com/metal-stack/metal-robot/pkg/webhooks" @@ -28,7 +27,7 @@ const ( var ( cfgFile string - logger *zap.SugaredLogger + logger *slog.Logger c *config.Configuration ) @@ -62,7 +61,7 @@ var cmd = &cobra.Command{ func main() { if err := cmd.Execute(); err != nil { - logger.Fatalw("an error occurred", "error", err) + log.Fatalf("an error occurred %s", err) } } @@ -141,25 +140,19 @@ func loadRobotConfig() error { } func initLogging() { - level := zap.InfoLevel + level := slog.LevelInfo + var lvlvar slog.LevelVar if viper.IsSet("log-level") { - err := level.UnmarshalText([]byte(viper.GetString("log-level"))) + err := lvlvar.UnmarshalText([]byte(viper.GetString("log-level"))) if err != nil { log.Fatalf("can't initialize zap logger: %v", err) } + level = lvlvar.Level() } - cfg := zap.NewProductionConfig() - cfg.Level = zap.NewAtomicLevelAt(level) - cfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder - - l, err := cfg.Build() - if err != nil { - log.Fatalf("can't initialize zap logger: %v", err) - } - - logger = l.Sugar() + jsonHandler := slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: level}) + logger = slog.New(jsonHandler) } func run(opts *Opts) error { @@ -174,7 +167,7 @@ func run(opts *Opts) error { } addr := fmt.Sprintf("%s:%d", opts.BindAddr, opts.Port) - logger.Infow("starting metal-robot server", "version", v.V.String(), "address", addr) + logger.Info("starting metal-robot server", "version", v.V.String(), "address", addr) server := http.Server{ Addr: addr, ReadHeaderTimeout: 1 * time.Minute, diff --git a/go.mod b/go.mod index 9df9515..4bd23aa 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/metal-stack/metal-robot -go 1.21 +go 1.22 require ( github.com/Masterminds/semver/v3 v3.2.1 @@ -9,18 +9,17 @@ require ( github.com/go-git/go-billy/v5 v5.5.0 // IMPORTANT: keep this version as long as https://github.com/go-git/go-git/issues/328 is open github.com/go-git/go-git/v5 v5.3.0 - github.com/go-playground/validator/v10 v10.16.0 + github.com/go-playground/validator/v10 v10.19.0 github.com/go-playground/webhooks/v6 v6.3.0 github.com/google/go-cmp v0.6.0 github.com/google/go-github/v57 v57.0.0 - github.com/metal-stack/metal-lib v0.14.4 + github.com/metal-stack/metal-lib v0.15.1 github.com/metal-stack/v v1.0.3 github.com/mitchellh/mapstructure v1.5.0 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.18.2 - github.com/tidwall/gjson v1.17.0 + github.com/tidwall/gjson v1.17.1 github.com/tidwall/sjson v1.2.5 - go.uber.org/zap v1.26.0 golang.org/x/sync v0.6.0 sigs.k8s.io/yaml v1.4.0 ) @@ -30,7 +29,7 @@ require ( github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect @@ -41,7 +40,7 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/leodido/go-urn v1.2.4 // indirect + github.com/leodido/go-urn v1.4.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect @@ -57,13 +56,13 @@ require ( github.com/tidwall/pretty v1.2.1 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.18.0 // indirect - golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sys v0.16.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f // indirect + golang.org/x/mod v0.16.0 // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.17.0 // indirect + golang.org/x/tools v0.19.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 3011bad..9612ec5 100644 --- a/go.sum +++ b/go.sum @@ -31,8 +31,8 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= @@ -52,8 +52,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqRRkz6M78GuJAfGE= -github.com/go-playground/validator/v10 v10.16.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4= +github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-playground/webhooks/v6 v6.3.0 h1:zBLUxK1Scxwi97TmZt5j/B/rLlard2zY7P77FHg58FE= github.com/go-playground/webhooks/v6 v6.3.0/go.mod h1:GCocmfMtpJdkEOM1uG9p2nXzg1kY5X/LtvQgtPHUaaA= github.com/gogits/go-gogs-client v0.0.0-20200905025246-8bb8a50cb355/go.mod h1:cY2AIrMgHm6oOHmR7jY+9TtjzSjQ3iG7tURJG3Y6XH0= @@ -89,12 +89,12 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/metal-stack/metal-lib v0.14.4 h1:vm2868vcua6khoyWL7d0to8Hq5RayrjMse0FZTyWEec= -github.com/metal-stack/metal-lib v0.14.4/go.mod h1:Z3PAh8dkyWC4B19fXsu6EYwXXee0Lk9JZbjoHPLbDbc= +github.com/metal-stack/metal-lib v0.15.1 h1:QCmtZ6ci6pHsf3RQnSDbbvYshpyRaxCSeXghVvbDFuA= +github.com/metal-stack/metal-lib v0.15.1/go.mod h1:x1nyPRi+b/WeK7N41cm4R8w4pScnhOYv8hos2UM4lXY= github.com/metal-stack/v v1.0.3 h1:Sh2oBlnxrCUD+mVpzfC8HiqL045YWkxs0gpTvkjppqs= github.com/metal-stack/v v1.0.3/go.mod h1:YTahEu7/ishwpYKnp/VaW/7nf8+PInogkfGwLcGPdXg= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -145,14 +145,13 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= -github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= +github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= @@ -163,26 +162,22 @@ github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6 github.com/xanzy/ssh-agent v0.3.0/go.mod h1:3s9xbODqPuuhK9JV1R321M/FlMZSBvE5aY6eAcqrDh0= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= -golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= -golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f h1:3CW0unweImhOzd5FmYuRsD4Y4oQFKZIjAnKbjV4WIrw= +golang.org/x/exp v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -197,18 +192,18 @@ golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.16.0 h1:m+B6fahuftsE9qjo0VWp2FW0mB3MTJvR0BaMQrq0pmE= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= -golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/pkg/clients/common.go b/pkg/clients/common.go index aeafe60..a12dba7 100644 --- a/pkg/clients/common.go +++ b/pkg/clients/common.go @@ -2,9 +2,9 @@ package clients import ( "fmt" + "log/slog" "github.com/metal-stack/metal-robot/pkg/config" - "go.uber.org/zap" ) type ClientMap map[string]Client @@ -14,7 +14,7 @@ type Client interface { Organization() string } -func InitClients(logger *zap.SugaredLogger, config []config.Client) (ClientMap, error) { +func InitClients(logger *slog.Logger, config []config.Client) (ClientMap, error) { cs := ClientMap{} for _, clientConfig := range config { ghConfig := clientConfig.GithubAuthConfig @@ -25,7 +25,7 @@ func InitClients(logger *zap.SugaredLogger, config []config.Client) (ClientMap, } if ghConfig != nil { - client, err := NewGithub(logger.Named(clientConfig.Name), clientConfig.OrganizationName, ghConfig) + client, err := NewGithub(logger.WithGroup(clientConfig.Name), clientConfig.OrganizationName, ghConfig) if err != nil { return nil, err } @@ -34,7 +34,7 @@ func InitClients(logger *zap.SugaredLogger, config []config.Client) (ClientMap, } if glConfig != nil { - client, err := NewGitlab(logger.Named(clientConfig.Name), glConfig.Token) + client, err := NewGitlab(logger.WithGroup(clientConfig.Name), glConfig.Token) if err != nil { return nil, err } diff --git a/pkg/clients/github.go b/pkg/clients/github.go index 4df7df1..d68c0f5 100644 --- a/pkg/clients/github.go +++ b/pkg/clients/github.go @@ -3,17 +3,17 @@ package clients import ( "context" "fmt" + "log/slog" "net/http" "github.com/bradleyfalzon/ghinstallation/v2" "github.com/metal-stack/metal-robot/pkg/config" - "go.uber.org/zap" v3 "github.com/google/go-github/v57/github" ) type Github struct { - logger *zap.SugaredLogger + logger *slog.Logger keyPath string appID int64 installationID int64 @@ -23,7 +23,7 @@ type Github struct { itr *ghinstallation.Transport } -func NewGithub(logger *zap.SugaredLogger, organizationID string, config *config.GithubClient) (*Github, error) { +func NewGithub(logger *slog.Logger, organizationID string, config *config.GithubClient) (*Github, error) { a := &Github{ logger: logger, keyPath: config.PrivateKeyCertPath, @@ -59,7 +59,7 @@ func (a *Github) initClients() error { a.atr = atr a.itr = itr - a.logger.Infow("successfully initalized github app client", "organization-id", a.organizationID, "installation-id", a.installationID, "expected-events", installation.Events) + a.logger.Info("successfully initalized github app client", "organization-id", a.organizationID, "installation-id", a.installationID, "expected-events", installation.Events) return nil } diff --git a/pkg/clients/gitlab.go b/pkg/clients/gitlab.go index 906d77c..875238b 100644 --- a/pkg/clients/gitlab.go +++ b/pkg/clients/gitlab.go @@ -1,17 +1,18 @@ package clients import ( + "log/slog" + "github.com/metal-stack/metal-robot/pkg/config" - "go.uber.org/zap" ) type Gitlab struct { - logger *zap.SugaredLogger + logger *slog.Logger token string organizationID string } -func NewGitlab(logger *zap.SugaredLogger, token string) (*Gitlab, error) { +func NewGitlab(logger *slog.Logger, token string) (*Gitlab, error) { a := &Gitlab{ logger: logger, token: token, diff --git a/pkg/webhooks/common.go b/pkg/webhooks/common.go index 888ab09..8edaf79 100644 --- a/pkg/webhooks/common.go +++ b/pkg/webhooks/common.go @@ -2,32 +2,32 @@ package webhooks import ( "fmt" + "log/slog" "net/http" "github.com/metal-stack/metal-robot/pkg/clients" "github.com/metal-stack/metal-robot/pkg/config" "github.com/metal-stack/metal-robot/pkg/webhooks/github" "github.com/metal-stack/metal-robot/pkg/webhooks/gitlab" - "go.uber.org/zap" ) -func InitWebhooks(logger *zap.SugaredLogger, cs clients.ClientMap, c *config.Configuration) error { +func InitWebhooks(logger *slog.Logger, cs clients.ClientMap, c *config.Configuration) error { for _, w := range c.Webhooks { switch w.VCS { case config.Github: - controller, err := github.NewGithubWebhook(logger.Named("github-webhook"), w, cs) + controller, err := github.NewGithubWebhook(logger.WithGroup("github-webhook"), w, cs) if err != nil { return err } http.HandleFunc(w.ServePath, controller.Handle) - logger.Infow("initialized github webhook", "serve-path", w.ServePath) + logger.Info("initialized github webhook", "serve-path", w.ServePath) case config.Gitlab: - controller, err := gitlab.NewGitlabWebhook(logger.Named("gitlab-webhook"), w, cs) + controller, err := gitlab.NewGitlabWebhook(logger.WithGroup("gitlab-webhook"), w, cs) if err != nil { return err } http.HandleFunc(w.ServePath, controller.Handle) - logger.Infow("initialized gitlab webhook", "serve-path", w.ServePath) + logger.Info("initialized gitlab webhook", "serve-path", w.ServePath) default: return fmt.Errorf("unsupported webhook type: %s", w.VCS) } diff --git a/pkg/webhooks/github/actions/aggregate_releases.go b/pkg/webhooks/github/actions/aggregate_releases.go index 82ee4df..bb99f7e 100644 --- a/pkg/webhooks/github/actions/aggregate_releases.go +++ b/pkg/webhooks/github/actions/aggregate_releases.go @@ -3,6 +3,7 @@ package actions import ( "context" "fmt" + "log/slog" "net/url" "strings" "sync" @@ -18,11 +19,10 @@ import ( "github.com/metal-stack/metal-robot/pkg/git" filepatchers "github.com/metal-stack/metal-robot/pkg/webhooks/modifiers/file-patchers" "github.com/mitchellh/mapstructure" - "go.uber.org/zap" ) type AggregateReleases struct { - logger *zap.SugaredLogger + logger *slog.Logger client *clients.Github branch string branchBase string @@ -42,7 +42,7 @@ type AggregateReleaseParams struct { Sender string } -func NewAggregateReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*AggregateReleases, error) { +func NewAggregateReleases(logger *slog.Logger, client *clients.Github, rawConfig map[string]any) (*AggregateReleases, error) { var ( branch = "develop" branchBase = "master" @@ -112,7 +112,7 @@ func (r *AggregateReleases) AggregateRelease(ctx context.Context, p *AggregateRe patches, ok := r.patchMap[p.RepositoryName] if !ok { - log.Debugw("skip applying release actions to aggregation repo, not in list of source repositories") + log.Debug("skip applying release actions to aggregation repo, not in list of source repositories") return nil } @@ -120,7 +120,7 @@ func (r *AggregateReleases) AggregateRelease(ctx context.Context, p *AggregateRe trimmed := strings.TrimPrefix(tag, "v") _, err := semver.NewVersion(trimmed) if err != nil { - log.Infow("skip applying release actions to aggregation repo because not a valid semver release tag", "error", err) + log.Info("skip applying release actions to aggregation repo because not a valid semver release tag", "error", err) return nil } @@ -136,7 +136,7 @@ func (r *AggregateReleases) AggregateRelease(ctx context.Context, p *AggregateRe } if frozen { - log.Infow("skip applying release actions to aggregation repo because release is currently frozen") + log.Info("skip applying release actions to aggregation repo because release is currently frozen") _, _, err = r.client.GetV3Client().Issues.CreateComment(ctx, r.client.Organization(), r.repoName, *openPR.Number, &v3.IssueComment{ Body: v3.String(fmt.Sprintf(":warning: Release `%v` in repository %s (issued by @%s) was rejected because release is currently frozen. Please re-issue the release hook once this branch was merged or unfrozen.", @@ -193,12 +193,12 @@ func (r *AggregateReleases) AggregateRelease(ctx context.Context, p *AggregateRe hash, err := git.CommitAndPush(repository, commitMessage) if err != nil { if errors.Is(err, git.NoChangesError) { - log.Debugw("skip push to target repository because nothing changed") + log.Debug("skip push to target repository because nothing changed") } else { return fmt.Errorf("error pushing to target repository %w", err) } } else { - log.Infow("pushed to aggregate target repo", "branch", r.branch, "hash", hash) + log.Info("pushed to aggregate target repo", "branch", r.branch, "hash", hash) once.Do(func() { r.lock.Unlock() }) } @@ -215,7 +215,7 @@ func (r *AggregateReleases) AggregateRelease(ctx context.Context, p *AggregateRe return err } } else { - log.Infow("created pull request", "url", pr.GetURL()) + log.Info("created pull request", "url", pr.GetURL()) } return nil diff --git a/pkg/webhooks/github/actions/common.go b/pkg/webhooks/github/actions/common.go index 90d5dd9..a97462c 100644 --- a/pkg/webhooks/github/actions/common.go +++ b/pkg/webhooks/github/actions/common.go @@ -3,13 +3,13 @@ package actions import ( "context" "fmt" + "log/slog" "strconv" "strings" "github.com/metal-stack/metal-robot/pkg/clients" "github.com/metal-stack/metal-robot/pkg/config" "github.com/metal-stack/metal-robot/pkg/webhooks/constants" - "go.uber.org/zap" "golang.org/x/sync/errgroup" ghwebhooks "github.com/go-playground/webhooks/v6/github" @@ -26,7 +26,7 @@ const ( ) type WebhookActions struct { - logger *zap.SugaredLogger + logger *slog.Logger rm []*repositoryMaintainers dp []*docsPreviewComment ar []*AggregateReleases @@ -36,7 +36,7 @@ type WebhookActions struct { yr []*yamlTranslateReleases } -func InitActions(logger *zap.SugaredLogger, cs clients.ClientMap, config config.WebhookActions) (*WebhookActions, error) { +func InitActions(logger *slog.Logger, cs clients.ClientMap, config config.WebhookActions) (*WebhookActions, error) { actions := WebhookActions{ logger: logger, } @@ -100,7 +100,7 @@ func InitActions(logger *zap.SugaredLogger, cs clients.ClientMap, config config. return nil, fmt.Errorf("handler type not supported: %s", t) } - logger.Debugw("initialized github webhook action", "name", spec.Type) + logger.Debug("initialized github webhook action", "name", spec.Type) } return &actions, nil @@ -125,7 +125,7 @@ func (w *WebhookActions) ProcessReleaseEvent(ctx context.Context, payload *ghweb } err := a.AggregateRelease(ctx, params) if err != nil { - w.logger.Errorw("error in aggregate release action", "source-repo", params.RepositoryName, "target-repo", a.repoName, "tag", params.TagName, "error", err) + w.logger.Error("error in aggregate release action", "source-repo", params.RepositoryName, "target-repo", a.repoName, "tag", params.TagName, "error", err) return err } @@ -147,7 +147,7 @@ func (w *WebhookActions) ProcessReleaseEvent(ctx context.Context, payload *ghweb } err := a.draft(ctx, params) if err != nil { - w.logger.Errorw("error creating release draft", "repo", a.repoName, "tag", params.TagName, "error", err) + w.logger.Error("error creating release draft", "repo", a.repoName, "tag", params.TagName, "error", err) return err } @@ -168,7 +168,7 @@ func (w *WebhookActions) ProcessReleaseEvent(ctx context.Context, payload *ghweb } err := a.translateRelease(ctx, params) if err != nil { - w.logger.Errorw("error creating translating release", "repo", a.repoName, "tag", params.TagName, "error", err) + w.logger.Error("error creating translating release", "repo", a.repoName, "tag", params.TagName, "error", err) return err } @@ -177,7 +177,7 @@ func (w *WebhookActions) ProcessReleaseEvent(ctx context.Context, payload *ghweb } if err := g.Wait(); err != nil { - w.logger.Errorw("errors processing event", "error", err) + w.logger.Error("errors processing event", "error", err) } } @@ -197,7 +197,7 @@ func (w *WebhookActions) ProcessPullRequestEvent(ctx context.Context, payload *g } err := a.AddDocsPreviewComment(ctx, params) if err != nil { - w.logger.Errorw("error adding docs preview comment to docs", "repo", payload.Repository.Name, "pull_request", params.PullRequestNumber, "error", err) + w.logger.Error("error adding docs preview comment to docs", "repo", payload.Repository.Name, "pull_request", params.PullRequestNumber, "error", err) return err } @@ -224,7 +224,7 @@ func (w *WebhookActions) ProcessPullRequestEvent(ctx context.Context, payload *g } err := a.appendMergedPR(ctx, payload.PullRequest.Title, payload.PullRequest.Number, payload.PullRequest.User.Login, params) if err != nil { - w.logger.Errorw("error append merged PR to release draft", "repo", a.repoName, "pr", payload.PullRequest.Title, "error", err) + w.logger.Error("error append merged PR to release draft", "repo", a.repoName, "pr", payload.PullRequest.Title, "error", err) return err } @@ -233,7 +233,7 @@ func (w *WebhookActions) ProcessPullRequestEvent(ctx context.Context, payload *g } if err := g.Wait(); err != nil { - w.logger.Errorw("errors processing event", "error", err) + w.logger.Error("errors processing event", "error", err) } } @@ -257,7 +257,7 @@ func (w *WebhookActions) ProcessPushEvent(ctx context.Context, payload *ghwebhoo err := a.AggregateRelease(ctx, params) if err != nil { - w.logger.Errorw("error in aggregate release action", "source-repo", params.RepositoryName, "target-repo", a.repoName, "tag", params.TagName, "error", err) + w.logger.Error("error in aggregate release action", "source-repo", params.RepositoryName, "target-repo", a.repoName, "tag", params.TagName, "error", err) return err } @@ -279,7 +279,7 @@ func (w *WebhookActions) ProcessPushEvent(ctx context.Context, payload *ghwebhoo err := a.DistributeRelease(ctx, params) if err != nil { - w.logger.Errorw("error in distribute release action", "source-repo", params.RepositoryName, "tag", params.TagName, "error", err) + w.logger.Error("error in distribute release action", "source-repo", params.RepositoryName, "tag", params.TagName, "error", err) return err } @@ -288,7 +288,7 @@ func (w *WebhookActions) ProcessPushEvent(ctx context.Context, payload *ghwebhoo } if err := g.Wait(); err != nil { - w.logger.Errorw("errors processing event", "error", err) + w.logger.Error("errors processing event", "error", err) } } @@ -310,7 +310,7 @@ func (w *WebhookActions) ProcessRepositoryEvent(ctx context.Context, payload *gh } err := a.CreateRepositoryMaintainers(ctx, params) if err != nil { - w.logger.Errorw("error creating repository maintainers team", "repo", params.RepositoryName, "error", err) + w.logger.Error("error creating repository maintainers team", "repo", params.RepositoryName, "error", err) return err } @@ -319,7 +319,7 @@ func (w *WebhookActions) ProcessRepositoryEvent(ctx context.Context, payload *gh } if err := g.Wait(); err != nil { - w.logger.Errorw("errors processing event", "error", err) + w.logger.Error("errors processing event", "error", err) } } @@ -356,7 +356,7 @@ func (w *WebhookActions) ProcessIssueCommentEvent(ctx context.Context, payload * err = i.HandleIssueComment(ctx, params) if err != nil { - w.logger.Errorw("error in issue comment handler action", "source-repo", params.RepositoryName, "error", err) + w.logger.Error("error in issue comment handler action", "source-repo", params.RepositoryName, "error", err) return err } @@ -365,7 +365,7 @@ func (w *WebhookActions) ProcessIssueCommentEvent(ctx context.Context, payload * } if err := g.Wait(); err != nil { - w.logger.Errorw("errors processing event", "error", err) + w.logger.Error("errors processing event", "error", err) } } diff --git a/pkg/webhooks/github/actions/distribute_releases.go b/pkg/webhooks/github/actions/distribute_releases.go index c946d8a..37314c9 100644 --- a/pkg/webhooks/github/actions/distribute_releases.go +++ b/pkg/webhooks/github/actions/distribute_releases.go @@ -3,6 +3,7 @@ package actions import ( "context" "fmt" + "log/slog" "net/url" "strings" "sync" @@ -17,7 +18,6 @@ import ( "github.com/metal-stack/metal-robot/pkg/git" filepatchers "github.com/metal-stack/metal-robot/pkg/webhooks/modifiers/file-patchers" "github.com/mitchellh/mapstructure" - "go.uber.org/zap" "golang.org/x/sync/errgroup" ) @@ -27,7 +27,7 @@ type distributeReleaseParams struct { } type distributeReleases struct { - logger *zap.SugaredLogger + logger *slog.Logger client *clients.Github commitMessageTemplate string branchTemplate string @@ -42,7 +42,7 @@ type targetRepo struct { url string } -func newDistributeReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*distributeReleases, error) { +func newDistributeReleases(logger *slog.Logger, client *clients.Github, rawConfig map[string]any) (*distributeReleases, error) { var ( commitMessageTemplate = "Bump %s to version %s" branchTemplate = "auto-generate/%s" @@ -104,13 +104,13 @@ func newDistributeReleases(logger *zap.SugaredLogger, client *clients.Github, ra // DistributeRelease applies the actions to a given list of target repositories after a push or release trigger on the source repository func (d *distributeReleases) DistributeRelease(ctx context.Context, p *distributeReleaseParams) error { if p.RepositoryName != d.repoName { - d.logger.Debugw("skip applying release actions to target repos, not triggered by source repo", "source-repo", d.repoName, "trigger-repo", p.RepositoryName, "tag", p.TagName) + d.logger.Debug("skip applying release actions to target repos, not triggered by source repo", "source-repo", d.repoName, "trigger-repo", p.RepositoryName, "tag", p.TagName) return nil } tag := p.TagName if !strings.HasPrefix(tag, "v") { - d.logger.Debugw("skip applying release actions to target repos because release tag not starting with v", "source-repo", p.RepositoryName, "tag", p.TagName) + d.logger.Debug("skip applying release actions to target repos because release tag not starting with v", "source-repo", p.RepositoryName, "tag", p.TagName) return nil } @@ -118,12 +118,12 @@ func (d *distributeReleases) DistributeRelease(ctx context.Context, p *distribut parsedVersion, err := semver.NewVersion(trimmed) if err != nil { - d.logger.Infow("skip applying release actions to target repos because not a valid semver release tag", "source-repo", d.repoName, "trigger-repo", p.RepositoryName, "tag", p.TagName) + d.logger.Info("skip applying release actions to target repos because not a valid semver release tag", "source-repo", d.repoName, "trigger-repo", p.RepositoryName, "tag", p.TagName) return nil //nolint:nilerr } if parsedVersion.Prerelease() != "" { - d.logger.Infow("skip applying release actions to target repos because is a pre-release", "source-repo", d.repoName, "trigger-repo", p.RepositoryName, "tag", p.TagName) + d.logger.Info("skip applying release actions to target repos because is a pre-release", "source-repo", d.repoName, "trigger-repo", p.RepositoryName, "tag", p.TagName) return nil //nolint:nilerr } @@ -180,13 +180,13 @@ func (d *distributeReleases) DistributeRelease(ctx context.Context, p *distribut hash, err := git.CommitAndPush(r, commitMessage) if err != nil { if errors.Is(err, git.NoChangesError) { - d.logger.Debugw("skip applying release actions to target repo because nothing changed", "source-repo", p.RepositoryName, "target-repo", targetRepoName, "tag", p.TagName) + d.logger.Debug("skip applying release actions to target repo because nothing changed", "source-repo", p.RepositoryName, "target-repo", targetRepoName, "tag", p.TagName) return nil } return fmt.Errorf("error applying release updates %w", err) } - d.logger.Infow("pushed to target repo", "source-repo", p.RepositoryName, "target-repo", targetRepoName, "release", tag, "branch", prBranch, "hash", hash) + d.logger.Info("pushed to target repo", "source-repo", p.RepositoryName, "target-repo", targetRepoName, "release", tag, "branch", prBranch, "hash", hash) once.Do(func() { lock.Unlock() }) @@ -202,7 +202,7 @@ func (d *distributeReleases) DistributeRelease(ctx context.Context, p *distribut return err } } else { - d.logger.Infow("created pull request for target repo", "source-repo", p.RepositoryName, "target-repo", targetRepoName, "release", tag, "url", pr.GetURL()) + d.logger.Info("created pull request for target repo", "source-repo", p.RepositoryName, "target-repo", targetRepoName, "release", tag, "url", pr.GetURL()) } return nil @@ -210,7 +210,7 @@ func (d *distributeReleases) DistributeRelease(ctx context.Context, p *distribut } if err := g.Wait(); err != nil { - d.logger.Errorw("errors occurred while applying release actions to target repos", "error", err) + d.logger.Error("errors occurred while applying release actions to target repos", "error", err) } return nil diff --git a/pkg/webhooks/github/actions/docs_preview_comment.go b/pkg/webhooks/github/actions/docs_preview_comment.go index f59c4f1..4f824af 100644 --- a/pkg/webhooks/github/actions/docs_preview_comment.go +++ b/pkg/webhooks/github/actions/docs_preview_comment.go @@ -3,18 +3,18 @@ package actions import ( "context" "fmt" + "log/slog" v3 "github.com/google/go-github/v57/github" "github.com/metal-stack/metal-robot/pkg/clients" "github.com/metal-stack/metal-robot/pkg/config" "github.com/mitchellh/mapstructure" - "go.uber.org/zap" ) const () type docsPreviewComment struct { - logger *zap.SugaredLogger + logger *slog.Logger client *clients.Github commentTemplate string repositoryName string @@ -24,7 +24,7 @@ type docsPreviewCommentParams struct { PullRequestNumber int } -func newDocsPreviewComment(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*docsPreviewComment, error) { +func newDocsPreviewComment(logger *slog.Logger, client *clients.Github, rawConfig map[string]any) (*docsPreviewComment, error) { var ( commentTemplate = "#%d" ) @@ -66,7 +66,7 @@ func (d *docsPreviewComment) AddDocsPreviewComment(ctx context.Context, p *docsP return fmt.Errorf("error creating pull request comment in docs repo %w", err) } - d.logger.Infow("added preview comment in docs repo", "url", c.GetURL()) + d.logger.Info("added preview comment in docs repo", "url", c.GetURL()) return nil } diff --git a/pkg/webhooks/github/actions/issues_handler.go b/pkg/webhooks/github/actions/issues_handler.go index d77a4ce..1ae6f60 100644 --- a/pkg/webhooks/github/actions/issues_handler.go +++ b/pkg/webhooks/github/actions/issues_handler.go @@ -3,6 +3,7 @@ package actions import ( "context" "fmt" + "log/slog" "net/url" "strings" @@ -10,7 +11,6 @@ import ( "github.com/metal-stack/metal-robot/pkg/config" "github.com/metal-stack/metal-robot/pkg/git" "github.com/mitchellh/mapstructure" - "go.uber.org/zap" ) type IssueCommentCommand string @@ -33,7 +33,7 @@ var ( ) type IssuesAction struct { - logger *zap.SugaredLogger + logger *slog.Logger client *clients.Github targetRepos map[string]bool @@ -48,7 +48,7 @@ type IssuesActionParams struct { User string } -func NewIssuesAction(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*IssuesAction, error) { +func NewIssuesAction(logger *slog.Logger, client *clients.Github, rawConfig map[string]any) (*IssuesAction, error) { var typedConfig config.IssuesCommentHandlerConfig err := mapstructure.Decode(rawConfig, &typedConfig) if err != nil { @@ -70,7 +70,7 @@ func NewIssuesAction(logger *zap.SugaredLogger, client *clients.Github, rawConfi func (r *IssuesAction) HandleIssueComment(ctx context.Context, p *IssuesActionParams) error { _, ok := r.targetRepos[p.RepositoryName] if !ok { - r.logger.Debugw("skip handling issues comment action, not in list of target repositories", "source-repo", p.RepositoryName) + r.logger.Debug("skip handling issues comment action, not in list of target repositories", "source-repo", p.RepositoryName) return nil } @@ -83,7 +83,7 @@ func (r *IssuesAction) HandleIssueComment(ctx context.Context, p *IssuesActionPa case "admin": // fallthrough default: - r.logger.Debugw("skip handling issues comment action, author does not have admin permissions on this repo", "source-repo", p.RepositoryName, "author", p.User) + r.logger.Debug("skip handling issues comment action, author does not have admin permissions on this repo", "source-repo", p.RepositoryName, "author", p.User) return nil } @@ -111,7 +111,7 @@ func (r *IssuesAction) buildForkPR(ctx context.Context, p *IssuesActionParams) e } if pullRequest.Head.Repo.Fork == nil || !*pullRequest.Head.Repo.Fork { - r.logger.Debugw("skip handling issues comment action, pull request is not from a fork", "source-repo", p.RepositoryName) + r.logger.Debug("skip handling issues comment action, pull request is not from a fork", "source-repo", p.RepositoryName) return nil } @@ -133,7 +133,7 @@ func (r *IssuesAction) buildForkPR(ctx context.Context, p *IssuesActionParams) e return fmt.Errorf("error pushing to target remote repository %w", err) } - r.logger.Infow("triggered fork build action by pushing to fork-build branch", "source-repo", p.RepositoryName, "branch", headRef) + r.logger.Info("triggered fork build action by pushing to fork-build branch", "source-repo", p.RepositoryName, "branch", headRef) _, _, err = r.client.GetV3Client().Reactions.CreateIssueCommentReaction(ctx, r.client.Organization(), p.RepositoryName, p.CommentID, "rocket") if err != nil { @@ -177,7 +177,7 @@ func (r *IssuesAction) tag(ctx context.Context, p *IssuesActionParams, args []st return err } - r.logger.Infow("pushed tag to repo", "repo", p.RepositoryName, "branch", headRef, "tag", tag) + r.logger.Info("pushed tag to repo", "repo", p.RepositoryName, "branch", headRef, "tag", tag) return nil } diff --git a/pkg/webhooks/github/actions/release_drafter.go b/pkg/webhooks/github/actions/release_drafter.go index e2194ff..202d67b 100644 --- a/pkg/webhooks/github/actions/release_drafter.go +++ b/pkg/webhooks/github/actions/release_drafter.go @@ -3,6 +3,7 @@ package actions import ( "context" "fmt" + "log/slog" "regexp" "strings" @@ -13,7 +14,6 @@ import ( "github.com/metal-stack/metal-robot/pkg/markdown" "github.com/metal-stack/metal-robot/pkg/utils" "github.com/mitchellh/mapstructure" - "go.uber.org/zap" v3 "github.com/google/go-github/v57/github" ) @@ -38,7 +38,7 @@ type codeBlock struct { } type releaseDrafter struct { - logger *zap.SugaredLogger + logger *slog.Logger client *clients.Github branch string branchBase string @@ -57,7 +57,7 @@ type releaseDrafterParams struct { ReleaseURL string } -func newReleaseDrafter(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*releaseDrafter, error) { +func newReleaseDrafter(logger *slog.Logger, client *clients.Github, rawConfig map[string]any) (*releaseDrafter, error) { var ( releaseTitleTemplate = "%s" draftHeadline = "General" @@ -123,7 +123,7 @@ func (r *releaseDrafter) draft(ctx context.Context, p *releaseDrafterParams) err // if there is an ACTIONS_REQUIRED block, we want to add it (even when it's not a release vector repository) if p.ComponentReleaseInfo == nil { - log.Debugw("skip adding release draft because not a release vector repo and no special sections") + log.Debug("skip adding release draft because not a release vector repo and no special sections") return nil } @@ -141,7 +141,7 @@ func (r *releaseDrafter) draft(ctx context.Context, p *releaseDrafterParams) err } err = r.prependCodeBlocks(m, *p.ComponentReleaseInfo, releaseSuffix) if err != nil { - log.Debugw("skip adding release draft", "reason", err) + log.Debug("skip adding release draft", "reason", err) return nil } @@ -152,13 +152,13 @@ func (r *releaseDrafter) draft(ctx context.Context, p *releaseDrafterParams) err componentTag := p.TagName if !strings.HasPrefix(componentTag, "v") { - log.Debugw("skip adding release draft because tag not starting with v") + log.Debug("skip adding release draft because tag not starting with v") return nil } trimmedVersion := strings.TrimPrefix(componentTag, "v") componentSemver, err := semver.NewVersion(trimmedVersion) if err != nil { - log.Debugw("skip adding release draft because tag is not semver compatible") + log.Debug("skip adding release draft because tag is not semver compatible") return nil //nolint:nilerr } @@ -174,7 +174,7 @@ func (r *releaseDrafter) draft(ctx context.Context, p *releaseDrafterParams) err } if frozen { - log.Infow("skip adding release draft because release is currently frozen") + log.Info("skip adding release draft because release is currently frozen") return nil } } @@ -262,7 +262,7 @@ func (r *releaseDrafter) appendMergedPR(ctx context.Context, title string, numbe // if there is an ACTIONS_REQUIRED block, we want to add it (even when it's a release vector handled repository) if p.ComponentReleaseInfo == nil { - r.logger.Debugw("skip adding merged pull request to release draft because of special handling in release vector", "repo", p.RepositoryName) + r.logger.Debug("skip adding merged pull request to release draft because of special handling in release vector", "repo", p.RepositoryName) return nil } @@ -276,7 +276,7 @@ func (r *releaseDrafter) appendMergedPR(ctx context.Context, title string, numbe issueSuffix := fmt.Sprintf("(%s/%s#%d)", r.client.Organization(), p.RepositoryName, number) err = r.prependCodeBlocks(m, *p.ComponentReleaseInfo, &issueSuffix) if err != nil { - r.logger.Debugw("skip adding merged pull request to release draft", "reason", err, "repo", p.RepositoryName) + r.logger.Debug("skip adding merged pull request to release draft", "reason", err, "repo", p.RepositoryName) return nil } @@ -437,7 +437,7 @@ func (r *releaseDrafter) guessNextVersionFromLatestRelease(ctx context.Context) t = strings.TrimPrefix(t, "v") latestTag, err := semver.NewVersion(t) if err != nil { - r.logger.Warnw("latest release of repository was not a semver tag", "repository", r.repoName, "latest-tag", *latest.TagName) + r.logger.Warn("latest release of repository was not a semver tag", "repository", r.repoName, "latest-tag", *latest.TagName) } else { return "v" + latestTag.IncPatch().String(), nil } @@ -478,7 +478,7 @@ func (r *releaseDrafter) createOrUpdateRelease(ctx context.Context, infos *relea if err != nil { return fmt.Errorf("unable to update release draft %w", err) } - r.logger.Infow("release draft updated", "repository", r.repoName, "trigger-component", p.RepositoryName, "version", p.TagName) + r.logger.Info("release draft updated", "repository", r.repoName, "trigger-component", p.RepositoryName, "version", p.TagName) } else { newDraft := &github.RepositoryRelease{ TagName: v3.String(infos.releaseTag), @@ -490,7 +490,7 @@ func (r *releaseDrafter) createOrUpdateRelease(ctx context.Context, infos *relea if err != nil { return fmt.Errorf("unable to create release draft %w", err) } - r.logger.Infow("new release draft created", "repository", r.repoName, "trigger-component", p.RepositoryName, "version", p.TagName) + r.logger.Info("new release draft created", "repository", r.repoName, "trigger-component", p.RepositoryName, "version", p.TagName) } return nil diff --git a/pkg/webhooks/github/actions/release_drafter_test.go b/pkg/webhooks/github/actions/release_drafter_test.go index cc9064d..7a082cd 100644 --- a/pkg/webhooks/github/actions/release_drafter_test.go +++ b/pkg/webhooks/github/actions/release_drafter_test.go @@ -1,12 +1,12 @@ package actions import ( + "log/slog" "testing" "github.com/Masterminds/semver/v3" "github.com/google/go-cmp/cmp" v3 "github.com/google/go-github/v57/github" - "go.uber.org/zap/zaptest" ) func TestReleaseDrafter_updateReleaseBody(t *testing.T) { @@ -191,7 +191,7 @@ Some description tt := tt t.Run(tt.name, func(t *testing.T) { r := &releaseDrafter{ - logger: zaptest.NewLogger(t).Sugar(), + logger: slog.Default(), client: nil, draftHeadline: tt.headline, } @@ -319,7 +319,7 @@ Some description t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) { r := &releaseDrafter{ - logger: zaptest.NewLogger(t).Sugar(), + logger: slog.Default(), client: nil, prHeadline: "Merged Pull Requests", draftHeadline: "General", diff --git a/pkg/webhooks/github/actions/repository_maintainers.go b/pkg/webhooks/github/actions/repository_maintainers.go index 2b06b8e..59f9797 100644 --- a/pkg/webhooks/github/actions/repository_maintainers.go +++ b/pkg/webhooks/github/actions/repository_maintainers.go @@ -3,17 +3,17 @@ package actions import ( "context" "fmt" + "log/slog" "strings" v3 "github.com/google/go-github/v57/github" "github.com/metal-stack/metal-robot/pkg/clients" "github.com/metal-stack/metal-robot/pkg/config" "github.com/mitchellh/mapstructure" - "go.uber.org/zap" ) type repositoryMaintainers struct { - logger *zap.SugaredLogger + logger *slog.Logger client *clients.Github suffix string additionalTeams repositoryAdditionalMemberships @@ -31,7 +31,7 @@ type repositoryMaintainersParams struct { Creator string } -func newCreateRepositoryMaintainers(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*repositoryMaintainers, error) { +func newCreateRepositoryMaintainers(logger *slog.Logger, client *clients.Github, rawConfig map[string]any) (*repositoryMaintainers, error) { var ( suffix = "-maintainers" ) @@ -78,12 +78,12 @@ func (r *repositoryMaintainers) CreateRepositoryMaintainers(ctx context.Context, }) if err != nil { if strings.Contains(err.Error(), "Name must be unique for this org") { - r.logger.Infow("maintainers team for repository already exists", "repository", p.RepositoryName, "team", name) + r.logger.Info("maintainers team for repository already exists", "repository", p.RepositoryName, "team", name) } else { return fmt.Errorf("error creating maintainers team %w", err) } } else { - r.logger.Infow("created new maintainers team for repository", "repository", p.RepositoryName, "team", name) + r.logger.Info("created new maintainers team for repository", "repository", p.RepositoryName, "team", name) } memberships := []repositoryTeamMembership{ @@ -103,7 +103,7 @@ func (r *repositoryMaintainers) CreateRepositoryMaintainers(ctx context.Context, if err != nil { return fmt.Errorf("error adding team membership: %w", err) } else { - r.logger.Infow("added team to repository", "repository", p.RepositoryName, "team", team.teamSlug, "permission", team.permission) + r.logger.Info("added team to repository", "repository", p.RepositoryName, "team", team.teamSlug, "permission", team.permission) } } diff --git a/pkg/webhooks/github/actions/yaml_translate_releases.go b/pkg/webhooks/github/actions/yaml_translate_releases.go index ef3cb9a..5a03146 100644 --- a/pkg/webhooks/github/actions/yaml_translate_releases.go +++ b/pkg/webhooks/github/actions/yaml_translate_releases.go @@ -3,6 +3,7 @@ package actions import ( "context" "fmt" + "log/slog" "net/url" "strings" "sync" @@ -17,11 +18,10 @@ import ( "github.com/metal-stack/metal-robot/pkg/git" filepatchers "github.com/metal-stack/metal-robot/pkg/webhooks/modifiers/file-patchers" "github.com/mitchellh/mapstructure" - "go.uber.org/zap" ) type yamlTranslateReleases struct { - logger *zap.SugaredLogger + logger *slog.Logger client *clients.Github branch string branchBase string @@ -50,7 +50,7 @@ type yamlTranslateReleaseParams struct { TagName string } -func newYAMLTranslateReleases(logger *zap.SugaredLogger, client *clients.Github, rawConfig map[string]any) (*yamlTranslateReleases, error) { +func newYAMLTranslateReleases(logger *slog.Logger, client *clients.Github, rawConfig map[string]any) (*yamlTranslateReleases, error) { var ( branch = "develop" branchBase = "master" @@ -131,7 +131,7 @@ func newYAMLTranslateReleases(logger *zap.SugaredLogger, client *clients.Github, func (r *yamlTranslateReleases) translateRelease(ctx context.Context, p *yamlTranslateReleaseParams) error { translations, ok := r.translationMap[p.RepositoryName] if !ok { - r.logger.Debugw("skip applying translate release actions to aggregation repo, not in list of source repositories", "target-repo", r.repoName, "source-repo", p.RepositoryName, "tag", p.TagName) + r.logger.Debug("skip applying translate release actions to aggregation repo, not in list of source repositories", "target-repo", r.repoName, "source-repo", p.RepositoryName, "tag", p.TagName) return nil } @@ -139,7 +139,7 @@ func (r *yamlTranslateReleases) translateRelease(ctx context.Context, p *yamlTra trimmed := strings.TrimPrefix(tag, "v") _, err := semver.NewVersion(trimmed) if err != nil { - r.logger.Infow("skip applying translate release actions to aggregation repo because not a valid semver release tag", "target-repo", r.repoName, "source-repo", p.RepositoryName, "tag", p.TagName) + r.logger.Info("skip applying translate release actions to aggregation repo because not a valid semver release tag", "target-repo", r.repoName, "source-repo", p.RepositoryName, "tag", p.TagName) return nil //nolint:nilerr } @@ -206,13 +206,13 @@ func (r *yamlTranslateReleases) translateRelease(ctx context.Context, p *yamlTra hash, err := git.CommitAndPush(targetRepository, commitMessage) if err != nil { if errors.Is(err, git.NoChangesError) { - r.logger.Debugw("skip push to target repository because nothing changed", "target-repo", p.RepositoryName, "source-repo", p.RepositoryName, "release", tag) + r.logger.Debug("skip push to target repository because nothing changed", "target-repo", p.RepositoryName, "source-repo", p.RepositoryName, "release", tag) return nil } return fmt.Errorf("error pushing to target repository %w", err) } - r.logger.Infow("pushed to translate target repo", "target-repo", p.RepositoryName, "source-repo", p.RepositoryName, "release", tag, "branch", r.branch, "hash", hash) + r.logger.Info("pushed to translate target repo", "target-repo", p.RepositoryName, "source-repo", p.RepositoryName, "release", tag, "branch", r.branch, "hash", hash) once.Do(func() { r.lock.Unlock() }) @@ -228,7 +228,7 @@ func (r *yamlTranslateReleases) translateRelease(ctx context.Context, p *yamlTra return err } } else { - r.logger.Infow("created pull request", "target-repo", p.RepositoryName, "url", pr.GetURL()) + r.logger.Info("created pull request", "target-repo", p.RepositoryName, "url", pr.GetURL()) } return nil diff --git a/pkg/webhooks/github/github.go b/pkg/webhooks/github/github.go index 6bb3559..2efe379 100644 --- a/pkg/webhooks/github/github.go +++ b/pkg/webhooks/github/github.go @@ -3,13 +3,13 @@ package github import ( "context" "errors" + "log/slog" "net/http" ghwebhooks "github.com/go-playground/webhooks/v6/github" "github.com/metal-stack/metal-robot/pkg/clients" "github.com/metal-stack/metal-robot/pkg/config" "github.com/metal-stack/metal-robot/pkg/webhooks/github/actions" - "go.uber.org/zap" ) var listenEvents = []ghwebhooks.Event{ @@ -22,14 +22,14 @@ var listenEvents = []ghwebhooks.Event{ } type Webhook struct { - logger *zap.SugaredLogger + logger *slog.Logger cs clients.ClientMap hook *ghwebhooks.Webhook a *actions.WebhookActions } // NewGithubWebhook returns a new webhook controller -func NewGithubWebhook(logger *zap.SugaredLogger, w config.Webhook, cs clients.ClientMap) (*Webhook, error) { +func NewGithubWebhook(logger *slog.Logger, w config.Webhook, cs clients.ClientMap) (*Webhook, error) { hook, err := ghwebhooks.New(ghwebhooks.Options.Secret(w.Secret)) if err != nil { return nil, err @@ -55,10 +55,10 @@ func (w *Webhook) Handle(response http.ResponseWriter, request *http.Request) { payload, err := w.hook.Parse(request, listenEvents...) if err != nil { if errors.Is(err, ghwebhooks.ErrEventNotFound) { - w.logger.Warnw("received unregistered github event", "error", err) + w.logger.Warn("received unregistered github event", "error", err) response.WriteHeader(http.StatusOK) } else { - w.logger.Errorw("received malformed github event", "error", err) + w.logger.Error("received malformed github event", "error", err) response.WriteHeader(http.StatusInternalServerError) } return @@ -67,29 +67,29 @@ func (w *Webhook) Handle(response http.ResponseWriter, request *http.Request) { ctx := context.Background() switch payload := payload.(type) { case ghwebhooks.ReleasePayload: - w.logger.Debugw("received release event") + w.logger.Debug("received release event") // nolint:contextcheck go w.a.ProcessReleaseEvent(ctx, &payload) case ghwebhooks.PullRequestPayload: - w.logger.Debugw("received pull request event") + w.logger.Debug("received pull request event") // nolint:contextcheck go w.a.ProcessPullRequestEvent(ctx, &payload) case ghwebhooks.PushPayload: - w.logger.Debugw("received push event") + w.logger.Debug("received push event") // nolint:contextcheck go w.a.ProcessPushEvent(ctx, &payload) case ghwebhooks.IssuesPayload: - w.logger.Debugw("received issues event") + w.logger.Debug("received issues event") case ghwebhooks.IssueCommentPayload: - w.logger.Debugw("received issue comment event") + w.logger.Debug("received issue comment event") // nolint:contextcheck go w.a.ProcessIssueCommentEvent(ctx, &payload) case ghwebhooks.RepositoryPayload: - w.logger.Debugw("received repository event") + w.logger.Debug("received repository event") // nolint:contextcheck go w.a.ProcessRepositoryEvent(ctx, &payload) default: - w.logger.Warnw("missing handler", "payload", payload) + w.logger.Warn("missing handler", "payload", payload) } response.WriteHeader(http.StatusOK) diff --git a/pkg/webhooks/gitlab/actions/common.go b/pkg/webhooks/gitlab/actions/common.go index 333c414..27a0769 100644 --- a/pkg/webhooks/gitlab/actions/common.go +++ b/pkg/webhooks/gitlab/actions/common.go @@ -3,24 +3,24 @@ package actions import ( "context" "fmt" + "log/slog" "strings" "github.com/metal-stack/metal-robot/pkg/clients" "github.com/metal-stack/metal-robot/pkg/config" "github.com/metal-stack/metal-robot/pkg/webhooks/constants" ghactions "github.com/metal-stack/metal-robot/pkg/webhooks/github/actions" - "go.uber.org/zap" "golang.org/x/sync/errgroup" glwebhooks "github.com/go-playground/webhooks/v6/gitlab" ) type WebhookActions struct { - logger *zap.SugaredLogger + logger *slog.Logger ar []*ghactions.AggregateReleases } -func InitActions(logger *zap.SugaredLogger, cs clients.ClientMap, config config.WebhookActions) (*WebhookActions, error) { +func InitActions(logger *slog.Logger, cs clients.ClientMap, config config.WebhookActions) (*WebhookActions, error) { actions := WebhookActions{ logger: logger, } @@ -46,7 +46,7 @@ func InitActions(logger *zap.SugaredLogger, cs clients.ClientMap, config config. return nil, fmt.Errorf("handler type not supported: %s", t) } - logger.Debugw("initialized github webhook action", "name", ghactions.ActionAggregateReleases) + logger.Debug("initialized github webhook action", "name", ghactions.ActionAggregateReleases) } return &actions, nil @@ -68,8 +68,8 @@ func (w *WebhookActions) ProcessTagEvent(ctx context.Context, payload *glwebhook } err := a.AggregateRelease(ctx, params) if err != nil { - w.logger.Errorw("error in aggregate release action", "release-repo", params, "repo", params.RepositoryName, "tag", params.TagName, "error", err) - w.logger.Errorw("error adding release to release vector", "repo", params.RepositoryName, "tag", extractTag(payload), "error", err) + w.logger.Error("error in aggregate release action", "release-repo", params, "repo", params.RepositoryName, "tag", params.TagName, "error", err) + w.logger.Error("error adding release to release vector", "repo", params.RepositoryName, "tag", extractTag(payload), "error", err) return err } @@ -78,7 +78,7 @@ func (w *WebhookActions) ProcessTagEvent(ctx context.Context, payload *glwebhook } if err := g.Wait(); err != nil { - w.logger.Errorw("errors processing event", "error", err) + w.logger.Error("errors processing event", "error", err) } } diff --git a/pkg/webhooks/gitlab/gitlab.go b/pkg/webhooks/gitlab/gitlab.go index 2239208..9e4c805 100644 --- a/pkg/webhooks/gitlab/gitlab.go +++ b/pkg/webhooks/gitlab/gitlab.go @@ -3,13 +3,13 @@ package gitlab import ( "context" "errors" + "log/slog" "net/http" glwebhooks "github.com/go-playground/webhooks/v6/gitlab" "github.com/metal-stack/metal-robot/pkg/clients" "github.com/metal-stack/metal-robot/pkg/config" "github.com/metal-stack/metal-robot/pkg/webhooks/gitlab/actions" - "go.uber.org/zap" ) var ( @@ -19,14 +19,14 @@ var ( ) type Webhook struct { - logger *zap.SugaredLogger + logger *slog.Logger cs clients.ClientMap hook *glwebhooks.Webhook a *actions.WebhookActions } // NewGitlabWebhook returns a new webhook controller -func NewGitlabWebhook(logger *zap.SugaredLogger, w config.Webhook, cs clients.ClientMap) (*Webhook, error) { +func NewGitlabWebhook(logger *slog.Logger, w config.Webhook, cs clients.ClientMap) (*Webhook, error) { hook, err := glwebhooks.New(glwebhooks.Options.Secret(w.Secret)) if err != nil { return nil, err @@ -52,10 +52,10 @@ func (w *Webhook) Handle(response http.ResponseWriter, request *http.Request) { payload, err := w.hook.Parse(request, listenEvents...) if err != nil { if errors.Is(err, glwebhooks.ErrEventNotFound) { - w.logger.Warnw("received unregistered gitlab event", "error", err) + w.logger.Warn("received unregistered gitlab event", "error", err) response.WriteHeader(http.StatusOK) } else { - w.logger.Errorw("received malformed gitlab event", "error", err) + w.logger.Error("received malformed gitlab event", "error", err) response.WriteHeader(http.StatusInternalServerError) } return @@ -64,11 +64,11 @@ func (w *Webhook) Handle(response http.ResponseWriter, request *http.Request) { ctx := context.Background() switch payload := payload.(type) { case glwebhooks.TagEventPayload: - w.logger.Debugw("received tag push event") + w.logger.Debug("received tag push event") // nolint:contextcheck w.a.ProcessTagEvent(ctx, &payload) default: - w.logger.Warnw("missing handler", "payload", payload) + w.logger.Warn("missing handler", "payload", payload) } response.WriteHeader(http.StatusOK)