mirror of
https://github.com/status-im/consul.git
synced 2025-02-16 23:57:07 +00:00
agent: atlas_endpoint is configurable
This commit is contained in:
parent
b0fcb6c234
commit
1cc2429364
@ -363,6 +363,10 @@ type Config struct {
|
|||||||
// to it's cluster. Requires Atlas integration.
|
// to it's cluster. Requires Atlas integration.
|
||||||
AtlasJoin bool `mapstructure:"atlas_join"`
|
AtlasJoin bool `mapstructure:"atlas_join"`
|
||||||
|
|
||||||
|
// AtlasEndpoint is the SCADA endpoint used for Atlas integration. If
|
||||||
|
// empty, the defaults from the provider are used.
|
||||||
|
AtlasEndpoint string `mapstructure:"atlas_endpoint"`
|
||||||
|
|
||||||
// AEInterval controls the anti-entropy interval. This is how often
|
// AEInterval controls the anti-entropy interval. This is how often
|
||||||
// the agent attempts to reconcile it's local state with the server'
|
// the agent attempts to reconcile it's local state with the server'
|
||||||
// representation of our state. Defaults to every 60s.
|
// representation of our state. Defaults to every 60s.
|
||||||
@ -1056,6 +1060,9 @@ func MergeConfig(a, b *Config) *Config {
|
|||||||
if b.AtlasJoin {
|
if b.AtlasJoin {
|
||||||
result.AtlasJoin = true
|
result.AtlasJoin = true
|
||||||
}
|
}
|
||||||
|
if b.AtlasEndpoint != "" {
|
||||||
|
result.AtlasEndpoint = b.AtlasEndpoint
|
||||||
|
}
|
||||||
if b.SessionTTLMinRaw != "" {
|
if b.SessionTTLMinRaw != "" {
|
||||||
result.SessionTTLMin = b.SessionTTLMin
|
result.SessionTTLMin = b.SessionTTLMin
|
||||||
result.SessionTTLMinRaw = b.SessionTTLMinRaw
|
result.SessionTTLMinRaw = b.SessionTTLMinRaw
|
||||||
|
@ -706,7 +706,13 @@ func TestDecodeConfig(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Atlas configs
|
// Atlas configs
|
||||||
input = `{"atlas_infrastructure": "hashicorp/prod", "atlas_token": "abcdefg", "atlas_acl_token": "123456789", "atlas_join": true}`
|
input = `{
|
||||||
|
"atlas_infrastructure": "hashicorp/prod",
|
||||||
|
"atlas_token": "abcdefg",
|
||||||
|
"atlas_acl_token": "123456789",
|
||||||
|
"atlas_join": true,
|
||||||
|
"atlas_endpoint": "foo.bar:1111"
|
||||||
|
}`
|
||||||
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
t.Fatalf("err: %s", err)
|
||||||
@ -724,6 +730,9 @@ func TestDecodeConfig(t *testing.T) {
|
|||||||
if !config.AtlasJoin {
|
if !config.AtlasJoin {
|
||||||
t.Fatalf("bad: %#v", config)
|
t.Fatalf("bad: %#v", config)
|
||||||
}
|
}
|
||||||
|
if config.AtlasEndpoint != "foo.bar:1111" {
|
||||||
|
t.Fatalf("bad: %#v", config)
|
||||||
|
}
|
||||||
|
|
||||||
// SessionTTLMin
|
// SessionTTLMin
|
||||||
input = `{"session_ttl_min": "5s"}`
|
input = `{"session_ttl_min": "5s"}`
|
||||||
|
@ -47,6 +47,7 @@ func ProviderConfig(c *Config) *client.ProviderConfig {
|
|||||||
Handlers: map[string]client.CapabilityProvider{
|
Handlers: map[string]client.CapabilityProvider{
|
||||||
"http": nil,
|
"http": nil,
|
||||||
},
|
},
|
||||||
|
Endpoint: c.AtlasEndpoint,
|
||||||
ResourceGroup: c.AtlasInfrastructure,
|
ResourceGroup: c.AtlasInfrastructure,
|
||||||
Token: c.AtlasToken,
|
Token: c.AtlasToken,
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ func TestProviderConfig(t *testing.T) {
|
|||||||
conf.Server = true
|
conf.Server = true
|
||||||
conf.AtlasInfrastructure = "armon/test"
|
conf.AtlasInfrastructure = "armon/test"
|
||||||
conf.AtlasToken = "foobarbaz"
|
conf.AtlasToken = "foobarbaz"
|
||||||
|
conf.AtlasEndpoint = "foo.bar:1111"
|
||||||
pc := ProviderConfig(conf)
|
pc := ProviderConfig(conf)
|
||||||
|
|
||||||
expect := &client.ProviderConfig{
|
expect := &client.ProviderConfig{
|
||||||
@ -62,6 +63,7 @@ func TestProviderConfig(t *testing.T) {
|
|||||||
Handlers: map[string]client.CapabilityProvider{
|
Handlers: map[string]client.CapabilityProvider{
|
||||||
"http": nil,
|
"http": nil,
|
||||||
},
|
},
|
||||||
|
Endpoint: "foo.bar:1111",
|
||||||
ResourceGroup: "armon/test",
|
ResourceGroup: "armon/test",
|
||||||
Token: "foobarbaz",
|
Token: "foobarbaz",
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user