Fix: fix step id to name in workflow logs (#5805)

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
Tianxin Dong
2023-04-06 14:56:22 +08:00
committed by GitHub
parent c24cbdc6f9
commit 3c2d47be6e
2 changed files with 8 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ package cli
import (
"context"
"fmt"
"regexp"
"strings"
"github.com/fatih/color"
@@ -34,6 +35,8 @@ import (
"github.com/oam-dev/kubevela/references/appfile"
)
var re = regexp.MustCompile(`^.*?"([^"]*)"`)
// NewLogsCommand creates `logs` command to tail logs of application
func NewLogsCommand(c common.Args, order string, ioStreams util.IOStreams) *cobra.Command {
largs := &Args{Args: c}
@@ -122,6 +125,10 @@ func (l *Args) printPodLogs(ctx context.Context, ioStreams util.IOStreams, selec
}
}
if show {
match := re.FindStringSubmatch(str)
if len(match) > 1 {
str = strings.ReplaceAll(match[1], "\\n", "\n")
}
ioStreams.Infonln(str)
}
case <-ctx.Done():

View File

@@ -467,7 +467,7 @@ func (w *WorkflowArgs) selectWorkflowStep(msg string) error {
if err != nil {
return fmt.Errorf("failed to select step %s: %w", unwrapStepName(w.StepName), err)
}
w.StepName = unwrapStepID(stepName, w.WorkflowInstance)
w.StepName = unwrapStepName(stepName)
return nil
}