diff --git a/command/agent/config.go b/command/agent/config.go index 5b3357a34e..f0aba4247f 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -363,6 +363,10 @@ type Config struct { // to it's cluster. Requires Atlas integration. 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 // the agent attempts to reconcile it's local state with the server' // representation of our state. Defaults to every 60s. @@ -1056,6 +1060,9 @@ func MergeConfig(a, b *Config) *Config { if b.AtlasJoin { result.AtlasJoin = true } + if b.AtlasEndpoint != "" { + result.AtlasEndpoint = b.AtlasEndpoint + } if b.SessionTTLMinRaw != "" { result.SessionTTLMin = b.SessionTTLMin result.SessionTTLMinRaw = b.SessionTTLMinRaw diff --git a/command/agent/config_test.go b/command/agent/config_test.go index ed2a2921e0..37e0cf27dd 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -706,7 +706,13 @@ func TestDecodeConfig(t *testing.T) { } // 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))) if err != nil { t.Fatalf("err: %s", err) @@ -724,6 +730,9 @@ func TestDecodeConfig(t *testing.T) { if !config.AtlasJoin { t.Fatalf("bad: %#v", config) } + if config.AtlasEndpoint != "foo.bar:1111" { + t.Fatalf("bad: %#v", config) + } // SessionTTLMin input = `{"session_ttl_min": "5s"}` diff --git a/command/agent/scada.go b/command/agent/scada.go index 2fd3d543d9..7cd69e0238 100644 --- a/command/agent/scada.go +++ b/command/agent/scada.go @@ -47,6 +47,7 @@ func ProviderConfig(c *Config) *client.ProviderConfig { Handlers: map[string]client.CapabilityProvider{ "http": nil, }, + Endpoint: c.AtlasEndpoint, ResourceGroup: c.AtlasInfrastructure, Token: c.AtlasToken, } diff --git a/command/agent/scada_test.go b/command/agent/scada_test.go index e142f54ae5..bdd52be6e2 100644 --- a/command/agent/scada_test.go +++ b/command/agent/scada_test.go @@ -43,6 +43,7 @@ func TestProviderConfig(t *testing.T) { conf.Server = true conf.AtlasInfrastructure = "armon/test" conf.AtlasToken = "foobarbaz" + conf.AtlasEndpoint = "foo.bar:1111" pc := ProviderConfig(conf) expect := &client.ProviderConfig{ @@ -62,6 +63,7 @@ func TestProviderConfig(t *testing.T) { Handlers: map[string]client.CapabilityProvider{ "http": nil, }, + Endpoint: "foo.bar:1111", ResourceGroup: "armon/test", Token: "foobarbaz", }