Skip to content

Feat: add collect support-data commands#1065

Open
dascole wants to merge 1 commit into
Kong:mainfrom
dascole:feat/kong-debug-tool
Open

Feat: add collect support-data commands#1065
dascole wants to merge 1 commit into
Kong:mainfrom
dascole:feat/kong-debug-tool

Conversation

@dascole
Copy link
Copy Markdown

@dascole dascole commented May 15, 2026

Summary

Adds collect and collect support-data commands to gather deployment
diagnostic information into a compressed archive for troubleshooting and
support workflows.

What changed

  • adds the top-level collect command
  • adds the collect support-data subcommand
  • collects logs, configuration files, and system diagnostics
  • packages collected data into a compressed archive

Why

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.

Add support-data collection commands for Kong deployments to gather
logs, configuration files, and system diagnostics into a compressed
archive for troubleshooting and support.
Copilot AI review requested due to automatic review settings May 15, 2026 00:29
@dascole dascole requested review from a team as code owners May 15, 2026 00:29
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 15, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment thread go.mod
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 collect as a top-level verb and wires it into the root command.
  • Adds collect support-data with on-prem and konnect subcommands, 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 include kong-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)
			}

Comment on lines +62 to +63
For Docker: duration string (e.g., "1h", "30m")
For Kubernetes: seconds (converted internally)
Comment on lines +248 to +254
// 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
Comment on lines +154 to +166
// 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)
@rspurgeon rspurgeon changed the title feat(cmd): add collect support-data commands Feat: add collect support-data commands May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants