From 8f737cc6eb67a7cbdee4c2b28f629372e93a3256 Mon Sep 17 00:00:00 2001 From: Teppei Fukuda Date: Fri, 24 Dec 2021 23:02:19 +0200 Subject: [PATCH] feat(cli): warning for root command (#1516) --- pkg/commands/app.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/commands/app.go b/pkg/commands/app.go index 2c60c712fa0c..ebacc7aef3d5 100644 --- a/pkg/commands/app.go +++ b/pkg/commands/app.go @@ -18,6 +18,7 @@ import ( "github.com/aquasecurity/trivy/pkg/commands/plugin" "github.com/aquasecurity/trivy/pkg/commands/server" tdb "github.com/aquasecurity/trivy/pkg/db" + "github.com/aquasecurity/trivy/pkg/log" "github.com/aquasecurity/trivy/pkg/result" "github.com/aquasecurity/trivy/pkg/types" "github.com/aquasecurity/trivy/pkg/utils" @@ -351,7 +352,10 @@ func NewApp(version string) *cli.App { runAsPlugin := os.Getenv("TRIVY_RUN_AS_PLUGIN") if runAsPlugin == "" { - app.Action = artifact.ImageRun + app.Action = func(ctx *cli.Context) error { + log.Logger.Warn("The root command will be removed. Please migrate to 'trivy image' command. See https://github.com/aquasecurity/trivy/discussions/1515") + return artifact.ImageRun(ctx) + } } else { app.Action = func(ctx *cli.Context) error { return plugin.RunWithArgs(ctx.Context, runAsPlugin, ctx.Args().Slice())