Skip to content

Commit

Permalink
resmgr/control: golangci-lint fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub authored and askervin committed Dec 11, 2024
1 parent f1cedb1 commit ce697f1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
10 changes: 0 additions & 10 deletions pkg/resmgr/control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package control
import (
"errors"
"fmt"
"os"
"sort"
"strings"

Expand All @@ -27,15 +26,6 @@ import (
cfgapi "github.com/containers/nri-plugins/pkg/apis/config/v1alpha1/resmgr/control"
)

const (
// EnvVarEnableTestAPIs controls if test APIS are enabled (currently e2e test controller).
EnvVarEnableTestAPIs = "ENABLE_TEST_APIS"
)

var (
enableTestAPIs = (os.Getenv(EnvVarEnableTestAPIs) != "")
)

// Control is the interface for triggering controller-/domain-specific post-decision actions.
type Control interface {
// StartStopControllers starts/stops all controllers according to configuration.
Expand Down
7 changes: 3 additions & 4 deletions pkg/resmgr/control/cpu/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ func setClassAssignments(c cache.Cache, a *cpuClassAssignments) {

// Set the value of cached cpuClassAssignments
func (c *cpuClassAssignments) Set(value interface{}) {
switch value.(type) {
switch v := value.(type) {
case cpuClassAssignments:
*c = value.(cpuClassAssignments)
*c = v
case *cpuClassAssignments:
cp := value.(*cpuClassAssignments)
*c = *cp
*c = *v
}
}

Expand Down
5 changes: 4 additions & 1 deletion pkg/resmgr/control/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,5 +295,8 @@ func (ctl *cpuctl) getClasses() map[string]Class {

// Register us as a controller.
func init() {
control.Register(CPUController, "CPU controller", getCPUController())
err := control.Register(CPUController, "CPU controller", getCPUController())
if err != nil {
log.Warnf("failed to register CPU controller: %v", err)
}
}
5 changes: 4 additions & 1 deletion pkg/resmgr/control/e2e-test/e2e-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,5 +154,8 @@ func (ctl *testctl) registerHandler() {

// Register us as a controller.
func init() {
control.Register(ControllerName, "Test controller", getE2ETestController())
err := control.Register(ControllerName, "Test controller", getE2ETestController())
if err != nil {
log.Warnf("failed to register controller: %v", err)
}
}

0 comments on commit ce697f1

Please sign in to comment.