stanctl-fleet: list command#103
Conversation
Signed-off-by: dishabhagat <disha.14624@gmail.com>
| .epilog(examplesForRestart); | ||
| }, handlers.handleRestart) | ||
| .command( | ||
| 'list', |
There was a problem hiding this comment.
How about using:
stanctl-fleet list-configs --type ...This follows the pattern "verb" / "verb-noun" with those fleet commands as below:
stanctl-fleet restart --type ... --tag ...
stanctl-fleet deploy --type ... --tag ... --configuration-id ...Because of this, we may also need to change the configuration update command in PR #102 by following the same pattern:
stanctl-fleet update-config --type ... --tag ... --configuration-id ...Then, for configuration related fleet comments, we have update-config and list-configs ((plural for list, singular for update). Also, --resource configuration is not needed any more and should be removed.
| logger.debug(JSON.stringify(data, null, 2)); | ||
| } | ||
|
|
||
| logger.info(JSON.stringify(data, null, 2)); |
There was a problem hiding this comment.
This is called unconditionally, even when isDebugEnabled() is also true: configuration data gets logged twice when --debug is on.
| import { validateServerAddress } from '../validators'; | ||
| import logger from '../logger'; | ||
|
|
||
| export async function handleList(argv: any) { |
There was a problem hiding this comment.
It does not use sendAgentRequest and duplicates the server/token/type/debug validation pattern that was explicitly consolidated in PR #102.
sendAgentRequest may not be reused directly as list uses GET not POST. But at least the shared validation logic (server, token, debug, validateServerAddress, type) could be extracted into a separate helper, e.g.: resolveConnection(argv) in utils.ts that both sendAgentRequest and handleList call. This avoids the pattern drifting again as more commands are added.
| }, handlers.handleRestart) | ||
| .command( | ||
| 'list', | ||
| 'list available resources', |
There was a problem hiding this comment.
It looks the command description is lowercase while all other commands use sentence case.
| try { | ||
| logger.info(`Listing configurations for type: ${type}...`); | ||
|
|
||
| const response = await axiosInstance.get(url, { |
There was a problem hiding this comment.
No Content-Type header on the GET request. The other commands (deploy, update) include 'Content-Type': 'application/json' in their request headers. For a GET request with no body it's not strictly required, but it's inconsistent. Please leave it out intentionally and add a comment, or add it for uniformity.
Command syntax:
stanctl-fleet list --resource configuration --server <server> --token <token> --type <agent-type>The
listcommand calls the appropriate API based on the--resourceoption. Currently, onlyconfigurationis supported as a resource type.This command lists all available configurations, making it easy to obtain the
configuration-idrequired for thedeployandupdate-configcommands.