mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Fix Vault parsing of booleans
This commit is contained in:
@@ -52,7 +52,7 @@ func makeAgent(t testing.TB, cb func(*Config)) (string, *Agent) {
|
||||
}
|
||||
conf.NodeName = fmt.Sprintf("Node %d", conf.Ports.RPC)
|
||||
conf.Consul = sconfig.DefaultConsulConfig()
|
||||
conf.Vault.Enabled = false
|
||||
conf.Vault.Enabled = new(bool)
|
||||
|
||||
// Tighten the Serf timing
|
||||
config.SerfConfig.MemberlistConfig.SuspicionMult = 2
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"github.com/hashicorp/go-checkpoint"
|
||||
"github.com/hashicorp/go-syslog"
|
||||
"github.com/hashicorp/logutils"
|
||||
"github.com/hashicorp/nomad/helper/flag-slice"
|
||||
"github.com/hashicorp/nomad/helper/flag-helpers"
|
||||
"github.com/hashicorp/nomad/helper/gated-writer"
|
||||
"github.com/hashicorp/nomad/nomad/structs/config"
|
||||
"github.com/hashicorp/scada-client/scada"
|
||||
@@ -79,8 +79,8 @@ func (c *Command) readConfig() *Config {
|
||||
// Server-only options
|
||||
flags.IntVar(&cmdConfig.Server.BootstrapExpect, "bootstrap-expect", 0, "")
|
||||
flags.BoolVar(&cmdConfig.Server.RejoinAfterLeave, "rejoin", false, "")
|
||||
flags.Var((*sliceflag.StringFlag)(&cmdConfig.Server.StartJoin), "join", "")
|
||||
flags.Var((*sliceflag.StringFlag)(&cmdConfig.Server.RetryJoin), "retry-join", "")
|
||||
flags.Var((*flaghelper.StringFlag)(&cmdConfig.Server.StartJoin), "join", "")
|
||||
flags.Var((*flaghelper.StringFlag)(&cmdConfig.Server.RetryJoin), "retry-join", "")
|
||||
flags.IntVar(&cmdConfig.Server.RetryMaxAttempts, "retry-max", 0, "")
|
||||
flags.StringVar(&cmdConfig.Server.RetryInterval, "retry-interval", "", "")
|
||||
|
||||
@@ -89,12 +89,12 @@ func (c *Command) readConfig() *Config {
|
||||
flags.StringVar(&cmdConfig.Client.AllocDir, "alloc-dir", "", "")
|
||||
flags.StringVar(&cmdConfig.Client.NodeClass, "node-class", "", "")
|
||||
flags.StringVar(&servers, "servers", "", "")
|
||||
flags.Var((*sliceflag.StringFlag)(&meta), "meta", "")
|
||||
flags.Var((*flaghelper.StringFlag)(&meta), "meta", "")
|
||||
flags.StringVar(&cmdConfig.Client.NetworkInterface, "network-interface", "", "")
|
||||
flags.IntVar(&cmdConfig.Client.NetworkSpeed, "network-speed", 0, "")
|
||||
|
||||
// General options
|
||||
flags.Var((*sliceflag.StringFlag)(&configPath), "config", "config")
|
||||
flags.Var((*flaghelper.StringFlag)(&configPath), "config", "config")
|
||||
flags.StringVar(&cmdConfig.BindAddr, "bind", "", "")
|
||||
flags.StringVar(&cmdConfig.Region, "region", "", "")
|
||||
flags.StringVar(&cmdConfig.DataDir, "data-dir", "", "")
|
||||
@@ -108,8 +108,14 @@ func (c *Command) readConfig() *Config {
|
||||
flags.StringVar(&cmdConfig.Atlas.Token, "atlas-token", "", "")
|
||||
|
||||
// Vault options
|
||||
flags.BoolVar(&cmdConfig.Vault.Enabled, "vault-enabled", false, "")
|
||||
flags.BoolVar(&cmdConfig.Vault.AllowUnauthenticated, "vault-allow-unauthenticated", false, "")
|
||||
flags.Var((flaghelper.FuncBoolVar)(func(b bool) error {
|
||||
cmdConfig.Vault.Enabled = &b
|
||||
return nil
|
||||
}), "vault-enabled", "")
|
||||
flags.Var((flaghelper.FuncBoolVar)(func(b bool) error {
|
||||
cmdConfig.Vault.AllowUnauthenticated = &b
|
||||
return nil
|
||||
}), "vault-allow-unauthenticated", "")
|
||||
flags.StringVar(&cmdConfig.Vault.Token, "vault-token", "", "")
|
||||
flags.StringVar(&cmdConfig.Vault.Addr, "vault-address", "", "")
|
||||
|
||||
|
||||
@@ -124,14 +124,14 @@ func TestConfig_Parse(t *testing.T) {
|
||||
},
|
||||
Vault: &config.VaultConfig{
|
||||
Addr: "127.0.0.1:9500",
|
||||
AllowUnauthenticated: true,
|
||||
Enabled: false,
|
||||
AllowUnauthenticated: &trueValue,
|
||||
Enabled: &falseValue,
|
||||
TLSCaFile: "/path/to/ca/file",
|
||||
TLSCaPath: "/path/to/ca",
|
||||
TLSCertFile: "/path/to/cert/file",
|
||||
TLSKeyFile: "/path/to/key/file",
|
||||
TLSServerName: "foobar",
|
||||
TLSSkipVerify: true,
|
||||
TLSSkipVerify: &trueValue,
|
||||
TaskTokenTTL: "1s",
|
||||
Token: "12345",
|
||||
},
|
||||
|
||||
@@ -12,6 +12,12 @@ import (
|
||||
"github.com/hashicorp/nomad/nomad/structs/config"
|
||||
)
|
||||
|
||||
var (
|
||||
// trueValue/falseValue are used to get a pointer to a boolean
|
||||
trueValue = true
|
||||
falseValue = false
|
||||
)
|
||||
|
||||
func TestConfig_Merge(t *testing.T) {
|
||||
c1 := &Config{
|
||||
Region: "global",
|
||||
@@ -97,14 +103,14 @@ func TestConfig_Merge(t *testing.T) {
|
||||
},
|
||||
Vault: &config.VaultConfig{
|
||||
Token: "1",
|
||||
AllowUnauthenticated: false,
|
||||
AllowUnauthenticated: &falseValue,
|
||||
TaskTokenTTL: "1",
|
||||
Addr: "1",
|
||||
TLSCaFile: "1",
|
||||
TLSCaPath: "1",
|
||||
TLSCertFile: "1",
|
||||
TLSKeyFile: "1",
|
||||
TLSSkipVerify: false,
|
||||
TLSSkipVerify: &falseValue,
|
||||
TLSServerName: "1",
|
||||
},
|
||||
Consul: &config.ConsulConfig{
|
||||
@@ -225,14 +231,14 @@ func TestConfig_Merge(t *testing.T) {
|
||||
},
|
||||
Vault: &config.VaultConfig{
|
||||
Token: "2",
|
||||
AllowUnauthenticated: true,
|
||||
AllowUnauthenticated: &trueValue,
|
||||
TaskTokenTTL: "2",
|
||||
Addr: "2",
|
||||
TLSCaFile: "2",
|
||||
TLSCaPath: "2",
|
||||
TLSCertFile: "2",
|
||||
TLSKeyFile: "2",
|
||||
TLSSkipVerify: true,
|
||||
TLSSkipVerify: &trueValue,
|
||||
TLSServerName: "2",
|
||||
},
|
||||
Consul: &config.ConsulConfig{
|
||||
|
||||
Reference in New Issue
Block a user