feat: add --prices flag to server plans command#633
Merged
kangasta merged 20 commits intoUpCloudLtd:mainfrom Jan 14, 2026
Merged
feat: add --prices flag to server plans command#633kangasta merged 20 commits intoUpCloudLtd:mainfrom
--prices flag to server plans command#633kangasta merged 20 commits intoUpCloudLtd:mainfrom
Conversation
Contributor
Author
kangasta
requested changes
Dec 31, 2025
Member
kangasta
left a comment
There was a problem hiding this comment.
Thank you for the PR! Added few comments about the arguments and calculations, didn't yet go through the rest of the getPlanCost function 👀
mgajda
added a commit
to mgajda/upcloud-cli
that referenced
this pull request
Dec 31, 2025
Based on Toni's review on PR UpCloudLtd#633: - Changed --cost flag to --pricing with zone parameter - Renamed --duration to --pricing-duration with support for named values (hourly, monthly) - Made 'monthly' the default pricing duration to align with GUI/marketing - Simplified header generation - only special cases for hourly/monthly - Fixed billing calculation to use math.Ceil() for per-hour billing The command now works like: upctl server plans --pricing de-fra1 --pricing-duration monthly upctl server plans --pricing de-fra1 --pricing-duration hourly upctl server plans --pricing de-fra1 --pricing-duration 168h
Contributor
Author
Thank you! I have addressed the comments and reduced the added code. |
kangasta
reviewed
Jan 2, 2026
kangasta
reviewed
Jan 2, 2026
kangasta
reviewed
Jan 2, 2026
Implements cost calculation features for capacity planning and budgeting. Features: - Add --cost flag to display hourly pricing for server plans - Add --duration flag with standard Go duration format (1h, 24h, 720h) - Dynamic cost calculation based on requested duration - Intelligent column headers (per hour/day/week/month/year) - Fallback to component pricing when specific plan prices unavailable This helps users with: - Budget planning for infrastructure costs - Comparing costs across different plan types - Capacity planning with cost visibility - Multi-period cost projections Examples: upctl server plans --cost # hourly pricing upctl server plans --cost --duration 24h # daily pricing upctl server plans --cost --duration 720h # monthly (~30 days) Related to UpCloudLtd#339 (billing/budget visibility)
Based on Toni's review on PR UpCloudLtd#633: - Changed --cost flag to --pricing with zone parameter - Renamed --duration to --pricing-duration with support for named values (hourly, monthly) - Made 'monthly' the default pricing duration to align with GUI/marketing - Simplified header generation - only special cases for hourly/monthly - Fixed billing calculation to use math.Ceil() for per-hour billing The command now works like: upctl server plans --pricing de-fra1 --pricing-duration monthly upctl server plans --pricing de-fra1 --pricing-duration hourly upctl server plans --pricing de-fra1 --pricing-duration 168h
- Remove special "hourly" and "monthly" keywords - use 1h and 1m instead - Support month-based durations: 1m, 3m, 12m etc. - Default to 1m (one month) for pricing-duration - Simplify header formatting: "Price (per N months)" for all month durations - Keep special cases only for 1h (per hour) and 24h (per day) This makes the interface more consistent and predictable.
UpCloud bills servers for a maximum of 28 days per month as per their pricing policy. Updated monthly duration calculations to use 28 days instead of 30 days. - Changed month calculation from 30 to 28 days per month - Fixed nil pointer issue when GetPriceZones returns nil - Added validation that --pricing-duration requires --pricing zone - Added comprehensive tests for sub-hour duration billing (rounds up to full hour) - Added tests to verify 6 months = 6*28*24 hours - Confirmed billing is per hour (rounded up to next full hour) Addresses review comment from @kangasta
Added support for 'hourly' and 'monthly' keywords in the --pricing-duration flag as requested by reviewer. These provide more intuitive options for users: - 'hourly' maps to 1 hour duration - 'monthly' maps to 28 days (UpCloud billing month) The existing duration format support (1h, 24h, 1m, 3m, etc.) is retained for flexibility. Updated tests to cover the new keywords.
- Added constants for 'hourly' and 'monthly' strings (goconst) - Converted if-else chains to switch statements (gocritic) - Fixed staticcheck issue with tagged switch in tests Resolves all golangci-lint errors from CI pipeline.
f622c90 to
5e36c43
Compare
kangasta
reviewed
Jan 9, 2026
kangasta
reviewed
Jan 9, 2026
kangasta
reviewed
Jan 9, 2026
kangasta
reviewed
Jan 9, 2026
Correct the priceField. Co-authored-by: Toni Kangas <kangasta@users.noreply.github.com>
kangasta
reviewed
Jan 9, 2026
kangasta
reviewed
Jan 13, 2026
--pricing flag to server plans command
--pricing flag to server plans command--prices flag to server plans command
kangasta
reviewed
Jan 13, 2026
kangasta
approved these changes
Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements cost calculation features for capacity planning and budgeting.
Features:
This helps users with:
Examples:
Related to #339 (billing/budget visibility)