Fix: fix vela debug cli to find id for step (#5294)

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
Tianxin Dong
2023-01-10 16:46:21 +08:00
committed by GitHub
parent 46b31b2569
commit b71a8a353a
2 changed files with 19 additions and 2 deletions

View File

@@ -143,8 +143,10 @@ func (d *debugOpts) debugWorkflow(ctx context.Context, wargs *WorkflowArgs, cli
if err != nil {
return fmt.Errorf("failed to select workflow step: %w", err)
}
d.step = unwrapStepName(step)
d.step = unwrapStepID(step, wargs.WorkflowInstance)
d.errMsg = d.errMap[d.step]
} else {
d.step = unwrapStepID(d.step, wargs.WorkflowInstance)
}
// debug workflow steps
@@ -261,6 +263,21 @@ func unwrapStepName(step string) string {
}
}
func unwrapStepID(step string, instance *wfTypes.WorkflowInstance) string {
step = unwrapStepName(step)
for _, status := range instance.Status.Steps {
if status.Name == step {
return status.ID
}
for _, sub := range status.SubStepsStatus {
if sub.Name == step {
return sub.ID
}
}
}
return step
}
func (d *debugOpts) getDebugRawValue(ctx context.Context, cli client.Client, pd *packages.PackageDiscover, instance *wfTypes.WorkflowInstance) (*value.Value, string, error) {
debugCM := &corev1.ConfigMap{}
if err := cli.Get(ctx, client.ObjectKey{Name: debug.GenerateContextName(instance.Name, d.step, string(instance.UID)), Namespace: instance.Namespace}, debugCM); err != nil {

View File

@@ -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 = unwrapStepName(stepName)
w.StepName = unwrapStepID(stepName, w.WorkflowInstance)
return nil
}