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

get atmos config and vendor from .yaml or .yml #736

Merged
merged 5 commits into from
Oct 20, 2024
Merged

get atmos config and vendor from .yaml or .yml #736

merged 5 commits into from
Oct 20, 2024

Conversation

haitham911
Copy link
Collaborator

@haitham911 haitham911 commented Oct 20, 2024

what

  • get atmos config and vendor file from atmos.yaml or atmos .yml vendor.yml
  • support both extensions if no extension set
  • if no extension set first checks if atmos.yaml exists, and if not, it checks for atmos.yml
  • If both .yaml and .yml files exist, the .yaml file is prioritized.

why

  • Both .yaml and .yml files have the same format . automatically selecting either file .yaml and .yml exist

references

Summary by CodeRabbit

  • New Features

    • Introduced a new function to search for configuration files with specific extensions, enhancing file handling capabilities.
  • Improvements

    • Enhanced logic for checking the existence of vendor and configuration files, improving robustness and flexibility in file handling.
    • Updated error messages for invalid component and stack configurations to improve clarity.
  • Bug Fixes

    • Refined error handling related to configuration file processing to prevent unnecessary error returns.
  • Chores

    • Updated constant values for configuration file names to remove file extensions, streamlining file handling.

@haitham911 haitham911 requested review from a team as code owners October 20, 2024 12:28
Copy link
Contributor

coderabbitai bot commented Oct 20, 2024

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes primarily focus on enhancing the handling of configuration files across several components. The ReadAndProcessVendorConfigFile function in internal/exec/vendor_utils.go has been updated to improve file existence checks and error handling. Similarly, the processConfigFile function in pkg/config/config.go has been refined to utilize a new method for checking configuration file existence. Additionally, a new function SearchConfigFile has been introduced in pkg/utils/file_utils.go to streamline the search for configuration files with specific extensions.

Changes

File Change Summary
internal/exec/vendor_utils.go Updated ReadAndProcessVendorConfigFile for improved file existence checks and error handling.
pkg/config/config.go Modified processConfigFile to use u.SearchConfigFile for checking configuration file paths.
pkg/utils/file_utils.go Added SearchConfigFile function for searching configuration files with specific extensions.
cmd/cmd_utils.go Updated error messages in executeCustomCommand for clarity regarding component and stack config.
pkg/config/const.go Changed CliConfigFileName constant from "atmos.yaml" to "atmos", removing the extension.

Possibly related PRs

  • get atmos config and vendor from .yaml or .yml #736: This PR modifies the ReadAndProcessVendorConfigFile function in internal/exec/vendor_utils.go, enhancing the file existence check to utilize u.SearchConfigFile, which aligns with the changes made in the main PR regarding vendor configuration file handling.

Suggested labels

minor

Suggested reviewers

  • johncblandii
  • nitrocode

Poem

🐰 In the burrow where configs dwell,
A search for files, we do so well.
With paths refined, we hop with glee,
Finding vendors, just wait and see!
So let us cheer, for code so bright,
In our little world, all feels just right! 🌼


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 to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@haitham911 haitham911 changed the title Dev 78 get atmos config and vendor file from atmos.yaml or atmos .yml vendor.yml Oct 20, 2024
@haitham911 haitham911 changed the title get atmos config and vendor file from atmos.yaml or atmos .yml vendor.yml get atmos config and vendor from .yml or .yml Oct 20, 2024
@haitham911 haitham911 changed the title get atmos config and vendor from .yml or .yml get atmos config and vendor from .yaml or .yml Oct 20, 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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between c866ab5 and a75fef0.

📒 Files selected for processing (3)
  • internal/exec/vendor_utils.go (1 hunks)
  • pkg/config/config.go (1 hunks)
  • pkg/utils/file_utils.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
pkg/utils/file_utils.go (1)

Line range hint 170-175: LGTM: Improved code formatting

The indentation change in the IsSocket function improves code readability while maintaining the existing functionality.

pkg/config/config.go (1)

341-354: LGTM! Changes align well with PR objectives.

The modifications to the processConfigFile function effectively implement the PR's goal of supporting both atmos.yaml and atmos.yml files. The use of u.SearchConfigFile(path) likely allows for checking both file extensions, and the subsequent use of configPath ensures consistency throughout the function.

These changes are minimal and focused, which reduces the risk of introducing new bugs while achieving the desired functionality enhancement.

internal/exec/vendor_utils.go (1)

135-137: Enhanced configuration file search improves flexibility

The use of u.SearchConfigFile(foundVendorConfigFile) enhances the flexibility by allowing the system to search for configuration files with different extensions, aligning with the PR objectives to support both atmos.yaml and atmos.yml.

pkg/utils/file_utils.go Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Outside diff range comments (2)
internal/exec/vendor_utils.go (2)

Line range hint 131-141: Consider refactoring to unify search paths

Currently, after calling u.SearchConfigFile(vendorConfigFile), the code checks cliConfig.BasePath separately if the file is not found. To streamline the search process and reduce redundancy, consider updating u.SearchConfigFile to include cliConfig.BasePath in its search paths. This would centralize the file-search logic and potentially simplify error handling.


Line range hint 137-139: Enhance error message for missing configuration file

When the vendor configuration file is not found, the error message only references the path constructed with cliConfig.BasePath:

fmt.Errorf("vendor config file '%s' does not exist", pathToVendorConfig)

To provide clearer guidance to the user, consider updating the error message to include all the locations searched for the configuration file. This will help users understand where the file is expected and troubleshoot more effectively.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between a75fef0 and 19c0542.

📒 Files selected for processing (4)
  • cmd/cmd_utils.go (2 hunks)
  • internal/exec/vendor_utils.go (1 hunks)
  • pkg/config/const.go (1 hunks)
  • pkg/utils/file_utils.go (1 hunks)
🧰 Additional context used
🔇 Additional comments (1)
internal/exec/vendor_utils.go (1)

Line range hint 128-144: Configuration file search logic correctly updated

The ReadAndProcessVendorConfigFile function now utilizes u.SearchConfigFile(vendorConfigFile) to enhance the search for vendor configuration files, allowing it to locate files with both .yaml and .yml extensions as intended in the PR objectives. The additional check in cliConfig.BasePath ensures that the configuration file is found even when it's not in the current directory, maintaining compatibility with existing configurations.

pkg/config/const.go Show resolved Hide resolved
pkg/utils/file_utils.go Show resolved Hide resolved
cmd/cmd_utils.go Show resolved Hide resolved
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 @haitham911

@aknysh aknysh added the no-release Do not create a new release (wait for additional code changes) label Oct 20, 2024
@aknysh aknysh merged commit 4fa97ea into main Oct 20, 2024
21 of 22 checks passed
@aknysh aknysh deleted the DEV-78 branch October 20, 2024 23:40
Copy link

These changes were released in v1.94.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-release Do not create a new release (wait for additional code changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants