diff --git a/.golangci.yml b/.golangci.yml index b61b1cb4..8f1256d0 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -22,6 +22,7 @@ linters: - varnamelen - whitespace - asciicheck + - bodyclose linters-settings: whitespace: diff --git a/cmd/builder/init.go b/cmd/builder/init.go index 3c68ade6..3129825d 100644 --- a/cmd/builder/init.go +++ b/cmd/builder/init.go @@ -142,7 +142,7 @@ func (b Builder) initToken() error { btConfig.Workers.OCI.Snapshotter = "auto" btConfig.Workers.OCI.NoProcessSandbox = true btConfig.Workers.OCI.GC = ptr.Of(true) - btConfig.Workers.OCI.GCKeepStorage.Bytes = 10 << 30 // 10GB + btConfig.Workers.OCI.GCReservedSpace.Bytes = 10 << 30 // 10GB btConfig.Workers.OCI.MaxParallelism = 4 btConfig.Workers.OCI.CNIPoolSize = 16 btConfig.Workers.OCI.Rootless = true diff --git a/go.mod b/go.mod index 85512aab..91e5b120 100644 --- a/go.mod +++ b/go.mod @@ -69,6 +69,7 @@ require ( github.com/wagslane/go-password-validator v0.3.0 github.com/xanzy/go-gitlab v0.115.0 github.com/xo/dburl v0.23.2 + gitlab.com/gitlab-org/api/client-go v0.118.0 go.uber.org/dig v1.18.0 go.uber.org/mock v0.5.0 golang.org/x/crypto v0.31.0 @@ -316,7 +317,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mattn/go-sqlite3 v1.14.24 // indirect - github.com/microsoft/go-mssqldb v1.6.0 // indirect + github.com/microsoft/go-mssqldb v1.7.2 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect github.com/mistifyio/go-zfs/v3 v3.0.1 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -460,7 +461,7 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect google.golang.org/grpc v1.68.0 // indirect google.golang.org/grpc/stats/opentelemetry v0.0.0-20240907200651-3ffb98b2c93a // indirect - google.golang.org/protobuf v1.35.2 // indirect + google.golang.org/protobuf v1.36.0 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect @@ -468,9 +469,9 @@ require ( gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gorm.io/datatypes v1.2.0 // indirect + gorm.io/datatypes v1.2.5 // indirect gorm.io/driver/sqlite v1.5.5 // indirect - gorm.io/driver/sqlserver v1.5.3 // indirect + gorm.io/driver/sqlserver v1.5.4 // indirect gorm.io/hints v1.1.2 // indirect helm.sh/helm/v3 v3.16.3 // indirect k8s.io/apiextensions-apiserver v0.31.1 // indirect diff --git a/go.sum b/go.sum index 5ad01a9e..de1f35bd 100644 --- a/go.sum +++ b/go.sum @@ -221,24 +221,22 @@ github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider v0.14.0 github.com/AliyunContainerService/ack-ram-tool/pkg/credentials/provider v0.14.0/go.mod h1:tlqp9mUGbsP+0z3Q+c0Q5MgSdq/OMwQhm5bffR3Q3ss= github.com/Azure/azure-sdk-for-go v68.0.0+incompatible h1:fcYLmCpyNYRnvJbPerq7U0hS+6+I79yEDJBqVNcqUzU= github.com/Azure/azure-sdk-for-go v68.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0 h1:JZg6HRh6W6U4OLl6lk7BZ7BLisIzM9dG1R50zUk9C/M= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.16.0/go.mod h1:YL1xnZ6QejvQHWJrX/AvhFl4WW4rqHVoKspWNVwFk0M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1/go.mod h1:uE9zaUfEQT/nbQjVi2IblCG9iaLtZsuYZ8ne+PuQ02M= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1/go.mod h1:h8hyGFDsU5HMivxiS2iYFZsgDbU9OnnJ163x5UGVKYo= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0 h1:B/dfvscEQtew9dVuoxqxrUKKv8Ih2f55PydknDamU+g= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0/go.mod h1:fiPSssYvltE08HJchL04dOy+RD4hgrjph0cwGGMntdI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.1.2/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.0/go.mod h1:Q28U+75mpCaSCDowNEmhIo/rmgdkqmkmzI7N6TGR4UY= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1/go.mod h1:GpPjLhVR9dnUoJMyHWSPy71xY9/lcmpzIPZXmF0FCVY= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.1.0 h1:DRiANoJTiW6obBQe3SqZizkuV1PEgfiiGivmVocDy64= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.1.0/go.mod h1:qLIye2hwb/ZouqhpSD9Zn3SJipvpEnz1Ywl3VUk9Y0s= -github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0/go.mod h1:cw4zVQgBby0Z5f2v0itn6se2dDP17nTjbZFXW5uPyHA= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 h1:D3occbWoio4EBLkbkevetNMAVX197GkzbUMtqjGWn80= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0/go.mod h1:bTSOgj05NGRuHHhQwAdPnYr9TOdNmKlZTgGLL6nyAdI= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= @@ -259,8 +257,8 @@ github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+Z github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.0/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -853,11 +851,10 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= -github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo= github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-migrate/migrate/v4 v4.18.1 h1:JML/k+t4tpHCpQTCAD62Nu43NUFzHY4CV3uAuvHGC+Y= @@ -1341,8 +1338,8 @@ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/mholt/archiver/v3 v3.5.1 h1:rDjOBX9JSF5BvoJGvjqK479aL70qh9DIpZCl+k7Clwo= github.com/mholt/archiver/v3 v3.5.1/go.mod h1:e3dqJ7H78uzsRSEACH1joayhuSyhnonssnDhppzS1L4= -github.com/microsoft/go-mssqldb v1.6.0 h1:mM3gYdVwEPFrlg/Dvr2DNVEgYFG7L42l+dGc67NNNpc= -github.com/microsoft/go-mssqldb v1.6.0/go.mod h1:00mDtPbeQCRGC1HwOOR5K/gr30P1NcEG0vx6Kbv2aJU= +github.com/microsoft/go-mssqldb v1.7.2 h1:CHkFJiObW7ItKTJfHo1QX7QBBD1iV+mn1eOyRP3b/PA= +github.com/microsoft/go-mssqldb v1.7.2/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= @@ -1690,7 +1687,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -1818,6 +1814,8 @@ github.com/zclconf/go-cty-yaml v1.1.0/go.mod h1:9YLUH4g7lOhVWqUbctnVlZ5KLpg7JApr github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs= github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +gitlab.com/gitlab-org/api/client-go v0.118.0 h1:qHIEw+XHt+2xuk4iZGW8fc6t+gTLAGEmTA5Bzp/brxs= +gitlab.com/gitlab-org/api/client-go v0.118.0/go.mod h1:E+X2dndIYDuUfKVP0C3jhkWvTSE00BkLbCsXTY3edDo= go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= @@ -1933,12 +1931,13 @@ golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20181106170214-d68db9428509/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2020,7 +2019,6 @@ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -2050,9 +2048,12 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -2205,10 +2206,13 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= @@ -2219,9 +2223,12 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -2237,6 +2244,7 @@ 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.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= @@ -2553,8 +2561,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= -google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ= +google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -2591,8 +2599,8 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/datatypes v1.2.0 h1:5YT+eokWdIxhJgWHdrb2zYUimyk0+TaFth+7a0ybzco= -gorm.io/datatypes v1.2.0/go.mod h1:o1dh0ZvjIjhH/bngTpypG6lVRJ5chTBxE09FH/71k04= +gorm.io/datatypes v1.2.5 h1:9UogU3jkydFVW1bIVVeoYsTpLRgwDVW3rHfJG6/Ek9I= +gorm.io/datatypes v1.2.5/go.mod h1:I5FUdlKpLb5PMqeMQhm30CQ6jXP8Rj89xkTeCSAaAD4= gorm.io/driver/mysql v1.5.7 h1:MndhOPYOfEp2rHKgkZIhJ16eVUIRf2HmzgoPmh7FCWo= gorm.io/driver/mysql v1.5.7/go.mod h1:sEtPWMiqiN1N1cMXoXmBbd8C6/l+TESwriotuRRpkDM= gorm.io/driver/postgres v1.5.11 h1:ubBVAfbKEUld/twyKZ0IYn9rSQh448EdelLYk9Mv314= @@ -2600,8 +2608,8 @@ gorm.io/driver/postgres v1.5.11/go.mod h1:DX3GReXH+3FPWGrrgffdvCk3DQ1dwDPdmbenSk gorm.io/driver/sqlite v1.5.0/go.mod h1:kDMDfntV9u/vuMmz8APHtHF0b4nyBB7sfCieC6G8k8I= gorm.io/driver/sqlite v1.5.5 h1:7MDMtUZhV065SilG62E0MquljeArQZNfJnjd9i9gx3E= gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE= -gorm.io/driver/sqlserver v1.5.3 h1:rjupPS4PVw+rjJkfvr8jn2lJ8BMhT4UW5FwuJY0P3Z0= -gorm.io/driver/sqlserver v1.5.3/go.mod h1:B+CZ0/7oFJ6tAlefsKoyxdgDCXJKSgwS2bMOQZT0I00= +gorm.io/driver/sqlserver v1.5.4 h1:xA+Y1KDNspv79q43bPyjDMUgHoYHLhXYmdFcYPobg8g= +gorm.io/driver/sqlserver v1.5.4/go.mod h1:+frZ/qYmuna11zHPlh5oc2O6ZA/lS88Keb0XSH1Zh/g= gorm.io/gen v0.3.26 h1:sFf1j7vNStimPRRAtH4zz5NiHM+1dr6eA9aaRdplyhY= gorm.io/gen v0.3.26/go.mod h1:a5lq5y3w4g5LMxBcw0wnO6tYUCdNutWODq5LrIt75LE= gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= diff --git a/pkg/daemon/coderepo/gitlab.go b/pkg/daemon/coderepo/gitlab.go index d7e7dc50..bed1cee2 100644 --- a/pkg/daemon/coderepo/gitlab.go +++ b/pkg/daemon/coderepo/gitlab.go @@ -20,7 +20,7 @@ import ( "strconv" "github.com/rs/zerolog/log" - "github.com/xanzy/go-gitlab" + gitlab "gitlab.com/gitlab-org/api/client-go" "github.com/go-sigma/sigma/pkg/dal/models" "github.com/go-sigma/sigma/pkg/utils/ptr" diff --git a/pkg/dal/retry.go b/pkg/dal/retry.go index 561df195..2cfa539b 100644 --- a/pkg/dal/retry.go +++ b/pkg/dal/retry.go @@ -15,8 +15,10 @@ package dal import ( + "crypto/rand" "database/sql" - "math/rand" + "fmt" + "math/big" "strings" "time" @@ -28,10 +30,14 @@ import ( // TxnWithRetry ... func TxnWithRetry(fc func(tx *query.Query) error, opts ...*sql.TxOptions) error { - err := retry.Do(func() error { + randInt, err := rand.Int(rand.Reader, big.NewInt(300)) + if err != nil { + return fmt.Errorf("failed to generate random number: %w", err) + } + err = retry.Do(func() error { return query.Q.Transaction(fc, opts...) }, retry.MaxDelay(time.Second*10), retry.Attempts(6), retry.LastErrorOnly(true), - retry.Delay(300*time.Millisecond+time.Duration(rand.Intn(300))*time.Millisecond), + retry.Delay(300*time.Millisecond+time.Duration(randInt.Int64())*time.Millisecond), retry.RetryIf(func(err error) bool { if err != nil && strings.Contains(err.Error(), "Deadlock") { log.Debug().Err(err).Msg("transaction deadlock, retry again now") diff --git a/pkg/handlers/oauth2/oauth2_callback.go b/pkg/handlers/oauth2/oauth2_callback.go index e2c2ae95..c4a34d13 100644 --- a/pkg/handlers/oauth2/oauth2_callback.go +++ b/pkg/handlers/oauth2/oauth2_callback.go @@ -26,7 +26,7 @@ import ( "github.com/labstack/echo/v4" gonanoid "github.com/matoous/go-nanoid/v2" "github.com/rs/zerolog/log" - "github.com/xanzy/go-gitlab" + gitlab "gitlab.com/gitlab-org/api/client-go" "go.uber.org/dig" "golang.org/x/oauth2" "gorm.io/gorm" diff --git a/pkg/handlers/tokens/handler.go b/pkg/handlers/tokens/handler.go index 2236e1d3..b79f9e98 100644 --- a/pkg/handlers/tokens/handler.go +++ b/pkg/handlers/tokens/handler.go @@ -24,7 +24,10 @@ import ( "github.com/go-sigma/sigma/pkg/configs" "github.com/go-sigma/sigma/pkg/consts" "github.com/go-sigma/sigma/pkg/handlers" + "github.com/go-sigma/sigma/pkg/middlewares/authn" + "github.com/go-sigma/sigma/pkg/middlewares/authz" "github.com/go-sigma/sigma/pkg/utils" + "github.com/go-sigma/sigma/pkg/utils/echoplus" "github.com/go-sigma/sigma/pkg/utils/ptr" "github.com/go-sigma/sigma/pkg/utils/token" ) @@ -54,8 +57,8 @@ type factory struct{} func (f factory) Initialize(digCon *dig.Container) error { handler := handlerNew(digCon) echo := utils.MustGetObjFromDigCon[*echo.Echo](digCon) - tokenGroup := echo.Group(consts.APIV1) - tokenGroup.GET("/tokens", handler.Token) + plus := echoplus.New(echo.Group(consts.APIV1)) + plus.Get("/tokens", &authn.AuthnConfig{Skip: false}, &authz.AuthzConfig{Skip: true}, handler.Token) return nil } diff --git a/pkg/handlers/validators/handler.go b/pkg/handlers/validators/handler.go index e13f7186..3d7993a8 100644 --- a/pkg/handlers/validators/handler.go +++ b/pkg/handlers/validators/handler.go @@ -23,7 +23,10 @@ import ( "github.com/go-sigma/sigma/pkg/consts" "github.com/go-sigma/sigma/pkg/handlers" + "github.com/go-sigma/sigma/pkg/middlewares/authn" + "github.com/go-sigma/sigma/pkg/middlewares/authz" "github.com/go-sigma/sigma/pkg/utils" + "github.com/go-sigma/sigma/pkg/utils/echoplus" ) // Handler ... @@ -45,7 +48,7 @@ var _ Handler = &handler{} type handler struct{} // handlerNew creates a new instance of the distribution handlers -func handlerNew(_ *dig.Container) Handler { +func handlerNew() Handler { return &handler{} } @@ -53,14 +56,14 @@ type factory struct{} // Initialize initializes the namespace handlers func (f factory) Initialize(digCon *dig.Container) error { - e := utils.MustGetObjFromDigCon[*echo.Echo](digCon) - validatorGroup := e.Group(consts.APIV1 + "/validators") - repositoryHandler := handlerNew(digCon) - validatorGroup.GET("/reference", repositoryHandler.GetReference) - validatorGroup.GET("/tag", repositoryHandler.GetTag) - validatorGroup.POST("/password", repositoryHandler.GetPassword) - validatorGroup.POST("/cron", repositoryHandler.ValidateCron) - validatorGroup.POST("/regexp", repositoryHandler.ValidateRegexp) + handler := handlerNew() + echo := utils.MustGetObjFromDigCon[*echo.Echo](digCon) + plus := echoplus.New(echo.Group(consts.APIV1 + "/validators")) + plus.Get("/reference", &authn.AuthnConfig{Skip: true}, &authz.AuthzConfig{Skip: true}, handler.GetReference) + plus.Get("/tag", &authn.AuthnConfig{Skip: true}, &authz.AuthzConfig{Skip: true}, handler.GetTag) + plus.Post("/password", &authn.AuthnConfig{Skip: true}, &authz.AuthzConfig{Skip: true}, handler.GetPassword) + plus.Post("/cron", &authn.AuthnConfig{Skip: true}, &authz.AuthzConfig{Skip: true}, handler.ValidateCron) + plus.Post("/regexp", &authn.AuthnConfig{Skip: true}, &authz.AuthzConfig{Skip: true}, handler.ValidateRegexp) return nil } diff --git a/pkg/middlewares/authn/authn.go b/pkg/middlewares/authn/authn.go index d2fad386..474ce88b 100644 --- a/pkg/middlewares/authn/authn.go +++ b/pkg/middlewares/authn/authn.go @@ -16,6 +16,7 @@ package authn import ( "fmt" + "regexp" "strings" "github.com/google/uuid" @@ -43,6 +44,14 @@ type Config struct { DigCon *dig.Container } +// AuthnConfig ... +type AuthnConfig struct { + Skip bool +} + +// AuthMapper ... +var AuthMapper = make(map[*regexp.Regexp]*AuthnConfig) + // AuthnWithConfig returns a middleware which authenticates requests. func AuthnWithConfig(config Config) echo.MiddlewareFunc { return func(next echo.HandlerFunc) echo.HandlerFunc { diff --git a/pkg/middlewares/authz/authz.go b/pkg/middlewares/authz/authz.go index 7057d83c..b47e0789 100644 --- a/pkg/middlewares/authz/authz.go +++ b/pkg/middlewares/authz/authz.go @@ -18,6 +18,7 @@ package authz import ( + "regexp" "strconv" "strings" @@ -41,6 +42,21 @@ type ( } ) +// AuthzConfig ... +type AuthzConfig struct { + Skip bool + Source []AuthzConfigSource +} + +// AuthzConfigSource ... +type AuthzConfigSource struct { + Name string `json:"name"` + Position string `json:"position"` +} + +// AuthMapper ... +var AuthMapper = make(map[*regexp.Regexp]*AuthzConfig) + // AuthzWithConfig returns a CasbinAuth middleware with config func AuthzWithConfig(config Config) echo.MiddlewareFunc { if config.Enforcer == nil { diff --git a/pkg/tests/database.go b/pkg/tests/database.go deleted file mode 100644 index 656cc78c..00000000 --- a/pkg/tests/database.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2024 sigma -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package tests - -import ( - "go.uber.org/dig" - - "github.com/go-sigma/sigma/pkg/dal" -) - -func DatabaseInit(digCon *dig.Container) { - dal.Initialize(digCon) -} diff --git a/pkg/utils/echoplus/echoplus.go b/pkg/utils/echoplus/echoplus.go index 0490fb9a..18fa5af5 100644 --- a/pkg/utils/echoplus/echoplus.go +++ b/pkg/utils/echoplus/echoplus.go @@ -1,90 +1,83 @@ package echoplus import ( + "regexp" + "github.com/labstack/echo/v4" + + "github.com/go-sigma/sigma/pkg/middlewares/authn" + "github.com/go-sigma/sigma/pkg/middlewares/authz" ) +// Plus ... type Plus interface { + // Get ... + Get(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + // Post ... + Post(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + // Put ... + Put(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + // Delete ... + Delete(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + // Patch ... + Patch(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route +} + +type engine interface { + // Get ... + GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + // POST ... + POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + // PUT ... + PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + // DELETE ... + DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route + // PATCH ... + PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route } type plus struct { - *echo.Echo + engine engine } // New ... -func New(echo *echo.Echo) Plus { +func New(e engine) Plus { return &plus{ - Echo: echo, + engine: e, } } -// AuthzConfig ... -type AuthzConfig struct { - Skip bool - Source []AuthzConfigSource -} - -// AuthzConfigSource ... -type AuthzConfigSource struct { - Name string `json:"name"` - Position string `json:"position"` -} - -// AuthnConfig ... -type AuthnConfig struct { - Skip bool -} - -// AuthConfig ... -type AuthConfig struct { - AuthnConfig *AuthnConfig - AuthzConfig *AuthzConfig -} - -// AuthMapper ... -var AuthMapper = make(map[string]AuthConfig) - // Get ... -func (p *plus) Get(path string, authnConfig *AuthnConfig, authzConfig *AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { - AuthMapper[path] = AuthConfig{ - AuthnConfig: authnConfig, - AuthzConfig: authzConfig, - } - return p.Echo.GET(path, h, m...) +func (p *plus) Get(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { + authn.AuthMapper[regexp.MustCompile(path)] = authnConfig + authz.AuthMapper[regexp.MustCompile(path)] = authzConfig + return p.engine.GET(path, h, m...) } // Post ... -func (p *plus) Post(path string, authnConfig *AuthnConfig, authzConfig *AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { - AuthMapper[path] = AuthConfig{ - AuthnConfig: authnConfig, - AuthzConfig: authzConfig, - } - return p.Echo.POST(path, h, m...) +func (p *plus) Post(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { + authn.AuthMapper[regexp.MustCompile(path)] = authnConfig + authz.AuthMapper[regexp.MustCompile(path)] = authzConfig + return p.engine.POST(path, h, m...) } // Put ... -func (p *plus) Put(path string, authnConfig *AuthnConfig, authzConfig *AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { - AuthMapper[path] = AuthConfig{ - AuthnConfig: authnConfig, - AuthzConfig: authzConfig, - } - return p.Echo.PUT(path, h, m...) +func (p *plus) Put(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { + authn.AuthMapper[regexp.MustCompile(path)] = authnConfig + authz.AuthMapper[regexp.MustCompile(path)] = authzConfig + return p.engine.PUT(path, h, m...) } // Delete ... -func (p *plus) Delete(path string, authnConfig *AuthnConfig, authzConfig *AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { - AuthMapper[path] = AuthConfig{ - AuthnConfig: authnConfig, - AuthzConfig: authzConfig, - } - return p.Echo.DELETE(path, h, m...) +func (p *plus) Delete(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { + authn.AuthMapper[regexp.MustCompile(path)] = authnConfig + authz.AuthMapper[regexp.MustCompile(path)] = authzConfig + return p.engine.DELETE(path, h, m...) } // Patch ... -func (p *plus) Patch(path string, authnConfig *AuthnConfig, authzConfig *AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { - AuthMapper[path] = AuthConfig{ - AuthnConfig: authnConfig, - AuthzConfig: authzConfig, - } - return p.Echo.PATCH(path, h, m...) +func (p *plus) Patch(path string, authnConfig *authn.AuthnConfig, authzConfig *authz.AuthzConfig, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route { + authn.AuthMapper[regexp.MustCompile(path)] = authnConfig + authz.AuthMapper[regexp.MustCompile(path)] = authzConfig + return p.engine.PATCH(path, h, m...) }