8000 Fix describe stacks StringSlice flags by osterman · Pull Request #1317 · cloudposse/atmos · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix describe 8000 stacks StringSlice flags #1317

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

osterman
Copy link
Member
@osterman osterman commented 8000 Jun 18, 2025

Summary

  • parse --components, --component-types, and --sections as string slices
  • replicate panic when slice flags are defined as strings in a unit test
  • document the need to run go build before tests

https://chatgpt.com/codex/tasks/task_b_6852e5346c7483329a2a810e0d733569

Summary by CodeRabbit

  • New Features

    • Enhanced command-line flags for stack description to accept multiple values for components, component types, and sections.
  • Bug Fixes

    • Improved test coverage and error handling for flag parsing, ensuring correct behavior when using multi-value flags.
  • Documentation

    • Added guidance to build the project before running Go tests.

@osterman osterman requested a review from a team as a code owner June 18, 2025 23:49
Copy link
mergify bot commented Jun 18, 2025

💥 This pull request now has conflicts. Could you fix it @osterman? 🙏

@mergify mergify bot added the conflict This PR has conflicts label Jun 18, 2025
Copy link
Contributor
coderabbitai bot commented Jun 18, 2025
📝 Walkthrough

Walkthrough

This update changes three CLI flags in describeStacksCmd from accepting single string values to accepting multiple values as string slices. The corresponding tests are updated to support and validate this new behavior, including handling of comma-separated values and error scenarios. Documentation is also updated with a build instruction.

Changes

File(s) Summary
AGENTS.md Added instruction to run make build before executing Go tests.
cmd/describe_stacks.go Changed components, component-types, and sections flags from string to string slice type.
cmd/describe_stacks_test.go Enhanced tests for flag parsing, added new test cases for slice flags and error handling.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant FlagParser

    User->>CLI: Run describe-stacks with --components, --component-types, --sections (multiple values)
    CLI->>FlagParser: Parse flags as string slices
    FlagParser-->>CLI: Return parsed slices
    CLI-->>User: Proceed with command using multiple values for each flag
Loading

Possibly related PRs

Suggested labels

minor

Suggested reviewers

  • johncblandii

📜 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 8a2c245 and ba7b23e.

📒 Files selected for processing (1)
  • AGENTS.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • AGENTS.md
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: prepare
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: PR Semver Labels
  • GitHub Check: PR Size Labeler
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (macos-latest, macos)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Lint (golangci)
  • GitHub Check: Summary
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch codex/investigate-issue-#1309

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.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
AGENTS.md (1)

1-1: Helpful build instruction added.

The build prerequisite documentation is valuable for users running tests. Consider using the typographical ellipsis character (…) instead of three periods for better typography, though this is a minor style preference.

-Before running Go tests, build the project with `go build ./...`.
+Before running Go tests, build the project with `go build ./…`.
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fcb820 and 8a2c245.

📒 Files selected for processing (3)
  • AGENTS.md (1 hunks)
  • cmd/describe_stacks.go (1 hunks)
  • cmd/describe_stacks_test.go (5 hunks)
🧰 Additional context used
🪛 LanguageTool
AGENTS.md

[style] ~1-~1: Consider using the typographical ellipsis character here instead.
Context: ...unning Go tests, build the project with go build ./....

(ELLIPSIS)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (6)
cmd/describe_stacks.go (2)

136-140: Flag type changes look solid.

The conversion from String to StringSlice flags for components, component-types, and sections properly addresses the parsing issue mentioned in the PR objectives. The default value change from empty string to nil is appropriate for slice flags.


102-106: Type handling is robust.

The switch statement correctly handles []string types using GetStringSlice, and the panic for unsupported types provides clear error reporting. This aligns well with the test case that validates panic behavior.

cmd/describe_stacks_test.go (4)

43-43: Improved test isolation with initFlags approach.

The addition of the initFlags function field allows each test case to define exactly the flags it needs, improving test clarity and isolation. The comprehensive flag definitions match the actual command setup.

Also applies to: 52-63


122-150: Excellent test coverage for comma-separated parsing.

This test case validates that the StringSlice flags correctly parse comma-separated values, which is exactly what the flag type change was meant to enable. The expected values properly demonstrate the parsing behavior.


152-172: Smart panic test for type mismatch.

This test ensures that defining slice flags as String types triggers the expected panic with a clear error message. This validates the robustness of the type switching logic in setCliArgsForDescribeStackCli.


180-181: Clean test execution pattern.

The test execution properly calls initFlags before setting values, ensuring each test has the correct flag definitions. This maintains the improved isolation approach.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jun 18, 2025
@github-actions github-actions bot added the size/m Medium size PR label Jun 19, 2025
@mergify mergify bot removed the conflict This PR has conflicts label Jun 19, 2025
@osterman osterman added the patch A minor, backward compatible change label Jun 19, 2025
Copy link
codecov bot commented Jun 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.78%. Comparing base (913fe03) to head (ba7b23e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1317      +/-   ##
==========================================
+ Coverage   50.66%   50.78%   +0.12%     
==========================================
  Files         237      237              
  Lines       25777    25777              
==========================================
+ Hits        13061    13092      +31     
+ Misses      11085    11050      -35     
- Partials     1631     1635       +4     
Flag Coverage Δ
unittests 50.78% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

fs.String("file", "", "Write the result to file")
fs.String("format", "yaml", "Specify the output format (`yaml` is default)")
fs.StringP("stack", "s", "", "Filter by a specific stack\nThe filter supports names of the top-level stack manifests (including subfolder paths), and `atmos` stack names (derived from the context vars)")
fs.StringSlice("components", nil, "Filter by specific `atmos` components")
Copy link
Collaborator

Choose a reason for hiding this comment

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

These test cases would not have caught the bug that we faced with issue: #1309

It is testing setCliArgsForDescribeStackCli if that is what we are looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codex patch A minor, backward compatible change size/m Medium size PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0