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>
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package grammar
|
|
|
|
import (
|
|
"fmt"
|
|
"reflect"
|
|
"regexp"
|
|
)
|
|
|
|
// RegexMatcher matches if the supplied key matches the feature flag's regex
|
|
type RegexMatcher struct {
|
|
Matcher
|
|
regex string
|
|
}
|
|
|
|
// Match returns true if the supplied key matches the feature flag's regex
|
|
func (m *RegexMatcher) Match(key string, attributes map[string]interface{}, bucketingKey *string) bool {
|
|
matchingKey, err := m.matchingKey(key, attributes)
|
|
if err != nil {
|
|
m.logger.Warning(fmt.Sprintf("RegexMatcher: %s", err.Error()))
|
|
return false
|
|
}
|
|
|
|
conv, ok := matchingKey.(string)
|
|
if !ok {
|
|
m.logger.Error(
|
|
"RegexMatcher: Incorrect type. Expected string and received ",
|
|
reflect.TypeOf(matchingKey).String(),
|
|
)
|
|
return false
|
|
}
|
|
|
|
re, err := regexp.Compile(m.regex)
|
|
if err != nil {
|
|
m.logger.Error("RegexMatcher: Failed to compile regexp. ", err)
|
|
return false
|
|
}
|
|
return re.MatchString(conv)
|
|
}
|
|
|
|
// NewRegexMatcher returns a new instance to a RegexMatcher
|
|
func NewRegexMatcher(negate bool, regex string, attributeName *string) *RegexMatcher {
|
|
return &RegexMatcher{
|
|
Matcher: Matcher{
|
|
negate: negate,
|
|
attributeName: attributeName,
|
|
},
|
|
regex: regex,
|
|
}
|
|
}
|