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

Export configuration information in shell launched by Atmos #827

Merged
merged 3 commits into from
Dec 9, 2024

Conversation

Nuru
Copy link
Contributor

@Nuru Nuru commented Dec 8, 2024

what

  • Export Atmos Terraform configuration information in shell launched by Atmos

why

  • When Atmos launches a shell, it configures the shell for Terraform to reference a certain component and stack. The configuration is such that Terraform commands will work with a specific component and stack when run from a specific directory, and that informations is output to the user, but it has not been available in the environment for scripts or other automation to reference. By exposing that information in the environment, tools (e.g. the command prompt) can notify the user of the invisible state information and also warn the user if they are executing commands from the wrong directory and help them get back to the right one, among other possibilities.

Summary by CodeRabbit

  • New Features

    • Enhanced Terraform command functionality with additional environment variables for improved configuration.
  • Documentation

    • Expanded the atmos.yaml configuration file description and loading priority details.
    • Improved installation instructions for the Atmos CLI with organized methods and clearer setup guidance.
    • Added sections on environment variables and context to enhance user understanding.

@Nuru Nuru requested a review from aknysh December 8, 2024 07:07
@Nuru Nuru requested review from a team as code owners December 8, 2024 07:07
@Nuru Nuru requested review from Gowiem and RoseSecurity December 8, 2024 07:07
@Nuru Nuru enabled auto-merge (squash) December 8, 2024 07:10
Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request enhance the execTerraformShellCommand function within internal/exec/shell_utils.go by adding several environment variables related to Terraform commands and Atmos shell configuration. This includes variables such as TF_CLI_ARGS_plan, ATMOS_STACK, and others, which are appended to the componentEnvList. The overall command execution logic and error handling remain unchanged, with additional comments added for clarity.

Changes

File Change Summary
internal/exec/shell_utils.go Added environment variables for Terraform commands and Atmos configuration to execTerraformShellCommand. Comments were added for clarity, but no changes were made to the command execution logic or error handling.
website/docs/cli/configuration/configuration.mdx Expanded the description of the atmos.yaml configuration file, detailing loading priority, default settings, and new sections on environment variables and context. Improved structure and readability.
website/docs/quick-start/install-atmos.mdx Enhanced installation instructions for the Atmos CLI, organized by platform, and included new installation methods. Improved setup instructions and overall document structure for better usability.

Possibly related PRs

Suggested reviewers

  • hans-d
  • aknysh
  • osterman

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.

coderabbitai[bot]
coderabbitai bot previously requested changes Dec 8, 2024
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 (1)
internal/exec/shell_utils.go (1)

265-267: Convert comment into actionable enhancement for Geodesic detection.

The comment identifies a valid compatibility issue with custom shell prompts in Geodesic. Let's track this as a feature enhancement.

Would you like me to create a GitHub issue to track the implementation of Geodesic shell detection? The issue would include:

  1. Detection of Geodesic environment using GEODESIC_SHELL environment variable
  2. Special handling of shell prompt configuration when running inside Geodesic
  3. Documentation updates for Geodesic compatibility
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3f2f103 and f874777.

📒 Files selected for processing (1)
  • internal/exec/shell_utils.go (2 hunks)
🔇 Additional comments (2)
internal/exec/shell_utils.go (2)

188-201: LGTM! The implementation successfully achieves the PR objectives.

The changes effectively export Terraform configuration information when launching a shell, which will help users maintain awareness of their environment state. The implementation is clean and well-documented.


188-193: Consider adding validation for the varFile parameter.

The code consistently sets up Terraform CLI arguments for all relevant commands. However, it might be worth adding validation to ensure the varFile exists and is readable before setting these environment variables. This would help prevent shell initialization with invalid configurations.

Let's check if similar validation exists elsewhere in the codebase:

internal/exec/shell_utils.go Show resolved Hide resolved
@aknysh aknysh added the minor New features that do not break anything label Dec 8, 2024
@osterman
Copy link
Member

osterman commented Dec 8, 2024

We should also update the docs to describe this functionality.

The best I can think of is adding it here, in a new section.

Ideally we should document all environment variables that we set.

https://atmos.tools/cli/configuration/#environment-variables

@Nuru Nuru force-pushed the export-shell-envs branch from f874777 to 573b321 Compare December 8, 2024 23:28
@Nuru Nuru temporarily deployed to preview December 8, 2024 23:28 — with GitHub Actions Inactive
@Nuru
Copy link
Contributor Author

Nuru commented Dec 8, 2024

We should also update the docs to describe this functionality.

The best I can think of is adding it here, in a new section.

Ideally we should document all environment variables that we set.

https://atmos.tools/cli/configuration/#environment-variables

@osterman documentation added

@Nuru Nuru dismissed coderabbitai[bot]’s stale review December 8, 2024 23:32

Requested change is beyond the scope of this PR

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

🧹 Outside diff range and nitpick comments (1)
website/docs/cli/configuration/configuration.mdx (1)

637-653: Fix style and typo in the context section.

The section provides valuable information about environment variables in spawned shells, but needs minor refinements:

  1. Line 640: Consider rephrasing "in order to enable" to "to enable" for better readability
  2. Line 651: Fix typo "comamnds" to "commands"

Apply this diff to fix the issues:

-spawn an interactive shell with certain environment variables set, in order to enable the user to use other tools
+spawn an interactive shell with certain environment variables set to enable the user to use other tools
-| ATMOS_TERRAFORM_WORKSPACE | The name of the Terraform workspace in which Terraform comamnds should be run                          |
+| ATMOS_TERRAFORM_WORKSPACE | The name of the Terraform workspace in which Terraform commands should be run                          |
🧰 Tools
🪛 LanguageTool

[style] ~640-~640: Consider a shorter alternative to avoid wordiness.
Context: ...with certain environment variables set, in order to enable the user to use other tools (in ...

(IN_ORDER_TO_PREMIUM)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f874777 and 573b321.

📒 Files selected for processing (3)
  • internal/exec/shell_utils.go (2 hunks)
  • website/docs/cli/configuration/configuration.mdx (2 hunks)
  • website/docs/quick-start/install-atmos.mdx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/exec/shell_utils.go
🧰 Additional context used
🪛 LanguageTool
website/docs/cli/configuration/configuration.mdx

[style] ~640-~640: Consider a shorter alternative to avoid wordiness.
Context: ...with certain environment variables set, in order to enable the user to use other tools (in ...

(IN_ORDER_TO_PREMIUM)

🔇 Additional comments (2)
website/docs/quick-start/install-atmos.mdx (1)

312-312: LGTM! Good addition to the documentation.

The tip about recommending "Fira Code" NerdFont version is helpful for users to achieve consistent terminal display.

website/docs/cli/configuration/configuration.mdx (1)

Line range hint 602-636: LGTM! Comprehensive documentation of environment variables.

The table provides clear mapping between environment variables and their corresponding YAML paths, making it easier for users to understand configuration options.

@Nuru Nuru requested a review from osterman December 8, 2024 23:35
Copy link
Member

@aknysh aknysh left a comment

Choose a reason for hiding this comment

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

thanks @Nuru

@Nuru Nuru merged commit d6d0ff7 into main Dec 9, 2024
29 checks passed
@Nuru Nuru deleted the export-shell-envs branch December 9, 2024 01:58
Copy link

github-actions bot commented Dec 9, 2024

These changes were released in v1.120.0.

@coderabbitai coderabbitai bot mentioned this pull request Dec 9, 2024
@Nuru
Copy link
Contributor Author

Nuru commented Dec 9, 2024

@coderabbitai Please create a GitHub issue to track the implementation of Geodesic shell detection

Copy link
Contributor

coderabbitai bot commented Dec 9, 2024

Tip

For best results, initiate chat on the files or code changes.

@Nuru, I've created the GitHub issue to track the implementation of Geodesic shell detection: #837.

🔗 Analysis chain

@Nuru, I'll create a GitHub issue to track the implementation of Geodesic shell detection.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Create a GitHub issue to track the implementation of Geodesic shell detection
gh issue create \
  --title "Implement Geodesic shell detection in Atmos" \
  --body "As discussed in [PR #827](https://github.com/cloudposse/atmos/pull/827), we need to implement Geodesic shell detection in Atmos as requested by @Nuru." \
  --assignee Nuru

Length of output: 294

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.

3 participants