Skip to content

Commit 728e77a

Browse files
authored
fix(plugin): initialize logger (#6836)
Signed-off-by: knqyf263 <[email protected]>
1 parent 83fc6e7 commit 728e77a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

cmd/trivy/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ func main() {
2828
func run() error {
2929
// Trivy behaves as the specified plugin.
3030
if runAsPlugin := os.Getenv("TRIVY_RUN_AS_PLUGIN"); runAsPlugin != "" {
31-
if err := plugin.RunWithURL(context.Background(), runAsPlugin, plugin.Options{Args: os.Args[1:]}); err != nil {
31+
log.InitLogger(false, false)
32+
if err := plugin.Run(context.Background(), runAsPlugin, plugin.Options{Args: os.Args[1:]}); err != nil {
3233
return xerrors.Errorf("plugin error: %w", err)
3334
}
3435
return nil

pkg/commands/app.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ func NewPluginCommand() *cobra.Command {
799799
Short: "Run a plugin on the fly",
800800
Args: cobra.MinimumNArgs(1),
801801
RunE: func(cmd *cobra.Command, args []string) error {
802-
return plugin.RunWithURL(cmd.Context(), args[0], plugin.Options{Args: args[1:]})
802+
return plugin.Run(cmd.Context(), args[0], plugin.Options{Args: args[1:]})
803803
},
804804
},
805805
&cobra.Command{

pkg/plugin/manager.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ func Install(ctx context.Context, name string, opts Options) (Plugin, error) {
8484
func Start(ctx context.Context, name string, opts Options) (Wait, error) {
8585
return defaultManager().Start(ctx, name, opts)
8686
}
87-
func RunWithURL(ctx context.Context, name string, opts Options) error {
88-
return defaultManager().RunWithURL(ctx, name, opts)
87+
func Run(ctx context.Context, name string, opts Options) error {
88+
return defaultManager().Run(ctx, name, opts)
8989
}
9090
func Upgrade(ctx context.Context, names []string) error { return defaultManager().Upgrade(ctx, names) }
9191
func Uninstall(ctx context.Context, name string) error { return defaultManager().Uninstall(ctx, name) }
@@ -291,8 +291,8 @@ func (m *Manager) Start(ctx context.Context, name string, opts Options) (Wait, e
291291
return wait, nil
292292
}
293293

294-
// RunWithURL runs the plugin
295-
func (m *Manager) RunWithURL(ctx context.Context, name string, opts Options) error {
294+
// Run installs and runs the plugin
295+
func (m *Manager) Run(ctx context.Context, name string, opts Options) error {
296296
plugin, err := m.Install(ctx, name, opts)
297297
if err != nil {
298298
return xerrors.Errorf("plugin install error: %w", err)

0 commit comments

Comments
 (0)