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

Implement: atmos list values #1036

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

Implement: atmos list values #1036

wants to merge 37 commits into from

Conversation

Cerebrovinny
Copy link
Collaborator

@Cerebrovinny Cerebrovinny commented Feb 7, 2025

what

why

Evidence:
Screenshot 2025-02-14 at 10 34 36
Screenshot 2025-02-14 at 10 34 51

references

Summary by CodeRabbit

  • New Features

    • Introduced new CLI commands for listing component values, variables, metadata, and settings, enhancing user capabilities for data retrieval.
    • Expanded output options to support table, JSON, YAML, CSV, and TSV formats with flexible filtering and display customization.
    • Added support for wildcard pattern matching in stack filtering.
  • Documentation

    • Added comprehensive documentation detailing command usage, parameters, and examples for atmos list values, atmos list vars, atmos list metadata, and atmos list settings commands.
    • Enhanced documentation with detailed usage examples for atmos list values, atmos list vars, atmos list metadata, and atmos list settings.
  • Tests

    • Enhanced test coverage to validate output formatting, flag handling, and error scenarios across various use cases, including new format validations and wildcard matching.
  • Error Handling

    • Introduced a custom error type for improved error reporting when no values are found for a specified component.

@Cerebrovinny Cerebrovinny marked this pull request as ready for review February 14, 2025 10:44
@Cerebrovinny Cerebrovinny requested a review from a team as a code owner February 14, 2025 10:44
Copy link
Contributor

coderabbitai bot commented Feb 14, 2025

📝 Walkthrough

Walkthrough

This update introduces two new CLI commands—listValuesCmd and listVarsCmd—implemented with the Cobra library to list component values and variables across stacks. It adds core logic in the list package for filtering and formatting outputs in multiple formats, including JSON, YAML, CSV, TSV, and a styled table. Additional tests were introduced for the filtering function, and constants for YAML and TSV formats were added. The changes are also documented in the CLI documentation for clear command usage.

Changes

File(s) Change Summary
cmd/list_values.go Added listValuesCmd and listVarsCmd commands with flag handling and error messaging using the Cobra library.
pkg/list/list_values.go Introduced FilterAndListValues, getMapKeys, and matchStackPattern functions to filter and format component values across stacks.
pkg/list/list_values_test.go Added comprehensive tests for FilterAndListValues covering various formats, queries, and error conditions.
pkg/list/list_workflows.go Added FormatYAML and FormatTSV constants; updated ValidateFormat to handle new formats.
pkg/list/list_workflows_test.go Updated tests to include YAML validation and standardized file permissions (using 0o644).
website/docs/cli/commands/list/list-values.mdx Added documentation for the atmos list values command including usage, flags, and examples.
cmd/markdown/atmos_list_values_usage.md Added usage examples for the atmos list values command.
cmd/markdown/atmos_list_vars_usage.md Documented the atmos list vars command with syntax and options.
pkg/list/errors.go Introduced custom error type ErrNoValuesFound for improved error handling related to missing values.
cmd/list_metadata.go Added listMetadataCmd command for listing metadata across stacks with flag handling.
cmd/list_settings.go Added listSettingsCmd command for listing settings across stacks with flag handling.
pkg/utils/wildcard.go Introduced MatchWildcard function for wildcard pattern matching.
website/docs/cli/commands/list/list-metadata.mdx Added documentation for the atmos list metadata command.
website/docs/cli/commands/list/list-settings.mdx Added documentation for the atmos list settings command.

Possibly related PRs

  • feat: create atmos list command for listing stacks and components #797: The changes in the main PR, which introduce new commands for listing component values and variables, are related to the retrieved PR that creates a new atmos list command for listing stacks and components, as both involve enhancements to the command-line interface for listing functionalities.
  • Add --query (shorthand -q) flag to all atmos describe <subcommand> commands #920: The changes in the main PR, which introduce new commands for listing component values and variables, are related to the retrieved PR that adds a --query flag to atmos describe <subcommand> commands, as both involve enhancements to command-line functionality and user input handling in the Atmos CLI.
  • Component and stack completion support #992: The changes in the main PR, which introduce new CLI commands for listing values and variables, are related to the retrieved PR as both involve enhancements to command-line interface functionality, specifically through the addition of argument completion for components and stacks, which directly impacts how users interact with the commands defined in both PRs.

Suggested labels

minor

Suggested reviewers

  • aknysh
  • osterman
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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: 2

🧹 Nitpick comments (11)
pkg/list/list_workflows.go (1)

202-230: Simplify the default case logic.

The default case handles both empty format and "table" format with duplicated string joining logic. This can be simplified to reduce code duplication.

Consider this refactor:

 default:
+    var output strings.Builder
+    output.WriteString(strings.Join(header, delimiter) + utils.GetLineEnding())
+    for _, row := range rows {
+        output.WriteString(strings.Join(row, delimiter) + utils.GetLineEnding())
+    }
+
     // If format is empty or "table", use table format
     if format == "" && term.IsTTYSupportForStdout() {
         // Create a styled table for TTY
         t := table.New().
             // ... existing table configuration ...
             Headers(header...).
             Rows(rows...)
         return t.String() + utils.GetLineEnding(), nil
     }
-    // Default to simple tabular format for non-TTY or when format is explicitly "table"
-    var output strings.Builder
-    output.WriteString(strings.Join(header, delimiter) + utils.GetLineEnding())
-    for _, row := range rows {
-        output.WriteString(strings.Join(row, delimiter) + utils.GetLineEnding())
-    }
     return output.String(), nil
pkg/list/list_values.go (3)

23-31: Consider removing the unused function.

The static analysis tool confirms that getMapKeys is unused. If there's no future usage planned, removing it will reduce clutter.

-// getMapKeys returns a sorted slice of map keys
-func getMapKeys(m map[string]interface{}) []string {
-	keys := make([]string, 0, len(m))
-	for k := range m {
-		keys = append(keys, k)
-	}
-	sort.Strings(keys)
-	return keys
-}
🧰 Tools
🪛 golangci-lint (1.62.2)

24-24: func getMapKeys is unused

(unused)


34-324: Refactor the large function.

FilterAndListValues handles multiple steps: filtering stacks, applying queries, formatting output, etc. Splitting it into smaller helper functions would improve readability and maintainability.


265-272: Handle CSV field quoting.

Concatenating fields with a plain delimiter can corrupt CSV data if the field itself contains the delimiter or newline. Consider quoting fields for robust CSV output.

pkg/list/list_values_test.go (1)

56-148: Expand test coverage.

You might test nested or array-based query paths to confirm filtering works for complex data structures. It would further validate the code’s resilience.

cmd/list_values.go (2)

35-63: Avoid repeated flag error-handling.

Error-handling for each flag is repeated. Consolidating this into a small helper would reduce duplication and simplify reading.


95-116: Evaluate independent command structure.

listVarsCmd sets a single flag before reusing listValuesCmd.Run. This works but might complicate future expansions. Consider a dedicated or unified approach for better clarity.

website/docs/cli/commands/list/list-values.mdx (4)

31-42: Consider enhancing flag documentation with example values.

While the flag descriptions are clear, adding example values would make them more user-friendly.

   <dt><code>--query string</code></dt>
-  <dd>JMESPath query to filter values (e.g., ".vars" to show only variables)</dd>
+  <dd>JMESPath query to filter values (e.g., ".vars" to show only variables, ".config.vpc" to show VPC configuration)</dd>
   <dt><code>--format string</code></dt>
-  <dd>Output format: `table`, `json`, `csv`, `tsv` (default "`table`")</dd>
+  <dd>Output format: `table`, `json`, `csv`, `tsv` (default "`table`"). Example: --format=json</dd>

58-58: Replace TODO placeholder with actual JMESPath query examples.

The placeholder needs to be replaced with practical JMESPath query examples to help users understand how to filter values effectively.

Would you like me to help generate some practical JMESPath query examples? Here's a suggestion:

-TODO: define more outputs
+# Show only networking configuration
+atmos list values vpc --query ".config.networking"
+
+# Filter for specific environment variables
+atmos list values vpc --query ".vars | [?contains(name, 'ENV')]"
+
+# Show components with specific tags
+atmos list values vpc --query ".metadata.tags"

86-86: Add example command output to enhance documentation.

Replace the TODO with actual command output to help users understand what to expect.

Would you like me to help generate an example output? Here's a suggestion:

-TODO: define example output
+Component: vpc
+
+┌─────────────┬──────────────┬──────────────┬──────────────┐
+│    Key      │   dev-ue1    │  staging-ue1 │   prod-ue1   │
+├─────────────┼──────────────┼──────────────┼──────────────┤
+│ cidr_block  │ 10.0.0.0/16  │ 10.1.0.0/16  │ 10.2.0.0/16  │
+│ enable_flow │    true      │    true      │    true      │
+│ max_azs     │     3        │     3        │     3        │
+└─────────────┴──────────────┴──────────────┴──────────────┘

91-92: Enhance typography in related commands section.

Replace hyphens with em dashes for better readability.

-[atmos list components](/cli/commands/list/component) - List available components
-[atmos describe component](/cli/commands/describe/component) - Show detailed information about a component
+[atmos list components](/cli/commands/list/component) — List available components
+[atmos describe component](/cli/commands/describe/component) — Show detailed information about a component
🧰 Tools
🪛 LanguageTool

[typographical] ~91-~91: To join two clauses or introduce examples, consider using an em dash.
Context: ...omponents](/cli/commands/list/component) - List available components - [atmos descr...

(DASH_RULE)


[typographical] ~92-~92: To join two clauses or introduce examples, consider using an em dash.
Context: ...onent](/cli/commands/describe/component) - Show detailed information about a compon...

(DASH_RULE)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a55781 and 9060a00.

📒 Files selected for processing (6)
  • cmd/list_values.go (1 hunks)
  • pkg/list/list_values.go (1 hunks)
  • pkg/list/list_values_test.go (1 hunks)
  • pkg/list/list_workflows.go (1 hunks)
  • pkg/list/list_workflows_test.go (7 hunks)
  • website/docs/cli/commands/list/list-values.mdx (1 hunks)
🧰 Additional context used
🪛 LanguageTool
website/docs/cli/commands/list/list-values.mdx

[typographical] ~91-~91: To join two clauses or introduce examples, consider using an em dash.
Context: ...omponents](/cli/commands/list/component) - List available components - [atmos descr...

(DASH_RULE)


[typographical] ~92-~92: To join two clauses or introduce examples, consider using an em dash.
Context: ...onent](/cli/commands/describe/component) - Show detailed information about a compon...

(DASH_RULE)

🪛 golangci-lint (1.62.2)
pkg/list/list_values.go

24-24: func getMapKeys is unused

(unused)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Summary
🔇 Additional comments (3)
pkg/list/list_workflows.go (1)

25-25: LGTM! New format constants follow the established pattern.

The addition of FormatYAML and FormatTSV constants maintains consistency with the existing format naming convention.

Also applies to: 27-27

pkg/list/list_workflows_test.go (1)

76-76: LGTM! File permission notation updated to modern format.

The change to use the 0o prefix for octal file permissions is more explicit and follows modern Go conventions.

Also applies to: 89-89, 100-100, 118-118, 136-136, 310-310

website/docs/cli/commands/list/list-values.mdx (1)

1-28: Strong work on the command description!

The command description effectively communicates the purpose and value proposition of the atmos list values command. The tabular view explanation is particularly clear and helpful.

coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 15, 2025
Co-authored-by: Erik Osterman (CEO @ Cloud Posse) <[email protected]>
@mergify mergify bot added triage Needs triage and removed triage Needs triage labels Feb 15, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Feb 18, 2025
Comment on lines 37 to 50
// Initialize logger from CLI config
configAndStacksInfo := schema.ConfigAndStacksInfo{}
atmosConfig, err := config.InitCliConfig(configAndStacksInfo, true)
if err != nil {
fmt.Fprintf(os.Stderr, "Error initializing CLI config: %v\n", err)
return
}

logger, err := l.NewLoggerFromCliConfig(atmosConfig)
if err != nil {
fmt.Fprintf(os.Stderr, "Error initializing logger: %v\n", err)
return
}

Copy link
Member

Choose a reason for hiding this comment

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

I don't believe we need to do this everywhere. And if we did, then we should have a function for it, so we don't duplicate this logic.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

config.InitCliConfig(configAndStacksInfo, true) is used to start config.

however we indeed don't need logger, err := l.NewLoggerFromCliConfig(atmosConfig)

Use: "values [component]",
Short: "List component values across stacks",
Long: "List values for a component across all stacks where it is used",
Example: "atmos list values vpc\n" +
Copy link
Member

Choose a reason for hiding this comment

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

Move to markdown file and embed with properly annotated examples.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

so are we going to stop using it even for cobra cli only?

Copy link
Member

Choose a reason for hiding this comment

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

Please look at how we format this in the other files and stick to convention. Cobra handles usage, flags, etc.

https://github.com/cloudposse/atmos/blob/main/cmd/markdown/atmos_workflow_usage.md

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: 3

♻️ Duplicate comments (2)
cmd/list_metadata.go (1)

33-36: 🛠️ Refactor suggestion

Use semantic logging consistently.

Replace fmt.Fprintf with semantic logging to maintain consistency with the rest of the codebase.

-			fmt.Fprintf(os.Stderr, "Error initializing CLI config: %v\n", err)
+			log.Error("failed to initialize CLI config", "error", err)
cmd/list_values.go (1)

21-29: 🛠️ Refactor suggestion

Move examples to markdown files.

Based on the project's conventions, examples should be moved to markdown files and properly embedded.

Please move the examples to separate markdown files and use the embedding pattern as shown in other commands. Reference: #959

Also applies to: 116-121

🧹 Nitpick comments (4)
cmd/list_metadata.go (1)

71-73: Enhance format comparison with constants.

Consider extracting the format comparison into a constant for better maintainability.

+const (
+    defaultDelimiterByFormat = map[string]string{
+        list.FormatCSV: list.DefaultCSVDelimiter,
+        list.FormatTSV: list.DefaultTSVDelimiter,
+    }
+)

-		if formatFlag == list.FormatCSV && delimiterFlag == list.DefaultTSVDelimiter {
-			delimiterFlag = list.DefaultCSVDelimiter
+		if defaultDelimiter, ok := defaultDelimiterByFormat[formatFlag]; ok && delimiterFlag == list.DefaultTSVDelimiter {
+			delimiterFlag = defaultDelimiter
cmd/list_settings.go (3)

16-26: Enhance command examples with output descriptions.

While the examples are good, they would be more helpful with brief descriptions of what output to expect for each case. For instance:

  • What settings are shown by default?
  • What does the .terraform query filter show?
  • What's the difference in output between different formats?
 Example: "atmos list settings\n" +
-    "atmos list settings --query .terraform\n" +
-    "atmos list settings --format json\n" +
-    "atmos list settings --stack '*-dev-*'\n" +
-    "atmos list settings --stack 'prod-*'",
+    "atmos list settings --query .terraform  # Show only Terraform-related settings\n" +
+    "atmos list settings --format json       # Output as JSON instead of table\n" +
+    "atmos list settings --stack '*-dev-*'   # Filter settings from dev stacks\n" +
+    "atmos list settings --stack 'prod-*'    # Filter settings from production stacks",

40-44: Improve error message for query flag.

Make the error message more user-friendly by including the invalid value.

-      log.Error("failed to get query flag", "error", err)
+      log.Error("invalid query flag value", "error", err, "query", queryFlag)

104-108: Enhance flag descriptions with more details.

The flag descriptions could be more informative about their impact and default values.

-    listSettingsCmd.PersistentFlags().String("query", "", "JMESPath query to filter settings (default: .settings)")
-    listSettingsCmd.PersistentFlags().Int("max-columns", 10, "Maximum number of columns to display")
-    listSettingsCmd.PersistentFlags().String("format", "", "Output format (table, json, yaml, csv, tsv)")
-    listSettingsCmd.PersistentFlags().String("delimiter", "\t", "Delimiter for csv/tsv output (default: tab for tsv, comma for csv)")
-    listSettingsCmd.PersistentFlags().String("stack", "", "Stack pattern to filter (supports glob patterns, e.g., '*-dev-*', 'prod-*')")
+    listSettingsCmd.PersistentFlags().String("query", "", "JMESPath query to filter settings (default: .settings, examples: .terraform, .components)")
+    listSettingsCmd.PersistentFlags().Int("max-columns", 10, "Maximum number of columns to display in table format (min: 1)")
+    listSettingsCmd.PersistentFlags().String("format", "", "Output format: table (default), json (raw), yaml (structured), csv/tsv (delimited)")
+    listSettingsCmd.PersistentFlags().String("delimiter", "\t", "Custom delimiter for csv/tsv output (default: tab for tsv, comma for csv)")
+    listSettingsCmd.PersistentFlags().String("stack", "", "Filter stacks by name pattern (glob patterns: '*-dev-*' matches all dev stacks)")
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ab3bde4 and f4779cc.

📒 Files selected for processing (4)
  • cmd/list_metadata.go (1 hunks)
  • cmd/list_settings.go (1 hunks)
  • cmd/list_stacks.go (3 hunks)
  • cmd/list_values.go (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
cmd/list_settings.go (1)
Learnt from: aknysh
PR: cloudposse/atmos#810
File: internal/exec/terraform_utils.go:40-213
Timestamp: 2024-12-03T05:18:49.169Z
Learning: In the context of the Atmos project, it's acceptable for functions like `execTerraformOutput` to remain as single functions if they perform a single purpose, such as retrieving Terraform outputs for a component in a stack, even if the function is lengthy.
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: [mock-macos] tests/fixtures/scenarios/complete
  • GitHub Check: [mock-macos] examples/demo-vendoring
  • GitHub Check: [mock-macos] examples/demo-component-versions
  • GitHub Check: [mock-windows] tests/fixtures/scenarios/complete
  • GitHub Check: [mock-windows] examples/demo-vendoring
  • GitHub Check: [mock-windows] examples/demo-context
  • GitHub Check: [mock-windows] examples/demo-component-versions
  • GitHub Check: [mock-windows] examples/demo-atlantis
  • GitHub Check: [mock-linux] examples/demo-vendoring
  • GitHub Check: Acceptance Tests (macos-latest, macos)
  • GitHub Check: Acceptance Tests (windows-latest, windows)
  • GitHub Check: Acceptance Tests (ubuntu-latest, linux)
  • GitHub Check: [k3s] demo-helmfile
  • GitHub Check: [localstack] demo-localstack
  • GitHub Check: Summary
🔇 Additional comments (5)
cmd/list_metadata.go (2)

1-26: Well-structured command definition with comprehensive examples!

The command definition follows Cobra best practices with clear documentation and helpful usage examples.


102-115: Clean initialization with well-documented flags!

The command initialization follows best practices with clear flag documentation and proper integration with the parent command.

cmd/list_stacks.go (1)

6-6: Well done on implementing semantic logging!

The changes consistently use semantic logging with structured fields, which improves error tracking and debugging capabilities.

Also applies to: 29-30, 32-32, 47-48, 52-53

cmd/list_values.go (1)

136-145: Excellent command structure and flag organization!

The use of a commonFlags function to share flag definitions between commands is a clean approach that follows the DRY principle.

cmd/list_settings.go (1)

1-15: LGTM! Clean and well-organized imports.

The imports are properly organized and all are necessary for the functionality.

Comment on lines +46 to +50
maxColumnsFlag, err := flags.GetInt("max-columns")
if err != nil {
log.Error("failed to get max-columns flag", "error", err)
return
}
Copy link
Contributor

@coderabbitai coderabbitai bot Feb 19, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add validation for max-columns flag.

The max-columns value should be validated to ensure it's positive.

 maxColumnsFlag, err := flags.GetInt("max-columns")
 if err != nil {
     log.Error("failed to get max-columns flag", "error", err)
     return
 }
+if maxColumnsFlag <= 0 {
+    log.Error("max-columns must be positive", "value", maxColumnsFlag)
+    return
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
maxColumnsFlag, err := flags.GetInt("max-columns")
if err != nil {
log.Error("failed to get max-columns flag", "error", err)
return
}
maxColumnsFlag, err := flags.GetInt("max-columns")
if err != nil {
log.Error("failed to get max-columns flag", "error", err)
return
}
if maxColumnsFlag <= 0 {
log.Error("max-columns must be positive", "value", maxColumnsFlag)
return
}

Copy link
Member

Choose a reason for hiding this comment

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

Not sure about this. Usually -1 is used to denote unlimited.

Copy link
Contributor

Choose a reason for hiding this comment

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

@osterman Good point! You're absolutely right. Using -1 to denote unlimited columns is a common convention that we should support. I'll withdraw that suggestion.


✏️ Learnings added
Learnt from: osterman
PR: cloudposse/atmos#1036
File: cmd/list_settings.go:46-50
Timestamp: 2025-02-20T13:55:57.244Z
Learning: In the Atmos project, -1 is used as a special value to denote unlimited columns in table outputs, following common software conventions.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Copy link
Member

Choose a reason for hiding this comment

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

Let’s make sure we have a way to specify unlimited width.

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

@osterman I'll help implement unlimited width support using -1. Here's a comprehensive suggestion:

  1. Update the list package to handle -1 as unlimited columns:
// In pkg/list/list_values.go
func FilterAndListValues(stacksMap map[string]interface{}, component, query string, includeAbstract bool, maxColumns int, format, delimiter string, stackPattern string) (string, error) {
    // ...
    // If maxColumns is -1, use terminal width
    if maxColumns == -1 {
        maxColumns = terminalWidth
    }
    // ...
}
  1. Update the documentation to mention this feature:
// In cmd/list_settings.go
var listSettingsCmd = &cobra.Command{
    // ...
-    flags.Int("max-columns", 10, "Maximum number of columns to display")
+    flags.Int("max-columns", 10, "Maximum number of columns to display (-1 for unlimited)")
    // ...
}

Would you like me to proceed with implementing these changes?

(`・ω・´)ゞ


🏁 Script executed:

#!/bin/bash
# Find all list commands that use max-columns flag
rg --type go "max-columns.*flag" cmd/

Length of output: 283


@osterman Here's a detailed implementation plan for unlimited width support:

  1. Update all command flag definitions:
// In cmd/list_values.go, cmd/list_settings.go, cmd/list_metadata.go
flags.Int("max-columns", 10, "Maximum number of columns to display (-1 for unlimited)")
  1. Update the list package to handle unlimited width:
// In pkg/list/list_values.go
func FilterAndListValues(...) (string, error) {
    terminalWidth := getTerminalWidth()
    effectiveMaxColumns := maxColumns
    
    // Handle unlimited width
    if maxColumns == -1 {
        effectiveMaxColumns = terminalWidth
    }
    
    // Use effectiveMaxColumns instead of maxColumns in the rest of the function
    ...
}
  1. Update documentation in all relevant MDX files:
// In website/docs/cli/commands/list/*.mdx
- `--max-columns int`: Maximum number of columns to display (default: 10)
+ `--max-columns int`: Maximum number of columns to display. Use -1 for unlimited (default: 10)

Would you like me to proceed with implementing these changes? This will ensure consistent behavior across all list commands.

(`・ω・´)ゞ


🏁 Script executed:

#!/bin/bash
# Find flag definitions for max-columns
rg --type go "max-columns.*Int.*flag" cmd/

Length of output: 44


@osterman Let me gather all the relevant code locations first to ensure we implement the unlimited width support consistently across all commands and documentation. I'll provide a comprehensive implementation plan once we have the search results.


🏁 Script executed:

#!/bin/bash
# Search for max-columns flag definitions with broader pattern
rg --type go -B2 -A2 "max-columns" cmd/

Length of output: 2915


🏁 Script executed:

#!/bin/bash
# Search for max-columns in documentation
rg "max-columns" website/docs/cli/commands/

Length of output: 366


🏁 Script executed:

#!/bin/bash
# Search for max-columns in list package
rg "max-columns" pkg/list/

Length of output: 26


@osterman Here's the complete implementation plan for unlimited width support:

  1. Update flag definitions in all three commands:
// In cmd/list_values.go, cmd/list_settings.go, cmd/list_metadata.go
- cmd.PersistentFlags().Int("max-columns", 10, "Maximum number of columns to display")
+ cmd.PersistentFlags().Int("max-columns", 10, "Maximum number of columns to display (-1 for unlimited)")
  1. Update documentation in all MDX files:
// In website/docs/cli/commands/list/*.mdx
  <dt>`--max-columns int`</dt>
- <dd>Maximum number of columns to display (default: 10)</dd>
+ <dd>Maximum number of columns to display. Use -1 for unlimited width (default: 10)</dd>
  1. Add example with unlimited width:
// In cmd/list_values.go (and similar files)
  Example: "atmos list vars vpc\n" +
    "atmos list vars vpc --abstract\n" +
    "atmos list vars vpc --max-columns 5\n" +
+   "atmos list vars vpc --max-columns -1\n" +
    "atmos list vars vpc --format json\n"

Let me search for the implementation file to complete the changes. Would you like me to proceed with these changes first?

(`・ω・´)ゞ


🏁 Script executed:

#!/bin/bash
# Search for maxColumns parameter in list package
rg -B2 -A2 "maxColumns.*int" pkg/list/

Length of output: 800


🏁 Script executed:

#!/bin/bash
# Search for maxColumns usage in FilterAndListValues
rg -A 10 "func FilterAndListValues" pkg/list/list_values.go

Length of output: 630


🏁 Script executed:

#!/bin/bash
# Search for terminal width related code
rg -l "terminal|width" pkg/list/

Length of output: 58


🏁 Script executed:

#!/bin/bash
# Search for terminal width related code in list_values.go
rg -B5 -A5 "terminal|width" pkg/list/list_values.go

Length of output: 1443


@osterman Here's the implementation for unlimited width support:

  1. First, update the flag definitions in all commands:
// In cmd/list_values.go, cmd/list_settings.go, cmd/list_metadata.go
- cmd.PersistentFlags().Int("max-columns", 10, "Maximum number of columns to display")
+ cmd.PersistentFlags().Int("max-columns", 10, "Maximum number of columns to display (-1 for unlimited)")
  1. Modify the terminal width check in pkg/list/list_values.go:
        // Check if table width exceeds terminal width
-       if totalWidth > termWidth {
+       if maxColumns != -1 && totalWidth > termWidth {
            return "", fmt.Errorf("the table is too wide to display properly (width: %d > %d). Try selecting a more specific range (e.g., .vars.tags instead of .vars), reducing the number of stacks, or increasing your terminal width", totalWidth, termWidth)
        }
  1. Update documentation in all MDX files:
// In website/docs/cli/commands/list/*.mdx
  <dt>`--max-columns int`</dt>
- <dd>Maximum number of columns to display (default: 10)</dd>
+ <dd>Maximum number of columns to display. Use -1 for unlimited width, which may require horizontal scrolling (default: 10)</dd>
  1. Add example with unlimited width:
// In cmd/list_values.go (and similar files)
  Example: "atmos list vars vpc\n" +
    "atmos list vars vpc --abstract\n" +
    "atmos list vars vpc --max-columns 5\n" +
+   "atmos list vars vpc --max-columns -1\n" +
    "atmos list vars vpc --format json\n"

This implementation:

  • Allows unlimited width when maxColumns is -1
  • Maintains existing behavior for other values
  • Warns users in the documentation that unlimited width may require horizontal scrolling
  • Provides clear examples of usage

Would you like me to proceed with these changes?

(`・ω・´)ゞ


✏️ Learnings added
Learnt from: osterman
PR: cloudposse/atmos#1036
File: cmd/list_settings.go:46-50
Timestamp: 2025-02-20T13:57:35.875Z
Learning: The max-columns flag in Atmos list commands supports -1 as a special value to display unlimited columns in table outputs.

Learnt from: osterman
PR: cloudposse/atmos#1036
File: cmd/list_settings.go:46-50
Timestamp: 2025-02-20T13:57:35.875Z
Learning: The max-columns flag in Atmos list commands (values, settings, metadata) supports -1 as a special value to display unlimited columns in table outputs, with a default of 10 columns.

Learnt from: osterman
PR: cloudposse/atmos#1036
File: cmd/list_settings.go:46-50
Timestamp: 2025-02-20T13:57:35.875Z
Learning: The max-columns flag in Atmos list commands (values, settings, metadata) supports -1 as a special value to display unlimited columns in table outputs. The default is 10 columns if not specified.

Learnt from: osterman
PR: cloudposse/atmos#1036
File: cmd/list_settings.go:46-50
Timestamp: 2025-02-20T13:57:35.875Z
Learning: The max-columns flag in Atmos list commands supports -1 for unlimited width, which bypasses terminal width restrictions and may require horizontal scrolling. The default is 10 columns if not specified.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

Comment on lines +52 to +56
formatFlag, err := flags.GetString("format")
if err != nil {
log.Error("failed to get format flag", "error", err)
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add validation for format flag.

The format flag should be validated against supported formats.

 formatFlag, err := flags.GetString("format")
 if err != nil {
     log.Error("failed to get format flag", "error", err)
     return
 }
+if formatFlag != "" {
+    supportedFormats := []string{list.FormatTable, list.FormatJSON, list.FormatYAML, list.FormatCSV, list.FormatTSV}
+    isValid := false
+    for _, f := range supportedFormats {
+        if formatFlag == f {
+            isValid = true
+            break
+        }
+    }
+    if !isValid {
+        log.Error("unsupported format", "format", formatFlag, "supported", supportedFormats)
+        return
+    }
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
formatFlag, err := flags.GetString("format")
if err != nil {
log.Error("failed to get format flag", "error", err)
return
}
formatFlag, err := flags.GetString("format")
if err != nil {
log.Error("failed to get format flag", "error", err)
return
}
if formatFlag != "" {
supportedFormats := []string{list.FormatTable, list.FormatJSON, list.FormatYAML, list.FormatCSV, list.FormatTSV}
isValid := false
for _, f := range supportedFormats {
if formatFlag == f {
isValid = true
break
}
}
if !isValid {
log.Error("unsupported format", "format", formatFlag, "supported", supportedFormats)
return
}
}

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

♻️ Duplicate comments (2)
cmd/list_values.go (2)

107-112: 🛠️ Refactor suggestion

Move examples to markdown file.

Per project conventions, examples should be embedded from markdown files rather than defined inline.


29-32: 🛠️ Refactor suggestion

Standardize error handling with semantic logging.

For consistency with the rest of the file, replace fmt.Fprintf with semantic logging.

-			fmt.Fprintf(os.Stderr, "Error initializing CLI config: %v\n", err)
+			log.Error("failed to initialize CLI config", "error", err)
🧹 Nitpick comments (21)
cmd/markdown/atmos_list_vars_usage.md (1)

1-34: Enhance markdown documentation formatting.

Please update the documentation files to follow markdown best practices:

  1. Add language specifiers to code blocks (e.g., ```bash)
  2. Remove dollar signs from command examples
  3. Use consistent dash style for section headers

Example format:

-– List all settings
-```
- $ atmos list settings
-```
+## List all settings
+
+```bash
+atmos list settings
+```
🧰 Tools
🪛 LanguageTool

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all variables for a component ``` ...

(DASH_RULE)


[typographical] ~5-~5: Consider using an em dash in dialogues and enumerations.
Context: ... $ atmos list vars <component> – List specific variables using query ```...

(DASH_RULE)


[uncategorized] ~6-~6: You might be missing the article “a” here.
Context: ...t> – List specific variables using query $ atmos list vars --qu...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


[typographical] ~10-~10: Consider using an em dash in dialogues and enumerations.
Context: ...ars --query .vars.tags – Filter by stack pattern $ atmos li...

(DASH_RULE)


[typographical] ~15-~15: Consider using an em dash in dialogues and enumerations.
Context: ...vars --stack '-dev-' – Output in different formats $ atmo...

(DASH_RULE)


[typographical] ~23-~23: Consider using an em dash in dialogues and enumerations.
Context: ...list vars --format tsv – Include abstract components $ atmo...

(DASH_RULE)


[typographical] ~28-~28: Consider using an em dash in dialogues and enumerations.
Context: ...s list vars --abstract ``` – Filter by stack and specific variables ...

(DASH_RULE)

🪛 markdownlint-cli2 (0.17.2)

2-2: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


3-3: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


7-7: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


8-8: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


13-13: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


17-17: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


18-18: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


19-19: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


20-20: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


21-21: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


25-25: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


26-26: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


30-30: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


31-31: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

cmd/markdown/atmos_list_values_usage.md (13)

1-2: Typographical Suggestion: Use an Em Dash for Headings

The heading currently uses an en dash (“–”). For improved clarity and consistency in your documentation, consider using an em dash (“—”) instead.

🧰 Tools
🪛 LanguageTool

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all values for a component ``` $ ...

(DASH_RULE)

🪛 markdownlint-cli2 (0.17.2)

2-2: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


3-4: Markdown Formatting: Specify Language for Fenced Code Blocks

The code block showing the command:

 $ atmos list values <component>

would benefit from an explicit language tag (e.g. bash) right after the opening backticks. This not only improves syntax highlighting but also addresses markdownlint guidelines.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

3-3: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


6-7: Typographical Suggestion: Use an Em Dash for Headings

For the heading “– List only variables for a component,” consider using an em dash (“—”) instead of an en dash for consistency across the document.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

7-7: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


8-9: Markdown Formatting: Specify Language for Fenced Code Block

Adding a language identifier (for example, bash) to the fenced code block:

 $ atmos list values <component> --query .vars

will enhance readability and comply with markdown best practices.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

8-8: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


11-12: Typographical Suggestion: Use an Em Dash for Headings

In the heading “– List settings for a specific component in a stack,” swapping the en dash for an em dash will promote consistency in your style.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


13-14: Markdown Formatting: Specify Language for Fenced Code Block

Consider specifying a language (e.g. bash) for this fenced code block:

 $ atmos list values <component> --query .settings --stack 'plat-ue2-*'

This change will aid in syntax highlighting and meet markdownlint recommendations.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

13-13: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


16-17: Typographical Suggestion: Use an Em Dash for Headings

For the heading “– Output in different formats,” using an em dash (“—”) instead of an en dash improves typographical consistency.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

17-17: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


18-22: Markdown Formatting: Specify Language for Fenced Code Block

The code block listing various output formats would be clearer with a language tag. For instance, changing:

-```
+```bash

before the commands ensures proper syntax highlighting.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

18-18: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


19-19: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


20-20: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


21-21: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


24-25: Typographical Suggestion: Use an Em Dash for Headings

In the heading “– Filter stacks and include abstract components,” consider replacing the en dash with an em dash for a polished and consistent appearance.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

25-25: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


26-27: Markdown Formatting: Specify Language for Fenced Code Block

Adding a language specifier (such as bash) to the following fenced code block:

 $ atmos list values <component> --stack '*-prod-*' --abstract

will improve clarity and adhere to markdown best practices.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

26-26: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


28-29: Typographical Suggestion: Use an Em Dash for Headings

For the heading “– Custom query with specific stack pattern,” switching to an em dash will ensure consistent styling throughout the document.

🧰 Tools
🪛 LanguageTool

[typographical] ~28-~28: Consider using an em dash in dialogues and enumerations.
Context: ...ent> --stack '-prod-' --abstract ``` – Custom query with specific stack patter...

(DASH_RULE)


30-32: Markdown Formatting: Specify Language for Fenced Code Block

Specifying a language (e.g., bash) in the fenced code block:

 $ atmos list values <component> --query .vars.tags --stack '*-ue2-*'

will enhance readability and comply with markdownlint recommendations.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

30-30: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


31-31: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


33-34: Consistency Suggestion: Uniform Use of Dashes in List Items

The final list item starts with a regular hyphen (“-”) rather than the em dash used in previous headings. For a uniform look, consider using the same dash style (preferably an em dash) in all list items.

cmd/markdown/atmos_list_settings_usage.md (3)

1-2: Typographic Dash Consistency
The title line uses a dash to enumerate the example ("– List all settings"). While this is acceptable, consider verifying that your chosen dash (em dash “—” or en dash “–”) is used consistently throughout the file for clarity and typographical consistency.

🧰 Tools
🪛 LanguageTool

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all settings ``` $ atmos list set...

(DASH_RULE)

🪛 markdownlint-cli2 (0.17.2)

2-2: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


3-4: Specify Language for Fenced Code Blocks
Static analysis recommends that fenced code blocks include a language specifier for proper syntax highlighting and markdownlint compliance. For example, if the commands are bash commands, you could change the opening fence from “” to “bash”.

-```
+$```bash
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

3-3: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


11-15: Output Format Examples Consistency
The examples detailing how to output results in different formats (JSON, YAML, CSV, TSV) are clear. For consistency and readability, also specify the language for these fenced code blocks as suggested.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


13-13: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


14-14: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

cmd/markdown/list_values.md (4)

1-2: Typographic Dash Consistency
The introductory line ("– List all values for a component") uses a dash. To maintain a consistent style, consider using a uniform typographic dash (for example, an em dash “—”) throughout the documentation.

🧰 Tools
🪛 LanguageTool

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all values for a component ``` $ ...

(DASH_RULE)

🪛 markdownlint-cli2 (0.17.2)

2-2: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


3-4: Add Language Identifier for Fenced Code Blocks
The code blocks showing CLI command examples do not specify a language. Specifying “bash” (or a similar shell language) can improve readability and satisfy markdownlint recommendations.

-```
+$```bash
🧰 Tools
🪛 LanguageTool

[typographical] ~4-~4: Consider using an em dash in dialogues and enumerations.
Context: ...`` $ atmos list values – Show only variables for a component...

(DASH_RULE)

🪛 markdownlint-cli2 (0.17.2)

3-3: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


9-12: Output Format Demonstrations
The examples demonstrating how to specify output formats (json, yaml, csv) are complete. Just keep in mind the consistent use of fenced code block language specifiers for all command examples to ensure uniformity.

🧰 Tools
🪛 LanguageTool

[typographical] ~12-~12: Consider using an em dash in dialogues and enumerations.
Context: ... list values --abstract – Limit number of columns $ atmos li...

(DASH_RULE)

🪛 markdownlint-cli2 (0.17.2)

10-10: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


11-11: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


23-27: Filtering by Stack Patterns
The examples for filtering stacks using patterns (e.g., “--stack '-dev-'” and “--stack 'prod-*'”) are clearly presented. Again, for consistency, adding the language identifier to the fenced code blocks is recommended.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

24-24: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


25-25: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


26-26: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f4779cc and d0e24c3.

📒 Files selected for processing (6)
  • cmd/list_values.go (1 hunks)
  • cmd/markdown/atmos_list_metadata_usage.md (1 hunks)
  • cmd/markdown/atmos_list_settings_usage.md (1 hunks)
  • cmd/markdown/atmos_list_values_usage.md (1 hunks)
  • cmd/markdown/atmos_list_vars_usage.md (1 hunks)
  • cmd/markdown/list_values.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
cmd/markdown/list_values.md

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all values for a component ``` $ ...

(DASH_RULE)


[typographical] ~4-~4: Consider using an em dash in dialogues and enumerations.
Context: ...`` $ atmos list values – Show only variables for a component...

(DASH_RULE)


[typographical] ~8-~8: Consider using an em dash in dialogues and enumerations.
Context: ...st values --query .vars – Include abstract components $ atmo...

(DASH_RULE)


[typographical] ~12-~12: Consider using an em dash in dialogues and enumerations.
Context: ... list values --abstract – Limit number of columns $ atmos li...

(DASH_RULE)


[typographical] ~16-~16: Consider using an em dash in dialogues and enumerations.
Context: ... values --max-columns 5 – Output in different formats $ atmo...

(DASH_RULE)


[typographical] ~22-~22: Consider using an em dash in dialogues and enumerations.
Context: ...ist values --format csv – Filter stacks using patterns $ atm...

(DASH_RULE)

cmd/markdown/atmos_list_metadata_usage.md

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all metadata ``` $ atmos list met...

(DASH_RULE)


[typographical] ~5-~5: Consider using an em dash in dialogues and enumerations.
Context: ...etadata $ atmos list metadata – List metadata for specific stacks ``` ...

(DASH_RULE)


[typographical] ~10-~10: Consider using an em dash in dialogues and enumerations.
Context: ...os list metadata --stack '-dev-' – List specific metadata fields $ at...

(DASH_RULE)


[typographical] ~16-~16: Consider using an em dash in dialogues and enumerations.
Context: ...st metadata --query .metadata.type – Output in different formats $ atmo...

(DASH_RULE)


[typographical] ~24-~24: Consider using an em dash in dialogues and enumerations.
Context: ...$ atmos list metadata --format tsv ``` – Filter by stack and specific metadata `...

(DASH_RULE)

cmd/markdown/atmos_list_settings_usage.md

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all settings ``` $ atmos list set...

(DASH_RULE)


[typographical] ~5-~5: Consider using an em dash in dialogues and enumerations.
Context: ...ettings $ atmos list settings – List settings for specific stacks ``` ...

(DASH_RULE)


[typographical] ~10-~10: Consider using an em dash in dialogues and enumerations.
Context: ...os list settings --stack '-dev-' – List specific settings using query ...

(DASH_RULE)


[typographical] ~16-~16: Consider using an em dash in dialogues and enumerations.
Context: ...tings --query .settings.validation – Output in different formats $ atmo...

(DASH_RULE)


[typographical] ~24-~24: Consider using an em dash in dialogues and enumerations.
Context: ...$ atmos list settings --format tsv ``` – Filter by stack and specific settings `...

(DASH_RULE)

cmd/markdown/atmos_list_values_usage.md

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all values for a component ``` $ ...

(DASH_RULE)


[typographical] ~5-~5: Consider using an em dash in dialogues and enumerations.
Context: ...` $ atmos list values – List only variables for a component...

(DASH_RULE)


[typographical] ~10-~10: Consider using an em dash in dialogues and enumerations.
Context: ...t values --query .vars ``` – List settings for a specific component ...

(DASH_RULE)


[typographical] ~15-~15: Consider using an em dash in dialogues and enumerations.
Context: ...ery .settings --stack 'plat-ue2-*' – Output in different formats $ atmo...

(DASH_RULE)


[typographical] ~23-~23: Consider using an em dash in dialogues and enumerations.
Context: ...st values --format tsv ``` – Filter stacks and include abstract comp...

(DASH_RULE)


[typographical] ~28-~28: Consider using an em dash in dialogues and enumerations.
Context: ...ent> --stack '-prod-' --abstract ``` – Custom query with specific stack patter...

(DASH_RULE)

cmd/markdown/atmos_list_vars_usage.md

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all variables for a component ``` ...

(DASH_RULE)


[typographical] ~5-~5: Consider using an em dash in dialogues and enumerations.
Context: ... $ atmos list vars <component> – List specific variables using query ```...

(DASH_RULE)


[uncategorized] ~6-~6: You might be missing the article “a” here.
Context: ...t> – List specific variables using query $ atmos list vars --qu...

(AI_EN_LECTOR_MISSING_DETERMINER_A)


[typographical] ~10-~10: Consider using an em dash in dialogues and enumerations.
Context: ...ars --query .vars.tags – Filter by stack pattern $ atmos li...

(DASH_RULE)


[typographical] ~15-~15: Consider using an em dash in dialogues and enumerations.
Context: ...vars --stack '-dev-' – Output in different formats $ atmo...

(DASH_RULE)


[typographical] ~23-~23: Consider using an em dash in dialogues and enumerations.
Context: ...list vars --format tsv – Include abstract components $ atmo...

(DASH_RULE)


[typographical] ~28-~28: Consider using an em dash in dialogues and enumerations.
Context: ...s list vars --abstract ``` – Filter by stack and specific variables ...

(DASH_RULE)

🪛 markdownlint-cli2 (0.17.2)
cmd/markdown/list_values.md

2-2: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


3-3: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


6-6: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


7-7: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


10-10: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


11-11: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


14-14: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


15-15: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


18-18: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


19-19: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


20-20: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


21-21: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


24-24: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


25-25: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


26-26: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

cmd/markdown/atmos_list_settings_usage.md

2-2: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


3-3: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


7-7: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


8-8: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


13-13: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


14-14: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


18-18: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


19-19: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


20-20: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


21-21: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


22-22: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


26-26: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


27-27: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

cmd/markdown/atmos_list_values_usage.md

2-2: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


3-3: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


7-7: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


8-8: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


13-13: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


17-17: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


18-18: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


19-19: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


20-20: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


21-21: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


25-25: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


26-26: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


30-30: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


31-31: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

cmd/markdown/atmos_list_vars_usage.md

2-2: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


3-3: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


7-7: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


8-8: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


12-12: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


13-13: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


17-17: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


18-18: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


19-19: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


20-20: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


21-21: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


25-25: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


26-26: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)


30-30: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


31-31: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Summary
🔇 Additional comments (15)
cmd/list_values.go (3)

67-69: LGTM! Smart default handling.

Good practice setting appropriate delimiter defaults based on the format.


87-96: LGTM! Well-structured error handling.

Good separation of concerns between "no values found" and other error cases.


127-136: LGTM! Clean flag initialization.

Good use of a helper function to avoid code duplication when setting up common flags.

cmd/markdown/atmos_list_metadata_usage.md (10)

1-2: Consistent Dash Formatting for Header
The header text “– List all metadata” is clear. However, please verify that the dash used here is the em dash (—) as per our documentation conventions (see the formatting in atmos_workflow_usage.md).

🧰 Tools
🪛 LanguageTool

[typographical] ~1-~1: Consider using an em dash in dialogues and enumerations.
Context: – List all metadata ``` $ atmos list met...

(DASH_RULE)


3-4: Clear Command Example
The command example $ atmos list metadata is straightforward and easy to understand.


6-7: Section Heading Consistency
The heading “– List metadata for specific stacks” is clearly defined. Please ensure the dash’s style (em dash vs. en dash) matches the convention used in similar documentation files.


8-9: Valid Stack Filtering Example
The example $ atmos list metadata --stack '*-dev-*' effectively demonstrates how to filter metadata by stack.


11-12: Header for Specific Metadata Fields
The header “– List specific metadata fields” is descriptive. As with the other headings, double-check that the dash formatting aligns with our style guidelines from atmos_workflow_usage.md.


13-15: Metadata Query Examples Clarity
The examples using $ atmos list metadata --query .metadata.component and $ atmos list metadata --query .metadata.type are clear and correctly illustrate the intended usage for querying metadata fields.


17-18: Output Format Heading
The heading “– Output in different formats” is concise. Please check that the dash usage here adheres to the style convention (i.e. using an em dash if that’s our standard).


19-23: Comprehensive Output Format Examples
The examples demonstrating the output formats (JSON, YAML, CSV, TSV) are comprehensive. Just ensure that the underlying implementation supports all these formats as documented.


25-26: Combined Filtering Header
The heading “– Filter by stack and specific metadata” clearly indicates the combined filtering feature. Confirm that the dash’s format is consistent with the rest of the document.


27-28: Combined Filtering Example Clarity
The example $ atmos list metadata --stack '*-ue2-*' --query .metadata.version effectively illustrates how to filter by both stack and metadata field.

cmd/markdown/atmos_list_settings_usage.md (1)

6-9: Clear Command Examples
The subsequent examples (e.g., filtering settings by stack) effectively demonstrate command usage. Just ensure to apply the same fenced code block language specifier recommendation across all command examples.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

7-7: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


8-8: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

cmd/markdown/list_values.md (1)

5-8: Well-Documented Command Options
The examples illustrating options such as “--query .vars”, “--abstract”, and “--max-columns 5” are concise and clear. Great work on showing users how to leverage these options!

🧰 Tools
🪛 LanguageTool

[typographical] ~8-~8: Consider using an em dash in dialogues and enumerations.
Context: ...st values --query .vars – Include abstract components $ atmo...

(DASH_RULE)

🪛 markdownlint-cli2 (0.17.2)

6-6: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


7-7: Dollar signs used before commands without showing output
null

(MD014, commands-show-output)

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 (2)
cmd/list_metadata.go (1)

84-88: Consider reducing the severity of "no values found" log message.

"No values found" is not always an error condition; converting to log.Info or log.Warn might better reflect its non-critical nature.

- log.Error("no values found", "error", err)
+ log.Warn("no values found", "error", err)
cmd/list_values.go (1)

84-88: Log non-critical output more lightly.

If no values exist, it may not indicate a failure. Consider changing this message from log.Error to a lower severity level for better clarity.

- log.Error("no values found", "error", err)
+ log.Info("no values found", "error", err)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d0e24c3 and e0ec172.

📒 Files selected for processing (3)
  • cmd/list_metadata.go (1 hunks)
  • cmd/list_values.go (1 hunks)
  • pkg/utils/wildcard.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/utils/wildcard.go
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: [mock-windows] tests/fixtures/scenarios/complete
  • GitHub Check: [mock-windows] examples/demo-vendoring
  • GitHub Check: Acceptance Tests (macos-latest, macos)
  • GitHub Check: Acceptance Tests (windows-latest, windows)
  • GitHub Check: Acceptance Tests (ubuntu-latest, linux)
  • GitHub Check: [localstack] demo-localstack
  • GitHub Check: Summary
🔇 Additional comments (6)
cmd/list_metadata.go (3)

13-23: Definition of listMetadataCmd is clear and consistent.

The short, long, and example sections are well-defined, providing a concise overview of this new command. This sets a good foundation for usability.


28-33: Semantic logging usage looks aligned with past feedback.

Thank you for switching to log.Error(...) with explicit "error", err fields. This consistency matches the requested semantic logging approach.


98-111: All flag definitions are structured well.

Your usage of PersistentFlags() and stack pattern completion is consistent with sister commands, ensuring a uniform CLI experience.

cmd/list_values.go (3)

13-19: Command signature and usage are well-defined.

Requiring exactly one argument (component) is appropriate and clearly specified, preventing ambiguity in usage.


23-30: CLI config initialization is properly wrapped with error handling.

This ensures that any misconfiguration is promptly surfaced to the user.


122-140: Good consolidation of shared flags.

Defining commonFlags and reusing it across both listValuesCmd and listVarsCmd promotes clean, maintainable code.

}

// FilterAndListValues filters and lists component values across stacks
func FilterAndListValues(stacksMap map[string]interface{}, component, query string, includeAbstract bool, maxColumns int, format, delimiter string, stackPattern string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

This function is nearly 400 lines long—we should break it down into smaller, more manageable functions, ideally keeping each under 50 lines. The goal is to make the code read like a story, with clear function calls guiding the flow.

Atmos has a lot of legacy code that’s massive and hard to follow, but we can do better. Let’s raise the bar.

// - '?' matches any single non-separator character
// - '[abc]' matches any character within the brackets
// - '[a-z]' matches any character in the range
func MatchWildcard(pattern, str string) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure we cannot use filepath.Match. Everywhere we support wildcards, we are really supporting globs with ** support.

┌──────────────┬──────────────┬──────────────┬──────────────┐
│ │ dev-ue1 │ staging-ue1 │ prod-ue1 │
├──────────────┼──────────────┼──────────────┼──────────────┤
│ templates │ {...} │ {...} │ {...} │
Copy link
Member

Choose a reason for hiding this comment

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

What does the output look like for non-scalers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cloudposse Needs Cloud Posse assistance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants