From 6761b182294e20be29b5efe278023f2fc25d8f2d Mon Sep 17 00:00:00 2001 From: Tianxin Dong Date: Wed, 27 Apr 2022 21:31:07 +0800 Subject: [PATCH] Fix: fix up command add debug policy (#3770) Signed-off-by: FogDong --- references/cli/up.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/references/cli/up.go b/references/cli/up.go index d848e3ea0..69e1184d4 100644 --- a/references/cli/up.go +++ b/references/cli/up.go @@ -175,10 +175,7 @@ func (opt *UpCommandOptions) deployExistingApp(f velacmd.Factory, cmd *cobra.Com } oam.SetPublishVersion(app, opt.PublishVersion) if opt.Debug { - app.Spec.Policies = append(app.Spec.Policies, v1beta1.AppPolicy{ - Name: "debug", - Type: "debug", - }) + addDebugPolicy(app) } return cli.Update(ctx, app) }); err != nil { @@ -188,6 +185,18 @@ func (opt *UpCommandOptions) deployExistingApp(f velacmd.Factory, cmd *cobra.Com return nil } +func addDebugPolicy(app *v1beta1.Application) { + for _, policy := range app.Spec.Policies { + if policy.Type == "debug" { + return + } + } + app.Spec.Policies = append(app.Spec.Policies, v1beta1.AppPolicy{ + Name: "debug", + Type: "debug", + }) +} + func (opt *UpCommandOptions) deployApplicationFromFile(f velacmd.Factory, cmd *cobra.Command) error { cli := f.Client() body, err := common.ReadRemoteOrLocalPath(opt.File)