mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
command/server: can set advertise addr
This commit is contained in:
@@ -94,6 +94,7 @@ func (c *ServerCommand) Run(args []string) int {
|
||||
|
||||
// Initialize the core
|
||||
core, err := vault.NewCore(&vault.CoreConfig{
|
||||
AdvertiseAddr: config.Backend.AdvertiseAddr,
|
||||
Physical: backend,
|
||||
AuditBackends: c.AuditBackends,
|
||||
CredentialBackends: c.CredentialBackends,
|
||||
|
||||
@@ -14,10 +14,11 @@ import (
|
||||
|
||||
// Config is the configuration for the vault server.
|
||||
type Config struct {
|
||||
Listeners []*Listener `hcl:"-"`
|
||||
Backend *Backend `hcl:"-"`
|
||||
StatsiteAddr string `hcl:"statsite_addr"`
|
||||
StatsdAddr string `hcl:"statsd_addr"`
|
||||
Listeners []*Listener `hcl:"-"`
|
||||
Backend *Backend `hcl:"-"`
|
||||
|
||||
StatsiteAddr string `hcl:"statsite_addr"`
|
||||
StatsdAddr string `hcl:"statsd_addr"`
|
||||
}
|
||||
|
||||
// DevConfig is a Config that is used for dev mode of Vault.
|
||||
@@ -50,8 +51,9 @@ func (l *Listener) GoString() string {
|
||||
|
||||
// Backend is the backend configuration for the server.
|
||||
type Backend struct {
|
||||
Type string
|
||||
Config map[string]string
|
||||
Type string
|
||||
AdvertiseAddr string
|
||||
Config map[string]string
|
||||
}
|
||||
|
||||
func (b *Backend) GoString() string {
|
||||
@@ -306,6 +308,11 @@ func loadBackend(os *hclobj.Object) (*Backend, error) {
|
||||
err)
|
||||
}
|
||||
|
||||
if v, ok := config["advertise_addr"]; ok {
|
||||
result.AdvertiseAddr = v
|
||||
delete(config, "advertise_addr")
|
||||
}
|
||||
|
||||
result.Config = config
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ func TestLoadConfigFile(t *testing.T) {
|
||||
},
|
||||
|
||||
Backend: &Backend{
|
||||
Type: "consul",
|
||||
Type: "consul",
|
||||
AdvertiseAddr: "foo",
|
||||
Config: map[string]string{
|
||||
"foo": "bar",
|
||||
},
|
||||
|
||||
@@ -7,4 +7,5 @@ listener "tcp" {
|
||||
|
||||
backend "consul" {
|
||||
foo = "bar"
|
||||
advertise_addr = "foo"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user