Skip to content

PT-2368 - refactor all tools cli#1096

Open
BON4 wants to merge 4 commits into3.xfrom
PT-2368-new-config-support
Open

PT-2368 - refactor all tools cli#1096
BON4 wants to merge 4 commits into3.xfrom
PT-2368-new-config-support

Conversation

@BON4
Copy link
Copy Markdown
Contributor

@BON4 BON4 commented Mar 25, 2026

Summary

This PR migrates CLI/config handling to the new Kong-based configuration layer across all affected Go tools.

The goal is to standardize flag parsing, config-file behavior, password prompts, and version/version-check flow using shared config primitives.

Changes

  • Switched shared version flag to Kong-native kong.VersionFlag in lib/config/commonFlags.go.
  • Migrated CLI bootstrap to config.Setup(...) in:
    • pt-mongodb-index-check
    • pt-mongodb-query-digest
    • pt-mongodb-summary
    • pt-pg-summary
    • pt-secure-collect
  • Replaced legacy parsers (getopt / kingpin) with Kong struct tags and hooks (AfterApply, command Run methods).
  • Unified version-check flow via config.VersionCheckFlag + versioncheck.CheckUpdates(...).
  • Unified interactive secret handling via config.StdinRequestString for DB/encryption passwords.
  • Refactored pt-secure-collect subcommands (collect, encrypt, decrypt, sanitize) to command structs with explicit validation and runtime handlers.

Notes

  • This is primarily a CLI/config refactor; no intended functional changes in business logic.

  • Main expected impact is behavior consistency across tools (flags, defaults, help/version output, password prompts).

  • The contributed code is licensed under GPL v2.0

  • Contributor Licence Agreement (CLA) is signed

  • util/update-modules has been ran

  • Documentation updated

  • Test suite update

BON4 added 2 commits March 12, 2026 15:27
This change intorduces refactoring of all tools to work
with new config implementation.
Copy link
Copy Markdown
Collaborator

@svetasmirnova svetasmirnova left a comment

Choose a reason for hiding this comment

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

Please finish the merge of 3.x and resolve conflicts: pt-k8s-debug-collector tests fail.

Copy link
Copy Markdown
Collaborator

@svetasmirnova svetasmirnova left a comment

Choose a reason for hiding this comment

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

pt-mongodb-summary test also fails. Looks like another conflict issue:

=== RUN   TestGetMongosInfo
    main_test.go:296: 
        	Error Trace:	/home/sveta/src/percona/percona-toolkit/src/go/pt-mongodb-summary/main_test.go:296
        	Error:      	Should not be: 0
        	Test:       	TestGetMongosInfo
--- FAIL: TestGetMongosInfo (0.00s)

@svetasmirnova
Copy link
Copy Markdown
Collaborator

$ ./bin/pt-k8s-debug-collector --version

This is not right.


Disable update checks.

``--version``
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
``--version``
``--version-check``
Check for updates (enabled by default).
``--no-version-check``
Disable update checks.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

  • No need to mention --skip-pod-summary two times.
  • Spaces matter, because they change formatting. Please follow style.

Comment on lines +19 to +22
``--config``

List of Percona Toolkit configuration file(s) separated by a comma without an equal sign. Must be a first flag. Uses default config file locations if not specified.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
``--config``
List of Percona Toolkit configuration file(s) separated by a comma without an equal sign. Must be a first flag. Uses default config file locations if not specified.
``--config``
List of Percona Toolkit configuration file(s) separated by a comma without an equal sign. Must be a first flag. Uses default config file locations if not specified.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Spaces affect formatting

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