squakez commented on code in PR #6721:
URL: https://github.com/apache/camel-k/pull/6721#discussion_r3663238008


##########
pkg/trait/init_containers.go:
##########
@@ -194,31 +217,90 @@ func (t *initContainersTrait) parseTasks() (bool, error) {
        t.tasks = make([]containerTask, len(t.InitTasks)+len(t.SidecarTasks))
        i := 0
        for _, task := range t.InitTasks {
-               split := strings.SplitN(task, ";", 3)
-               if len(split) != 3 {
-                       return false, fmt.Errorf(`could not parse init 
container task "%s": format expected "name;container-image;command"`, task)
-               }
-               t.tasks[i] = containerTask{
-                       name:      split[0],
-                       image:     split[1],
-                       command:   split[2],
-                       isSidecar: false,
+               parsed, err := parseSingleTask(task, false)
+               if err != nil {
+                       return false, fmt.Errorf("could not parse init 
container task %q: %w", task, err)
                }
+               t.tasks[i] = parsed
                i++
        }
        for _, task := range t.SidecarTasks {
-               split := strings.SplitN(task, ";", 3)
-               if len(split) != 3 {
-                       return false, fmt.Errorf(`could not parse sidecar 
container task "%s": format expected "name;container-image;command"`, task)
-               }
-               t.tasks[i] = containerTask{
-                       name:      split[0],
-                       image:     split[1],
-                       command:   split[2],
-                       isSidecar: true,
+               parsed, err := parseSingleTask(task, true)
+               if err != nil {
+                       return false, fmt.Errorf("could not parse sidecar 
container task %q: %w", task, err)
                }
+               t.tasks[i] = parsed
                i++
        }
 
        return true, nil
 }
+
+func parseSingleTask(task string, isSidecar bool) (containerTask, error) {
+       segments := strings.Split(task, ";")
+
+       var result containerTask
+       result.isSidecar = isSidecar
+
+       var commandParts []string
+
+       for _, seg := range segments {
+               if len(strings.TrimSpace(seg)) == 0 {
+                       continue
+               }
+               if strings.Contains(seg, "=") {

Review Comment:
   Feel free to add a `nolint` statement to avoid the warn



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to