Merge pull request #1201 from hashicorp/f-atlas-endpoint

Configurable Atlas endpoint
This commit is contained in:
Ryan Uber 2015-08-27 12:05:36 -07:00
commit c1c83c5d87
7 changed files with 66 additions and 30 deletions

View file

@ -87,6 +87,7 @@ func (c *Command) readConfig() *Config {
cmdFlags.StringVar(&cmdConfig.AtlasInfrastructure, "atlas", "", "infrastructure name in Atlas") cmdFlags.StringVar(&cmdConfig.AtlasInfrastructure, "atlas", "", "infrastructure name in Atlas")
cmdFlags.StringVar(&cmdConfig.AtlasToken, "atlas-token", "", "authentication token for Atlas") cmdFlags.StringVar(&cmdConfig.AtlasToken, "atlas-token", "", "authentication token for Atlas")
cmdFlags.BoolVar(&cmdConfig.AtlasJoin, "atlas-join", false, "auto-join with Atlas") cmdFlags.BoolVar(&cmdConfig.AtlasJoin, "atlas-join", false, "auto-join with Atlas")
cmdFlags.StringVar(&cmdConfig.AtlasEndpoint, "atlas-endpoint", "", "endpoint for Atlas integration")
cmdFlags.IntVar(&cmdConfig.Protocol, "protocol", -1, "protocol version") cmdFlags.IntVar(&cmdConfig.Protocol, "protocol", -1, "protocol version")
@ -962,6 +963,7 @@ Options:
-atlas=org/name Sets the Atlas infrastructure name, enables SCADA. -atlas=org/name Sets the Atlas infrastructure name, enables SCADA.
-atlas-join Enables auto-joining the Atlas cluster -atlas-join Enables auto-joining the Atlas cluster
-atlas-token=token Provides the Atlas API token -atlas-token=token Provides the Atlas API token
-atlas-endpoint=1.2.3.4 The address of the endpoint for Atlas integration.
-bootstrap Sets server to bootstrap mode -bootstrap Sets server to bootstrap mode
-bind=0.0.0.0 Sets the bind address for cluster communication -bind=0.0.0.0 Sets the bind address for cluster communication
-bootstrap-expect=0 Sets server to expect bootstrap mode. -bootstrap-expect=0 Sets server to expect bootstrap mode.

View file

@ -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

View file

@ -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"}`

View file

@ -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,
} }

View file

@ -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",
} }

View file

@ -21,21 +21,25 @@ GIT
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
activesupport (4.1.12) activesupport (4.2.4)
i18n (~> 0.6, >= 0.6.9) i18n (~> 0.7)
json (~> 1.7, >= 1.7.7) json (~> 1.7, >= 1.7.7)
minitest (~> 5.1) minitest (~> 5.1)
thread_safe (~> 0.1) thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1) tzinfo (~> 1.1)
autoprefixer-rails (5.2.1) autoprefixer-rails (5.2.1.3)
execjs execjs
json json
bootstrap-sass (3.3.5.1) bootstrap-sass (3.3.5.1)
autoprefixer-rails (>= 5.0.0.1) autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.3.0) sass (>= 3.3.0)
builder (3.2.2) builder (3.2.2)
celluloid (0.16.0) capybara (2.4.4)
timers (~> 4.0.0) mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
chunky_png (1.3.4) chunky_png (1.3.4)
coffee-script (2.4.1) coffee-script (2.4.1)
coffee-script-source coffee-script-source
@ -59,16 +63,15 @@ GEM
eventmachine (>= 0.12.9) eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0) http_parser.rb (~> 0.6.0)
erubis (2.7.0) erubis (2.7.0)
eventmachine (1.0.7) eventmachine (1.0.8)
execjs (2.5.2) execjs (2.6.0)
ffi (1.9.10) ffi (1.9.10)
git-version-bump (0.15.1) git-version-bump (0.15.1)
haml (4.0.6) haml (4.0.7)
tilt tilt
hike (1.2.3) hike (1.2.3)
hitimes (1.2.2) hooks (0.4.1)
hooks (0.4.0) uber (~> 0.0.14)
uber (~> 0.0.4)
htmlcompressor (0.2.0) htmlcompressor (0.2.0)
http_parser.rb (0.6.0) http_parser.rb (0.6.0)
i18n (0.7.0) i18n (0.7.0)
@ -77,34 +80,33 @@ GEM
less (2.6.0) less (2.6.0)
commonjs (~> 0.2.7) commonjs (~> 0.2.7)
libv8 (3.16.14.11) libv8 (3.16.14.11)
listen (2.10.1) listen (3.0.3)
celluloid (~> 0.16.0)
rb-fsevent (>= 0.9.3) rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9) rb-inotify (>= 0.9)
middleman (3.3.13) middleman (3.4.0)
coffee-script (~> 2.2) coffee-script (~> 2.2)
compass (>= 1.0.0, < 2.0.0) compass (>= 1.0.0, < 2.0.0)
compass-import-once (= 1.0.5) compass-import-once (= 1.0.5)
execjs (~> 2.0) execjs (~> 2.0)
haml (>= 4.0.5) haml (>= 4.0.5)
kramdown (~> 1.2) kramdown (~> 1.2)
middleman-core (= 3.3.13) middleman-core (= 3.4.0)
middleman-sprockets (>= 3.1.2) middleman-sprockets (>= 3.1.2)
sass (>= 3.4.0, < 4.0) sass (>= 3.4.0, < 4.0)
uglifier (~> 2.5) uglifier (~> 2.5)
middleman-core (3.3.13) middleman-core (3.4.0)
activesupport (~> 4.1.0) activesupport (~> 4.1)
bundler (~> 1.1) bundler (~> 1.1)
capybara (~> 2.4.4)
erubis erubis
hooks (~> 0.3) hooks (~> 0.3)
i18n (~> 0.7.0) i18n (~> 0.7.0)
listen (>= 2.7.9, < 3.0) listen (~> 3.0.3)
padrino-helpers (~> 0.12.3) padrino-helpers (~> 0.12.3)
rack (>= 1.4.5, < 2.0) rack (>= 1.4.5, < 2.0)
rack-test (~> 0.6.2)
thor (>= 0.15.2, < 2.0) thor (>= 0.15.2, < 2.0)
tilt (~> 1.4.1, < 2.0) tilt (~> 1.4.1, < 2.0)
middleman-livereload (3.4.2) middleman-livereload (3.4.3)
em-websocket (~> 0.5.1) em-websocket (~> 0.5.1)
middleman-core (>= 3.3) middleman-core (>= 3.3)
rack-livereload (~> 0.3.15) rack-livereload (~> 0.3.15)
@ -119,8 +121,12 @@ GEM
middleman-syntax (2.0.0) middleman-syntax (2.0.0)
middleman-core (~> 3.2) middleman-core (~> 3.2)
rouge (~> 1.0) rouge (~> 1.0)
minitest (5.7.0) mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.8.0)
multi_json (1.11.2) multi_json (1.11.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
padrino-helpers (0.12.5) padrino-helpers (0.12.5)
i18n (~> 0.6, >= 0.6.7) i18n (~> 0.6, >= 0.6.7)
padrino-support (= 0.12.5) padrino-support (= 0.12.5)
@ -128,7 +134,7 @@ GEM
padrino-support (0.12.5) padrino-support (0.12.5)
activesupport (>= 3.1) activesupport (>= 3.1)
rack (1.6.4) rack (1.6.4)
rack-contrib (1.3.0) rack-contrib (1.4.0)
git-version-bump (~> 0.15) git-version-bump (~> 0.15)
rack (~> 1.4) rack (~> 1.4)
rack-livereload (0.3.16) rack-livereload (0.3.16)
@ -136,7 +142,7 @@ GEM
rack-protection (1.5.3) rack-protection (1.5.3)
rack rack
rack-rewrite (1.5.1) rack-rewrite (1.5.1)
rack-ssl-enforcer (0.2.8) rack-ssl-enforcer (0.2.9)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
rb-fsevent (0.9.5) rb-fsevent (0.9.5)
@ -145,7 +151,7 @@ GEM
redcarpet (3.3.2) redcarpet (3.3.2)
ref (2.0.0) ref (2.0.0)
rouge (1.9.1) rouge (1.9.1)
sass (3.4.16) sass (3.4.18)
sprockets (2.12.4) sprockets (2.12.4)
hike (~> 1.2) hike (~> 1.2)
multi_json (~> 1.0) multi_json (~> 1.0)
@ -166,14 +172,14 @@ GEM
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (1.4.1) tilt (1.4.1)
timers (4.0.1)
hitimes
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
uber (0.0.13) uber (0.0.14)
uglifier (2.7.1) uglifier (2.7.2)
execjs (>= 0.3.0) execjs (>= 0.3.0)
json (>= 1.8.0) json (>= 1.8.0)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS PLATFORMS
ruby ruby

View file

@ -63,6 +63,11 @@ The options below are all specified on the command-line.
API authentication token. This can also be provided API authentication token. This can also be provided
using the `ATLAS_TOKEN` environment variable. Required for use with Atlas. using the `ATLAS_TOKEN` environment variable. Required for use with Atlas.
* <a name="_atlas_endpoint"></a><a href="#_atlas_endpoint">`-atlas-endpoint`</a> - The endpoint
address used for Atlas integration. Used only if the `-atlas` and
`-atlas-token` options are specified. This is optional, and defaults to the
public Atlas endpoints.
* <a name="_bootstrap"></a><a href="#_bootstrap">`-bootstrap`</a> - This flag is used to control if a * <a name="_bootstrap"></a><a href="#_bootstrap">`-bootstrap`</a> - This flag is used to control if a
server is in "bootstrap" mode. It is important that server is in "bootstrap" mode. It is important that
no more than one server *per* datacenter be running in this mode. Technically, a server in bootstrap mode no more than one server *per* datacenter be running in this mode. Technically, a server in bootstrap mode
@ -351,6 +356,9 @@ definitions support being updated during a reload.
* <a name="atlas_token"></a><a href="#atlas_token">`atlas_token`</a> Equivalent to the * <a name="atlas_token"></a><a href="#atlas_token">`atlas_token`</a> Equivalent to the
[`-atlas-token` command-line flag](#_atlas_token). [`-atlas-token` command-line flag](#_atlas_token).
* <a name="atlas_endpoint"></a><a href="#atlas_endpoint">`atlas_endpoint`</a> Equivalent to the
[`-atlas-endpoint` command-line flag](#_atlas_endpoint).
* <a name="bootstrap"></a><a href="#bootstrap">`bootstrap`</a> Equivalent to the * <a name="bootstrap"></a><a href="#bootstrap">`bootstrap`</a> Equivalent to the
[`-bootstrap` command-line flag](#_bootstrap). [`-bootstrap` command-line flag](#_bootstrap).
@ -645,3 +653,4 @@ items which are reloaded include:
* HTTP Client Address * HTTP Client Address
* Atlas Token * Atlas Token
* Atlas Infrastructure * Atlas Infrastructure
* Atlas Endpoint