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

Imports for overrides #831

Merged
merged 9 commits into from
Dec 9, 2024
Merged

Imports for overrides #831

merged 9 commits into from
Dec 9, 2024

Conversation

aknysh
Copy link
Member

@aknysh aknysh commented Dec 8, 2024

what

why

  • To make the overrides configuration DRY and reusable, you can place the overrides sections into a separate stack manifest, and then import it into other stacks

For example:

Define the overrides sections in a separate manifest stacks/teams/testing-overrides.yaml:

# Global overrides
# Override the variables, env, command and settings ONLY in the components managed by the `testing` Team.
overrides:
  env:
    # This ENV variable will be added or overridden in all the components managed by the `testing` Team
    TEST_ENV_VAR1: "test-env-var1-overridden"
  settings: {}
  vars: {}

# Terraform overrides
# Override the variables, env, command and settings ONLY in the Terraform components managed by the `testing` Team.
# The Terraform `overrides` are deep-merged with the global `overrides`
# and takes higher priority (it will override the same keys from the global `overrides`).
terraform:
  overrides:
    settings:
      spacelift:
        # All the components managed by the `testing` Team will have the Spacelift stacks auto-applied
        # if the planning phase was successful and there are no plan policy warnings
        # https://docs.spacelift.io/concepts/stack/stack-settings#autodeploy
        autodeploy: true
    vars:
      # This variable will be added or overridden in all the Terraform components managed by the `testing` Team
      test_1: 1
    # The `testing` Team uses `tofu` instead of `terraform`
    # https://opentofu.org
    # The commands `atmos terraform <sub-command> ...` will execute the `tofu` binary
    command: tofu

Import the stacks/teams/testing-overrides.yaml manifest into the stack stacks/teams/testing.yaml:

import:
  # The `testing` Team manages all the components defined in this stack manifest and imported from the catalog
  - catalog/terraform/test-component-2
  # The `overrides` in `teams/testing-overrides` will affect all the components in this stack manifest
  # and all the components that are imported AFTER the `overrides` from `teams/testing-overrides`.
  # It will affect the components imported from `catalog/terraform/test-component-2`.
  # The `overrides` defined in this manifest will affect all the imported components, including `catalog/terraform/test-component-2`.
  - teams/testing-overrides
  - catalog/terraform/test-component
  - catalog/terraform/test-component-override

# The `overrides` in this stack manifest take precedence over the `overrides` imported from `teams/testing-overrides`

# Global overrides
# Override the variables, env, command and settings ONLY in the components managed by the `testing` Team.
overrides:
  env:
    # This ENV variable will be added or overridden in all the components managed by the `testing` Team
    TEST_ENV_VAR1: "test-env-var1-overridden-2"
  settings: {}
  vars: {}

# Terraform overrides
# Override the variables, env, command and settings ONLY in the Terraform components managed by the `testing` Team.
# The Terraform `overrides` are deep-merged with the global `overrides`
# and takes higher priority (it will override the same keys from the global `overrides`).
terraform:
  overrides:
    vars:
      # This variable will be added or overridden in all the Terraform components managed by the `testing` Team
      test_1: 2

NOTES:

  • The order of the imports is important. The overrides in teams/testing-overrides will affect all the components in
    this stack manifest and all the components that are imported after the overrides from teams/testing-overrides.
    In other words, the overrides in teams/testing-overrides will be applied to the catalog/terraform/test-component
    and catalog/terraform/test-component-override components, but not to catalog/terraform/test-component-2

  • On the other hand, the overrides defined in this stack manifest stacks/teams/testing.yaml will be applied to all
    components defined inline in stacks/teams/testing.yaml and all the imported components, including catalog/terraform/test-component-2

  • The overrides defined inline in the stack manifest stacks/teams/testing.yaml take precedence over the overrides
    imported from teams/testing-overrides (they will override the same values defined in teams/testing-overrides)

Summary by CodeRabbit

  • New Features
    • Introduced a new YAML configuration file for the testing team with specific overrides.
  • Improvements
    • Updated documentation on override configurations for better clarity and usability.
    • Enhanced the Atlantis integration documentation with detailed configuration options and workflows.
  • Bug Fixes
    • Updated various environment variable values for the testing team to ensure correct configurations.
  • Chores
    • Updated dependency versions in the website's package.json for improved performance and compatibility.

@aknysh aknysh added the minor New features that do not break anything label Dec 8, 2024
@aknysh aknysh requested a review from osterman December 8, 2024 20:38
@aknysh aknysh self-assigned this Dec 8, 2024
@aknysh aknysh requested review from a team as code owners December 8, 2024 20:38
Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

📝 Walkthrough

Walkthrough

This pull request includes updates to several configuration files. The Dockerfile version for Atmos is updated from 1.118.0 to 1.121.0. A new YAML file, testing-overrides.yaml, is introduced with environment variable overrides for the testing Team. The existing testing.yaml file is modified to update variable values and clarify comments. Additionally, several functions in Go files are updated to accommodate new return values, enhancing error handling and configuration management. Documentation files are also revised for clarity without altering functionality.

Changes

File Path Change Summary
examples/quick-start-advanced/Dockerfile Updated ATMOS_VERSION from 1.118.0 to 1.121.0.
examples/tests/stacks/teams/testing-overrides.yaml New file created with global and component-specific overrides for the testing Team.
examples/tests/stacks/teams/testing.yaml Updated variable values and comments for clarity; modified TEST_ENV_VAR1, test_1, TEST_ENV_VAR2.
internal/exec/stack_processor_utils.go Updated ProcessYAMLConfigFile and ProcessYAMLConfigFiles signatures to include new return values.
internal/exec/validate_stacks.go Updated ProcessYAMLConfigFile call in ValidateStacks to include additional parameters.
pkg/stack/stack_processor.go Updated ProcessYAMLConfigFile signature to include two additional return values.
website/docs/core-concepts/stacks/overrides.mdx Added new import statement and restructured content for clarity regarding overrides.
website/docs/integrations/atlantis.mdx Updated document for Atlantis Integration with clearer configuration options and workflows.
website/package.json Updated posthog-js from ^1.194.0 to ^1.194.5 and prettier from ^3.4.1 to ^3.4.2.
atmos.yaml Minor updates to comments regarding YAML file handling; no changes to configuration settings.

Possibly related PRs

Suggested reviewers

  • osterman: Suggested for review based on expertise and familiarity with the changes.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 24ab927 and 049577f.

📒 Files selected for processing (2)
  • examples/quick-start-advanced/Dockerfile (1 hunks)
  • website/docs/integrations/atlantis.mdx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/quick-start-advanced/Dockerfile
  • website/docs/integrations/atlantis.mdx

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

🧹 Outside diff range and nitpick comments (3)
internal/exec/stack_processor_utils.go (2)

Line range hint 220-230: Reduce duplication in error handling.

Consider refactoring repetitive error return blocks to improve maintainability.


454-472: Optimize override merging logic.

Review the merging of final Terraform and Helmfile overrides to see if it can be streamlined.

website/docs/quick-start/install-atmos.mdx (1)

312-312: Documentation improvement for better user experience

The font recommendation enhances readability, though it's unrelated to the override functionality.

Consider moving font recommendations to a separate "Terminal Configuration" section in the documentation.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between bd20472 and 5782626.

⛔ Files ignored due to path filters (1)
  • website/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (10)
  • examples/quick-start-advanced/Dockerfile (1 hunks)
  • examples/tests/stacks/teams/testing-overrides.yaml (1 hunks)
  • examples/tests/stacks/teams/testing.yaml (1 hunks)
  • internal/exec/stack_processor_utils.go (13 hunks)
  • internal/exec/validate_stacks.go (1 hunks)
  • pkg/stack/stack_processor.go (1 hunks)
  • website/docs/core-concepts/stacks/overrides.mdx (7 hunks)
  • website/docs/integrations/atlantis.mdx (1 hunks)
  • website/docs/quick-start/install-atmos.mdx (1 hunks)
  • website/package.json (2 hunks)
🧰 Additional context used
📓 Learnings (1)
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.
🪛 LanguageTool
website/docs/core-concepts/stacks/overrides.mdx

[grammar] ~68-~68: Did you mean “until” or “up to”?
Context: ...within the manifest and all its imports up until that point. In other words, the `overri...

(UP_UNTIL)


[style] ~112-~112: A comma is missing here.
Context: ...ifests into a top-level stack manifest, e.g. tenant1/dev/us-west-2.yaml: <File ti...

(EG_NO_COMMA)


[style] ~292-~292: The serial comma (Oxford comma, Harvard comma) is missing.
Context: ...verrides # Override the variables, env, command and settings ONLY in the Terraform componen...

(SERIAL_COMMA_ON)


[style] ~308-~308: Consider using the typographical ellipsis character here instead.
Context: ...https://opentofu.org # The commands atmos terraform <sub-command> ... will execute the tofu binary com...

(ELLIPSIS)


[grammar] ~355-~355: Please add a punctuation mark at the end of paragraph.
Context: ...component-overridecomponents, but not tocatalog/terraform/test-component-2` -...

(PUNCTUATION_PARAGRAPH_END)

🔇 Additional comments (17)
internal/exec/stack_processor_utils.go (4)

73-73: Confirm handling of new return values in ProcessYAMLConfigFile.

Ensure that ignoring the additional return values in the function call is intentional and doesn't affect the application flow.


199-201: Check consistency in error return statements.

Verify that all error returns include the new return values to maintain consistency across the function.


283-311: Validate processing of overrides sections.

Ensure that the parsing and merging of global, Terraform, and Helmfile overrides correctly reflect the intended hierarchy.


316-331: Assess merge order of override configurations.

Confirm that the order of merging overrides provides the correct precedence, especially for parent overrides.

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

9-9: Version update to 1.120.0 is acceptable.

Updating ATMOS_VERSION aligns with team practices and future release planning.

examples/tests/stacks/teams/testing-overrides.yaml (1)

1-40: Overrides are well-structured and effective.

The configuration correctly implements the desired overrides for the testing team components.

website/package.json (1)

39-39: Confirm compatibility with updated dependencies.

Ensure that the updates to posthog-js and prettier do not introduce any issues in the project.

Also applies to: 55-55

examples/tests/stacks/teams/testing.yaml (3)

4-10: Well-documented import behavior!

The comments clearly explain the scope and precedence of overrides, which is crucial for maintainability.


33-33: Well-structured component-specific overrides

The separation between Terraform and Helmfile overrides provides clear organization and follows the DRY principle.

Also applies to: 43-43


21-21: Verify override propagation

Let's ensure this global override is correctly applied to all components.

✅ Verification successful

Global override is properly structured

The override hierarchy for TEST_ENV_VAR1 is well-defined across the stack:

  • Base value in test-component.yaml: "val1"
  • Various component-level overrides in different override files
  • Final global override in testing.yaml: "test-env-var1-overridden-2"

The global override follows the expected pattern and will take precedence over component-level values, which is the intended behavior.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any hardcoded values of TEST_ENV_VAR1 that might conflict
rg "TEST_ENV_VAR1.*test-env-var1-overridden-2" --type yaml

Length of output: 149


Script:

#!/bin/bash
# Let's check for all occurrences of TEST_ENV_VAR1 to understand the override hierarchy
rg "TEST_ENV_VAR1" --type yaml -A 2

Length of output: 1729

pkg/stack/stack_processor.go (1)

54-55: Function signature enhancement supports override functionality

The addition of two map return values enhances the override processing capabilities. However, we should ensure proper error handling for these new return values.

✅ Verification successful

Function signature change is properly handled

The function signature change in ProcessYAMLConfigFile is correctly implemented across the codebase. The function is a wrapper in pkg/stack/stack_processor.go that delegates to the actual implementation in internal/exec/stack_processor_utils.go. All callers are using the updated signature with proper error handling, and the new return values (maps) are used for override processing functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent error handling in callers
rg "ProcessYAMLConfigFile.*map\[string\]any.*error" --type go

Length of output: 63


Script:

#!/bin/bash
# Let's first check the function signature and its implementation
ast-grep --pattern 'func ProcessYAMLConfigFile($$$) ($$$)'

# Also check for any calls to this function
rg "ProcessYAMLConfigFile\(" -A 2 --type go

Length of output: 33301

internal/exec/validate_stacks.go (1)

132-132: LGTM! Function call updated to match new signature.

The ProcessYAMLConfigFile function call has been correctly updated to include the two additional parameters required by the new function signature.

website/docs/core-concepts/stacks/overrides.mdx (4)

10-10: LGTM! Added File component import.

The import statement for the File component has been added, which is used to better represent file content in the documentation.


13-14: LGTM! Improved introduction clarity.

The introduction has been reformatted to improve readability, with better line breaks and clearer explanation of the overrides functionality.


67-69: LGTM! Enhanced explanation of overrides scope.

The text clearly explains the scope limitations of override configurations within stack manifests.

🧰 Tools
🪛 LanguageTool

[grammar] ~68-~68: Did you mean “until” or “up to”?
Context: ...within the manifest and all its imports up until that point. In other words, the `overri...

(UP_UNTIL)


271-362: LGTM! Comprehensive new section on importing overrides.

Added a new section that thoroughly explains:

  • How to make overrides configuration DRY and reusable
  • The process of importing overrides from separate manifests
  • The importance of import order
  • Precedence rules for inline vs imported overrides
🧰 Tools
🪛 LanguageTool

[style] ~292-~292: The serial comma (Oxford comma, Harvard comma) is missing.
Context: ...verrides # Override the variables, env, command and settings ONLY in the Terraform componen...

(SERIAL_COMMA_ON)


[style] ~308-~308: Consider using the typographical ellipsis character here instead.
Context: ...https://opentofu.org # The commands atmos terraform <sub-command> ... will execute the tofu binary com...

(ELLIPSIS)


[grammar] ~355-~355: Please add a punctuation mark at the end of paragraph.
Context: ...component-overridecomponents, but not tocatalog/terraform/test-component-2` -...

(PUNCTUATION_PARAGRAPH_END)

website/docs/integrations/atlantis.mdx (1)

676-676: LGTM! Updated Atmos version.

The ATMOS_VERSION has been updated from 1.118.0 to 1.120.0, keeping the documentation in sync with the latest release.

internal/exec/stack_processor_utils.go Show resolved Hide resolved
coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 8, 2024
@aknysh
Copy link
Member Author

aknysh commented Dec 9, 2024

@coderabbitai review again

Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

@aknysh: Understood, I will review the changes.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 9, 2024
@aknysh aknysh temporarily deployed to preview December 9, 2024 02:27 — with GitHub Actions Inactive
@aknysh aknysh merged commit 73c8c49 into main Dec 9, 2024
29 checks passed
@aknysh aknysh deleted the imports-for-overrides branch December 9, 2024 13:48
Copy link

github-actions bot commented Dec 9, 2024

These changes were released in v1.121.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor New features that do not break anything
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants