From 098ae9fb8a776acbe2f4bfbabdf5ceae0dadbbd3 Mon Sep 17 00:00:00 2001 From: Matias Melograno Date: Fri, 3 May 2024 13:04:32 -0300 Subject: [PATCH] clean proxy logic to point commons --- docker/Dockerfile.proxy | 4 ++-- docker/Dockerfile.synchronizer | 4 ++-- go.mod | 2 +- go.sum | 2 ++ splitio/proxy/controllers/sdk.go | 13 ++----------- splitio/proxy/controllers/sdk_test.go | 3 ++- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/docker/Dockerfile.proxy b/docker/Dockerfile.proxy index a47bbc5c..c96856b6 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.9-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..3ca5dcb1 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.9-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 0d7aacfe..222b81e7 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/google/uuid v1.3.0 github.com/splitio/gincache v1.0.1 - github.com/splitio/go-split-commons/v5 v5.2.2-0.20240502174052-97f050270ae1 + github.com/splitio/go-split-commons/v5 v5.2.2-0.20240503155951-b129e757301d github.com/splitio/go-toolkit/v5 v5.4.0 github.com/stretchr/testify v1.8.4 go.etcd.io/bbolt v1.3.6 diff --git a/go.sum b/go.sum index 16685c99..4ed80744 100644 --- a/go.sum +++ b/go.sum @@ -92,6 +92,8 @@ github.com/splitio/gincache v1.0.1 h1:dLYdANY/BqH4KcUMCe/LluLyV5WtuE/LEdQWRE06IX github.com/splitio/gincache v1.0.1/go.mod h1:CcgJDSM9Af75kyBH0724v55URVwMBuSj5x1eCWIOECY= github.com/splitio/go-split-commons/v5 v5.2.2-0.20240502174052-97f050270ae1 h1:ApuAWj2XxHobGXuoThhpPhuLI95Zkx1YmaQyKzSoQZw= github.com/splitio/go-split-commons/v5 v5.2.2-0.20240502174052-97f050270ae1/go.mod h1:344KP05ULARzjRfnC4VtGSyu5l3kmIM375WUIzrURs0= +github.com/splitio/go-split-commons/v5 v5.2.2-0.20240503155951-b129e757301d h1:E8mp3mB3jikxOQQacpC4xeAKtNhRQS4oRwU2ADEfSnw= +github.com/splitio/go-split-commons/v5 v5.2.2-0.20240503155951-b129e757301d/go.mod h1:344KP05ULARzjRfnC4VtGSyu5l3kmIM375WUIzrURs0= 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= diff --git a/splitio/proxy/controllers/sdk.go b/splitio/proxy/controllers/sdk.go index 86c40d10..afc1ca07 100644 --- a/splitio/proxy/controllers/sdk.go +++ b/splitio/proxy/controllers/sdk.go @@ -9,8 +9,7 @@ import ( "github.com/gin-gonic/gin" "github.com/splitio/go-split-commons/v5/dtos" - "github.com/splitio/go-split-commons/v5/engine/grammar" - "github.com/splitio/go-split-commons/v5/engine/grammar/matchers" + "github.com/splitio/go-split-commons/v5/engine/validator" "github.com/splitio/go-split-commons/v5/service" "github.com/splitio/go-split-commons/v5/service/api/specs" "github.com/splitio/go-toolkit/v5/logging" @@ -21,10 +20,6 @@ import ( "github.com/splitio/split-synchronizer/v5/splitio/proxy/storage" ) -const ( - labelUnsupportedMatcher = "targeting rule type unsupported by sdk" -) - // SdkServerController bundles all request handler for sdk-server apis type SdkServerController struct { logger logging.LoggerInterface @@ -165,11 +160,7 @@ func (c *SdkServerController) patchUnsupportedMatchers(splits []dtos.SplitDTO, v for ci := range splits[si].Conditions { for mi := range splits[si].Conditions[ci].MatcherGroup.Matchers { if c.versionFilter.ShouldFilter(splits[si].Conditions[ci].MatcherGroup.Matchers[mi].MatcherType, version) { - splits[si].Conditions[ci].ConditionType = grammar.ConditionTypeWhitelist - splits[si].Conditions[ci].MatcherGroup.Matchers[mi].MatcherType = matchers.MatcherTypeAllKeys - splits[si].Conditions[ci].MatcherGroup.Matchers[mi].String = nil - splits[si].Conditions[ci].Label = labelUnsupportedMatcher - splits[si].Conditions[ci].Partitions = []dtos.PartitionDTO{{Treatment: "control", Size: 100}} + validator.OverrideWithUnsupported(&splits[si], ci, mi) } } } diff --git a/splitio/proxy/controllers/sdk_test.go b/splitio/proxy/controllers/sdk_test.go index 2f55552d..1dc62071 100644 --- a/splitio/proxy/controllers/sdk_test.go +++ b/splitio/proxy/controllers/sdk_test.go @@ -10,6 +10,7 @@ import ( "github.com/gin-gonic/gin" "github.com/splitio/go-split-commons/v5/dtos" + "github.com/splitio/go-split-commons/v5/engine/evaluator/impressionlabels" "github.com/splitio/go-split-commons/v5/engine/grammar" "github.com/splitio/go-split-commons/v5/engine/grammar/matchers" "github.com/splitio/go-split-commons/v5/service" @@ -315,7 +316,7 @@ func TestSplitChangesNewMatcherOldSpec(t *testing.T) { 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, labelUnsupportedMatcher, cond.Label) + assert.Equal(t, impressionlabels.UnsupportedMatcherType, cond.Label) assert.Equal(t, []dtos.PartitionDTO{{Treatment: "control", Size: 100}}, cond.Partitions) splitStorage.AssertExpectations(t)