Skip to content

Commit ed34c09

Browse files
authored
Simplify the softdep config generation (#390)
1 parent 15ba4f4 commit ed34c09

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

internal/daemonset/daemonset.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -496,17 +496,12 @@ func makeUnloadCommand(spec kmmv1beta1.ModprobeSpec, modName string) []string {
496496

497497
func getModulesOrderAnnotationValue(mld *api.ModuleLoaderData) string {
498498
modulesNames := mld.Modprobe.ModulesLoadingOrder
499-
softDepData := ""
500-
for i := 0; i < len(modulesNames); i++ {
501-
if i == len(modulesNames)-1 {
502-
break
503-
}
504-
line := prepareSoftDepLine(modulesNames[i], modulesNames[i+1])
505-
softDepData = softDepData + line
499+
500+
var sb strings.Builder
501+
502+
for i := 0; i < len(modulesNames)-1; i++ {
503+
fmt.Fprintf(&sb, "softdep %s pre: %s\n", modulesNames[i], modulesNames[i+1])
506504
}
507-
return softDepData
508-
}
509505

510-
func prepareSoftDepLine(dependendModuleName, moduleName string) string {
511-
return fmt.Sprintf("softdep %s pre: %s\n", dependendModuleName, moduleName)
506+
return sb.String()
512507
}

0 commit comments

Comments
 (0)