fix: allow subcommands with TRIVY_RUN_AS_PLUGIN (#2577)

This commit is contained in:
Teppei Fukuda
2022-07-25 11:27:47 +03:00
committed by GitHub
parent c2f3731873
commit c7f0bc92ae
3 changed files with 31 additions and 11 deletions

View File

@@ -68,15 +68,6 @@ func SetOut(out io.Writer) {
func NewApp(version string) *cobra.Command {
globalFlags := flag.NewGlobalFlagGroup()
rootCmd := NewRootCommand(version, globalFlags)
if runAsPlugin := os.Getenv("TRIVY_RUN_AS_PLUGIN"); runAsPlugin != "" {
rootCmd.RunE = func(cmd *cobra.Command, args []string) error {
return plugin.RunWithArgs(cmd.Context(), runAsPlugin, args)
}
rootCmd.DisableFlagParsing = true
return rootCmd
}
rootCmd.AddCommand(
NewImageCommand(globalFlags),
NewFilesystemCommand(globalFlags),