From 0e5a39097b2f50c3c9d121725fde63b699611f4a Mon Sep 17 00:00:00 2001 From: Eric Curtin Date: Sun, 2 Nov 2025 10:59:15 +0000 Subject: [PATCH] Remove duplicate splitArgs function We have an exact duplicate in utils Signed-off-by: Eric Curtin --- main.go | 31 ++----------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/main.go b/main.go index e5c30ea98..317270ddc 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,6 @@ import ( "os" "os/signal" "path/filepath" - "strings" "syscall" "github.com/docker/model-runner/pkg/distribution/transport/resumable" @@ -22,6 +21,7 @@ import ( "github.com/docker/model-runner/pkg/inference/scheduling" "github.com/docker/model-runner/pkg/metrics" "github.com/docker/model-runner/pkg/routing" + "github.com/docker/model-runner/pkg/utils" "github.com/sirupsen/logrus" ) @@ -255,7 +255,7 @@ func createLlamaCppConfigFromEnv() config.BackendConfig { } // Split the string by spaces, respecting quoted arguments - args := splitArgs(argsStr) + args := utils.SplitArgs(argsStr) // Check for disallowed arguments disallowedArgs := []string{"--model", "--host", "--embeddings", "--mmproj"} @@ -272,30 +272,3 @@ func createLlamaCppConfigFromEnv() config.BackendConfig { Args: args, } } - -// splitArgs splits a string into arguments, respecting quoted arguments -func splitArgs(s string) []string { - var args []string - var currentArg strings.Builder - inQuotes := false - - for _, r := range s { - switch { - case r == '"' || r == '\'': - inQuotes = !inQuotes - case r == ' ' && !inQuotes: - if currentArg.Len() > 0 { - args = append(args, currentArg.String()) - currentArg.Reset() - } - default: - currentArg.WriteRune(r) - } - } - - if currentArg.Len() > 0 { - args = append(args, currentArg.String()) - } - - return args -}