From 52500f8ce75d7b03b8e10d17358ce6ebcad999fc Mon Sep 17 00:00:00 2001 From: Jamie Tanna Date: Wed, 21 Feb 2024 10:42:22 +0000 Subject: [PATCH 01/12] Upgrade version of `oapi-codegen` To get the latest features and bug fixes, we should bump to the latest version of the library. --- cmd/lakectl/cmd/root.go | 2 +- go.mod | 12 ++++--- go.sum | 53 +++++++++++------------------- pkg/api/apigen/doc.go | 2 +- pkg/api/auth_middleware_test.go | 2 +- pkg/api/serve_test.go | 2 +- pkg/api/tmpl/inline.tmpl | 2 +- pkg/auth/service.go | 4 +-- pkg/dockertest/lakefs_container.go | 2 +- pkg/loadtest/loader.go | 2 +- pkg/testutil/setup.go | 2 +- 11 files changed, 37 insertions(+), 48 deletions(-) diff --git a/cmd/lakectl/cmd/root.go b/cmd/lakectl/cmd/root.go index b4df633fd73..a9cd0ba112d 100644 --- a/cmd/lakectl/cmd/root.go +++ b/cmd/lakectl/cmd/root.go @@ -10,7 +10,7 @@ import ( "reflect" "strings" - "github.com/deepmap/oapi-codegen/pkg/securityprovider" + "github.com/deepmap/oapi-codegen/v2/pkg/securityprovider" "github.com/go-openapi/swag" "github.com/mitchellh/go-homedir" "github.com/mitchellh/mapstructure" diff --git a/go.mod b/go.mod index 8cbb2078d03..abda3d7514b 100644 --- a/go.mod +++ b/go.mod @@ -9,12 +9,12 @@ require ( github.com/cockroachdb/pebble v0.0.0-20230106151110-65ff304d3d7a github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc - github.com/deepmap/oapi-codegen v1.5.6 + github.com/deepmap/oapi-codegen/v2 v2.1.0 github.com/dgraph-io/ristretto v0.1.1 github.com/fsnotify/fsnotify v1.7.0 - github.com/getkin/kin-openapi v0.53.0 + github.com/getkin/kin-openapi v0.122.0 github.com/go-chi/chi/v5 v5.0.10 - github.com/go-openapi/swag v0.19.14 + github.com/go-openapi/swag v0.22.4 github.com/go-test/deep v1.1.0 github.com/gobwas/glob v0.2.3 github.com/golang/mock v1.6.0 @@ -137,11 +137,14 @@ require ( github.com/google/wire v0.5.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/invopop/yaml v0.2.0 // indirect github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/pierrec/lz4/v4 v4.1.8 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/repeale/fp-go v0.11.1 // indirect @@ -189,8 +192,7 @@ require ( github.com/docker/go-units v0.5.0 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/fatih/color v1.15.0 // indirect - github.com/ghodss/yaml v1.0.0 // indirect - github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect diff --git a/go.sum b/go.sum index f4519df6679..4bace4da530 100644 --- a/go.sum +++ b/go.sum @@ -337,7 +337,6 @@ github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI= github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY= -github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/databricks/databricks-sdk-go v0.26.2 h1:OcA8aOpwCqCs+brATOuOR6BmqCK/Boye21+1rYw2MOg= github.com/databricks/databricks-sdk-go v0.26.2/go.mod h1:cyFYsqaDiIdaKPdNAuh+YsMUL1k9Lt02JB/72+zgCxg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -346,8 +345,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.5.0 h1:hn6cEZtQ0h3J8kFrHR/NrzyOoTnjgW1+FmNJzQ7y/sA= github.com/deckarep/golang-set/v2 v2.5.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= -github.com/deepmap/oapi-codegen v1.5.6 h1:hlUtA13SL2HNoC/5vXDFdGm2AaN1j9/rUu7zedjBiqg= -github.com/deepmap/oapi-codegen v1.5.6/go.mod h1:NoliSkZp7cRAkisw65+PUtvgy56f21QQesX1tVUzS8g= +github.com/deepmap/oapi-codegen/v2 v2.1.0 h1:I/NMVhJCtuvL9x+S2QzZKpSjGi33oDZwPRdemvOZWyQ= +github.com/deepmap/oapi-codegen/v2 v2.1.0/go.mod h1:R1wL226vc5VmCNJUvMyYr3hJMm5reyv25j952zAVXZ8= github.com/denisenkom/go-mssqldb v0.12.0/go.mod h1:iiK0YP1ZeepvmBQk/QpLEhhTNJgfzrpArPY/aFvc9yU= github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= @@ -408,13 +407,11 @@ github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyT github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/georgysavva/scany/v2 v2.0.0 h1:RGXqxDv4row7/FYoK8MRXAZXqoWF/NM+NP0q50k3DKU= github.com/georgysavva/scany/v2 v2.0.0/go.mod h1:sigOdh+0qb/+aOs3TVhehVT10p8qJL7K/Zhyz8vWo38= -github.com/getkin/kin-openapi v0.47.0/go.mod h1:ZJSfy1PxJv2QQvH9EdBj3nupRTVvV42mkW6zKUlRBwk= -github.com/getkin/kin-openapi v0.53.0 h1:7WzP+MZRRe7YQz2Kc74Ley3dukJmXDvifVbElGmQfoA= -github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= +github.com/getkin/kin-openapi v0.122.0 h1:WB9Jbl0Hp/T79/JF9xlSW5Kl9uYdk/AWD0yAd9HOM10= +github.com/getkin/kin-openapi v0.122.0/go.mod h1:PCWw/lfBrJY4HcdqE3jj+QFkaFK8ABoqo7PvqVhXXqw= github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TBdRL1M71JZW2c= github.com/getsentry/sentry-go v0.16.0 h1:owk+S+5XcgJLlGR/3+3s6N4d+uKwqYvh/eS0AIMjPWo= github.com/getsentry/sentry-go v0.16.0/go.mod h1:ZXCloQLj0pG7mja5NK6NPf2V4A88YJ4pNlc2mOHwh6Y= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= @@ -422,7 +419,6 @@ github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/ github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.7.3/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= -github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-co-op/gocron v1.35.2 h1:lG3rdA9TqBBC/PtT2ukQqgLm6jEepnAzz3+OQetvPTE= @@ -447,11 +443,11 @@ github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ4 github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= -github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= -github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng= -github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= +github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -535,7 +531,6 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -616,6 +611,7 @@ github.com/googleapis/gax-go/v2 v2.12.0 h1:A+gCJKdRfqXkr+BIRGtZLibNXf0m1f9E4HG56 github.com/googleapis/gax-go/v2 v2.12.0/go.mod h1:y+aIqrI5eb1YGMVJfuV3185Ts/D7qKpsEkdD5+I6QGU= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= @@ -659,6 +655,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/tdigest v0.0.1 h1:XpFptwYmnEKUqmkcDjrzffswZ3nvNeevbUSLPP/ZzIY= github.com/influxdata/tdigest v0.0.1/go.mod h1:Z0kXnxzbTC2qrx4NaIzYkE1k66+6oEDQTvL95hQFh5Y= +github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= +github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= @@ -782,13 +780,8 @@ github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LE github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/labstack/echo/v4 v4.1.11/go.mod h1:i541M3Fj6f76NZtHSj7TXnyM8n2gaodfvfxNnFqi74g= -github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= github.com/labstack/echo/v4 v4.5.0/go.mod h1:czIriw4a0C1dFun+ObrXp7ok03xON0N1awStJ6ArI7Y= -github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY= -github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= -github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o= -github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= 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= @@ -800,9 +793,6 @@ github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= @@ -810,11 +800,9 @@ github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GW github.com/matoous/go-nanoid v1.5.0/go.mod h1:zyD2a71IubI24efhpvkJz+ZwfwagzgSO6UNiFsZKN7U= github.com/matoous/go-nanoid/v2 v2.0.0 h1:d19kur2QuLeHmJBkvYkFdhFBzLoo1XVm2GgTpL+9Tj0= github.com/matoous/go-nanoid/v2 v2.0.0/go.mod h1:FtS4aGPVfEkxKxhdWPAspZpZSh1cOjtM7Ej/So3hR0g= -github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= 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.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -871,6 +859,8 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= @@ -880,7 +870,6 @@ github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7 github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/ncw/swift v1.0.52/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -900,6 +889,8 @@ github.com/pborman/getopt v0.0.0-20180729010549-6fdd0a2c7117/go.mod h1:85jBQOZwp github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= +github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI= github.com/pierrec/lz4/v4 v4.1.8 h1:ieHkV+i2BRzngO4Wd/3HGowuZStgq6QkPsD1eolNAO4= @@ -1036,17 +1027,18 @@ github.com/treeverse/delta-go v0.0.0-20240101152008-53c0d469272e/go.mod h1:E7uPC github.com/tsenart/vegeta/v12 v12.11.1 h1:Rbwe7Zxr7sJ+BDTReemeQalYPvKiSV+O7nwmUs20B3E= github.com/tsenart/vegeta/v12 v12.11.1/go.mod h1:swiFmrgpqj2llHURgHYFRFN0tfrIrlnspg01HjwOnSQ= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= +github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6 h1:TtyC78WMafNW8QFfv3TeP3yWNDG+uxNkk9vOrnDu6JA= github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6/go.mod h1:h8272+G2omSmi30fBXiZDMkmHuOgonplfKIKjQWzlfs= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= -github.com/valyala/fasttemplate v1.2.1 h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/vbauerster/mpb/v5 v5.4.0 h1:n8JPunifvQvh6P1D1HAl2Ur9YcmKT1tpoUuiea5mlmg= @@ -1135,11 +1127,9 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/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-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/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-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -1336,7 +1326,6 @@ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1414,7 +1403,6 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= @@ -1701,7 +1689,6 @@ google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqw gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= 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= @@ -1732,8 +1719,8 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= diff --git a/pkg/api/apigen/doc.go b/pkg/api/apigen/doc.go index d2d5aab83bb..0561874ce97 100644 --- a/pkg/api/apigen/doc.go +++ b/pkg/api/apigen/doc.go @@ -1,4 +1,4 @@ // Package apigen provides generated code for our OpenAPI package apigen -//go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.5.6 -package apigen -generate "types,client,chi-server,spec" -templates ../tmpl -o lakefs.gen.go ../../../api/swagger.yml +//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@v2.1.0 -package apigen -generate "types,client,chi-server,spec" -templates ../tmpl -o lakefs.gen.go ../../../api/swagger.yml diff --git a/pkg/api/auth_middleware_test.go b/pkg/api/auth_middleware_test.go index 684ef6809d1..3dea2692bc0 100644 --- a/pkg/api/auth_middleware_test.go +++ b/pkg/api/auth_middleware_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/deepmap/oapi-codegen/pkg/securityprovider" + "github.com/deepmap/oapi-codegen/v2/pkg/securityprovider" "github.com/gorilla/securecookie" "github.com/gorilla/sessions" "github.com/treeverse/lakefs/pkg/api" diff --git a/pkg/api/serve_test.go b/pkg/api/serve_test.go index a06c52c8ae4..5cd2c22d4e0 100644 --- a/pkg/api/serve_test.go +++ b/pkg/api/serve_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/deepmap/oapi-codegen/pkg/securityprovider" + "github.com/deepmap/oapi-codegen/v2/pkg/securityprovider" "github.com/go-openapi/swag" "github.com/spf13/viper" "github.com/treeverse/lakefs/pkg/actions" diff --git a/pkg/api/tmpl/inline.tmpl b/pkg/api/tmpl/inline.tmpl index 754e006f1ef..ee2af0e4ebb 100644 --- a/pkg/api/tmpl/inline.tmpl +++ b/pkg/api/tmpl/inline.tmpl @@ -2,7 +2,7 @@ // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ -{{range .}} +{{range .SpecParts}} "{{.}}",{{end}} } diff --git a/pkg/auth/service.go b/pkg/auth/service.go index 687e24c1bb4..f0d06b9386c 100644 --- a/pkg/auth/service.go +++ b/pkg/auth/service.go @@ -1,6 +1,6 @@ package auth -//go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.5.6 -package auth -generate "types,client" -o client.gen.go ../../api/authorization.yml +//go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen@v2.1.0 -package auth -generate "types,client" -o client.gen.go ../../api/authorization.yml //go:generate go run github.com/golang/mock/mockgen@v1.6.0 -package=mock -destination=mock/mock_auth_client.go github.com/treeverse/lakefs/pkg/auth ClientWithResponsesInterface import ( @@ -15,7 +15,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/cenkalti/backoff/v4" - "github.com/deepmap/oapi-codegen/pkg/securityprovider" + "github.com/deepmap/oapi-codegen/v2/pkg/securityprovider" "github.com/getkin/kin-openapi/openapi3filter" "github.com/go-openapi/swag" "github.com/golang-jwt/jwt/v4" diff --git a/pkg/dockertest/lakefs_container.go b/pkg/dockertest/lakefs_container.go index c1134c8f9d8..830ecdc530c 100644 --- a/pkg/dockertest/lakefs_container.go +++ b/pkg/dockertest/lakefs_container.go @@ -11,7 +11,7 @@ import ( "github.com/treeverse/lakefs/pkg/api/apigen" "github.com/treeverse/lakefs/pkg/api/helpers" - "github.com/deepmap/oapi-codegen/pkg/securityprovider" + "github.com/deepmap/oapi-codegen/v2/pkg/securityprovider" "github.com/ory/dockertest/v3" ) diff --git a/pkg/loadtest/loader.go b/pkg/loadtest/loader.go index 8a4bee7a75d..0c0367778ce 100644 --- a/pkg/loadtest/loader.go +++ b/pkg/loadtest/loader.go @@ -10,7 +10,7 @@ import ( "os" "time" - "github.com/deepmap/oapi-codegen/pkg/securityprovider" + "github.com/deepmap/oapi-codegen/v2/pkg/securityprovider" "github.com/google/uuid" "github.com/jedib0t/go-pretty/v6/text" "github.com/schollz/progressbar/v3" diff --git a/pkg/testutil/setup.go b/pkg/testutil/setup.go index 5e3897de9fc..beca7498052 100644 --- a/pkg/testutil/setup.go +++ b/pkg/testutil/setup.go @@ -15,7 +15,7 @@ import ( awsconfig "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/credentials" "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/deepmap/oapi-codegen/pkg/securityprovider" + "github.com/deepmap/oapi-codegen/v2/pkg/securityprovider" "github.com/spf13/viper" "github.com/treeverse/lakefs/pkg/api/apigen" "github.com/treeverse/lakefs/pkg/api/apiutil" From 660e4aa7632300c137f9f01363fbf49235ed1d75 Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Wed, 6 Mar 2024 16:11:02 +0200 Subject: [PATCH 02/12] go get github.com/oapi-codegen/v2/runtime Still doesn't compile. --- go.mod | 6 ++++-- go.sum | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index abda3d7514b..4bf416601d5 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/gobwas/glob v0.2.3 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 // indirect - github.com/google/uuid v1.4.0 + github.com/google/uuid v1.5.0 github.com/hashicorp/go-multierror v1.1.1 github.com/hnlq715/golang-lru v0.3.0 github.com/jamiealquiza/tachymeter v2.0.0+incompatible @@ -107,6 +107,7 @@ require ( github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect github.com/ahmetb/go-linq/v3 v3.2.0 // indirect github.com/apache/arrow/go/arrow v0.0.0-20200730104253-651201b0f516 // indirect + github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/aws/aws-sdk-go v1.48.11 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.3 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.9 // indirect @@ -143,6 +144,7 @@ require ( github.com/kylelemons/godebug v1.1.0 // indirect github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/oapi-codegen/runtime v1.1.1 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/pierrec/lz4/v4 v4.1.8 // indirect @@ -212,7 +214,7 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/md5-simd v1.1.2 // indirect diff --git a/go.sum b/go.sum index 4bace4da530..bae1404cee1 100644 --- a/go.sum +++ b/go.sum @@ -161,6 +161,7 @@ github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5 github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/Shopify/go-lua v0.0.0-20221004153744-91867de107cf h1:VSUCKpFV0AfYGslgQSRdBI9HCVp1TCXJmScWD0VXL5g= github.com/Shopify/go-lua v0.0.0-20221004153744-91867de107cf/go.mod h1:UCCi6u6YA8oXfJ15vEMiMGIaWWfLiOacinBPHxLXtEU= github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= @@ -184,6 +185,8 @@ github.com/apache/thrift v0.14.2/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb github.com/apache/thrift v0.16.0/go.mod h1:PHK3hniurgQaNMZYaCLEqXKsYK8upmhPbmdP2FXSqgU= github.com/apache/thrift v0.19.0 h1:sOqkWPzMj7w6XaYbJQG7m4sGqVolaW/0D28Ln7yPzMk= github.com/apache/thrift v0.19.0/go.mod h1:SUALL216IiaOw2Oy+5Vs9lboJ/t9g40C+G07Dc0QC1I= +github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= +github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk= github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/aws/aws-sdk-go v1.15.27/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= @@ -274,6 +277,7 @@ github.com/benburkert/dns v0.0.0-20190225204957-d356cf78cdfc h1:eyDlmf21vuKN61Wo github.com/benburkert/dns v0.0.0-20190225204957-d356cf78cdfc/go.mod h1:6ul4nJKqsreAIBK5lUkibcUn2YBU6CvDzlKDH+dtZsQ= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bmizerany/perks v0.0.0-20230307044200-03f9df79da1e h1:mWOqoK5jV13ChKf/aF3plwQ96laasTJgZi4f1aSOu+M= github.com/bmizerany/perks v0.0.0-20230307044200-03f9df79da1e/go.mod h1:ac9efd0D1fsDb3EJvhqgXRbFx7bs2wqZ10HQPeU8U/Q= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= @@ -598,6 +602,8 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8= github.com/google/wire v0.5.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs= @@ -730,6 +736,7 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1 github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE= github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= @@ -817,6 +824,7 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= @@ -871,6 +879,8 @@ github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxzi github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/ncw/swift v1.0.52/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= +github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -996,6 +1006,7 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.17.0 h1:I5txKw7MJasPL/BrfkbA0Jyo/oELqVmux4pR/UxOMfI= github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= +github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/streadway/quantile v0.0.0-20220407130108-4246515d968d h1:X4+kt6zM/OVO6gbJdAfJR60MGPsqCzbtXNnjoGqdfAs= github.com/streadway/quantile v0.0.0-20220407130108-4246515d968d/go.mod h1:lbP8tGiBjZ5YWIc2fzuRpTaz0b/53vT6PEs3QuAWzuU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= From 9bc02087216f48260b1e488cc08c369bcecc73dc Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Wed, 6 Mar 2024 16:18:10 +0200 Subject: [PATCH 03/12] go mod tidy --- go.mod | 4 +--- go.sum | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 4bf416601d5..0d707e69d4b 100644 --- a/go.mod +++ b/go.mod @@ -93,6 +93,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.4 github.com/hashicorp/go-version v1.6.0 github.com/jackc/pgx/v5 v5.4.3 + github.com/oapi-codegen/runtime v1.1.1 github.com/puzpuzpuz/xsync v1.5.2 go.uber.org/ratelimit v0.3.0 ) @@ -144,7 +145,6 @@ require ( github.com/kylelemons/godebug v1.1.0 // indirect github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect - github.com/oapi-codegen/runtime v1.1.1 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/pierrec/lz4/v4 v4.1.8 // indirect @@ -174,7 +174,6 @@ require ( require ( github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/BurntSushi/toml v1.3.2 // indirect github.com/DataDog/zstd v1.5.2 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect @@ -214,7 +213,6 @@ require ( github.com/kr/text v0.2.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/md5-simd v1.1.2 // indirect diff --git a/go.sum b/go.sum index bae1404cee1..1c13d798f86 100644 --- a/go.sum +++ b/go.sum @@ -600,8 +600,6 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= -github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8= @@ -822,8 +820,7 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y 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= github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +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-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= From 5d0b4e6d0dc07954ad9fe0999e138da91ae9cb36 Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Wed, 6 Mar 2024 16:18:23 +0200 Subject: [PATCH 04/12] Effect now has type StatementEffect; and regenerate mocks --- pkg/auth/mock/mock_auth_client.go | 12 ++++++------ pkg/auth/service.go | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/auth/mock/mock_auth_client.go b/pkg/auth/mock/mock_auth_client.go index ca573e30ab1..d3ffac55c9c 100644 --- a/pkg/auth/mock/mock_auth_client.go +++ b/pkg/auth/mock/mock_auth_client.go @@ -117,7 +117,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) ClaimTokenIdWithBodyWith } // ClaimTokenIdWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) ClaimTokenIdWithResponse(arg0 context.Context, arg1 auth.ClaimTokenIdJSONRequestBody, arg2 ...auth.RequestEditorFn) (*auth.ClaimTokenIdResponse, error) { +func (m *MockClientWithResponsesInterface) ClaimTokenIdWithResponse(arg0 context.Context, arg1 auth.ClaimTokenId, arg2 ...auth.RequestEditorFn) (*auth.ClaimTokenIdResponse, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { @@ -177,7 +177,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) CreateGroupWithBodyWithR } // CreateGroupWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) CreateGroupWithResponse(arg0 context.Context, arg1 auth.CreateGroupJSONRequestBody, arg2 ...auth.RequestEditorFn) (*auth.CreateGroupResponse, error) { +func (m *MockClientWithResponsesInterface) CreateGroupWithResponse(arg0 context.Context, arg1 auth.GroupCreation, arg2 ...auth.RequestEditorFn) (*auth.CreateGroupResponse, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { @@ -217,7 +217,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) CreatePolicyWithBodyWith } // CreatePolicyWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) CreatePolicyWithResponse(arg0 context.Context, arg1 auth.CreatePolicyJSONRequestBody, arg2 ...auth.RequestEditorFn) (*auth.CreatePolicyResponse, error) { +func (m *MockClientWithResponsesInterface) CreatePolicyWithResponse(arg0 context.Context, arg1 auth.Policy, arg2 ...auth.RequestEditorFn) (*auth.CreatePolicyResponse, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { @@ -277,7 +277,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) CreateUserWithBodyWithRe } // CreateUserWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) CreateUserWithResponse(arg0 context.Context, arg1 auth.CreateUserJSONRequestBody, arg2 ...auth.RequestEditorFn) (*auth.CreateUserResponse, error) { +func (m *MockClientWithResponsesInterface) CreateUserWithResponse(arg0 context.Context, arg1 auth.UserCreation, arg2 ...auth.RequestEditorFn) (*auth.CreateUserResponse, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1} for _, a := range arg2 { @@ -817,7 +817,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) UpdatePasswordWithBodyWi } // UpdatePasswordWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) UpdatePasswordWithResponse(arg0 context.Context, arg1 string, arg2 auth.UpdatePasswordJSONRequestBody, arg3 ...auth.RequestEditorFn) (*auth.UpdatePasswordResponse, error) { +func (m *MockClientWithResponsesInterface) UpdatePasswordWithResponse(arg0 context.Context, arg1 string, arg2 auth.UserPassword, arg3 ...auth.RequestEditorFn) (*auth.UpdatePasswordResponse, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1, arg2} for _, a := range arg3 { @@ -857,7 +857,7 @@ func (mr *MockClientWithResponsesInterfaceMockRecorder) UpdatePolicyWithBodyWith } // UpdatePolicyWithResponse mocks base method. -func (m *MockClientWithResponsesInterface) UpdatePolicyWithResponse(arg0 context.Context, arg1 string, arg2 auth.UpdatePolicyJSONRequestBody, arg3 ...auth.RequestEditorFn) (*auth.UpdatePolicyResponse, error) { +func (m *MockClientWithResponsesInterface) UpdatePolicyWithResponse(arg0 context.Context, arg1 string, arg2 auth.Policy, arg3 ...auth.RequestEditorFn) (*auth.UpdatePolicyResponse, error) { m.ctrl.T.Helper() varargs := []interface{}{arg0, arg1, arg2} for _, a := range arg3 { diff --git a/pkg/auth/service.go b/pkg/auth/service.go index f0d06b9386c..a1f3cb4e021 100644 --- a/pkg/auth/service.go +++ b/pkg/auth/service.go @@ -1564,7 +1564,7 @@ func (a *APIAuthService) WritePolicy(ctx context.Context, policy *model.Policy, for i, s := range policy.Statement { stmts[i] = Statement{ Action: s.Action, - Effect: s.Effect, + Effect: StatementEffect(s.Effect), Resource: s.Resource, } } @@ -1600,7 +1600,7 @@ func serializePolicyToModalPolicy(p Policy) *model.Policy { stmts := make(model.Statements, len(p.Statement)) for i, apiStatement := range p.Statement { stmts[i] = model.Statement{ - Effect: apiStatement.Effect, + Effect: string(apiStatement.Effect), Action: apiStatement.Action, Resource: apiStatement.Resource, } From cefbf583473ff10ecb9a47c79bbc7f687245de6f Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Thu, 7 Mar 2024 14:56:47 +0200 Subject: [PATCH 05/12] Handle openapi3 renamings Use the [new names from 0.61.0](https://github.com/getkin/kin-openapi/blob/7aa9f7ee3d530160cd6479d28578a40b290d008f/README.md?plain=1#L325-L326). --- pkg/api/tmpl/inline.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/tmpl/inline.tmpl b/pkg/api/tmpl/inline.tmpl index ee2af0e4ebb..9a356911db0 100644 --- a/pkg/api/tmpl/inline.tmpl +++ b/pkg/api/tmpl/inline.tmpl @@ -21,7 +21,7 @@ func GetSwaggerSpecReader() (io.Reader, error) { // GetSwagger returns the Swagger specification corresponding to the generated code // in this file. -func GetSwagger() (*openapi3.Swagger, error) { +func GetSwagger() (*openapi3.T, error) { zr, err := GetSwaggerSpecReader() if err != nil { return nil, err @@ -31,7 +31,7 @@ func GetSwagger() (*openapi3.Swagger, error) { if err != nil { return nil, fmt.Errorf("error decompressing spec: %s", err) } - swagger, err := openapi3.NewSwaggerLoader().LoadSwaggerFromData(buf.Bytes()) + swagger, err := openapi3.NewLoader().LoadFromData(buf.Bytes()) if err != nil { return nil, fmt.Errorf("error loading Swagger: %s", err) } From 365d909c98ee112c89cd0c04bd3246bd72df37e2 Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Thu, 7 Mar 2024 15:32:35 +0200 Subject: [PATCH 06/12] Modify types to match new OpenAPI generated code Still does not compile: generated type of AbortPresignMultipartUpload method changed, and it is not clear where to get the body! ```compilation pkg/api/serve.go:59:35: cannot use controller (variable of type *Controller) as apigen.ServerInterface value in argument to apigen.HandlerFromMuxWithBaseURL: *Controller does not implement apigen.ServerInterface (wrong type for method AbortPresignMultipartUpload) have AbortPresignMultipartUpload("net/http".ResponseWriter, *"net/http".Request, apigen.AbortPresignMultipartUpload, string, string, string, apigen.AbortPresignMultipartUploadParams) want AbortPresignMultipartUpload("net/http".ResponseWriter, *"net/http".Request, string, string, string, apigen.AbortPresignMultipartUploadParams) ``` --- cmd/lakectl/cmd/commit.go | 5 +-- cmd/lakectl/cmd/diff.go | 2 +- cmd/lakectl/cmd/fs_stage.go | 4 +- cmd/lakectl/cmd/import.go | 2 +- cmd/lakectl/cmd/local_commit.go | 6 +-- cmd/lakectl/cmd/merge.go | 2 +- pkg/api/auth_middleware.go | 4 +- pkg/api/controller.go | 67 +++++++++++++++++---------------- pkg/api/helpers/upload.go | 18 ++++----- pkg/api/metrics_middleware.go | 2 +- pkg/api/serve.go | 2 +- pkg/api/transform.go | 13 ++++--- pkg/auth/service_test.go | 2 +- pkg/local/diff.go | 10 ++--- pkg/local/sync.go | 2 +- 15 files changed, 67 insertions(+), 74 deletions(-) diff --git a/cmd/lakectl/cmd/commit.go b/cmd/lakectl/cmd/commit.go index 22d884c0bca..5d2b0251ee7 100644 --- a/cmd/lakectl/cmd/commit.go +++ b/cmd/lakectl/cmd/commit.go @@ -43,13 +43,10 @@ var commitCmd = &cobra.Command{ fmt.Println("Branch:", branchURI) // do commit - metadata := apigen.CommitCreation_Metadata{ - AdditionalProperties: kvPairs, - } client := getClient() resp, err := client.CommitWithResponse(cmd.Context(), branchURI.Repository, branchURI.Ref, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{ Message: message, - Metadata: &metadata, + Metadata: &kvPairs, Date: datePtr, AllowEmpty: &emptyCommitBool, }) diff --git a/cmd/lakectl/cmd/diff.go b/cmd/lakectl/cmd/diff.go index 4f137f9f6ca..fd765582e56 100644 --- a/cmd/lakectl/cmd/diff.go +++ b/cmd/lakectl/cmd/diff.go @@ -124,7 +124,7 @@ func printDiffRefs(ctx context.Context, client apigen.ClientWithResponsesInterfa } func FmtDiff(d apigen.Diff, withDirection bool) { - action, color := diff.Fmt(d.Type) + action, color := diff.Fmt(string(d.Type)) if !withDirection { _, _ = os.Stdout.WriteString( diff --git a/cmd/lakectl/cmd/fs_stage.go b/cmd/lakectl/cmd/fs_stage.go index f8ad4aac3ee..573494d6c6e 100644 --- a/cmd/lakectl/cmd/fs_stage.go +++ b/cmd/lakectl/cmd/fs_stage.go @@ -45,9 +45,7 @@ The object location must be outside the repository's storage namespace`, ContentType: &contentType, } if metaErr == nil { - metadata := apigen.ObjectUserMetadata{ - AdditionalProperties: meta, - } + metadata := apigen.ObjectUserMetadata(meta) obj.Metadata = &metadata } diff --git a/cmd/lakectl/cmd/import.go b/cmd/lakectl/cmd/import.go index 7f689a6da47..f2f7f75408d 100644 --- a/cmd/lakectl/cmd/import.go +++ b/cmd/lakectl/cmd/import.go @@ -62,7 +62,7 @@ var importCmd = &cobra.Command{ }, } if len(metadata) > 0 { - body.Commit.Metadata = &apigen.CommitCreation_Metadata{AdditionalProperties: metadata} + body.Commit.Metadata = &metadata } importResp, err := client.ImportStartWithResponse(ctx, toURI.Repository, toURI.Ref, body) diff --git a/cmd/lakectl/cmd/local_commit.go b/cmd/lakectl/cmd/local_commit.go index 0bcd4f627fb..3d282f7c0f5 100644 --- a/cmd/lakectl/cmd/local_commit.go +++ b/cmd/lakectl/cmd/local_commit.go @@ -139,10 +139,8 @@ var localCommitCmd = &cobra.Command{ // commit! response, err := client.CommitWithResponse(cmd.Context(), remote.Repository, remote.Ref, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{ - Message: message, - Metadata: &apigen.CommitCreation_Metadata{ - AdditionalProperties: kvPairs, - }, + Message: message, + Metadata: &kvPairs, }) DieOnErrorOrUnexpectedStatusCode(response, err, http.StatusCreated) commit := response.JSON201 diff --git a/cmd/lakectl/cmd/merge.go b/cmd/lakectl/cmd/merge.go index 5402bdd3d28..3a8a2606d8f 100644 --- a/cmd/lakectl/cmd/merge.go +++ b/cmd/lakectl/cmd/merge.go @@ -51,7 +51,7 @@ var mergeCmd = &cobra.Command{ body := apigen.MergeIntoBranchJSONRequestBody{ Message: &message, - Metadata: &apigen.Merge_Metadata{AdditionalProperties: kvPairs}, + Metadata: &kvPairs, Strategy: &strategy, } resp, err := client.MergeIntoBranchWithResponse(cmd.Context(), destinationRef.Repository, sourceRef.Ref, destinationRef.Ref, body) diff --git a/pkg/api/auth_middleware.go b/pkg/api/auth_middleware.go index 647b48b41ed..8509f0cba4b 100644 --- a/pkg/api/auth_middleware.go +++ b/pkg/api/auth_middleware.go @@ -37,7 +37,7 @@ func extractSecurityRequirements(router routers.Router, r *http.Request) (openap return nil, err } if route.Operation.Security == nil { - return route.Swagger.Security, nil + return route.Spec.Security, nil } return *route.Operation.Security, nil } @@ -82,7 +82,7 @@ func GenericAuthMiddleware(logger logging.Logger, authenticator auth.Authenticat }, nil } -func AuthMiddleware(logger logging.Logger, swagger *openapi3.Swagger, authenticator auth.Authenticator, authService auth.Service, sessionStore sessions.Store, oidcConfig *OIDCConfig, cookieAuthConfig *CookieAuthConfig) func(next http.Handler) http.Handler { +func AuthMiddleware(logger logging.Logger, swagger *openapi3.T, authenticator auth.Authenticator, authService auth.Service, sessionStore sessions.Store, oidcConfig *OIDCConfig, cookieAuthConfig *CookieAuthConfig) func(next http.Handler) http.Handler { router, err := legacy.NewRouter(swagger) if err != nil { panic(err) diff --git a/pkg/api/controller.go b/pkg/api/controller.go index 91072954335..48dcaeb9cfa 100644 --- a/pkg/api/controller.go +++ b/pkg/api/controller.go @@ -370,7 +370,7 @@ func (c *Controller) CompletePresignMultipartUpload(w http.ResponseWriter, r *ht Checksum(checksum). ContentType(swag.StringValue(body.ContentType)) if body.UserMetadata != nil { - entryBuilder.Metadata(body.UserMetadata.AdditionalProperties) + entryBuilder.Metadata(catalog.Metadata(*body.UserMetadata)) } entry := entryBuilder.Build() @@ -379,7 +379,7 @@ func (c *Controller) CompletePresignMultipartUpload(w http.ResponseWriter, r *ht return } - metadata := apigen.ObjectUserMetadata{AdditionalProperties: entry.Metadata} + metadata := apigen.ObjectUserMetadata(entry.Metadata) response := apigen.ObjectStats{ Checksum: entry.Checksum, ContentType: swag.String(entry.ContentType), @@ -766,7 +766,7 @@ func (c *Controller) LinkPhysicalAddress(w http.ResponseWriter, r *http.Request, Checksum(checksum). ContentType(swag.StringValue(body.ContentType)) if body.UserMetadata != nil { - entryBuilder.Metadata(body.UserMetadata.AdditionalProperties) + entryBuilder.Metadata(catalog.Metadata(*body.UserMetadata)) } entry := entryBuilder.Build() err = c.Catalog.CreateEntry(ctx, repo.Name, branch, entry, graveler.WithForce(swag.BoolValue(body.Force)), graveler.WithIfAbsent(ifAbsent)) @@ -774,7 +774,7 @@ func (c *Controller) LinkPhysicalAddress(w http.ResponseWriter, r *http.Request, return } - metadata := apigen.ObjectUserMetadata{AdditionalProperties: entry.Metadata} + metadata := apigen.ObjectUserMetadata(entry.Metadata) response := apigen.ObjectStats{ Checksum: entry.Checksum, ContentType: swag.String(entry.ContentType), @@ -1162,7 +1162,7 @@ func serializePolicy(p *model.Policy) apigen.Policy { for _, s := range p.Statement { stmts = append(stmts, apigen.Statement{ Action: s.Action, - Effect: s.Effect, + Effect: apigen.StatementEffect(s.Effect), Resource: s.Resource, }) } @@ -1284,7 +1284,7 @@ func (c *Controller) CreatePolicy(w http.ResponseWriter, r *http.Request, body a stmts := make(model.Statements, len(body.Statement)) for i, apiStatement := range body.Statement { stmts[i] = model.Statement{ - Effect: apiStatement.Effect, + Effect: string(apiStatement.Effect), Action: apiStatement.Action, Resource: apiStatement.Resource, } @@ -1383,7 +1383,7 @@ func (c *Controller) UpdatePolicy(w http.ResponseWriter, r *http.Request, body a stmts := make(model.Statements, len(body.Statement)) for i, apiStatement := range body.Statement { stmts[i] = model.Statement{ - Effect: apiStatement.Effect, + Effect: string(apiStatement.Effect), Action: apiStatement.Action, Resource: apiStatement.Resource, } @@ -2141,7 +2141,7 @@ func (c *Controller) GetRepositoryMetadata(w http.ResponseWriter, r *http.Reques if c.handleAPIError(ctx, w, r, err) { return } - writeResponse(w, r, http.StatusOK, apigen.RepositoryMetadata{AdditionalProperties: metadata}) + writeResponse(w, r, http.StatusOK, apigen.RepositoryMetadata(metadata)) } func (c *Controller) SetRepositoryMetadata(w http.ResponseWriter, r *http.Request, body apigen.SetRepositoryMetadataJSONRequestBody, repository string) { @@ -2155,7 +2155,7 @@ func (c *Controller) SetRepositoryMetadata(w http.ResponseWriter, r *http.Reques } ctx := r.Context() c.LogAction(ctx, "update_repo_metadata", r, repository, "", "") - err := c.Catalog.UpdateRepositoryMetadata(ctx, repository, body.Metadata.AdditionalProperties) + err := c.Catalog.UpdateRepositoryMetadata(ctx, repository, body.Metadata) if c.handleAPIError(ctx, w, r, err) { return } @@ -2397,7 +2397,7 @@ func (c *Controller) GetRun(w http.ResponseWriter, r *http.Request, repository, EventType: runResult.EventType, StartTime: runResult.StartTime, EndTime: &runResult.EndTime, - Status: status, + Status: apigen.ActionRunStatus(status), Branch: runResult.BranchID, CommitId: runResult.CommitID, } @@ -2819,11 +2819,11 @@ func (c *Controller) ImportStart(w http.ResponseWriter, r *http.Request, body ap } metadata := map[string]string{} if body.Commit.Metadata != nil { - metadata = body.Commit.Metadata.AdditionalProperties + metadata = *body.Commit.Metadata } paths := make([]catalog.ImportPath, 0, len(body.Paths)) for _, p := range body.Paths { - pathType, err := catalog.GetImportPathType(p.Type) + pathType, err := catalog.GetImportPathType(string(p.Type)) if c.handleAPIError(ctx, w, r, err) { return } @@ -2867,6 +2867,7 @@ func importStatusToResponse(status *graveler.ImportStatus) apigen.ImportStatus { } commitLog := catalog.CommitRecordToLog(status.Commit) + metadata := map[string]string(commitLog.Metadata) if commitLog != nil { resp.Commit = &apigen.Commit{ Committer: commitLog.Committer, @@ -2874,7 +2875,7 @@ func importStatusToResponse(status *graveler.ImportStatus) apigen.ImportStatus { Id: commitLog.Reference, Message: commitLog.Message, MetaRangeId: commitLog.MetaRangeID, - Metadata: &apigen.Commit_Metadata{AdditionalProperties: commitLog.Metadata}, + Metadata: &metadata, Parents: commitLog.Parents, Version: apiutil.Ptr(int(commitLog.Version)), Generation: apiutil.Ptr(int64(commitLog.Generation)), @@ -2940,7 +2941,7 @@ func (c *Controller) Commit(w http.ResponseWriter, r *http.Request, body apigen. } var metadata map[string]string if body.Metadata != nil { - metadata = body.Metadata.AdditionalProperties + metadata = *body.Metadata } newCommit, err := c.Catalog.Commit(ctx, repository, branch, body.Message, user.Committer(), metadata, body.Date, params.SourceMetarange, swag.BoolValue(body.AllowEmpty), graveler.WithForce(swag.BoolValue(body.Force))) @@ -2966,7 +2967,7 @@ func (c *Controller) CreateCommitRecord(w http.ResponseWriter, r *http.Request, writeError(w, r, http.StatusUnauthorized, "missing user") return } - err = c.Catalog.CreateCommitRecord(ctx, repository, body.CommitId, body.Version, body.Committer, body.Message, body.MetarangeId, body.CreationDate, body.Parents, body.Metadata.AdditionalProperties, int(body.Generation), graveler.WithForce(swag.BoolValue(body.Force))) + err = c.Catalog.CreateCommitRecord(ctx, repository, body.CommitId, body.Version, body.Committer, body.Message, body.MetarangeId, body.CreationDate, body.Parents, *body.Metadata, int(body.Generation), graveler.WithForce(swag.BoolValue(body.Force))) if c.handleAPIError(ctx, w, r, err) { return } @@ -2975,13 +2976,14 @@ func (c *Controller) CreateCommitRecord(w http.ResponseWriter, r *http.Request, } func commitResponse(w http.ResponseWriter, r *http.Request, newCommit *catalog.CommitLog) { + metadata := map[string]string(newCommit.Metadata) response := apigen.Commit{ Committer: newCommit.Committer, CreationDate: newCommit.CreationDate.Unix(), Id: newCommit.Reference, Message: newCommit.Message, MetaRangeId: newCommit.MetaRangeID, - Metadata: &apigen.Commit_Metadata{AdditionalProperties: newCommit.Metadata}, + Metadata: &metadata, Parents: newCommit.Parents, Version: apiutil.Ptr(int(newCommit.Version)), Generation: apiutil.Ptr(int64(newCommit.Generation)), @@ -3023,7 +3025,7 @@ func (c *Controller) DiffBranch(w http.ResponseWriter, r *http.Request, reposito diff := apigen.Diff{ Path: d.Path, Type: transformDifferenceTypeToString(d.Type), - PathType: pathType, + PathType: apigen.DiffPathType(pathType), } if !d.CommonLevel { diff.SizeBytes = swag.Int64(d.Size) @@ -3226,7 +3228,7 @@ func (c *Controller) UploadObject(w http.ResponseWriter, r *http.Request, reposi PhysicalAddress: qk.Format(), SizeBytes: swag.Int64(blob.Size), ContentType: &contentType, - Metadata: &apigen.ObjectUserMetadata{AdditionalProperties: meta}, + Metadata: (*apigen.ObjectUserMetadata)(&meta), } writeResponse(w, r, http.StatusCreated, response) } @@ -3280,7 +3282,7 @@ func (c *Controller) StageObject(w http.ResponseWriter, r *http.Request, body ap Checksum(body.Checksum). ContentType(swag.StringValue(body.ContentType)) if body.Metadata != nil { - entryBuilder.Metadata(body.Metadata.AdditionalProperties) + entryBuilder.Metadata(catalog.Metadata(*body.Metadata)) } entry := entryBuilder.Build() @@ -3374,7 +3376,7 @@ func (c *Controller) CopyObject(w http.ResponseWriter, r *http.Request, body api PhysicalAddress: qk.Format(), SizeBytes: swag.Int64(entry.Size), ContentType: swag.String(entry.ContentType), - Metadata: &apigen.ObjectUserMetadata{AdditionalProperties: metadata}, + Metadata: (*apigen.ObjectUserMetadata)(&metadata), } writeResponse(w, r, http.StatusCreated, response) } @@ -3478,7 +3480,7 @@ func (c *Controller) GetCommit(w http.ResponseWriter, r *http.Request, repositor CreationDate: commit.CreationDate.Unix(), Message: commit.Message, MetaRangeId: commit.MetaRangeID, - Metadata: &apigen.Commit_Metadata{AdditionalProperties: commit.Metadata}, + Metadata: (*map[string]string)(&commit.Metadata), Parents: commit.Parents, Generation: apiutil.Ptr(int64(commit.Generation)), Version: apiutil.Ptr(int(commit.Version)), @@ -4141,7 +4143,7 @@ func (c *Controller) DiffRefs(w http.ResponseWriter, r *http.Request, repository diff := apigen.Diff{ Path: d.Path, Type: transformDifferenceTypeToString(d.Type), - PathType: pathType, + PathType: apigen.DiffPathType(pathType), } if !d.CommonLevel { diff.SizeBytes = swag.Int64(d.Size) @@ -4183,15 +4185,12 @@ func (c *Controller) LogCommits(w http.ResponseWriter, r *http.Request, reposito serializedCommits := make([]apigen.Commit, 0, len(commitLog)) for _, commit := range commitLog { - metadata := apigen.Commit_Metadata{ - AdditionalProperties: commit.Metadata, - } serializedCommits = append(serializedCommits, apigen.Commit{ Committer: commit.Committer, CreationDate: commit.CreationDate.Unix(), Id: commit.Reference, Message: commit.Message, - Metadata: &metadata, + Metadata: (*map[string]string)(&commit.Metadata), MetaRangeId: commit.MetaRangeID, Parents: commit.Parents, Generation: apiutil.Ptr(int64(commit.Generation)), @@ -4424,7 +4423,7 @@ func (c *Controller) ListObjects(w http.ResponseWriter, r *http.Request, reposit ContentType: swag.String(entry.ContentType), } if (params.UserMetadata == nil || *params.UserMetadata) && entry.Metadata != nil { - objStat.Metadata = &apigen.ObjectUserMetadata{AdditionalProperties: entry.Metadata} + objStat.Metadata = (*apigen.ObjectUserMetadata)(&entry.Metadata) } if swag.BoolValue(params.Presign) { // check if the user has read permissions for this object @@ -4517,7 +4516,7 @@ func (c *Controller) StatObject(w http.ResponseWriter, r *http.Request, reposito } else { metadata = map[string]string{} } - objStat.Metadata = &apigen.ObjectUserMetadata{AdditionalProperties: metadata} + objStat.Metadata = (*apigen.ObjectUserMetadata)(&metadata) code := http.StatusOK if entry.Expired { @@ -4598,7 +4597,7 @@ func (c *Controller) MergeIntoBranch(w http.ResponseWriter, r *http.Request, bod } metadata := map[string]string{} if body.Metadata != nil { - metadata = body.Metadata.AdditionalProperties + metadata = *body.Metadata } reference, err := c.Catalog.Merge(ctx, @@ -4742,7 +4741,7 @@ func (c *Controller) GetTag(w http.ResponseWriter, r *http.Request, repository, func newLoginConfig(c *config.Config) *apigen.LoginConfig { return &apigen.LoginConfig{ - RBAC: &c.Auth.UIConfig.RBAC, + RBAC: (*apigen.LoginConfigRBAC)(&c.Auth.UIConfig.RBAC), LoginUrl: c.Auth.UIConfig.LoginURL, LoginFailedMessage: &c.Auth.UIConfig.LoginFailedMessage, FallbackLoginUrl: c.Auth.UIConfig.FallbackLoginURL, @@ -4752,13 +4751,17 @@ func newLoginConfig(c *config.Config) *apigen.LoginConfig { } } +func makePtr[T any](t T) *T { + return &t +} + func (c *Controller) GetSetupState(w http.ResponseWriter, r *http.Request) { ctx := r.Context() // external auth reports as initialized to avoid triggering the setup wizard if c.Config.Auth.UIConfig.RBAC == config.AuthRBACExternal { response := apigen.SetupState{ - State: swag.String(string(auth.SetupStateInitialized)), + State: makePtr(apigen.Initialized), LoginConfig: newLoginConfig(c.Config), CommPrefsMissing: swag.Bool(false), } @@ -4776,7 +4779,7 @@ func (c *Controller) GetSetupState(w http.ResponseWriter, r *http.Request) { } response := apigen.SetupState{ - State: swag.String(string(savedState)), + State: (*apigen.SetupStateState)(&savedState), LoginConfig: newLoginConfig(c.Config), } diff --git a/pkg/api/helpers/upload.go b/pkg/api/helpers/upload.go index 57dd759012d..6c39d9ab95d 100644 --- a/pkg/api/helpers/upload.go +++ b/pkg/api/helpers/upload.go @@ -225,10 +225,8 @@ func (u *presignUpload) completeMultipart(ctx context.Context, mpu *apigen.Presi apigen.CompletePresignMultipartUploadJSONRequestBody{ Parts: uploadParts, PhysicalAddress: mpu.PhysicalAddress, - UserMetadata: &apigen.CompletePresignMultipartUpload_UserMetadata{ - AdditionalProperties: u.metadata, - }, - ContentType: apiutil.Ptr(u.contentType), + UserMetadata: &u.metadata, + ContentType: apiutil.Ptr(u.contentType), }, ) if err != nil { @@ -367,13 +365,11 @@ func (u *presignUpload) uploadObject(ctx context.Context) (*apigen.ObjectStats, } linkReqBody := apigen.LinkPhysicalAddressJSONRequestBody{ - Checksum: etag, - SizeBytes: u.size, - Staging: *stagingLocation, - UserMetadata: &apigen.StagingMetadata_UserMetadata{ - AdditionalProperties: u.metadata, - }, - ContentType: apiutil.Ptr(u.contentType), + Checksum: etag, + SizeBytes: u.size, + Staging: *stagingLocation, + UserMetadata: &u.metadata, + ContentType: apiutil.Ptr(u.contentType), } linkResp, err := u.uploader.Client.LinkPhysicalAddressWithResponse(ctx, u.repoID, u.branchID, &apigen.LinkPhysicalAddressParams{ diff --git a/pkg/api/metrics_middleware.go b/pkg/api/metrics_middleware.go index 07c9a2b6edf..128cd6c4225 100644 --- a/pkg/api/metrics_middleware.go +++ b/pkg/api/metrics_middleware.go @@ -11,7 +11,7 @@ import ( "github.com/treeverse/lakefs/pkg/httputil" ) -func MetricsMiddleware(swagger *openapi3.Swagger) func(http.Handler) http.Handler { +func MetricsMiddleware(swagger *openapi3.T) func(http.Handler) http.Handler { // router for operation ID lookup router, err := legacy.NewRouter(swagger) if err != nil { diff --git a/pkg/api/serve.go b/pkg/api/serve.go index b44b8266e4e..ae369d8fef5 100644 --- a/pkg/api/serve.go +++ b/pkg/api/serve.go @@ -102,7 +102,7 @@ func swaggerSpecHandler(w http.ResponseWriter, _ *http.Request) { // 2. For file upload wanted to skip body validation for two reasons: // a. didn't find a way for the validator to accept any file content type // b. didn't want the validator to read the complete request body for the specific request -func OapiRequestValidatorWithOptions(swagger *openapi3.Swagger, options *openapi3filter.Options) func(http.Handler) http.Handler { +func OapiRequestValidatorWithOptions(swagger *openapi3.T, options *openapi3filter.Options) func(http.Handler) http.Handler { router, err := legacy.NewRouter(swagger) if err != nil { panic(err) diff --git a/pkg/api/transform.go b/pkg/api/transform.go index 8988d9e6669..60bb53a8d10 100644 --- a/pkg/api/transform.go +++ b/pkg/api/transform.go @@ -1,21 +1,22 @@ package api import ( + "github.com/treeverse/lakefs/pkg/api/apigen" "github.com/treeverse/lakefs/pkg/catalog" ) -func transformDifferenceTypeToString(d catalog.DifferenceType) string { +func transformDifferenceTypeToString(d catalog.DifferenceType) apigen.DiffType { switch d { case catalog.DifferenceTypeAdded: - return "added" + return apigen.DiffTypeAdded case catalog.DifferenceTypeRemoved: - return "removed" + return apigen.DiffTypeRemoved case catalog.DifferenceTypeChanged: - return "changed" + return apigen.DiffTypeChanged case catalog.DifferenceTypeConflict: - return "conflict" + return apigen.DiffTypeConflict case catalog.DifferenceTypePrefixChanged: - return "prefix_changed" + return apigen.DiffTypePrefixChanged default: return "" } diff --git a/pkg/auth/service_test.go b/pkg/auth/service_test.go index 7611f86f3a3..f88d1f715a8 100644 --- a/pkg/auth/service_test.go +++ b/pkg/auth/service_test.go @@ -1793,7 +1793,7 @@ func TestAPIAuthService_WritePolicy(t *testing.T) { policyName string responseStatusCode int firstStatementResource string - firstStatementEffect string + firstStatementEffect auth.StatementEffect firstStatementAction []string responseName string expectedErr error diff --git a/pkg/local/diff.go b/pkg/local/diff.go index 61bfee02b89..8da7d5cf722 100644 --- a/pkg/local/diff.go +++ b/pkg/local/diff.go @@ -43,15 +43,15 @@ func (c *Change) String() string { return fmt.Sprintf("%s\t%s\t%s", ChangeSourceString(c.Source), ChangeTypeString(c.Type), c.Path) } -func ChangeTypeFromString(changeType string) ChangeType { +func ChangeTypeFromString(changeType apigen.DiffType) ChangeType { switch changeType { - case "added": + case apigen.DiffTypeAdded: return ChangeTypeAdded - case "removed": + case apigen.DiffTypeRemoved: return ChangeTypeRemoved - case "modified", "changed": + case apigen.DiffType("modified"), apigen.DiffTypeChanged: return ChangeTypeModified - case "conflict": + case apigen.DiffTypeConflict: return ChangeTypeConflict default: panic("invalid change type") diff --git a/pkg/local/sync.go b/pkg/local/sync.go index 26e8f6b117a..d027a07dca2 100644 --- a/pkg/local/sync.go +++ b/pkg/local/sync.go @@ -39,7 +39,7 @@ func getMtimeFromStats(stats apigen.ObjectStats) (int64, error) { if stats.Metadata == nil { return stats.Mtime, nil } - clientMtime, hasClientMtime := stats.Metadata.Get(ClientMtimeMetadataKey) + clientMtime, hasClientMtime := (*stats.Metadata)[ClientMtimeMetadataKey] if hasClientMtime { // parse return strconv.ParseInt(clientMtime, 10, 64) From dc1e8f7885f00c62c90f749f56e28a4bba6f9e57 Mon Sep 17 00:00:00 2001 From: Jonathan Rosenberg <96974219+Jonathan-Rosenberg@users.noreply.github.com> Date: Wed, 20 Mar 2024 17:59:14 +0200 Subject: [PATCH 07/12] move chi server templates to the correct location --- pkg/api/tmpl/chi/chi-handler.tmpl | 50 ++++++++++++++++++++++ pkg/api/tmpl/{ => chi}/chi-interface.tmpl | 6 +-- pkg/api/tmpl/{ => chi}/chi-middleware.tmpl | 0 3 files changed, 52 insertions(+), 4 deletions(-) create mode 100644 pkg/api/tmpl/chi/chi-handler.tmpl rename pkg/api/tmpl/{ => chi}/chi-interface.tmpl (61%) rename pkg/api/tmpl/{ => chi}/chi-middleware.tmpl (100%) diff --git a/pkg/api/tmpl/chi/chi-handler.tmpl b/pkg/api/tmpl/chi/chi-handler.tmpl new file mode 100644 index 00000000000..066e28ac3eb --- /dev/null +++ b/pkg/api/tmpl/chi/chi-handler.tmpl @@ -0,0 +1,50 @@ +// Handler creates http.Handler with routing matching OpenAPI spec. +func Handler(si ServerInterface) http.Handler { + return HandlerWithOptions(si, ChiServerOptions{}) +} + +type ChiServerOptions struct { + BaseURL string + BaseRouter chi.Router + Middlewares []MiddlewareFunc + ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) +} + +// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux. +func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler { + return HandlerWithOptions(si, ChiServerOptions { + BaseRouter: r, + }) +} + +func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler { + return HandlerWithOptions(si, ChiServerOptions { + BaseURL: baseURL, + BaseRouter: r, + }) +} + +// HandlerWithOptions creates http.Handler with additional options +func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler { +r := options.BaseRouter + +if r == nil { +r = chi.NewRouter() +} +if options.ErrorHandlerFunc == nil { + options.ErrorHandlerFunc = func(w http.ResponseWriter, r *http.Request, err error) { + http.Error(w, err.Error(), http.StatusBadRequest) + } +} +{{if .}}wrapper := ServerInterfaceWrapper{ +Handler: si, +HandlerMiddlewares: options.Middlewares, +ErrorHandlerFunc: options.ErrorHandlerFunc, +} +{{end}} +{{range .}}r.Group(func(r chi.Router) { +r.{{.Method | lower | title }}(options.BaseURL+"{{.Path | swaggerUriToChiUri}}", wrapper.{{.OperationId}}) +}) +{{end}} +return r +} \ No newline at end of file diff --git a/pkg/api/tmpl/chi-interface.tmpl b/pkg/api/tmpl/chi/chi-interface.tmpl similarity index 61% rename from pkg/api/tmpl/chi-interface.tmpl rename to pkg/api/tmpl/chi/chi-interface.tmpl index 0f48c0ca7fd..b4bab04ef4f 100644 --- a/pkg/api/tmpl/chi-interface.tmpl +++ b/pkg/api/tmpl/chi/chi-interface.tmpl @@ -3,9 +3,7 @@ // ServerInterface represents all server handlers. type ServerInterface interface { {{range .}}{{.SummaryAsComment }}{{$opid := .OperationId}} -// ({{.Method}} {{.Path}}) -{{.OperationId}}(w http.ResponseWriter, r *http.Request -{{- if .HasBody}}{{range .Bodies}}{{if and .Default (eq .NameTag "JSON")}}, body {{$opid}}{{.NameTag}}RequestBody {{end}}{{end}}{{end -}} -{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params {{.OperationId}}Params{{end}}) +// ({{.Method}} {{.Path}}) +{{.OperationId}}(w http.ResponseWriter, r *http.Request{{- if .HasBody}}{{range .Bodies}}{{if and .Default (eq .NameTag "JSON")}}, body {{$opid}}{{.NameTag}}RequestBody {{end}}{{end}}{{end -}}{{genParamArgs .PathParams}}{{if .RequiresParamObject}}, params {{.OperationId}}Params{{end}}) {{end}} } diff --git a/pkg/api/tmpl/chi-middleware.tmpl b/pkg/api/tmpl/chi/chi-middleware.tmpl similarity index 100% rename from pkg/api/tmpl/chi-middleware.tmpl rename to pkg/api/tmpl/chi/chi-middleware.tmpl From 7c420f44e112d99e98b622ff2def16087ca37398 Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Wed, 10 Apr 2024 14:16:12 +0300 Subject: [PATCH 08/12] Fix Swagger examples The new Kin generator actually enforces examples are correct. This is a Good Thing. --- api/swagger.yml | 6 ++++-- clients/java-legacy/api/openapi.yaml | 2 ++ clients/java/api/openapi.yaml | 2 ++ docs/assets/js/swagger.yml | 10 ++++++---- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/api/swagger.yml b/api/swagger.yml index fb011a03ac0..ae510fbe571 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -267,11 +267,11 @@ components: example: "main" sample_data: type: boolean - example: "true" + example: true default: false read_only: type: boolean - example: "true" + example: true default: false PathList: @@ -1467,6 +1467,8 @@ components: - path: s3://my-bucket/production/collections/file1 destination: collections/file1 type: object + commit: + message: Commit message RangeMetadata: type: object diff --git a/clients/java-legacy/api/openapi.yaml b/clients/java-legacy/api/openapi.yaml index 98ec6b1c984..7eac1386482 100644 --- a/clients/java-legacy/api/openapi.yaml +++ b/clients/java-legacy/api/openapi.yaml @@ -8819,6 +8819,8 @@ components: - path: s3://my-bucket/production/collections/file1 destination: collections/file1 type: object + commit: + message: Commit message properties: paths: items: diff --git a/clients/java/api/openapi.yaml b/clients/java/api/openapi.yaml index db50fed50a2..c71c13acef7 100644 --- a/clients/java/api/openapi.yaml +++ b/clients/java/api/openapi.yaml @@ -8793,6 +8793,8 @@ components: - path: s3://my-bucket/production/collections/file1 destination: collections/file1 type: object + commit: + message: Commit message properties: paths: items: diff --git a/docs/assets/js/swagger.yml b/docs/assets/js/swagger.yml index fb011a03ac0..a34bfac49c1 100644 --- a/docs/assets/js/swagger.yml +++ b/docs/assets/js/swagger.yml @@ -267,11 +267,11 @@ components: example: "main" sample_data: type: boolean - example: "true" + example: true default: false read_only: type: boolean - example: "true" + example: true default: false PathList: @@ -1078,8 +1078,8 @@ components: type: integer format: int64 description: | - The time-to-live for the generated token in seconds. The default - value is 3600 seconds (1 hour) maximum time allowed is 12 hours. + The time-to-live for the generated token in seconds. The maximum + value is 3600 seconds (1 hour) max is 12 hours. AuthenticationToken: type: object required: @@ -1467,6 +1467,8 @@ components: - path: s3://my-bucket/production/collections/file1 destination: collections/file1 type: object + commit: + message: Commit message RangeMetadata: type: object From b143e55dc83e0f702eb6fdffc020333c4495390d Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Wed, 10 Apr 2024 14:17:18 +0300 Subject: [PATCH 09/12] Fix middleware and some changes to accessing the changed Go APIs Includes 7e0c91c6e73bb563dcb743e34f82fd5ed6da7528, thanks @Jonathan-Rosenberg! --- esti/hooks_test.go | 4 +-- esti/import_test.go | 6 ++-- esti/merge_test.go | 4 +-- esti/presign_multipart_test.go | 4 +-- esti/system_test.go | 12 ++++---- pkg/api/controller_test.go | 41 +++++++++++++--------------- pkg/api/tmpl/chi/chi-middleware.tmpl | 1 + pkg/auth/service_test.go | 6 ++-- 8 files changed, 36 insertions(+), 42 deletions(-) diff --git a/esti/hooks_test.go b/esti/hooks_test.go index 7a1a1f44b83..5de39d7213a 100644 --- a/esti/hooks_test.go +++ b/esti/hooks_test.go @@ -141,7 +141,7 @@ func testCommitMerge(t *testing.T, ctx context.Context, repo string) { BranchID: branch, Committer: commitRecord.Committer, CommitMessage: commitRecord.Message, - Metadata: commitRecord.Metadata.AdditionalProperties, + Metadata: *commitRecord.Metadata, }, preCommitEvent) require.NotNil(t, webhookData.queryParams) require.Contains(t, webhookData.queryParams, "check_env_vars") @@ -166,7 +166,7 @@ func testCommitMerge(t *testing.T, ctx context.Context, repo string) { CommitID: commitRecord.Id, Committer: commitRecord.Committer, CommitMessage: commitRecord.Message, - Metadata: commitRecord.Metadata.AdditionalProperties, + Metadata: *commitRecord.Metadata, }, postCommitEvent) mergeResp, err := client.MergeIntoBranchWithResponse(ctx, repo, branch, mainBranch, apigen.MergeIntoBranchJSONRequestBody{}) diff --git a/esti/import_test.go b/esti/import_test.go index 3aee101eebf..23329b6e6c4 100644 --- a/esti/import_test.go +++ b/esti/import_test.go @@ -172,7 +172,7 @@ func TestImport(t *testing.T) { require.NoError(t, err) require.NotNil(t, metadataResp.JSON200) - repoMetadata := metadataResp.JSON200.AdditionalProperties + repoMetadata := *metadataResp.JSON200 require.NotNil(t, repoMetadata) importMetadata, ok := repoMetadata[graveler.MetadataKeyLastImportTimeStamp] require.True(t, ok) @@ -264,7 +264,7 @@ func testImportNew(t testing.TB, ctx context.Context, repoName, importBranch str Force: swag.Bool(force), } if len(metadata) > 0 { - body.Commit.Metadata = &apigen.CommitCreation_Metadata{AdditionalProperties: metadata} + body.Commit.Metadata = &metadata } importResp, err := client.ImportStartWithResponse(ctx, repoName, importBranch, body) @@ -314,7 +314,7 @@ func TestImportCancel(t *testing.T) { importResp, err := client.ImportStartWithResponse(ctx, repoName, branch, apigen.ImportStartJSONRequestBody{ Commit: apigen.CommitCreation{ Message: "created by import", - Metadata: &apigen.CommitCreation_Metadata{AdditionalProperties: map[string]string{"created_by": "import"}}, + Metadata: &map[string]string{"created_by": "import"}, }, Paths: []apigen.ImportLocation{{ Destination: importTargetPrefix, diff --git a/esti/merge_test.go b/esti/merge_test.go index 8f05ae2cdf7..0d43d6f413e 100644 --- a/esti/merge_test.go +++ b/esti/merge_test.go @@ -76,8 +76,8 @@ func doMergeAndListIteration(t *testing.T, logger logging.Logger, ctx context.Co res, err := client.GetCommitWithResponse(ctx, repo, mergeRes.JSON200.Reference) require.NoError(t, err, "failed to get commit") require.NotNil(t, res.JSON200) - metadata := res.JSON200.Metadata - val, ok := metadata.AdditionalProperties[graveler.MergeStrategyMetadataKey] + metadata := *res.JSON200.Metadata + val, ok := metadata[graveler.MergeStrategyMetadataKey] require.True(t, ok) require.Equal(t, strategy, val) diff --git a/esti/presign_multipart_test.go b/esti/presign_multipart_test.go index 3c822cc2a2b..e7de8ddfd92 100644 --- a/esti/presign_multipart_test.go +++ b/esti/presign_multipart_test.go @@ -234,9 +234,7 @@ func TestCompletePresignMultipartUpload(t *testing.T) { ContentType: swag.String("application/octet-stream"), Parts: parts, PhysicalAddress: respCreate.JSON201.PhysicalAddress, - UserMetadata: &apigen.CompletePresignMultipartUpload_UserMetadata{ - AdditionalProperties: map[string]string{"foo": "bar"}, - }, + UserMetadata: &map[string]string{"foo": "bar"}, }) require.NoError(t, err, "CompletePresignMultipartUpload should succeed") require.Equalf(t, http.StatusOK, resp.StatusCode(), "CompletePresignMultipartUpload status code mismatch: %s - %s", resp.Status(), resp.Body) diff --git a/esti/system_test.go b/esti/system_test.go index 2d64255ab7d..48e8ed900e1 100644 --- a/esti/system_test.go +++ b/esti/system_test.go @@ -223,13 +223,11 @@ func uploadContentDirect(ctx context.Context, client apigen.ClientWithResponsesI resp, err := client.LinkPhysicalAddressWithResponse(ctx, repoID, branchID, &apigen.LinkPhysicalAddressParams{ Path: objPath, }, apigen.LinkPhysicalAddressJSONRequestBody{ - Checksum: stats.ETag, - SizeBytes: stats.Size, - Staging: *stagingLocation, - UserMetadata: &apigen.StagingMetadata_UserMetadata{ - AdditionalProperties: metadata, - }, - ContentType: &contentType, + Checksum: stats.ETag, + SizeBytes: stats.Size, + Staging: *stagingLocation, + UserMetadata: &metadata, + ContentType: &contentType, }) if err != nil { return nil, fmt.Errorf("link object to backing store: %w", err) diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 70c87ea8e55..aef095a9c48 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -828,14 +828,13 @@ func TestController_GetCommitHandler(t *testing.T) { if len(commit.Id) == 0 { t.Errorf("GetCommit initial commit missing ID: %+v", commit) } - metadata := apigen.Commit_Metadata{} expectedCommit := &apigen.Commit{ Committer: "", CreationDate: commit.CreationDate, Id: commit.Id, Message: graveler.FirstCommitMsg, MetaRangeId: "", - Metadata: &metadata, + Metadata: nil, Parents: []string{}, Generation: swag.Int64(1), Version: swag.Int(1), @@ -1300,15 +1299,15 @@ func TestController_SetRepositoryMetadataHandler(t *testing.T) { }) verifyResponseOK(t, createResp, err) - resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: apigen.RepositoryMetadataSet_Metadata{AdditionalProperties: tt1.properties}}) + resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: tt1.properties}) verifyResponseOK(t, resp, err) - resp, err = clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: apigen.RepositoryMetadataSet_Metadata{AdditionalProperties: tt1.appendProps}}) + resp, err = clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: tt1.appendProps}) verifyResponseOK(t, resp, err) getResp, err := clt.GetRepositoryMetadataWithResponse(ctx, repoName) verifyResponseOK(t, resp, err) - if diff := deep.Equal(getResp.JSON200.AdditionalProperties, tt1.expected); diff != nil { + if diff := deep.Equal(*getResp.JSON200, apigen.RepositoryMetadata(tt1.expected)); diff != nil { t.Fatal("Get repository metadata results diff:", diff) } }) @@ -1328,13 +1327,13 @@ func TestController_SetRepositoryMetadataHandler(t *testing.T) { }) verifyResponseOK(t, createResp, err) - resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: apigen.RepositoryMetadataSet_Metadata{AdditionalProperties: map[string]string{"foo": "bar"}}}) + resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: map[string]string{"foo": "bar"}}) verifyResponseOK(t, resp, err) }) t.Run("set repository metadata not exist", func(t *testing.T) { repoName := testUniqueRepoName() - resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: apigen.RepositoryMetadataSet_Metadata{AdditionalProperties: map[string]string{"foo": "bar"}}}) + resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: map[string]string{"foo": "bar"}}) require.NoError(t, err) require.NotNil(t, resp.JSON404) }) @@ -1352,7 +1351,7 @@ func TestController_SetRepositoryMetadataHandler(t *testing.T) { creds := createUserWithDefaultGroup(t, clt) // create a client with the user regClt := setupClientByEndpoint(t, deps.server.URL, creds.AccessKeyID, creds.SecretAccessKey) - resp, err := regClt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: apigen.RepositoryMetadataSet_Metadata{AdditionalProperties: map[string]string{"foo": "bar"}}}) + resp, err := regClt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: map[string]string{"foo": "bar"}}) require.NoError(t, err) require.NotNil(t, resp.JSON401) }) @@ -1404,7 +1403,7 @@ func TestController_DeleteRepositoryMetadataHandler(t *testing.T) { }) verifyResponseOK(t, createResp, err) - resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: apigen.RepositoryMetadataSet_Metadata{AdditionalProperties: tt.properties}}) + resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: tt.properties}) verifyResponseOK(t, resp, err) deleteResp, err := clt.DeleteRepositoryMetadataWithResponse(ctx, repoName, apigen.DeleteRepositoryMetadataJSONRequestBody{Keys: tt.deleteProps}) @@ -1412,7 +1411,7 @@ func TestController_DeleteRepositoryMetadataHandler(t *testing.T) { getResp, err := clt.GetRepositoryMetadataWithResponse(ctx, repoName) verifyResponseOK(t, getResp, err) - if diff := deep.Equal(getResp.JSON200.AdditionalProperties, tt.expected); diff != nil { + if diff := deep.Equal(*getResp.JSON200, apigen.RepositoryMetadata(tt.expected)); diff != nil { t.Fatal("Get repository metadata results diff:", diff) } }) @@ -1432,13 +1431,13 @@ func TestController_DeleteRepositoryMetadataHandler(t *testing.T) { }) verifyResponseOK(t, createResp, err) - resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: apigen.RepositoryMetadataSet_Metadata{AdditionalProperties: map[string]string{"foo": "bar"}}}) + resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: map[string]string{"foo": "bar"}}) verifyResponseOK(t, resp, err) }) t.Run("delete repository metadata, repository not exist", func(t *testing.T) { repoName := testUniqueRepoName() - resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: apigen.RepositoryMetadataSet_Metadata{AdditionalProperties: map[string]string{"foo": "bar"}}}) + resp, err := clt.SetRepositoryMetadataWithResponse(ctx, repoName, apigen.SetRepositoryMetadataJSONRequestBody{Metadata: map[string]string{"foo": "bar"}}) require.NoError(t, err) require.NotNil(t, resp.JSON404) }) @@ -1477,8 +1476,7 @@ func TestController_GetRepositoryMetadataHandler(t *testing.T) { resp, err := clt.GetRepositoryMetadataWithResponse(ctx, repoName) verifyResponseOK(t, resp, err) - require.NotNil(t, resp.JSON200) - require.Nil(t, resp.JSON200.AdditionalProperties) + require.Empty(t, resp.JSON200, 0) }) t.Run("get metadata bare repo", func(t *testing.T) { @@ -1496,8 +1494,7 @@ func TestController_GetRepositoryMetadataHandler(t *testing.T) { resp, err := clt.GetRepositoryMetadataWithResponse(ctx, repoName) verifyResponseOK(t, resp, err) - require.NotNil(t, resp.JSON200) - require.Nil(t, resp.JSON200.AdditionalProperties) + require.Empty(t, resp.JSON200) }) t.Run("get repository metadata not exist", func(t *testing.T) { @@ -2328,7 +2325,7 @@ func TestController_ObjectsStatObjectHandler(t *testing.T) { if objectStats.PhysicalAddress != onBlock(deps, "some-bucket/")+entry.PhysicalAddress { t.Fatalf("expected correct PhysicalAddress, got %s", objectStats.PhysicalAddress) } - if diff := deep.Equal(objectStats.Metadata.AdditionalProperties, map[string]string(entry.Metadata)); diff != nil { + if diff := deep.Equal(*objectStats.Metadata, apigen.ObjectUserMetadata(entry.Metadata)); diff != nil { t.Fatalf("expected to get back user-defined metadata: %s", diff) } contentType := apiutil.Value(objectStats.ContentType) @@ -2341,8 +2338,8 @@ func TestController_ObjectsStatObjectHandler(t *testing.T) { resp, err = clt.StatObjectWithResponse(ctx, repo, "main", &apigen.StatObjectParams{Path: "foo/bar", UserMetadata: &getUserMetadata}) verifyResponseOK(t, resp, err) objectStatsNoMetadata := resp.JSON200 - if objectStatsNoMetadata.Metadata == nil || len(objectStatsNoMetadata.Metadata.AdditionalProperties) != 0 { - t.Fatalf("expected to not get back empty user-defined metadata, got %+v", objectStatsNoMetadata.Metadata.AdditionalProperties) + if objectStatsNoMetadata.Metadata == nil || len(*objectStatsNoMetadata.Metadata) != 0 { + t.Fatalf("expected to not get back empty user-defined metadata, got %+v", objectStatsNoMetadata.Metadata) } }) @@ -2439,7 +2436,7 @@ func TestController_ObjectsListObjectsHandler(t *testing.T) { results := resp.JSON200.Results for _, obj := range results { if obj.Metadata != nil { - t.Fatalf("expected no user-defined metadata, got %+v", obj.Metadata.AdditionalProperties) + t.Fatalf("expected no user-defined metadata, got %+v", obj.Metadata) } } }) @@ -5536,7 +5533,7 @@ func TestController_CreateCommitRecord(t *testing.T) { CreationDate: 1e9, Generation: 1, Message: "message", - Metadata: &apigen.CommitRecordCreation_Metadata{AdditionalProperties: map[string]string{"key": "value"}}, + Metadata: &map[string]string{"key": "value"}, MetarangeId: "metarangeId", Parents: []string{"parent1", "parent2"}, Version: 1, @@ -5558,7 +5555,7 @@ func TestController_CreateCommitRecord(t *testing.T) { Committer: body.Committer, Message: body.Message, CreationDate: time.Unix(body.CreationDate, 0).UTC(), - Metadata: body.Metadata.AdditionalProperties, + Metadata: *body.Metadata, MetaRangeID: body.MetarangeId, Parents: body.Parents, Generation: catalog.CommitGeneration(body.Generation), diff --git a/pkg/api/tmpl/chi/chi-middleware.tmpl b/pkg/api/tmpl/chi/chi-middleware.tmpl index cb126ddb31b..c3038ee25e5 100644 --- a/pkg/api/tmpl/chi/chi-middleware.tmpl +++ b/pkg/api/tmpl/chi/chi-middleware.tmpl @@ -4,6 +4,7 @@ type ServerInterfaceWrapper struct { Handler ServerInterface HandlerMiddlewares []MiddlewareFunc + ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) } type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc diff --git a/pkg/auth/service_test.go b/pkg/auth/service_test.go index f88d1f715a8..e8da2fb2b3a 100644 --- a/pkg/auth/service_test.go +++ b/pkg/auth/service_test.go @@ -1907,7 +1907,7 @@ func TestAPIAuthService_WritePolicy(t *testing.T) { CreatedAt: creationTime, Statement: []model.Statement{{ Action: tt.firstStatementAction, - Effect: tt.firstStatementEffect, + Effect: string(tt.firstStatementEffect), Resource: tt.firstStatementResource, }}, }, tt.overwrite) @@ -1963,7 +1963,7 @@ func TestAPIAuthService_GetPolicy(t *testing.T) { Statement: []auth.Statement{ { Action: tt.firstStatementAction, - Effect: tt.firstStatementEffect, + Effect: auth.StatementEffect(tt.firstStatementEffect), Resource: tt.firstStatementResource, }, }, @@ -2011,7 +2011,7 @@ func statementEquals(t *testing.T, authStatement []auth.Statement, modalStatemen return } for i, authS := range authStatement { - if authS.Effect != modalStatement[i].Effect { + if string(authS.Effect) != modalStatement[i].Effect { t.Errorf("Effect (authStatement)%s != (modelStatement)%s", modalStatement[i].Effect, authS.Effect) } if authS.Resource != modalStatement[i].Resource { From a88555388e827018c1874ed4bfe389fc52e07226 Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Wed, 10 Apr 2024 22:59:15 +0300 Subject: [PATCH 10/12] Allow pagination prefix, after params to be empty strings Apparently Kin now enforces even more OpenAPI rules. --- api/swagger.yml | 5 +- clients/java-legacy/api/openapi.yaml | 111 ++++++++++++++++++--------- clients/java/api/openapi.yaml | 111 ++++++++++++++++++--------- docs/assets/js/swagger.yml | 3 + 4 files changed, 157 insertions(+), 73 deletions(-) diff --git a/api/swagger.yml b/api/swagger.yml index ae510fbe571..6e00af9da06 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -46,6 +46,7 @@ components: description: return items prefixed with this value schema: type: string + allowEmptyValue: true PaginationAfter: in: query @@ -53,6 +54,7 @@ components: description: return items after this value schema: type: string + allowEmptyValue: true PaginationAmount: in: query @@ -70,7 +72,8 @@ components: description: delimiter used to group common prefixes by schema: type: string - + allowEmptyValue: true + IfNoneMatch: in: header name: If-None-Match diff --git a/clients/java-legacy/api/openapi.yaml b/clients/java-legacy/api/openapi.yaml index 7eac1386482..2d14aaac6d3 100644 --- a/clients/java-legacy/api/openapi.yaml +++ b/clients/java-legacy/api/openapi.yaml @@ -292,7 +292,8 @@ paths: get: operationId: listUsers parameters: - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -300,7 +301,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -472,7 +474,8 @@ paths: get: operationId: listGroups parameters: - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -480,7 +483,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -646,7 +650,8 @@ paths: get: operationId: listPolicies parameters: - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -654,7 +659,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -888,7 +894,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -896,7 +903,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1040,7 +1048,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1048,7 +1057,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1243,7 +1253,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1251,7 +1262,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1312,7 +1324,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1320,7 +1333,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1586,7 +1600,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1594,7 +1609,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1701,7 +1717,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1709,7 +1726,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1938,7 +1956,8 @@ paths: get: operationId: listRepositories parameters: - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1946,7 +1965,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -2847,7 +2867,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -2855,7 +2876,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -3088,7 +3110,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -3096,7 +3119,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -3230,7 +3254,8 @@ paths: schema: type: string style: simple - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -4031,7 +4056,8 @@ paths: get: operationId: diffBranch parameters: - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -4050,7 +4076,8 @@ paths: minimum: -1 type: integer style: form - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -4058,7 +4085,8 @@ paths: schema: type: string style: form - - description: delimiter used to group common prefixes by + - allowEmptyValue: true + description: delimiter used to group common prefixes by explode: true in: query name: delimiter @@ -4139,7 +4167,8 @@ paths: schema: type: string style: simple - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -4158,7 +4187,8 @@ paths: minimum: -1 type: integer style: form - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -4166,7 +4196,8 @@ paths: schema: type: string style: form - - description: delimiter used to group common prefixes by + - allowEmptyValue: true + description: delimiter used to group common prefixes by explode: true in: query name: delimiter @@ -5740,7 +5771,8 @@ paths: schema: type: boolean style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -5759,7 +5791,8 @@ paths: minimum: -1 type: integer style: form - - description: delimiter used to group common prefixes by + - allowEmptyValue: true + description: delimiter used to group common prefixes by explode: true in: query name: delimiter @@ -5767,7 +5800,8 @@ paths: schema: type: string style: form - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -5874,7 +5908,8 @@ paths: schema: type: string style: simple - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -6005,7 +6040,8 @@ paths: schema: type: string style: simple - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -6852,6 +6888,7 @@ paths: components: parameters: PaginationPrefix: + allowEmptyValue: true description: return items prefixed with this value explode: true in: query @@ -6861,6 +6898,7 @@ components: type: string style: form PaginationAfter: + allowEmptyValue: true description: return items after this value explode: true in: query @@ -6882,6 +6920,7 @@ components: type: integer style: form PaginationDelimiter: + allowEmptyValue: true description: delimiter used to group common prefixes by explode: true in: query diff --git a/clients/java/api/openapi.yaml b/clients/java/api/openapi.yaml index c71c13acef7..b10d8ebbabf 100644 --- a/clients/java/api/openapi.yaml +++ b/clients/java/api/openapi.yaml @@ -292,7 +292,8 @@ paths: get: operationId: listUsers parameters: - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -300,7 +301,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -472,7 +474,8 @@ paths: get: operationId: listGroups parameters: - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -480,7 +483,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -646,7 +650,8 @@ paths: get: operationId: listPolicies parameters: - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -654,7 +659,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -888,7 +894,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -896,7 +903,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1040,7 +1048,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1048,7 +1057,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1243,7 +1253,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1251,7 +1262,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1312,7 +1324,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1320,7 +1333,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1586,7 +1600,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1594,7 +1609,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1701,7 +1717,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1709,7 +1726,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -1938,7 +1956,8 @@ paths: get: operationId: listRepositories parameters: - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -1946,7 +1965,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -2847,7 +2867,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -2855,7 +2876,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -3088,7 +3110,8 @@ paths: schema: type: string style: simple - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -3096,7 +3119,8 @@ paths: schema: type: string style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -3230,7 +3254,8 @@ paths: schema: type: string style: simple - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -4031,7 +4056,8 @@ paths: get: operationId: diffBranch parameters: - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -4050,7 +4076,8 @@ paths: minimum: -1 type: integer style: form - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -4058,7 +4085,8 @@ paths: schema: type: string style: form - - description: delimiter used to group common prefixes by + - allowEmptyValue: true + description: delimiter used to group common prefixes by explode: true in: query name: delimiter @@ -4139,7 +4167,8 @@ paths: schema: type: string style: simple - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -4158,7 +4187,8 @@ paths: minimum: -1 type: integer style: form - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -4166,7 +4196,8 @@ paths: schema: type: string style: form - - description: delimiter used to group common prefixes by + - allowEmptyValue: true + description: delimiter used to group common prefixes by explode: true in: query name: delimiter @@ -5735,7 +5766,8 @@ paths: schema: type: boolean style: form - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -5754,7 +5786,8 @@ paths: minimum: -1 type: integer style: form - - description: delimiter used to group common prefixes by + - allowEmptyValue: true + description: delimiter used to group common prefixes by explode: true in: query name: delimiter @@ -5762,7 +5795,8 @@ paths: schema: type: string style: form - - description: return items prefixed with this value + - allowEmptyValue: true + description: return items prefixed with this value explode: true in: query name: prefix @@ -5869,7 +5903,8 @@ paths: schema: type: string style: simple - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -6000,7 +6035,8 @@ paths: schema: type: string style: simple - - description: return items after this value + - allowEmptyValue: true + description: return items after this value explode: true in: query name: after @@ -6841,6 +6877,7 @@ paths: components: parameters: PaginationPrefix: + allowEmptyValue: true description: return items prefixed with this value explode: true in: query @@ -6850,6 +6887,7 @@ components: type: string style: form PaginationAfter: + allowEmptyValue: true description: return items after this value explode: true in: query @@ -6871,6 +6909,7 @@ components: type: integer style: form PaginationDelimiter: + allowEmptyValue: true description: delimiter used to group common prefixes by explode: true in: query diff --git a/docs/assets/js/swagger.yml b/docs/assets/js/swagger.yml index a34bfac49c1..60069c17d18 100644 --- a/docs/assets/js/swagger.yml +++ b/docs/assets/js/swagger.yml @@ -46,6 +46,7 @@ components: description: return items prefixed with this value schema: type: string + allowEmptyValue: true PaginationAfter: in: query @@ -53,6 +54,7 @@ components: description: return items after this value schema: type: string + allowEmptyValue: true PaginationAmount: in: query @@ -70,6 +72,7 @@ components: description: delimiter used to group common prefixes by schema: type: string + allowEmptyValue: true IfNoneMatch: in: header From 149612238a06e215a2505a343e1d161676732d88 Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Thu, 11 Apr 2024 15:51:06 +0300 Subject: [PATCH 11/12] Fix types to match generated code The new generated code no longer aliases some types. This manifests primarily in all pagination parameters, which are now actual strings and ints. --- Makefile | 1 + cmd/lakectl/cmd/abuse_commit.go | 2 +- cmd/lakectl/cmd/abuse_create_branches.go | 4 +-- cmd/lakectl/cmd/abuse_list.go | 2 +- cmd/lakectl/cmd/abuse_random_writes.go | 2 +- cmd/lakectl/cmd/actions_runs_describe.go | 5 ++-- cmd/lakectl/cmd/actions_runs_list.go | 5 ++-- cmd/lakectl/cmd/annotate.go | 6 ++-- cmd/lakectl/cmd/auth_groups_list.go | 5 ++-- cmd/lakectl/cmd/auth_groups_members_list.go | 5 ++-- cmd/lakectl/cmd/auth_groups_policies_list.go | 5 ++-- cmd/lakectl/cmd/auth_policies_list.go | 4 +-- .../cmd/auth_users_credentials_list.go | 5 ++-- cmd/lakectl/cmd/auth_users_groups_list.go | 5 ++-- cmd/lakectl/cmd/auth_users_list.go | 5 ++-- cmd/lakectl/cmd/auth_users_policies_list.go | 5 ++-- cmd/lakectl/cmd/bisect.go | 4 +-- cmd/lakectl/cmd/branch_list.go | 5 ++-- cmd/lakectl/cmd/branch_reset.go | 2 +- cmd/lakectl/cmd/diff.go | 4 +-- cmd/lakectl/cmd/fs_download.go | 4 +-- cmd/lakectl/cmd/fs_ls.go | 5 ++-- cmd/lakectl/cmd/fs_rm.go | 5 ++-- cmd/lakectl/cmd/fs_stage.go | 2 +- cmd/lakectl/cmd/local_clone.go | 4 +-- cmd/lakectl/cmd/log.go | 6 ++-- cmd/lakectl/cmd/refs_restore.go | 2 +- cmd/lakectl/cmd/repo_list.go | 5 ++-- cmd/lakectl/cmd/tag_list.go | 5 ++-- cmd/lakectl/cmd/validargs.go | 5 ++-- esti/auth_test.go | 2 +- esti/catalog_export_test.go | 3 +- esti/main_test.go | 9 +++--- esti/merge_test.go | 2 +- esti/sanity_api_test.go | 2 +- esti/system_test.go | 8 +++--- pkg/api/controller.go | 21 ++++++++------ pkg/api/controller_test.go | 28 +++++++++---------- pkg/auth/service.go | 18 ++++-------- pkg/diff/diff.go | 5 ++-- pkg/local/diff.go | 4 +-- 41 files changed, 103 insertions(+), 123 deletions(-) diff --git a/Makefile b/Makefile index 578abacbf11..855aacd92ac 100644 --- a/Makefile +++ b/Makefile @@ -14,6 +14,7 @@ OPENAPI_GENERATOR_IMAGE=treeverse/openapi-generator-cli:v7.0.0.1 OPENAPI_GENERATOR=$(DOCKER) run --user $(UID_GID) --rm -v $(shell pwd):/mnt $(OPENAPI_GENERATOR_IMAGE) GOLANGCI_LINT_VERSION=v1.53.3 +GOLANGCI_LINT_FLAGS=--max-same-issues=50 BUF_CLI_VERSION=v1.28.1 ifndef PACKAGE_VERSION diff --git a/cmd/lakectl/cmd/abuse_commit.go b/cmd/lakectl/cmd/abuse_commit.go index 51ab2478fec..4db990dca5f 100644 --- a/cmd/lakectl/cmd/abuse_commit.go +++ b/cmd/lakectl/cmd/abuse_commit.go @@ -51,7 +51,7 @@ var abuseCommitCmd = &cobra.Command{ for work := range input { start := time.Now() resp, err := client.CommitWithResponse(ctx, u.Repository, u.Ref, &apigen.CommitParams{}, - apigen.CommitJSONRequestBody(apigen.CommitCreation{Message: work})) + apigen.CommitCreation{Message: work}) if err == nil && resp.StatusCode() != http.StatusOK { err = helpers.ResponseAsError(resp) } diff --git a/cmd/lakectl/cmd/abuse_create_branches.go b/cmd/lakectl/cmd/abuse_create_branches.go index cb721876a7f..3f0ef42ef06 100644 --- a/cmd/lakectl/cmd/abuse_create_branches.go +++ b/cmd/lakectl/cmd/abuse_create_branches.go @@ -34,7 +34,7 @@ var abuseCreateBranchesCmd = &cobra.Command{ const paginationAmount = 1000 deleteGen.Setup(func(add stress.GeneratorAddFn) { - currentOffset := apigen.PaginationAfter(branchPrefix) + currentOffset := branchPrefix amount := apigen.PaginationAmount(paginationAmount) for { resp, err := client.ListBranchesWithResponse(cmd.Context(), u.Repository, &apigen.ListBranchesParams{ @@ -56,7 +56,7 @@ var abuseCreateBranchesCmd = &cobra.Command{ if !pagination.HasMore { return } - currentOffset = apigen.PaginationAfter(pagination.NextOffset) + currentOffset = pagination.NextOffset } }) diff --git a/cmd/lakectl/cmd/abuse_list.go b/cmd/lakectl/cmd/abuse_list.go index 5af00096d77..f3f89c99190 100644 --- a/cmd/lakectl/cmd/abuse_list.go +++ b/cmd/lakectl/cmd/abuse_list.go @@ -34,7 +34,7 @@ var abuseListCmd = &cobra.Command{ } }) - listPrefix := apigen.PaginationPrefix(prefix) + listPrefix := prefix // execute the things! generator.Run(func(input chan string, output chan stress.Result) { ctx := cmd.Context() diff --git a/cmd/lakectl/cmd/abuse_random_writes.go b/cmd/lakectl/cmd/abuse_random_writes.go index 68bd30aaac2..0d7e1ee6b0c 100644 --- a/cmd/lakectl/cmd/abuse_random_writes.go +++ b/cmd/lakectl/cmd/abuse_random_writes.go @@ -60,7 +60,7 @@ var abuseRandomWritesCmd = &cobra.Command{ for work := range input { start := time.Now() resp, err := client.StageObjectWithResponse(ctx, u.Repository, u.Ref, &apigen.StageObjectParams{Path: work}, - apigen.StageObjectJSONRequestBody(creationInfo)) + creationInfo) if err == nil && resp.StatusCode() != http.StatusOK { err = helpers.ResponseAsError(resp) } diff --git a/cmd/lakectl/cmd/actions_runs_describe.go b/cmd/lakectl/cmd/actions_runs_describe.go index ef5d27a9cd5..7c168e0d4cc 100644 --- a/cmd/lakectl/cmd/actions_runs_describe.go +++ b/cmd/lakectl/cmd/actions_runs_describe.go @@ -8,7 +8,6 @@ import ( "github.com/jedib0t/go-pretty/v6/text" "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" "github.com/treeverse/lakefs/pkg/api/helpers" ) @@ -54,8 +53,8 @@ var actionsRunsDescribeCmd = &cobra.Command{ } // iterator over hooks - print information and output runHooksRes, err := client.ListRunHooksWithResponse(ctx, u.Repository, runID, &apigen.ListRunHooksParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amountForPagination)), + After: &after, + Amount: &amountForPagination, }) DieOnErrorOrUnexpectedStatusCode(runHooksRes, err, http.StatusOK) if runHooksRes.JSON200 == nil { diff --git a/cmd/lakectl/cmd/actions_runs_list.go b/cmd/lakectl/cmd/actions_runs_list.go index 683cb04b992..d6abbd30521 100644 --- a/cmd/lakectl/cmd/actions_runs_list.go +++ b/cmd/lakectl/cmd/actions_runs_list.go @@ -5,7 +5,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) const actionsRunsListTemplate = `{{.ActionsRunsTable | table -}} @@ -43,8 +42,8 @@ var actionsRunsListCmd = &cobra.Command{ } resp, err := client.ListRepositoryRunsWithResponse(ctx, u.Repository, &apigen.ListRepositoryRunsParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, Branch: optionalBranch, Commit: optionalCommit, }) diff --git a/cmd/lakectl/cmd/annotate.go b/cmd/lakectl/cmd/annotate.go index 73f80c9bf42..708135fcbdd 100644 --- a/cmd/lakectl/cmd/annotate.go +++ b/cmd/lakectl/cmd/annotate.go @@ -33,7 +33,7 @@ var annotateCmd = &cobra.Command{ recursive := Must(cmd.Flags().GetBool(recursiveFlagName)) firstParent := Must(cmd.Flags().GetBool("first-parent")) client := getClient() - pfx := apigen.PaginationPrefix(*pathURI.Path) + pfx := *pathURI.Path context := cmd.Context() resp, err := client.ListObjectsWithResponse(context, pathURI.Repository, pathURI.Ref, &apigen.ListObjectsParams{Prefix: &pfx}) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) @@ -49,7 +49,7 @@ var annotateCmd = &cobra.Command{ for { params := &apigen.ListObjectsParams{ Prefix: &pfx, - After: apiutil.Ptr(apigen.PaginationAfter(from)), + After: &from, Delimiter: &listObjectsDelimiter, } listObjectsResp, err := client.ListObjectsWithResponse(context, pathURI.Repository, pathURI.Ref, params) @@ -59,7 +59,7 @@ var annotateCmd = &cobra.Command{ } for _, obj := range listObjectsResp.JSON200.Results { logCommitsParams := &apigen.LogCommitsParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(1)), + Amount: apiutil.Ptr(1), Limit: &limit, FirstParent: &firstParent, } diff --git a/cmd/lakectl/cmd/auth_groups_list.go b/cmd/lakectl/cmd/auth_groups_list.go index 6e672b2e78c..79b84ea5271 100644 --- a/cmd/lakectl/cmd/auth_groups_list.go +++ b/cmd/lakectl/cmd/auth_groups_list.go @@ -6,7 +6,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var authGroupsListCmd = &cobra.Command{ @@ -19,8 +18,8 @@ var authGroupsListCmd = &cobra.Command{ clt := getClient() resp, err := clt.ListGroupsWithResponse(cmd.Context(), &apigen.ListGroupsParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/auth_groups_members_list.go b/cmd/lakectl/cmd/auth_groups_members_list.go index 3850b608329..11a05b39259 100644 --- a/cmd/lakectl/cmd/auth_groups_members_list.go +++ b/cmd/lakectl/cmd/auth_groups_members_list.go @@ -5,7 +5,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var authGroupsMembersList = &cobra.Command{ @@ -19,8 +18,8 @@ var authGroupsMembersList = &cobra.Command{ clt := getClient() resp, err := clt.ListGroupMembersWithResponse(cmd.Context(), id, &apigen.ListGroupMembersParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/auth_groups_policies_list.go b/cmd/lakectl/cmd/auth_groups_policies_list.go index 94c6711e86e..80ab077bee7 100644 --- a/cmd/lakectl/cmd/auth_groups_policies_list.go +++ b/cmd/lakectl/cmd/auth_groups_policies_list.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var authGroupsPoliciesList = &cobra.Command{ @@ -21,8 +20,8 @@ var authGroupsPoliciesList = &cobra.Command{ clt := getClient() resp, err := clt.ListGroupPoliciesWithResponse(cmd.Context(), id, &apigen.ListGroupPoliciesParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/auth_policies_list.go b/cmd/lakectl/cmd/auth_policies_list.go index 91cac8613af..a24b5e39e63 100644 --- a/cmd/lakectl/cmd/auth_policies_list.go +++ b/cmd/lakectl/cmd/auth_policies_list.go @@ -19,8 +19,8 @@ var authPoliciesList = &cobra.Command{ clt := getClient() resp, err := clt.ListPoliciesWithResponse(cmd.Context(), &apigen.ListPoliciesParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: apiutil.Ptr(after), + Amount: apiutil.Ptr(amount), }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/auth_users_credentials_list.go b/cmd/lakectl/cmd/auth_users_credentials_list.go index d9d2ee2fe6a..56e5e60ba89 100644 --- a/cmd/lakectl/cmd/auth_users_credentials_list.go +++ b/cmd/lakectl/cmd/auth_users_credentials_list.go @@ -6,7 +6,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var authUsersCredentialsList = &cobra.Command{ @@ -28,8 +27,8 @@ var authUsersCredentialsList = &cobra.Command{ } resp, err := clt.ListUserCredentialsWithResponse(cmd.Context(), id, &apigen.ListUserCredentialsParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/auth_users_groups_list.go b/cmd/lakectl/cmd/auth_users_groups_list.go index 198f6ba9146..70edafe4f7c 100644 --- a/cmd/lakectl/cmd/auth_users_groups_list.go +++ b/cmd/lakectl/cmd/auth_users_groups_list.go @@ -6,7 +6,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var authUsersGroupsList = &cobra.Command{ @@ -20,8 +19,8 @@ var authUsersGroupsList = &cobra.Command{ clt := getClient() resp, err := clt.ListUserGroupsWithResponse(cmd.Context(), id, &apigen.ListUserGroupsParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/auth_users_list.go b/cmd/lakectl/cmd/auth_users_list.go index d06ac810f7d..930599c560d 100644 --- a/cmd/lakectl/cmd/auth_users_list.go +++ b/cmd/lakectl/cmd/auth_users_list.go @@ -6,7 +6,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var authUsersList = &cobra.Command{ @@ -19,8 +18,8 @@ var authUsersList = &cobra.Command{ clt := getClient() resp, err := clt.ListUsersWithResponse(cmd.Context(), &apigen.ListUsersParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/auth_users_policies_list.go b/cmd/lakectl/cmd/auth_users_policies_list.go index f5afba6edb5..673f37adbfc 100644 --- a/cmd/lakectl/cmd/auth_users_policies_list.go +++ b/cmd/lakectl/cmd/auth_users_policies_list.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var authUsersPoliciesList = &cobra.Command{ @@ -22,8 +21,8 @@ var authUsersPoliciesList = &cobra.Command{ clt := getClient() resp, err := clt.ListUserPoliciesWithResponse(cmd.Context(), id, &apigen.ListUserPoliciesParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, Effective: &effective, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) diff --git a/cmd/lakectl/cmd/bisect.go b/cmd/lakectl/cmd/bisect.go index 36a163fd553..ab3db51ce95 100644 --- a/cmd/lakectl/cmd/bisect.go +++ b/cmd/lakectl/cmd/bisect.go @@ -149,7 +149,7 @@ func (b *Bisect) Update(ctx context.Context, client apigen.ClientWithResponsesIn b.Commits = nil const amountPerCall = 500 params := &apigen.LogCommitsParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(amountPerCall)), + Amount: apiutil.Ptr(amountPerCall), } var commits []*apigen.Commit for { @@ -169,7 +169,7 @@ func (b *Bisect) Update(ctx context.Context, client apigen.ClientWithResponsesIn if !logResponse.JSON200.Pagination.HasMore { break } - params.After = apiutil.Ptr(apigen.PaginationAfter(logResponse.JSON200.Pagination.NextOffset)) + params.After = &logResponse.JSON200.Pagination.NextOffset } return fmt.Errorf("good %w", ErrCommitNotFound) } diff --git a/cmd/lakectl/cmd/branch_list.go b/cmd/lakectl/cmd/branch_list.go index 12269ba5773..56e2f5e65ba 100644 --- a/cmd/lakectl/cmd/branch_list.go +++ b/cmd/lakectl/cmd/branch_list.go @@ -5,7 +5,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var branchListCmd = &cobra.Command{ @@ -20,8 +19,8 @@ var branchListCmd = &cobra.Command{ u := MustParseRepoURI("repository URI", args[0]) client := getClient() resp, err := client.ListBranchesWithResponse(cmd.Context(), u.Repository, &apigen.ListBranchesParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/branch_reset.go b/cmd/lakectl/cmd/branch_reset.go index c288101003c..2553f6604b2 100644 --- a/cmd/lakectl/cmd/branch_reset.go +++ b/cmd/lakectl/cmd/branch_reset.go @@ -59,7 +59,7 @@ var branchResetCmd = &cobra.Command{ Die("Reset aborted", 1) return } - resp, err := clt.ResetBranchWithResponse(cmd.Context(), u.Repository, u.Ref, apigen.ResetBranchJSONRequestBody(reset)) + resp, err := clt.ResetBranchWithResponse(cmd.Context(), u.Repository, u.Ref, reset) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusNoContent) }, } diff --git a/cmd/lakectl/cmd/diff.go b/cmd/lakectl/cmd/diff.go index fd765582e56..5e24235b89e 100644 --- a/cmd/lakectl/cmd/diff.go +++ b/cmd/lakectl/cmd/diff.go @@ -89,8 +89,8 @@ func printDiffBranch(ctx context.Context, client apigen.ClientWithResponsesInter pageSize := pageSize(minDiffPageSize) for { resp, err := client.DiffBranchWithResponse(ctx, repository, branch, &apigen.DiffBranchParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(pageSize)), + After: &after, + Amount: apiutil.Ptr(int(pageSize)), }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/fs_download.go b/cmd/lakectl/cmd/fs_download.go index 7c108490611..64aa8372ca3 100644 --- a/cmd/lakectl/cmd/fs_download.go +++ b/cmd/lakectl/cmd/fs_download.go @@ -70,8 +70,8 @@ var fsDownloadCmd = &cobra.Command{ var after string for { listResp, err := client.ListObjectsWithResponse(ctx, remote.Repository, remote.Ref, &apigen.ListObjectsParams{ - After: (*apigen.PaginationAfter)(swag.String(after)), - Prefix: (*apigen.PaginationPrefix)(remote.Path), + After: &after, + Prefix: remote.Path, UserMetadata: swag.Bool(true), }) DieOnErrorOrUnexpectedStatusCode(listResp, err, http.StatusOK) diff --git a/cmd/lakectl/cmd/fs_ls.go b/cmd/lakectl/cmd/fs_ls.go index 9d442f7cf10..fd9bf35a996 100644 --- a/cmd/lakectl/cmd/fs_ls.go +++ b/cmd/lakectl/cmd/fs_ls.go @@ -6,7 +6,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var fsLsCmd = &cobra.Command{ @@ -32,10 +31,10 @@ var fsLsCmd = &cobra.Command{ } var from string for { - pfx := apigen.PaginationPrefix(prefix) + pfx := prefix params := &apigen.ListObjectsParams{ Prefix: &pfx, - After: apiutil.Ptr(apigen.PaginationAfter(from)), + After: &from, Delimiter: ¶msDelimiter, } resp, err := client.ListObjectsWithResponse(cmd.Context(), pathURI.Repository, pathURI.Ref, params) diff --git a/cmd/lakectl/cmd/fs_rm.go b/cmd/lakectl/cmd/fs_rm.go index 628bf2e8c6e..8dffb418334 100644 --- a/cmd/lakectl/cmd/fs_rm.go +++ b/cmd/lakectl/cmd/fs_rm.go @@ -9,7 +9,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" "github.com/treeverse/lakefs/pkg/uri" ) @@ -56,11 +55,11 @@ var fsRmCmd = &cobra.Command{ prefix := *pathURI.Path var paramsDelimiter apigen.PaginationDelimiter = "" var from string - pfx := apigen.PaginationPrefix(prefix) + pfx := prefix for { params := &apigen.ListObjectsParams{ Prefix: &pfx, - After: apiutil.Ptr(apigen.PaginationAfter(from)), + After: &from, Delimiter: ¶msDelimiter, } resp, err := client.ListObjectsWithResponse(cmd.Context(), pathURI.Repository, pathURI.Ref, params) diff --git a/cmd/lakectl/cmd/fs_stage.go b/cmd/lakectl/cmd/fs_stage.go index 573494d6c6e..396ea1cd37c 100644 --- a/cmd/lakectl/cmd/fs_stage.go +++ b/cmd/lakectl/cmd/fs_stage.go @@ -51,7 +51,7 @@ The object location must be outside the repository's storage namespace`, resp, err := client.StageObjectWithResponse(cmd.Context(), pathURI.Repository, pathURI.Ref, &apigen.StageObjectParams{ Path: *pathURI.Path, - }, apigen.StageObjectJSONRequestBody(obj)) + }, obj) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusCreated) if resp.JSON201 == nil { Die("Bad response from server", 1) diff --git a/cmd/lakectl/cmd/local_clone.go b/cmd/lakectl/cmd/local_clone.go index b1afac88993..bc1e507e7da 100644 --- a/cmd/lakectl/cmd/local_clone.go +++ b/cmd/lakectl/cmd/local_clone.go @@ -53,8 +53,8 @@ var localCloneCmd = &cobra.Command{ var after string for { listResp, err := client.ListObjectsWithResponse(ctx, remote.Repository, stableRemote.Ref, &apigen.ListObjectsParams{ - After: (*apigen.PaginationAfter)(swag.String(after)), - Prefix: (*apigen.PaginationPrefix)(remote.Path), + After: swag.String(after), + Prefix: remote.Path, UserMetadata: swag.Bool(true), }) DieOnErrorOrUnexpectedStatusCode(listResp, err, http.StatusOK) diff --git a/cmd/lakectl/cmd/log.go b/cmd/lakectl/cmd/log.go index a40812d66f1..a891af3b91c 100644 --- a/cmd/lakectl/cmd/log.go +++ b/cmd/lakectl/cmd/log.go @@ -101,8 +101,8 @@ var logCmd = &cobra.Command{ amountForPagination = internalPageSize } logCommitsParams := &apigen.LogCommitsParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amountForPagination)), + After: &after, + Amount: &amountForPagination, Limit: &limit, FirstParent: &firstParent, StopAt: &stopAt, @@ -136,7 +136,7 @@ var logCmd = &cobra.Command{ Die("Bad response from server", 1) } pagination = resp.JSON200.Pagination - logCommitsParams.After = apiutil.Ptr(apigen.PaginationAfter(pagination.NextOffset)) + logCommitsParams.After = &pagination.NextOffset data := struct { Commits []apigen.Commit Pagination *Pagination diff --git a/cmd/lakectl/cmd/refs_restore.go b/cmd/lakectl/cmd/refs_restore.go index c4652e1169d..7b5e23c8e43 100644 --- a/cmd/lakectl/cmd/refs_restore.go +++ b/cmd/lakectl/cmd/refs_restore.go @@ -56,7 +56,7 @@ Since a bare repo is expected, in case of transient failure, delete the reposito // execute the restore operation client := getClient() ctx := cmd.Context() - resp, err := client.RestoreSubmitWithResponse(ctx, repoURI.Repository, apigen.RestoreSubmitJSONRequestBody(manifest)) + resp, err := client.RestoreSubmitWithResponse(ctx, repoURI.Repository, manifest) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusAccepted) if resp.JSON202 == nil { Die("Bad response from server", 1) diff --git a/cmd/lakectl/cmd/repo_list.go b/cmd/lakectl/cmd/repo_list.go index 0c3c61c5b05..059ac6f562d 100644 --- a/cmd/lakectl/cmd/repo_list.go +++ b/cmd/lakectl/cmd/repo_list.go @@ -6,7 +6,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var repoListCmd = &cobra.Command{ @@ -22,8 +21,8 @@ var repoListCmd = &cobra.Command{ clt := getClient() resp, err := clt.ListRepositoriesWithResponse(cmd.Context(), &apigen.ListRepositoriesParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/tag_list.go b/cmd/lakectl/cmd/tag_list.go index 5cc23da0556..45aff3ba3d9 100644 --- a/cmd/lakectl/cmd/tag_list.go +++ b/cmd/lakectl/cmd/tag_list.go @@ -5,7 +5,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" ) var tagListCmd = &cobra.Command{ @@ -23,8 +22,8 @@ var tagListCmd = &cobra.Command{ ctx := cmd.Context() client := getClient() resp, err := client.ListTagsWithResponse(ctx, u.Repository, &apigen.ListTagsParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: &amount, }) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { diff --git a/cmd/lakectl/cmd/validargs.go b/cmd/lakectl/cmd/validargs.go index ca97af30b1d..0616480415e 100644 --- a/cmd/lakectl/cmd/validargs.go +++ b/cmd/lakectl/cmd/validargs.go @@ -6,7 +6,6 @@ import ( "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" "github.com/treeverse/lakefs/pkg/uri" ) @@ -28,7 +27,7 @@ func validRepositoryToComplete(ctx context.Context, toComplete string) ([]string var prefix apigen.PaginationPrefix if strings.HasPrefix(toComplete, uriPrefix) { if !strings.Contains(toComplete[len(uriPrefix):], uri.PathSeparator) { - prefix = apigen.PaginationPrefix(toComplete[len(uriPrefix):]) + prefix = toComplete[len(uriPrefix):] } } @@ -41,7 +40,7 @@ func validRepositoryToComplete(ctx context.Context, toComplete string) ([]string for { params := &apigen.ListRepositoriesParams{ Prefix: &prefix, - After: apiutil.Ptr(apigen.PaginationAfter(after)), + After: &after, } resp, err := clt.ListRepositoriesWithResponse(ctx, params) result := resp.JSON200 diff --git a/esti/auth_test.go b/esti/auth_test.go index 8b7dd26c18d..1e7e6eb0b84 100644 --- a/esti/auth_test.go +++ b/esti/auth_test.go @@ -244,7 +244,7 @@ func mapGroupNamesToIDs(t *testing.T, ctx context.Context, groups []string) (map mapGroupNameToID := make(map[string]string) // get group list - resListGroups, err := client.ListGroupsWithResponse(ctx, &apigen.ListGroupsParams{Amount: apiutil.Ptr(apigen.PaginationAmount(-1))}) + resListGroups, err := client.ListGroupsWithResponse(ctx, &apigen.ListGroupsParams{Amount: apiutil.Ptr(-1)}) require.NoError(t, err, "unexpectedly failed while listing groups") require.Equal(t, http.StatusOK, resListGroups.StatusCode()) require.NotNil(t, resListGroups.JSON200, "unexpectedly got empty response when listing groups") diff --git a/esti/catalog_export_test.go b/esti/catalog_export_test.go index ebd93be464c..5c43f8e62ce 100644 --- a/esti/catalog_export_test.go +++ b/esti/catalog_export_test.go @@ -26,7 +26,6 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" "github.com/treeverse/lakefs/pkg/block" "github.com/treeverse/lakefs/pkg/block/azure" "github.com/treeverse/lakefs/pkg/block/params" @@ -227,7 +226,7 @@ func testSymlinkS3Exporter(t *testing.T, ctx context.Context, repo string, tmplD } lakeFSObjs, err := client.ListObjectsWithResponse(ctx, repo, commit.Id, &apigen.ListObjectsParams{ - Prefix: apiutil.Ptr(apigen.PaginationPrefix(testData.TableSpec.Path)), + Prefix: &testData.TableSpec.Path, }) require.NoError(t, err, "failed listing lakefs objects") diff --git a/esti/main_test.go b/esti/main_test.go index 1a8a108497a..5a0b7cc6981 100644 --- a/esti/main_test.go +++ b/esti/main_test.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/go-multierror" "github.com/spf13/viper" "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/api/apiutil" "github.com/treeverse/lakefs/pkg/logging" "github.com/treeverse/lakefs/pkg/testutil" ) @@ -70,7 +69,7 @@ func deleteAllRepositories(ctx context.Context, client apigen.ClientWithResponse ) for { - resp, err := client.ListRepositoriesWithResponse(ctx, &apigen.ListRepositoriesParams{After: apiutil.Ptr(apigen.PaginationAfter(nextOffset))}) + resp, err := client.ListRepositoriesWithResponse(ctx, &apigen.ListRepositoriesParams{After: &nextOffset}) if err != nil { return fmt.Errorf("list repositories: %w", err) } @@ -108,7 +107,7 @@ func deleteAllGroups(ctx context.Context, client apigen.ClientWithResponsesInter nextOffset string ) for { - resp, err := client.ListGroupsWithResponse(ctx, &apigen.ListGroupsParams{After: apiutil.Ptr(apigen.PaginationAfter(nextOffset))}) + resp, err := client.ListGroupsWithResponse(ctx, &apigen.ListGroupsParams{After: &nextOffset}) if err != nil { return fmt.Errorf("list groups: %w", err) } @@ -146,7 +145,7 @@ func deleteAllUsers(ctx context.Context, client apigen.ClientWithResponsesInterf nextOffset string ) for { - resp, err := client.ListUsersWithResponse(ctx, &apigen.ListUsersParams{After: apiutil.Ptr(apigen.PaginationAfter(nextOffset))}) + resp, err := client.ListUsersWithResponse(ctx, &apigen.ListUsersParams{After: &nextOffset}) if err != nil { return fmt.Errorf("list users: %s", err) } @@ -184,7 +183,7 @@ func deleteAllPolicies(ctx context.Context, client apigen.ClientWithResponsesInt nextOffset string ) for { - resp, err := client.ListPoliciesWithResponse(ctx, &apigen.ListPoliciesParams{After: apiutil.Ptr(apigen.PaginationAfter(nextOffset))}) + resp, err := client.ListPoliciesWithResponse(ctx, &apigen.ListPoliciesParams{After: &nextOffset}) if err != nil { return fmt.Errorf("list policies: %w", err) } diff --git a/esti/merge_test.go b/esti/merge_test.go index 0d43d6f413e..c72431cccb4 100644 --- a/esti/merge_test.go +++ b/esti/merge_test.go @@ -81,7 +81,7 @@ func doMergeAndListIteration(t *testing.T, logger logging.Logger, ctx context.Co require.True(t, ok) require.Equal(t, strategy, val) - resp, err := client.ListObjectsWithResponse(ctx, repo, mainBranch, &apigen.ListObjectsParams{Amount: apiutil.Ptr(apigen.PaginationAmount(100))}) + resp, err := client.ListObjectsWithResponse(ctx, repo, mainBranch, &apigen.ListObjectsParams{Amount: apiutil.Ptr(100)}) require.NoError(t, err, "failed to list objects") require.Equal(t, http.StatusOK, resp.StatusCode()) payload := resp.JSON200 diff --git a/esti/sanity_api_test.go b/esti/sanity_api_test.go index d88071ace4e..ff8b93da4c5 100644 --- a/esti/sanity_api_test.go +++ b/esti/sanity_api_test.go @@ -122,7 +122,7 @@ func TestSanityAPI(t *testing.T) { log.Debug("branch1 - diff changes with main") diffResp, err = client.DiffRefsWithResponse(ctx, repo, mainBranch, "branch1", &apigen.DiffRefsParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(-1)), + Amount: apiutil.Ptr(-1), }) require.NoError(t, err, "diff between branch1 and main") require.Equal(t, http.StatusOK, diffResp.StatusCode()) diff --git a/esti/system_test.go b/esti/system_test.go index 48e8ed900e1..a2d665ffb8c 100644 --- a/esti/system_test.go +++ b/esti/system_test.go @@ -278,8 +278,8 @@ func listRepositoryObjects(ctx context.Context, t *testing.T, repository string, var after string for { resp, err := client.ListObjectsWithResponse(ctx, repository, ref, &apigen.ListObjectsParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(amount)), + After: &after, + Amount: apiutil.Ptr(amount), }) require.NoError(t, err, "listing objects") require.NoErrorf(t, verifyResponse(resp.HTTPResponse, resp.Body), @@ -309,8 +309,8 @@ func listRepositories(t *testing.T, ctx context.Context) []apigen.Repository { var listedRepos []apigen.Repository for { resp, err := client.ListRepositoriesWithResponse(ctx, &apigen.ListRepositoriesParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(repoPerPage)), + After: &after, + Amount: apiutil.Ptr(repoPerPage), }) require.NoError(t, err, "list repositories") require.NoErrorf(t, verifyResponse(resp.HTTPResponse, resp.Body), diff --git a/pkg/api/controller.go b/pkg/api/controller.go index 48dcaeb9cfa..5719ce35b9f 100644 --- a/pkg/api/controller.go +++ b/pkg/api/controller.go @@ -719,7 +719,7 @@ func (c *Controller) LinkPhysicalAddress(w http.ResponseWriter, r *http.Request, ifAbsent := false if params.IfNoneMatch != nil { - if swag.StringValue((*string)(params.IfNoneMatch)) != "*" { + if *params.IfNoneMatch != "*" { writeError(w, r, http.StatusBadRequest, "Unsupported value for If-None-Match - Only \"*\" is supported") return } @@ -2867,15 +2867,18 @@ func importStatusToResponse(status *graveler.ImportStatus) apigen.ImportStatus { } commitLog := catalog.CommitRecordToLog(status.Commit) - metadata := map[string]string(commitLog.Metadata) if commitLog != nil { + stringMetadata := make(map[string]string, len(commitLog.Metadata)) + for k, v := range commitLog.Metadata { + stringMetadata[k] = v + } resp.Commit = &apigen.Commit{ Committer: commitLog.Committer, CreationDate: commitLog.CreationDate.Unix(), Id: commitLog.Reference, Message: commitLog.Message, MetaRangeId: commitLog.MetaRangeID, - Metadata: &metadata, + Metadata: &stringMetadata, Parents: commitLog.Parents, Version: apiutil.Ptr(int(commitLog.Version)), Generation: apiutil.Ptr(int64(commitLog.Generation)), @@ -3105,7 +3108,7 @@ func (c *Controller) UploadObject(w http.ResponseWriter, r *http.Request, reposi // and then graveler will check again when passed a SetOptions. allowOverwrite := true if params.IfNoneMatch != nil { - if swag.StringValue((*string)(params.IfNoneMatch)) != "*" { + if *params.IfNoneMatch != "*" { writeError(w, r, http.StatusBadRequest, "Unsupported value for If-None-Match - Only \"*\" is supported") return } @@ -3509,7 +3512,7 @@ func (c *Controller) SetGarbageCollectionRulesPreflight(w http.ResponseWriter, r } func (c *Controller) InternalSetGarbageCollectionRules(w http.ResponseWriter, r *http.Request, body apigen.InternalSetGarbageCollectionRulesJSONRequestBody, repository string) { - c.SetGCRules(w, r, apigen.SetGCRulesJSONRequestBody(body), repository) + c.SetGCRules(w, r, body, repository) } func (c *Controller) InternalDeleteGarbageCollectionRules(w http.ResponseWriter, r *http.Request, repository string) { @@ -5065,28 +5068,28 @@ func paginationAfter(v *apigen.PaginationAfter) string { if v == nil { return "" } - return string(*v) + return *v } func paginationPrefix(v *apigen.PaginationPrefix) string { if v == nil { return "" } - return string(*v) + return *v } func paginationDelimiter(v *apigen.PaginationDelimiter) string { if v == nil { return "" } - return string(*v) + return *v } func paginationAmount(v *apigen.PaginationAmount) int { if v == nil { return DefaultPerPage } - i := int(*v) + i := *v if i > DefaultMaxPerPage { return DefaultMaxPerPage } diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index aef095a9c48..3624afe0c0f 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -122,7 +122,7 @@ func TestController_ListRepositoriesHandler(t *testing.T) { t.Run("paginate repos", func(t *testing.T) { // write some repos resp, err := clt.ListRepositoriesWithResponse(ctx, &apigen.ListRepositoriesParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(2)), + Amount: apiutil.Ptr(2), }) if err != nil { t.Fatal(err) @@ -508,10 +508,10 @@ func TestController_LogCommitsPredefinedData(t *testing.T) { } if tt.limit { params.Limit = &tt.limit - params.Amount = apiutil.Ptr(apigen.PaginationAmount(1)) + params.Amount = apiutil.Ptr(1) } if tt.amount > 0 { - params.Amount = apiutil.Ptr(apigen.PaginationAmount(tt.amount)) + params.Amount = &tt.amount } if tt.stopAt != "" { params.StopAt = &tt.stopAt @@ -1533,7 +1533,7 @@ func TestController_ListBranchesHandler(t *testing.T) { _, err := deps.catalog.CreateRepository(ctx, repo, onBlock(deps, "foo1"), "main", false) testutil.Must(t, err) resp, err := clt.ListBranchesWithResponse(ctx, repo, &apigen.ListBranchesParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(-1)), + Amount: apiutil.Ptr(-1), }) verifyResponseOK(t, resp, err) @@ -1561,7 +1561,7 @@ func TestController_ListBranchesHandler(t *testing.T) { testutil.MustDo(t, "create branch "+branchName, err) } resp, err := clt.ListBranchesWithResponse(ctx, repo, &apigen.ListBranchesParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(2)), + Amount: apiutil.Ptr(2), }) verifyResponseOK(t, resp, err) if len(resp.JSON200.Results) != 2 { @@ -1586,7 +1586,7 @@ func TestController_ListBranchesHandler(t *testing.T) { t.Run("list branches repo doesnt exist", func(t *testing.T) { resp, err := clt.ListBranchesWithResponse(ctx, "repo666", &apigen.ListBranchesParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(2)), + Amount: apiutil.Ptr(2), }) testutil.Must(t, err) if resp == nil { @@ -1627,7 +1627,7 @@ func TestController_ListTagsHandler(t *testing.T) { t.Run("default", func(t *testing.T) { resp, err := clt.ListTagsWithResponse(ctx, repo, &apigen.ListTagsParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(-1)), + Amount: apiutil.Ptr(-1), }) verifyResponseOK(t, resp, err) payload := resp.JSON200 @@ -1648,8 +1648,8 @@ func TestController_ListTagsHandler(t *testing.T) { for { calls++ resp, err := clt.ListTagsWithResponse(ctx, repo, &apigen.ListTagsParams{ - After: apiutil.Ptr(apigen.PaginationAfter(after)), - Amount: apiutil.Ptr(apigen.PaginationAmount(pageSize)), + After: &after, + Amount: apiutil.Ptr(pageSize), }) testutil.Must(t, err) payload := resp.JSON200 @@ -2445,7 +2445,7 @@ func TestController_ObjectsListObjectsHandler(t *testing.T) { prefix := apigen.PaginationPrefix("foo/") resp, err := clt.ListObjectsWithResponse(ctx, repo, "main", &apigen.ListObjectsParams{ Prefix: &prefix, - Amount: apiutil.Ptr(apigen.PaginationAmount(2)), + Amount: apiutil.Ptr(2), }) verifyResponseOK(t, resp, err) if len(resp.JSON200.Results) != 2 { @@ -3801,7 +3801,7 @@ func TestController_ListRepositoryRuns(t *testing.T) { t.Run("total", func(t *testing.T) { respList, err := clt.ListRepositoryRunsWithResponse(ctx, repo, &apigen.ListRepositoryRunsParams{ - Amount: apiutil.Ptr(apigen.PaginationAmount(100)), + Amount: apiutil.Ptr(100), }) verifyResponseOK(t, respList, err) runsCount := len(respList.JSON200.Results) @@ -3813,7 +3813,7 @@ func TestController_ListRepositoryRuns(t *testing.T) { t.Run("on branch", func(t *testing.T) { respList, err := clt.ListRepositoryRunsWithResponse(ctx, repo, &apigen.ListRepositoryRunsParams{ Branch: apiutil.Ptr("work"), - Amount: apiutil.Ptr(apigen.PaginationAmount(100)), + Amount: apiutil.Ptr(100), }) verifyResponseOK(t, respList, err) runsCount := len(respList.JSON200.Results) @@ -3826,7 +3826,7 @@ func TestController_ListRepositoryRuns(t *testing.T) { respList, err := clt.ListRepositoryRunsWithResponse(ctx, repo, &apigen.ListRepositoryRunsParams{ Branch: apiutil.Ptr("someBranch"), Commit: apiutil.Ptr("someCommit"), - Amount: apiutil.Ptr(apigen.PaginationAmount(100)), + Amount: apiutil.Ptr(100), }) require.NoError(t, err) require.NotNil(t, respList) @@ -3840,7 +3840,7 @@ func TestController_ListRepositoryRuns(t *testing.T) { respList, err := clt.ListRepositoryRunsWithResponse(ctx, repo, &apigen.ListRepositoryRunsParams{ Branch: apiutil.Ptr("work"), - Amount: apiutil.Ptr(apigen.PaginationAmount(100)), + Amount: apiutil.Ptr(100), }) verifyResponseOK(t, respList, err) runsCount := len(respList.JSON200.Results) diff --git a/pkg/auth/service.go b/pkg/auth/service.go index a1f3cb4e021..4eb76e9b34e 100644 --- a/pkg/auth/service.go +++ b/pkg/auth/service.go @@ -1341,13 +1341,10 @@ func toPagination(paginator Pagination) *model.Paginator { } func (a *APIAuthService) ListUsers(ctx context.Context, params *model.PaginationParams) ([]*model.User, *model.Paginator, error) { - paginationPrefix := PaginationPrefix(params.Prefix) - paginationAfter := PaginationAfter(params.After) - paginationAmount := PaginationAmount(params.Amount) resp, err := a.apiClient.ListUsersWithResponse(ctx, &ListUsersParams{ - Prefix: &paginationPrefix, - After: &paginationAfter, - Amount: &paginationAmount, + Prefix: ¶ms.Prefix, + After: ¶ms.After, + Amount: ¶ms.Amount, }) if err != nil { a.logger.WithError(err).Error("failed to list users") @@ -1423,18 +1420,15 @@ func (a *APIAuthService) validateResponse(resp openapi3filter.StatusCoder, expec } func paginationPrefix(prefix string) *PaginationPrefix { - p := PaginationPrefix(prefix) - return &p + return &prefix } func paginationAfter(after string) *PaginationAfter { - p := PaginationAfter(after) - return &p + return &after } func paginationAmount(amount int) *PaginationAmount { - p := PaginationAmount(amount) - return &p + return &amount } func (a *APIAuthService) DeleteGroup(ctx context.Context, groupID string) error { diff --git a/pkg/diff/diff.go b/pkg/diff/diff.go index 67473f554f1..7ac215f6284 100644 --- a/pkg/diff/diff.go +++ b/pkg/diff/diff.go @@ -5,7 +5,6 @@ import ( "fmt" "net/http" - "github.com/go-openapi/swag" "github.com/jedib0t/go-pretty/v6/text" "github.com/treeverse/lakefs/pkg/api/apigen" "github.com/treeverse/lakefs/pkg/api/apiutil" @@ -29,8 +28,8 @@ func StreamRepositoryDiffs(ctx context.Context, client apigen.ClientWithResponse var after string for hasMore { diffResp, err := client.DiffRefsWithResponse(ctx, left.Repository, left.Ref, right.Ref, &apigen.DiffRefsParams{ - After: (*apigen.PaginationAfter)(swag.String(after)), - Prefix: (*apigen.PaginationPrefix)(&prefix), + After: &after, + Prefix: &prefix, Type: diffType, }) if err != nil { diff --git a/pkg/local/diff.go b/pkg/local/diff.go index 8da7d5cf722..acf7892b149 100644 --- a/pkg/local/diff.go +++ b/pkg/local/diff.go @@ -276,8 +276,8 @@ func ListRemote(ctx context.Context, client apigen.ClientWithResponsesInterface, for hasMore { listResp, err := client.ListObjectsWithResponse(ctx, loc.Repository, loc.Ref, &apigen.ListObjectsParams{ - After: (*apigen.PaginationAfter)(swag.String(after)), - Prefix: (*apigen.PaginationPrefix)(loc.Path), + After: &after, + Prefix: loc.Path, UserMetadata: swag.Bool(true), }) if err != nil { From 9ebd11895d90dae79f1776f56b245603275a3c62 Mon Sep 17 00:00:00 2001 From: "Ariel Shaqed (Scolnicov)" Date: Thu, 11 Apr 2024 16:48:27 +0300 Subject: [PATCH 12/12] Fix some tests: types are different, apiutil needed for *map[K]V. --- esti/catalog_export_test.go | 10 +++++----- esti/hooks_test.go | 3 ++- esti/import_test.go | 1 + pkg/api/apiutil/util.go | 7 +++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/esti/catalog_export_test.go b/esti/catalog_export_test.go index 5c43f8e62ce..c294aa68706 100644 --- a/esti/catalog_export_test.go +++ b/esti/catalog_export_test.go @@ -163,7 +163,7 @@ func testSymlinkS3Exporter(t *testing.T, ctx context.Context, repo string, tmplD // wait until actions finish running runs := waitForListRepositoryRunsLen(ctx, t, repo, commit.Id, 1) - require.Equal(t, "completed", runs.Results[0].Status, "symlink action result not finished") + require.Equal(t, "completed", string(runs.Results[0].Status), "symlink action result not finished") // list symlink.txt files from blockstore @@ -327,7 +327,7 @@ func TestAWSCatalogExport(t *testing.T) { // wait for action to finish runs := waitForListRepositoryRunsLen(ctx, t, repo, headCommit.Id, 1) - require.Equal(t, "completed", runs.Results[0].Status, "glue action result not finished") + require.Equal(t, "completed", string(runs.Results[0].Status), "glue action result not finished") // create glue client @@ -514,7 +514,7 @@ func TestDeltaCatalogExport(t *testing.T) { runs := waitForListRepositoryRunsLen(ctx, t, repo, headCommit.Id, 1) run := runs.Results[0] - require.Equal(t, "completed", run.Status) + require.Equal(t, "completed", string(run.Status)) amount := apigen.PaginationAmount(1) tasks, err := client.ListRunHooksWithResponse(ctx, repo, run.RunId, &apigen.ListRunHooksParams{ @@ -564,7 +564,7 @@ func TestDeltaCatalogImportExport(t *testing.T) { runs := waitForListRepositoryRunsLen(ctx, t, repo, headCommit.Id, 1) run := runs.Results[0] - require.Equal(t, "completed", run.Status) + require.Equal(t, "completed", string(run.Status)) amount := apigen.PaginationAmount(1) tasks, err := client.ListRunHooksWithResponse(ctx, repo, run.RunId, &apigen.ListRunHooksParams{ @@ -656,7 +656,7 @@ func TestDeltaCatalogExportAbfss(t *testing.T) { runs := waitForListRepositoryRunsLen(ctx, t, repo, headCommit.Id, 1) run := runs.Results[0] - require.Equal(t, "completed", run.Status) + require.Equal(t, "completed", string(run.Status)) amount := apigen.PaginationAmount(1) tasks, err := client.ListRunHooksWithResponse(ctx, repo, run.RunId, &apigen.ListRunHooksParams{ diff --git a/esti/hooks_test.go b/esti/hooks_test.go index 5de39d7213a..9dc55e5965c 100644 --- a/esti/hooks_test.go +++ b/esti/hooks_test.go @@ -141,7 +141,8 @@ func testCommitMerge(t *testing.T, ctx context.Context, repo string) { BranchID: branch, Committer: commitRecord.Committer, CommitMessage: commitRecord.Message, - Metadata: *commitRecord.Metadata, + + Metadata: apiutil.MapValue(*commitRecord.Metadata), }, preCommitEvent) require.NotNil(t, webhookData.queryParams) require.Contains(t, webhookData.queryParams, "check_env_vars") diff --git a/esti/import_test.go b/esti/import_test.go index 23329b6e6c4..dc632f98aec 100644 --- a/esti/import_test.go +++ b/esti/import_test.go @@ -288,6 +288,7 @@ func testImportNew(t testing.TB, ctx context.Context, repoName, importBranch str require.NotNil(t, statusResp.JSON200, "failed to get import status", err) status := statusResp.JSON200 require.Nil(t, status.Error, "import failed", err) + t.Logf("Update time %s, got %s", updateTime, status.UpdateTime) require.NotEqual(t, updateTime, status.UpdateTime) updateTime = status.UpdateTime t.Log("Import progress:", *status.IngestedObjects, importID) diff --git a/pkg/api/apiutil/util.go b/pkg/api/apiutil/util.go index b929bdcdf15..5b0655fd417 100644 --- a/pkg/api/apiutil/util.go +++ b/pkg/api/apiutil/util.go @@ -11,6 +11,13 @@ func Value[T any](ptr *T) T { return *ptr } +func MapValue[K comparable, V any](m *map[K]V) map[K]V { + if m == nil { + return make(map[K]V) + } + return *m +} + func Ptr[T any](val T) *T { return &val }