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

Update overrides section behavior in imports and inline #1122

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

Conversation

aknysh
Copy link
Member

@aknysh aknysh commented Mar 8, 2025

what

  • Update overrides section behavior in imports and inline
  • Add acceptance tests for the overrides section for many scenarios (overrides at the stack level, team level, inline and in imports)
  • Update docs
  • Update Go to 1.24.0 and fix some issues in the code (1.24.0 is more strict about the Go format functions always requiring the format as the first argument)
  • Add unit tests

why

  • Importing the overrides did not cover all possible scenarios (e.g. when importing the overrides affected the imported components, but the inline overrides for the same stack were not taken into account). This PR fixes this and adds acceptance tests for all scenarios
  • Update the Share Data Between Components doc to describe how the !terraform.output YAML function can (and should be) used to to read the outputs (remote state) of components directly in Atmos stack manifests

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced configuration processing distinguishes inline and imported overrides for greater deployment flexibility.
    • Added sample configuration files for various environments (development, production, staging, sandbox, and test) with team-specific settings.
    • Introduced new YAML function !terraform.output for improved data sharing in stack manifests.
    • New workflows added for testing various Atmos commands across multiple environments.
  • Documentation

    • Updated documentation to showcase improved data sharing and new output functionalities.
  • Chores

    • Upgraded Atmos CLI and related dependencies for enhanced performance.
    • Improved command output formatting for clearer error messages.
  • Tests

    • Introduced test cases to validate configuration override behavior across environments.
    • Added tests for the aboutCmd and supportCmd commands to ensure correct output.
    • New test functions added for ProcessYAMLConfigFile, ValidateStacks, and workflow command to enhance coverage.

…verrides-in-imports

# Conflicts:
#	examples/quick-start-advanced/Dockerfile
#	website/docs/integrations/atlantis.mdx
@aknysh aknysh added the patch A minor, backward compatible change label Mar 8, 2025
@aknysh aknysh requested a review from osterman March 8, 2025 16:10
@aknysh aknysh self-assigned this Mar 8, 2025
@aknysh aknysh requested a review from a team as a code owner March 8, 2025 16:10
@github-actions github-actions bot added the size/l label Mar 8, 2025
Copy link

mergify bot commented Mar 8, 2025

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

Copy link
Contributor

coderabbitai bot commented Mar 8, 2025

📝 Walkthrough

Walkthrough

This pull request updates how markdown content is formatted by modifying PrintfMarkdown calls in the about and support commands. The Atmos version is bumped in both the Dockerfile and documentation, and the Go module is updated with a new Go version and refreshed dependencies. Function signatures for YAML configuration processing have been revised to distinguish between inline and import overrides for Terraform and Helmfile, with corresponding return value updates. Several new YAML configuration files, test cases, and documentation updates have also been introduced, along with minor enhancements to error message formatting.

Changes

File(s) Change Summary
cmd/about.go, cmd/support.go Updated PrintfMarkdown invocations to include a %s format specifier for markdown content.
examples/quick-start-advanced/Dockerfile, website/docs/integrations/atlantis.mdx Updated Atmos version from 1.164.0 to 1.165.3.
go.mod Updated Go version to 1.24.0 and refreshed multiple dependency versions.
internal/exec/stack_processor_utils.go, internal/exec/validate_stacks.go, pkg/stack/stack_processor.go Revised ProcessYAMLConfigFile signatures to separate inline and import overrides and updated return values.
internal/exec/vendor_utils.go, internal/exec/workflow.go Enhanced error message formatting using %s in error strings.
tests/fixtures/scenarios/atmos-overrides-section/**, tests/test-cases/atmos-overrides-section.yaml Added YAML configuration files and test cases for environment-specific deployment overrides.
website/docs/core-concepts/share-data/*.mdx Reordered function documentation, added the !terraform.output section, and corrected YAML capitalization.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Stack Processor
    participant YAMLProcessor as ProcessYAMLConfigFile
    Caller->>YAMLProcessor: Call with inline & import override maps
    YAMLProcessor-->>Caller: Return updated override maps
Loading

Possibly related PRs

  • Merge atmos specific and terraform help documentation #857: The changes in the main PR, which modify the invocation of the PrintfMarkdown function in the aboutCmd and supportCmd commands, are related to the changes in the retrieved PR that also involve command execution and output formatting, specifically in the context of help commands. Both PRs focus on enhancing command output handling, although they target different commands.
  • Update atmos terraform commands that require processing of Go templates and Atmos YAML functions #1062: The changes in the main PR, which modify the invocation of the PrintfMarkdown function in the aboutCmd and supportCmd commands, are related to the changes in the retrieved PR that also involve updates to command handling, specifically in the context of Atmos commands, indicating a shared focus on command execution and output formatting.

Suggested labels

minor

Suggested reviewers

  • osterman
  • mcalhoun

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 golangci-lint (1.62.2)

Error: can't load config: the Go language version (go1.23) used to build golangci-lint is lower than the targeted Go version (1.24.0)
Failed executing command with error: can't load config: the Go language version (go1.23) used to build golangci-lint is lower than the targeted Go version (1.24.0)


📜 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 bb7e0e9 and ea8edbb.

📒 Files selected for processing (1)
  • pkg/utils/markdown_utils.go (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/utils/markdown_utils.go
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: website-deploy-preview
  • GitHub Check: Summary

🪧 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.
  • @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 (3)
internal/exec/workflow.go (1)

120-128: Enhanced error message clarity for workflows.
The updated error message now constructs a detailed list of available workflows using the sorted keys, making it easier for users to see what options are available. One minor suggestion: if no string formatting is needed later in the error handling, consider using errors.New(errorMarkdown) for simplicity, though the current use of fmt.Errorf is perfectly acceptable.

tests/fixtures/scenarios/atmos-overrides-section/atmos.yaml (1)

10-10: Remove trailing spaces.
There are trailing spaces on line 10. Please remove these spaces to adhere to clean YAML formatting standards.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 10-10: trailing spaces

(trailing-spaces)

website/docs/core-concepts/share-data/remote-state.mdx (1)

353-363: Enhance Punctuation in Remote State ActionCard Block
The ActionCard block clearly illustrates the alternative methods using the !terraform.output YAML function and the atmos.Component template function. To further polish the presentation, please add a punctuation mark (e.g., a period) at the end of the text in the PrimaryCTA section on line 363.

🧰 Tools
🪛 LanguageTool

[grammar] ~363-~363: Please add a punctuation mark at the end of paragraph.
Context: ...n how to use 'atmos.Component' template function

(PUNCTUATION_PARAGRAPH_END)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a410633 and 815a0b3.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (22)
  • cmd/about.go (1 hunks)
  • cmd/support.go (1 hunks)
  • examples/quick-start-advanced/Dockerfile (1 hunks)
  • go.mod (11 hunks)
  • internal/exec/stack_processor_utils.go (18 hunks)
  • internal/exec/validate_stacks.go (2 hunks)
  • internal/exec/vendor_utils.go (1 hunks)
  • internal/exec/workflow.go (1 hunks)
  • pkg/stack/stack_processor.go (2 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/atmos.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/catalog/c1.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/dev.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/prod.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/sandbox.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/staging.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/test.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/teams/team1.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/teams/team2.yaml (1 hunks)
  • tests/test-cases/atmos-overrides-section.yaml (1 hunks)
  • website/docs/core-concepts/share-data/remote-state.mdx (1 hunks)
  • website/docs/core-concepts/share-data/share-data.mdx (1 hunks)
  • website/docs/integrations/atlantis.mdx (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
website/docs/core-concepts/share-data/share-data.mdx (2)
Learnt from: aknysh
PR: cloudposse/atmos#810
File: website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx:0-0
Timestamp: 2024-12-03T04:01:16.446Z
Learning: In the `terraform.output.mdx` documentation file (`website/docs/core-concepts/stacks/yaml-functions/terraform.output.mdx`), the cache invalidation and cache scope behavior for the `!terraform.output` function are already described.
Learnt from: aknysh
PR: cloudposse/atmos#810
File: examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml:28-32
Timestamp: 2024-12-01T00:33:20.298Z
Learning: In `examples/tests/stacks/catalog/terraform/template-functions-test2/defaults.yaml`, `!exec atmos terraform output` is used in examples to demonstrate its usage, even though `!terraform.output` is the recommended approach according to the documentation.
examples/quick-start-advanced/Dockerfile (2)
Learnt from: aknysh
PR: cloudposse/atmos#775
File: examples/quick-start-advanced/Dockerfile:9-9
Timestamp: 2024-11-12T05:52:05.088Z
Learning: It is acceptable to set `ARG ATMOS_VERSION` to a future version like `1.105.0` in `examples/quick-start-advanced/Dockerfile` if that will be the next release.
Learnt from: osterman
PR: cloudposse/atmos#801
File: examples/quick-start-advanced/Dockerfile:9-9
Timestamp: 2024-11-23T00:13:22.004Z
Learning: When updating the `ATMOS_VERSION` in Dockerfiles, the team prefers to pin to the next future version when the PR merges, even if the version is not yet released.
🪛 YAMLlint (1.35.1)
tests/fixtures/scenarios/atmos-overrides-section/atmos.yaml

[error] 10-10: trailing spaces

(trailing-spaces)

🪛 LanguageTool
website/docs/core-concepts/share-data/remote-state.mdx

[grammar] ~363-~363: Please add a punctuation mark at the end of paragraph.
Context: ...n how to use 'atmos.Component' template function

(PUNCTUATION_PARAGRAPH_END)

⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Build (macos-latest, macos)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: [lint] golangci
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: website-deploy-preview
  • GitHub Check: Summary
🔇 Additional comments (61)
website/docs/integrations/atlantis.mdx (1)

675-677: Atmos Version Update in GitHub Action Environment

The update of the ATMOS_VERSION from 1.164.0 to 1.165.3 in the environment variables looks consistent with our overall version bump. Please double-check that any references to the older version in related tests or documentation have also been updated accordingly.

examples/quick-start-advanced/Dockerfile (1)

9-9: Updated ARG ATMOS_VERSION

Changing the ARG ATMOS_VERSION from 1.164.0 to 1.165.3 in the Dockerfile is aligned with the coordinated version update seen in the docs. This change is consistent with our current release strategy.

tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/sandbox.yaml (1)

1-9: Configuration structure looks good.

This sandbox manifest properly defines the environment stage and imports team configurations. The structure follows Atmos best practices with a clear separation of concerns.

cmd/support.go (1)

23-23: Properly updated PrintfMarkdown call.

The change adds a format specifier to the PrintfMarkdown call, which is the correct approach for string formatting. This matches similar changes in other commands.

tests/fixtures/scenarios/atmos-overrides-section/stacks/teams/team2.yaml (1)

1-12: Effective overrides demonstration.

This file correctly demonstrates the overrides functionality by importing a base configuration and providing team-specific variable values. The empty top-level overrides section and the terraform-specific overrides are both structured properly.

tests/fixtures/scenarios/atmos-overrides-section/stacks/catalog/c1.yaml (1)

1-12: Base component definition is well-structured.

This file properly defines a base Terraform component with test variables that can be overridden by team configurations. The schema reference is correctly included.

tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/staging.yaml (1)

1-17: Clean and well-structured fixture for testing overrides

This new YAML file provides a clear test case for the updated overrides section behavior. It properly demonstrates the staging environment configuration with team imports and environment-specific terraform variable overrides.

cmd/about.go (1)

20-20: Format specifier added for PrintfMarkdown

The change adds a proper format specifier when using PrintfMarkdown, improving string handling consistency.

tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/prod.yaml (1)

1-19: Clear production test fixture with complete overrides

This fixture defines a production environment with multiple variable overrides (a, b, c) that will properly test the overrides section behavior across different levels.

tests/fixtures/scenarios/atmos-overrides-section/stacks/teams/team1.yaml (1)

1-13: Appropriate team-level configuration with overrides

This team configuration imports component definitions and specifies team-specific variable values that will be used in testing the inheritance and override behavior across different configuration levels.

tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/dev.yaml (1)

1-15: New YAML manifest for the dev environment added.
This file clearly defines the environment variables (stage: dev), imports for teams, and a Terraform overrides section. Ensure that the referenced team directories (e.g. teams/team1 and teams/team2) exist and that the override structure aligns with the expectations in other environments.

tests/fixtures/scenarios/atmos-overrides-section/stacks/deploy/test.yaml (1)

1-20: New YAML manifest for the test environment added.
This file correctly sets the stage to "test" and defines both inline and Terraform override sections. The structure is consistent with the dev manifest, which helps maintain clarity across environments.

tests/fixtures/scenarios/atmos-overrides-section/atmos.yaml (1)

1-22: New base configuration file for Atmos introduced.
The configuration is well-structured, defining the base path, components, stack configurations (including included/excluded paths and a naming pattern), and logging settings. This will serve as a strong foundation supporting the environment-specific overrides defined in the stack manifests.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 10-10: trailing spaces

(trailing-spaces)

internal/exec/vendor_utils.go (1)

136-137: Enhanced error message for missing '--component' flag.
The revised error message now not only informs the user that the --component flag is required but also provides an example usage, which helps clarify the expected input. This improvement in user guidance is appreciated.

internal/exec/validate_stacks.go (1)

155-169: Add usage note for the override maps
These new parameters are passed as empty maps. Document their intended usage or provide an inline comment about how these maps will be populated.

tests/test-cases/atmos-overrides-section.yaml (5)

1-25: Validate negative scenarios
These tests for the 'prod' stack look solid. Consider adding negative or edge case scenarios for a more robust test suite.
[approve]


26-49: Confirm coverage for staging
The staging test can also exercise partial or conflicting overrides for additional confidence.


50-73: Good demonstration of dev stack
This test covers dev overrides effectively. If feasible, add a check for scenario with no overrides applied.


74-97: Sandbox test is comprehensive
All required keys are shown. The approach appears consistent with other tests. Keep up the coverage.


98-121: Thorough test for 'test' stack
This neatly verifies override inheritance. Everything else seems aligned.

pkg/stack/stack_processor.go (3)

47-50: Function signature extension
The inline and import-based override parameters clarify usage. Confirm these are consistently passed from all call sites.


58-59: Return maps confirmation
Returning two extra maps for overrides is logical. Ensure downstream callers consume them appropriately.


72-75: Param forwarding confirmed
Forwarding the new override maps to exec.ProcessYAMLConfigFile is consistent with the new design. Looks good.

internal/exec/stack_processor_utils.go (4)

76-89: Expanded return values
You're capturing additional override maps from ProcessYAMLConfigFile. This should help unify override handling.


439-476: Ensuring overrides pass through
The function call now passes all override parameters, forming a proper override chain. Keep an eye on performance if there's heavy merging in large configs.


488-505: Terraform and Helmfile overrides merging
Merging inline and imported overrides is a strong approach. Just confirm these merges do not generate unintended key collisions.


541-548: Return statements handle new parameters
The updated return logic appropriately includes the final override maps. No issues spotted.

go.mod (32)

3-3: Bump Go Version to 1.24.0
The Go version was updated to 1.24.0. This helps leverage improvements in the toolchain but be sure to run the full test suite to catch any subtle compatibility issues.


11-13: Update AWS SDK Core and Modules
The AWS SDK dependencies (core, config, and SSM service) have been bumped to v1.36.3, v1.29.9, and v1.57.2 respectively. Verify that these versions align with your AWS integrations and that no breaking changes affect your functionality.


16-16: Upgrade Charm Bubbletea Package
The bubbletea package has been updated to v1.3.4. Check the release notes to ensure there are no breaking API changes that might affect the UI behavior.


25-25: Update go-git Dependency
The go-git package version was updated to v5.14.0, a minor bump that likely includes improvements and bug fixes. It’s a good idea to verify any git-related workflows.


38-38: Bump JFrog Client Version
The jfrog-client-go version has been updated to v1.51.0. Ensure that any functionality relying on JFrog services works as expected with this new version.


42-42: Update Bubblezone Module
The commit for bubblezone has been updated to a newer reference (v0.0.0-20250301021021-ab7b445e9861). Confirm that this version is well-tested in your UI or CLI contexts.


47-47: Upgrade Termenv Dependency
The termenv package was bumped to v0.16.0. This should bring newer terminal styling features without breaking existing functionality.


48-48: Update OPA Version
The Open Policy Agent (OPA) dependency has been updated to v1.2.0. Please double-check that any policy evaluations or integrations remain consistent with your configuration handling.


51-51: Bump go-redis Version
The redis/go-redis/v9 dependency was updated to v9.7.1. Ensure that this change does not introduce compatibility issues with your Redis integrations.


60-60: Update OAuth2 Package
The golang.org/x/oauth2 package was bumped to v0.28.0. This update likely contains improvements and security patches. It’s worth running authentication integration tests after this change.


61-61: Upgrade x/term Package
The golang.org/x/term package was updated to v0.30.0. This is a minor update—just confirm that terminal input/output operations still behave as expected.


62-62: Bump x/text Dependency
The golang.org/x/text package was updated to v0.23.0. This should bring enhancements in text processing; verifying non-regression in i18n or formatting is a good step.


66-66: Update mvdan.cc/sh Version
The mvdan.cc/sh/v3 dependency was bumped to v3.11.0. If your project makes use of shell parsing/formatting, please run the related tests to confirm everything works as before.


83-83: Update Agnivade Levenshtein Library
The agnivade/levenshtein indirect dependency is now at v1.2.1. This minor bump should improve text distance calculations without introducing breaking changes.


96-96: Bump AWS Credentials Package
The aws-sdk-go-v2/credentials dependency was updated to v1.17.62. Confirm that your AWS authentication flows remain secure and functional.


97-97: Update EC2 IMDS Feature
The aws-sdk-go-v2/feature/ec2/imds package was bumped to v1.16.30. Validate that fetching instance metadata works as expected after the update.


99-99: Upgrade AWS Internal Config Sources
The internal configuration sources dependency was updated to v1.3.34. As this is an internal package of the AWS SDK, testing any configuration load paths is recommended.


100-100: Update AWS Endpoints Package
The aws-sdk-go-v2/internal/endpoints/v2 package now at v2.6.34 should ensure better endpoint resolution. Make sure that your AWS service calls resolve endpoints correctly.


105-105: Bump Presigned-URL Internal Package
The aws-sdk-go-v2/service/internal/presigned-url dependency was updated to v1.12.15. Verify that URL signing and pre-signed operations still behave as expected.


108-108: Upgrade AWS SSO Service Package
The aws-sdk-go-v2/service/sso package was updated to v1.25.1. Double-check that any Single Sign-On integrations continue to function correctly.


109-109: Update AWS SSO OIDC Service
The aws-sdk-go-v2/service/ssooidc dependency is now at v1.29.1. Ensure that OIDC-based SSO flows are thoroughly tested with this update.


110-110: Bump AWS STS Dependency
The aws-sdk-go-v2/service/sts dependency was updated to v1.33.17. This change should improve stability in security token services; testing the STS integration is advised.


128-128: Update Containerd Dependency
The containerd/containerd indirect dependency was bumped to v1.7.26. Verify that any functionalities depending on container runtime interactions remain unaffected.


166-166: Bump go-cmp Version
The google/go-cmp dependency was updated to v0.7.0. This should enhance the diffing and comparison capabilities in tests, so ensure your test assertions behave as expected.


244-244: Update Prometheus Client Library
The prometheus/client_golang dependency has been updated to v1.21.0. Check that custom metrics and scraping integrations continue to work seamlessly.


246-246: Upgrade Prometheus Common Package
The prometheus/common dependency was bumped to v0.62.0. This should provide better support for Prometheus integrations—verify your monitoring dashboards if applicable.


289-289: Update go4.org Unsafe GC Assumption Package
The go4.org/unsafe/assume-no-moving-gc dependency was updated to a more recent commit. Given its low-level nature, ensure that any performance-sensitive areas that depend on GC behaviors are adequately tested.


291-291: Bump x/crypto Package
The golang.org/x/crypto dependency was updated to v0.35.0. This update likely includes important security fixes; reviewing the release notes for any breaking changes is recommended.


294-294: Upgrade x/net Package
The golang.org/x/net dependency was bumped to v0.35.0. Ensure that any network communication or proxy functionalities continue to work as expected.


295-295: Update x/sync Package
The golang.org/x/sync dependency was updated to v0.12.0. This minor version bump should provide some performance improvements with low risk.


296-296: Bump x/sys Package
The golang.org/x/sys dependency is now at v0.31.0. Check that any system-level calls or integrations remain stable after this update.


297-297: Upgrade x/time Package
The golang.org/x/time dependency was updated to v0.10.0. This update is generally non-disruptive but verify that any time-based utilities used in your code still operate correctly.

website/docs/core-concepts/share-data/share-data.mdx (2)

63-65: Documentation Update for !store ActionCard
The updated ActionCard block for the !store YAML function is clear and directs the reader to the detailed documentation, which is in line with the revised behavior in overrides.


67-97: New !terraform.output YAML Function Section
The new section on the !terraform.output function is well-written and provides clear examples for both accessing outputs from the current stack and from a specified stack. This addition not only improves clarity for users but also aligns with the updated behavior objectives in override handling.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 8, 2025
Copy link

codecov bot commented Mar 8, 2025

Codecov Report

Attention: Patch coverage is 46.42857% with 45 lines in your changes missing coverage. Please review.

Project coverage is 16.44%. Comparing base (a410633) to head (ea8edbb).

Files with missing lines Patch % Lines
internal/exec/stack_processor_utils.go 42.85% 38 Missing and 2 partials ⚠️
internal/exec/vendor_utils.go 0.00% 2 Missing ⚠️
internal/exec/workflow.go 0.00% 2 Missing ⚠️
pkg/utils/markdown_utils.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1122      +/-   ##
==========================================
- Coverage   17.44%   16.44%   -1.01%     
==========================================
  Files         170      170              
  Lines       18764    18789      +25     
==========================================
- Hits         3274     3090     -184     
- Misses      14892    15107     +215     
+ Partials      598      592       -6     
Flag Coverage Δ
unittests 16.44% <46.42%> (-1.01%) ⬇️

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.

@aknysh aknysh requested a review from osterman March 8, 2025 17:49
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (6)
cmd/support_test.go (2)

15-15: Consider handling the error from os.Pipe()

This line ignores the potential error returned from os.Pipe(). While this is common in test code, it's generally better to assert or handle errors properly.

-r, w, _ := os.Pipe()
+r, w, err := os.Pipe()
+assert.NoError(t, err, "Failed to create pipe for stdout capture")

20-20: Use distinct error messages for different assertion points

The same error message is used for three different assertions. Using distinct messages would make it clearer which assertion failed when troubleshooting test failures.

-assert.NoError(t, err, "'atmos support' command should execute without error")
+assert.NoError(t, err, "'atmos support' command execution failed")

-assert.NoError(t, err, "'atmos support' command should execute without error")
+assert.NoError(t, err, "Failed to close stdout pipe writer")

-assert.NoError(t, err, "'atmos support' command should execute without error")
+assert.NoError(t, err, "Failed to read captured stdout")

Also applies to: 24-24, 31-31

cmd/about_test.go (3)

15-16: Check error from os.Pipe() call

The error return value from os.Pipe() is discarded with _, but should be checked to ensure the pipe was created successfully.

-r, w, _ := os.Pipe()
+r, w, err := os.Pipe()
+assert.NoError(t, err, "Failed to create pipe for stdout capture")

24-24: Use a more specific error message

The error message is identical to the one used in line 20, but it's for a different operation (closing the writer vs. executing the command).

-assert.NoError(t, err, "'atmos about' command should execute without error")
+assert.NoError(t, err, "Failed to close the stdout pipe writer")

31-31: Use a more specific error message

Similarly, this error message could be more specific about the operation being performed.

-assert.NoError(t, err, "'atmos about' command should execute without error")
+assert.NoError(t, err, "Failed to read captured output from pipe")
internal/exec/workflow.go (1)

128-128: Fix dynamic error construction to address linter warning.

The change addresses the err113 linter warning by using fmt.Errorf("%s", errorMarkdown) instead of directly passing errorMarkdown to the error.

While this change addresses the linter warning, consider using errors.New(errorMarkdown) instead for cleaner error creation when no formatting is needed:

-return fmt.Errorf("%s", errorMarkdown)
+return errors.New(errorMarkdown)
🧰 Tools
🪛 GitHub Check: golangci

[failure] 128-128: [golangci] internal/exec/workflow.go#L128
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("%s", errorMarkdown)" (err113)

🛑 Comments failed to post (1)
internal/exec/vendor_utils.go (1)

136-137: 💡 Verification agent

🧩 Analysis chain

Consider using wrapped static errors instead of dynamic error messages

The static analysis tool flagged this pattern as it violates the err113 rule. For better error handling, consider defining static errors as constants and wrapping them with additional context.


🏁 Script executed:

#!/bin/bash
# Search for other similar error patterns in the codebase to understand the project's error handling conventions

echo "Searching for error handling patterns in the codebase..."
rg -A 1 -B 1 "var Err[A-Z][a-zA-Z0-9]+ = errors\.New\(" --type go

echo "Searching for uses of fmt.Errorf..."
rg "fmt\.Errorf\(" --type go | head -n 10

Length of output: 1411


Attention: Refactor to Employ Wrapped Static Errors

It looks like our project already standardizes error handling by defining static error constants (e.g., in internal/exec/terraform.go). To comply with the err113 rule and improve consistency, please replace the dynamic error construction in internal/exec/vendor_utils.go (lines 136–137) with a wrapped static error.

  • Actionable Change:
    Define a package-level error constant—something like:

    var ErrMissingComponentFlag = errors.New("to vendor a component, the '--component' (shorthand '-c') flag needs to be specified. Example: atmos vendor pull -c <component>")

    Then update the error return to wrap this constant:

    -	return fmt.Errorf("to vendor a component, the '--component' (shorthand '-c') flag needs to be specified.\n"+
    -		"Example: atmos vendor pull -c <component>\n%s", q)
    +	return fmt.Errorf("%w\n%s", ErrMissingComponentFlag, q)

This change will align error handling with the conventions already present in the codebase and address the static analysis concerns.

🧰 Tools
🪛 GitHub Check: golangci

[failure] 136-136: [golangci] internal/exec/vendor_utils.go#L136
do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf("to vendor a component, the '--component' (shorthand '-c') flag needs to be specified.\n"+\n\t"Example: atmos vendor pull -c \n%s", q)" (err113)

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 (3)
tests/fixtures/scenarios/atmos-overrides-section/atmos.yaml (1)

10-10: Remove trailing whitespace

There's a trailing space at the end of this line that should be removed.

-  
+
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 10-10: trailing spaces

(trailing-spaces)

internal/exec/validate_stacks_test.go (1)

26-44: Consider extracting test configuration setup to helper function

As you add more tests for different override section scenarios, this configuration setup might be reused. Consider extracting it to a helper function to reduce duplication in future tests.

tests/fixtures/scenarios/atmos-overrides-section/stacks/workflows/workflows.yaml (1)

20-32: Consider using workflow composition for DRY principles

The show-all-describe-component-commands workflow repeats the same pattern with only environment differences. If Atmos supports workflow composition or parameterization, you could make this more maintainable.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0cf449a and 6ef13c4.

📒 Files selected for processing (5)
  • cmd/support_test.go (1 hunks)
  • cmd/workflow_test.go (1 hunks)
  • internal/exec/validate_stacks_test.go (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/atmos.yaml (1 hunks)
  • tests/fixtures/scenarios/atmos-overrides-section/stacks/workflows/workflows.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
tests/fixtures/scenarios/atmos-overrides-section/atmos.yaml

[error] 10-10: trailing spaces

(trailing-spaces)

⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Build (macos-latest, macos)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Build (ubuntu-latest, linux)
  • GitHub Check: Analyze (go)
  • GitHub Check: website-deploy-preview
  • GitHub Check: Summary
🔇 Additional comments (8)
cmd/support_test.go (1)

12-35: Good implementation of test for the support command

The test correctly captures stdout, executes the command, and validates output. The approach of using pipes to capture output is a robust pattern for testing CLI commands that write to stdout.

A few observations:

  • Good error handling at each step
  • Clear assertions with descriptive messages
  • Proper cleanup by restoring stdout
cmd/workflow_test.go (4)

12-24: Well-structured test setup for workflow command

The test properly sets up the environment variables needed for the workflow command test. Using a relative path to test fixtures is a good practice for maintainability.


26-31: Clear definition of expected output

The expected output is well-defined as a multi-line string, making it clear what the test is checking for. This makes the test intention obvious.


33-36: Effective command execution pattern

Using RootCmd.SetArgs followed by Execute() properly simulates how the command would be run in production, which is better than testing internal methods directly.


38-51: Good output validation approach

The output capture, restoration, and validation follow best practices for CLI testing. The assertion clearly expresses the expected behavior.

tests/fixtures/scenarios/atmos-overrides-section/atmos.yaml (1)

1-25: Clean configuration structure with good organization

This Atmos configuration file establishes a solid foundation for the overrides section testing scenario with proper path configurations and logical organization of components, stacks, logs, and workflows.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 10-10: trailing spaces

(trailing-spaces)

internal/exec/validate_stacks_test.go (1)

12-48: Well-structured test for stack validation

The test effectively validates stacks with overrides section configurations across multiple environments. Good use of filepath handling and clear configuration setup.

tests/fixtures/scenarios/atmos-overrides-section/stacks/workflows/workflows.yaml (1)

1-32: Comprehensive workflow definitions for testing overrides behavior

The workflows provide good coverage for testing component behavior across multiple environments, which will help validate the changes to the overrides section functionality.

coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 10, 2025
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🧹 Nitpick comments (7)
internal/exec/stack_processor_utils_test.go (2)

13-58: Test looks solid, consider documenting parameters for improved readability

The test provides good coverage for the ProcessYAMLConfigFile function, ensuring it produces the expected structure. However, the numerous parameters in the function call (lines 31-46) could use comments explaining their purpose, especially since most are set to nil or false.

Consider adding parameter documentation:

 	_, _, stackConfigMap, _, _, _, _, err := ProcessYAMLConfigFile(
-		atmosConfig,
-		stacksBasePath,
-		filePath,
-		map[string]map[string]any{},
-		nil,
-		false,
-		false,
-		true,
-		false,
-		nil,
-		nil,
-		nil,
-		nil,
-		"",
+		atmosConfig,            // Atmos configuration
+		stacksBasePath,         // Base path for stacks
+		filePath,               // Path to the YAML file to process
+		map[string]map[string]any{}, // Additional configurations
+		nil,                    // Inline Terraform overrides
+		false,                  // Skip template processing
+		false,                  // Skip template functions processing
+		true,                   // Process component vars
+		false,                  // Show template processing
+		nil,                    // Imported Terraform overrides
+		nil,                    // Inline Helmfile overrides
+		nil,                    // Imported Helmfile overrides
+		nil,                    // Context for template processing
+		"",                     // Component type

48-57: Consider enhancing assertions to validate map content

The test currently verifies the map keys exist, but doesn't check the actual content of these map entries. Adding assertions for the expected values would improve test coverage.

 	assert.Equal(t, "components", mapResultKeys[0])
 	assert.Equal(t, "import", mapResultKeys[1])
 	assert.Equal(t, "vars", mapResultKeys[2])
+
+	// Verify the content of the map entries
+	componentsMap, ok := stackConfigMap["components"].(map[string]interface{})
+	assert.True(t, ok, "components should be a map")
+	// Add assertions for specific component entries
cmd/workflow_test.go (2)

26-31: Consider using a constant or extracting this to a shared test util

This expected output string is duplicated in internal/exec/workflow_test.go. Consider extracting it to a shared constant or test utility to avoid duplication.

Move this to a shared test utility file that both tests can import.


49-50: Use more specific assertion to improve test clarity

The Contains assertion is useful but provides limited feedback. Consider using a more specific assertion that clearly shows what was expected vs. received.

-	assert.Contains(t, output.String(), expectedOutput, "'atmos workflow' output should contain information about workflows")
+	// Normalize whitespace in output for comparison
+	normalizedOutput := strings.TrimSpace(output.String())
+	normalizedExpected := strings.TrimSpace(expectedOutput)
+	assert.Equal(t, normalizedExpected, normalizedOutput, "'atmos workflow' output should match expected commands")
internal/exec/workflow_test.go (3)

40-63: Consider extracting workflow definition to test fixture

The hardcoded workflow definition would be better placed in a test fixture file, making the test more maintainable and focused on test logic rather than test data.

Move this workflow definition to a YAML fixture file and load it during the test, similar to how you're using other fixtures in this PR.


80-80: Fix typo in assertion message

There's a minor typo in the assertion message - missing "about" between "information" and "workflows".

-	assert.Contains(t, output.String(), expectedOutput, "'ExecuteWorkflow' output should contain information workflows")
+	assert.Contains(t, output.String(), expectedOutput, "'ExecuteWorkflow' output should contain information about workflows")

15-81: Reduce duplication with the TestWorkflowCmd test

This test has significant duplication with the cmd/workflow_test.go test. Consider extracting common setup and assertion code to shared test utilities.

Create a shared test utility package with functions for:

  1. Setting up and tearing down environment variables
  2. Capturing and restoring stdout
  3. Defining common expected outputs
  4. Common assertion helpers

This would make both tests more concise and maintainable.

🛑 Comments failed to post (2)
cmd/workflow_test.go (1)

15-19: 🛠️ Refactor suggestion

Remember to restore environment variables after test

Environment variables are set but not restored, which could affect other tests running in the same process. Consider using defer to restore them.

 	err := os.Setenv("ATMOS_CLI_CONFIG_PATH", stacksPath)
 	assert.NoError(t, err, "Setting 'ATMOS_CLI_CONFIG_PATH' environment variable should execute without error")
+	oldCliConfigPath := os.Getenv("ATMOS_CLI_CONFIG_PATH")
+	defer os.Setenv("ATMOS_CLI_CONFIG_PATH", oldCliConfigPath)
 
 	err = os.Setenv("ATMOS_BASE_PATH", stacksPath)
 	assert.NoError(t, err, "Setting 'ATMOS_BASE_PATH' environment variable should execute without error")
+	oldBasePath := os.Getenv("ATMOS_BASE_PATH")
+	defer os.Setenv("ATMOS_BASE_PATH", oldBasePath)

Committable suggestion skipped: line range outside the PR's diff.

internal/exec/workflow_test.go (1)

19-23: 🛠️ Refactor suggestion

Remember to restore environment variables after test

Environment variables are set but not restored, which could affect other tests running in the same process. Consider using defer to restore them.

 	err := os.Setenv("ATMOS_CLI_CONFIG_PATH", stacksPath)
 	assert.NoError(t, err, "Setting 'ATMOS_CLI_CONFIG_PATH' environment variable should execute without error")
+	oldCliConfigPath := os.Getenv("ATMOS_CLI_CONFIG_PATH")
+	defer os.Setenv("ATMOS_CLI_CONFIG_PATH", oldCliConfigPath)
 
 	err = os.Setenv("ATMOS_BASE_PATH", stacksPath)
 	assert.NoError(t, err, "Setting 'ATMOS_BASE_PATH' environment variable should execute without error")
+	oldBasePath := os.Getenv("ATMOS_BASE_PATH")
+	defer os.Setenv("ATMOS_BASE_PATH", oldBasePath)

Committable suggestion skipped: line range outside the PR's diff.

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 patch A minor, backward compatible change size/l
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants