Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Page size #290

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Roaster05
Copy link
Contributor

@Roaster05 Roaster05 commented Dec 22, 2024

Fix #244
also fix #261

Description

This PR enhances the handling of the page-size parameter by introducing a hierarchical priority mechanism and integrating it into the command execution flow.

Hierarchy for page-size Resolution

  1. Flag: The value provided via the command flag takes the highest priority.
  2. ResolvePageSize Utility: If no flag is provided, the utility determines the page-size in the following order:
    • Value from the configuration file.
    • Value from the HARBOR_CLI_DEFAULT_PAGE_SIZE environment variable.
    • Hardcoded default value (x).

Key Changes

  1. Command Execution:
    • Updated list commands to prioritize page-size values using the hierarchy mentioned above.
  2. Config Updates:
    • Introduced a new parameter for page-size in the configuration.
    • Added initialization for this parameter in the relevant configuration files.

Copy link
Member

@bupd bupd left a comment

Choose a reason for hiding this comment

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

Thanks for your contributions. Here is one change.

Instead of giving different page sizes at different places.

We should have single default page size. that is configurable.

@Roaster05
Copy link
Contributor Author

@bupd It seems there was some confusion regarding the value passed in the ResolvePageSize(x int64) int64 function.

To clarify:

  • The parameter value x is only used when:
    1. There is no configuration available in the config file.
    2. No environment variable is explicitly set for the default page size.

In such cases, the function assigns a hardcoded value to serve as the default. Previously, this hardcoded value varied across different files (10 or 20), leading to inconsistency.

To address this:

  • The current implementation uses the parameter x to provide the hardcoded default value when none of the config or environment variables are set.
  • If we want to enforce a consistent hardcoded value across all places, we can eliminate the parameter x entirely and define the hardcoded value directly within the function. This ensures consistency and simplifies the function signature.

Let me know if you want to proceed with this approach or need further clarification!

@bupd bupd added the question Further information is requested label Dec 28, 2024
@bupd
Copy link
Member

bupd commented Dec 28, 2024

Thanks GPT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add config option for defaults in cli Ability to configure default page size
2 participants