diff --git a/go.mod b/go.mod index cd7872c18a9..e7dd5529a8f 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,6 @@ require ( github.com/hashicorp/vault/api v1.12.0 github.com/iancoleman/strcase v0.3.0 github.com/jackc/pgconn v1.14.3 - github.com/jackc/pgx/v4 v4.18.3 // indirect github.com/jefferai/keyring v1.1.7-0.20220316160357-58a74bb55891 github.com/kr/pretty v0.3.1 github.com/kr/text v0.2.0 @@ -82,7 +81,7 @@ require ( nhooyr.io/websocket v1.8.10 ) -require github.com/hashicorp/go-dbw v0.1.3-0.20240312210008-7ed943176e5b +require github.com/hashicorp/go-dbw v0.1.4-0.20240728230619-2d5c356ada71 require ( github.com/DATA-DOG/go-sqlmock v1.5.2 @@ -96,7 +95,7 @@ require ( github.com/hashicorp/go-rate v0.0.0-20231204194614-cc8d401f70ab github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/nodeenrollment v0.2.13 - github.com/jackc/pgx/v5 v5.5.5 + github.com/jackc/pgx/v5 v5.6.0 github.com/jimlambrt/gldap v0.1.10 github.com/kelseyhightower/envconfig v1.4.0 github.com/miekg/dns v1.1.58 @@ -110,7 +109,7 @@ require ( require ( github.com/dustin/go-humanize v1.0.1 // indirect - github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect + github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect modernc.org/libc v1.41.0 // indirect modernc.org/mathutil v1.6.0 // indirect @@ -190,7 +189,6 @@ require ( github.com/jackc/pgpassfile v1.0.0 // indirect github.com/jackc/pgproto3/v2 v2.3.3 // indirect github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect - github.com/jackc/pgtype v1.14.2 // indirect github.com/jefferai/go-libsecret v0.0.0-20210525195240-b53481abef97 // indirect github.com/jefferai/isbadcipher v0.0.0-20190226160619-51d2077c035f // indirect github.com/jinzhu/gorm v1.9.16 // indirect diff --git a/go.sum b/go.sum index c9ea988086d..52b71dd278e 100644 --- a/go.sum +++ b/go.sum @@ -63,20 +63,15 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/containerd/continuity v0.4.3 h1:6HVkalIp+2u1ZLH1J/pYX2oBVXlJZvh1X1A7bEZ9Su8= github.com/containerd/continuity v0.4.3/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= github.com/coreos/go-oidc/v3 v3.9.0 h1:0J/ogVOd4y8P0f0xUh8l9t07xRP/d8tccvjHl2dcsSo= github.com/coreos/go-oidc/v3 v3.9.0/go.mod h1:rTKz2PYwftcrtoCzV5g5kvfJoWcm0Mk8AF8y1iAQro4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0= github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= @@ -151,8 +146,6 @@ github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncV github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-migrate/migrate/v4 v4.17.0 h1:rd40H3QXU0AA4IoLllFcEAEo9dYKRHYND2gB4p7xcaU= @@ -178,7 +171,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -209,8 +201,12 @@ github.com/hashicorp/go-bexpr v0.1.13 h1:HNwp7vZrMpRq8VZXj8VF90LbZpRjQQpim1oJF0D github.com/hashicorp/go-bexpr v0.1.13/go.mod h1:gN7hRKB3s7yT+YvTdnhZVLTENejvhlkZ8UE4YVBS+Q8= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-dbw v0.1.3-0.20240312210008-7ed943176e5b h1:DKThhRxpCyHtmzCwdZUPTSM+DRSOHCUv7eBs+AqIJ7c= -github.com/hashicorp/go-dbw v0.1.3-0.20240312210008-7ed943176e5b/go.mod h1:dEiD86O4U0CNjS6p4xgRLjXCyMfj1DUQtpsnG/ORU38= +github.com/hashicorp/go-dbw v0.1.4-0.20240727204150-b18c36f37401 h1:sPYMUgjN7NZ15CP0YnNQ+WZzG81WwoSQ2cY7zuRNx4Y= +github.com/hashicorp/go-dbw v0.1.4-0.20240727204150-b18c36f37401/go.mod h1:El3jppdwsLpCNlvFN4Ihk4K8ONsr/3Sq3ESVZ7Wbjnw= +github.com/hashicorp/go-dbw v0.1.4-0.20240728204920-cf2eba76eb7a h1:2QMvSDAV3GkxL/gB/D8LeeBpyRw77vPyZao4eNdXt2Y= +github.com/hashicorp/go-dbw v0.1.4-0.20240728204920-cf2eba76eb7a/go.mod h1:El3jppdwsLpCNlvFN4Ihk4K8ONsr/3Sq3ESVZ7Wbjnw= +github.com/hashicorp/go-dbw v0.1.4-0.20240728230619-2d5c356ada71 h1:l5LEIUSw516kpJ2ZQBj/0qpzFEmtyRAgfSrAPR80bXw= +github.com/hashicorp/go-dbw v0.1.4-0.20240728230619-2d5c356ada71/go.mod h1:El3jppdwsLpCNlvFN4Ihk4K8ONsr/3Sq3ESVZ7Wbjnw= github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-kms-wrapping/extras/kms/v2 v2.0.0-20231219183231-6bac757bb482 h1:1DqTnLaNk658AEenlF4PNGYd9b1hXE/+0jSOBIGOAms= @@ -290,55 +286,23 @@ github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47 github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= -github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= -github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= -github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= -github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= -github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= -github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w= github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= -github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= -github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= -github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= -github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= -github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag= github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 h1:L0QtFUgDarD7Fpv9jeVMgy/+Ec0mtnmYuImjTz6dtDA= github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= -github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= -github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= -github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= -github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.14.2 h1:QBdZQTKpPdBlw2AdKwHEyqUcm/lrl2cwWAHjCMyln/o= -github.com/jackc/pgtype v1.14.2/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= -github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= -github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= -github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.18.3 h1:dE2/TrEsGX3RBprb3qryqSV9Y60iZN1C6i8IrmW9/BA= -github.com/jackc/pgx/v4 v4.18.3/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= -github.com/jackc/pgx/v5 v5.5.5 h1:amBjrZVmksIdNjxGW/IiIMzxMKZFelXbUoPNb+8sjQw= -github.com/jackc/pgx/v5 v5.5.5/go.mod h1:ez9gk+OAat140fv9ErkZDYFWmXLfV+++K0uAOiwgm1A= -github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY= +github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jefferai/go-libsecret v0.0.0-20210525195240-b53481abef97 h1:/jVRo4KmyL3FgEYAqFe+S8nxo6xRkFLm+CvIV0qG7PU= @@ -370,7 +334,6 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -383,24 +346,18 @@ github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= 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/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= @@ -408,8 +365,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= -github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw= -github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= @@ -489,31 +446,24 @@ github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3c github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/fastuuid v1.1.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.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sethvargo/go-diceware v0.3.0 h1:UVVEfmN/uF50JfWAN7nbY6CiAlp5xeSx+5U0lWKkMCQ= github.com/sethvargo/go-diceware v0.3.0/go.mod h1:lH5Q/oSPMivseNdhMERAC7Ti5oOPqsaVddU1BcN1CY0= github.com/sevlyar/go-daemon v0.1.6 h1:EUh1MDjEM4BI109Jign0EaknA2izkOyi0LV3ro3QQGs= github.com/sevlyar/go-daemon v0.1.6/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -525,7 +475,6 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= @@ -564,7 +513,6 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zalando/go-keyring v0.2.3 h1:v9CUu9phlABObO4LPWycf+zwMG7nlbb3t/B5wa97yms= github.com/zalando/go-keyring v0.2.3/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk= -github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0 h1:doUP+ExOpH3spVTLS0FcWGLnQrPct/hD/bCPbDRUEAU= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.48.0/go.mod h1:rdENBZMT2OE6Ne/KLwpiXudnAsbdrdBaqBvTN8M8BgA= go.opentelemetry.io/otel v1.23.1 h1:Za4UzOqJYS+MUczKI320AtqZHZb7EqxO00jAHE0jmQY= @@ -581,10 +529,6 @@ go.opentelemetry.io/otel/trace v1.23.1 h1:4LrmmEd8AU2rFvU1zegmvqW7+kWarxtNOPyeL6 go.opentelemetry.io/otel/trace v1.23.1/go.mod h1:4IpnpJFwr1mo/6HL8XIPJaE9y0+u1KcVmuW7dwFSVrI= go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= @@ -592,30 +536,17 @@ go.uber.org/goleak v1.0.0/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/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.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= @@ -630,7 +561,6 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -648,7 +578,6 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -673,15 +602,11 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 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-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -706,7 +631,6 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -720,8 +644,6 @@ golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/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= @@ -736,15 +658,9 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210101214203-2dba1e4ea05c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -753,8 +669,6 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= -golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -793,7 +707,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -819,7 +732,6 @@ gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk= modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY= modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= diff --git a/internal/auth/ldap/auth_method.go b/internal/auth/ldap/auth_method.go index bc0affa030a..4ae52c2f348 100644 --- a/internal/auth/ldap/auth_method.go +++ b/internal/auth/ldap/auth_method.go @@ -141,14 +141,14 @@ func (am *AuthMethod) oplog(ctx context.Context, opType oplog.OpType) (oplog.Met } type convertedValues struct { - Urls []any - Certs []any - UserEntrySearchConf any - GroupEntrySearchConf any - ClientCertificate any - BindCredential any - AccountAttributeMaps []any - DerefAliases any + Urls []*Url + Certs []*Certificate + UserEntrySearchConf *UserEntrySearchConf + GroupEntrySearchConf *GroupEntrySearchConf + ClientCertificate *ClientCertificate + BindCredential *BindCredential + AccountAttributeMaps []*AccountAttributeMap + DerefAliases *DerefAliases } // convertValueObjects converts the embedded value objects. It will return an @@ -199,15 +199,15 @@ func (am *AuthMethod) convertValueObjects(ctx context.Context) (*convertedValues return converted, nil } -// convertCertificates converts any embedded URLs from []string -// to []any where each slice element is a *Url. It will return an error if the -// AuthMethod's public id is not set. -func (am *AuthMethod) convertUrls(ctx context.Context) ([]any, error) { +// convertUrls converts any embedded URLs from []string to []*Url where each +// slice element is a *Url. It will return an error if the AuthMethod's public +// id is not set. +func (am *AuthMethod) convertUrls(ctx context.Context) ([]*Url, error) { const op = "ldap.(AuthMethod).convertUrls" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newValObjs := make([]any, 0, len(am.Urls)) + newValObjs := make([]*Url, 0, len(am.Urls)) for priority, u := range am.Urls { parsed, err := url.Parse(u) if err != nil { @@ -223,14 +223,14 @@ func (am *AuthMethod) convertUrls(ctx context.Context) ([]any, error) { } // convertCertificates converts any embedded certificates from []string -// to []any where each slice element is a *Certificate. It will return an error -// if the AuthMethod's public id is not set. -func (am *AuthMethod) convertCertificates(ctx context.Context) ([]any, error) { +// to []*Certificate. It will return an error if the AuthMethod's public id is +// not set. +func (am *AuthMethod) convertCertificates(ctx context.Context) ([]*Certificate, error) { const op = "ldap.(AuthMethod).convertCertificates" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newValObjs := make([]any, 0, len(am.Certificates)) + newValObjs := make([]*Certificate, 0, len(am.Certificates)) for _, cert := range am.Certificates { obj, err := NewCertificate(ctx, am.PublicId, cert) if err != nil { @@ -242,9 +242,9 @@ func (am *AuthMethod) convertCertificates(ctx context.Context) ([]any, error) { } // convertUserEntrySearchConf converts an embedded user entry search fields -// into an any type. It will return an error if the AuthMethod's public id is -// not set. -func (am *AuthMethod) convertUserEntrySearchConf(ctx context.Context) (any, error) { +// into an *UserEntrySearchConf type. It will return an error if the +// AuthMethod's public id is not set. +func (am *AuthMethod) convertUserEntrySearchConf(ctx context.Context) (*UserEntrySearchConf, error) { const op = "ldap.(AuthMethod).convertUserEntrySearchConf" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") @@ -257,9 +257,9 @@ func (am *AuthMethod) convertUserEntrySearchConf(ctx context.Context) (any, erro } // convertGroupEntrySearchConf converts an embedded group entry search fields -// into an any type. It will return an error if the AuthMethod's public id is -// not set. -func (am *AuthMethod) convertGroupEntrySearchConf(ctx context.Context) (any, error) { +// into an *GroupEntrySearchConf type. It will return an error if the +// AuthMethod's public id is not set. +func (am *AuthMethod) convertGroupEntrySearchConf(ctx context.Context) (*GroupEntrySearchConf, error) { const op = "ldap.(AuthMethod).convertGroupEntrySearchConf" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") @@ -272,9 +272,9 @@ func (am *AuthMethod) convertGroupEntrySearchConf(ctx context.Context) (any, err } // convertClientCertificate converts an embedded client certificate entry into -// an any type. It will return an error if the AuthMethod's public id is not -// set. -func (am *AuthMethod) convertClientCertificate(ctx context.Context) (any, error) { +// an *ClientCertificate type. It will return an error if the AuthMethod's +// public id is not set. +func (am *AuthMethod) convertClientCertificate(ctx context.Context) (*ClientCertificate, error) { const op = "ldap.(AuthMethod).convertClientCertificate" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing auth method id") @@ -287,9 +287,9 @@ func (am *AuthMethod) convertClientCertificate(ctx context.Context) (any, error) } // convertBindCredential converts an embedded bind credential entry into -// an any type. It will return an error if the AuthMethod's public id is not -// set. -func (am *AuthMethod) convertBindCredential(ctx context.Context) (any, error) { +// an *BindCredential type. It will return an error if the AuthMethod's public +// id is not set. +func (am *AuthMethod) convertBindCredential(ctx context.Context) (*BindCredential, error) { const op = "ldap.(AuthMethod).convertBindCredentials" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing auth method id") @@ -302,9 +302,9 @@ func (am *AuthMethod) convertBindCredential(ctx context.Context) (any, error) { } // convertDerefAliases converts an embedded deref aliases entry into -// an any type. It will return an error if the AuthMethod's public id is not -// set. -func (am *AuthMethod) convertDerefAliases(ctx context.Context) (any, error) { +// an *DerefAliases type. It will return an error if the AuthMethod's public id +// is not set. +func (am *AuthMethod) convertDerefAliases(ctx context.Context) (*DerefAliases, error) { const op = "ldap.(AuthMethod).convertDerefAliases" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing auth method id") @@ -317,15 +317,15 @@ func (am *AuthMethod) convertDerefAliases(ctx context.Context) (any, error) { } // convertAccountAttributeMaps converts the embedded account attribute maps from -// []string to []interface{} where each slice element is a *AccountAttributeMap. It -// will return an error if the AuthMethod's public id is not set or it can -// convert the account attribute maps. -func (am *AuthMethod) convertAccountAttributeMaps(ctx context.Context) ([]any, error) { +// []string to []*AccountAttributeMap. It will return an error if the +// AuthMethod's public id is not set or it can convert the account attribute +// maps. +func (am *AuthMethod) convertAccountAttributeMaps(ctx context.Context) ([]*AccountAttributeMap, error) { const op = "ldap.(AuthMethod).convertAccountAttributeMaps" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newInterfaces := make([]any, 0, len(am.AccountAttributeMaps)) + acctAttribMaps := make([]*AccountAttributeMap, 0, len(am.AccountAttributeMaps)) const ( from = 0 to = 1 @@ -343,7 +343,7 @@ func (am *AuthMethod) convertAccountAttributeMaps(ctx context.Context) ([]any, e if err != nil { return nil, errors.Wrap(ctx, err, op) } - newInterfaces = append(newInterfaces, obj) + acctAttribMaps = append(acctAttribMaps, obj) } - return newInterfaces, nil + return acctAttribMaps, nil } diff --git a/internal/auth/ldap/auth_method_test.go b/internal/auth/ldap/auth_method_test.go index d4819504b8d..7fd6d361026 100644 --- a/internal/auth/ldap/auth_method_test.go +++ b/internal/auth/ldap/auth_method_test.go @@ -348,9 +348,9 @@ func Test_convertValueObjects(t *testing.T) { testCerts := []string{pem} c, err := NewCertificate(testCtx, testPublicId, pem) require.NoError(t, err) - testCertificates := []any{c} + testCertificates := []*Certificate{c} - testUrls := make([]any, 0, len(testLdapServers)) + testUrls := make([]*Url, 0, len(testLdapServers)) for priority, uu := range TestConvertToUrls(t, testLdapServers...) { u, err := NewUrl(testCtx, testPublicId, priority+1, uu) require.NoError(t, err) @@ -358,7 +358,7 @@ func Test_convertValueObjects(t *testing.T) { } testAttrMaps := []string{"email_address=email", "display_name=fullName"} - testAccountAttributeMaps := make([]any, 0, len(testAttrMaps)) + testAccountAttributeMaps := make([]*AccountAttributeMap, 0, len(testAttrMaps)) acms, err := ParseAccountAttributeMaps(testCtx, testAttrMaps...) require.NoError(t, err) for _, m := range acms { @@ -618,6 +618,23 @@ func (a converted) Less(i, j int) bool { } func testSortConverted(t *testing.T, c *convertedValues) { - sort.Sort(converted(c.Urls)) - sort.Sort(converted(c.Certs)) + t.Helper() + sort.Sort(sortableUrls(c.Urls)) + sort.Sort(sortableCerts(c.Certs)) +} + +type sortableUrls []*Url + +func (u sortableUrls) Len() int { return len(u) } +func (u sortableUrls) Swap(i, j int) { u[i], u[j] = u[j], u[i] } +func (u sortableUrls) Less(i, j int) bool { + return u[i].GetServerUrl() < u[j].GetServerUrl() +} + +type sortableCerts []*Certificate + +func (c sortableCerts) Len() int { return len(c) } +func (c sortableCerts) Swap(i, j int) { c[i], c[j] = c[j], c[i] } +func (c sortableCerts) Less(i, j int) bool { + return c[i].GetCert() < c[j].GetCert() } diff --git a/internal/auth/ldap/repository_auth_method_create.go b/internal/auth/ldap/repository_auth_method_create.go index 2aee67cb3ca..93ed5290746 100644 --- a/internal/auth/ldap/repository_auth_method_create.go +++ b/internal/auth/ldap/repository_auth_method_create.go @@ -68,20 +68,12 @@ func (r *Repository) CreateAuthMethod(ctx context.Context, am *AuthMethod, opt . } if cv.BindCredential != nil { - bc, ok := cv.BindCredential.(*BindCredential) - if !ok { - return nil, errors.New(ctx, errors.Internal, op, fmt.Sprintf("invalid type (%T) is not a bind credential", cv.BindCredential)) - } - if err := bc.encrypt(ctx, dbWrapper); err != nil { + if err := cv.BindCredential.encrypt(ctx, dbWrapper); err != nil { return nil, errors.Wrap(ctx, err, op, errors.WithMsg("failed to encrypt bind credential")) } } if cv.ClientCertificate != nil { - cc, ok := cv.ClientCertificate.(*ClientCertificate) - if !ok { - return nil, errors.New(ctx, errors.Internal, op, fmt.Sprintf("invalid type (%T) is not a client certificate", cv.ClientCertificate)) - } - if err := cc.encrypt(ctx, dbWrapper); err != nil { + if err := cv.ClientCertificate.encrypt(ctx, dbWrapper); err != nil { return nil, errors.Wrap(ctx, err, op, errors.WithMsg("failed to encrypt client certificate")) } } diff --git a/internal/auth/ldap/repository_auth_method_update.go b/internal/auth/ldap/repository_auth_method_update.go index 2c61c45add5..65acd17f4d1 100644 --- a/internal/auth/ldap/repository_auth_method_update.go +++ b/internal/auth/ldap/repository_auth_method_update.go @@ -155,18 +155,42 @@ func (r *Repository) UpdateAuthMethod(ctx context.Context, am *AuthMethod, versi if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg("unable to get database wrapper")) } - addUrls, deleteUrls, err := valueObjectChanges(ctx, origAm.PublicId, UrlVO, am.Urls, origAm.Urls, dbMask, nullFields) + au, du, err := valueObjectChanges(ctx, origAm.PublicId, UrlVO, am.Urls, origAm.Urls, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg("unable to update urls")) } - addCerts, deleteCerts, err := valueObjectChanges(ctx, origAm.PublicId, CertificateVO, am.Certificates, origAm.Certificates, dbMask, nullFields) + addUrls := []*Url{} + for _, u := range au { + addUrls = append(addUrls, u.(*Url)) + } + deleteUrls := []*Url{} + for _, u := range du { + deleteUrls = append(deleteUrls, u.(*Url)) + } + ac, dc, err := valueObjectChanges(ctx, origAm.PublicId, CertificateVO, am.Certificates, origAm.Certificates, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg("unable to update certificates")) } - addMaps, deleteMaps, err := valueObjectChanges(ctx, origAm.PublicId, AccountAttributeMapsVO, am.AccountAttributeMaps, origAm.AccountAttributeMaps, dbMask, nullFields) + deleteCerts := []*Certificate{} + for _, c := range dc { + deleteCerts = append(deleteCerts, c.(*Certificate)) + } + addCerts := []*Certificate{} + for _, c := range ac { + addCerts = append(addCerts, c.(*Certificate)) + } + addM, deleteM, err := valueObjectChanges(ctx, origAm.PublicId, AccountAttributeMapsVO, am.AccountAttributeMaps, origAm.AccountAttributeMaps, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg("unable to update account attribute maps")) } + addMaps := []*AccountAttributeMap{} + for _, m := range addM { + addMaps = append(addMaps, m.(*AccountAttributeMap)) + } + deleteMaps := []*AccountAttributeMap{} + for _, m := range deleteM { + deleteMaps = append(deleteMaps, m.(*AccountAttributeMap)) + } combinedMasks := append(dbMask, nullFields...) diff --git a/internal/auth/ldap/repository_authenticate.go b/internal/auth/ldap/repository_authenticate.go index 0e758391c51..2b0dfd31407 100644 --- a/internal/auth/ldap/repository_authenticate.go +++ b/internal/auth/ldap/repository_authenticate.go @@ -117,18 +117,13 @@ func (r *Repository) Authenticate(ctx context.Context, authMethodId, loginName, } for _, attrMap := range attrMaps { - aam, ok := attrMap.(*AccountAttributeMap) - if !ok { - return nil, errors.New(ctx, errors.Internal, op, "failed to convert attribute map into AccountAttributeMap type") - } - - switch aam.ToAttribute { + switch attrMap.ToAttribute { case DefaultEmailAttribute: - emailAttr = aam.FromAttribute + emailAttr = attrMap.FromAttribute case DefaultFullNameAttribute: - fullNameAttr = aam.FromAttribute + fullNameAttr = attrMap.FromAttribute default: - return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("invalid to attribute %q", aam.ToAttribute)) + return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("invalid to attribute %q", attrMap.ToAttribute)) } } diff --git a/internal/auth/oidc/auth_method.go b/internal/auth/oidc/auth_method.go index 981a9faef2f..55e8c525ba0 100644 --- a/internal/auth/oidc/auth_method.go +++ b/internal/auth/oidc/auth_method.go @@ -289,12 +289,12 @@ func (am *AuthMethod) isComplete(ctx context.Context) error { } type convertedValues struct { - Algs []any - Auds []any - Certs []any - ClaimsScopes []any - AccountClaimMaps []any - Prompts []any + Algs []*SigningAlg + Auds []*AudClaim + Certs []*Certificate + ClaimsScopes []*ClaimsScope + AccountClaimMaps []*AccountClaimMap + Prompts []*Prompt } // convertValueObjects converts the embedded value objects. It will return an @@ -305,121 +305,113 @@ func (am *AuthMethod) convertValueObjects(ctx context.Context) (*convertedValues return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } var err error - var addAlgs, addAuds, addCerts, addScopes, addAccountClaimMaps, addPrompts []any - if addAlgs, err = am.convertSigningAlgs(ctx); err != nil { + converted := &convertedValues{} + if converted.Algs, err = am.convertSigningAlgs(ctx); err != nil { return nil, errors.Wrap(ctx, err, op) } - if addAuds, err = am.convertAudClaims(ctx); err != nil { + if converted.Auds, err = am.convertAudClaims(ctx); err != nil { return nil, errors.Wrap(ctx, err, op) } - if addCerts, err = am.convertCertificates(ctx); err != nil { + if converted.Certs, err = am.convertCertificates(ctx); err != nil { return nil, errors.Wrap(ctx, err, op) } - if addScopes, err = am.convertClaimsScopes(ctx); err != nil { + if converted.ClaimsScopes, err = am.convertClaimsScopes(ctx); err != nil { return nil, errors.Wrap(ctx, err, op) } - if addAccountClaimMaps, err = am.convertAccountClaimMaps(ctx); err != nil { + if converted.AccountClaimMaps, err = am.convertAccountClaimMaps(ctx); err != nil { return nil, errors.Wrap(ctx, err, op) } - if addPrompts, err = am.convertPrompts(ctx); err != nil { + if converted.Prompts, err = am.convertPrompts(ctx); err != nil { return nil, errors.Wrap(ctx, err, op) } - return &convertedValues{ - Algs: addAlgs, - Auds: addAuds, - Certs: addCerts, - ClaimsScopes: addScopes, - AccountClaimMaps: addAccountClaimMaps, - Prompts: addPrompts, - }, nil + return converted, nil } // convertSigningAlgs converts the embedded signing algorithms from []string -// to []interface{} where each slice element is a *SigningAlg. It will return an -// error if the AuthMethod's public id is not set. -func (am *AuthMethod) convertSigningAlgs(ctx context.Context) ([]any, error) { +// to []*SigningAlg. It will return an error if the AuthMethod's public id is +// not set. +func (am *AuthMethod) convertSigningAlgs(ctx context.Context) ([]*SigningAlg, error) { const op = "oidc.(AuthMethod).convertSigningAlgs" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newInterfaces := make([]any, 0, len(am.SigningAlgs)) + newAlgs := make([]*SigningAlg, 0, len(am.SigningAlgs)) for _, a := range am.SigningAlgs { obj, err := NewSigningAlg(ctx, am.PublicId, Alg(a)) if err != nil { return nil, errors.Wrap(ctx, err, op) } - newInterfaces = append(newInterfaces, obj) + newAlgs = append(newAlgs, obj) } - return newInterfaces, nil + return newAlgs, nil } // convertAudClaims converts the embedded audience claims from []string -// to []interface{} where each slice element is a *AudClaim. It will return an -// error if the AuthMethod's public id is not set. -func (am *AuthMethod) convertAudClaims(ctx context.Context) ([]any, error) { +// to []*AudClaim. It will return an error if the AuthMethod's public id is not +// set. +func (am *AuthMethod) convertAudClaims(ctx context.Context) ([]*AudClaim, error) { const op = "oidc.(AuthMethod).convertAudClaims" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newInterfaces := make([]any, 0, len(am.AudClaims)) + newClaims := make([]*AudClaim, 0, len(am.AudClaims)) for _, a := range am.AudClaims { obj, err := NewAudClaim(ctx, am.PublicId, a) if err != nil { return nil, errors.Wrap(ctx, err, op) } - newInterfaces = append(newInterfaces, obj) + newClaims = append(newClaims, obj) } - return newInterfaces, nil + return newClaims, nil } // convertCertificates converts the embedded certificates from []string -// to []interface{} where each slice element is a *Certificate. It will return an -// error if the AuthMethod's public id is not set. -func (am *AuthMethod) convertCertificates(ctx context.Context) ([]any, error) { +// to []*Certificate. It will return an error if the AuthMethod's public id is +// not set. +func (am *AuthMethod) convertCertificates(ctx context.Context) ([]*Certificate, error) { const op = "oidc.(AuthMethod).convertCertificates" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newInterfaces := make([]any, 0, len(am.Certificates)) + newCerts := make([]*Certificate, 0, len(am.Certificates)) for _, cert := range am.Certificates { obj, err := NewCertificate(ctx, am.PublicId, cert) if err != nil { return nil, errors.Wrap(ctx, err, op) } - newInterfaces = append(newInterfaces, obj) + newCerts = append(newCerts, obj) } - return newInterfaces, nil + return newCerts, nil } // convertClaimsScopes converts the embedded claims scopes from []string -// to []interface{} where each slice element is a *ClaimsScope. It will return an -// error if the AuthMethod's public id is not set. -func (am *AuthMethod) convertClaimsScopes(ctx context.Context) ([]any, error) { +// to []*ClaimsScope. It will return an error if the AuthMethod's public id is +// not set. +func (am *AuthMethod) convertClaimsScopes(ctx context.Context) ([]*ClaimsScope, error) { const op = "oidc.(AuthMethod).convertClaimsScopes" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newInterfaces := make([]any, 0, len(am.ClaimsScopes)) + newClaimsScopes := make([]*ClaimsScope, 0, len(am.ClaimsScopes)) for _, cs := range am.ClaimsScopes { obj, err := NewClaimsScope(ctx, am.PublicId, cs) if err != nil { return nil, errors.Wrap(ctx, err, op) } - newInterfaces = append(newInterfaces, obj) + newClaimsScopes = append(newClaimsScopes, obj) } - return newInterfaces, nil + return newClaimsScopes, nil } // convertAccountClaimMaps converts the embedded account claim maps from -// []string to []interface{} where each slice element is a *AccountClaimMap. It -// will return an error if the AuthMethod's public id is not set or it can -// convert the account claim maps. -func (am *AuthMethod) convertAccountClaimMaps(ctx context.Context) ([]any, error) { +// []*AccountClaimMap. It will return an error if the AuthMethod's public id is +// not set or it can convert the account claim maps. +func (am *AuthMethod) convertAccountClaimMaps(ctx context.Context) ([]*AccountClaimMap, error) { const op = "oidc.(AuthMethod).convertAccountClaimMaps" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newInterfaces := make([]any, 0, len(am.AccountClaimMaps)) + newAccountClaimMaps := make([]*AccountClaimMap, 0, len(am.AccountClaimMaps)) const ( from = 0 to = 1 @@ -437,9 +429,9 @@ func (am *AuthMethod) convertAccountClaimMaps(ctx context.Context) ([]any, error if err != nil { return nil, errors.Wrap(ctx, err, op) } - newInterfaces = append(newInterfaces, obj) + newAccountClaimMaps = append(newAccountClaimMaps, obj) } - return newInterfaces, nil + return newAccountClaimMaps, nil } // ClaimMap defines the To and From of an oidc claim map @@ -477,20 +469,20 @@ func ParseAccountClaimMaps(ctx context.Context, m ...string) ([]ClaimMap, error) } // convertPrompts converts the embedded prompts from []string -// to []interface{} where each slice element is a *Prompt. It will return an -// error if the AuthMethod's public id is not set. -func (am *AuthMethod) convertPrompts(ctx context.Context) ([]any, error) { +// to []*Prompt. It will return an error if the AuthMethod's public id is not +// set. +func (am *AuthMethod) convertPrompts(ctx context.Context) ([]*Prompt, error) { const op = "oidc.(AuthMethod).convertPrompts" if am.PublicId == "" { return nil, errors.New(ctx, errors.InvalidPublicId, op, "missing public id") } - newInterfaces := make([]any, 0, len(am.Prompts)) + newPrompts := make([]*Prompt, 0, len(am.Prompts)) for _, a := range am.Prompts { obj, err := NewPrompt(ctx, am.PublicId, PromptParam(a)) if err != nil { return nil, errors.Wrap(ctx, err, op) } - newInterfaces = append(newInterfaces, obj) + newPrompts = append(newPrompts, obj) } - return newInterfaces, nil + return newPrompts, nil } diff --git a/internal/auth/oidc/auth_method_test.go b/internal/auth/oidc/auth_method_test.go index 11ec01b2ad1..67c7017832e 100644 --- a/internal/auth/oidc/auth_method_test.go +++ b/internal/auth/oidc/auth_method_test.go @@ -550,7 +550,7 @@ func Test_convertValueObjects(t *testing.T) { testPublicId := "test-id" testAlgs := []string{string(RS256), string(RS384)} - var testSigningAlgs []any + var testSigningAlgs []*SigningAlg for _, a := range []Alg{RS256, RS384} { obj, err := NewSigningAlg(ctx, testPublicId, Alg(a)) require.NoError(t, err) @@ -558,7 +558,7 @@ func Test_convertValueObjects(t *testing.T) { } testAuds := []string{"alice", "eve"} - var testAudiences []any + var testAudiences []*AudClaim for _, a := range testAuds { obj, err := NewAudClaim(ctx, testPublicId, a) require.NoError(t, err) @@ -569,10 +569,10 @@ func Test_convertValueObjects(t *testing.T) { testCerts := []string{pem} c, err := NewCertificate(ctx, testPublicId, pem) require.NoError(t, err) - testCertificates := []any{c} + testCertificates := []*Certificate{c} testScopes := []string{"profile", "email"} - testClaimsScopes := make([]any, 0, len(testScopes)) + testClaimsScopes := make([]*ClaimsScope, 0, len(testScopes)) for _, s := range testScopes { obj, err := NewClaimsScope(ctx, testPublicId, s) require.NoError(t, err) @@ -580,7 +580,7 @@ func Test_convertValueObjects(t *testing.T) { } testClaimMaps := []string{"oid=sub", "display_name=name"} - testAccountClaimMaps := make([]any, 0, len(testClaimMaps)) + testAccountClaimMaps := make([]*AccountClaimMap, 0, len(testClaimMaps)) acms, err := ParseAccountClaimMaps(ctx, testClaimMaps...) require.NoError(t, err) for _, m := range acms { @@ -592,7 +592,7 @@ func Test_convertValueObjects(t *testing.T) { } testPrompts := []string{"consent", "select_account"} - testExpectedPrompts := make([]any, 0, len(testPrompts)) + testExpectedPrompts := make([]*Prompt, 0, len(testPrompts)) for _, a := range testPrompts { obj, err := NewPrompt(ctx, testPublicId, PromptParam(a)) require.NoError(t, err) @@ -690,11 +690,11 @@ func Test_convertValueObjects(t *testing.T) { } else { want := make([]*AccountClaimMap, 0, len(tt.wantValues.AccountClaimMaps)) for _, v := range tt.wantValues.AccountClaimMaps { - want = append(want, v.(*AccountClaimMap)) + want = append(want, v) } got := make([]*AccountClaimMap, 0, len(convertedMaps)) for _, v := range convertedMaps { - got = append(got, v.(*AccountClaimMap)) + got = append(got, v) } sort.Slice(want, func(a, b int) bool { return want[a].ToClaim < want[b].ToClaim @@ -730,30 +730,51 @@ func Test_convertValueObjects(t *testing.T) { } } -type converted []any - -func (a converted) Len() int { return len(a) } -func (a converted) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a converted) Less(i, j int) bool { - switch a[i].(type) { - case *SigningAlg: - return a[i].(*SigningAlg).GetAlg() < a[j].(*SigningAlg).GetAlg() - case *Certificate: - return a[i].(*Certificate).GetCert() < a[j].(*Certificate).GetCert() - case *AccountClaimMap: - return a[i].(*AccountClaimMap).GetToClaim() < a[j].(*AccountClaimMap).GetToClaim() - case *AudClaim: - return a[i].(*AudClaim).GetAud() < a[j].(*AudClaim).GetAud() - case *ClaimsScope: - return a[i].(*ClaimsScope).GetScope() < a[j].(*ClaimsScope).GetScope() - } - return false +type sortableAlgs []*SigningAlg + +func (s sortableAlgs) Len() int { return len(s) } +func (s sortableAlgs) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s sortableAlgs) Less(i, j int) bool { + return s[i].GetAlg() < s[j].GetAlg() +} + +type sortableCerts []*Certificate + +func (s sortableCerts) Len() int { return len(s) } +func (s sortableCerts) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s sortableCerts) Less(i, j int) bool { + return s[i].GetCert() < s[j].GetCert() +} + +type sortableAccountClaimMaps []*AccountClaimMap + +func (s sortableAccountClaimMaps) Len() int { return len(s) } +func (s sortableAccountClaimMaps) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s sortableAccountClaimMaps) Less(i, j int) bool { + return s[i].GetFromClaim()+s[i].GetToClaim() < s[j].GetFromClaim()+s[j].GetToClaim() +} + +type sortableAuds []*AudClaim + +func (s sortableAuds) Len() int { return len(s) } +func (s sortableAuds) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s sortableAuds) Less(i, j int) bool { + return s[i].GetAud() < s[j].GetAud() +} + +type sortableClaimsScopes []*ClaimsScope + +func (s sortableClaimsScopes) Len() int { return len(s) } +func (s sortableClaimsScopes) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s sortableClaimsScopes) Less(i, j int) bool { + return s[i].GetScope() < s[j].GetScope() } func testSortConverted(t *testing.T, c *convertedValues) { - sort.Sort(converted(c.Algs)) - sort.Sort(converted(c.Certs)) - sort.Sort(converted(c.AccountClaimMaps)) - sort.Sort(converted(c.Auds)) - sort.Sort(converted(c.ClaimsScopes)) + t.Helper() + sort.Sort(sortableAlgs(c.Algs)) + sort.Sort(sortableCerts(c.Certs)) + sort.Sort(sortableAccountClaimMaps(c.AccountClaimMaps)) + sort.Sort(sortableAuds(c.Auds)) + sort.Sort(sortableClaimsScopes(c.ClaimsScopes)) } diff --git a/internal/auth/oidc/repository_auth_method_update.go b/internal/auth/oidc/repository_auth_method_update.go index 71487422681..12faaacac1a 100644 --- a/internal/auth/oidc/repository_auth_method_update.go +++ b/internal/auth/oidc/repository_auth_method_update.go @@ -155,47 +155,93 @@ func (r *Repository) UpdateAuthMethod(ctx context.Context, am *AuthMethod, versi } } - addAlgs, deleteAlgs, err := valueObjectChanges(ctx, origAm.PublicId, SigningAlgVO, am.SigningAlgs, origAm.SigningAlgs, dbMask, nullFields) + aa, ad, err := valueObjectChanges(ctx, origAm.PublicId, SigningAlgVO, am.SigningAlgs, origAm.SigningAlgs, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op) } + addAlgs := []*SigningAlg{} + for _, a := range aa { + addAlgs = append(addAlgs, a.(*SigningAlg)) + } + deleteAlgs := []*SigningAlg{} + for _, a := range ad { + deleteAlgs = append(deleteAlgs, a.(*SigningAlg)) + } - addCerts, deleteCerts, err := valueObjectChanges(ctx, origAm.PublicId, CertificateVO, am.Certificates, origAm.Certificates, dbMask, nullFields) + ac, dc, err := valueObjectChanges(ctx, origAm.PublicId, CertificateVO, am.Certificates, origAm.Certificates, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op) } + addCerts := []*Certificate{} + for _, c := range ac { + addCerts = append(addCerts, c.(*Certificate)) + } + deleteCerts := []*Certificate{} + for _, c := range dc { + deleteCerts = append(deleteCerts, c.(*Certificate)) + } - addAuds, deleteAuds, err := valueObjectChanges(ctx, origAm.PublicId, AudClaimVO, am.AudClaims, origAm.AudClaims, dbMask, nullFields) + aa, ad, err = valueObjectChanges(ctx, origAm.PublicId, AudClaimVO, am.AudClaims, origAm.AudClaims, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op) } + addAuds := []*AudClaim{} + for _, a := range aa { + addAuds = append(addAuds, a.(*AudClaim)) + } + deleteAuds := []*AudClaim{} + for _, a := range ad { + deleteAuds = append(deleteAuds, a.(*AudClaim)) + } - addScopes, deleteScopes, err := valueObjectChanges(ctx, origAm.PublicId, ClaimsScopesVO, am.ClaimsScopes, origAm.ClaimsScopes, dbMask, nullFields) + as, ds, err := valueObjectChanges(ctx, origAm.PublicId, ClaimsScopesVO, am.ClaimsScopes, origAm.ClaimsScopes, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op) } + addScopes := []*ClaimsScope{} + for _, s := range as { + addScopes = append(addScopes, s.(*ClaimsScope)) + } + deleteScopes := []*ClaimsScope{} + for _, s := range ds { + deleteScopes = append(deleteScopes, s.(*ClaimsScope)) + } - addMaps, deleteMaps, err := valueObjectChanges(ctx, origAm.PublicId, AccountClaimMapsVO, am.AccountClaimMaps, origAm.AccountClaimMaps, dbMask, nullFields) + aacm, dacm, err := valueObjectChanges(ctx, origAm.PublicId, AccountClaimMapsVO, am.AccountClaimMaps, origAm.AccountClaimMaps, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op) } + addMaps := []*AccountClaimMap{} + for _, m := range aacm { + addMaps = append(addMaps, m.(*AccountClaimMap)) + } + deleteMaps := []*AccountClaimMap{} + for _, m := range dacm { + deleteMaps = append(deleteMaps, m.(*AccountClaimMap)) + } - addPrompts, deletePrompts, err := valueObjectChanges(ctx, origAm.PublicId, PromptsVO, am.Prompts, origAm.Prompts, dbMask, nullFields) + ap, dp, err := valueObjectChanges(ctx, origAm.PublicId, PromptsVO, am.Prompts, origAm.Prompts, dbMask, nullFields) if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op) } + addPrompts := []*Prompt{} + for _, p := range ap { + addPrompts = append(addPrompts, p.(*Prompt)) + } + deletePrompts := []*Prompt{} + for _, p := range dp { + deletePrompts = append(deletePrompts, p.(*Prompt)) + } // we don't allow updates for "sub" claim maps, because we have no way to // determine if the updated "from" claim in the map might create collisions // with any existing account's subject. - for _, rawCm := range addMaps { - cm := rawCm.(*AccountClaimMap) + for _, cm := range addMaps { if cm.ToClaim == string(ToSubClaim) { return nil, db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("you cannot update account claim map %s=%s for the \"sub\" claim", cm.FromClaim, cm.ToClaim)) } } - for _, rawCm := range deleteMaps { - cm := rawCm.(*AccountClaimMap) + for _, cm := range deleteMaps { if cm.ToClaim == string(ToSubClaim) { return nil, db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("you cannot update account claim map %s=%s for the \"sub\" claim", cm.FromClaim, cm.ToClaim)) } diff --git a/internal/auth/oidc/repository_managed_group_members.go b/internal/auth/oidc/repository_managed_group_members.go index 1cb3b587440..96e04b60b9c 100644 --- a/internal/auth/oidc/repository_managed_group_members.go +++ b/internal/auth/oidc/repository_managed_group_members.go @@ -117,7 +117,7 @@ func (r *Repository) SetManagedGroupMemberships(ctx context.Context, am *AuthMet } // Figure out which ones to delete and which ones we already have - toDelete := make([]any, 0, len(mgs)) + toDelete := make([]*ManagedGroupMemberAccount, 0, len(mgs)) for _, currMg := range currentMemberships { currMgId := currMg.ManagedGroupId if newMgPublicIds[currMgId] { @@ -161,7 +161,7 @@ func (r *Repository) SetManagedGroupMemberships(ctx context.Context, am *AuthMet if len(newMgPublicIds) > 0 { metadata["op-type"] = append(metadata["op-type"], oplog.OpType_OP_TYPE_CREATE.String()) addOplogMsgs := make([]*oplog.Message, 0, len(newMgPublicIds)) - toAdd := make([]any, 0, len(newMgPublicIds)) + toAdd := make([]*ManagedGroupMemberAccount, 0, len(newMgPublicIds)) for mgId := range newMgPublicIds { newMg := AllocManagedGroupMemberAccount() newMg.ManagedGroupId = mgId diff --git a/internal/auth/oidc/testing.go b/internal/auth/oidc/testing.go index be4e924d38d..5ec87d0f0f1 100644 --- a/internal/auth/oidc/testing.go +++ b/internal/auth/oidc/testing.go @@ -68,7 +68,7 @@ func TestAuthMethod( require.NoError(err) if len(opts.withAudClaims) > 0 { - newAudClaims := make([]any, 0, len(opts.withAudClaims)) + newAudClaims := make([]*AudClaim, 0, len(opts.withAudClaims)) for _, a := range opts.withAudClaims { aud, err := NewAudClaim(ctx, authMethod.PublicId, a) require.NoError(err) @@ -79,7 +79,7 @@ func TestAuthMethod( require.Equal(len(opts.withAudClaims), len(authMethod.AudClaims)) } if len(opts.withCertificates) > 0 { - newCerts := make([]any, 0, len(opts.withCertificates)) + newCerts := make([]*Certificate, 0, len(opts.withCertificates)) for _, c := range opts.withCertificates { pem, err := EncodeCertificates(ctx, c) require.NoError(err) @@ -92,7 +92,7 @@ func TestAuthMethod( require.Equal(len(opts.withCertificates), len(authMethod.Certificates)) } if len(opts.withSigningAlgs) > 0 { - newAlgs := make([]any, 0, len(opts.withSigningAlgs)) + newAlgs := make([]*SigningAlg, 0, len(opts.withSigningAlgs)) for _, a := range opts.withSigningAlgs { alg, err := NewSigningAlg(ctx, authMethod.PublicId, a) require.NoError(err) @@ -103,7 +103,7 @@ func TestAuthMethod( require.Equal(len(opts.withSigningAlgs), len(authMethod.SigningAlgs)) } if len(opts.withClaimsScopes) > 0 { - newClaimsScopes := make([]any, 0, len(opts.withClaimsScopes)) + newClaimsScopes := make([]*ClaimsScope, 0, len(opts.withClaimsScopes)) for _, cs := range opts.withClaimsScopes { s, err := NewClaimsScope(ctx, authMethod.PublicId, cs) require.NoError(err) @@ -114,7 +114,7 @@ func TestAuthMethod( require.Equal(len(opts.withClaimsScopes), len(authMethod.ClaimsScopes)) } if len(opts.withAccountClaimMap) > 0 { - newAccountClaimMaps := make([]any, 0, len(opts.withAccountClaimMap)) + newAccountClaimMaps := make([]*AccountClaimMap, 0, len(opts.withAccountClaimMap)) for k, v := range opts.withAccountClaimMap { acm, err := NewAccountClaimMap(ctx, authMethod.PublicId, k, v) require.NoError(err) @@ -124,7 +124,7 @@ func TestAuthMethod( require.Equal(len(opts.withAccountClaimMap), len(authMethod.AccountClaimMaps)) } if len(opts.withPrompts) > 0 { - newPrompts := make([]any, 0, len(opts.withPrompts)) + newPrompts := make([]*Prompt, 0, len(opts.withPrompts)) for _, p := range opts.withPrompts { prompt, err := NewPrompt(ctx, authMethod.PublicId, p) require.NoError(err) diff --git a/internal/clientcache/internal/cache/search_test.go b/internal/clientcache/internal/cache/search_test.go index b8bc008215c..e5f047eb0de 100644 --- a/internal/clientcache/internal/cache/search_test.go +++ b/internal/clientcache/internal/cache/search_test.go @@ -204,21 +204,21 @@ func TestSearch(t *testing.T) { require.NoError(t, rw.Create(ctx, u)) require.NoError(t, rw.Create(ctx, at)) - aliases := []any{ - &ResolvableAlias{FkUserId: u.Id, Id: "alt_1", Value: "one", Type: "target", Item: `{"id": "alt_1", "value": "one", "type": "target"}`}, - &ResolvableAlias{FkUserId: u.Id, Id: "alt_2", Value: "two", Type: "target", Item: `{"id": "alt_2", "value": "two", "type": "target"}`}, + aliases := []*ResolvableAlias{ + {FkUserId: u.Id, Id: "alt_1", Value: "one", Type: "target", Item: `{"id": "alt_1", "value": "one", "type": "target"}`}, + {FkUserId: u.Id, Id: "alt_2", Value: "two", Type: "target", Item: `{"id": "alt_2", "value": "two", "type": "target"}`}, } require.NoError(t, rw.CreateItems(ctx, aliases)) - targets := []any{ - &Target{FkUserId: u.Id, Id: "t_1", Name: "one", Type: "tcp", Item: `{"id": "t_1", "name": "one", "type": "tcp"}`}, - &Target{FkUserId: u.Id, Id: "t_2", Name: "two", Type: "tcp", Item: `{"id": "t_2", "name": "two", "type": "tcp"}`}, + targets := []*Target{ + {FkUserId: u.Id, Id: "t_1", Name: "one", Type: "tcp", Item: `{"id": "t_1", "name": "one", "type": "tcp"}`}, + {FkUserId: u.Id, Id: "t_2", Name: "two", Type: "tcp", Item: `{"id": "t_2", "name": "two", "type": "tcp"}`}, } require.NoError(t, rw.CreateItems(ctx, targets)) - sessions := []any{ - &Session{FkUserId: u.Id, Id: "s_1", Endpoint: "one", Type: "tcp", UserId: "u123", Item: `{"id": "s_1", "endpoint": "one", "type": "tcp", "user_id": "u123"}`}, - &Session{FkUserId: u.Id, Id: "s_2", Endpoint: "two", Type: "ssh", UserId: "u321", Item: `{"id": "s_2", "endpoint": "two", "type": "ssh", "user_id": "u321"}`}, + sessions := []*Session{ + {FkUserId: u.Id, Id: "s_1", Endpoint: "one", Type: "tcp", UserId: "u123", Item: `{"id": "s_1", "endpoint": "one", "type": "tcp", "user_id": "u123"}`}, + {FkUserId: u.Id, Id: "s_2", Endpoint: "two", Type: "ssh", UserId: "u321", Item: `{"id": "s_2", "endpoint": "two", "type": "ssh", "user_id": "u321"}`}, } require.NoError(t, rw.CreateItems(ctx, sessions)) } diff --git a/internal/db/changesafe_reader_writer.go b/internal/db/changesafe_reader_writer.go index 02e3ca149d9..7a62d3dab5a 100644 --- a/internal/db/changesafe_reader_writer.go +++ b/internal/db/changesafe_reader_writer.go @@ -75,7 +75,7 @@ func (w *changeSafeDbwWriter) Create(ctx context.Context, i any, opt ...dbw.Opti return dbw.New(w.db.underlying.wrapped.Load()).Create(ctx, i, opt...) } -func (w *changeSafeDbwWriter) CreateItems(ctx context.Context, createItems []any, opt ...dbw.Option) error { +func (w *changeSafeDbwWriter) CreateItems(ctx context.Context, createItems any, opt ...dbw.Option) error { return dbw.New(w.db.underlying.wrapped.Load()).CreateItems(ctx, createItems, opt...) } @@ -83,7 +83,7 @@ func (w *changeSafeDbwWriter) Delete(ctx context.Context, i any, opt ...dbw.Opti return dbw.New(w.db.underlying.wrapped.Load()).Delete(ctx, i, opt...) } -func (w *changeSafeDbwWriter) DeleteItems(ctx context.Context, deleteItems []any, opt ...dbw.Option) (int, error) { +func (w *changeSafeDbwWriter) DeleteItems(ctx context.Context, deleteItems any, opt ...dbw.Option) (int, error) { return dbw.New(w.db.underlying.wrapped.Load()).DeleteItems(ctx, deleteItems, opt...) } diff --git a/internal/db/read_writer.go b/internal/db/read_writer.go index adf1dfbe0c7..29f3da7b5ec 100644 --- a/internal/db/read_writer.go +++ b/internal/db/read_writer.go @@ -112,7 +112,7 @@ type Writer interface { // cycle of the writer and if an error is returned the caller must decide // what to do with the transaction, which almost always should be to // rollback. - CreateItems(ctx context.Context, createItems []any, opt ...Option) error + CreateItems(ctx context.Context, createItems any, opt ...Option) error // Delete an object in the db with options: WithOplog, WithDebug. // The caller is responsible for the transaction life cycle of the writer @@ -127,7 +127,7 @@ type Writer interface { // transaction life cycle of the writer and if an error is returned the // caller must decide what to do with the transaction, which almost always // should be to rollback. Delete returns the number of rows deleted or an error. - DeleteItems(ctx context.Context, deleteItems []any, opt ...Option) (int, error) + DeleteItems(ctx context.Context, deleteItems any, opt ...Option) (int, error) // Exec will execute the sql with the values as parameters. The int returned // is the number of rows affected by the sql. No options are currently @@ -311,7 +311,7 @@ func (rw *Db) Create(ctx context.Context, i any, opt ...Option) error { // WithDebug, WithOplog, WithOplogMsgs, WithReturnRowsAffected, OnConflict, // WithVersion, and WithWhere WithOplog and WithOplogMsgs may not be used // together. WithLookup is not a supported option. -func (rw *Db) CreateItems(ctx context.Context, createItems []any, opt ...Option) error { +func (rw *Db) CreateItems(ctx context.Context, createItems any, opt ...Option) error { const op = "db.CreateItems" if rw.underlying == nil { return errors.New(ctx, errors.InvalidParameter, op, "missing underlying db") @@ -389,7 +389,7 @@ func (rw *Db) Delete(ctx context.Context, i any, opt ...Option) (int, error) { // DeleteItems will delete multiple items of the same type. Supported options: // WithOplog and WithOplogMsgs. WithOplog and WithOplogMsgs may not be used // together. -func (rw *Db) DeleteItems(ctx context.Context, deleteItems []any, opt ...Option) (int, error) { +func (rw *Db) DeleteItems(ctx context.Context, deleteItems any, opt ...Option) (int, error) { const op = "db.DeleteItems" if rw.underlying == nil { return NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "missing underlying db") diff --git a/internal/db/read_writer_ext_test.go b/internal/db/read_writer_ext_test.go index 816be2ada9e..10338b69516 100644 --- a/internal/db/read_writer_ext_test.go +++ b/internal/db/read_writer_ext_test.go @@ -219,7 +219,7 @@ func TestDb_Create_OnConflict(t *testing.T) { Target: db.Constraint("db_test_user_public_id_key"), Action: db.SetColumns([]string{"name"}), } - users := []any{} + users := []*db_test.TestUser{} users = append(users, conflictUser) var rowsAffected int64 err = rw.CreateItems(ctx, users, db.WithOnConflict(&onConflict), db.WithOplog(oplogWrapper, md), db.WithReturnRowsAffected(&rowsAffected)) diff --git a/internal/db/read_writer_oplog.go b/internal/db/read_writer_oplog.go index bf3af721519..299b012f959 100644 --- a/internal/db/read_writer_oplog.go +++ b/internal/db/read_writer_oplog.go @@ -108,7 +108,7 @@ func (rw *Db) generateOplogBeforeAfterOpts(ctx context.Context, i any, opType Op case withOplog && (opType == CreateItemsOp || opType == DeleteItemsOp): afterFn = func(i any, rowsAffected int) error { const op = "db.afterFnMultiItem" - err := rw.addOplogForItems(ctx, opType, opts, ticket, i.([]any)) + err := rw.addOplogForItems(ctx, opType, opts, ticket, items) if err != nil { return errors.Wrap(ctx, err, op, errors.WithMsg("returning oplog msgs failed")) } diff --git a/internal/db/read_writer_test.go b/internal/db/read_writer_test.go index 787b5a8ec29..0340dcfdd37 100644 --- a/internal/db/read_writer_test.go +++ b/internal/db/read_writer_test.go @@ -1682,8 +1682,8 @@ func TestDb_CreateItems(t *testing.T) { oplogWrapper := TestOplogWrapper(t, db) testOplogResourceId := testId(t) - createFn := func() []any { - results := []any{} + createFn := func() []*db_test.TestUser { + results := []*db_test.TestUser{} for i := 0; i < 10; i++ { u, err := db_test.NewTestUser() require.NoError(t, err) @@ -1705,7 +1705,7 @@ func TestDb_CreateItems(t *testing.T) { returnedMsgs := []*oplog.Message{} type args struct { - createItems []any + createItems any opt []Option } tests := []struct { @@ -1865,21 +1865,19 @@ func TestDb_CreateItems(t *testing.T) { return } require.NoError(err) - for _, item := range tt.args.createItems { + for _, item := range tt.args.createItems.([]*db_test.TestUser) { u := db_test.AllocTestUser() - u.PublicId = item.(*db_test.TestUser).PublicId + u.PublicId = item.PublicId err := rw.LookupByPublicId(context.Background(), &u) assert.NoError(err) - if _, ok := item.(*db_test.TestUser); ok { - assert.Truef(proto.Equal(item.(*db_test.TestUser).StoreTestUser, u.StoreTestUser), "%s and %s should be equal", item, u) - } + assert.Truef(proto.Equal(item.StoreTestUser, u.StoreTestUser), "%s and %s should be equal", item, u) } if tt.wantOplogId != "" { err = TestVerifyOplog(t, rw, tt.wantOplogId, WithOperation(oplog.OpType_OP_TYPE_CREATE), WithCreateNotBefore(10*time.Second)) assert.NoError(err) } if tt.wantOplogMsgs { - assert.Equal(len(tt.args.createItems), len(returnedMsgs)) + assert.Equal(len(tt.args.createItems.([]*db_test.TestUser)), len(returnedMsgs)) for _, m := range returnedMsgs { assert.Equal(m.OpType, oplog.OpType_OP_TYPE_CREATE) } @@ -1894,8 +1892,8 @@ func TestDb_DeleteItems(t *testing.T) { oplogWrapper := TestOplogWrapper(t, db) testOplogResourceId := testId(t) - createFn := func() []any { - results := []any{} + createFn := func() []*db_test.TestUser { + results := []*db_test.TestUser{} for i := 0; i < 10; i++ { u := testUser(t, db, "", "", "") results = append(results, u) @@ -1906,7 +1904,7 @@ func TestDb_DeleteItems(t *testing.T) { returnedMsgs := []*oplog.Message{} type args struct { - deleteItems []any + deleteItems []*db_test.TestUser opt []Option } tests := []struct { @@ -2034,7 +2032,7 @@ func TestDb_DeleteItems(t *testing.T) { name: "empty items", underlying: db, args: args{ - deleteItems: []any{}, + deleteItems: []*db_test.TestUser{}, }, wantErr: true, wantErrIs: errors.InvalidParameter, @@ -2063,7 +2061,7 @@ func TestDb_DeleteItems(t *testing.T) { assert.Equal(tt.wantRowsDeleted, rowsDeleted) for _, item := range tt.args.deleteItems { u := db_test.AllocTestUser() - u.PublicId = item.(*db_test.TestUser).PublicId + u.PublicId = item.PublicId err := rw.LookupByPublicId(context.Background(), &u) require.Error(err) require.Truef(errors.Match(errors.T(errors.RecordNotFound), err), "found item %s that should be deleted", u.PublicId) diff --git a/internal/db/schema/migrations/oss/postgres_20_05_test.go b/internal/db/schema/migrations/oss/postgres_20_05_test.go index f9288b5d80a..5246a83dbc7 100644 --- a/internal/db/schema/migrations/oss/postgres_20_05_test.go +++ b/internal/db/schema/migrations/oss/postgres_20_05_test.go @@ -222,7 +222,7 @@ values require.NoError(err) // Add items to insert - var items []any + var items []*host.PreferredEndpoint for _, cond := range tt.conditions { ep := host.AllocPreferredEndpoint() ep.HostSetId = tt.hostSetId diff --git a/internal/host/plugin/job_set_sync.go b/internal/host/plugin/job_set_sync.go index a2428b1976c..8548e176fd0 100644 --- a/internal/host/plugin/job_set_sync.go +++ b/internal/host/plugin/job_set_sync.go @@ -437,7 +437,7 @@ func (r *SetSyncJob) upsertAndCleanHosts( { if len(hi.ipsToRemove) > 0 { oplogMsgs := make([]*oplog.Message, 0, len(hi.ipsToRemove)) - count, err := w.DeleteItems(ctx, hi.ipsToRemove.toArray(), db.NewOplogMsgs(&oplogMsgs)) + count, err := w.DeleteItems(ctx, hi.ipsToRemove.toSlice(), db.NewOplogMsgs(&oplogMsgs)) if err != nil { return err } @@ -452,8 +452,8 @@ func (r *SetSyncJob) upsertAndCleanHosts( Target: db.Constraint("host_ip_address_pkey"), Action: db.DoNothing(true), } - if err := w.CreateItems(ctx, hi.ipsToAdd.toArray(), db.NewOplogMsgs(&oplogMsgs), db.WithOnConflict(onConflict)); err != nil { - return errors.Wrap(ctx, err, op, errors.WithMsg(fmt.Sprintf("adding ips %v for host %q", hi.ipsToAdd.toArray(), ret.GetPublicId()))) + if err := w.CreateItems(ctx, hi.ipsToAdd.toSlice(), db.NewOplogMsgs(&oplogMsgs), db.WithOnConflict(onConflict)); err != nil { + return errors.Wrap(ctx, err, op, errors.WithMsg(fmt.Sprintf("adding ips %v for host %q", hi.ipsToAdd.toSlice(), ret.GetPublicId()))) } msgs = append(msgs, oplogMsgs...) } @@ -463,7 +463,7 @@ func (r *SetSyncJob) upsertAndCleanHosts( { if len(hi.dnsNamesToRemove) > 0 { oplogMsgs := make([]*oplog.Message, 0, len(hi.dnsNamesToRemove)) - count, err := w.DeleteItems(ctx, hi.dnsNamesToRemove.toArray(), db.NewOplogMsgs(&oplogMsgs)) + count, err := w.DeleteItems(ctx, hi.dnsNamesToRemove.toSlice(), db.NewOplogMsgs(&oplogMsgs)) if err != nil { return err } @@ -478,7 +478,7 @@ func (r *SetSyncJob) upsertAndCleanHosts( Target: db.Constraint("host_dns_name_pkey"), Action: db.DoNothing(true), } - if err := w.CreateItems(ctx, hi.dnsNamesToAdd.toArray(), db.NewOplogMsgs(&oplogMsgs), db.WithOnConflict(onConflict)); err != nil { + if err := w.CreateItems(ctx, hi.dnsNamesToAdd.toSlice(), db.NewOplogMsgs(&oplogMsgs), db.WithOnConflict(onConflict)); err != nil { return err } msgs = append(msgs, oplogMsgs...) diff --git a/internal/host/plugin/repository_host_set.go b/internal/host/plugin/repository_host_set.go index c30c9f11045..8a21e0b7f5c 100644 --- a/internal/host/plugin/repository_host_set.go +++ b/internal/host/plugin/repository_host_set.go @@ -138,9 +138,9 @@ func (r *Repository) CreateSet(ctx context.Context, projectId string, s *HostSet } } - var preferredEndpoints []any + var preferredEndpoints []*host.PreferredEndpoint if s.PreferredEndpoints != nil { - preferredEndpoints = make([]any, 0, len(s.PreferredEndpoints)) + preferredEndpoints = make([]*host.PreferredEndpoint, 0, len(s.PreferredEndpoints)) for i, e := range s.PreferredEndpoints { obj, err := host.NewPreferredEndpoint(ctx, s.PublicId, uint32(i+1), e) if err != nil { @@ -392,9 +392,9 @@ func (r *Repository) UpdateSet(ctx context.Context, projectId string, s *HostSet } // Get the preferred endpoints to write out. - var preferredEndpoints []any + var preferredEndpoints []*host.PreferredEndpoint if endpointOp == endpointOpUpdate { - preferredEndpoints = make([]any, 0, len(newSet.PreferredEndpoints)) + preferredEndpoints = make([]*host.PreferredEndpoint, 0, len(newSet.PreferredEndpoints)) for i, e := range newSet.PreferredEndpoints { obj, err := host.NewPreferredEndpoint(ctx, newSet.PublicId, uint32(i+1), e) if err != nil { @@ -454,7 +454,7 @@ func (r *Repository) UpdateSet(ctx context.Context, projectId string, s *HostSet case endpointOpDelete, endpointOpUpdate: if len(currentSet.PreferredEndpoints) > 0 { // Delete all old endpoint entries. - var peps []any + var peps []*host.PreferredEndpoint for i := 1; i <= len(currentSet.PreferredEndpoints); i++ { p := host.AllocPreferredEndpoint() p.HostSetId, p.Priority = currentSet.GetPublicId(), uint32(i) diff --git a/internal/host/plugin/repository_host_util.go b/internal/host/plugin/repository_host_util.go index 4f9f34b35a0..1dd87de784d 100644 --- a/internal/host/plugin/repository_host_util.go +++ b/internal/host/plugin/repository_host_util.go @@ -5,6 +5,7 @@ package plugin import ( "context" + "reflect" "sort" "github.com/hashicorp/boundary/internal/errors" @@ -13,22 +14,30 @@ import ( "github.com/hashicorp/go-secure-stdlib/strutil" ) -// valueToInterfaceMap is a map that has a function to convert values into an -// array +// valueToInterfaceMap is a map that has a function to convert values into a +// slice type valueToInterfaceMap map[string]any -func (m valueToInterfaceMap) toArray() []any { +func (m valueToInterfaceMap) toSlice() any { switch { case m == nil: return nil case len(m) == 0: return make([]any, 0) default: - ret := make([]any, 0, len(m)) - for _, v := range m { - ret = append(ret, v) + var valueType reflect.Type + existingValues := make([]any, 0, len(m)) + for _, value := range m { + valueType = reflect.TypeOf(value) // Assume all values are the same type + existingValues = append(existingValues, value) } - return ret + // Create a slice of the concrete type + sliceType := reflect.SliceOf(valueType) + sliceValue := reflect.MakeSlice(sliceType, len(m), len(m)) + for i := 0; i < len(m); i++ { + sliceValue.Index(i).Set(reflect.ValueOf(existingValues[i])) + } + return sliceValue.Interface() } } diff --git a/internal/host/plugin/testing.go b/internal/host/plugin/testing.go index dfc05931fcf..3b1559415a1 100644 --- a/internal/host/plugin/testing.go +++ b/internal/host/plugin/testing.go @@ -125,10 +125,10 @@ func TestHost(t testing.TB, conn *db.DB, catId, externId string, opt ...Option) require.NoError(t, err) require.NoError(t, w.Create(ctx, host1)) - var ipAddresses []any + var ipAddresses []*host.IpAddress if len(host1.GetIpAddresses()) > 0 { sort.Strings(host1.IpAddresses) - ipAddresses = make([]any, 0, len(host1.GetIpAddresses())) + ipAddresses = make([]*host.IpAddress, 0, len(host1.GetIpAddresses())) for _, a := range host1.GetIpAddresses() { obj, err := host.NewIpAddress(ctx, host1.PublicId, a) require.NoError(t, err) @@ -137,10 +137,10 @@ func TestHost(t testing.TB, conn *db.DB, catId, externId string, opt ...Option) require.NoError(t, w.CreateItems(ctx, ipAddresses)) } - var dnsNames []any + var dnsNames []*host.DnsName if len(host1.GetDnsNames()) > 0 { sort.Strings(host1.DnsNames) - dnsNames = make([]any, 0, len(host1.GetDnsNames())) + dnsNames = make([]*host.DnsName, 0, len(host1.GetDnsNames())) for _, n := range host1.GetDnsNames() { obj, err := host.NewDnsName(ctx, host1.PublicId, n) require.NoError(t, err) diff --git a/internal/host/static/repository_host_set_member.go b/internal/host/static/repository_host_set_member.go index 693f2e1f118..404a3d7a141 100644 --- a/internal/host/static/repository_host_set_member.go +++ b/internal/host/static/repository_host_set_member.go @@ -74,8 +74,8 @@ func (r *Repository) AddSetMembers(ctx context.Context, projectId string, setId return hosts, nil } -func (r *Repository) newMembers(ctx context.Context, setId string, hostIds []string) ([]any, error) { - var members []any +func (r *Repository) newMembers(ctx context.Context, setId string, hostIds []string) ([]*HostSetMember, error) { + var members []*HostSetMember for _, id := range hostIds { var m *HostSetMember m, err := NewHostSetMember(ctx, setId, id) @@ -87,7 +87,7 @@ func (r *Repository) newMembers(ctx context.Context, setId string, hostIds []str return members, nil } -func createMembers(ctx context.Context, w db.Writer, members []any) ([]*oplog.Message, error) { +func createMembers(ctx context.Context, w db.Writer, members []*HostSetMember) ([]*oplog.Message, error) { var msgs []*oplog.Message if err := w.CreateItems(ctx, members, db.NewOplogMsgs(&msgs)); err != nil { return nil, errors.Wrap(ctx, err, "static.createMembers") @@ -214,7 +214,7 @@ func (r *Repository) DeleteSetMembers(ctx context.Context, projectId string, set return len(hostIds), nil } -func deleteMembers(ctx context.Context, w db.Writer, members []any) ([]*oplog.Message, error) { +func deleteMembers(ctx context.Context, w db.Writer, members []*HostSetMember) ([]*oplog.Message, error) { const op = "static.deleteMembers" var msgs []*oplog.Message rowsDeleted, err := w.DeleteItems(ctx, members, db.NewOplogMsgs(&msgs)) @@ -261,7 +261,7 @@ func (r *Repository) SetSetMembers(ctx context.Context, projectId string, setId if err != nil { return nil, db.NoRowsAffected, errors.Wrap(ctx, err, op) } - var deletions, additions []any + var deletions, additions []*HostSetMember for _, c := range changes { m, err := NewHostSetMember(ctx, setId, c.HostId) if err != nil { diff --git a/internal/iam/repository_grant_scope.go b/internal/iam/repository_grant_scope.go index 102e4847d71..db2c3f6f656 100644 --- a/internal/iam/repository_grant_scope.go +++ b/internal/iam/repository_grant_scope.go @@ -56,7 +56,7 @@ func (r *Repository) AddRoleGrantScopes(ctx context.Context, roleId string, role } } - newRoleGrantScopes := make([]any, 0, len(addRoleGrantScopes)) + newRoleGrantScopes := make([]*RoleGrantScope, 0, len(addRoleGrantScopes)) for _, grantScope := range grantScopes { roleGrantScope, err := NewRoleGrantScope(ctx, role.GetPublicId(), grantScope) if err != nil { @@ -116,11 +116,7 @@ func (r *Repository) AddRoleGrantScopes(ctx context.Context, roleId string, role if err != nil { return nil, errors.Wrap(ctx, err, op) } - roleGrantScopes = make([]*RoleGrantScope, 0, len(newRoleGrantScopes)) - for _, grantScope := range newRoleGrantScopes { - roleGrantScopes = append(roleGrantScopes, grantScope.(*RoleGrantScope)) - } - return roleGrantScopes, nil + return newRoleGrantScopes, nil } // DeleteRoleGrantScopes will delete role grant scopes associated with the role ID in @@ -178,7 +174,7 @@ func (r *Repository) DeleteRoleGrantScopes(ctx context.Context, roleId string, r } msgs = append(msgs, &roleOplogMsg) - deleteRoleGrantScopes := make([]any, 0, len(grantScopes)) + deleteRoleGrantScopes := make([]*RoleGrantScope, 0, len(grantScopes)) for _, grantScope := range grantScopes { roleGrantScope, err := NewRoleGrantScope(ctx, roleId, grantScope) if err != nil { @@ -264,8 +260,8 @@ func (r *Repository) SetRoleGrantScopes(ctx context.Context, roleId string, role // Check incoming grant scopes to see if they exist and if so act appropriately currentRoleGrantScopes := make([]*RoleGrantScope, 0, len(grantScopes)+len(found)) - addRoleGrantScopes := make([]any, 0, len(grantScopes)) - deleteRoleGrantScopes := make([]any, 0, len(grantScopes)) + addRoleGrantScopes := make([]*RoleGrantScope, 0, len(grantScopes)) + deleteRoleGrantScopes := make([]*RoleGrantScope, 0, len(grantScopes)) for _, grantScope := range grantScopes { rgs, ok := found[grantScope] if ok { diff --git a/internal/iam/repository_group.go b/internal/iam/repository_group.go index 9579fbd0a29..92611f6191e 100644 --- a/internal/iam/repository_group.go +++ b/internal/iam/repository_group.go @@ -211,7 +211,7 @@ func (r *Repository) AddGroupMembers(ctx context.Context, groupId string, groupV return nil, errors.Wrap(ctx, err, op, errors.WithMsg(fmt.Sprintf("unable to get group members %s scope", groupId))) } - newGroupMembers := make([]any, 0, len(userIds)) + newGroupMembers := make([]*GroupMemberUser, 0, len(userIds)) for _, id := range userIds { gm, err := NewGroupMemberUser(ctx, groupId, id) if err != nil { @@ -304,7 +304,7 @@ func (r *Repository) DeleteGroupMembers(ctx context.Context, groupId string, gro return db.NoRowsAffected, errors.Wrap(ctx, err, op, errors.WithMsg(fmt.Sprintf("unable to get group members %s scope", groupId))) } - deleteMembers := make([]any, 0, len(userIds)) + deleteMembers := make([]*GroupMemberUser, 0, len(userIds)) for _, id := range userIds { member, err := NewGroupMemberUser(ctx, groupId, id) if err != nil { @@ -486,7 +486,7 @@ func (r *Repository) SetGroupMembers(ctx context.Context, groupId string, groupV } // groupMemberChanges returns two slices: members to add and delete -func groupMemberChanges(ctx context.Context, reader db.Reader, groupId string, userIds []string) ([]any, []any, error) { +func groupMemberChanges(ctx context.Context, reader db.Reader, groupId string, userIds []string) ([]*GroupMemberUser, []*GroupMemberUser, error) { const op = "iam.groupMemberChanges" var inClauseSpots []string // starts at 2 because there is already a ? in the query @@ -526,8 +526,8 @@ func groupMemberChanges(ctx context.Context, reader db.Reader, groupId string, u if err := rows.Err(); err != nil { return nil, nil, errors.Wrap(ctx, err, op) } - addMembers := []any{} - deleteMembers := []any{} + addMembers := []*GroupMemberUser{} + deleteMembers := []*GroupMemberUser{} for _, c := range changes { if c.MemberId == "" { return nil, nil, errors.New(ctx, errors.InvalidParameter, op, "missing user id in change result") diff --git a/internal/iam/repository_principal_role.go b/internal/iam/repository_principal_role.go index af4259656c4..c261c608460 100644 --- a/internal/iam/repository_principal_role.go +++ b/internal/iam/repository_principal_role.go @@ -36,7 +36,7 @@ func (r *Repository) AddPrincipalRoles(ctx context.Context, roleId string, roleV return nil, errors.New(ctx, errors.InvalidParameter, op, "missing any of users, groups, or managed groups to add") } - newUserRoles := make([]any, 0, len(userIds)) + newUserRoles := make([]*UserRole, 0, len(userIds)) for _, id := range userIds { usrRole, err := NewUserRole(ctx, roleId, id) if err != nil { @@ -44,7 +44,7 @@ func (r *Repository) AddPrincipalRoles(ctx context.Context, roleId string, roleV } newUserRoles = append(newUserRoles, usrRole) } - newGrpRoles := make([]any, 0, len(groupIds)) + newGrpRoles := make([]*GroupRole, 0, len(groupIds)) for _, id := range groupIds { grpRole, err := NewGroupRole(ctx, roleId, id) if err != nil { @@ -52,7 +52,7 @@ func (r *Repository) AddPrincipalRoles(ctx context.Context, roleId string, roleV } newGrpRoles = append(newGrpRoles, grpRole) } - newManagedGrpRoles := make([]any, 0, len(managedGroupIds)) + newManagedGrpRoles := make([]*ManagedGroupRole, 0, len(managedGroupIds)) for _, id := range managedGroupIds { managedGrpRole, err := NewManagedGroupRole(ctx, roleId, id) if err != nil { @@ -338,7 +338,7 @@ func (r *Repository) DeletePrincipalRoles(ctx context.Context, roleId string, ro role := allocRole() role.PublicId = roleId - deleteUserRoles := make([]any, 0, len(userIds)) + deleteUserRoles := make([]*UserRole, 0, len(userIds)) for _, id := range userIds { usrRole, err := NewUserRole(ctx, roleId, id) if err != nil { @@ -346,7 +346,7 @@ func (r *Repository) DeletePrincipalRoles(ctx context.Context, roleId string, ro } deleteUserRoles = append(deleteUserRoles, usrRole) } - deleteGrpRoles := make([]any, 0, len(groupIds)) + deleteGrpRoles := make([]*GroupRole, 0, len(groupIds)) for _, id := range groupIds { grpRole, err := NewGroupRole(ctx, roleId, id) if err != nil { @@ -354,7 +354,7 @@ func (r *Repository) DeletePrincipalRoles(ctx context.Context, roleId string, ro } deleteGrpRoles = append(deleteGrpRoles, grpRole) } - deleteManagedGrpRoles := make([]any, 0, len(managedGroupIds)) + deleteManagedGrpRoles := make([]*ManagedGroupRole, 0, len(managedGroupIds)) for _, id := range managedGroupIds { managedGrpRole, err := NewManagedGroupRole(ctx, roleId, id) if err != nil { @@ -465,12 +465,12 @@ func (r *Repository) ListPrincipalRoles(ctx context.Context, roleId string, opt } type PrincipalSet struct { - AddUserRoles []any - AddGroupRoles []any - AddManagedGroupRoles []any - DeleteUserRoles []any - DeleteGroupRoles []any - DeleteManagedGroupRoles []any + AddUserRoles []*UserRole + AddGroupRoles []*GroupRole + AddManagedGroupRoles []*ManagedGroupRole + DeleteUserRoles []*UserRole + DeleteGroupRoles []*GroupRole + DeleteManagedGroupRoles []*ManagedGroupRole // unchangedPrincipalRoles is set iff there are no changes, that is, the // length of all other members is zero UnchangedPrincipalRoles []*PrincipalRole @@ -503,7 +503,7 @@ func (r *Repository) PrincipalsToSet(ctx context.Context, role *Role, userIds, g return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("%s is unknown principal type %s", p.PrincipalId, p.GetType())) } } - var newUserRoles []any + var newUserRoles []*UserRole userIdsMap := map[string]struct{}{} for _, id := range userIds { userIdsMap[id] = struct{}{} @@ -515,7 +515,7 @@ func (r *Repository) PrincipalsToSet(ctx context.Context, role *Role, userIds, g newUserRoles = append(newUserRoles, usrRole) } } - var newGrpRoles []any + var newGrpRoles []*GroupRole groupIdsMap := map[string]struct{}{} for _, id := range groupIds { groupIdsMap[id] = struct{}{} @@ -527,7 +527,7 @@ func (r *Repository) PrincipalsToSet(ctx context.Context, role *Role, userIds, g newGrpRoles = append(newGrpRoles, grpRole) } } - var newManagedGrpRoles []any + var newManagedGrpRoles []*ManagedGroupRole managedGroupIdsMap := map[string]struct{}{} for _, id := range managedGroupIds { managedGroupIdsMap[id] = struct{}{} @@ -539,7 +539,7 @@ func (r *Repository) PrincipalsToSet(ctx context.Context, role *Role, userIds, g newManagedGrpRoles = append(newManagedGrpRoles, managedGrpRole) } } - var deleteUserRoles []any + var deleteUserRoles []*UserRole for _, p := range existingUsers { if _, ok := userIdsMap[p.PrincipalId]; !ok { usrRole, err := NewUserRole(ctx, p.GetRoleId(), p.GetPrincipalId()) @@ -549,7 +549,7 @@ func (r *Repository) PrincipalsToSet(ctx context.Context, role *Role, userIds, g deleteUserRoles = append(deleteUserRoles, usrRole) } } - var deleteGrpRoles []any + var deleteGrpRoles []*GroupRole for _, p := range existingGroups { if _, ok := groupIdsMap[p.PrincipalId]; !ok { grpRole, err := NewGroupRole(ctx, p.GetRoleId(), p.GetPrincipalId()) @@ -559,7 +559,7 @@ func (r *Repository) PrincipalsToSet(ctx context.Context, role *Role, userIds, g deleteGrpRoles = append(deleteGrpRoles, grpRole) } } - var deleteManagedGrpRoles []any + var deleteManagedGrpRoles []*ManagedGroupRole for _, p := range existingManagedGroups { if _, ok := managedGroupIdsMap[p.PrincipalId]; !ok { managedGrpRole, err := NewManagedGroupRole(ctx, p.GetRoleId(), p.GetPrincipalId()) diff --git a/internal/iam/repository_principal_role_ext_test.go b/internal/iam/repository_principal_role_ext_test.go index 59801b14a92..07cea74b017 100644 --- a/internal/iam/repository_principal_role_ext_test.go +++ b/internal/iam/repository_principal_role_ext_test.go @@ -206,7 +206,7 @@ func assertSetResults(t *testing.T, got *iam.PrincipalSet, wantAddUsers, wantAdd assert := assert.New(t) var gotAddUsers []string for _, r := range got.AddUserRoles { - gotAddUsers = append(gotAddUsers, r.(*iam.UserRole).PrincipalId) + gotAddUsers = append(gotAddUsers, r.PrincipalId) } // sort.Strings(wantAddUsers) // sort.Strings(gotAddUsers) @@ -214,7 +214,7 @@ func assertSetResults(t *testing.T, got *iam.PrincipalSet, wantAddUsers, wantAdd var gotAddGrps []string for _, r := range got.AddGroupRoles { - gotAddGrps = append(gotAddGrps, r.(*iam.GroupRole).PrincipalId) + gotAddGrps = append(gotAddGrps, r.PrincipalId) } // sort.Strings(wantAddGroups) // sort.Strings(gotAddGrps) @@ -222,7 +222,7 @@ func assertSetResults(t *testing.T, got *iam.PrincipalSet, wantAddUsers, wantAdd var gotAddManagedGrps []string for _, r := range got.AddManagedGroupRoles { - gotAddManagedGrps = append(gotAddManagedGrps, r.(*iam.ManagedGroupRole).PrincipalId) + gotAddManagedGrps = append(gotAddManagedGrps, r.PrincipalId) } // sort.Strings(wantAddGroups) // sort.Strings(gotAddGrps) @@ -230,7 +230,7 @@ func assertSetResults(t *testing.T, got *iam.PrincipalSet, wantAddUsers, wantAdd var gotDeleteUsers []string for _, r := range got.DeleteUserRoles { - gotDeleteUsers = append(gotDeleteUsers, r.(*iam.UserRole).PrincipalId) + gotDeleteUsers = append(gotDeleteUsers, r.PrincipalId) } sort.Strings(wantDeleteUsers) sort.Strings(gotDeleteUsers) @@ -238,7 +238,7 @@ func assertSetResults(t *testing.T, got *iam.PrincipalSet, wantAddUsers, wantAdd var gotDeleteGroups []string for _, r := range got.DeleteGroupRoles { - gotDeleteGroups = append(gotDeleteGroups, r.(*iam.GroupRole).PrincipalId) + gotDeleteGroups = append(gotDeleteGroups, r.PrincipalId) } sort.Strings(wantDeleteGroups) sort.Strings(gotDeleteGroups) @@ -246,7 +246,7 @@ func assertSetResults(t *testing.T, got *iam.PrincipalSet, wantAddUsers, wantAdd var gotDeleteManagedGroups []string for _, r := range got.DeleteManagedGroupRoles { - gotDeleteManagedGroups = append(gotDeleteManagedGroups, r.(*iam.ManagedGroupRole).PrincipalId) + gotDeleteManagedGroups = append(gotDeleteManagedGroups, r.PrincipalId) } sort.Strings(wantDeleteManagedGroups) sort.Strings(gotDeleteManagedGroups) diff --git a/internal/iam/repository_role_grant.go b/internal/iam/repository_role_grant.go index 8e37e63f9f6..116800053e4 100644 --- a/internal/iam/repository_role_grant.go +++ b/internal/iam/repository_role_grant.go @@ -32,7 +32,7 @@ func (r *Repository) AddRoleGrants(ctx context.Context, roleId string, roleVersi role := allocRole() role.PublicId = roleId - newRoleGrants := make([]any, 0, len(grants)) + newRoleGrants := make([]*RoleGrant, 0, len(grants)) for _, grant := range grants { roleGrant, err := NewRoleGrant(ctx, roleId, grant) if err != nil { @@ -96,11 +96,7 @@ func (r *Repository) AddRoleGrants(ctx context.Context, roleId string, roleVersi if err != nil { return nil, errors.Wrap(ctx, err, op) } - roleGrants := make([]*RoleGrant, 0, len(newRoleGrants)) - for _, grant := range newRoleGrants { - roleGrants = append(roleGrants, grant.(*RoleGrant)) - } - return roleGrants, nil + return newRoleGrants, nil } // DeleteRoleGrants deletes grants (as strings) from a role (roleId). The role's @@ -166,7 +162,7 @@ func (r *Repository) DeleteRoleGrants(ctx context.Context, roleId string, roleVe // Check incoming grants to see if they exist and if so add to // delete slice - deleteRoleGrants := make([]any, 0, len(grants)) + deleteRoleGrants := make([]*RoleGrant, 0, len(grants)) for _, grant := range grants { // Use a fake scope, just want to get out a canonical string perm, err := perms.Parse(ctx, "o_abcd1234", grant, perms.WithSkipFinalValidation(true)) @@ -257,8 +253,8 @@ func (r *Repository) SetRoleGrants(ctx context.Context, roleId string, roleVersi // Check incoming grants to see if they exist and if so act appropriately currentRoleGrants := make([]*RoleGrant, 0, len(grants)+len(found)) - addRoleGrants := make([]any, 0, len(grants)) - deleteRoleGrants := make([]any, 0, len(grants)) + addRoleGrants := make([]*RoleGrant, 0, len(grants)) + deleteRoleGrants := make([]*RoleGrant, 0, len(grants)) for _, grant := range grants { // Use a fake scope, just want to get out a canonical string perm, err := perms.Parse(ctx, "o_abcd1234", grant, perms.WithSkipFinalValidation(true)) diff --git a/internal/iam/repository_scope.go b/internal/iam/repository_scope.go index dc29fb6ba21..5c115e66d30 100644 --- a/internal/iam/repository_scope.go +++ b/internal/iam/repository_scope.go @@ -232,7 +232,7 @@ func (r *Repository) CreateScope(ctx context.Context, s *Scope, userId string, o return errors.Wrap(ctx, err, op, errors.WithMsg("unable to create in memory role grant")) } roleGrantOplogMsgs := make([]*oplog.Message, 0, 1) - if err := w.CreateItems(ctx, []any{roleGrant}, db.NewOplogMsgs(&roleGrantOplogMsgs)); err != nil { + if err := w.CreateItems(ctx, []*RoleGrant{roleGrant}, db.NewOplogMsgs(&roleGrantOplogMsgs)); err != nil { return errors.Wrap(ctx, err, op, errors.WithMsg("unable to add grants")) } msgs = append(msgs, roleGrantOplogMsgs...) @@ -242,7 +242,7 @@ func (r *Repository) CreateScope(ctx context.Context, s *Scope, userId string, o return errors.Wrap(ctx, err, op, errors.WithMsg("unable to create in memory role grant scope")) } roleGrantScopeOplogMsgs := make([]*oplog.Message, 0, 1) - if err := w.CreateItems(ctx, []any{roleGrantScope}, db.NewOplogMsgs(&roleGrantScopeOplogMsgs)); err != nil { + if err := w.CreateItems(ctx, []*RoleGrantScope{roleGrantScope}, db.NewOplogMsgs(&roleGrantScopeOplogMsgs)); err != nil { return errors.Wrap(ctx, err, op, errors.WithMsg("unable to add grant scope")) } msgs = append(msgs, roleGrantScopeOplogMsgs...) @@ -252,7 +252,7 @@ func (r *Repository) CreateScope(ctx context.Context, s *Scope, userId string, o return errors.Wrap(ctx, err, op, errors.WithMsg("unable to create in memory role user")) } roleUserOplogMsgs := make([]*oplog.Message, 0, 1) - if err := w.CreateItems(ctx, []any{rolePrincipal}, db.NewOplogMsgs(&roleUserOplogMsgs)); err != nil { + if err := w.CreateItems(ctx, []*UserRole{rolePrincipal}, db.NewOplogMsgs(&roleUserOplogMsgs)); err != nil { return errors.Wrap(ctx, err, op, errors.WithMsg("unable to add grants")) } msgs = append(msgs, roleUserOplogMsgs...) @@ -301,7 +301,7 @@ func (r *Repository) CreateScope(ctx context.Context, s *Scope, userId string, o // Grants { - grants := []any{} + grants := []*RoleGrant{} switch s.Type { case scope.Project.String(): @@ -352,7 +352,7 @@ func (r *Repository) CreateScope(ctx context.Context, s *Scope, userId string, o // Principals { - principals := []any{} + principals := []*UserRole{} userId := globals.AnonymousUserId if s.Type == scope.Project.String() { userId = globals.AnyAuthenticatedUserId @@ -375,7 +375,7 @@ func (r *Repository) CreateScope(ctx context.Context, s *Scope, userId string, o return errors.Wrap(ctx, err, op, errors.WithMsg("unable to create in memory role grant scope")) } roleGrantScopeOplogMsgs := make([]*oplog.Message, 0, 1) - if err := w.CreateItems(ctx, []any{roleGrantScope}, db.NewOplogMsgs(&roleGrantScopeOplogMsgs)); err != nil { + if err := w.CreateItems(ctx, []*RoleGrantScope{roleGrantScope}, db.NewOplogMsgs(&roleGrantScopeOplogMsgs)); err != nil { return errors.Wrap(ctx, err, op, errors.WithMsg("unable to add grant scope")) } msgs = append(msgs, roleGrantScopeOplogMsgs...) diff --git a/internal/oplog/oplog.go b/internal/oplog/oplog.go index 80826696934..10977f86f0c 100644 --- a/internal/oplog/oplog.go +++ b/internal/oplog/oplog.go @@ -8,6 +8,7 @@ import ( "context" "fmt" "io" + reflect "reflect" "github.com/golang/protobuf/ptypes/wrappers" "github.com/hashicorp/boundary/internal/errors" @@ -17,6 +18,7 @@ import ( wrapping "github.com/hashicorp/go-kms-wrapping/v2" "github.com/hashicorp/go-kms-wrapping/v2/extras/structwrapping" "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/known/structpb" ) @@ -463,7 +465,12 @@ func (e *Entry) Replay(ctx context.Context, tx *Writer, types *TypeCatalog, tabl // TODO: jimlambrt 12/2021 -> while this will work for // CreateItems(...) it's hardly efficient. We'll need to refactor // oplog quite a bit to support a multi-message operation. - if err := rw.CreateItems(ctx, []any{m.Message}, m.Opts...); err != nil { + // valueType := reflect.TypeOf(m.Message) // Assume all values are the same type + // sliceType := reflect.SliceOf(valueType) + // sliceValue := reflect.MakeSlice(sliceType, 1, 1) + // sliceValue.Index(0).Set(reflect.ValueOf(m.Message)) + // sliceValue.Interface() + if err := rw.CreateItems(ctx, convertToSlice(m.Message), m.Opts...); err != nil { return errors.Wrap(ctx, err, op) } case OpType_OP_TYPE_UPDATE: @@ -478,7 +485,7 @@ func (e *Entry) Replay(ctx context.Context, tx *Writer, types *TypeCatalog, tabl // TODO: jimlambrt 12/2021 -> while this will work for // DeleteItems(...) it's hardly efficient. We'll need to refactor // oplog quite a bit to support a multi-message operation. - if _, err := rw.DeleteItems(ctx, []any{m.Message}, m.Opts...); err != nil { + if _, err := rw.DeleteItems(ctx, convertToSlice(m.Message), m.Opts...); err != nil { return errors.Wrap(ctx, err, op) } default: @@ -487,3 +494,11 @@ func (e *Entry) Replay(ctx context.Context, tx *Writer, types *TypeCatalog, tabl } return nil } + +func convertToSlice(m protoreflect.ProtoMessage) any { + valueType := reflect.TypeOf(m) // Assume all values are the same type + sliceType := reflect.SliceOf(valueType) + sliceValue := reflect.MakeSlice(sliceType, 1, 1) + sliceValue.Index(0).Set(reflect.ValueOf(m)) + return sliceValue.Interface() +} diff --git a/internal/oplog/oplog_test.go b/internal/oplog/oplog_test.go index c683479b8d1..e47c05f9297 100644 --- a/internal/oplog/oplog_test.go +++ b/internal/oplog/oplog_test.go @@ -407,7 +407,7 @@ func Test_Replay(t *testing.T) { userCreateItems := &oplog_test.TestUser{ Name: "foo-" + testId(t), } - require.NoError(dbw.New(db).CreateItems(context.Background(), []any{userCreateItems})) + require.NoError(dbw.New(db).CreateItems(context.Background(), []*oplog_test.TestUser{userCreateItems})) err = newLogEntry.WriteEntryWith(context.Background(), &Writer{tx.DB()}, ticket, &Message{Message: userCreate, TypeName: "user", OpType: OpType_OP_TYPE_CREATE}, @@ -536,7 +536,7 @@ func Test_Replay(t *testing.T) { deleteUser2 := oplog_test.TestUser{ Id: userCreate2.Id, } - _, err = tx2.DeleteItems(testCtx, []any{&deleteUser2}) + _, err = tx2.DeleteItems(testCtx, []*oplog_test.TestUser{&deleteUser2}) require.NoError(err) newLogEntry2, err := NewEntry( diff --git a/internal/server/repository_worker.go b/internal/server/repository_worker.go index cee85974b79..576313fb6e5 100644 --- a/internal/server/repository_worker.go +++ b/internal/server/repository_worker.go @@ -455,7 +455,7 @@ func setWorkerTags(ctx context.Context, w db.Writer, id string, ts TagSource, ta // Otherwise, go through and stage each tuple for insertion // below. if len(tags) > 0 { - uTags := make([]any, 0, len(tags)) + uTags := make([]*store.WorkerTag, 0, len(tags)) for _, v := range tags { if v == nil { return errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("found nil tag value for worker %s", id)) @@ -822,7 +822,7 @@ func (r *Repository) DeleteWorkerTags(ctx context.Context, workerId string, work } rowsDeleted := 0 - deleteTags := make([]any, 0, len(tags)) + deleteTags := make([]*store.WorkerTag, 0, len(tags)) for _, t := range tags { if t == nil { return db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "found nil tag value in input") diff --git a/internal/server/testing.go b/internal/server/testing.go index b234db68cca..8070d9bff3a 100644 --- a/internal/server/testing.go +++ b/internal/server/testing.go @@ -131,7 +131,7 @@ func TestKmsWorker(t *testing.T, conn *db.DB, wrapper wrapping.Wrapper, opt ...O require.Equal(t, "kms", wrk.Type) if len(opts.withWorkerTags) > 0 { - var tags []any + var tags []*store.WorkerTag for _, t := range opts.withWorkerTags { tags = append(tags, &store.WorkerTag{ WorkerId: wrk.GetPublicId(), @@ -170,7 +170,7 @@ func TestPkiWorker(t *testing.T, conn *db.DB, wrapper wrapping.Wrapper, opt ...O require.NotNil(t, wrk) if len(opts.withWorkerTags) > 0 { - var tags []any + var tags []*store.WorkerTag for _, t := range opts.withWorkerTags { tags = append(tags, &store.WorkerTag{ WorkerId: wrk.GetPublicId(), diff --git a/internal/session/repository_credential.go b/internal/session/repository_credential.go index 55e9776b1a7..be148292958 100644 --- a/internal/session/repository_credential.go +++ b/internal/session/repository_credential.go @@ -32,7 +32,7 @@ func (r *Repository) AddSessionCredentials(ctx context.Context, sessProjectId, s return errors.Wrap(ctx, err, op, errors.WithMsg("unable to get database wrapper")) } - addCreds := make([]any, 0, len(credData)) + addCreds := make([]credential, 0, len(credData)) for _, cred := range credData { if len(cred) == 0 { return errors.New(ctx, errors.InvalidParameter, op, "missing credential") diff --git a/internal/session/repository_session.go b/internal/session/repository_session.go index 60eb835ae67..5cff87003b3 100644 --- a/internal/session/repository_session.go +++ b/internal/session/repository_session.go @@ -127,7 +127,7 @@ func (r *Repository) CreateSession(ctx context.Context, sessionWrapper wrapping. cred.SessionId = newSession.PublicId } - var staticCreds []any + var staticCreds []*StaticCredential for _, cred := range newSession.StaticCredentials { cred.SessionId = newSession.PublicId staticCreds = append(staticCreds, cred) diff --git a/internal/target/repository_credential_source.go b/internal/target/repository_credential_source.go index 9ccc917c32a..ad6f59058f2 100644 --- a/internal/target/repository_credential_source.go +++ b/internal/target/repository_credential_source.go @@ -88,7 +88,7 @@ func (r *Repository) AddTargetCredentialSources(ctx context.Context, targetId st msgs = append(msgs, &targetOplogMsg) if len(addCredLibs) > 0 { - i := make([]any, 0, len(addCredLibs)) + i := make([]*CredentialLibrary, 0, len(addCredLibs)) for _, cl := range addCredLibs { i = append(i, cl) } @@ -100,7 +100,7 @@ func (r *Repository) AddTargetCredentialSources(ctx context.Context, targetId st } if len(addStaticCreds) > 0 { - i := make([]any, 0, len(addStaticCreds)) + i := make([]*StaticCredential, 0, len(addStaticCreds)) for _, c := range addStaticCreds { i = append(i, c) } @@ -208,7 +208,7 @@ func (r *Repository) DeleteTargetCredentialSources(ctx context.Context, targetId msgs = append(msgs, &targetOplogMsg) if len(deleteCredLibs) > 0 { - i := make([]any, 0, len(deleteCredLibs)) + i := make([]*CredentialLibrary, 0, len(deleteCredLibs)) for _, cl := range deleteCredLibs { i = append(i, cl) } @@ -226,7 +226,7 @@ func (r *Repository) DeleteTargetCredentialSources(ctx context.Context, targetId } if len(deleteStaticCred) > 0 { - i := make([]any, 0, len(deleteStaticCred)) + i := make([]*StaticCredential, 0, len(deleteStaticCred)) for _, cl := range deleteStaticCred { i = append(i, cl) } @@ -362,7 +362,7 @@ func (r *Repository) SetTargetCredentialSources(ctx context.Context, targetId st // add new credential libraries if len(addCredLibs) > 0 { - i := make([]any, 0, len(addCredLibs)) + i := make([]*CredentialLibrary, 0, len(addCredLibs)) for _, cl := range addCredLibs { i = append(i, cl) } @@ -377,7 +377,7 @@ func (r *Repository) SetTargetCredentialSources(ctx context.Context, targetId st // delete existing credential libraries not part of set if len(delCredLibs) > 0 { - i := make([]any, 0, len(delCredLibs)) + i := make([]*CredentialLibrary, 0, len(delCredLibs)) for _, cl := range delCredLibs { i = append(i, cl) } @@ -396,7 +396,7 @@ func (r *Repository) SetTargetCredentialSources(ctx context.Context, targetId st // add new static credential if len(addStaticCred) > 0 { - i := make([]any, 0, len(addStaticCred)) + i := make([]*StaticCredential, 0, len(addStaticCred)) for _, cl := range addStaticCred { i = append(i, cl) } @@ -411,7 +411,7 @@ func (r *Repository) SetTargetCredentialSources(ctx context.Context, targetId st // delete existing static credentials not part of set if len(delStaticCred) > 0 { - i := make([]any, 0, len(delStaticCred)) + i := make([]*StaticCredential, 0, len(delStaticCred)) for _, cl := range delStaticCred { i = append(i, cl) } diff --git a/internal/target/repository_host_source.go b/internal/target/repository_host_source.go index 58212d99e2b..a1a8e8a83d7 100644 --- a/internal/target/repository_host_source.go +++ b/internal/target/repository_host_source.go @@ -29,7 +29,7 @@ func (r *Repository) AddTargetHostSources(ctx context.Context, targetId string, if len(hostSourceIds) == 0 { return nil, errors.New(ctx, errors.InvalidParameter, op, "missing host source ids") } - newHostSources := make([]any, 0, len(hostSourceIds)) + newHostSources := make([]*TargetHostSet, 0, len(hostSourceIds)) for _, id := range hostSourceIds { ths, err := NewTargetHostSet(ctx, targetId, id) if err != nil { @@ -139,7 +139,7 @@ func (r *Repository) DeleteTargetHostSources(ctx context.Context, targetId strin if len(hostSourceIds) == 0 { return db.NoRowsAffected, errors.New(ctx, errors.InvalidParameter, op, "missing host source ids") } - deleteTargetHostSources := make([]any, 0, len(hostSourceIds)) + deleteTargetHostSources := make([]*TargetHostSet, 0, len(hostSourceIds)) for _, id := range hostSourceIds { ths, err := NewTargetHostSet(ctx, targetId, id) if err != nil { @@ -251,7 +251,7 @@ func (r *Repository) SetTargetHostSources(ctx context.Context, targetId string, for _, s := range foundThs { found[s.Id()] = s } - addHostSources := make([]any, 0, len(hostSourceIds)) + addHostSources := make([]*TargetHostSet, 0, len(hostSourceIds)) for _, id := range hostSourceIds { if _, ok := found[id]; ok { // found a match, so do nothing (we want to keep it), but remove it @@ -265,7 +265,7 @@ func (r *Repository) SetTargetHostSources(ctx context.Context, targetId string, } addHostSources = append(addHostSources, hs) } - deleteHostSources := make([]any, 0, len(hostSourceIds)) + deleteHostSources := make([]*TargetHostSet, 0, len(hostSourceIds)) if len(found) > 0 { for _, s := range found { hs, err := NewTargetHostSet(ctx, targetId, s.Id()) diff --git a/internal/target/targettest/target.go b/internal/target/targettest/target.go index e1b74f92314..036fb16544a 100644 --- a/internal/target/targettest/target.go +++ b/internal/target/targettest/target.go @@ -360,7 +360,7 @@ func TestNewTestTarget(ctx context.Context, t *testing.T, conn *db.DB, projectId require.NoError(err) if len(opts.WithHostSources) > 0 { - newHostSets := make([]any, 0, len(opts.WithHostSources)) + newHostSets := make([]*target.TargetHostSet, 0, len(opts.WithHostSources)) for _, s := range opts.WithHostSources { hostSet, err := target.NewTargetHostSet(ctx, tar.GetPublicId(), s) require.NoError(err) @@ -370,7 +370,7 @@ func TestNewTestTarget(ctx context.Context, t *testing.T, conn *db.DB, projectId require.NoError(err) } if len(opts.WithCredentialLibraries) > 0 { - newCredLibs := make([]any, 0, len(opts.WithCredentialLibraries)) + newCredLibs := make([]*target.CredentialLibrary, 0, len(opts.WithCredentialLibraries)) for _, cl := range opts.WithCredentialLibraries { cl.TargetId = tar.GetPublicId() newCredLibs = append(newCredLibs, cl) diff --git a/internal/target/tcp/testing.go b/internal/target/tcp/testing.go index 7a9bf5a6579..4251b86c333 100644 --- a/internal/target/tcp/testing.go +++ b/internal/target/tcp/testing.go @@ -36,7 +36,7 @@ func TestTarget(ctx context.Context, t testing.TB, conn *db.DB, projectId, name require.NoError(err) } if len(opts.WithHostSources) > 0 { - newHostSets := make([]any, 0, len(opts.WithHostSources)) + newHostSets := make([]*target.TargetHostSet, 0, len(opts.WithHostSources)) for _, s := range opts.WithHostSources { hostSet, err := target.NewTargetHostSet(ctx, tar.GetPublicId(), s) require.NoError(err) @@ -46,7 +46,7 @@ func TestTarget(ctx context.Context, t testing.TB, conn *db.DB, projectId, name require.NoError(err) } if len(opts.WithCredentialLibraries) > 0 { - newCredLibs := make([]any, 0, len(opts.WithCredentialLibraries)) + newCredLibs := make([]*target.CredentialLibrary, 0, len(opts.WithCredentialLibraries)) for _, cl := range opts.WithCredentialLibraries { cl.TargetId = tar.GetPublicId() newCredLibs = append(newCredLibs, cl) @@ -55,7 +55,7 @@ func TestTarget(ctx context.Context, t testing.TB, conn *db.DB, projectId, name require.NoError(err) } if len(opts.WithStaticCredentials) > 0 { - newCreds := make([]any, 0, len(opts.WithStaticCredentials)) + newCreds := make([]*target.StaticCredential, 0, len(opts.WithStaticCredentials)) for _, c := range opts.WithStaticCredentials { c.TargetId = tar.GetPublicId() newCreds = append(newCreds, c)