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 JSON schema for Atmos manifests validation. Update !terraform.output YAML function #1053

Merged
merged 5 commits into from
Feb 12, 2025

Conversation

aknysh
Copy link
Member

@aknysh aknysh commented Feb 12, 2025

what

  • Update JSON schema for Atmos manifests validation. Add hooks to the JSON schema for Atmos manifests validation

  • Update !terraform.output YAML function

why

  • hooks is a recent addition to Atmos and need to be added to the JSON schema

  • When executing !terraform.output, Atmos sets all the ENV variables from the parent process (that executes the CLI command) in the child process (that executes terraform output using the terraform-exec library. The library does not allow certain environment variables to be set in the process, so we don't include those

related

Summary by CodeRabbit

  • New Features
    • Updated Atmos manifest schemas now support customizable hooks and a locking flag for enhanced component control.
  • Chores
    • Upgraded Atmos version from 1.160.4 to 1.160.5 across builds and CI/CD workflows.
    • Updated dependencies to improve overall reliability.
  • Documentation
    • Revised integration and workflow documentation to reflect the latest Atmos version.

@aknysh aknysh added the patch A minor, backward compatible change label Feb 12, 2025
@aknysh aknysh self-assigned this Feb 12, 2025
@aknysh aknysh requested a review from a team as a code owner February 12, 2025 03:54
Copy link

mergify bot commented Feb 12, 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.

@mergify mergify bot added the needs-cloudposse Needs Cloud Posse assistance label Feb 12, 2025
Copy link
Contributor

coderabbitai bot commented Feb 12, 2025

📝 Walkthrough

Walkthrough

This pull request makes several updates across Atmos JSON schemas to add new properties for enhanced extensibility. The changes include adding a top-level "hooks" property and incorporating "hooks" into the terraform_component_manifest, along with a new locked boolean within metadata definitions. In addition, the Atmos version is bumped in the Dockerfile, a dependency version is updated in the go module, and Terraform execution now filters prohibited environment variables using a new helper function. Test cases and documentation have been updated to reflect these changes.

Changes

Files Change Summary
examples/demo-.../schemas/atmos-manifest.json, website/static/schemas/atmos/.../atmos-manifest.json, internal/exec/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json, tests/fixtures/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json JSON schema updates: Added "hooks" at the root and within terraform_component_manifest; added locked (boolean) in metadata definitions.
examples/quick-start-advanced/Dockerfile Bumped ATMOS_VERSION from 1.160.4 to 1.160.5.
go.mod Updated github.com/charmbracelet/bubbletea version from v1.3.2 to v1.3.3.
internal/exec/terraform_outputs.go Introduced new constants, helper function environToMap(), and filtering for prohibited Terraform env vars with enhanced debug logging.
tests/test-cases/atmos-functions.yaml, website/docs/integrations/atlantis.mdx Adjusted test cases to include new environment variables; updated documentation with the new Atmos version.

Sequence Diagram(s)

sequenceDiagram
    participant E as execTerraformOutput
    participant F as environToMap
    participant T as Terraform Execution
    E->>F: Call environToMap()
    F-->>E: Return filtered environment map
    E->>T: Execute Terraform with filtered env vars
Loading

Possibly related PRs

Suggested labels

minor

Suggested reviewers

  • Gowiem
  • 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: 0

🧹 Nitpick comments (2)
internal/exec/terraform_outputs.go (1)

383-397: Consider removing the TODO comment or creating an issue.

The TODO comment suggests finding an alternative to using terraform-exec/tfexec. This should either be addressed now or tracked in an issue.

Would you like me to help create an issue to track this improvement?

tests/fixtures/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json (1)

742-747: Consider enhancing hooks schema with common patterns.

While the current implementation with additionalProperties: true provides maximum flexibility, consider documenting common hook patterns or providing an enum of known hook types to guide users.

Apply this diff to add common hook patterns:

   "hooks": {
     "type": "object",
     "description": "Hooks section",
     "additionalProperties": true,
+    "properties": {
+      "before": {
+        "type": "object",
+        "description": "Hooks to run before component operations",
+        "additionalProperties": true
+      },
+      "after": {
+        "type": "object",
+        "description": "Hooks to run after component operations",
+        "additionalProperties": true
+      }
+    },
     "title": "hooks"
   }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f10f64c and dbada8d.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (11)
  • examples/demo-context/schemas/atmos-manifest.json (3 hunks)
  • examples/demo-helmfile/schemas/atmos-manifest.json (3 hunks)
  • examples/demo-localstack/schemas/atmos-manifest.json (3 hunks)
  • examples/quick-start-advanced/Dockerfile (1 hunks)
  • go.mod (1 hunks)
  • internal/exec/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json (2 hunks)
  • internal/exec/terraform_outputs.go (5 hunks)
  • tests/fixtures/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json (2 hunks)
  • tests/test-cases/atmos-functions.yaml (1 hunks)
  • website/docs/integrations/atlantis.mdx (1 hunks)
  • website/static/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • website/docs/integrations/atlantis.mdx
  • go.mod
🧰 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.
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Build (macos-latest, macos)
  • GitHub Check: Build (windows-latest, windows)
  • GitHub Check: Summary
🔇 Additional comments (13)
internal/exec/terraform_outputs.go (3)

23-39: LGTM! Well-structured constants for Terraform environment variables.

The constants are well-organized and clearly named, making the code more maintainable.


41-54: LGTM! Comprehensive lists of prohibited environment variables.

The lists effectively capture both direct variables and prefixes that should be filtered out during Terraform execution.

Also applies to: 56-59


173-174: LGTM! Improved environment variable handling.

The code now properly filters out prohibited environment variables before passing them to the Terraform execution context.

Also applies to: 180-184

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

9-9: LGTM! Version update aligns with team preferences.

The update to ATMOS_VERSION=1.160.5 follows the team's practice of pinning to the next future version when the PR merges.

tests/test-cases/atmos-functions.yaml (1)

80-86: LGTM! Test case validates environment variable filtering.

The test case effectively demonstrates that prohibited environment variables will not be passed to the child process.

website/static/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json (2)

235-237: LGTM! Added hooks support to terraform component manifest.

The schema now properly supports the hooks feature for Terraform components.


742-747: LGTM! Well-defined hooks schema.

The hooks schema is properly defined with appropriate type and description, allowing for flexible additional properties.

tests/fixtures/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json (2)

234-237: LGTM! Well-structured hooks integration.

The addition of the hooks property to the terraform_component_manifest is clean and follows JSON Schema best practices by referencing the hooks definition.


356-359: LGTM! Clear metadata locking mechanism.

The locked property in metadata is well-documented and provides a clear mechanism for controlling component modifications.

internal/exec/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json (1)

234-237: LGTM! Schema changes are consistent.

The changes in this file mirror those in the test fixtures, maintaining consistency across the codebase.

Also applies to: 742-747, 356-359

examples/demo-context/schemas/atmos-manifest.json (1)

234-237: LGTM! Example schema maintains consistency.

The demo context schema correctly implements the new hooks and locked properties, providing a good reference for users.

Also applies to: 742-747, 356-359

examples/demo-localstack/schemas/atmos-manifest.json (1)

234-237: LGTM! LocalStack demo schema is aligned.

The schema changes are consistently implemented in the LocalStack demo, maintaining parity with other examples.

Also applies to: 742-747, 356-359

examples/demo-helmfile/schemas/atmos-manifest.json (1)

234-237: LGTM! Helmfile demo schema is synchronized.

The schema changes are properly reflected in the Helmfile demo, ensuring consistency across all example implementations.

Also applies to: 742-747, 356-359

@aknysh aknysh merged commit 82bdaa6 into main Feb 12, 2025
48 of 49 checks passed
@aknysh aknysh deleted the update-yaml-funcs-5 branch February 12, 2025 04:35
@mergify mergify bot removed the needs-cloudposse Needs Cloud Posse assistance label Feb 12, 2025
Copy link

These changes were released in v1.160.5.

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

Successfully merging this pull request may close these issues.

2 participants