mirror of
https://github.com/status-im/consul.git
synced 2025-01-22 11:40:06 +00:00
agent: Adding atlas_join configuration
This commit is contained in:
parent
32aaee5185
commit
85a47ba584
@ -80,6 +80,7 @@ func (c *Command) readConfig() *Config {
|
||||
|
||||
cmdFlags.StringVar(&cmdConfig.AtlasCluster, "atlas-cluster", "", "cluster name in Atlas")
|
||||
cmdFlags.StringVar(&cmdConfig.AtlasToken, "atlas-token", "", "authentication token for Atlas")
|
||||
cmdFlags.BoolVar(&cmdConfig.AtlasJoin, "atlas-join", false, "auto-join with Atlas")
|
||||
|
||||
cmdFlags.IntVar(&cmdConfig.Protocol, "protocol", -1, "protocol version")
|
||||
|
||||
@ -842,6 +843,7 @@ Options:
|
||||
|
||||
-advertise=addr Sets the advertise address to use
|
||||
-atlas-cluster=org/name Sets the Atlas cluster name, enables SCADA.
|
||||
-atlas-join Enables auto-joining the Atlas cluster
|
||||
-atlas-token=token Provides the Atlas API token
|
||||
-bootstrap Sets server to bootstrap mode
|
||||
-bind=0.0.0.0 Sets the bind address for cluster communication
|
||||
|
@ -331,6 +331,10 @@ type Config struct {
|
||||
// to reduce the Atlas privileges to below that of the ACLToken.
|
||||
AtlasACLToken string `mapstructure:"atlas_acl_token"`
|
||||
|
||||
// AtlasJoin controls if Atlas will attempt to auto-join the node
|
||||
// to it's cluster. Requires Atlas integration.
|
||||
AtlasJoin bool `mapstructure:"atlas_join"`
|
||||
|
||||
// AEInterval controls the anti-entropy interval. This is how often
|
||||
// the agent attempts to reconcile it's local state with the server'
|
||||
// representation of our state. Defaults to every 60s.
|
||||
@ -963,6 +967,9 @@ func MergeConfig(a, b *Config) *Config {
|
||||
if b.AtlasACLToken != "" {
|
||||
result.AtlasACLToken = b.AtlasACLToken
|
||||
}
|
||||
if b.AtlasJoin {
|
||||
result.AtlasJoin = true
|
||||
}
|
||||
|
||||
if len(b.HTTPAPIResponseHeaders) != 0 {
|
||||
if result.HTTPAPIResponseHeaders == nil {
|
||||
|
@ -635,7 +635,7 @@ func TestDecodeConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
// Atlas configs
|
||||
input = `{"atlas_cluster": "hashicorp/prod", "atlas_token": "abcdefg", "atlas_acl_token": "123456789"}`
|
||||
input = `{"atlas_cluster": "hashicorp/prod", "atlas_token": "abcdefg", "atlas_acl_token": "123456789", "atlas_join": true}`
|
||||
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
@ -650,6 +650,9 @@ func TestDecodeConfig(t *testing.T) {
|
||||
if config.AtlasACLToken != "123456789" {
|
||||
t.Fatalf("bad: %#v", config)
|
||||
}
|
||||
if !config.AtlasJoin {
|
||||
t.Fatalf("bad: %#v", config)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeConfig_invalidKeys(t *testing.T) {
|
||||
@ -1116,6 +1119,7 @@ func TestMergeConfig(t *testing.T) {
|
||||
AtlasCluster: "hashicorp/prod",
|
||||
AtlasToken: "123456789",
|
||||
AtlasACLToken: "abcdefgh",
|
||||
AtlasJoin: true,
|
||||
}
|
||||
|
||||
c := MergeConfig(a, b)
|
||||
|
@ -36,7 +36,7 @@ func makeHTTPServerWithConfig(t *testing.T, cb func(c *Config)) (string, *HTTPSe
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
conf.UiDir = uiDir
|
||||
servers, err := NewHTTPServers(agent, conf, agent.logOutput)
|
||||
servers, err := NewHTTPServers(agent, conf, nil, agent.logOutput)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
@ -146,7 +146,7 @@ func TestHTTPServer_UnixSocket_FileExists(t *testing.T) {
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
// Try to start the server with the same path anyways.
|
||||
if _, err := NewHTTPServers(agent, conf, agent.logOutput); err != nil {
|
||||
if _, err := NewHTTPServers(agent, conf, nil, agent.logOutput); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user