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

Deduplicate click options#366

Merged
mangelajo merged 3 commits intomainfrom
less-options
Mar 20, 2025
Merged

Deduplicate click options#366
mangelajo merged 3 commits intomainfrom
less-options

Conversation

@NickCao
Copy link
Copy Markdown
Collaborator

@NickCao NickCao commented Mar 20, 2025

Summary by CodeRabbit

  • New Features

    • Consolidated OIDC authentication now uses a single unified option for credentials, streamlining the login experience.
    • Enhanced label selection now supports multiple query operators (e.g., =, ==, !=) for more flexible filtering.
    • Improved handling of duration parameters in update commands provides more robust behavior.
  • Refactor

    • Streamlined command-line interfaces by removing redundant options and simplifying parameter structures across commands.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 20, 2025

Walkthrough

This pull request restructures various CLI commands by consolidating multiple OIDC authentication options into a single decorator and streamlining related function signatures. In addition, it unifies selector handling by replacing the older opt_selector_simple with an enhanced opt_selector and updates duration handling to use opt_duration_partial. The changes affect both client and exporter login workflows as well as shell and lease management commands, ensuring a more consistent and simplified command-line interface.

Changes

File(s) Change Summary
packages/jumpstarter-cli-client/jumpstarter_cli_client/client_login.py
packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_login.py
packages/jumpstarter-cli-common/jumpstarter_cli_common/oidc.py
Removed individual OIDC options (--username, --password, --token, --issuer), removed decorators @opt_client_id/@opt_connector_id, added new @opt_oidc to consolidate OIDC parameters, and updated function signatures accordingly.
packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py
packages/jumpstarter-cli-client/jumpstarter_cli_client/create.py
packages/jumpstarter-cli-client/jumpstarter_cli_client/common.py
Replaced the import and usage of opt_selector_simple with opt_selector, updating decorators and help text to support a broader range of operators (=, ==, !=).
packages/jumpstarter-cli-client/jumpstarter_cli_client/update.py Modified the duration option by replacing the direct DURATION specification with the opt_duration_partial decorator for the update_lease command.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant OIDC_Decorator as @opt_oidc
    participant Login_Function
    participant OIDC_Provider

    User->>CLI: Issue login command with OIDC options
    CLI->>OIDC_Decorator: Parse and consolidate options
    OIDC_Decorator-->>CLI: Return unified credentials
    CLI->>Login_Function: Call login with consolidated OIDC parameters
    Login_Function->>OIDC_Provider: Request authentication token
    OIDC_Provider-->>Login_Function: Return token
    Login_Function-->>CLI: Send login result
    CLI-->>User: Display login status
Loading

Possibly related PRs

Suggested reviewers

  • mangelajo

Poem

I'm a little rabbit, hopping through the code,
Finding simpler paths in every change bestowed.
OIDC and selectors are now neat and new,
Leaping through the logic with a joyful hop or two.
CodeRabbit cheers this refactor day—
With every jump, we streamline the way!


📜 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 36015dd and 86ddbbc.

📒 Files selected for processing (7)
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/client_login.py (2 hunks)
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py (1 hunks)
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/common.py (0 hunks)
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/create.py (2 hunks)
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/update.py (2 hunks)
  • packages/jumpstarter-cli-common/jumpstarter_cli_common/oidc.py (2 hunks)
  • packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_login.py (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/jumpstarter-cli-client/jumpstarter_cli_client/common.py
🧰 Additional context used
🧬 Code Definitions (3)
packages/jumpstarter-cli-client/jumpstarter_cli_client/client_login.py (1)
packages/jumpstarter-cli-common/jumpstarter_cli_common/oidc.py (3) (3)
  • Config (40-116)
  • decode_jwt_issuer (123-124)
  • opt_oidc (25-36)
packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py (1)
packages/jumpstarter/jumpstarter/common/utils.py (1) (1)
  • launch_shell (83-104)
packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_login.py (1)
packages/jumpstarter-cli-common/jumpstarter_cli_common/oidc.py (3) (3)
  • Config (40-116)
  • decode_jwt_issuer (123-124)
  • opt_oidc (25-36)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: pytest-matrix (3.12)
  • GitHub Check: pytest-matrix (3.11)
  • GitHub Check: pytest-matrix (3.13)
  • GitHub Check: e2e
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-utils Dockerfile.utils)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-devspace .devfile/Containerfile.client)
  • GitHub Check: build-and-push-image (jumpstarter-dev/jumpstarter-dev .devfile/Containerfile)
🔇 Additional comments (13)
packages/jumpstarter-cli-common/jumpstarter_cli_common/oidc.py (1)

25-36: Good consolidation of OIDC options.

This new opt_oidc decorator effectively consolidates six OIDC-related command-line options into a single reusable component. The use of @wraps(f) properly preserves the metadata of the decorated function, which is a good practice.

packages/jumpstarter-cli-client/jumpstarter_cli_client/client_shell.py (2)

7-7: Appropriate update to import the enhanced selector option.

Replacing opt_selector_simple with opt_selector aligns with the PR objective of deduplicating and enhancing click options.


14-14: Enhanced selector functionality.

Switching from @opt_selector_simple to @opt_selector provides more flexible selector options while maintaining consistent behavior across the codebase.

packages/jumpstarter-cli-client/jumpstarter_cli_client/update.py (2)

7-7: Good standardization of duration imports.

Replacing the import of DURATION with opt_duration_partial is consistent with the PR's objective to standardize option handling.


20-20: Improved duration parameter handling.

Replacing the direct click option with the @opt_duration_partial decorator provides a more consistent approach to duration handling across commands.

packages/jumpstarter-cli-client/jumpstarter_cli_client/create.py (2)

12-12: Appropriate update to import the enhanced selector option.

Replacing opt_selector_simple with opt_selector aligns with the PR objective of deduplicating and enhancing click options.


24-24: Enhanced selector functionality.

Switching from @opt_selector_simple to @opt_selector provides more flexible selector options while maintaining consistent behavior across the codebase.

packages/jumpstarter-cli-exporter/jumpstarter_cli_exporter/exporter_login.py (3)

2-2: Good refactoring to use the consolidated OIDC options.

Importing opt_oidc from the common module is a good approach to ensure consistent OIDC authentication handling across the codebase.


12-12: Great simplification using the consolidated decorator.

Using the @opt_oidc decorator is a good approach to replace multiple individual OIDC-related option decorators. This makes the code more maintainable and consistent across the codebase.


13-24:

Details

✅ Verification successful

Verify that function parameters still match with decorator options.

The function signature still includes parameters for username, password, token, and issuer that are now being provided by the @opt_oidc decorator. This matches the decorator's implementation, but ensure all calls to this function include these parameters.


🏁 Script executed:

#!/bin/bash
# Search for all calls to exporter_login to ensure they provide all required parameters
rg -A 1 -B 1 "exporter_login\(" --type py

Length of output: 326


Action: Confirm decorator alignment and absence of mismatched calls.
After verifying with the grep search, the only occurrence of exporter_login( is the function’s definition in the file, immediately following the @opt_oidc decorator. This confirms that the function signature—including parameters for username, password, token, and issuer—matches the decorator’s implementation. There are no external calls that might bypass the decorator, so the current configuration appears consistent.

packages/jumpstarter-cli-client/jumpstarter_cli_client/client_login.py (3)

3-3: Good refactoring to use the consolidated OIDC options.

Importing opt_oidc from the common module ensures consistent OIDC authentication handling across the codebase.


39-39: Great simplification using the consolidated decorator.

Using the @opt_oidc decorator is a good approach to replace multiple individual OIDC-related option decorators. This makes the code more maintainable and consistent across the codebase.


41-54:

Details

❓ Verification inconclusive

Verify that function parameters still match with decorator options.

The function signature still includes parameters for username, password, token, and issuer that are now being provided by the @opt_oidc decorator. This matches the decorator's implementation, but ensure all calls to this function include these parameters.


🏁 Script executed:

#!/bin/bash
# Search for all calls to client_login to ensure they provide all required parameters
rg -A 1 -B 1 "client_login\(" --type py

Length of output: 333


Action Required: Verify Client Login Parameter Usage with @opt_oidc Decorator

The function signature in packages/jumpstarter-cli-client/jumpstarter_cli_client/client_login.py still includes the parameters username, password, token, and issuer, which are now automatically provided by the @opt_oidc decorator. Our repository search only revealed the function definition itself and did not show explicit call-sites invoking client_login.

  • Ensure that any future or indirect calls to client_login properly account for these parameters, whether they’re passed explicitly or injected by the decorator.
  • Double-check that the decorator’s behavior remains consistent so that there’s no need for additional parameters at call time.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 20, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 86ddbbc
🔍 Latest deploy log https://app.netlify.com/sites/jumpstarter-docs/deploys/67dc4d3fd578460008f430da
😎 Deploy Preview https://deploy-preview-366--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.

@NickCao NickCao marked this pull request as draft March 20, 2025 17:21
@NickCao NickCao marked this pull request as ready for review March 20, 2025 17:25
@mangelajo mangelajo merged commit e0a3c55 into main Mar 20, 2025
18 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Mar 20, 2025
@NickCao NickCao deleted the less-options branch March 31, 2025 15:44
@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