Add format flag to atmos version command
what
-
- Different format
why
- Required for automation
references
- https://github.com/cloudposse/atmos/issues/1169
Summary by CodeRabbit
-
New Features
- Added support for specifying the output format (JSON or YAML) when displaying version information.
- Version command now includes OS and architecture details in formatted output.
-
Bug Fixes
- Improved version checking logic to respect configuration and cache settings.
-
Tests
- Expanded test coverage for version checking, retrieval, and output formatting.
-
Refactor
- Simplified and modularized version retrieval and checking logic for better maintainability.
Codecov Report
Attention: Patch coverage is 64.10256% with 28 lines in your changes missing coverage. Please review.
Project coverage is 51.18%. Comparing base (
e4ff11c) to head (11b68b1). Report is 1 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| internal/exec/version.go | 64.47% | 21 Missing and 6 partials :warning: |
| cmd/version.go | 50.00% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1322 +/- ##
==========================================
+ Coverage 51.08% 51.18% +0.10%
==========================================
Files 243 243
Lines 26230 26295 +65
==========================================
+ Hits 13399 13459 +60
+ Misses 11180 11175 -5
- Partials 1651 1661 +10
| Flag | Coverage ฮ | |
|---|---|---|
| unittests | 51.18% <64.10%> (+0.10%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
๐ Walkthrough
Walkthrough
The changes introduce a --format flag to the version command, add configuration-aware and cache-based version checking, and refactor the version execution logic for modularity. Method signatures and mocks are updated to simplify parameters, and the test suite is expanded to cover new logic, including formatted output and version check conditions.
Changes
| File(s) | Change Summary |
|---|---|
| cmd/version.go | Added --format flag, updated global variables, refactored command execution to support new logic. |
| internal/exec/version.go | Refactored version logic: added config/caching, new methods, modularized, updated method signatures. |
| internal/exec/mock_version_test.go | Updated mock methods to remove parameters from GetLatestGitHubRepoRelease. |
| internal/exec/version_test.go | Expanded tests: added cases for new logic, updated interface, improved coverage and modularity. |
| website/docs/cli/commands/version.mdx | Enhanced CLI command docs with detailed flags section for --check and --format. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant CLI
participant versionExec
participant Config
participant GitHub
User->>CLI: atmos version [--check] [--format=json|yaml]
CLI->>versionExec: Execute(checkFlag, format)
alt format specified
versionExec->>Config: Load config/cached data
versionExec->>GitHub: (if needed) Fetch latest release
versionExec->>CLI: Output version info in specified format
else checkFlag is true
versionExec->>GitHub: Fetch latest release
versionExec->>CLI: Print version/update info
else
versionExec->>Config: Check if update check is needed
alt update needed
versionExec->>GitHub: Fetch latest release
versionExec->>CLI: Print upgrade message if newer version
else
versionExec->>CLI: Print current version info
end
end
Possibly related PRs
- cloudposse/atmos#869: Refactors how atmos config is accessed and passed within commands, including
versionCmd, closely related to config handling changes here. - cloudposse/atmos#1120: Introduced modularization and testability improvements for version execution, which this PR builds upon with further enhancements.
Suggested reviewers
- aknysh
- osterman
- Gowiem
๐ Recent review details
Configuration used: .coderabbit.yaml Review profile: CHILL Plan: Pro
๐ฅ Commits
Reviewing files that changed from the base of the PR and between a0a8468c22e1b4cbcbc4cfc4656c1a9933bc225d and 11b68b1efd59ca3539f6121819464be5df386d81.
๐ Files selected for processing (1)
-
website/docs/cli/commands/version.mdx(1 hunks)
โ Files skipped from review due to trivial changes (1)
- website/docs/cli/commands/version.mdx
โฐ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: Build (macos-latest, macos)
- GitHub Check: Build (ubuntu-latest, linux)
- GitHub Check: Build (windows-latest, windows)
- GitHub Check: Lint (golangci)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
- GitHub Check: website-deploy-preview
- GitHub Check: autofix
- GitHub Check: Summary
โจ Finishing Touches
๐งช Generate Unit Tests
- [ ] Create PR with Unit Tests
- [ ] Post Copyable Unit Tests in Comment
- [ ] Commit Unit Tests in branch
feature/dev-3104-support-configurable-atmos-version-output
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.
๐ชง 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. -
Explain this complex logic. -
Open a follow-up GitHub issue for this discussion.
-
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:-
@coderabbitai explain this code block. -
@coderabbitai modularize this function.
-
- PR comments: Tag
@coderabbitaiin 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 explain its main purpose. -
@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.
-
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
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 pauseto pause the reviews on a PR. -
@coderabbitai resumeto resume the paused reviews. -
@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository. -
@coderabbitai full reviewto do a full review from scratch and review all the files again. -
@coderabbitai summaryto regenerate the summary of the PR. -
@coderabbitai generate docstringsto generate docstrings for this PR. -
@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR. -
@coderabbitai auto-generate unit teststo generate unit tests for this PR. -
@coderabbitai resolveresolve all the CodeRabbit review comments. -
@coderabbitai configurationto show the current CodeRabbit configuration for the repository. -
@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryor@auto-summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaior@auto-titleanywhere in the PR title to generate the title automatically.
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.
These changes were released in v1.182.0.