diff --git a/CHANGES.txt b/CHANGES.txt index e91ac5af..5496eca5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,14 @@ -5.7.0 (TD) +5.8.0 (May 14, 2024) + - Added support for targeting rules based on semantic versions (https://semver.org/). + - Added special impression label "targeting rule type unsupported by sdk" when the matcher type is not supported by the SDK, which returns 'control' treatment. + - Forward TLS server name when in redis-sentinel & redis-cluster + - Fixed vulnerabilities: + - Updated debian image to 12.5 + - Updated golang image to 1.21.10 + - Updated gin/gonic to 1.10 + - Updated go-split-commons to v6 + +5.7.0 (TBD) - Add support for FIPS-compliant binaries & docker images 5.6.1 (Jan 29, 2024) diff --git a/docker/Dockerfile.proxy b/docker/Dockerfile.proxy index a47bbc5c..84853c89 100644 --- a/docker/Dockerfile.proxy +++ b/docker/Dockerfile.proxy @@ -1,5 +1,5 @@ # Build stage -FROM golang:1.21.6-bookworm AS builder +FROM golang:1.21.10-bookworm AS builder ARG EXTRA_BUILD_ARGS ARG FIPS_MODE @@ -17,7 +17,7 @@ RUN bash -c 'if [[ "${FIPS_MODE}" = "enabled" ]]; \ fi' # Runner stage -FROM debian:12.4 AS runner +FROM debian:12.5 AS runner RUN apt update -y RUN apt install -y bash ca-certificates diff --git a/docker/Dockerfile.synchronizer b/docker/Dockerfile.synchronizer index 350009a7..d500af55 100644 --- a/docker/Dockerfile.synchronizer +++ b/docker/Dockerfile.synchronizer @@ -1,5 +1,5 @@ # Build stage -FROM golang:1.21.6-bookworm AS builder +FROM golang:1.21.10-bookworm AS builder ARG EXTRA_BUILD_ARGS ARG FIPS_MODE @@ -17,7 +17,7 @@ RUN bash -c 'if [[ "${FIPS_MODE}" = "enabled" ]]; \ fi' # Runner stage -FROM debian:12.4 AS runner +FROM debian:12.5 AS runner RUN apt update -y RUN apt install -y bash ca-certificates diff --git a/go.mod b/go.mod index c73d83a4..83c38de6 100644 --- a/go.mod +++ b/go.mod @@ -5,12 +5,12 @@ go 1.21 require ( github.com/gin-contrib/cors v1.4.0 github.com/gin-contrib/gzip v0.0.6 - github.com/gin-gonic/gin v1.9.1 + github.com/gin-gonic/gin v1.10.0 github.com/google/uuid v1.3.0 github.com/splitio/gincache v1.0.1 - github.com/splitio/go-split-commons/v5 v5.2.1 + github.com/splitio/go-split-commons/v6 v6.0.0 github.com/splitio/go-toolkit/v5 v5.4.0 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 go.etcd.io/bbolt v1.3.6 golang.org/x/exp v0.0.0-20231006140011-7918f672742d ) @@ -18,35 +18,37 @@ require ( require ( github.com/bits-and-blooms/bitset v1.3.1 // indirect github.com/bits-and-blooms/bloom/v3 v3.3.1 // indirect - github.com/bytedance/sonic v1.9.1 // indirect + github.com/bytedance/sonic v1.11.6 // indirect + github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/redis/go-redis/v9 v9.0.4 // indirect - github.com/stretchr/objx v0.5.0 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect - golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/net v0.17.0 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect + golang.org/x/arch v0.8.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/net v0.25.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.15.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index ce2b638e..4ac52bd4 100644 --- a/go.sum +++ b/go.sum @@ -6,22 +6,24 @@ github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= -github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= +github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= +github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= @@ -29,8 +31,8 @@ github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjo github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= +github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= @@ -41,8 +43,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= +github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= @@ -56,8 +58,9 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= -github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= @@ -67,19 +70,19 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -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/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 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/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -90,49 +93,45 @@ github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUA github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/splitio/gincache v1.0.1 h1:dLYdANY/BqH4KcUMCe/LluLyV5WtuE/LEdQWRE06IXU= github.com/splitio/gincache v1.0.1/go.mod h1:CcgJDSM9Af75kyBH0724v55URVwMBuSj5x1eCWIOECY= -github.com/splitio/go-split-commons/v5 v5.1.1 h1:lLOqNQMdZA5Z7FBBh4YODWdE2QFgxSPMptX9ty14x4c= -github.com/splitio/go-split-commons/v5 v5.1.1/go.mod h1:9vAZrlhKvhensyRC11hyVFdgLIBrkX9D5vdYc9qB13w= -github.com/splitio/go-split-commons/v5 v5.2.0 h1:1P66JdUV1Fj1DUeWU1rwkeObqinl9AecRxDsktBsx0g= -github.com/splitio/go-split-commons/v5 v5.2.0/go.mod h1:m1Od/jxiSUJXpdbRvRxTaKeSAdQVem5AZr7AjI4xXn8= -github.com/splitio/go-split-commons/v5 v5.2.1 h1:h8Up3Jk6NFkHSYCj4Sr15uuoxQwFqPr3gn0G4vghM/8= -github.com/splitio/go-split-commons/v5 v5.2.1/go.mod h1:344KP05ULARzjRfnC4VtGSyu5l3kmIM375WUIzrURs0= +github.com/splitio/go-split-commons/v6 v6.0.0 h1:qenr5qbXafjvM832C64CVpjtlShuQiWCwtR5I2h4ogM= +github.com/splitio/go-split-commons/v6 v6.0.0/go.mod h1:TsvIh3XP7yjc7ly4vpj06AkoBND36SodPs5qfhb8rHc= github.com/splitio/go-toolkit/v5 v5.4.0 h1:g5WFpRhQomnXCmvfsNOWV4s5AuUrWIZ+amM68G8NBKM= github.com/splitio/go-toolkit/v5 v5.4.0/go.mod h1:xYhUvV1gga9/1029Wbp5pjnR6Cy8nvBpjw99wAbsMko= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/twmb/murmur3 v1.1.6 h1:mqrRot1BRxm+Yct+vavLMou2/iJt0tNVTTC0QoIjaZg= github.com/twmb/murmur3 v1.1.6/go.mod h1:Qq/R7NUyOfr65zD+6Q5IHKsJLwP7exErjN6lyyq3OSQ= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -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/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= +golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -140,21 +139,21 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 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-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= @@ -165,4 +164,5 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/splitio/admin/admin.go b/splitio/admin/admin.go index d14ad167..c0cfbac1 100644 --- a/splitio/admin/admin.go +++ b/splitio/admin/admin.go @@ -39,6 +39,7 @@ type Options struct { Snapshotter cstorage.Snapshotter TLS *tls.Config FullConfig interface{} + FlagSpecVersion string } type AdminServer struct { @@ -66,6 +67,7 @@ func NewServer(options *Options) (*AdminServer, error) { options.EventsEvCalc, options.Runtime, options.HcAppMonitor, + options.FlagSpecVersion, ) if err != nil { return nil, fmt.Errorf("error instantiating dashboard controller: %w", err) diff --git a/splitio/admin/common/config.go b/splitio/admin/common/config.go index 6187c8e0..acf417e2 100644 --- a/splitio/admin/common/config.go +++ b/splitio/admin/common/config.go @@ -1,6 +1,6 @@ package common -import "github.com/splitio/go-split-commons/v5/storage" +import "github.com/splitio/go-split-commons/v6/storage" // Storages wraps storages in one struct type Storages struct { diff --git a/splitio/admin/controllers/dashboard.go b/splitio/admin/controllers/dashboard.go index 355f209b..147bbefc 100644 --- a/splitio/admin/controllers/dashboard.go +++ b/splitio/admin/controllers/dashboard.go @@ -29,6 +29,7 @@ type DashboardController struct { eventsEvCalc evcalc.Monitor runtime common.Runtime appMonitor application.MonitorIterface + FlagSpecVersion string } // NewDashboardController instantiates a new dashboard controller @@ -41,6 +42,7 @@ func NewDashboardController( eventsEvCalc evcalc.Monitor, runtime common.Runtime, appMonitor application.MonitorIterface, + flagSpecVersion string, ) (*DashboardController, error) { toReturn := &DashboardController{ @@ -52,6 +54,7 @@ func NewDashboardController( eventsEvCalc: eventsEvCalc, impressionsEvCalc: impressionEvCalc, appMonitor: appMonitor, + FlagSpecVersion: flagSpecVersion, } var err error @@ -104,12 +107,13 @@ func (c *DashboardController) segmentKeys(ctx *gin.Context) { func (c *DashboardController) renderDashboard() ([]byte, error) { var layoutBuffer bytes.Buffer err := c.layout.Execute(&layoutBuffer, dashboard.RootObject{ - DashboardTitle: c.title, - Version: splitio.Version, - ProxyMode: c.proxy, - RefreshTime: 30000, - Stats: *c.gatherStats(), - Health: c.appMonitor.GetHealthStatus(), + DashboardTitle: c.title, + Version: splitio.Version, + ProxyMode: c.proxy, + RefreshTime: 30000, + Stats: *c.gatherStats(), + Health: c.appMonitor.GetHealthStatus(), + FlagSpecVersion: c.FlagSpecVersion, }) if err != nil { diff --git a/splitio/admin/controllers/helpers.go b/splitio/admin/controllers/helpers.go index 8d1d0a54..8fbb03d9 100644 --- a/splitio/admin/controllers/helpers.go +++ b/splitio/admin/controllers/helpers.go @@ -5,8 +5,8 @@ import ( "strings" "time" - "github.com/splitio/go-split-commons/v5/storage" - "github.com/splitio/go-split-commons/v5/telemetry" + "github.com/splitio/go-split-commons/v6/storage" + "github.com/splitio/go-split-commons/v6/telemetry" "github.com/splitio/split-synchronizer/v5/splitio/admin/views/dashboard" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" diff --git a/splitio/admin/controllers/observability_test.go b/splitio/admin/controllers/observability_test.go index a8e58b73..e5f3e305 100644 --- a/splitio/admin/controllers/observability_test.go +++ b/splitio/admin/controllers/observability_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/storage/mocks" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/storage/mocks" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" adminCommon "github.com/splitio/split-synchronizer/v5/splitio/admin/common" diff --git a/splitio/admin/views/dashboard/main.go b/splitio/admin/views/dashboard/main.go index b790e22a..4fff2f94 100644 --- a/splitio/admin/views/dashboard/main.go +++ b/splitio/admin/views/dashboard/main.go @@ -45,7 +45,7 @@ const main = ` {{template "SplitLogo" .}} </div> <div class="pull-right" style="text-align: center; padding-right: 10px;"> - <p style="padding-top: 8px; color: white; margin: 0px; font-weight: bold; text-align: right"><span>{{.Version}}</span></p> + <p style="padding-top: 8px; color: white; margin: 0px; font-weight: bold; text-align: right"><span>{{.Version}}</span> | Flag Spec: <span>{{.FlagSpecVersion}}</span></p> <p class="navbar-text navbar-right" style="padding-top: 0px;margin-bottom: 15px;margin-top: 0px;color:white;min-width: 175px;height: 10px;"> <a href="#" onclick="javascript:sendSignal('graceful'); return false;" class="navbar-link"> <span class="label label-success">Graceful stop</span> @@ -76,13 +76,14 @@ const main = ` // RootObject is the main/root object used to render the dashboard type RootObject struct { - DashboardTitle string - Version string - ProxyMode bool - RefreshTime int64 - Stats GlobalStats `json:"stats"` - Health application.HealthDto `json:"health"` - ServicesHealth services.HealthDto `json:"servicesHealth"` + DashboardTitle string + Version string + ProxyMode bool + RefreshTime int64 + Stats GlobalStats `json:"stats"` + Health application.HealthDto `json:"health"` + ServicesHealth services.HealthDto `json:"servicesHealth"` + FlagSpecVersion string } // GlobalStats runtime stats used to render the dashboard diff --git a/splitio/commitversion.go b/splitio/commitversion.go index 9efa5bb7..c841f0fd 100644 --- a/splitio/commitversion.go +++ b/splitio/commitversion.go @@ -5,4 +5,4 @@ This file is created automatically, please do not edit */ // CommitVersion is the version of the last commit previous to release -const CommitVersion = "1ffbd68" +const CommitVersion = "ae5a5ac" diff --git a/splitio/common/conf/advanced.go b/splitio/common/conf/advanced.go index 559257aa..0d678b00 100644 --- a/splitio/common/conf/advanced.go +++ b/splitio/common/conf/advanced.go @@ -3,7 +3,7 @@ package conf import ( "os" - "github.com/splitio/go-split-commons/v5/conf" + "github.com/splitio/go-split-commons/v6/conf" ) // InitAdvancedOptions initializes an advanced config with default values + overriden urls. diff --git a/splitio/common/conf/validators.go b/splitio/common/conf/validators.go index ff369328..8a69a1ea 100644 --- a/splitio/common/conf/validators.go +++ b/splitio/common/conf/validators.go @@ -3,7 +3,7 @@ package conf import ( "strings" - "github.com/splitio/go-split-commons/v5/flagsets" + "github.com/splitio/go-split-commons/v6/flagsets" ) type FlagSetValidationError struct { diff --git a/splitio/common/conf/validators_test.go b/splitio/common/conf/validators_test.go index d7a60b52..456dbe36 100644 --- a/splitio/common/conf/validators_test.go +++ b/splitio/common/conf/validators_test.go @@ -3,7 +3,7 @@ package conf import ( "testing" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/stretchr/testify/assert" ) diff --git a/splitio/common/impressionlistener/listener.go b/splitio/common/impressionlistener/listener.go index db0880cd..e45ccd4a 100644 --- a/splitio/common/impressionlistener/listener.go +++ b/splitio/common/impressionlistener/listener.go @@ -7,7 +7,7 @@ import ( "fmt" "net/http" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/go-toolkit/v5/struct/traits/lifecycle" ) diff --git a/splitio/common/impressionlistener/listener_test.go b/splitio/common/impressionlistener/listener_test.go index 3a48bd21..0a178ed0 100644 --- a/splitio/common/impressionlistener/listener_test.go +++ b/splitio/common/impressionlistener/listener_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" ) func TestImpressionListener(t *testing.T) { diff --git a/splitio/common/impressionlistener/mocks/listener.go b/splitio/common/impressionlistener/mocks/listener.go index 13b0b486..561d39bd 100644 --- a/splitio/common/impressionlistener/mocks/listener.go +++ b/splitio/common/impressionlistener/mocks/listener.go @@ -1,7 +1,7 @@ package mocks import ( - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" ) diff --git a/splitio/common/runtime.go b/splitio/common/runtime.go index 9d0807ee..5bba5677 100644 --- a/splitio/common/runtime.go +++ b/splitio/common/runtime.go @@ -7,7 +7,7 @@ import ( "syscall" "time" - "github.com/splitio/go-split-commons/v5/synchronizer" + "github.com/splitio/go-split-commons/v6/synchronizer" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/sync" diff --git a/splitio/common/sync/sync.go b/splitio/common/sync/sync.go index 54f2909e..66effc97 100644 --- a/splitio/common/sync/sync.go +++ b/splitio/common/sync/sync.go @@ -3,10 +3,10 @@ package sync import ( "github.com/splitio/go-toolkit/v5/logging" - "github.com/splitio/go-split-commons/v5/conf" + "github.com/splitio/go-split-commons/v6/conf" - "github.com/splitio/go-split-commons/v5/synchronizer" - "github.com/splitio/go-split-commons/v5/tasks" + "github.com/splitio/go-split-commons/v6/synchronizer" + "github.com/splitio/go-split-commons/v6/tasks" ) // WSync is a wrapper for the Regular synchronizer that handles both local telemetry diff --git a/splitio/producer/conf/sections.go b/splitio/producer/conf/sections.go index ba26d57e..9c98850c 100644 --- a/splitio/producer/conf/sections.go +++ b/splitio/producer/conf/sections.go @@ -1,7 +1,7 @@ package conf import ( - cconf "github.com/splitio/go-split-commons/v5/conf" + cconf "github.com/splitio/go-split-commons/v6/conf" "github.com/splitio/split-synchronizer/v5/splitio/common/conf" ) @@ -17,6 +17,7 @@ type Main struct { Integrations conf.Integrations `json:"integrations" s-nested:"true"` Logging conf.Logging `json:"logging" s-nested:"true"` Healthcheck Healthcheck `json:"healthcheck" s-nested:"true"` + FlagSpecVersion string `json:"flagSpecVersion" s-cli:"flag-spec-version" s-def:"1.1" s-desc:"Spec version for flags"` } // BuildAdvancedConfig generates a commons-compatible advancedconfig with default + overriden parameters diff --git a/splitio/producer/initialization.go b/splitio/producer/initialization.go index f1a865cb..f1e6b6d1 100644 --- a/splitio/producer/initialization.go +++ b/splitio/producer/initialization.go @@ -5,20 +5,20 @@ import ( "fmt" "time" - cconf "github.com/splitio/go-split-commons/v5/conf" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/flagsets" - "github.com/splitio/go-split-commons/v5/provisional/strategy" - "github.com/splitio/go-split-commons/v5/service/api" - "github.com/splitio/go-split-commons/v5/storage/filter" - "github.com/splitio/go-split-commons/v5/storage/inmemory" - "github.com/splitio/go-split-commons/v5/storage/redis" - "github.com/splitio/go-split-commons/v5/synchronizer" - "github.com/splitio/go-split-commons/v5/synchronizer/worker/impressionscount" - "github.com/splitio/go-split-commons/v5/synchronizer/worker/segment" - "github.com/splitio/go-split-commons/v5/synchronizer/worker/split" - "github.com/splitio/go-split-commons/v5/tasks" - "github.com/splitio/go-split-commons/v5/telemetry" + cconf "github.com/splitio/go-split-commons/v6/conf" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/flagsets" + "github.com/splitio/go-split-commons/v6/provisional/strategy" + "github.com/splitio/go-split-commons/v6/service/api" + "github.com/splitio/go-split-commons/v6/storage/filter" + "github.com/splitio/go-split-commons/v6/storage/inmemory" + "github.com/splitio/go-split-commons/v6/storage/redis" + "github.com/splitio/go-split-commons/v6/synchronizer" + "github.com/splitio/go-split-commons/v6/synchronizer/worker/impressionscount" + "github.com/splitio/go-split-commons/v6/synchronizer/worker/segment" + "github.com/splitio/go-split-commons/v6/synchronizer/worker/split" + "github.com/splitio/go-split-commons/v6/tasks" + "github.com/splitio/go-split-commons/v6/telemetry" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/admin" @@ -47,6 +47,8 @@ const ( func Start(logger logging.LoggerInterface, cfg *conf.Main) error { // Getting initial config data advanced := cfg.BuildAdvancedConfig() + advanced.AuthSpecVersion = cfg.FlagSpecVersion + advanced.FlagsSpecVersion = cfg.FlagSpecVersion advanced.FlagSetsFilter = cfg.FlagSetsFilter metadata := util.GetMetadata(false, cfg.IPAddressEnabled) @@ -298,6 +300,7 @@ func Start(logger logging.LoggerInterface, cfg *conf.Main) error { HcServicesMonitor: servicesMonitor, FullConfig: cfgForAdmin, TLS: adminTLSConfig, + FlagSpecVersion: cfg.FlagSpecVersion, }) if err != nil { panic(err.Error()) diff --git a/splitio/producer/initialization_test.go b/splitio/producer/initialization_test.go index df7f58c3..fb1d71ba 100644 --- a/splitio/producer/initialization_test.go +++ b/splitio/producer/initialization_test.go @@ -10,11 +10,11 @@ import ( "strings" "testing" - config "github.com/splitio/go-split-commons/v5/conf" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/service" - "github.com/splitio/go-split-commons/v5/service/mocks" - predis "github.com/splitio/go-split-commons/v5/storage/redis" + config "github.com/splitio/go-split-commons/v6/conf" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/service" + "github.com/splitio/go-split-commons/v6/service/mocks" + predis "github.com/splitio/go-split-commons/v6/storage/redis" "github.com/splitio/go-toolkit/v5/logging" cconf "github.com/splitio/split-synchronizer/v5/splitio/common/conf" "github.com/splitio/split-synchronizer/v5/splitio/producer/conf" @@ -48,7 +48,7 @@ func TestIsApikeyValidOk(t *testing.T) { os.Setenv("SPLITIO_EVENTS_URL", ts.URL) httpSplitFetcher := mocks.MockSplitFetcher{ - FetchCall: func(changeNumber int64, fetchOptions *service.FetchOptions) (*dtos.SplitChangesDTO, error) { + FetchCall: func(fetchOptions *service.FlagRequestParams) (*dtos.SplitChangesDTO, error) { return nil, nil }, } @@ -68,7 +68,7 @@ func TestIsApikeyValidNotOk(t *testing.T) { os.Setenv("SPLITIO_EVENTS_URL", ts.URL) httpSplitFetcher := mocks.MockSplitFetcher{ - FetchCall: func(changeNumber int64, fetchOptions *service.FetchOptions) (*dtos.SplitChangesDTO, error) { + FetchCall: func(fetchOptions *service.FlagRequestParams) (*dtos.SplitChangesDTO, error) { return nil, errors.New("Some") }, } @@ -81,6 +81,7 @@ func TestIsApikeyValidNotOk(t *testing.T) { func TestSanitizeRedisWithForcedCleanup(t *testing.T) { cfg := getDefaultConf() cfg.Apikey = "983564etyrudhijfgknf9i08euh" + cfg.FlagSpecVersion = "1.0" cfg.Initialization.ForceFreshStartup = true logger := logging.NewLogger(nil) @@ -99,13 +100,12 @@ func TestSanitizeRedisWithForcedCleanup(t *testing.T) { if err != nil { t.Error("It should be nil") } - value, err := redisClient.Get("SPLITIO.test1") + value, _ := redisClient.Get("SPLITIO.test1") if value != "123" { t.Error("Value should have been set properly") } miscStorage := predis.NewMiscStorage(redisClient, logger) - value, err = redisClient.Get("SPLITIO.test1") err = sanitizeRedis(cfg, miscStorage, logger) if err != nil { t.Error("It should be nil", err) @@ -116,8 +116,8 @@ func TestSanitizeRedisWithForcedCleanup(t *testing.T) { t.Error("Value should have been null, and was ", value) } - value, err = redisClient.Get("SPLITIO.hash") - if value != "1497926959" { + value, _ = redisClient.Get("SPLITIO.hash") + if value != "2298020180" { t.Error("Incorrect apikey hash set in redis after sanitization operation.", value) } @@ -126,7 +126,8 @@ func TestSanitizeRedisWithForcedCleanup(t *testing.T) { func TestSanitizeRedisWithRedisEqualApiKey(t *testing.T) { cfg := getDefaultConf() - cfg.Apikey = "djasghdhjasfganyr73dsah9" + cfg.Apikey = "983564etyrudhijfgknf9i08euh" + cfg.FlagSpecVersion = "1.0" logger := logging.NewLogger(nil) @@ -139,9 +140,10 @@ func TestSanitizeRedisWithRedisEqualApiKey(t *testing.T) { if err != nil { t.Error("It should be nil") } + hash := util.HashAPIKey(cfg.Apikey + cfg.FlagSpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) redisClient.Set("SPLITIO.test1", "123", 0) - redisClient.Set("SPLITIO.hash", "3376912823", 0) + redisClient.Set("SPLITIO.hash", hash, 0) miscStorage := predis.NewMiscStorage(redisClient, logger) err = sanitizeRedis(cfg, miscStorage, logger) @@ -155,16 +157,18 @@ func TestSanitizeRedisWithRedisEqualApiKey(t *testing.T) { } val, _ = redisClient.Get("SPLITIO.hash") - if val != "3376912823" { + if val != strconv.FormatUint(uint64(hash), 10) { t.Error("Incorrect apikey hash set in redis after sanitization operation.") } + redisClient.Del("SPLITIO.hash") redisClient.Del("SPLITIO.test1") } func TestSanitizeRedisWithRedisDifferentApiKey(t *testing.T) { cfg := getDefaultConf() cfg.Apikey = "983564etyrudhijfgknf9i08euh" + cfg.FlagSpecVersion = "1.0" logger := logging.NewLogger(nil) @@ -177,9 +181,12 @@ func TestSanitizeRedisWithRedisDifferentApiKey(t *testing.T) { if err != nil { t.Error("It should be nil") } + hash := util.HashAPIKey("djasghdhjasfganyr73dsah9" + cfg.FlagSpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) redisClient.Set("SPLITIO.test1", "123", 0) - redisClient.Set("SPLITIO.hash", "3376912823", 0) + redisClient.Set("SPLITIO.hash", "3216514561", 0) + + hash = util.HashAPIKey(cfg.Apikey + cfg.FlagSpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) miscStorage := predis.NewMiscStorage(redisClient, logger) err = sanitizeRedis(cfg, miscStorage, logger) @@ -193,20 +200,22 @@ func TestSanitizeRedisWithRedisDifferentApiKey(t *testing.T) { } val, _ = redisClient.Get("SPLITIO.hash") - if val != "1497926959" { - t.Error("Incorrect apikey hash set in redis after sanitization operation.") + if val != strconv.FormatUint(uint64(hash), 10) { + t.Error("Incorrect apikey hash set in redis after sanitization operation.", val) } + redisClient.Del("SPLITIO.hash") redisClient.Del("SPLITIO.test1") } func TestSanitizeRedisWithForcedCleanupByFlagSets(t *testing.T) { cfg := getDefaultConf() + cfg.FlagSpecVersion = "1.0" cfg.Apikey = "983564etyrudhijfgknf9i08euh" cfg.Initialization.ForceFreshStartup = true cfg.FlagSetsFilter = []string{"flagset1", "flagset2"} - hash := util.HashAPIKey(cfg.Apikey + strings.Join(cfg.FlagSetsFilter, "::")) + hash := util.HashAPIKey(cfg.Apikey + cfg.FlagSpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) logger := logging.NewLogger(nil) @@ -225,14 +234,64 @@ func TestSanitizeRedisWithForcedCleanupByFlagSets(t *testing.T) { if err != nil { t.Error("It should be nil") } - value, err := redisClient.Get("SPLITIO.test1") + value, _ := redisClient.Get("SPLITIO.test1") if value != "123" { t.Error("Value should have been set properly") } cfg.FlagSetsFilter = []string{"flagset7"} miscStorage := predis.NewMiscStorage(redisClient, logger) - value, err = redisClient.Get("SPLITIO.test1") + err = sanitizeRedis(cfg, miscStorage, logger) + if err != nil { + t.Error("It should be nil", err) + } + + value, _ = redisClient.Get("SPLITIO.test1") + if value != "" { + t.Error("Value should have been removed.") + } + + val, _ := redisClient.Get("SPLITIO.hash") + parsedHash, _ := strconv.ParseUint(val, 10, 64) + if uint32(parsedHash) == hash { + t.Error("ApiHash should have been updated.") + } + redisClient.Del("SPLITIO.hash") + redisClient.Del("SPLITIO.test1") +} + +func TestSanitizeRedisWithForcedCleanupBySpecVersion(t *testing.T) { + cfg := getDefaultConf() + cfg.Apikey = "983564etyrudhijfgknf9i08euh" + cfg.Initialization.ForceFreshStartup = true + cfg.FlagSpecVersion = "1.0" + + hash := util.HashAPIKey(cfg.Apikey + cfg.FlagSpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) + + logger := logging.NewLogger(nil) + + redisClient, err := predis.NewRedisClient(&config.RedisConfig{ + Host: "localhost", + Port: 6379, + Prefix: "some_prefix", + Database: 1, + }, logger) + if err != nil { + t.Error("It should be nil") + } + + err = redisClient.Set("SPLITIO.test1", "123", 0) + redisClient.Set("SPLITIO.hash", hash, 0) + if err != nil { + t.Error("It should be nil") + } + value, _ := redisClient.Get("SPLITIO.test1") + if value != "123" { + t.Error("Value should have been set properly") + } + + cfg.FlagSpecVersion = "1.1" + miscStorage := predis.NewMiscStorage(redisClient, logger) err = sanitizeRedis(cfg, miscStorage, logger) if err != nil { t.Error("It should be nil", err) diff --git a/splitio/producer/storage/mocks/telemetry.go b/splitio/producer/storage/mocks/telemetry.go index e7faad6c..beb484aa 100644 --- a/splitio/producer/storage/mocks/telemetry.go +++ b/splitio/producer/storage/mocks/telemetry.go @@ -1,7 +1,7 @@ package mocks import ( - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" ) // RedisTelemetryConsumerMultiMock is a mock diff --git a/splitio/producer/storage/telemetry.go b/splitio/producer/storage/telemetry.go index 27d9bbdb..66742583 100644 --- a/splitio/producer/storage/telemetry.go +++ b/splitio/producer/storage/telemetry.go @@ -10,9 +10,9 @@ import ( "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/redis" - "github.com/splitio/go-split-commons/v5/dtos" - redisSt "github.com/splitio/go-split-commons/v5/storage/redis" - "github.com/splitio/go-split-commons/v5/telemetry" + "github.com/splitio/go-split-commons/v6/dtos" + redisSt "github.com/splitio/go-split-commons/v6/storage/redis" + "github.com/splitio/go-split-commons/v6/telemetry" ) const ( diff --git a/splitio/producer/storage/telemetry_test.go b/splitio/producer/storage/telemetry_test.go index c077384a..69943a89 100644 --- a/splitio/producer/storage/telemetry_test.go +++ b/splitio/producer/storage/telemetry_test.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v5/dtos" - redisSt "github.com/splitio/go-split-commons/v5/storage/redis" - "github.com/splitio/go-split-commons/v5/telemetry" + "github.com/splitio/go-split-commons/v6/dtos" + redisSt "github.com/splitio/go-split-commons/v6/storage/redis" + "github.com/splitio/go-split-commons/v6/telemetry" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/redis" ) diff --git a/splitio/producer/task/events.go b/splitio/producer/task/events.go index 443072a8..709200fa 100644 --- a/splitio/producer/task/events.go +++ b/splitio/producer/task/events.go @@ -8,8 +8,8 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/storage" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" ) diff --git a/splitio/producer/task/events_test.go b/splitio/producer/task/events_test.go index c11aa3a8..407067d1 100644 --- a/splitio/producer/task/events_test.go +++ b/splitio/producer/task/events_test.go @@ -11,8 +11,8 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/storage/mocks" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/storage/mocks" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" ) diff --git a/splitio/producer/task/impressions.go b/splitio/producer/task/impressions.go index 4c329627..d8fc2298 100644 --- a/splitio/producer/task/impressions.go +++ b/splitio/producer/task/impressions.go @@ -8,9 +8,9 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/provisional" - "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/provisional" + "github.com/splitio/go-split-commons/v6/storage" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" diff --git a/splitio/producer/task/impressions_test.go b/splitio/producer/task/impressions_test.go index b396ce83..e25b78a3 100644 --- a/splitio/producer/task/impressions_test.go +++ b/splitio/producer/task/impressions_test.go @@ -11,11 +11,11 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/provisional" - "github.com/splitio/go-split-commons/v5/provisional/strategy" - "github.com/splitio/go-split-commons/v5/storage/inmemory" - "github.com/splitio/go-split-commons/v5/storage/mocks" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/provisional" + "github.com/splitio/go-split-commons/v6/provisional/strategy" + "github.com/splitio/go-split-commons/v6/storage/inmemory" + "github.com/splitio/go-split-commons/v6/storage/mocks" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/evcalc" ) diff --git a/splitio/producer/task/uniquekeys.go b/splitio/producer/task/uniquekeys.go index f3134ce1..f28b6fb1 100644 --- a/splitio/producer/task/uniquekeys.go +++ b/splitio/producer/task/uniquekeys.go @@ -6,9 +6,9 @@ import ( "fmt" "net/http" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/provisional/strategy" - "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/provisional/strategy" + "github.com/splitio/go-split-commons/v6/storage" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/producer/task/uniquekeys_test.go b/splitio/producer/task/uniquekeys_test.go index 4985bb62..f47e2507 100644 --- a/splitio/producer/task/uniquekeys_test.go +++ b/splitio/producer/task/uniquekeys_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "testing" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/provisional/strategy" - "github.com/splitio/go-split-commons/v5/storage/mocks" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/provisional/strategy" + "github.com/splitio/go-split-commons/v6/storage/mocks" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/producer/util.go b/splitio/producer/util.go index f7cda7f2..ee1931b4 100644 --- a/splitio/producer/util.go +++ b/splitio/producer/util.go @@ -12,13 +12,12 @@ import ( "strings" "time" - cconf "github.com/splitio/go-split-commons/v5/conf" - config "github.com/splitio/go-split-commons/v5/conf" - "github.com/splitio/go-split-commons/v5/provisional" - "github.com/splitio/go-split-commons/v5/provisional/strategy" - "github.com/splitio/go-split-commons/v5/service" - storageCommon "github.com/splitio/go-split-commons/v5/storage" - "github.com/splitio/go-split-commons/v5/storage/redis" + config "github.com/splitio/go-split-commons/v6/conf" + "github.com/splitio/go-split-commons/v6/provisional" + "github.com/splitio/go-split-commons/v6/provisional/strategy" + "github.com/splitio/go-split-commons/v6/service" + storageCommon "github.com/splitio/go-split-commons/v6/storage" + "github.com/splitio/go-split-commons/v6/storage/redis" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" "github.com/splitio/split-synchronizer/v5/splitio/producer/conf" @@ -37,13 +36,9 @@ func parseTLSConfig(opt *conf.Redis) (*tls.Config, error) { return nil, nil } - cfg := tls.Config{} - if !opt.SentinelReplication && !opt.ClusterMode { - if opt.TLSServerName != "" { - cfg.ServerName = opt.TLSServerName - } else { - cfg.ServerName = opt.Host - } + cfg := tls.Config{ServerName: opt.TLSServerName} + if cfg.ServerName == "" { + cfg.ServerName = opt.Host } if len(opt.TLSCACertificates) > 0 { @@ -116,15 +111,15 @@ func parseRedisOptions(cfg *conf.Redis) (*config.RedisConfig, error) { } func isValidApikey(splitFetcher service.SplitFetcher) bool { - _, err := splitFetcher.Fetch(time.Now().UnixNano()/int64(time.Millisecond), &service.FetchOptions{CacheControlHeaders: false}) + _, err := splitFetcher.Fetch(service.MakeFlagRequestParams().WithCacheControl(false).WithChangeNumber(time.Now().UnixNano() / int64(time.Millisecond))) return err == nil } func sanitizeRedis(cfg *conf.Main, miscStorage *redis.MiscStorage, logger logging.LoggerInterface) error { if miscStorage == nil { - return errors.New("Could not sanitize redis") + return errors.New("could not sanitize redis") } - currentHash := util.HashAPIKey(cfg.Apikey + strings.Join(cfg.FlagSetsFilter, "::")) + currentHash := util.HashAPIKey(cfg.Apikey + cfg.FlagSpecVersion + strings.Join(cfg.FlagSetsFilter, "::")) currentHashAsStr := strconv.Itoa(int(currentHash)) defer miscStorage.SetApikeyHash(currentHashAsStr) @@ -166,7 +161,7 @@ func getAppCounterConfigs(storage storageCommon.SplitStorage) (hcAppCounter.Thre return splitsConfig, segmentsConfig, storageConfig } -func getServicesCountersConfig(advanced *cconf.AdvancedConfig) []hcServicesCounter.Config { +func getServicesCountersConfig(advanced *config.AdvancedConfig) []hcServicesCounter.Config { var cfgs []hcServicesCounter.Config apiConfig := hcServicesCounter.DefaultConfig("API", advanced.SdkURL, "/version") diff --git a/splitio/producer/worker/impcounts.go b/splitio/producer/worker/impcounts.go index ef3dd124..e4121e4c 100644 --- a/splitio/producer/worker/impcounts.go +++ b/splitio/producer/worker/impcounts.go @@ -1,8 +1,8 @@ package worker import ( - "github.com/splitio/go-split-commons/v5/provisional/strategy" - "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v6/provisional/strategy" + "github.com/splitio/go-split-commons/v6/storage" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/producer/worker/telemetry.go b/splitio/producer/worker/telemetry.go index a92bf7a1..8476a33e 100644 --- a/splitio/producer/worker/telemetry.go +++ b/splitio/producer/worker/telemetry.go @@ -3,8 +3,8 @@ package worker import ( "fmt" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/service" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/service" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/storage" ) @@ -115,17 +115,6 @@ func (w *TelemetryMultiWorkerImpl) SyncrhonizeConfigs() error { return nil } -// import ( -// "sync" -// -// "github.com/splitio/go-split-commons/v5/dtos" -// "github.com/splitio/go-split-commons/v5/service" -// "github.com/splitio/go-split-commons/v5/storage" -// -// // "github.com/splitio/go-split-commons/v5/synchronizer/worker/metric" -// "github.com/splitio/go-toolkit/v5/logging" -// ) -// // // RecorderMetricMultiple struct for metric sync // type RecorderMetricMultiple struct { // metricRecorder service.MetricsRecorder diff --git a/splitio/producer/worker/telemetry_test.go b/splitio/producer/worker/telemetry_test.go index 72e4198d..3644b5d5 100644 --- a/splitio/producer/worker/telemetry_test.go +++ b/splitio/producer/worker/telemetry_test.go @@ -3,9 +3,9 @@ package worker import ( "testing" - "github.com/splitio/go-split-commons/v5/dtos" - serviceMocks "github.com/splitio/go-split-commons/v5/service/mocks" - "github.com/splitio/go-split-commons/v5/telemetry" + "github.com/splitio/go-split-commons/v6/dtos" + serviceMocks "github.com/splitio/go-split-commons/v6/service/mocks" + "github.com/splitio/go-split-commons/v6/telemetry" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/producer/storage" storageMocks "github.com/splitio/split-synchronizer/v5/splitio/producer/storage/mocks" diff --git a/splitio/provisional/healthcheck/application/monitor_test.go b/splitio/provisional/healthcheck/application/monitor_test.go index 50e55e97..edf9859e 100644 --- a/splitio/provisional/healthcheck/application/monitor_test.go +++ b/splitio/provisional/healthcheck/application/monitor_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v5/healthcheck/application" + "github.com/splitio/go-split-commons/v6/healthcheck/application" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/provisional/healthcheck/application/counter" ) diff --git a/splitio/provisional/healthcheck/services/counter/bypercentage.go b/splitio/provisional/healthcheck/services/counter/bypercentage.go index 0a18e274..d29977e2 100644 --- a/splitio/provisional/healthcheck/services/counter/bypercentage.go +++ b/splitio/provisional/healthcheck/services/counter/bypercentage.go @@ -6,9 +6,9 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v5/conf" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/service/api" + "github.com/splitio/go-split-commons/v6/conf" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/service/api" "github.com/splitio/go-toolkit/v5/asynctask" "github.com/splitio/go-toolkit/v5/logging" diff --git a/splitio/provisional/observability/segment_wrapper.go b/splitio/provisional/observability/segment_wrapper.go index d89f85b7..aae49fa3 100644 --- a/splitio/provisional/observability/segment_wrapper.go +++ b/splitio/provisional/observability/segment_wrapper.go @@ -5,7 +5,7 @@ import ( "fmt" "sync" - "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v6/storage" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" diff --git a/splitio/provisional/observability/segment_wrapper_test.go b/splitio/provisional/observability/segment_wrapper_test.go index aab99a50..cff78827 100644 --- a/splitio/provisional/observability/segment_wrapper_test.go +++ b/splitio/provisional/observability/segment_wrapper_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/splitio/go-split-commons/v5/storage/mocks" + "github.com/splitio/go-split-commons/v6/storage/mocks" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/provisional/observability/split_wrapper.go b/splitio/provisional/observability/split_wrapper.go index dfc78c95..fa935f5e 100644 --- a/splitio/provisional/observability/split_wrapper.go +++ b/splitio/provisional/observability/split_wrapper.go @@ -4,9 +4,9 @@ import ( "errors" "sync" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/storage" - "github.com/splitio/go-split-commons/v5/storage/redis" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/storage" + "github.com/splitio/go-split-commons/v6/storage/redis" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/provisional/observability/split_wrapper_test.go b/splitio/provisional/observability/split_wrapper_test.go index 6ac4c33d..92bc87b6 100644 --- a/splitio/provisional/observability/split_wrapper_test.go +++ b/splitio/provisional/observability/split_wrapper_test.go @@ -4,9 +4,9 @@ import ( "errors" "testing" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/storage/mocks" - "github.com/splitio/go-split-commons/v5/storage/redis" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/storage/mocks" + "github.com/splitio/go-split-commons/v6/storage/redis" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/proxy/caching/caching.go b/splitio/proxy/caching/caching.go index 89d153ec..efae93cf 100644 --- a/splitio/proxy/caching/caching.go +++ b/splitio/proxy/caching/caching.go @@ -5,7 +5,7 @@ import ( "github.com/gin-gonic/gin" "github.com/splitio/gincache" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" ) const ( @@ -51,23 +51,25 @@ func MakeProxyCache() *gincache.Middleware { return gincache.New(&gincache.Options{ SuccessfulOnly: true, // we're not interested in caching non-200 responses Size: cacheSize, - KeyFactory: func(ctx *gin.Context) string { - - var encodingPrefix string - if strings.Contains(ctx.Request.Header.Get("Accept-Encoding"), "gzip") { - encodingPrefix = "gzip::" - } - - if strings.HasPrefix(ctx.Request.URL.Path, "/api/auth") || strings.HasPrefix(ctx.Request.URL.Path, "/api/v2/auth") { - // For auth requests, since we don't support streaming yet, we only need a single entry in the table, - // so we strip the query-string which contains the user-list - return encodingPrefix + ctx.Request.URL.Path - } - return encodingPrefix + ctx.Request.URL.Path + ctx.Request.URL.RawQuery - }, + KeyFactory: keyFactoryFN, // we make each request handler responsible for generating the surrogates. // this way we can use segment names as surrogates for mysegments & segment changes // with a lot less work SurrogateFactory: func(ctx *gin.Context) []string { return ctx.GetStringSlice(SurrogateContextKey) }, }) } + +func keyFactoryFN(ctx *gin.Context) string { + + var encodingPrefix string + if strings.Contains(ctx.Request.Header.Get("Accept-Encoding"), "gzip") { + encodingPrefix = "gzip::" + } + + if strings.HasPrefix(ctx.Request.URL.Path, "/api/auth") || strings.HasPrefix(ctx.Request.URL.Path, "/api/v2/auth") { + // For auth requests, since we don't support streaming yet, we only need a single entry in the table, + // so we strip the query-string which contains the user-list + return encodingPrefix + ctx.Request.URL.Path + } + return encodingPrefix + ctx.Request.URL.Path + ctx.Request.URL.RawQuery +} diff --git a/splitio/proxy/caching/caching_test.go b/splitio/proxy/caching/caching_test.go index 5d46574b..98eb9f8f 100644 --- a/splitio/proxy/caching/caching_test.go +++ b/splitio/proxy/caching/caching_test.go @@ -1,12 +1,26 @@ package caching import ( + "net/http" + "net/url" "testing" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/gin-gonic/gin" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/stretchr/testify/assert" ) +func TestCacheKeysDoNotOverlap(t *testing.T) { + + url1, _ := url.Parse("http://proxy.split.io/api/spitChanges?since=-1") + c1 := &gin.Context{Request: &http.Request{URL: url1}} + + url2, _ := url.Parse("http://proxy.split.io/api/spitChanges?s=1.1&since=-1") + c2 := &gin.Context{Request: &http.Request{URL: url2}} + + assert.NotEqual(t, keyFactoryFN(c1), keyFactoryFN(c2)) +} + func TestSegmentSurrogates(t *testing.T) { assert.Equal(t, segmentPrefix+"segment1", MakeSurrogateForSegmentChanges("segment1")) assert.NotEqual(t, MakeSurrogateForSegmentChanges("segment1"), MakeSurrogateForSegmentChanges("segment2")) diff --git a/splitio/proxy/caching/workers.go b/splitio/proxy/caching/workers.go index ea002998..deb9be13 100644 --- a/splitio/proxy/caching/workers.go +++ b/splitio/proxy/caching/workers.go @@ -1,13 +1,13 @@ package caching import ( - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/flagsets" - "github.com/splitio/go-split-commons/v5/healthcheck/application" - "github.com/splitio/go-split-commons/v5/service" - "github.com/splitio/go-split-commons/v5/storage" - "github.com/splitio/go-split-commons/v5/synchronizer/worker/segment" - "github.com/splitio/go-split-commons/v5/synchronizer/worker/split" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/flagsets" + "github.com/splitio/go-split-commons/v6/healthcheck/application" + "github.com/splitio/go-split-commons/v6/service" + "github.com/splitio/go-split-commons/v6/storage" + "github.com/splitio/go-split-commons/v6/synchronizer/worker/segment" + "github.com/splitio/go-split-commons/v6/synchronizer/worker/split" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/gincache" diff --git a/splitio/proxy/caching/workers_test.go b/splitio/proxy/caching/workers_test.go index a979c9d9..ad19e847 100644 --- a/splitio/proxy/caching/workers_test.go +++ b/splitio/proxy/caching/workers_test.go @@ -4,10 +4,10 @@ import ( "testing" "github.com/splitio/gincache" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/storage" - "github.com/splitio/go-split-commons/v5/synchronizer/worker/segment" - "github.com/splitio/go-split-commons/v5/synchronizer/worker/split" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/storage" + "github.com/splitio/go-split-commons/v6/synchronizer/worker/segment" + "github.com/splitio/go-split-commons/v6/synchronizer/worker/split" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/splitio/proxy/conf/sections.go b/splitio/proxy/conf/sections.go index 3f7d796a..4b3df854 100644 --- a/splitio/proxy/conf/sections.go +++ b/splitio/proxy/conf/sections.go @@ -1,7 +1,7 @@ package conf import ( - cconf "github.com/splitio/go-split-commons/v5/conf" + cconf "github.com/splitio/go-split-commons/v6/conf" "github.com/splitio/split-synchronizer/v5/splitio/common/conf" ) @@ -20,6 +20,7 @@ type Main struct { Logging conf.Logging `json:"logging" s-nested:"true"` Healthcheck Healthcheck `json:"healthcheck" s-nested:"true"` Observability Observability `json:"observability" s-nested:"true"` + FlagSpecVersion string `json:"flagSpecVersion" s-cli:"flag-spec-version" s-def:"1.1" s-desc:"Spec version for flags"` } // BuildAdvancedConfig generates a commons-compatible advancedconfig with default + overriden parameters diff --git a/splitio/proxy/controllers/events.go b/splitio/proxy/controllers/events.go index 38ca22ab..b37d8ce3 100644 --- a/splitio/proxy/controllers/events.go +++ b/splitio/proxy/controllers/events.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" diff --git a/splitio/proxy/controllers/events_test.go b/splitio/proxy/controllers/events_test.go index aee2ab7d..aa3637c6 100644 --- a/splitio/proxy/controllers/events_test.go +++ b/splitio/proxy/controllers/events_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" ilMock "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener/mocks" diff --git a/splitio/proxy/controllers/sdk.go b/splitio/proxy/controllers/sdk.go index 7f05c2c6..3909558b 100644 --- a/splitio/proxy/controllers/sdk.go +++ b/splitio/proxy/controllers/sdk.go @@ -8,8 +8,10 @@ import ( "strings" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/service" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/engine/validator" + "github.com/splitio/go-split-commons/v6/service" + "github.com/splitio/go-split-commons/v6/service/api/specs" "github.com/splitio/go-toolkit/v5/logging" "golang.org/x/exp/slices" @@ -25,6 +27,7 @@ type SdkServerController struct { proxySplitStorage storage.ProxySplitStorage proxySegmentStorage storage.ProxySegmentStorage fsmatcher flagsets.FlagSetMatcher + versionFilter specs.SplitVersionFilter } // NewSdkServerController instantiates a new sdk server controller @@ -42,6 +45,7 @@ func NewSdkServerController( proxySplitStorage: proxySplitStorage, proxySegmentStorage: proxySegmentStorage, fsmatcher: fsmatcher, + versionFilter: specs.NewSplitVersionFilter(), } } @@ -77,6 +81,13 @@ func (c *SdkServerController) SplitChanges(ctx *gin.Context) { ctx.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } + + spec, _ := ctx.GetQuery("s") + if spec != specs.FLAG_V1_1 { + spec = specs.FLAG_V1_0 + } + splits.Splits = c.patchUnsupportedMatchers(splits.Splits, spec) + ctx.JSON(http.StatusOK, splits) ctx.Set(caching.SurrogateContextKey, []string{caching.SplitSurrogate}) ctx.Set(caching.StickyContextKey, true) @@ -140,7 +151,26 @@ func (c *SdkServerController) fetchSplitChangesSince(since int64, sets []string) // perform a fetch to the BE using the supplied `since`, have the storage process it's response &, retry // TODO(mredolatti): implement basic collapsing here to avoid flooding the BE with requests - fetchOptions := service.NewFetchOptions(true, nil) - fetchOptions.FlagSetsFilter = strings.Join(sets, ",") // at this point the sets have been sanitized & sorted - return c.fetcher.Fetch(since, &fetchOptions) + fetchOptions := service.MakeFlagRequestParams().WithChangeNumber(since).WithFlagSetsFilter(strings.Join(sets, ",")) // at this point the sets have been sanitized & sorted + return c.fetcher.Fetch(fetchOptions) +} + +func (c *SdkServerController) shouldOverrideSplitCondition(split *dtos.SplitDTO, version string) bool { + for _, condition := range split.Conditions { + for _, matcher := range condition.MatcherGroup.Matchers { + if c.versionFilter.ShouldFilter(matcher.MatcherType, version) { + return true + } + } + } + return false +} + +func (c *SdkServerController) patchUnsupportedMatchers(splits []dtos.SplitDTO, version string) []dtos.SplitDTO { + for si := range splits { + if c.shouldOverrideSplitCondition(&splits[si], version) { + splits[si].Conditions = validator.MakeUnsupportedMatcherConditionReplacement() + } + } + return splits } diff --git a/splitio/proxy/controllers/sdk_test.go b/splitio/proxy/controllers/sdk_test.go index 2ddc8bbb..0c0c1b99 100644 --- a/splitio/proxy/controllers/sdk_test.go +++ b/splitio/proxy/controllers/sdk_test.go @@ -3,14 +3,18 @@ package controllers import ( "encoding/json" "errors" - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/service" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/engine/evaluator/impressionlabels" + "github.com/splitio/go-split-commons/v6/engine/grammar" + "github.com/splitio/go-split-commons/v6/engine/grammar/matchers" + "github.com/splitio/go-split-commons/v6/service" + "github.com/splitio/go-split-commons/v6/service/api/specs" "github.com/splitio/go-toolkit/v5/logging" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -52,7 +56,7 @@ func TestSplitChangesRecentSince(t *testing.T) { assert.Equal(t, 200, resp.Code) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) assert.Nil(t, err) var s dtos.SplitChangesDTO @@ -75,7 +79,7 @@ func TestSplitChangesOlderSince(t *testing.T) { Once() var splitFetcher splitFetcherMock - splitFetcher.On("Fetch", int64(-1), ref(service.NewFetchOptions(true, nil))). + splitFetcher.On("Fetch", ref(*service.MakeFlagRequestParams().WithChangeNumber(-1))). Return(&dtos.SplitChangesDTO{Since: -1, Till: 1, Splits: []dtos.SplitDTO{{Name: "s1", Status: "ACTIVE"}, {Name: "s2", Status: "ACTIVE"}}}, nil). Once() @@ -103,7 +107,7 @@ func TestSplitChangesOlderSince(t *testing.T) { assert.Equal(t, 200, resp.Code) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) assert.Nil(t, err) var s dtos.SplitChangesDTO @@ -126,7 +130,7 @@ func TestSplitChangesOlderSinceFetchFails(t *testing.T) { Once() var splitFetcher splitFetcherMock - splitFetcher.On("Fetch", int64(-1), ref(service.NewFetchOptions(true, nil))). + splitFetcher.On("Fetch", ref(*service.MakeFlagRequestParams().WithChangeNumber(-1))). Return((*dtos.SplitChangesDTO)(nil), errors.New("something")). Once() @@ -192,7 +196,7 @@ func TestSplitChangesWithFlagSets(t *testing.T) { assert.Equal(t, 200, resp.Code) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) assert.Nil(t, err) var s dtos.SplitChangesDTO @@ -239,7 +243,7 @@ func TestSplitChangesWithFlagSetsStrict(t *testing.T) { assert.Equal(t, 200, resp.Code) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) assert.Nil(t, err) var s dtos.SplitChangesDTO @@ -252,6 +256,148 @@ func TestSplitChangesWithFlagSetsStrict(t *testing.T) { splitFetcher.AssertExpectations(t) } +func TestSplitChangesNewMatcherOldSpec(t *testing.T) { + gin.SetMode(gin.TestMode) + + var splitStorage psmocks.ProxySplitStorageMock + splitStorage.On("ChangesSince", int64(-1), []string(nil)). + Return(&dtos.SplitChangesDTO{ + Since: -1, + Till: 1, + Splits: []dtos.SplitDTO{ + { + Name: "s1", + Status: "ACTIVE", + Conditions: []dtos.ConditionDTO{ + { + MatcherGroup: dtos.MatcherGroupDTO{Matchers: []dtos.MatcherDTO{{MatcherType: matchers.MatcherTypeEndsWith}}}, + Partitions: []dtos.PartitionDTO{{Treatment: "on", Size: 100}}, + Label: "some label", + }, + { + MatcherGroup: dtos.MatcherGroupDTO{Matchers: []dtos.MatcherDTO{{MatcherType: matchers.MatcherTypeGreaterThanOrEqualToSemver}}}, + Partitions: []dtos.PartitionDTO{{Treatment: "on", Size: 100}}, + Label: "some label", + }, + }}, + }, + }, nil). + Once() + + var splitFetcher splitFetcherMock + + resp := httptest.NewRecorder() + ctx, router := gin.CreateTestContext(resp) + logger := logging.NewLogger(nil) + group := router.Group("/api") + controller := NewSdkServerController( + logger, + &splitFetcher, + &splitStorage, + nil, + flagsets.NewMatcher(false, nil), + ) + controller.Register(group) + + ctx.Request, _ = http.NewRequest(http.MethodGet, "/api/splitChanges?since=-1", nil) + ctx.Request.Header.Set("Authorization", "Bearer someApiKey") + ctx.Request.Header.Set("SplitSDKVersion", "go-1.1.1") + ctx.Request.Header.Set("SplitSDKMachineIp", "1.2.3.4") + ctx.Request.Header.Set("SplitSDKMachineName", "ip-1-2-3-4") + router.ServeHTTP(resp, ctx.Request) + + assert.Equal(t, 200, resp.Code) + + body, err := io.ReadAll(resp.Body) + assert.Nil(t, err) + + var s dtos.SplitChangesDTO + err = json.Unmarshal(body, &s) + assert.Nil(t, err) + assert.Equal(t, 1, len(s.Splits)) + assert.Equal(t, int64(-1), s.Since) + assert.Equal(t, int64(1), s.Till) + + assert.Equal(t, 1, len(s.Splits[0].Conditions)) + cond := s.Splits[0].Conditions[0] + assert.Equal(t, grammar.ConditionTypeWhitelist, cond.ConditionType) + assert.Equal(t, matchers.MatcherTypeAllKeys, cond.MatcherGroup.Matchers[0].MatcherType) + assert.Equal(t, impressionlabels.UnsupportedMatcherType, cond.Label) + assert.Equal(t, []dtos.PartitionDTO{{Treatment: "control", Size: 100}}, cond.Partitions) + + splitStorage.AssertExpectations(t) + splitFetcher.AssertExpectations(t) +} + +func TestSplitChangesNewMatcherNewSpec(t *testing.T) { + gin.SetMode(gin.TestMode) + + var splitStorage psmocks.ProxySplitStorageMock + splitStorage.On("ChangesSince", int64(-1), []string(nil)). + Return(&dtos.SplitChangesDTO{ + Since: -1, + Till: 1, + Splits: []dtos.SplitDTO{ + { + Name: "s1", + Status: "ACTIVE", + Conditions: []dtos.ConditionDTO{ + { + MatcherGroup: dtos.MatcherGroupDTO{Matchers: []dtos.MatcherDTO{{MatcherType: matchers.MatcherTypeGreaterThanOrEqualToSemver}}}, + Partitions: []dtos.PartitionDTO{{Treatment: "on", Size: 100}}, + Label: "some label", + }, + }}, + }, + }, nil). + Once() + + var splitFetcher splitFetcherMock + + resp := httptest.NewRecorder() + ctx, router := gin.CreateTestContext(resp) + logger := logging.NewLogger(nil) + group := router.Group("/api") + controller := NewSdkServerController( + logger, + &splitFetcher, + &splitStorage, + nil, + flagsets.NewMatcher(false, nil), + ) + controller.Register(group) + + ctx.Request, _ = http.NewRequest(http.MethodGet, "/api/splitChanges?since=-1", nil) + ctx.Request.Header.Set("Authorization", "Bearer someApiKey") + ctx.Request.Header.Set("SplitSDKVersion", "go-1.1.1") + ctx.Request.Header.Set("SplitSDKMachineIp", "1.2.3.4") + ctx.Request.Header.Set("SplitSDKMachineName", "ip-1-2-3-4") + q := ctx.Request.URL.Query() + q.Add("s", specs.FLAG_V1_1) + ctx.Request.URL.RawQuery = q.Encode() + router.ServeHTTP(resp, ctx.Request) + + assert.Equal(t, 200, resp.Code) + + body, err := io.ReadAll(resp.Body) + assert.Nil(t, err) + + var s dtos.SplitChangesDTO + err = json.Unmarshal(body, &s) + assert.Nil(t, err) + assert.Equal(t, 1, len(s.Splits)) + assert.Equal(t, int64(-1), s.Since) + assert.Equal(t, int64(1), s.Till) + + cond := s.Splits[0].Conditions[0] + assert.Equal(t, matchers.MatcherTypeGreaterThanOrEqualToSemver, cond.MatcherGroup.Matchers[0].MatcherType) + assert.Equal(t, "some label", cond.Label) + assert.Equal(t, []dtos.PartitionDTO{{Treatment: "on", Size: 100}}, cond.Partitions) + + splitStorage.AssertExpectations(t) + splitFetcher.AssertExpectations(t) +} + func TestSegmentChanges(t *testing.T) { gin.SetMode(gin.TestMode) @@ -280,7 +426,7 @@ func TestSegmentChanges(t *testing.T) { assert.Equal(t, 200, resp.Code) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) assert.Nil(t, err) var s dtos.SegmentChangesDTO @@ -353,7 +499,7 @@ func TestMySegments(t *testing.T) { router.ServeHTTP(resp, ctx.Request) assert.Equal(t, 200, resp.Code) - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) assert.Nil(t, err) var ms MSC @@ -404,8 +550,8 @@ type splitFetcherMock struct { } // Fetch implements service.SplitFetcher -func (s *splitFetcherMock) Fetch(changeNumber int64, fetchOptions *service.FetchOptions) (*dtos.SplitChangesDTO, error) { - args := s.Called(changeNumber, fetchOptions) +func (s *splitFetcherMock) Fetch(fetchOptions *service.FlagRequestParams) (*dtos.SplitChangesDTO, error) { + args := s.Called(fetchOptions) return args.Get(0).(*dtos.SplitChangesDTO), args.Error(1) } diff --git a/splitio/proxy/controllers/telemetry.go b/splitio/proxy/controllers/telemetry.go index a6b02c3c..545fcca7 100644 --- a/splitio/proxy/controllers/telemetry.go +++ b/splitio/proxy/controllers/telemetry.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/proxy/internal" diff --git a/splitio/proxy/controllers/telemetry_test.go b/splitio/proxy/controllers/telemetry_test.go index d67297a7..9dcb1722 100644 --- a/splitio/proxy/controllers/telemetry_test.go +++ b/splitio/proxy/controllers/telemetry_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/proxy/controllers/middleware" "github.com/splitio/split-synchronizer/v5/splitio/proxy/internal" diff --git a/splitio/proxy/controllers/util.go b/splitio/proxy/controllers/util.go index d5326362..2dc85f5e 100644 --- a/splitio/proxy/controllers/util.go +++ b/splitio/proxy/controllers/util.go @@ -2,8 +2,8 @@ package controllers import ( "github.com/gin-gonic/gin" - "github.com/splitio/go-split-commons/v5/conf" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/conf" + "github.com/splitio/go-split-commons/v6/dtos" ) func metadataFromHeaders(ctx *gin.Context) dtos.Metadata { diff --git a/splitio/proxy/initialization.go b/splitio/proxy/initialization.go index 80254925..5c8fd35c 100644 --- a/splitio/proxy/initialization.go +++ b/splitio/proxy/initialization.go @@ -9,12 +9,12 @@ import ( "strings" - "github.com/splitio/go-split-commons/v5/conf" - "github.com/splitio/go-split-commons/v5/flagsets" - "github.com/splitio/go-split-commons/v5/service/api" - "github.com/splitio/go-split-commons/v5/synchronizer" - "github.com/splitio/go-split-commons/v5/tasks" - "github.com/splitio/go-split-commons/v5/telemetry" + "github.com/splitio/go-split-commons/v6/conf" + "github.com/splitio/go-split-commons/v6/flagsets" + "github.com/splitio/go-split-commons/v6/service/api" + "github.com/splitio/go-split-commons/v6/synchronizer" + "github.com/splitio/go-split-commons/v6/tasks" + "github.com/splitio/go-split-commons/v6/telemetry" "github.com/splitio/go-toolkit/v5/backoff" "github.com/splitio/go-toolkit/v5/logging" @@ -72,6 +72,8 @@ func Start(logger logging.LoggerInterface, cfg *pconf.Main) error { // Getting initial config data advanced := cfg.BuildAdvancedConfig() advanced.FlagSetsFilter = cfg.FlagSetsFilter + advanced.AuthSpecVersion = cfg.FlagSpecVersion + advanced.FlagsSpecVersion = cfg.FlagSpecVersion metadata := util.GetMetadata(cfg.IPAddressEnabled, true) // FlagSetsFilter @@ -222,6 +224,7 @@ func Start(logger logging.LoggerInterface, cfg *pconf.Main) error { HcServicesMonitor: servicesMonitor, FullConfig: cfgForAdmin, TLS: adminTLSConfig, + FlagSpecVersion: cfg.FlagSpecVersion, }) if err != nil { return common.NewInitError(fmt.Errorf("error starting admin server: %w", err), common.ExitAdminError) diff --git a/splitio/proxy/initialization_test.go b/splitio/proxy/initialization_test.go index 37c5ad8a..cfe0c002 100644 --- a/splitio/proxy/initialization_test.go +++ b/splitio/proxy/initialization_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v5/synchronizer" + "github.com/splitio/go-split-commons/v6/synchronizer" ) type syncManagerMock struct { diff --git a/splitio/proxy/internal/dtos.go b/splitio/proxy/internal/dtos.go index 686fd036..73db37d2 100644 --- a/splitio/proxy/internal/dtos.go +++ b/splitio/proxy/internal/dtos.go @@ -1,7 +1,7 @@ package internal import ( - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" ) // RawData represents the raw data submitted by an sdk when posting data with associated metadata diff --git a/splitio/proxy/proxy.go b/splitio/proxy/proxy.go index 4aab8ea5..f11e2f43 100644 --- a/splitio/proxy/proxy.go +++ b/splitio/proxy/proxy.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/splitio/go-split-commons/v5/service" + "github.com/splitio/go-split-commons/v6/service" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener" diff --git a/splitio/proxy/proxy_test.go b/splitio/proxy/proxy_test.go index 5459081d..faad8614 100644 --- a/splitio/proxy/proxy_test.go +++ b/splitio/proxy/proxy_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v5/dtos" - serviceMocks "github.com/splitio/go-split-commons/v5/service/mocks" + "github.com/splitio/go-split-commons/v6/dtos" + serviceMocks "github.com/splitio/go-split-commons/v6/service/mocks" "github.com/splitio/go-toolkit/v5/logging" ilmock "github.com/splitio/split-synchronizer/v5/splitio/common/impressionlistener/mocks" "github.com/splitio/split-synchronizer/v5/splitio/proxy/caching" diff --git a/splitio/proxy/storage/mocks/mocks.go b/splitio/proxy/storage/mocks/mocks.go index 1228cc35..5910c7ca 100644 --- a/splitio/proxy/storage/mocks/mocks.go +++ b/splitio/proxy/storage/mocks/mocks.go @@ -1,7 +1,7 @@ package mocks import ( - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/stretchr/testify/mock" ) diff --git a/splitio/proxy/storage/optimized/historic.go b/splitio/proxy/storage/optimized/historic.go index b4264d1d..5a1f1d8e 100644 --- a/splitio/proxy/storage/optimized/historic.go +++ b/splitio/proxy/storage/optimized/historic.go @@ -6,7 +6,7 @@ import ( "strings" "sync" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" ) type HistoricChanges interface { diff --git a/splitio/proxy/storage/optimized/historic_test.go b/splitio/proxy/storage/optimized/historic_test.go index 6c826602..c1d4bb21 100644 --- a/splitio/proxy/storage/optimized/historic_test.go +++ b/splitio/proxy/storage/optimized/historic_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/stretchr/testify/assert" ) diff --git a/splitio/proxy/storage/optimized/mocks/mocks.go b/splitio/proxy/storage/optimized/mocks/mocks.go index 24160c0f..c738ab58 100644 --- a/splitio/proxy/storage/optimized/mocks/mocks.go +++ b/splitio/proxy/storage/optimized/mocks/mocks.go @@ -1,7 +1,7 @@ package mocks import ( - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/split-synchronizer/v5/splitio/proxy/storage/optimized" "github.com/stretchr/testify/mock" ) diff --git a/splitio/proxy/storage/persistent/splits.go b/splitio/proxy/storage/persistent/splits.go index 0b450950..093d5e28 100644 --- a/splitio/proxy/storage/persistent/splits.go +++ b/splitio/proxy/storage/persistent/splits.go @@ -6,7 +6,7 @@ import ( "encoding/json" "sync" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/proxy/storage/persistent/splits_test.go b/splitio/proxy/storage/persistent/splits_test.go index d6919a62..b9a29f77 100644 --- a/splitio/proxy/storage/persistent/splits_test.go +++ b/splitio/proxy/storage/persistent/splits_test.go @@ -3,7 +3,7 @@ package persistent import ( "testing" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/go-toolkit/v5/logging" ) diff --git a/splitio/proxy/storage/segments.go b/splitio/proxy/storage/segments.go index 48fe5bc3..a6a01c83 100644 --- a/splitio/proxy/storage/segments.go +++ b/splitio/proxy/storage/segments.go @@ -4,8 +4,8 @@ import ( "errors" "fmt" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/storage" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" diff --git a/splitio/proxy/storage/splits.go b/splitio/proxy/storage/splits.go index 1fed1965..9b3f2f8c 100644 --- a/splitio/proxy/storage/splits.go +++ b/splitio/proxy/storage/splits.go @@ -5,10 +5,10 @@ import ( "fmt" "sync" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/flagsets" - "github.com/splitio/go-split-commons/v5/storage" - "github.com/splitio/go-split-commons/v5/storage/inmemory/mutexmap" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/flagsets" + "github.com/splitio/go-split-commons/v6/storage" + "github.com/splitio/go-split-commons/v6/storage/inmemory/mutexmap" "github.com/splitio/go-toolkit/v5/datastructures/set" "github.com/splitio/go-toolkit/v5/logging" diff --git a/splitio/proxy/storage/splits_test.go b/splitio/proxy/storage/splits_test.go index 12fbefea..e2d1fa03 100644 --- a/splitio/proxy/storage/splits_test.go +++ b/splitio/proxy/storage/splits_test.go @@ -7,8 +7,8 @@ import ( "github.com/splitio/split-synchronizer/v5/splitio/proxy/storage/optimized/mocks" "github.com/splitio/split-synchronizer/v5/splitio/proxy/storage/persistent" - "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/flagsets" + "github.com/splitio/go-split-commons/v6/dtos" + "github.com/splitio/go-split-commons/v6/flagsets" "github.com/splitio/go-toolkit/v5/logging" "github.com/stretchr/testify/assert" diff --git a/splitio/proxy/storage/telemetry.go b/splitio/proxy/storage/telemetry.go index 341f9615..71dc46e9 100644 --- a/splitio/proxy/storage/telemetry.go +++ b/splitio/proxy/storage/telemetry.go @@ -4,9 +4,9 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v5/storage" - "github.com/splitio/go-split-commons/v5/storage/inmemory" - "github.com/splitio/go-split-commons/v5/telemetry" + "github.com/splitio/go-split-commons/v6/storage" + "github.com/splitio/go-split-commons/v6/storage/inmemory" + "github.com/splitio/go-split-commons/v6/telemetry" ) // Local telemetry constants diff --git a/splitio/proxy/storage/telemetryts.go b/splitio/proxy/storage/telemetryts.go index 2f5411b0..cca69e49 100644 --- a/splitio/proxy/storage/telemetryts.go +++ b/splitio/proxy/storage/telemetryts.go @@ -5,7 +5,7 @@ import ( "sync" "time" - "github.com/splitio/go-split-commons/v5/storage" + "github.com/splitio/go-split-commons/v6/storage" ) // Granularity selection constants to be used upon component instantiation diff --git a/splitio/proxy/tasks/deferred.go b/splitio/proxy/tasks/deferred.go index 571fed85..da73d5ab 100644 --- a/splitio/proxy/tasks/deferred.go +++ b/splitio/proxy/tasks/deferred.go @@ -4,7 +4,7 @@ import ( "errors" "sync" - "github.com/splitio/go-split-commons/v5/tasks" + "github.com/splitio/go-split-commons/v6/tasks" "github.com/splitio/go-toolkit/v5/asynctask" "github.com/splitio/go-toolkit/v5/logging" gtSync "github.com/splitio/go-toolkit/v5/sync" diff --git a/splitio/proxy/tasks/events.go b/splitio/proxy/tasks/events.go index 672f74d2..5d1a4d0a 100644 --- a/splitio/proxy/tasks/events.go +++ b/splitio/proxy/tasks/events.go @@ -3,7 +3,7 @@ package tasks import ( "fmt" - "github.com/splitio/go-split-commons/v5/service/api" + "github.com/splitio/go-split-commons/v6/service/api" "github.com/splitio/go-toolkit/v5/common" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/workerpool" diff --git a/splitio/proxy/tasks/impcount.go b/splitio/proxy/tasks/impcount.go index b5ffb0b9..87dea4b1 100644 --- a/splitio/proxy/tasks/impcount.go +++ b/splitio/proxy/tasks/impcount.go @@ -3,7 +3,7 @@ package tasks import ( "fmt" - "github.com/splitio/go-split-commons/v5/service/api" + "github.com/splitio/go-split-commons/v6/service/api" "github.com/splitio/go-toolkit/v5/common" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/workerpool" diff --git a/splitio/proxy/tasks/impressions.go b/splitio/proxy/tasks/impressions.go index bbf82d0a..cad05061 100644 --- a/splitio/proxy/tasks/impressions.go +++ b/splitio/proxy/tasks/impressions.go @@ -3,7 +3,7 @@ package tasks import ( "fmt" - "github.com/splitio/go-split-commons/v5/service/api" + "github.com/splitio/go-split-commons/v6/service/api" "github.com/splitio/go-toolkit/v5/common" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/workerpool" diff --git a/splitio/proxy/tasks/telemetry.go b/splitio/proxy/tasks/telemetry.go index a3e9edce..b030b7f9 100644 --- a/splitio/proxy/tasks/telemetry.go +++ b/splitio/proxy/tasks/telemetry.go @@ -3,7 +3,7 @@ package tasks import ( "fmt" - "github.com/splitio/go-split-commons/v5/service/api" + "github.com/splitio/go-split-commons/v6/service/api" "github.com/splitio/go-toolkit/v5/common" "github.com/splitio/go-toolkit/v5/logging" "github.com/splitio/go-toolkit/v5/workerpool" diff --git a/splitio/util/utils.go b/splitio/util/utils.go index 023b9971..b55ab558 100644 --- a/splitio/util/utils.go +++ b/splitio/util/utils.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v6/dtos" "github.com/splitio/go-toolkit/v5/hasher" "github.com/splitio/go-toolkit/v5/nethelpers" "github.com/splitio/split-synchronizer/v5/splitio" diff --git a/splitio/version.go b/splitio/version.go index 3cffdc2e..0e25613e 100644 --- a/splitio/version.go +++ b/splitio/version.go @@ -2,4 +2,4 @@ package splitio // Version is the version of this Agent -const Version = "5.7.0" +const Version = "5.8.0"