Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

admin cli: print all names instead of only the first one on OutputMod…#352

Merged
NickCao merged 2 commits intomainfrom
name-only
Mar 18, 2025
Merged

admin cli: print all names instead of only the first one on OutputMod…#352
NickCao merged 2 commits intomainfrom
name-only

Conversation

@NickCao
Copy link
Copy Markdown
Collaborator

@NickCao NickCao commented Mar 17, 2025

…e.NAME

Summary by CodeRabbit

  • New Features
    • Enhanced resource name display: When the output mode is set to display names, the system now prints all resource names rather than just one, providing a more comprehensive view.
  • Tests
    • Improved maintainability of test assertions by introducing constants for client, exporter, and lease names, replacing hardcoded strings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 17, 2025

Walkthrough

The changes modify three functions in the print.py file to iterate over all items in the list when the OutputMode is set to NAME. Instead of only printing the first item, the updated code loops through the entire list and prints each item's name. If the list is empty, the functions continue to raise a click.ClickException as before. Additionally, new constants for client, exporter, and lease names are introduced in the get_test.py file to replace hardcoded strings in test assertions, enhancing maintainability.

Changes

File Path Change Summary
packages/.../jumpstarter_cli_admin/print.py Updated print_clients, print_exporters, and print_leases functions to loop over all items and print their names instead of just the first one when OutputMode is NAME. Error handling for empty lists remains unchanged.
packages/.../jumpstarter_cli_admin/get_test.py Added constants CLIENTS_LIST_NAME, EXPORTERS_LIST_NAME, EXPORTERS_DEVICES_LIST_NAME, and LEASES_LIST_NAME for use in assertions, replacing hardcoded strings in the test functions.

Suggested reviewers

  • mangelajo

Poem

I'm a rabbit with a happy hop,
Skipping through code that just won't stop.
Each name now gleams like a carrot so bright,
Looping anew in the soft moonlight.
Celebrate the change with a twitch and a bop!
🐰🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb9a779 and 5d6b5ae.

📒 Files selected for processing (2)
  • packages/jumpstarter-cli-admin/jumpstarter_cli_admin/get_test.py (8 hunks)
  • packages/jumpstarter-cli-admin/jumpstarter_cli_admin/print.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/jumpstarter-cli-admin/jumpstarter_cli_admin/print.py
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: e2e
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
🔇 Additional comments (8)
packages/jumpstarter-cli-admin/jumpstarter_cli_admin/get_test.py (8)

222-224: Well-structured constant for client names output.

Good addition of the CLIENTS_LIST_NAME constant to represent the expected output when listing clients with the --output name option. This improves maintainability by centralizing the expected output format.


266-266: Proper assertion update to match multi-name output.

The assertion is correctly updated to use the CLIENTS_LIST_NAME constant, validating that all client names are now displayed when using the --output name option.


597-599: Well-structured constant for exporter names output.

The addition of the EXPORTERS_LIST_NAME constant follows the same pattern as the client names constant, providing consistent test expectations for the exporters listing functionality.


634-634: Proper assertion update for exporter names output.

The assertion is correctly updated to use the EXPORTERS_LIST_NAME constant, ensuring all exporter names are properly displayed.


765-765: Appropriate reuse of exporter list name constant.

Good decision to reuse the EXPORTERS_LIST_NAME constant for the devices list output, as the name format is the same regardless of whether the --devices flag is used.


802-802: Proper assertion update for exporter devices output.

The assertion is correctly updated to use the EXPORTERS_DEVICES_LIST_NAME constant, maintaining consistency in the expected output format.


1140-1142: Well-structured constant for lease names output.

The addition of the LEASES_LIST_NAME constant follows the established pattern, properly representing the expected format for lease listings.


1187-1187: Proper assertion update for lease names output.

The assertion is correctly updated to use the LEASES_LIST_NAME constant, validating that all lease names are now displayed when using the --output name option.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 17, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 6d13567
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/67d9a1ffaaa9820008647624
😎 Deploy Preview https://deploy-preview-352--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
packages/jumpstarter-cli-admin/jumpstarter_cli_admin/print.py (3)

37-48: Verify if the empty check order is optimal

The current implementation has the NAME output mode check before the empty items check. This means the loop will run (but not print anything) even when the items list is empty, before hitting the exception in line 46. Consider if reordering these conditions would be more efficient.

def print_clients(clients: V1Alpha1List[V1Alpha1Client], namespace: str, output: OutputType):
    if output == OutputMode.JSON:
        click.echo(clients.dump_json())
    elif output == OutputMode.YAML:
        click.echo(clients.dump_yaml())
+   elif len(clients.items) == 0:
+       raise click.ClickException(f'No resources found in "{namespace}" namespace')
    elif output == OutputMode.NAME:
        for item in clients.items:
            click.echo(f"client.jumpstarter.dev/{item.metadata.name}")
-   elif len(clients.items) == 0:
-       raise click.ClickException(f'No resources found in "{namespace}" namespace')
    else:
        click.echo(make_table(CLIENT_COLUMNS, list(map(make_client_row, clients.items))))

101-114: Consider applying the same condition reordering to print_exporters

Similar to the suggestion for print_clients, consider reordering the conditions to check for empty items before the OutputMode.NAME check.


165-176: Consider applying the same condition reordering to print_leases

For consistency and efficiency, consider reordering the conditions in this function as well to check for empty items before handling OutputMode.NAME.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35dc3df and eb9a779.

📒 Files selected for processing (1)
  • packages/jumpstarter-cli-admin/jumpstarter_cli_admin/print.py (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: e2e
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter Dockerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-utils Dockerfile.utils)
🔇 Additional comments (3)
packages/jumpstarter-cli-admin/jumpstarter_cli_admin/print.py (3)

43-44: Improved functionality to print all client names

The change correctly modifies the behavior to iterate through all items in the clients list and print each client's name when OutputMode is NAME, rather than just printing the first item. This aligns with the PR objective to "print all names instead of only the first one".


107-108: Improved functionality to print all exporter names

Similar to the clients change, this modification correctly iterates through all exporters and prints each name when OutputMode is NAME. This ensures consistent behavior across different resource types and aligns with the PR objective.


171-172: Improved functionality to print all lease names

This change completes the set of modifications by ensuring all lease names are printed when OutputMode is NAME, maintaining consistency with the other resource types. The implementation correctly iterates through all items in the leases list.

@NickCao NickCao enabled auto-merge March 18, 2025 16:40
@NickCao NickCao merged commit 74d3e2a into main Mar 18, 2025
18 checks passed
@NickCao NickCao deleted the name-only branch March 18, 2025 16:54
@mangelajo mangelajo added this to the 0.6.0 milestone May 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants