Skip to content

stanctl-fleet: list command#103

Open
disha-148 wants to merge 1 commit into
instana:fi-featuresfrom
disha-148:INSTA-104230-stanctl-fleet-list
Open

stanctl-fleet: list command#103
disha-148 wants to merge 1 commit into
instana:fi-featuresfrom
disha-148:INSTA-104230-stanctl-fleet-list

Conversation

@disha-148

Copy link
Copy Markdown
Collaborator

Command syntax:

stanctl-fleet list --resource configuration --server <server> --token <token> --type <agent-type>

The list command calls the appropriate API based on the --resource option. Currently, only configuration is supported as a resource type.

This command lists all available configurations, making it easy to obtain the configuration-id required for the deploy and update-config commands.

Signed-off-by: dishabhagat <disha.14624@gmail.com>
@disha-148
disha-148 requested a review from morningspace July 24, 2026 15:39
Comment thread tools/fleet/src/cli.ts
.epilog(examplesForRestart);
}, handlers.handleRestart)
.command(
'list',

@morningspace morningspace Jul 25, 2026

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.

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));

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.

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) {

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.

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.

Comment thread tools/fleet/src/cli.ts
}, handlers.handleRestart)
.command(
'list',
'list available resources',

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.

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, {

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 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.

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.

2 participants