Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Gardner committed Sep 6, 2023
1 parent b3440bc commit c8c3869
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
7 changes: 7 additions & 0 deletions pkg/devices/power.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func SnmpPowerRead(device *sdk.Device) (readings []*output.Reading, err error) {
var reading *output.Reading
if result.Data == nil {
reading, err = output.Watt.MakeReading(nil)
if err != nil {
return nil, err
}

readings = []*output.Reading{reading}
return readings, nil
}
Expand All @@ -40,6 +44,9 @@ func SnmpPowerRead(device *sdk.Device) (readings []*output.Reading, err error) {
// Create the reading.
// FIXME (etd): differentiate between watts/VA
reading, err = output.Watt.MakeReading(resultFloat)
if err != nil {
return nil, err
}

readings = []*output.Reading{reading}
return readings, nil
Expand Down
6 changes: 3 additions & 3 deletions pkg/snmp/servers/galaxy_ups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func TestGalaxyUps(t *testing.T) {
assert.Equal(t, clientDeviceConfig.Version, "V3")
assert.Equal(t, clientDeviceConfig.Endpoint, "127.0.0.1")
assert.Equal(t, clientDeviceConfig.ContextName, "public")
thirtySeconds, _ := time.ParseDuration("30s")
assert.Equal(t, clientDeviceConfig.Timeout, thirtySeconds)
timeout, _ := time.ParseDuration("30s")
assert.Equal(t, clientDeviceConfig.Timeout, timeout)
assert.NotNil(t, clientDeviceConfig.SecurityParameters)
assert.Equal(t, clientDeviceConfig.SecurityParameters.AuthenticationProtocol, core.AuthenticationProtocol(3))
assert.Equal(t, clientDeviceConfig.SecurityParameters.PrivacyProtocol, core.PrivacyProtocol(3))
Expand All @@ -51,7 +51,7 @@ func TestGalaxyUps(t *testing.T) {
assert.Equal(t, serverDeviceConfig.Version, "V3")
assert.Equal(t, serverDeviceConfig.Endpoint, "127.0.0.1")
assert.Equal(t, serverDeviceConfig.ContextName, "public")
assert.Equal(t, serverDeviceConfig.Timeout, thirtySeconds)
assert.Equal(t, serverDeviceConfig.Timeout, timeout)
assert.NotNil(t, serverDeviceConfig.SecurityParameters)
assert.Equal(t, serverDeviceConfig.SecurityParameters.AuthenticationProtocol, core.AuthenticationProtocol(3))
assert.Equal(t, serverDeviceConfig.SecurityParameters.PrivacyProtocol, core.PrivacyProtocol(3))
Expand Down
6 changes: 3 additions & 3 deletions pkg/snmp/servers/pxgms_ups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func TestPxgmsUps(t *testing.T) {
assert.Equal(t, clientDeviceConfig.Version, "V3")
assert.Equal(t, clientDeviceConfig.Endpoint, "127.0.0.1")
assert.Equal(t, clientDeviceConfig.ContextName, "public")
thirtySeconds, _ := time.ParseDuration("30s")
assert.Equal(t, clientDeviceConfig.Timeout, thirtySeconds)
timeout, _ := time.ParseDuration("30s")
assert.Equal(t, clientDeviceConfig.Timeout, timeout)
assert.NotNil(t, clientDeviceConfig.SecurityParameters)
assert.Equal(t, clientDeviceConfig.SecurityParameters.AuthenticationProtocol, core.AuthenticationProtocol(3))
assert.Equal(t, clientDeviceConfig.SecurityParameters.PrivacyProtocol, core.PrivacyProtocol(3))
Expand All @@ -52,7 +52,7 @@ func TestPxgmsUps(t *testing.T) {
assert.Equal(t, serverDeviceConfig.Version, "V3")
assert.Equal(t, serverDeviceConfig.Endpoint, "127.0.0.1")
assert.Equal(t, serverDeviceConfig.ContextName, "public")
assert.Equal(t, serverDeviceConfig.Timeout, thirtySeconds)
assert.Equal(t, serverDeviceConfig.Timeout, timeout)
assert.NotNil(t, serverDeviceConfig.SecurityParameters)
assert.Equal(t, serverDeviceConfig.SecurityParameters.AuthenticationProtocol, core.AuthenticationProtocol(3))
assert.Equal(t, serverDeviceConfig.SecurityParameters.PrivacyProtocol, core.PrivacyProtocol(3))
Expand Down
7 changes: 4 additions & 3 deletions pkg/snmp/servers/snmp_server_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ package servers

import (
"fmt"
log "github.com/sirupsen/logrus"
"strings"

log "github.com/sirupsen/logrus"
)

// CreateSnmpServer creates a SnmpServer from the configuration data model string.
func CreateSnmpServer(data map[string]interface{}) (server *SnmpServer, err error) {
model, ok := data["model"].(string)
if !ok {
err = fmt.Errorf("No snmp server model")
err = fmt.Errorf("no snmp server model")
return
}

Expand Down Expand Up @@ -47,6 +48,6 @@ func CreateSnmpServer(data map[string]interface{}) (server *SnmpServer, err erro
return nil, err
}

err = fmt.Errorf("Unkown snmp server model: %v", model)
err = fmt.Errorf("unkown snmp server model: %v", model)
return
}
6 changes: 3 additions & 3 deletions pkg/snmp/servers/tripplite_ups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func TestTrippliteUps(t *testing.T) {
assert.Equal(t, clientDeviceConfig.Version, "V3")
assert.Equal(t, clientDeviceConfig.Endpoint, "127.0.0.1")
assert.Equal(t, clientDeviceConfig.ContextName, "public")
thirtySeconds, _ := time.ParseDuration("30s")
assert.Equal(t, clientDeviceConfig.Timeout, thirtySeconds)
timeout, _ := time.ParseDuration("30s")
assert.Equal(t, clientDeviceConfig.Timeout, timeout)
assert.NotNil(t, clientDeviceConfig.SecurityParameters)
assert.Equal(t, clientDeviceConfig.SecurityParameters.AuthenticationProtocol, core.AuthenticationProtocol(2))
assert.Equal(t, clientDeviceConfig.SecurityParameters.PrivacyProtocol, core.PrivacyProtocol(2))
Expand All @@ -53,7 +53,7 @@ func TestTrippliteUps(t *testing.T) {
assert.Equal(t, serverDeviceConfig.Version, "V3")
assert.Equal(t, serverDeviceConfig.Endpoint, "127.0.0.1")
assert.Equal(t, serverDeviceConfig.ContextName, "public")
assert.Equal(t, serverDeviceConfig.Timeout, thirtySeconds)
assert.Equal(t, serverDeviceConfig.Timeout, timeout)
assert.NotNil(t, serverDeviceConfig.SecurityParameters)
assert.Equal(t, serverDeviceConfig.SecurityParameters.AuthenticationProtocol, core.AuthenticationProtocol(2))
assert.Equal(t, serverDeviceConfig.SecurityParameters.PrivacyProtocol, core.PrivacyProtocol(2))
Expand Down

0 comments on commit c8c3869

Please sign in to comment.