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)