Adds version info back into the config.
In #2191 I accedentally broke SCADA by not populating the agent's version information into the config structure. This adds it back, and makes the distinction between the raw parts we send to APIs and the human form of the version that we display.
This commit is contained in:
parent
33e9f42329
commit
9816c995bd
|
@ -38,18 +38,21 @@ var validDatacenter = regexp.MustCompile("^[a-zA-Z0-9_-]+$")
|
||||||
// ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly
|
// ShutdownCh. If two messages are sent on the ShutdownCh it will forcibly
|
||||||
// exit.
|
// exit.
|
||||||
type Command struct {
|
type Command struct {
|
||||||
Version string
|
Revision string
|
||||||
Ui cli.Ui
|
Version string
|
||||||
ShutdownCh <-chan struct{}
|
VersionPrerelease string
|
||||||
args []string
|
HumanVersion string
|
||||||
logFilter *logutils.LevelFilter
|
Ui cli.Ui
|
||||||
logOutput io.Writer
|
ShutdownCh <-chan struct{}
|
||||||
agent *Agent
|
args []string
|
||||||
rpcServer *AgentRPC
|
logFilter *logutils.LevelFilter
|
||||||
httpServers []*HTTPServer
|
logOutput io.Writer
|
||||||
dnsServer *DNSServer
|
agent *Agent
|
||||||
scadaProvider *scada.Provider
|
rpcServer *AgentRPC
|
||||||
scadaHttp *HTTPServer
|
httpServers []*HTTPServer
|
||||||
|
dnsServer *DNSServer
|
||||||
|
scadaProvider *scada.Provider
|
||||||
|
scadaHttp *HTTPServer
|
||||||
}
|
}
|
||||||
|
|
||||||
// readConfig is responsible for setup of our configuration using
|
// readConfig is responsible for setup of our configuration using
|
||||||
|
@ -309,6 +312,11 @@ func (c *Command) readConfig() *Config {
|
||||||
c.Ui.Error("WARNING: Bootstrap mode enabled! Do not enable unless necessary")
|
c.Ui.Error("WARNING: Bootstrap mode enabled! Do not enable unless necessary")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the version info
|
||||||
|
config.Revision = c.Revision
|
||||||
|
config.Version = c.Version
|
||||||
|
config.VersionPrerelease = c.VersionPrerelease
|
||||||
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
|
|
||||||
// VersionCommand is a Command implementation prints the version.
|
// VersionCommand is a Command implementation prints the version.
|
||||||
type VersionCommand struct {
|
type VersionCommand struct {
|
||||||
Version string
|
HumanVersion string
|
||||||
Ui cli.Ui
|
Ui cli.Ui
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *VersionCommand) Help() string {
|
func (c *VersionCommand) Help() string {
|
||||||
|
@ -17,7 +17,7 @@ func (c *VersionCommand) Help() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *VersionCommand) Run(_ []string) int {
|
func (c *VersionCommand) Run(_ []string) int {
|
||||||
c.Ui.Output(fmt.Sprintf("Consul Version: %s", c.Version))
|
c.Ui.Output(fmt.Sprintf("Consul Version: %s", c.HumanVersion))
|
||||||
c.Ui.Output(fmt.Sprintf("Supported Protocol Version(s): %d to %d",
|
c.Ui.Output(fmt.Sprintf("Supported Protocol Version(s): %d to %d",
|
||||||
consul.ProtocolVersionMin, consul.ProtocolVersionMax))
|
consul.ProtocolVersionMin, consul.ProtocolVersionMax))
|
||||||
return 0
|
return 0
|
||||||
|
|
13
commands.go
13
commands.go
|
@ -19,9 +19,12 @@ func init() {
|
||||||
Commands = map[string]cli.CommandFactory{
|
Commands = map[string]cli.CommandFactory{
|
||||||
"agent": func() (cli.Command, error) {
|
"agent": func() (cli.Command, error) {
|
||||||
return &agent.Command{
|
return &agent.Command{
|
||||||
Version: GetVersion(),
|
Revision: GitCommit,
|
||||||
Ui: ui,
|
Version: Version,
|
||||||
ShutdownCh: make(chan struct{}),
|
VersionPrerelease: VersionPrerelease,
|
||||||
|
HumanVersion: GetHumanVersion(),
|
||||||
|
Ui: ui,
|
||||||
|
ShutdownCh: make(chan struct{}),
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -120,8 +123,8 @@ func init() {
|
||||||
|
|
||||||
"version": func() (cli.Command, error) {
|
"version": func() (cli.Command, error) {
|
||||||
return &command.VersionCommand{
|
return &command.VersionCommand{
|
||||||
Version: GetVersion(),
|
HumanVersion: GetHumanVersion(),
|
||||||
Ui: ui,
|
Ui: ui,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,9 @@ const Version = "0.7.0"
|
||||||
// such as "dev" (in development), "beta", "rc1", etc.
|
// such as "dev" (in development), "beta", "rc1", etc.
|
||||||
const VersionPrerelease = "dev"
|
const VersionPrerelease = "dev"
|
||||||
|
|
||||||
// GetVersion returns the full version of Consul.
|
// GetHumanVersion composes the parts of the version in a way that's suitable
|
||||||
func GetVersion() string {
|
// for displaying to humans.
|
||||||
|
func GetHumanVersion() string {
|
||||||
version := Version
|
version := Version
|
||||||
if GitDescribe != "" {
|
if GitDescribe != "" {
|
||||||
version = GitDescribe
|
version = GitDescribe
|
||||||
|
|
Loading…
Reference in New Issue