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>
46 lines
1.8 KiB
Go
46 lines
1.8 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
// ServiceEnvironmentProduction represents the production self-managed or cloud
|
|
// environments. This can be configured explicitly with MM_SERVICEENVIRONMENT explicitly
|
|
// set to "production", but is also the default for any production builds.
|
|
ServiceEnvironmentProduction = "production"
|
|
// ServiceEnvironmentTest represents testing environments in which MM_SERVICEENVIRONMENT
|
|
// is set explicitly to "test".
|
|
ServiceEnvironmentTest = "test"
|
|
// ServiceEnvironmentDev represents development environments. This can be configured
|
|
// explicitly with MM_SERVICEENVIRONMENT set to "dev", but is also the default for any
|
|
// non-production builds.
|
|
ServiceEnvironmentDev = "dev"
|
|
)
|
|
|
|
// GetServiceEnvironment returns the currently configured external service environment,
|
|
// deciding which public key is used to validate enterprise licenses, which telemetry keys are
|
|
// active, and which Stripe keys are in use.
|
|
//
|
|
// To configure an environment other than default, set MM_SERVICEENVIRONMENT before
|
|
// starting the application. Production builds default to ServiceEnvironmentProduction, and
|
|
// non-production builds default to ServiceEnvironmentDev.
|
|
//
|
|
// Note that this configuration is explicitly not part of the model.Config data structure, as it
|
|
// should never be persisted to the config store nor accidentally configured in any other way than
|
|
// the MM_SERVICEENVIRONMENT variable.
|
|
func GetServiceEnvironment() string {
|
|
externalServiceEnvironment := strings.TrimSpace(strings.ToLower(os.Getenv("MM_SERVICEENVIRONMENT")))
|
|
|
|
switch externalServiceEnvironment {
|
|
case ServiceEnvironmentProduction, ServiceEnvironmentTest, ServiceEnvironmentDev:
|
|
return externalServiceEnvironment
|
|
}
|
|
|
|
return getDefaultServiceEnvironment()
|
|
}
|