-
Notifications
You must be signed in to change notification settings - Fork 24
Add panic command for internal testing purposes #3310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ import ( | |
| "github.com/confluentinc/cli/v4/internal/connect" | ||
| "github.com/confluentinc/cli/v4/internal/context" | ||
| ccl "github.com/confluentinc/cli/v4/internal/custom-code-logging" | ||
| idebug "github.com/confluentinc/cli/v4/internal/debug" | ||
| "github.com/confluentinc/cli/v4/internal/environment" | ||
| "github.com/confluentinc/cli/v4/internal/feedback" | ||
| "github.com/confluentinc/cli/v4/internal/flink" | ||
|
|
@@ -117,6 +118,7 @@ func NewConfluentCommand(cfg *config.Config) *cobra.Command { | |
| cmd.AddCommand(configuration.New(cfg, prerunner)) | ||
| cmd.AddCommand(connect.New(cfg, prerunner)) | ||
| cmd.AddCommand(context.New(prerunner)) | ||
| cmd.AddCommand(idebug.New(prerunner)) | ||
| cmd.AddCommand(environment.New(prerunner)) | ||
|
Comment on lines
118
to
122
|
||
| cmd.AddCommand(feedback.New(prerunner)) | ||
| cmd.AddCommand(flink.New(cfg, prerunner)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package debug | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
|
|
||
| pcmd "github.com/confluentinc/cli/v4/pkg/cmd" | ||
| ) | ||
|
|
||
| type command struct { | ||
| *pcmd.CLICommand | ||
| } | ||
|
|
||
| func New(prerunner pcmd.PreRunner) *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "debug", | ||
| Short: "Debug utilities for internal testing.", | ||
| Hidden: true, | ||
| } | ||
|
|
||
| c := &command{CLICommand: pcmd.NewAnonymousCLICommand(cmd, prerunner)} | ||
|
|
||
| cmd.AddCommand(c.newPanicCommand()) | ||
|
|
||
| return cmd | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||||||||||||||
| package debug | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| import ( | ||||||||||||||||||||||
| "github.com/spf13/cobra" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func (c *command) newPanicCommand() *cobra.Command { | ||||||||||||||||||||||
| return &cobra.Command{ | ||||||||||||||||||||||
| Use: "panic", | ||||||||||||||||||||||
| Short: "Trigger a test panic for crash reporting validation.", | ||||||||||||||||||||||
| Long: "Trigger a test panic to validate the crash reporting pipeline; note that panic traces are only collected and reported when logged in to Confluent Cloud.", | ||||||||||||||||||||||
| Args: cobra.NoArgs, | ||||||||||||||||||||||
| RunE: c.panic, | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func (c *command) panic(_ *cobra.Command, _ []string) error { | ||||||||||||||||||||||
|
Comment on lines
+13
to
+17
|
||||||||||||||||||||||
| RunE: c.panic, | |
| } | |
| } | |
| func (c *command) panic(_ *cobra.Command, _ []string) error { | |
| RunE: c.triggerPanic, | |
| } | |
| } | |
| func (c *command) triggerPanic(_ *cobra.Command, _ []string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registering an intentionally crashing command on the main CLI root means any user who discovers it can force a panic (and potentially generate crash telemetry noise when logged into Confluent Cloud). Consider gating this command behind an explicit opt-in (env var / build tag / feature flag) or adding a confirmation flag so it can’t be triggered accidentally.