Skip to content

Commit

Permalink
oem/smc: replace getters with direct members for top level oem data
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt1360 committed Oct 15, 2024
1 parent 2b2fce4 commit 0e46b21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
27 changes: 6 additions & 21 deletions oem/smc/drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ type Drive struct {
redfish.Drive

// Fields from the SMC OEM section
temperature int
percentageDriveLifeUsed int
driveFunctional bool
Temperature int
PercentageDriveLifeUsed int
DriveFunctional bool

// indicateTarget is the uri to hit to change the light state
indicateTarget string
Expand Down Expand Up @@ -53,9 +53,9 @@ func FromDrive(drive *redfish.Drive) (Drive, error) {
return smcDrive, err
}

smcDrive.temperature = t.Oem.Supermicro.Temperature
smcDrive.percentageDriveLifeUsed = t.Oem.Supermicro.PercentageDriveLifeUsed
smcDrive.driveFunctional = t.Oem.Supermicro.DriveFunctional
smcDrive.Temperature = t.Oem.Supermicro.Temperature
smcDrive.PercentageDriveLifeUsed = t.Oem.Supermicro.PercentageDriveLifeUsed
smcDrive.DriveFunctional = t.Oem.Supermicro.DriveFunctional

// We check both the SmcDriveIndicate and the DriveIndicate targets
// in the Oem sections - certain models and bmc firmwares will mix
Expand All @@ -68,21 +68,6 @@ func FromDrive(drive *redfish.Drive) (Drive, error) {
return smcDrive, nil
}

// Temperature returns the OEM provided temperature for the drive
func (d Drive) Temperature() int {
return d.temperature
}

// PercentageDriveLifeUsed returns the OEM provided drive life estimate as a percentage used
func (d Drive) PercentageDriveLifeUsed() int {
return d.percentageDriveLifeUsed
}

// Functional returns the OEM provided flag that suggests whether a drive is functional or not
func (d Drive) Functional() bool {
return d.driveFunctional
}

// Indicate will set the indicator light activity, true for on, false for off
func (d Drive) Indicate(active bool) error {

Check failure on line 72 in oem/smc/drive.go

View workflow job for this annotation

GitHub Actions / Lint

hugeParam: d is heavy (2184 bytes); consider passing it by pointer (gocritic)
// Return a common error to let the user try falling back on the normal gofish path
Expand Down
4 changes: 2 additions & 2 deletions oem/smc/drive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func TestSmcDriveOem(t *testing.T) {
t.Fatalf("error getting oem info from drive: %v", err)
}

if smcDrive.Temperature() != 33 {
t.Errorf("unexpected oem drive temerature: %d", smcDrive.Temperature())
if smcDrive.Temperature != 33 {
t.Errorf("unexpected oem drive temerature: %d", smcDrive.Temperature)

Check failure on line 61 in oem/smc/drive_test.go

View workflow job for this annotation

GitHub Actions / Lint

`temerature` is a misspelling of `temperature` (misspell)
}

if smcDrive.indicateTarget != "/redfish/v1/Chassis/NVMeSSD.0.Group.0.StorageBackplane/Drives/Disk.Bay.22/Actions/Oem/Drive.Indicate" {
Expand Down

0 comments on commit 0e46b21

Please sign in to comment.