Skip to content

Commit

Permalink
Enable lint & small linter issues fixes
Browse files Browse the repository at this point in the history
Signed-off-by: amaslennikov <amaslennikov@nvidia.com>
  • Loading branch information
almaslennikov committed Sep 21, 2024
1 parent 364c8bb commit 0744b8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ issues:
linters:
- dupl
- lll
- path: "pkg/*"
linters:
- dupl
- lll
linters:
disable-all: true
enable:
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/nicconfigurationtemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type NicSelectorSpec struct {
// +enum
type LinkTypeEnum string

// PciPerformanceOptimizedSpec specifies PCI performace optimization settings
// PciPerformanceOptimizedSpec specifies PCI performance optimization settings
type PciPerformanceOptimizedSpec struct {
// Specifies whether to enable PCI performance optimization
Enabled bool `json:"enabled"`
Expand Down
8 changes: 5 additions & 3 deletions internal/controller/nicconfigurationtemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ func (r *NicConfigurationTemplateReconciler) Reconcile(ctx context.Context, req

nodeMap := map[string]*v1.Node{}
for _, node := range nodeList.Items {
node := node
nodeMap[node.Name] = &node
}

templates := []*v1alpha1.NicConfigurationTemplate{}
for _, template := range templateList.Items {
template := template
templates = append(templates, &template)
}

Expand All @@ -109,7 +111,7 @@ func (r *NicConfigurationTemplateReconciler) Reconcile(ctx context.Context, req

for _, template := range templates {
if !deviceMatchesSelectors(&device, template, node) {
r.dropDeviceFromStatus(ctx, device.Name, template)
r.dropDeviceFromStatus(device.Name, template)

continue
}
Expand All @@ -130,7 +132,7 @@ func (r *NicConfigurationTemplateReconciler) Reconcile(ctx context.Context, req

if len(matchingTemplates) > 1 {
for _, template := range matchingTemplates {
r.dropDeviceFromStatus(ctx, device.Name, template)
r.dropDeviceFromStatus(device.Name, template)
}

templateNames := []string{}
Expand Down Expand Up @@ -172,7 +174,7 @@ func (r *NicConfigurationTemplateReconciler) Reconcile(ctx context.Context, req
return ctrl.Result{}, nil
}

func (r *NicConfigurationTemplateReconciler) dropDeviceFromStatus(ctx context.Context, deviceName string, template *v1alpha1.NicConfigurationTemplate) {
func (r *NicConfigurationTemplateReconciler) dropDeviceFromStatus(deviceName string, template *v1alpha1.NicConfigurationTemplate) {
index := slices.Index(template.Status.NicDevices, deviceName)
if index != -1 {
// Device no longer matches template, drop it from the template's status
Expand Down

0 comments on commit 0744b8d

Please sign in to comment.