Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package grammar
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/splitio/go-toolkit/v5/datastructures/set"
|
|
)
|
|
|
|
// PartOfSetMatcher matches if the set supplied to the getTreatment is a subset of the one in the feature flag
|
|
type PartOfSetMatcher struct {
|
|
Matcher
|
|
comparisonSet *set.ThreadUnsafeSet
|
|
}
|
|
|
|
// Match returns true if the match provided is a subset of the one in the feature flasg
|
|
func (m *PartOfSetMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool {
|
|
matchingKey, err := m.matchingKey(key, attributes)
|
|
if err != nil {
|
|
m.logger.Warning(fmt.Sprintf("PartOfSetMatcher: %s", err.Error()))
|
|
return false
|
|
}
|
|
|
|
conv, ok := matchingKey.([]string)
|
|
if !ok {
|
|
m.logger.Error("Unable to type-assert key to []string")
|
|
return false
|
|
}
|
|
|
|
matchingSet := set.NewSet()
|
|
for _, x := range conv {
|
|
matchingSet.Add(x)
|
|
}
|
|
|
|
if matchingSet.IsEmpty() {
|
|
return false
|
|
}
|
|
return m.comparisonSet.IsSubset(matchingSet)
|
|
}
|
|
|
|
// NewPartOfSetMatcher returns a pointer to a new instance of PartOfSetMatcher
|
|
func NewPartOfSetMatcher(negate bool, setItems []string, attributeName *string) *PartOfSetMatcher {
|
|
setObj := set.NewSet()
|
|
for _, item := range setItems {
|
|
setObj.Add(item)
|
|
}
|
|
|
|
return &PartOfSetMatcher{
|
|
Matcher: Matcher{
|
|
negate: negate,
|
|
attributeName: attributeName,
|
|
},
|
|
comparisonSet: setObj,
|
|
}
|
|
}
|