Skip to content

Conversation

@JoeColeman95
Copy link
Contributor

Migrates all build subcommands from Cobra to Kong as part of the CLI modernization effort. This must be part of the same PR, as we'd be breaking all other build subcommands in the interm if we tried to move them 1-by-1.

Meat of the changes

Created /cmd/build/ with Kong versions of all 7 build subcommands:

  • create.go (kept new alias for backward compatibility)
  • cancel.go, view.go, list.go, download.go, rebuild.go, watch.go

Each command has:

  • Run(kongCtx *kong.Context, globals cli.GlobalFlags) error method
  • Help() method with examples

Added a global flag interface as this was needed to avoid circular dependencies. Kong commands access SkipConfirmation() and DisableInput() without importing the main package.

ValidateConfiguration function created as a Kong version of the Cobra config validation that all migrated commands use, added TODO's where relevant so we can easily use find to delete the Cobra versions once fully migrated.

Main.go changes

  • Added BuildCmd struct with all the subcommands we've moved
  • Added Globals struct that uses GlobalFlags
  • Updated buildCobraArgs() to reconstruct global flags when passing them to Cobra
  • Updated isHelpRequest() so Kong handles build --help instead of Cobra

General cleanup

  • Removed build command registration from pkg/cmd/root/root.go
  • Deleted pkg/cmd/build/build.go (not needed anymore)
  • Moved list_test.go to cmd/build/ and updated it to work without Cobra
  • Simplified tests to only cover client-side filtering, moved test helpers into the test file

View.go

For some reason this was using --format as a flag, I aligned this with the rest of the cli and made it --output.

Testing

I've tested this iteratively as I went along, all commands are working as they were before, no core logic has been changed from any of them, so it all works as expected.

The global flags work with the Cobra commands, and everything is playing nicely as it was before.

All tests passing, moved them over to the new /cmd/build/ folder, had to add some new helper functions to the list_test.go test as it was using Cobra there, too.

Allows us to do the same checks on tokens requirements, and if api token/org slug are missing in Kong like we do with Cobra
Had to change a few bits here to add the --output flag as it was a bit weird on this one. For some reason it expected --format? Anyway, sorted.
Add some helper functions to well, help... too... I guess?
@JoeColeman95 JoeColeman95 requested a review from a team as a code owner November 28, 2025 17:34
@JoeColeman95
Copy link
Contributor Author

Shows a lot as deleted and created rather than moved because I copy pasted the old one, made modifications to it, commited and then deleted the old one so that I have a backup of the original one if I needed it... But everything's moved

@mcncl mcncl merged commit 700ba6d into main Nov 28, 2025
1 check passed
@mcncl mcncl deleted the SUP-4603/Kongify/build/create branch November 28, 2025 22:10
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