atmos icon indicating copy to clipboard operation
atmos copied to clipboard

Add format flag to atmos version command

Open samtholiya opened this issue 8 months ago โ€ข 2 comments

what

  • image
  • 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.

samtholiya avatar Jun 21 '25 20:06 samtholiya

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.

codecov[bot] avatar Jun 21 '25 20:06 codecov[bot]

๐Ÿ“ 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.

โค๏ธ 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.
    • 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 @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @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 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 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 generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests 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 or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere 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.

coderabbitai[bot] avatar Jun 26 '25 21:06 coderabbitai[bot]

These changes were released in v1.182.0.

github-actions[bot] avatar Jul 01 '25 03:07 github-actions[bot]