token: OSS support for enterprise tokens
This commit is contained in:
parent
8e477feb22
commit
9535a1b57d
|
@ -1078,10 +1078,8 @@ func (b *Builder) Build() (rt RuntimeConfig, err error) {
|
||||||
return RuntimeConfig{}, fmt.Errorf("cache.entry_fetch_rate must be strictly positive, was: %v", rt.Cache.EntryFetchRate)
|
return RuntimeConfig{}, fmt.Errorf("cache.entry_fetch_rate must be strictly positive, was: %v", rt.Cache.EntryFetchRate)
|
||||||
}
|
}
|
||||||
|
|
||||||
if entCfg, err := b.BuildEnterpriseRuntimeConfig(&c); err != nil {
|
if err := b.BuildEnterpriseRuntimeConfig(&rt, &c); err != nil {
|
||||||
return RuntimeConfig{}, err
|
return rt, err
|
||||||
} else {
|
|
||||||
rt.EnterpriseRuntimeConfig = entCfg
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if rt.BootstrapExpect == 1 {
|
if rt.BootstrapExpect == 1 {
|
||||||
|
@ -1369,7 +1367,8 @@ func (b *Builder) Validate(rt RuntimeConfig) error {
|
||||||
b.warn(err.Error())
|
b.warn(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
err := b.validateEnterpriseConfig(rt)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// addrUnique checks if the given address is already in use for another
|
// addrUnique checks if the given address is already in use for another
|
||||||
|
|
|
@ -51,8 +51,12 @@ func (e enterpriseConfigKeyError) Error() string {
|
||||||
return fmt.Sprintf("%q is a Consul Enterprise configuration and will have no effect", e.key)
|
return fmt.Sprintf("%q is a Consul Enterprise configuration and will have no effect", e.key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ *Builder) BuildEnterpriseRuntimeConfig(_ *Config) (EnterpriseRuntimeConfig, error) {
|
func (*Builder) BuildEnterpriseRuntimeConfig(_ *RuntimeConfig, _ *Config) error {
|
||||||
return EnterpriseRuntimeConfig{}, nil
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*Builder) validateEnterpriseConfig(_ RuntimeConfig) error {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// validateEnterpriseConfig is a function to validate the enterprise specific
|
// validateEnterpriseConfig is a function to validate the enterprise specific
|
||||||
|
|
|
@ -6,11 +6,9 @@ var entMetaJSON = `{}`
|
||||||
|
|
||||||
var entRuntimeConfigSanitize = `{}`
|
var entRuntimeConfigSanitize = `{}`
|
||||||
|
|
||||||
var entFullDNSJSONConfig = ``
|
var entTokenConfigSanitize = `"EnterpriseConfig": {},`
|
||||||
|
|
||||||
var entFullDNSHCLConfig = ``
|
func entFullRuntimeConfig(rt *RuntimeConfig) {}
|
||||||
|
|
||||||
var entFullRuntimeConfig = EnterpriseRuntimeConfig{}
|
|
||||||
|
|
||||||
var enterpriseNonVotingServerWarnings []string = []string{enterpriseConfigKeyError{key: "non_voting_server"}.Error()}
|
var enterpriseNonVotingServerWarnings []string = []string{enterpriseConfigKeyError{key: "non_voting_server"}.Error()}
|
||||||
|
|
||||||
|
|
|
@ -6497,9 +6497,10 @@ func TestFullConfig(t *testing.T) {
|
||||||
"args": []interface{}{"dltjDJ2a", "flEa7C2d"},
|
"args": []interface{}{"dltjDJ2a", "flEa7C2d"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
EnterpriseRuntimeConfig: entFullRuntimeConfig,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
entFullRuntimeConfig(&want)
|
||||||
|
|
||||||
warns := []string{
|
warns := []string{
|
||||||
`The 'acl_datacenter' field is deprecated. Use the 'primary_datacenter' field instead.`,
|
`The 'acl_datacenter' field is deprecated. Use the 'primary_datacenter' field instead.`,
|
||||||
`bootstrap_expect > 0: expecting 53 servers`,
|
`bootstrap_expect > 0: expecting 53 servers`,
|
||||||
|
@ -6817,6 +6818,7 @@ func TestSanitize(t *testing.T) {
|
||||||
|
|
||||||
rtJSON := `{
|
rtJSON := `{
|
||||||
"ACLTokens": {
|
"ACLTokens": {
|
||||||
|
` + entTokenConfigSanitize + `
|
||||||
"ACLAgentMasterToken": "hidden",
|
"ACLAgentMasterToken": "hidden",
|
||||||
"ACLAgentToken": "hidden",
|
"ACLAgentToken": "hidden",
|
||||||
"ACLDefaultToken": "hidden",
|
"ACLDefaultToken": "hidden",
|
||||||
|
|
|
@ -23,6 +23,8 @@ type Config struct {
|
||||||
ACLAgentToken string
|
ACLAgentToken string
|
||||||
ACLAgentMasterToken string
|
ACLAgentMasterToken string
|
||||||
ACLReplicationToken string
|
ACLReplicationToken string
|
||||||
|
|
||||||
|
EnterpriseConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokensPath = "acl-tokens.json"
|
const tokensPath = "acl-tokens.json"
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
package token
|
package token
|
||||||
|
|
||||||
|
type EnterpriseConfig struct {
|
||||||
|
}
|
||||||
|
|
||||||
// Stub for enterpriseTokens
|
// Stub for enterpriseTokens
|
||||||
type enterpriseTokens struct {
|
type enterpriseTokens struct {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue