From aa5e825683b2c2cb81b863944f8b4552fba400ca Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 6 Apr 2023 14:59:44 +0800 Subject: [PATCH] Fix: fix step id to name in workflow logs (#5807) Signed-off-by: FogDong (cherry picked from commit 6b1f57e8774fb7d22c924a7eebca3934264e8481) Co-authored-by: FogDong --- references/cli/logs.go | 7 +++++++ references/cli/workflow.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/references/cli/logs.go b/references/cli/logs.go index 1fd5d23ba..ba0c17634 100644 --- a/references/cli/logs.go +++ b/references/cli/logs.go @@ -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(): diff --git a/references/cli/workflow.go b/references/cli/workflow.go index 8d1880fa2..2619d4891 100644 --- a/references/cli/workflow.go +++ b/references/cli/workflow.go @@ -454,7 +454,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 }