Skip to content

Commit

Permalink
[kn-plugin-workflow] Executing kn workflow run creates the container …
Browse files Browse the repository at this point in the history
…in the background
  • Loading branch information
treblereel committed Nov 30, 2024
1 parent ed127d1 commit 9dda668
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/kn-plugin-workflow/pkg/command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package command

import (
"bufio"
"fmt"
"os"
"sync"
Expand Down Expand Up @@ -137,6 +138,34 @@ func runSWFProjectDevMode(containerTool string, cfg RunCmdConfig) (err error) {
pollInterval := 5 * time.Second
common.ReadyCheck(readyCheckURL, pollInterval, cfg.PortMapping, cfg.OpenDevUI)

if err := stopContainer(containerTool); err != nil {
return err
}

wg.Wait()
return err
}

func stopContainer(containerTool string) error {
fmt.Println("Press ENTER to stop the container")

reader := bufio.NewReader(os.Stdin)

_, err := reader.ReadString('\n')
if err != nil {
return fmt.Errorf("error reading from stdin: %w", err)
}

fmt.Println("⏳ Stopping the container...")

containerID, err := common.GetContainerID(containerTool)
if err != nil {
return err
}
if err := common.StopContainer(containerTool, containerID); err != nil {
return err
}
return nil
}


0 comments on commit 9dda668

Please sign in to comment.