Feat: add collect support-data commands#1065
Conversation
Add support-data collection commands for Kong deployments to gather logs, configuration files, and system diagnostics into a compressed archive for troubleshooting and support.
|
|
There was a problem hiding this comment.
4 Open source vulnerabilities detected - high severity
Aikido detected 4 vulnerabilities across 3 packages, it includes 4 high vulnerabilities.
Details
Remediation Aikido suggests bumping the vulnerable packages to a safe version.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
There was a problem hiding this comment.
Pull request overview
Adds a new collect verb and a collect support-data command tree to gather diagnostic artifacts from Kong deployments (on-prem and Konnect) into an archive, leveraging kong-deployment-toolkit’s collector.
Changes:
- Introduces
collectas a top-level verb and wires it into the root command. - Adds
collect support-datawithon-premandkonnectsubcommands, including flag/config mapping and output formatting. - Adds unit tests for flag registration/config layering and a parity test against
collector.Config; updates Go dependencies to includekong-deployment-toolkit.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/cmd/root/verbs/verbs.go | Adds the collect verb constant. |
| internal/cmd/root/verbs/collect/collect.go | Implements the new top-level collect command and registers support-data. |
| internal/cmd/root/verbs/collect/supportdata/supportdata.go | Defines the support-data parent command and help text. |
| internal/cmd/root/verbs/collect/supportdata/common.go | Common flags/config mapping and result output formatting. |
| internal/cmd/root/verbs/collect/supportdata/onprem.go | Implements collect support-data on-prem command, flags, and config layering. |
| internal/cmd/root/verbs/collect/supportdata/konnect.go | Implements collect support-data konnect command, flags, and config layering/base URL logic. |
| internal/cmd/root/verbs/collect/supportdata/common_test.go | Tests for common flag registration and config/flag application behavior. |
| internal/cmd/root/verbs/collect/supportdata/onprem_test.go | Tests for on-prem flags and config layering behavior. |
| internal/cmd/root/verbs/collect/supportdata/konnect_test.go | Tests for Konnect flags, PAT/base-url/region behavior, and config layering. |
| internal/cmd/root/verbs/collect/supportdata/flagparity_test.go | Reflection-based parity test to ensure collector.Config fields are mapped or intentionally excluded. |
| internal/cmd/root/root.go | Wires the new collect command into the CLI. |
| go.mod / go.sum | Adds github.com/kong/kong-deployment-toolkit and updates transitive dependencies. |
Comments suppressed due to low confidence (1)
internal/cmd/root/verbs/collect/supportdata/common.go:185
- FormatOutput's text branch prints via fmt.Printf/fmt.Println and writes warnings directly to os.Stderr. For consistency with other commands and to support output capture/redirection, prefer writing via provided writers/IOStreams rather than using the process-level stdio globals.
default: // TEXT
fmt.Printf("Support data archive: %s\n", result.ArchivePath)
fmt.Printf("Runtime: %s\n", result.Runtime)
fmt.Printf("Files collected: %d\n", len(result.CollectedFiles))
if len(result.Warnings) > 0 {
fmt.Println("\nWarnings:")
for _, warn := range result.Warnings {
fmt.Fprintf(os.Stderr, " - %v\n", warn)
}
| For Docker: duration string (e.g., "1h", "30m") | ||
| For Kubernetes: seconds (converted internally) |
| // Resolve base URL (handles region -> URL conversion) | ||
| baseURL, err := konnectcommon.ResolveBaseURL(cfg) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to resolve Konnect base URL: %w", err) | ||
| } | ||
| collectorCfg.KongAddr = baseURL | ||
|
|
| // Get output format | ||
| outputFormat, err := helper.GetOutputFormat() | ||
| if err != nil { | ||
| outputFormat = common.TEXT |
| // Get output format | ||
| outputFormat, err := helper.GetOutputFormat() | ||
| if err != nil { | ||
| outputFormat = common.TEXT |
| // FormatOutput formats the collection result based on output format. | ||
| func FormatOutput(format common.OutputFormat, result *collector.Result) error { | ||
| switch format { | ||
| case common.JSON: | ||
| output := map[string]interface{}{ | ||
| "archive_path": result.ArchivePath, | ||
| "runtime": result.Runtime, | ||
| "files_collected": len(result.CollectedFiles), | ||
| "warnings": warningsToStrings(result.Warnings), | ||
| } | ||
| enc := json.NewEncoder(os.Stdout) | ||
| enc.SetIndent("", " ") | ||
| return enc.Encode(output) |
Summary
Adds
collectandcollect support-datacommands to gather deploymentdiagnostic information into a compressed archive for troubleshooting and
support workflows.
What changed
collectcommandcollect support-datasubcommandWhy
This makes it easier to gather the information typically needed for
support investigations and debugging without requiring users to collect
artifacts manually.
User impact
Users can run the new support-data collection command to generate a
single archive containing relevant diagnostic artifacts.