diff --git a/go.mod b/go.mod index eedd4cd0..a8bdc99b 100644 --- a/go.mod +++ b/go.mod @@ -3,18 +3,18 @@ module github.com/whosonfirst/go-whosonfirst-findingaid go 1.16 require ( - github.com/aaronland/go-http-server v0.0.6 + github.com/aaronland/go-http-server v0.0.7 github.com/aaronland/go-roster v0.0.2 - github.com/aaronland/gocloud-blob-s3 v0.1.0 + github.com/aaronland/gocloud-blob-s3 v0.1.3 github.com/jtacoma/uritemplates v1.0.0 - github.com/rs/cors v1.7.0 + github.com/rs/cors v1.8.0 github.com/sfomuseum/go-flags v0.8.2 - github.com/tidwall/gjson v1.8.0 + github.com/tidwall/gjson v1.8.1 github.com/tidwall/sjson v1.1.7 github.com/whosonfirst/go-cache v0.5.0 github.com/whosonfirst/go-cache-blob v0.2.0 github.com/whosonfirst/go-ioutil v1.0.0 github.com/whosonfirst/go-whosonfirst-iterate v1.2.0 - github.com/whosonfirst/go-whosonfirst-uri v1.0.1 + github.com/whosonfirst/go-whosonfirst-uri v1.1.0 gocloud.dev v0.23.0 ) diff --git a/go.sum b/go.sum index b67cbe97..501c97a8 100644 --- a/go.sum +++ b/go.sum @@ -84,6 +84,8 @@ github.com/aaronland/go-http-server v0.0.5 h1:DxQKt2tcoq27gjqMJ9/wKyTu0briY9lPuK github.com/aaronland/go-http-server v0.0.5/go.mod h1:6dtsZDrQG0XvUOCL0eaHsUw+7gw3Xa/Nm+XofvkSw2w= github.com/aaronland/go-http-server v0.0.6 h1:KR6zm17QB+Mal0kpn/7vZHzj18W2O5ytGKIF7D1cN/4= github.com/aaronland/go-http-server v0.0.6/go.mod h1:6dtsZDrQG0XvUOCL0eaHsUw+7gw3Xa/Nm+XofvkSw2w= +github.com/aaronland/go-http-server v0.0.7 h1:hKY2e/WLkUhaeEx4KZW2iRcBfsSZqAV/wfLLRQcrECM= +github.com/aaronland/go-http-server v0.0.7/go.mod h1:6dtsZDrQG0XvUOCL0eaHsUw+7gw3Xa/Nm+XofvkSw2w= github.com/aaronland/go-json-query v0.0.2 h1:cKw/DnxtGaPsClb78ONgmXPOJkqHhaBMU2RTBbPoXos= github.com/aaronland/go-json-query v0.0.2/go.mod h1:dGc7y824R93ugQMTldL7PFD/SPVGPwKdqrUJFLE/ILU= github.com/aaronland/go-json-query v0.1.0 h1:ZHtbpW8jiGYuOXKDEscWDrDjyVXZhU9Qqfi3nkyI9Ho= @@ -96,6 +98,8 @@ github.com/aaronland/go-string v0.1.2 h1:RSr/mQNbLgF37H0RV+nF7j2kILRRFkCmr8Jwq4l github.com/aaronland/go-string v0.1.2/go.mod h1:2aMIWdTqk63jZsaLLy+p9dsB1MDRqx4sHYoLtkwyYUo= github.com/aaronland/gocloud-blob-s3 v0.1.0 h1:pytPBr+ypLDZYqTjoVbdf4cPmlEYQ03LW8NkjsynruM= github.com/aaronland/gocloud-blob-s3 v0.1.0/go.mod h1:lp5o6UdndyGn0M+oIZEG98eip+T71vL+U8P8WQUe0UE= +github.com/aaronland/gocloud-blob-s3 v0.1.3 h1:cCRS07X7o+KqjNlF5kZ6YW6x9+ew+TuirTgPNw89AuU= +github.com/aaronland/gocloud-blob-s3 v0.1.3/go.mod h1:lp5o6UdndyGn0M+oIZEG98eip+T71vL+U8P8WQUe0UE= github.com/akrylysov/algnhsa v0.0.0-20190319020909-05b3d192e9a7/go.mod h1:HhzjNA0EjUWcwHTUMwqrpeAdIF3gRmpH0HpWx1hYJSc= github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= @@ -141,6 +145,7 @@ github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoD github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -149,7 +154,9 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2 github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-ini/ini v1.42.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= @@ -250,6 +257,7 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= @@ -265,10 +273,12 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.1/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mattn/go-ieproxy v0.0.1/go.mod h1:pYabZ6IHcRpFh7vIaLfK7rdcWgFEb3SFJ6/gNWuh88E= +github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= @@ -290,6 +300,8 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so= +github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sfomuseum/go-flags v0.4.2 h1:sDSvp0c4QZKf3pNUcpfIwshAu9U6sjsNEopmPfC329U= @@ -314,6 +326,8 @@ github.com/tidwall/gjson v1.6.1/go.mod h1:BaHyNc5bjzYkPqgLq7mdVzeiRtULKULXLgZFKs github.com/tidwall/gjson v1.7.5/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk= github.com/tidwall/gjson v1.8.0 h1:Qt+orfosKn0rbNTZqHYDqBrmm3UDA4KRkv70fDzG+PQ= github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk= +github.com/tidwall/gjson v1.8.1 h1:8j5EE9Hrh3l9Od1OIEDAb7IpezNA20UdRngNAj5N0WU= +github.com/tidwall/gjson v1.8.1/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk= github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc= github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= github.com/tidwall/match v1.0.3 h1:FQUVvBImDutD8wJLN6c5eMzWtjgONK9MwIBCOrUJKeE= @@ -401,6 +415,8 @@ github.com/whosonfirst/go-whosonfirst-uri v0.2.0 h1:iODHdyvW+8IXqHZTixZ/9GEZy1dV github.com/whosonfirst/go-whosonfirst-uri v0.2.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= github.com/whosonfirst/go-whosonfirst-uri v1.0.1 h1:hVEDRuW9WhqvTksDi092OO9UecX7PAMDrD47KPEqAg0= github.com/whosonfirst/go-whosonfirst-uri v1.0.1/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= +github.com/whosonfirst/go-whosonfirst-uri v1.1.0 h1:kNYOmKSm3u2asUOeq7yXL1Q8gFKkPIl8A0qinKrGV/8= +github.com/whosonfirst/go-whosonfirst-uri v1.1.0/go.mod h1:8eaDVcc4v+HHHEDaRbApdmhPwM4/JQllw2PktvZcPVs= github.com/whosonfirst/walk v0.0.0-20160802000000-c0a349674b73681a7272f5ce6ade8ea28055059f/go.mod h1:U/1VXxlMzNZbyylg18AzEeHkGi1RXiBCMKpaM2XR+tQ= github.com/whosonfirst/walk v0.0.0-20160803014805-c0a349674b73 h1:/43peH8y6Wg+dAgQ97swaPN8c3/M6hi8lawr1vDblzs= github.com/whosonfirst/walk v0.0.0-20160803014805-c0a349674b73/go.mod h1:U/1VXxlMzNZbyylg18AzEeHkGi1RXiBCMKpaM2XR+tQ= @@ -553,6 +569,7 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -785,6 +802,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg= gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98= diff --git a/vendor/github.com/aaronland/go-http-server/http.go b/vendor/github.com/aaronland/go-http-server/http.go index ed633ba3..cc42b176 100644 --- a/vendor/github.com/aaronland/go-http-server/http.go +++ b/vendor/github.com/aaronland/go-http-server/http.go @@ -146,7 +146,7 @@ func (s *HTTPServer) Address() string { return u.String() } -func (s *HTTPServer) ListenAndServe(ctx context.Context, mux *http.ServeMux) error { +func (s *HTTPServer) ListenAndServe(ctx context.Context, mux http.Handler) error { idleConnsClosed := make(chan struct{}) diff --git a/vendor/github.com/aaronland/go-http-server/lambda.go b/vendor/github.com/aaronland/go-http-server/lambda.go index 3f09c267..2e842ead 100644 --- a/vendor/github.com/aaronland/go-http-server/lambda.go +++ b/vendor/github.com/aaronland/go-http-server/lambda.go @@ -46,7 +46,7 @@ func (s *LambdaServer) Address() string { return s.url.String() } -func (s *LambdaServer) ListenAndServe(ctx context.Context, mux *http.ServeMux) error { +func (s *LambdaServer) ListenAndServe(ctx context.Context, mux http.Handler) error { lambda_opts := new(algnhsa.Options) diff --git a/vendor/github.com/aaronland/go-http-server/server.go b/vendor/github.com/aaronland/go-http-server/server.go index d378cce2..2a5717ee 100644 --- a/vendor/github.com/aaronland/go-http-server/server.go +++ b/vendor/github.com/aaronland/go-http-server/server.go @@ -10,7 +10,7 @@ import ( ) type Server interface { - ListenAndServe(context.Context, *http.ServeMux) error + ListenAndServe(context.Context, http.Handler) error Address() string } diff --git a/vendor/github.com/aaronland/gocloud-blob-s3/acl.go b/vendor/github.com/aaronland/gocloud-blob-s3/acl.go index 44162bd0..732e3d76 100644 --- a/vendor/github.com/aaronland/gocloud-blob-s3/acl.go +++ b/vendor/github.com/aaronland/gocloud-blob-s3/acl.go @@ -2,33 +2,13 @@ package s3blob import ( "context" - "fmt" - "gocloud.dev/blob" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/s3/s3manager" ) // SetACLWriterOptionsWithContext return a new context.Context instance with a gocloud.dev/blob.WriterOptions // instance used to assign 'acl' permissions for all S3 blob writes. The WriterOptions instance is assigned // to the new context with key 'key' and is assumed to be retrieved later by code using blob.NewWriter instances. +// This method is DEPRECATED. Please use SetWriterOptionsWithContext() instead. func SetACLWriterOptionsWithContext(ctx context.Context, key interface{}, acl string) context.Context { - - before := func(asFunc func(interface{}) bool) error { - - req := &s3manager.UploadInput{} - ok := asFunc(&req) - - if !ok { - return fmt.Errorf("invalid s3 type") - } - - req.ACL = aws.String(acl) - return nil - } - - wr_opts := &blob.WriterOptions{ - BeforeWrite: before, - } - - return context.WithValue(ctx, key, wr_opts) + ctx, _ = SetWriterOptionsWithContext(ctx, key, "ACL", acl) + return ctx } diff --git a/vendor/github.com/aaronland/gocloud-blob-s3/options.go b/vendor/github.com/aaronland/gocloud-blob-s3/options.go new file mode 100644 index 00000000..d0bcd21e --- /dev/null +++ b/vendor/github.com/aaronland/gocloud-blob-s3/options.go @@ -0,0 +1,150 @@ +package s3blob + +import ( + "context" + "fmt" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/s3/s3manager" + "gocloud.dev/blob" +) + +type AsFunc func(func(interface{}) bool) error + +// SetACLWriterOptionsWithContext return a new context.Context instance with a gocloud.dev/blob.WriterOptions +// instance whose properties are assigned according to 'opt_key' and 'opt_value', where the latter is a valid +// blob.WriterOptions property and the former is a valid type for that property. The one special-case is the +// "ACL" opt_key which which takes a opt_value of type type string and will assign a suitable GoCloud BeforeWrite +// option for assigning AWS S3 ACL permissions. +// +// The WriterOptions instance is assigned to the new context with key 'ctx_key' and is assumed to be retrieved later +// by code using blob.NewWriter instances. +func SetWriterOptionsWithContext(ctx context.Context, ctx_key interface{}, opt_key string, opt_value interface{}) (context.Context, error) { + + var wr_opts *blob.WriterOptions + + v := ctx.Value(ctx_key) + + if v == nil { + wr_opts = &blob.WriterOptions{} + } else { + wr_opts = v.(*blob.WriterOptions) + } + + switch opt_key { + case "BufferSize": + + switch opt_value.(type) { + case int: + // pass + default: + return nil, fmt.Errorf("Invalid type for '%s' value", opt_key) + } + + wr_opts.BufferSize = opt_value.(int) + + case "CacheControl", "ContentDisposition", "ContentEncoding", "ContentType", "ContentLanguage": + + switch opt_value.(type) { + case string: + // pass + default: + return nil, fmt.Errorf("Invalid type for '%s' value", opt_key) + } + + switch opt_key { + case "CacheControl": + wr_opts.CacheControl = opt_value.(string) + case "ContentDisposition": + wr_opts.ContentDisposition = opt_value.(string) + case "ContentEncoding": + wr_opts.ContentEncoding = opt_value.(string) + case "ContentType": + wr_opts.ContentType = opt_value.(string) + case "ContentLanguage": + wr_opts.ContentLanguage = opt_value.(string) + } + + case "ContentMD5": + + switch opt_value.(type) { + case string: + // pass + default: + return nil, fmt.Errorf("Invalid type for '%s' value", opt_key) + } + + wr_opts.ContentMD5 = opt_value.([]byte) + + case "Metadata": + + switch opt_value.(type) { + case map[string]string: + // pass + default: + return nil, fmt.Errorf("Invalid type for '%s' value", opt_key) + } + + wr_opts.Metadata = opt_value.(map[string]string) + + case "BeforeWrite": + + switch opt_value.(type) { + case AsFunc: + // pass + default: + return nil, fmt.Errorf("Invalid type for '%s' value", opt_key) + } + + wr_opts.BeforeWrite = opt_value.(AsFunc) + + case "ACL": + + switch opt_value.(type) { + case string: + // pass + default: + return nil, fmt.Errorf("Invalid type for '%s' value", opt_key) + } + + acl := opt_value.(string) + + before := func(asFunc func(interface{}) bool) error { + + req := &s3manager.UploadInput{} + ok := asFunc(&req) + + if !ok { + return fmt.Errorf("invalid s3 type") + } + + req.ACL = aws.String(acl) + return nil + } + + wr_opts.BeforeWrite = before + + default: + return nil, fmt.Errorf("Invalid or unsupported key '%s'", opt_key) + } + + ctx = context.WithValue(ctx, ctx_key, wr_opts) + return ctx, nil +} + +// SetWriterOptionsWithContextAndMap is a convenience method for invoking SetWriterOptionsWithContext +// multiple times. +func SetWriterOptionsWithContextAndMap(ctx context.Context, ctx_key interface{}, opts map[string]interface{}) (context.Context, error) { + + var err error + + for k, v := range opts { + + ctx, err = SetWriterOptionsWithContext(ctx, ctx_key, k, v) + + if err != nil { + return nil, fmt.Errorf("Failed to set writer options for '%s', %v", k, v) + } + } + + return ctx, nil +} diff --git a/vendor/github.com/rs/cors/.travis.yml b/vendor/github.com/rs/cors/.travis.yml index 9a68b567..f59a345f 100644 --- a/vendor/github.com/rs/cors/.travis.yml +++ b/vendor/github.com/rs/cors/.travis.yml @@ -1,8 +1,6 @@ language: go go: -- "1.10" -- "1.11" -- "1.12" +- "1.13" - tip matrix: allow_failures: diff --git a/vendor/github.com/rs/cors/cors.go b/vendor/github.com/rs/cors/cors.go index 27309346..41d5f7cb 100644 --- a/vendor/github.com/rs/cors/cors.go +++ b/vendor/github.com/rs/cors/cors.go @@ -41,7 +41,7 @@ type Options struct { // as argument and returns true if allowed or false otherwise. If this option is // set, the content of AllowedOrigins is ignored. AllowOriginFunc func(origin string) bool - // AllowOriginFunc is a custom function to validate the origin. It takes the HTTP Request object and the origin as + // AllowOriginRequestFunc is a custom function to validate the origin. It takes the HTTP Request object and the origin as // argument and returns true if allowed or false otherwise. If this option is set, the content of `AllowedOrigins` // and `AllowOriginFunc` is ignored. AllowOriginRequestFunc func(r *http.Request, origin string) bool @@ -211,7 +211,7 @@ func (c *Cors) Handler(h http.Handler) http.Handler { if c.optionPassthrough { h.ServeHTTP(w, r) } else { - w.WriteHeader(http.StatusOK) + w.WriteHeader(http.StatusNoContent) } } else { c.logf("Handler: Actual request") @@ -244,7 +244,7 @@ func (c *Cors) ServeHTTP(w http.ResponseWriter, r *http.Request, next http.Handl if c.optionPassthrough { next(w, r) } else { - w.WriteHeader(http.StatusOK) + w.WriteHeader(http.StatusNoContent) } } else { c.logf("ServeHTTP: Actual request") @@ -357,6 +357,12 @@ func (c *Cors) logf(format string, a ...interface{}) { } } +// check the Origin of a request. No origin at all is also allowed. +func (c *Cors) OriginAllowed(r *http.Request) bool { + origin := r.Header.Get("Origin") + return c.isOriginAllowed(r, origin) +} + // isOriginAllowed checks if a given origin is allowed to perform cross-domain requests // on the endpoint func (c *Cors) isOriginAllowed(r *http.Request, origin string) bool { @@ -384,7 +390,7 @@ func (c *Cors) isOriginAllowed(r *http.Request, origin string) bool { } // isMethodAllowed checks if a given method can be used as part of a cross-domain request -// on the endpoing +// on the endpoint func (c *Cors) isMethodAllowed(method string) bool { if len(c.allowedMethods) == 0 { // If no method allowed, always return false, even for preflight request @@ -415,6 +421,7 @@ func (c *Cors) areHeadersAllowed(requestedHeaders []string) bool { for _, h := range c.allowedHeaders { if h == header { found = true + break } } if !found { diff --git a/vendor/github.com/rs/cors/go.mod b/vendor/github.com/rs/cors/go.mod index 0a4c6521..94d050c6 100644 --- a/vendor/github.com/rs/cors/go.mod +++ b/vendor/github.com/rs/cors/go.mod @@ -1 +1,7 @@ module github.com/rs/cors + +go 1.13 + +require ( + github.com/gin-gonic/gin v1.5.0 +) diff --git a/vendor/github.com/rs/cors/go.sum b/vendor/github.com/rs/cors/go.sum new file mode 100644 index 00000000..2f8cfa77 --- /dev/null +++ b/vendor/github.com/rs/cors/go.sum @@ -0,0 +1,25 @@ +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.5.0 h1:fi+bqFAx/oLK54somfCtEZs9HeH1LHVoEPUgARpTqyc= +github.com/gin-gonic/gin v1.5.0/go.mod h1:Nd6IXA8m5kNZdNEHMBd93KT+mdY3+bewLgRvmCsR2Do= +github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= +github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/leodido/go-urn v1.1.0/go.mod h1:+cyI34gQWZcE1eQU7NVgKkkzdXDQHr1dBMtdAPozLkw= +github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v9 v9.29.1/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/vendor/github.com/rs/cors/utils.go b/vendor/github.com/rs/cors/utils.go index db83ac3e..6bb120ca 100644 --- a/vendor/github.com/rs/cors/utils.go +++ b/vendor/github.com/rs/cors/utils.go @@ -52,7 +52,7 @@ func parseHeaderList(headerList string) []string { } else { h = append(h, b) } - case b == '-' || b == '_' || (b >= '0' && b <= '9'): + case b == '-' || b == '_' || b == '.' || (b >= '0' && b <= '9'): h = append(h, b) } diff --git a/vendor/github.com/tidwall/gjson/SYNTAX.md b/vendor/github.com/tidwall/gjson/SYNTAX.md index 86235b9b..bb6e92d5 100644 --- a/vendor/github.com/tidwall/gjson/SYNTAX.md +++ b/vendor/github.com/tidwall/gjson/SYNTAX.md @@ -135,6 +135,37 @@ changed in v1.3.0 as to avoid confusion with the new [multipath](#multipaths) syntax. For backwards compatibility, `#[...]` will continue to work until the next major release.* +The `~` (tilde) operator will convert a value to a boolean before comparison. + +For example, using the following JSON: + +```json +{ + "vals": [ + { "a": 1, "b": true }, + { "a": 2, "b": true }, + { "a": 3, "b": false }, + { "a": 4, "b": "0" }, + { "a": 5, "b": 0 }, + { "a": 6, "b": "1" }, + { "a": 7, "b": 1 }, + { "a": 8, "b": "true" }, + { "a": 9, "b": false }, + { "a": 10, "b": null }, + { "a": 11 } + ] +} +``` + +You can now query for all true(ish) or false(ish) values: + +``` +vals.#(b==~true)#.a >> [1,2,6,7,8] +vals.#(b==~false)#.a >> [3,4,5,9,10,11] +``` + +The last value which was non-existent is treated as `false` + ### Dot vs Pipe The `.` is standard separator, but it's also possible to use a `|`. diff --git a/vendor/github.com/tidwall/gjson/gjson.go b/vendor/github.com/tidwall/gjson/gjson.go index 9687c0bb..8e6c0990 100644 --- a/vendor/github.com/tidwall/gjson/gjson.go +++ b/vendor/github.com/tidwall/gjson/gjson.go @@ -584,7 +584,7 @@ func tostr(json string) (raw string, str string) { continue } } - break + return json[:i+1], unescape(json[1:i]) } } var ret string diff --git a/vendor/modules.txt b/vendor/modules.txt index aca22168..8a78552d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,6 +1,6 @@ # github.com/aaronland/go-aws-session v0.0.6 github.com/aaronland/go-aws-session -# github.com/aaronland/go-http-server v0.0.6 +# github.com/aaronland/go-http-server v0.0.7 ## explicit github.com/aaronland/go-http-server # github.com/aaronland/go-json-query v0.1.0 @@ -10,7 +10,7 @@ github.com/aaronland/go-json-query github.com/aaronland/go-roster # github.com/aaronland/go-string v0.1.2 github.com/aaronland/go-string/dsn -# github.com/aaronland/gocloud-blob-s3 v0.1.0 +# github.com/aaronland/gocloud-blob-s3 v0.1.3 ## explicit github.com/aaronland/gocloud-blob-s3 # github.com/aws/aws-lambda-go v1.10.0 @@ -90,13 +90,13 @@ github.com/jmespath/go-jmespath github.com/jtacoma/uritemplates # github.com/patrickmn/go-cache v2.1.0+incompatible github.com/patrickmn/go-cache -# github.com/rs/cors v1.7.0 +# github.com/rs/cors v1.8.0 ## explicit github.com/rs/cors # github.com/sfomuseum/go-flags v0.8.2 ## explicit github.com/sfomuseum/go-flags/flagset -# github.com/tidwall/gjson v1.8.0 +# github.com/tidwall/gjson v1.8.1 ## explicit github.com/tidwall/gjson # github.com/tidwall/match v1.0.3 @@ -127,7 +127,7 @@ github.com/whosonfirst/go-whosonfirst-iterate/iterator # github.com/whosonfirst/go-whosonfirst-sources v0.1.0 github.com/whosonfirst/go-whosonfirst-sources github.com/whosonfirst/go-whosonfirst-sources/sources -# github.com/whosonfirst/go-whosonfirst-uri v1.0.1 +# github.com/whosonfirst/go-whosonfirst-uri v1.1.0 ## explicit github.com/whosonfirst/go-whosonfirst-uri # github.com/whosonfirst/walk v0.0.1