Skip to content

Commit

Permalink
clean proxy logic to point commons
Browse files Browse the repository at this point in the history
  • Loading branch information
mmelograno committed May 3, 2024
1 parent ba224ea commit 098ae9f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docker/Dockerfile.proxy
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.synchronizer
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
13 changes: 2 additions & 11 deletions splitio/proxy/controllers/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion splitio/proxy/controllers/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 098ae9f

Please sign in to comment.