Add OSS bits for supporting specifying the enterprise license via config

This commit is contained in:
Matt Keeler 2021-05-10 10:10:39 -04:00 committed by Matt Keeler
parent bd84c94e4f
commit 84c6c56578
7 changed files with 20 additions and 0 deletions

3
.changelog/10210.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
licensing: **(Enterprise Only)** Consul Enterprise has gained the ability to autoload a license via configuration. This can be specified with the `license_path` configuration, the `CONSUL_LICENSE` environment variable or the `CONSUL_LICENSE_PATH` environment variable
```

View File

@ -49,6 +49,10 @@ func validateEnterpriseConfigKeys(config *Config) []error {
if boolVal(config.Audit.Enabled) || len(config.Audit.Sinks) > 0 {
add("audit")
}
if config.LicensePath != nil {
add("license_path")
config.LicensePath = nil
}
return result
}

View File

@ -97,6 +97,15 @@ func TestValidateEnterpriseConfigKeys(t *testing.T) {
require.Nil(t, c.ACL.Tokens.ManagedServiceProvider)
},
},
"license_path": {
config: Config{
LicensePath: &stringVal,
},
badKeys: []string{"license_path"},
check: func(t *testing.T, c *Config) {
require.Empty(t, c.LicensePath)
},
},
"multi": {
config: Config{
ReadReplica: &boolVal,

View File

@ -187,6 +187,7 @@ type Config struct {
HTTPConfig HTTPConfig `mapstructure:"http_config"`
KeyFile *string `mapstructure:"key_file"`
LeaveOnTerm *bool `mapstructure:"leave_on_terminate"`
LicensePath *string `mapstructure:"license_path"`
Limits Limits `mapstructure:"limits"`
LogLevel *string `mapstructure:"log_level"`
LogJSON *bool `mapstructure:"log_json"`

View File

@ -9,6 +9,7 @@ func entFullRuntimeConfig(rt *RuntimeConfig) {}
var enterpriseReadReplicaWarnings = []string{enterpriseConfigKeyError{key: "read_replica (or the deprecated non_voting_server)"}.Error()}
var enterpriseConfigKeyWarnings = []string{
enterpriseConfigKeyError{key: "license_path"}.Error(),
enterpriseConfigKeyError{key: "read_replica (or the deprecated non_voting_server)"}.Error(),
enterpriseConfigKeyError{key: "autopilot.redundancy_zone_tag"}.Error(),
enterpriseConfigKeyError{key: "autopilot.upgrade_version_tag"}.Error(),

View File

@ -277,6 +277,7 @@ http_config {
}
key_file = "IEkkwgIA"
leave_on_terminate = true
license_path = "/path/to/license.lic"
limits {
http_max_conns_per_client = 100
https_handshake_timeout = "2391ms"

View File

@ -277,6 +277,7 @@
},
"key_file": "IEkkwgIA",
"leave_on_terminate": true,
"license_path": "/path/to/license.lic",
"limits": {
"http_max_conns_per_client": 100,
"https_handshake_timeout": "2391ms",