Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pkg/cmd/plugin_cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ func addPluginSubcommandStubs(parent *cobra.Command, commands []plugins.CommandI

// runPluginCmd hands off to the plugin itself to take over
func (ptc *pluginTemplateCmd) runPluginCmd(cmd *cobra.Command, args []string) error {
ctx := withSIGTERMCancel(cmd.Context(), func() {
// Plugin subcommand stubs can reach this path with a nil command context,
// which makes withSIGTERMCancel -> context.WithCancel panic ("cannot create
// context from nil parent"). Fall back to a background context, mirroring the
// guard already used on the help path above.
parentCtx := cmd.Context()
if parentCtx == nil {
parentCtx = context.Background()
}
ctx := withSIGTERMCancel(parentCtx, func() {
log.WithFields(log.Fields{
"prefix": "cmd.pluginCmd.runPluginCmd",
}).Debug("Ctrl+C received, cleaning up...")
Expand Down