mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-11 14:54:34 -05:00
* fix fileutils.TestFindFile on MacOS * introduce model.ExternalServiceEnvironment * pick license public key from external service env * pick Stripe public key from external service env * pick Rudder key from external service env * configure Sentry DSN from external service env * always log external_service_environment, Unsetenv * clear faked BuildEnv, improve logging * strip out unset GOTAGS * fix Sentry tests * simplify to just ServiceEnvironment * relocate ServiceEnvironment in client config * initialize CWS URLs based on service environment * unset rudder key for boards dev * harden service environment to avoid accidental production * fix TestSentry again * fix DEFAULT -> ENTERPRISE * s/dev/test when naming playbooks rudder key * simplify boards rudder key switch * use uniform rudderKey variable names * retain compatibility with existing pipeline * reduce to just production/test * unit test with valid test license * simplify Playbooks telemetry initialization * restore dev service environment * emit ServiceEnvironment when running e2e tests
45 lines
1.8 KiB
Go
45 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()
|
|
}
|