Pull Version down into enterprise service
We need to report the current version, but it's only available as a link-time variable in the main package. Since we can't import this without incurring the wrath of the Go compiler's no-circular dependency rule, we need to pull this down through the agent.
This commit is contained in:
@@ -21,18 +21,20 @@ type Service struct {
|
||||
hosts []*client.Host
|
||||
logger *log.Logger
|
||||
hostname string
|
||||
version string
|
||||
adminPort string
|
||||
|
||||
shutdown chan struct{}
|
||||
}
|
||||
|
||||
func NewEnterprise(c Config, hostname string, shutdown chan struct{}) *Service {
|
||||
func NewEnterprise(c Config, hostname, version string, shutdown chan struct{}) *Service {
|
||||
return &Service{
|
||||
hosts: c.Hosts,
|
||||
hostname: hostname,
|
||||
logger: log.New(os.Stdout, "[enterprise]", log.Ldate|log.Ltime),
|
||||
adminPort: fmt.Sprintf(":%d", c.AdminPort),
|
||||
shutdown: shutdown,
|
||||
version: version,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +62,7 @@ func (s *Service) registerProduct(cl *client.Client) (token string, secret strin
|
||||
Host: s.hostname,
|
||||
ClusterID: "8675309",
|
||||
Name: "telegraf",
|
||||
Version: "0.10.1.dev",
|
||||
Version: s.version,
|
||||
AdminURL: "http://" + s.hostname + s.adminPort,
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ func Test_RegistersWithEnterprise(t *testing.T) {
|
||||
|
||||
shutdown := make(chan struct{})
|
||||
defer close(shutdown)
|
||||
e := enterprise.NewEnterprise(c, expected, shutdown)
|
||||
e := enterprise.NewEnterprise(c, expected, "test", shutdown)
|
||||
e.Open()
|
||||
|
||||
timeout := time.After(1 * time.Millisecond)
|
||||
@@ -80,7 +80,7 @@ func Test_StartsAdminInterface(t *testing.T) {
|
||||
|
||||
shutdown := make(chan struct{})
|
||||
defer close(shutdown)
|
||||
e := enterprise.NewEnterprise(c, hostname, shutdown)
|
||||
e := enterprise.NewEnterprise(c, hostname, "test", shutdown)
|
||||
e.Open()
|
||||
|
||||
timeout := time.After(1 * time.Millisecond)
|
||||
@@ -113,7 +113,7 @@ func Test_ClosesAdminInterface(t *testing.T) {
|
||||
}
|
||||
|
||||
shutdown := make(chan struct{})
|
||||
e := enterprise.NewEnterprise(c, hostname, shutdown)
|
||||
e := enterprise.NewEnterprise(c, hostname, "test", shutdown)
|
||||
e.Open()
|
||||
|
||||
timeout := time.After(1 * time.Millisecond)
|
||||
|
||||
Reference in New Issue
Block a user