mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
Build date in config file
Signed-off-by: Mark Anderson <manderson@hashicorp.com>
This commit is contained in:
parent
4cd42a2e1f
commit
ec060e5e37
@ -804,6 +804,8 @@ func (b *builder) build() (rt RuntimeConfig, err error) {
|
||||
Version: stringVal(c.Version),
|
||||
VersionPrerelease: stringVal(c.VersionPrerelease),
|
||||
VersionMetadata: stringVal(c.VersionMetadata),
|
||||
// What is a sensible default for BuildDate?
|
||||
BuildDate: timeValWithDefault(c.BuildDate, time.Now()),
|
||||
|
||||
// consul configuration
|
||||
ConsulCoordinateUpdateBatchSize: intVal(c.Consul.Coordinate.UpdateBatchSize),
|
||||
@ -1946,6 +1948,13 @@ func stringVal(v *string) string {
|
||||
return *v
|
||||
}
|
||||
|
||||
func timeValWithDefault(v *time.Time, defaultVal time.Time) time.Time {
|
||||
if v == nil {
|
||||
return defaultVal
|
||||
}
|
||||
return *v
|
||||
}
|
||||
|
||||
func float64ValWithDefault(v *float64, defaultVal float64) float64 {
|
||||
if v == nil {
|
||||
return defaultVal
|
||||
|
@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/consul/agent/consul"
|
||||
|
||||
@ -261,18 +262,19 @@ type Config struct {
|
||||
SnapshotAgent map[string]interface{} `mapstructure:"snapshot_agent"`
|
||||
|
||||
// non-user configurable values
|
||||
AEInterval *string `mapstructure:"ae_interval"`
|
||||
CheckDeregisterIntervalMin *string `mapstructure:"check_deregister_interval_min"`
|
||||
CheckReapInterval *string `mapstructure:"check_reap_interval"`
|
||||
Consul Consul `mapstructure:"consul"`
|
||||
Revision *string `mapstructure:"revision"`
|
||||
SegmentLimit *int `mapstructure:"segment_limit"`
|
||||
SegmentNameLimit *int `mapstructure:"segment_name_limit"`
|
||||
SyncCoordinateIntervalMin *string `mapstructure:"sync_coordinate_interval_min"`
|
||||
SyncCoordinateRateTarget *float64 `mapstructure:"sync_coordinate_rate_target"`
|
||||
Version *string `mapstructure:"version"`
|
||||
VersionPrerelease *string `mapstructure:"version_prerelease"`
|
||||
VersionMetadata *string `mapstructure:"version_metadata"`
|
||||
AEInterval *string `mapstructure:"ae_interval"`
|
||||
CheckDeregisterIntervalMin *string `mapstructure:"check_deregister_interval_min"`
|
||||
CheckReapInterval *string `mapstructure:"check_reap_interval"`
|
||||
Consul Consul `mapstructure:"consul"`
|
||||
Revision *string `mapstructure:"revision"`
|
||||
SegmentLimit *int `mapstructure:"segment_limit"`
|
||||
SegmentNameLimit *int `mapstructure:"segment_name_limit"`
|
||||
SyncCoordinateIntervalMin *string `mapstructure:"sync_coordinate_interval_min"`
|
||||
SyncCoordinateRateTarget *float64 `mapstructure:"sync_coordinate_rate_target"`
|
||||
Version *string `mapstructure:"version"`
|
||||
VersionPrerelease *string `mapstructure:"version_prerelease"`
|
||||
VersionMetadata *string `mapstructure:"version_metadata"`
|
||||
BuildDate *time.Time `mapstructure:"build_date"`
|
||||
|
||||
// Enterprise Only
|
||||
Audit Audit `mapstructure:"audit"`
|
||||
|
@ -2,6 +2,7 @@ package config
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/raft"
|
||||
|
||||
@ -197,8 +198,8 @@ func NonUserSource() Source {
|
||||
|
||||
# SegmentNameLimit is the maximum segment name length.
|
||||
segment_name_limit = 64
|
||||
|
||||
connect = {
|
||||
|
||||
connect = {
|
||||
# 0s causes the value to be ignored and operate without capping
|
||||
# the max time before leaf certs can be generated after a roots change.
|
||||
test_ca_leaf_root_change_spread = "0s"
|
||||
@ -210,7 +211,7 @@ func NonUserSource() Source {
|
||||
// versionSource creates a config source for the version parameters.
|
||||
// This should be merged in the tail since these values are not
|
||||
// user configurable.
|
||||
func versionSource(rev, ver, verPre, meta string) Source {
|
||||
func versionSource(rev, ver, verPre, meta string, buildDate time.Time) Source {
|
||||
return LiteralSource{
|
||||
Name: "version",
|
||||
Config: Config{
|
||||
@ -218,6 +219,7 @@ func versionSource(rev, ver, verPre, meta string) Source {
|
||||
Version: &ver,
|
||||
VersionPrerelease: &verPre,
|
||||
VersionMetadata: &meta,
|
||||
BuildDate: &buildDate,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -225,7 +227,8 @@ func versionSource(rev, ver, verPre, meta string) Source {
|
||||
// defaultVersionSource returns the version config source for the embedded
|
||||
// version numbers.
|
||||
func defaultVersionSource() Source {
|
||||
return versionSource(version.GitCommit, version.Version, version.VersionPrerelease, version.VersionMetadata)
|
||||
buildDate, _ := time.Parse(time.RFC3339, version.BuildDate) // This has been checked elsewhere
|
||||
return versionSource(version.GitCommit, version.Version, version.VersionPrerelease, version.VersionMetadata, buildDate)
|
||||
}
|
||||
|
||||
// DefaultConsulSource returns the default configuration for the consul agent.
|
||||
|
@ -62,6 +62,7 @@ type RuntimeConfig struct {
|
||||
Version string
|
||||
VersionPrerelease string
|
||||
VersionMetadata string
|
||||
BuildDate time.Time
|
||||
|
||||
// consul config
|
||||
ConsulCoordinateUpdateMaxBatches int
|
||||
|
Loading…
x
Reference in New Issue
Block a user