Repository navigation
feat(cli): add the grus client commands and repl - #51
Merged
Merged
Conversation
Move the grus binary to cobra, keeping controller, fetch, openapi and version as they were. Add get, describe, apply, scale, stop, logs, exec, events, network, login and config commands on a small typed API client, plus shell completions and an interactive shell with live completion of resource names.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was the problem
The
grusbinary could only run the controller. Operators had no way to look at pools and instances, apply a pool definition, read a log or stop a server without writing curl calls against the REST API.What changed
grusis now also the command line client. The existingcontroller,fetch,openapiandversionsubcommands behave as before (same flags, same environment variables). New commands:get,describe,apply -f,scale,stop,logs [-f],exec,events,network,loginandconfig, with-o table|json|yamland shell completion scripts for bash, zsh, fish and PowerShell.grus shellstarts an interactive session on the same commands, with a history file in the user config directory, the context name in the prompt, and tab completion of pool, instance, template, group, environment and host names taken live from the controller (cached for a few seconds).Connections are saved as contexts in
~/.config/grus/config.yaml. The token comes fromGRUS_TOKENor a token file and is never printed. Groups, environments, hosts and the network count are requested from endpoints that other changes add; an older controller answers with a clear "not supported by this controller" message instead of a raw 404.How it was tested
Unit tests run the commands in process against
httptestservers (output formats, apply ordering and validation, scale, stop, logs, events, contexts, token handling), the API client has its own tests, and completion is tested including cache expiry with an injected clock. The existing end-to-end test still passes.grus shellwas smoke-tested by hand.