From 83402890df4a46b7f272ae4bcf5069b850bababe Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Tue, 5 Dec 2023 09:29:30 +0100 Subject: [PATCH] providers/asrr: use constants for the model names --- providers/asrockrack/asrockrack.go | 10 +++++++--- providers/asrockrack/helpers.go | 2 +- providers/asrockrack/inventory.go | 2 +- providers/asrockrack/inventory_test.go | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/providers/asrockrack/asrockrack.go b/providers/asrockrack/asrockrack.go index c8f2238b..721c10dc 100644 --- a/providers/asrockrack/asrockrack.go +++ b/providers/asrockrack/asrockrack.go @@ -21,6 +21,10 @@ const ( ProviderName = "asrockrack" // ProviderProtocol for the provider implementation ProviderProtocol = "vendorapi" + + E3C256D4ID_NL = "E3C256D4ID-NL" + E3C246D4ID_NL = "E3C246D4ID-NL" + E3C246D4I_NL = "E3C246D4I-NL" ) var ( @@ -119,9 +123,9 @@ func (a *ASRockRack) Open(ctx context.Context) (err error) { func (a *ASRockRack) supported(ctx context.Context) error { supported := []string{ - "E3C256D4ID-NL", - "E3C246D4ID-NL", - "E3C246D4I-NL", + E3C256D4ID_NL, + E3C246D4ID_NL, + E3C246D4I_NL, } if a.deviceModel == "" { diff --git a/providers/asrockrack/helpers.go b/providers/asrockrack/helpers.go index 3166614b..503bda88 100644 --- a/providers/asrockrack/helpers.go +++ b/providers/asrockrack/helpers.go @@ -192,7 +192,7 @@ func (a *ASRockRack) setFlashMode(ctx context.Context) error { pConfig := &preserveConfig{} // preserve config is needed by e3c256d4i switch device.Model { - case "E3C256D4ID-NL": + case E3C256D4ID_NL: pConfig = &preserveConfig{PreserveConfig: 1} } diff --git a/providers/asrockrack/inventory.go b/providers/asrockrack/inventory.go index 2f2044e7..d571a241 100644 --- a/providers/asrockrack/inventory.go +++ b/providers/asrockrack/inventory.go @@ -143,7 +143,7 @@ func (a *ASRockRack) systemAttributes(ctx context.Context, device *common.Device device.Metadata["node_id"] = fwInfo.NodeID switch device.Model { - case "E3C246D4ID-NL", "E3C246D4I-NL": + case E3C246D4ID_NL, E3C246D4I_NL: return a.componentAttributesE3C246(ctx, fwInfo, device) default: return nil diff --git a/providers/asrockrack/inventory_test.go b/providers/asrockrack/inventory_test.go index 56e01895..8d7e1c3a 100644 --- a/providers/asrockrack/inventory_test.go +++ b/providers/asrockrack/inventory_test.go @@ -13,10 +13,10 @@ func TestGetInventory(t *testing.T) { t.Fatal(err) } - aClient.deviceModel = "E3C246D4I-NL" + aClient.deviceModel = E3C246D4I_NL assert.NotNil(t, device) assert.Equal(t, "ASRockRack", device.Vendor) - assert.Equal(t, "E3C246D4I-NL", device.Model) + assert.Equal(t, E3C246D4I_NL, device.Model) assert.Equal(t, "L2.07B", device.BIOS.Firmware.Installed) assert.Equal(t, "0.01.00", device.BMC.Firmware.Installed)