mirror of https://github.com/status-im/consul.git
config: move acl_ttl to DeprecatedConfig
This commit is contained in:
parent
977f6d8888
commit
5c40b717ed
|
@ -856,7 +856,7 @@ func (b *builder) build() (rt RuntimeConfig, err error) {
|
|||
Datacenter: datacenter,
|
||||
NodeName: b.nodeName(c.NodeName),
|
||||
ACLPolicyTTL: b.durationVal("acl.policy_ttl", c.ACL.PolicyTTL),
|
||||
ACLTokenTTL: b.durationValWithDefault("acl.token_ttl", c.ACL.TokenTTL, b.durationVal("acl_ttl", c.ACLTTL)),
|
||||
ACLTokenTTL: b.durationVal("acl.token_ttl", c.ACL.TokenTTL),
|
||||
ACLRoleTTL: b.durationVal("acl.role_ttl", c.ACL.RoleTTL),
|
||||
ACLDownPolicy: stringVal(c.ACL.DownPolicy),
|
||||
ACLDefaultPolicy: stringVal(c.ACL.DefaultPolicy),
|
||||
|
|
|
@ -131,9 +131,7 @@ type Cache struct {
|
|||
// changed and refactored at will since this will break existing setups.
|
||||
type Config struct {
|
||||
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl" stanza
|
||||
ACLEnableKeyListPolicy *bool `mapstructure:"acl_enable_key_list_policy"`
|
||||
// DEPRECATED (ACL-Legacy-Compat) - moved into the "acl.tokens" stanza
|
||||
ACLTTL *string `mapstructure:"acl_ttl"`
|
||||
ACLEnableKeyListPolicy *bool `mapstructure:"acl_enable_key_list_policy"`
|
||||
ACL ACL `mapstructure:"acl"`
|
||||
Addresses Addresses `mapstructure:"addresses"`
|
||||
AdvertiseAddrLAN *string `mapstructure:"advertise_addr"`
|
||||
|
|
|
@ -27,8 +27,8 @@ func DefaultSource() Source {
|
|||
Name: "default",
|
||||
Format: "hcl",
|
||||
Data: `
|
||||
acl_ttl = "30s"
|
||||
acl = {
|
||||
token_ttl = "30s"
|
||||
policy_ttl = "30s"
|
||||
default_policy = "allow"
|
||||
down_policy = "extend-cache"
|
||||
|
|
|
@ -24,6 +24,8 @@ type DeprecatedConfig struct {
|
|||
ACLDefaultPolicy *string `mapstructure:"acl_default_policy"`
|
||||
// DEPRECATED (ACL-Legacy-Compat) - moved to "acl.down_policy"
|
||||
ACLDownPolicy *string `mapstructure:"acl_down_policy"`
|
||||
// DEPRECATED (ACL-Legacy-Compat) - moved to "acl.token_ttl"
|
||||
ACLTTL *string `mapstructure:"acl_ttl"`
|
||||
}
|
||||
|
||||
func applyDeprecatedConfig(d *decodeTarget) (Config, []string) {
|
||||
|
@ -97,6 +99,13 @@ func applyDeprecatedConfig(d *decodeTarget) (Config, []string) {
|
|||
warns = append(warns, deprecationWarning("acl_down_policy", "acl.down_policy"))
|
||||
}
|
||||
|
||||
if dep.ACLTTL != nil {
|
||||
if d.Config.ACL.TokenTTL == nil {
|
||||
d.Config.ACL.TokenTTL = dep.ACLTTL
|
||||
}
|
||||
warns = append(warns, deprecationWarning("acl_ttl", "acl.token_ttl"))
|
||||
}
|
||||
|
||||
return d.Config, warns
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package config
|
|||
import (
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -24,6 +25,8 @@ acl_replication_token = "token5"
|
|||
acl_default_policy = "deny"
|
||||
acl_down_policy = "async-cache"
|
||||
|
||||
acl_ttl = "3h"
|
||||
|
||||
`},
|
||||
}
|
||||
patchLoadOptsShims(&opts)
|
||||
|
@ -39,6 +42,7 @@ acl_down_policy = "async-cache"
|
|||
deprecationWarning("acl_master_token", "acl.tokens.master"),
|
||||
deprecationWarning("acl_replication_token", "acl.tokens.replication"),
|
||||
deprecationWarning("acl_token", "acl.tokens.default"),
|
||||
deprecationWarning("acl_ttl", "acl.token_ttl"),
|
||||
}
|
||||
sort.Strings(result.Warnings)
|
||||
require.Equal(t, expectWarns, result.Warnings)
|
||||
|
@ -56,6 +60,7 @@ acl_down_policy = "async-cache"
|
|||
require.Equal(t, "token5", rt.ACLTokens.ACLReplicationToken)
|
||||
require.Equal(t, "deny", rt.ACLResolverSettings.ACLDefaultPolicy)
|
||||
require.Equal(t, "async-cache", rt.ACLResolverSettings.ACLDownPolicy)
|
||||
require.Equal(t, 3*time.Hour, rt.ACLResolverSettings.ACLTokenTTL)
|
||||
}
|
||||
|
||||
func TestLoad_DeprecatedConfig_ACLReplication(t *testing.T) {
|
||||
|
|
|
@ -5923,6 +5923,7 @@ func TestLoad_FullConfig(t *testing.T) {
|
|||
deprecationWarning("enable_acl_replication", "acl.enable_token_replication"),
|
||||
deprecationWarning("acl_default_policy", "acl.default_policy"),
|
||||
deprecationWarning("acl_down_policy", "acl.down_policy"),
|
||||
deprecationWarning("acl_ttl", "acl.token_ttl"),
|
||||
`bootstrap_expect > 0: expecting 53 servers`,
|
||||
}
|
||||
expectedWarns = append(expectedWarns, enterpriseConfigKeyWarnings...)
|
||||
|
|
Loading…
Reference in New Issue