Skip to content

Commit

Permalink
Merge pull request #4028 from hashicorp/f-checkpoint-oss
Browse files Browse the repository at this point in the history
Allow separate enterprise config overlay
  • Loading branch information
dadgar authored Mar 22, 2018
2 parents 4be0451 + 1ac3798 commit bb8f02d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
7 changes: 6 additions & 1 deletion command/agent/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ func (c *Command) readConfig() *Config {
} else {
config = DefaultConfig()
}

// Merge in the enterprise overlay
config.Merge(DefaultEntConfig())

for _, path := range configPath {
current, err := LoadConfig(path)
if err != nil {
Expand Down Expand Up @@ -383,7 +387,7 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer, inmem *metrics
c.httpServer = http

// Setup update checking
if !config.DisableUpdateCheck {
if config.DisableUpdateCheck != nil && *config.DisableUpdateCheck {
version := config.Version.Version
if config.Version.VersionPrerelease != "" {
version += fmt.Sprintf("-%s", config.Version.VersionPrerelease)
Expand All @@ -405,6 +409,7 @@ func (c *Command) setupAgent(config *Config, logOutput io.Writer, inmem *metrics
c.checkpointResults(checkpoint.Check(updateParams))
}()
}

return nil
}

Expand Down
15 changes: 8 additions & 7 deletions command/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type Config struct {

// DisableUpdateCheck is used to disable the periodic update
// and security bulletin checking.
DisableUpdateCheck bool `mapstructure:"disable_update_check"`
DisableUpdateCheck *bool `mapstructure:"disable_update_check"`

// DisableAnonymousSignature is used to disable setting the
// anonymous signature when doing the update check and looking
Expand Down Expand Up @@ -616,10 +616,11 @@ func DefaultConfig() *Config {
CollectionInterval: "1s",
collectionInterval: 1 * time.Second,
},
TLSConfig: &config.TLSConfig{},
Sentinel: &config.SentinelConfig{},
Version: version.GetVersion(),
Autopilot: config.DefaultAutopilotConfig(),
TLSConfig: &config.TLSConfig{},
Sentinel: &config.SentinelConfig{},
Version: version.GetVersion(),
Autopilot: config.DefaultAutopilotConfig(),
DisableUpdateCheck: helper.BoolToPtr(false),
}
}

Expand Down Expand Up @@ -685,8 +686,8 @@ func (c *Config) Merge(b *Config) *Config {
if b.SyslogFacility != "" {
result.SyslogFacility = b.SyslogFacility
}
if b.DisableUpdateCheck {
result.DisableUpdateCheck = true
if b.DisableUpdateCheck != nil {
result.DisableUpdateCheck = helper.BoolToPtr(*b.DisableUpdateCheck)
}
if b.DisableAnonymousSignature {
result.DisableAnonymousSignature = true
Expand Down
8 changes: 8 additions & 0 deletions command/agent/config_oss.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// +build !pro,!ent

package agent

// DefaultEntConfig is an empty config in open source
func DefaultEntConfig() *Config {
return &Config{}
}
2 changes: 1 addition & 1 deletion command/agent/config_parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func TestConfig_Parse(t *testing.T) {
LeaveOnTerm: true,
EnableSyslog: true,
SyslogFacility: "LOCAL1",
DisableUpdateCheck: true,
DisableUpdateCheck: helper.BoolToPtr(true),
DisableAnonymousSignature: true,
Consul: &config.ConsulConfig{
ServerServiceName: "nomad",
Expand Down
5 changes: 3 additions & 2 deletions command/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/hashicorp/consul/lib/freeport"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/hashicorp/nomad/nomad/structs/config"
)
Expand Down Expand Up @@ -49,7 +50,7 @@ func TestConfig_Merge(t *testing.T) {
LeaveOnTerm: false,
EnableSyslog: false,
SyslogFacility: "local0.info",
DisableUpdateCheck: false,
DisableUpdateCheck: helper.BoolToPtr(false),
DisableAnonymousSignature: false,
BindAddr: "127.0.0.1",
Telemetry: &Telemetry{
Expand Down Expand Up @@ -185,7 +186,7 @@ func TestConfig_Merge(t *testing.T) {
LeaveOnTerm: true,
EnableSyslog: true,
SyslogFacility: "local0.debug",
DisableUpdateCheck: true,
DisableUpdateCheck: helper.BoolToPtr(true),
DisableAnonymousSignature: true,
BindAddr: "127.0.0.2",
Telemetry: &Telemetry{
Expand Down

0 comments on commit bb8f02d

Please sign in to comment.