diff --git a/cloudevents-server/Dockerfile b/cloudevents-server/Dockerfile index 5ada53b7..75f26154 100644 --- a/cloudevents-server/Dockerfile +++ b/cloudevents-server/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22.4 AS builder +FROM golang:1.23.1 AS builder COPY . /app RUN cd /app && go build -o server diff --git a/cloudevents-server/go.mod b/cloudevents-server/go.mod index 1adddf16..1e894e98 100644 --- a/cloudevents-server/go.mod +++ b/cloudevents-server/go.mod @@ -1,9 +1,12 @@ module github.com/PingCAP-QE/ee-apps/cloudevents-server -go 1.21 +go 1.23 + +toolchain go1.23.1 require ( entgo.io/ent v0.13.1 + github.com/Masterminds/sprig/v3 v3.3.0 github.com/cloudevents/sdk-go/v2 v2.15.2 github.com/gin-gonic/gin v1.10.0 github.com/go-sql-driver/mysql v1.8.1 @@ -11,26 +14,21 @@ require ( github.com/mattn/go-sqlite3 v1.14.22 github.com/pkg/errors v0.9.1 github.com/rs/zerolog v1.33.0 + github.com/segmentio/kafka-go v0.4.47 github.com/tektoncd/pipeline v0.39.0 gopkg.in/yaml.v3 v3.0.1 k8s.io/apimachinery v0.23.9 -) - -require ( - github.com/rogpeppe/go-internal v1.10.0 // indirect - github.com/xdg-go/pbkdf2 v1.0.0 // indirect - github.com/xdg-go/scram v1.1.2 // indirect - github.com/xdg-go/stringprep v1.0.4 // indirect + knative.dev/pkg v0.0.0-20220805012121-7b8b06028e4f ) require ( ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 // indirect contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d // indirect contrib.go.opencensus.io/exporter/prometheus v0.4.0 // indirect + dario.cat/mergo v1.0.1 // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/Masterminds/goutils v1.1.1 // indirect - github.com/Masterminds/semver/v3 v3.2.0 // indirect - github.com/Masterminds/sprig/v3 v3.2.3 + github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/agext/levenshtein v1.2.1 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -64,29 +62,28 @@ require ( github.com/google/go-cmp v0.6.0 // indirect github.com/google/go-containerregistry v0.8.1-0.20220216220642-00c59d91847c // indirect github.com/google/gofuzz v1.2.0 // indirect - github.com/google/uuid v1.4.0 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/googleapis/gnostic v0.5.5 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/hcl/v2 v2.13.0 // indirect - github.com/huandu/xstrings v1.3.3 // indirect + github.com/huandu/xstrings v1.5.0 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kelseyhightower/envconfig v1.4.0 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect - github.com/kr/pretty v0.3.1 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect - github.com/mitchellh/copystructure v1.0.0 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-wordwrap v1.0.0 // indirect - github.com/mitchellh/reflectwalk v1.0.1 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect @@ -97,12 +94,15 @@ require ( github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.6.0 // indirect github.com/prometheus/statsd_exporter v0.21.0 // indirect - github.com/segmentio/kafka-go v0.4.47 - github.com/shopspring/decimal v1.2.0 // indirect - github.com/spf13/cast v1.3.1 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect + github.com/shopspring/decimal v1.4.0 // indirect + github.com/spf13/cast v1.7.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect github.com/zclconf/go-cty v1.8.0 // indirect go.opencensus.io v0.24.0 // indirect go.uber.org/atomic v1.11.0 // indirect @@ -134,7 +134,6 @@ require ( k8s.io/klog/v2 v2.70.2-0.20220707122935-0990e81f1a8f // indirect k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf // indirect k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect - knative.dev/pkg v0.0.0-20220805012121-7b8b06028e4f sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect diff --git a/cloudevents-server/go.sum b/cloudevents-server/go.sum index c043400c..a82688d5 100644 --- a/cloudevents-server/go.sum +++ b/cloudevents-server/go.sum @@ -41,6 +41,8 @@ contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d h contrib.go.opencensus.io/exporter/ocagent v0.7.1-0.20200907061046-05415f1de66d/go.mod h1:IshRmMJBhDfFj5Y67nVhMYTTIze91RUeT73ipWKs/GY= contrib.go.opencensus.io/exporter/prometheus v0.4.0 h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs= contrib.go.opencensus.io/exporter/prometheus v0.4.0/go.mod h1:o7cosnyfuPVK0tB8q0QmaQNhGnptITnPQB+z1+qeFB0= +dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= +dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= entgo.io/ent v0.13.1 h1:uD8QwN1h6SNphdCCzmkMN3feSUzNnVvV/WIkHKMbzOE= entgo.io/ent v0.13.1/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A= @@ -59,10 +61,10 @@ github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20O github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= -github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= -github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= -github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= -github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= +github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= +github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= +github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= @@ -130,6 +132,8 @@ github.com/evanphx/json-patch/v5 v5.6.0 h1:b91NhWfaz02IuVxO9faSllyAtNXHMPkC5J8sJ github.com/evanphx/json-patch/v5 v5.6.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= @@ -262,10 +266,9 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= @@ -290,12 +293,11 @@ github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc= github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= -github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= +github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -355,14 +357,13 @@ github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxU github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= -github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= -github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/mitchellh/reflectwalk v1.0.1 h1:FVzMWA5RllMAKIdUSC8mdWo3XtwoecrH79BY70sEEpE= -github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= @@ -393,7 +394,6 @@ github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ= github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= -github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -428,7 +428,6 @@ github.com/prometheus/statsd_exporter v0.21.0 h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf github.com/prometheus/statsd_exporter v0.21.0/go.mod h1:rbT83sZq2V+p73lHhPZfMc3MLCHmSHelCh9hSGYNLTQ= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= @@ -438,14 +437,14 @@ github.com/segmentio/kafka-go v0.4.47 h1:IqziR4pA3vrZq7YdRxaT3w1/5fvIH5qpCwstUan github.com/segmentio/kafka-go v0.4.47/go.mod h1:HjF6XbOKh0Pjlkr5GVZxt6CsjjwnmhVOfURM5KMd8qg= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k= +github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= @@ -522,7 +521,6 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= @@ -607,7 +605,6 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211209124913-491a49abca63/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= @@ -699,7 +696,6 @@ golang.org/x/sys v0.0.0-20210831042530-f4d43177bf5e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -710,7 +706,6 @@ golang.org/x/sys v0.23.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.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= @@ -726,7 +721,6 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= diff --git a/cloudevents-server/handlers.go b/cloudevents-server/handlers.go index 3ed70b45..d33873f0 100644 --- a/cloudevents-server/handlers.go +++ b/cloudevents-server/handlers.go @@ -8,9 +8,9 @@ import ( "github.com/rs/zerolog/log" "github.com/PingCAP-QE/ee-apps/cloudevents-server/pkg/config" - "github.com/PingCAP-QE/ee-apps/cloudevents-server/pkg/events/custom/tekton" + "github.com/PingCAP-QE/ee-apps/cloudevents-server/pkg/events/tekton" "github.com/PingCAP-QE/ee-apps/cloudevents-server/pkg/events/custom/testcaserun" - "github.com/PingCAP-QE/ee-apps/cloudevents-server/pkg/events/custom/tibuild" + "github.com/PingCAP-QE/ee-apps/cloudevents-server/pkg/events/tibuild" "github.com/PingCAP-QE/ee-apps/cloudevents-server/pkg/events/handler" "github.com/PingCAP-QE/ee-apps/cloudevents-server/pkg/lark" ) diff --git a/cloudevents-server/pkg/config/config.go b/cloudevents-server/pkg/config/config.go index dc940983..62ce4821 100644 --- a/cloudevents-server/pkg/config/config.go +++ b/cloudevents-server/pkg/config/config.go @@ -76,7 +76,7 @@ type Config struct { func (c *Config) LoadFromFile(file string) error { content, err := os.ReadFile(file) if err != nil { - return fmt.Errorf("Failed to read file: %w", err) + return fmt.Errorf("failed to read file: %w", err) } ext := filepath.Ext(file) diff --git a/cloudevents-server/pkg/events/custom/testcaserun/handler.go b/cloudevents-server/pkg/events/custom/testcaserun/handler.go index 01d0044c..9c6b4196 100644 --- a/cloudevents-server/pkg/events/custom/testcaserun/handler.go +++ b/cloudevents-server/pkg/events/custom/testcaserun/handler.go @@ -3,7 +3,6 @@ package testcaserun import ( "context" - "net/http" "time" "github.com/PingCAP-QE/ee-apps/cloudevents-server/ent" @@ -33,7 +32,7 @@ func (h *Handler) SupportEventTypes() []string { func (h *Handler) Handle(event cloudevents.Event) cloudevents.Result { caseData := make(map[string]ProblemCasesFromBazel) if err := event.DataAs(&caseData); err != nil { - return cloudevents.NewHTTPResult(http.StatusBadRequest, err.Error()) + return cloudevents.NewReceipt(false, "invalid data: %v", err) } buildURL, _ := types.ToString(event.Extensions()["buildurl"]) @@ -42,7 +41,7 @@ func (h *Handler) Handle(event cloudevents.Event) cloudevents.Result { // Insert records if err := h.addRecords(context.Background(), caseData, repo, branch, buildURL); err != nil { - return cloudevents.NewHTTPResult(http.StatusInternalServerError, "insert failed: %v", err) + return cloudevents.NewReceipt(true, "insert database records failed: %v", err) } return cloudevents.ResultACK diff --git a/cloudevents-server/pkg/events/custom/types.go b/cloudevents-server/pkg/events/custom/types.go deleted file mode 100644 index e42100aa..00000000 --- a/cloudevents-server/pkg/events/custom/types.go +++ /dev/null @@ -1,5 +0,0 @@ -package custom - -const ( - EventTypeTestCaseRunReport = "test-case-run-report" -) diff --git a/cloudevents-server/pkg/events/handler/handler.go b/cloudevents-server/pkg/events/handler/handler.go index c30a79b4..87ca543b 100644 --- a/cloudevents-server/pkg/events/handler/handler.go +++ b/cloudevents-server/pkg/events/handler/handler.go @@ -1,8 +1,6 @@ package handler import ( - "net/http" - cloudevents "github.com/cloudevents/sdk-go/v2" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -28,7 +26,7 @@ func (h *CompositeEventHandler) Handle(event cloudevents.Event) cloudevents.Resu handlers, ok := h.handleMap[event.Type()] if !ok { log.Warn().Str("ce-type", event.Type()).Msg("no handlers registered for the event") - return cloudevents.NewHTTPResult(http.StatusNotFound, "no handlers registered for event type: %s, ignoring it", event.Type()) + return cloudevents.NewReceipt(false, "no handlers registered for the event") } var results []cloudevents.Result diff --git a/cloudevents-server/pkg/events/custom/tekton/handler.go b/cloudevents-server/pkg/events/tekton/handler.go similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/handler.go rename to cloudevents-server/pkg/events/tekton/handler.go diff --git a/cloudevents-server/pkg/events/custom/tekton/handler_pipelinerun.go b/cloudevents-server/pkg/events/tekton/handler_pipelinerun.go similarity index 96% rename from cloudevents-server/pkg/events/custom/tekton/handler_pipelinerun.go rename to cloudevents-server/pkg/events/tekton/handler_pipelinerun.go index 5b676334..cd81927a 100644 --- a/cloudevents-server/pkg/events/custom/tekton/handler_pipelinerun.go +++ b/cloudevents-server/pkg/events/tekton/handler_pipelinerun.go @@ -1,7 +1,6 @@ package tekton import ( - "net/http" "strings" cloudevents "github.com/cloudevents/sdk-go/v2" @@ -38,7 +37,7 @@ func (h *pipelineRunHandler) SupportEventTypes() []string { func (h *pipelineRunHandler) Handle(event cloudevents.Event) cloudevents.Result { data := new(tektoncloudevent.TektonCloudEventData) if err := event.DataAs(&data); err != nil { - return cloudevents.NewHTTPResult(http.StatusBadRequest, err.Error()) + return cloudevents.NewReceipt(false, "invalid data: %v", err) } switch tektoncloudevent.TektonEventType(event.Type()) { diff --git a/cloudevents-server/pkg/events/custom/tekton/handler_pipelinerun_test.go b/cloudevents-server/pkg/events/tekton/handler_pipelinerun_test.go similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/handler_pipelinerun_test.go rename to cloudevents-server/pkg/events/tekton/handler_pipelinerun_test.go diff --git a/cloudevents-server/pkg/events/custom/tekton/handler_taskrun.go b/cloudevents-server/pkg/events/tekton/handler_taskrun.go similarity index 96% rename from cloudevents-server/pkg/events/custom/tekton/handler_taskrun.go rename to cloudevents-server/pkg/events/tekton/handler_taskrun.go index a02a01b6..159e304c 100644 --- a/cloudevents-server/pkg/events/custom/tekton/handler_taskrun.go +++ b/cloudevents-server/pkg/events/tekton/handler_taskrun.go @@ -1,7 +1,6 @@ package tekton import ( - "net/http" "strings" cloudevents "github.com/cloudevents/sdk-go/v2" @@ -31,7 +30,7 @@ func (h *taskRunHandler) SupportEventTypes() []string { func (h *taskRunHandler) Handle(event cloudevents.Event) cloudevents.Result { data := new(tektoncloudevent.TektonCloudEventData) if err := event.DataAs(&data); err != nil { - return cloudevents.NewHTTPResult(http.StatusBadRequest, err.Error()) + return cloudevents.NewReceipt(false, "invalid data: %v", err) } switch event.Type() { diff --git a/cloudevents-server/pkg/events/custom/tekton/handler_taskrun_test.go b/cloudevents-server/pkg/events/tekton/handler_taskrun_test.go similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/handler_taskrun_test.go rename to cloudevents-server/pkg/events/tekton/handler_taskrun_test.go diff --git a/cloudevents-server/pkg/events/custom/tekton/handler_test.go b/cloudevents-server/pkg/events/tekton/handler_test.go similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/handler_test.go rename to cloudevents-server/pkg/events/tekton/handler_test.go diff --git a/cloudevents-server/pkg/events/custom/tekton/lark.go b/cloudevents-server/pkg/events/tekton/lark.go similarity index 94% rename from cloudevents-server/pkg/events/custom/tekton/lark.go rename to cloudevents-server/pkg/events/tekton/lark.go index 39415552..96da4a4a 100644 --- a/cloudevents-server/pkg/events/custom/tekton/lark.go +++ b/cloudevents-server/pkg/events/tekton/lark.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" "io" - "net/http" "regexp" "strings" "text/template" @@ -59,7 +58,7 @@ func composeAndSendLarkMessages(client *lark.Client, receivers []string, infos * createMsgReqs, err := composeLarkMessages(receivers, infos) if err != nil { log.Error().Err(err).Msg("compose lark message failed") - return cloudevents.NewHTTPResult(http.StatusInternalServerError, "compose lark message failed: %v", err) + return cloudevents.NewReceipt(true, "compose lark message failed: %v", err) } for _, createMsgReq := range createMsgReqs { @@ -76,7 +75,7 @@ func sendLarkMessage(client *lark.Client, createMsgReq *larkim.CreateMessageReq) resp, err := client.Im.Message.Create(context.Background(), createMsgReq) if err != nil { log.Error().Err(err).Msg("send lark message failed") - return cloudevents.NewHTTPResult(http.StatusInternalServerError, "send lark message failed: %v", err) + return cloudevents.NewReceipt(true, "send lark message failed: %v", err) } if !resp.Success() { diff --git a/cloudevents-server/pkg/events/custom/tekton/lark_templates/tekton-run-notify.yaml.tmpl b/cloudevents-server/pkg/events/tekton/lark_templates/tekton-run-notify.yaml.tmpl similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/lark_templates/tekton-run-notify.yaml.tmpl rename to cloudevents-server/pkg/events/tekton/lark_templates/tekton-run-notify.yaml.tmpl diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.failed.json b/cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.failed.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.failed.json rename to cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.failed.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.running.json b/cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.running.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.running.json rename to cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.running.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.started.json b/cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.started.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.started.json rename to cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.started.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.successful.json b/cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.successful.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.successful.json rename to cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.successful.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.unknown.json b/cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.unknown.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-pipelinerun.unknown.json rename to cloudevents-server/pkg/events/tekton/testdata/event-pipelinerun.unknown.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.failed-standalone.json b/cloudevents-server/pkg/events/tekton/testdata/event-taskrun.failed-standalone.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.failed-standalone.json rename to cloudevents-server/pkg/events/tekton/testdata/event-taskrun.failed-standalone.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.failed.json b/cloudevents-server/pkg/events/tekton/testdata/event-taskrun.failed.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.failed.json rename to cloudevents-server/pkg/events/tekton/testdata/event-taskrun.failed.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.running.json b/cloudevents-server/pkg/events/tekton/testdata/event-taskrun.running.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.running.json rename to cloudevents-server/pkg/events/tekton/testdata/event-taskrun.running.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.started.json b/cloudevents-server/pkg/events/tekton/testdata/event-taskrun.started.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.started.json rename to cloudevents-server/pkg/events/tekton/testdata/event-taskrun.started.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.successful.json b/cloudevents-server/pkg/events/tekton/testdata/event-taskrun.successful.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.successful.json rename to cloudevents-server/pkg/events/tekton/testdata/event-taskrun.successful.json diff --git a/cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.unknown.json b/cloudevents-server/pkg/events/tekton/testdata/event-taskrun.unknown.json similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/testdata/event-taskrun.unknown.json rename to cloudevents-server/pkg/events/tekton/testdata/event-taskrun.unknown.json diff --git a/cloudevents-server/pkg/events/custom/tekton/types.go b/cloudevents-server/pkg/events/tekton/types.go similarity index 100% rename from cloudevents-server/pkg/events/custom/tekton/types.go rename to cloudevents-server/pkg/events/tekton/types.go diff --git a/cloudevents-server/pkg/events/custom/tibuild/handler.go b/cloudevents-server/pkg/events/tibuild/handler.go similarity index 100% rename from cloudevents-server/pkg/events/custom/tibuild/handler.go rename to cloudevents-server/pkg/events/tibuild/handler.go diff --git a/cloudevents-server/pkg/events/custom/tibuild/types.go b/cloudevents-server/pkg/events/tibuild/types.go similarity index 100% rename from cloudevents-server/pkg/events/custom/tibuild/types.go rename to cloudevents-server/pkg/events/tibuild/types.go