mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 17:35:43 +03:00
modify fingerprint interface to use typed attribute struct
This commit is contained in:
@@ -24,6 +24,7 @@ import (
|
||||
"github.com/hashicorp/nomad/plugins/shared"
|
||||
"github.com/hashicorp/nomad/plugins/shared/hclspec"
|
||||
"github.com/hashicorp/nomad/plugins/shared/loader"
|
||||
pstructs "github.com/hashicorp/nomad/plugins/shared/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -195,7 +196,7 @@ func (d *Driver) handleFingerprint(ctx context.Context, ch chan *drivers.Fingerp
|
||||
|
||||
func (d *Driver) buildFingerprint() *drivers.Fingerprint {
|
||||
fp := &drivers.Fingerprint{
|
||||
Attributes: map[string]string{},
|
||||
Attributes: map[string]*pstructs.Attribute{},
|
||||
Health: drivers.HealthStateHealthy,
|
||||
HealthDescription: "healthy",
|
||||
}
|
||||
@@ -232,10 +233,10 @@ func (d *Driver) buildFingerprint() *drivers.Fingerprint {
|
||||
return fp
|
||||
}
|
||||
|
||||
fp.Attributes[driverAttr] = "1"
|
||||
fp.Attributes[driverVersionAttr] = version
|
||||
fp.Attributes["driver.java.runtime"] = runtime
|
||||
fp.Attributes["driver.java.vm"] = vm
|
||||
fp.Attributes[driverAttr] = pstructs.NewBoolAttribute(true)
|
||||
fp.Attributes[driverVersionAttr] = pstructs.NewStringAttribute(version)
|
||||
fp.Attributes["driver.java.runtime"] = pstructs.NewStringAttribute(runtime)
|
||||
fp.Attributes["driver.java.vm"] = pstructs.NewStringAttribute(vm)
|
||||
|
||||
return fp
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ func TestJavaDriver_Fingerprint(t *testing.T) {
|
||||
select {
|
||||
case fp := <-fpCh:
|
||||
require.Equal(t, drivers.HealthStateHealthy, fp.Health)
|
||||
require.Equal(t, "1", fp.Attributes["driver.java"])
|
||||
detected, _ := fp.Attributes["driver.java"].GetBool()
|
||||
require.True(t, detected)
|
||||
case <-time.After(time.Duration(testutil.TestMultiplier()*5) * time.Second):
|
||||
require.Fail(t, "timeout receiving fingerprint")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user