Skip to content

Commit

Permalink
moved sanitization for flagsets before setting the config
Browse files Browse the repository at this point in the history
  • Loading branch information
mmelograno committed Jan 17, 2024
1 parent 67fb0db commit 3f31174
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion splitio/commitsha.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package splitio

const CommitSHA = "0d2ade1"
const CommitSHA = "67fb0db"
13 changes: 13 additions & 0 deletions splitio/sdk/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"time"

"github.com/splitio/go-split-commons/v5/conf"
"github.com/splitio/go-split-commons/v5/dtos"
"github.com/splitio/go-split-commons/v5/flagsets"
)

const (
Expand Down Expand Up @@ -125,5 +127,16 @@ func (c *Config) Normalize() []string {
c.Impressions.SyncPeriod = minimumImpressionsRefreshRate
}

// Sanitize flagsets and append erros into warnings for logging purposes
sanitizedFlagSets, warns := flagsets.SanitizeMany(c.FlagSetsFilter)
if len(warns) != 0 {
for _, err := range warns {
if errType, ok := err.(dtos.FlagSetValidatonError); ok {
warnings = append(warnings, errType.Message)
}
}
}
c.FlagSetsFilter = sanitizedFlagSets

return warnings
}
10 changes: 1 addition & 9 deletions splitio/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,7 @@ func New(logger logging.LoggerInterface, apikey string, c *conf.Config) (*Impl,
md := dtos.Metadata{SDKVersion: fmt.Sprintf("splitd-%s", splitio.Version)}
advCfg := c.ToAdvancedConfig()

flagSets, errs := flagsets.SanitizeMany(advCfg.FlagSetsFilter)
if len(errs) != 0 {
for _, err := range errs {
if errType, ok := err.(dtos.FlagSetValidatonError); ok {
logger.Warning(errType.Message)
}
}
}
flagSetsFilter := flagsets.NewFlagSetFilter(flagSets)
flagSetsFilter := flagsets.NewFlagSetFilter(advCfg.FlagSetsFilter)

stores := setupStorages(c, flagSetsFilter)
impc, err := setupImpressionsComponents(&c.Impressions, stores.telemetry)
Expand Down

0 comments on commit 3f31174

Please sign in to comment.