Skip to content

add support for yml extension when searching for configuration file#506

Merged
creativeprojects merged 2 commits into
masterfrom
support-yml-extension
May 19, 2025
Merged

add support for yml extension when searching for configuration file#506
creativeprojects merged 2 commits into
masterfrom
support-yml-extension

Conversation

@creativeprojects
Copy link
Copy Markdown
Owner

Add support for yml extension when searching for configuration file

Fixes #404

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2025

## Walkthrough

The codebase refactors file searching logic to use a new `Finder` struct, enabling dependency injection of the filesystem and improving testability. All previous package-level file search functions are now instance methods on `Finder`. The configuration file search now supports both `.yaml` and `.yml` extensions.

## Changes

| File(s)                                                                 | Change Summary                                                                                                                                                                                                                                                                                                                                                  |
|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| filesearch/filesearch.go                                                | Refactored to introduce a `Finder` struct encapsulating an `afero.Fs` filesystem. All file search functions are now methods of `Finder`. Removed global `fs` and `AppName`, now using `constants.ApplicationName`. Added `.yml` to configuration extensions. Added `NewFinder` constructor.                                  |
| filesearch/filesearch_test.go                                           | Refactored tests to use isolated `Finder` instances with in-memory filesystems. Removed global filesystem setup and redundant cleanup. Simplified test data structures and added a test case for `.yml` support.                                                                                                         |
| commands_display.go, complete.go, config/config.go, main.go             | Updated to use `filesearch.NewFinder().<method>()` instead of package-level file search functions. No logic changes, only invocation method altered.                                                                                                                              |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Main
    participant Finder
    participant FS as FileSystem

    Main->>Finder: NewFinder()
    Main->>Finder: FindConfigurationFile("profiles.yml")
    Finder->>FS: Check existence for profiles.yml/yaml
    FS-->>Finder: File exists?
    Finder-->>Main: Return file path or error

Assessment against linked issues

Objective Addressed Explanation
Support both .yaml and .yml for configuration files (#404)

<!-- walkthrough_end -->

<!-- announcements_start -->

> [!NOTE]
> <details>
> <summary>⚡️ AI Code Reviews for VS Code, Cursor, Windsurf</summary>
> 
> CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
> Learn more [here](http://coderabbit.ai/ide).
> 
> </details>

---

> [!NOTE]
> <details>
> <summary>⚡️ Faster reviews with caching</summary>
> 
> CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure `Review - Disable Cache` at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the `Data Retention` setting under your Organization Settings.
> Enjoy the performance boost—your workflow just got faster.
> 
> </details>

<!-- announcements_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACI0WnoHbm58ClCAMxTIWWZfEgAPGgxEeHwsAHdYMnsSZwYEDCJIDL4mDDT4ImwqcVKm+EjoyDK0ZAcBZnUaejkwyshsREpGf2pJEl58ETFkEes7DEcBJYBWAAYANg0YObrMUhQMXApFbAZpe2wklPTM3DmAAw02S8/z6kUg+UKxV68CwcVo6hKWAIELySHEDVRUKRyAqVUWtXqjWaCjaHS6q167UiiCucFQn1o1A88P8iEWOww9HaeXeSAcHgOzCOfAALKdRXS5twuslFvw0rMPMxFPB2gxKVhUCiyLBMG8lU1Imi1F51PJ8Iq/h5Wu1Ot0kWCPEoaGJHTNYQwvNgEZjAcDQbs0H5RPgiBh4AAvKKQsjQjBSjwynwhoIhRiYSBHJr4bBc9ChWC4XDcRAcAD05aI6lg2AEGiYzHLDBW4ikGy2uEQ5bZ4gYG2pJHLya85bOlyM+mM4CgZHolpwBGIZGUUwUrHYXF4/GEojb7xmTCUVFU6i0OinJig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szyOgqama2daAeazw86s6uoS6zQY/Pw7BIwT+CI0haI6mOlX8BI2hNmFlGygm/InrSkwSSzUBU8soiorxf6+q2GsWccufNvKszUwg0G2goQhbdWCmlEcZRQOivVOyXjLWeZNcAK5ZXmFJBak2GyOyLJfSVKZAFhdOQ0Thf9FksqmkYTPKaS9S/8QRTS4uD46qI6TWIK7jRUYMGfJYbofqNTLAfpPsOmnEVZdZaQvaOCKePUg7Z4Y7Xkj+E5b+P5WgAAbjrQcTyg6WOt6H5u5DGxFk0tblflwzGn+muJquImuXqpJ2+zBmaspzar9I6rp2QVQSxnxXxkgivBRhK0XCfFpXanfE3F6h/HiI0sPFYhPDUFAgvAggMBrvfHUAQg9kQnkzsjoAQn6VSHAmrpnCaHOGOAAHYABGNIU4Y4NAAAThXpUDSDSAAGYl6SAt6BBjhaAAAOJe2gA+tILe0Udei+gQFe84JegAJi3ovvOFnoHvnvOAYFOH9TSAvqfqvoPoEAAdOH3qXrOAPq/qXoPpIBgYEAPrftFDfqXtOCZBIDfp/t/ogEumHtHoQnHoBVoAQjnFnqAA=== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=creativeprojects/resticprofile&utm_content=506):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `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 explain this code block.`
  -	`@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 explain its main purpose.`
  - `@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.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

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](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in 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` 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

@creativeprojects creativeprojects added this to the v0.31.0 milestone May 19, 2025
@creativeprojects creativeprojects added the enhancement New feature or request label May 19, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2025

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.33%. Comparing base (e6389f7) to head (6c0baf8).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
commands_display.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #506      +/-   ##
==========================================
- Coverage   79.34%   79.33%   -0.00%     
==========================================
  Files         134      134              
  Lines       13231    13233       +2     
==========================================
+ Hits        10497    10498       +1     
- Misses       2316     2317       +1     
  Partials      418      418              
Flag Coverage Δ
unittests 79.33% <95.83%> (-<0.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.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (2)
filesearch/filesearch_test.go (2)

235-239: Flaky test: relies on the real filesystem

TestCannotFindConfigurationFile calls NewFinder(), which wires the OS filesystem.
If a developer (or CI runner) happens to have a file called some_config_file.{yaml|yml|…} in any of the search paths, this test will produce a false negative.

Use an in-memory filesystem (as you did in the other tests) to guarantee determinism:

-	finder := NewFinder()
-	found, err := finder.FindConfigurationFile("some_config_file")
+	fs := afero.NewMemMapFs()
+	finder := Finder{fs: fs}
+	found, err := finder.FindConfigurationFile("some_config_file")

242-252: TestFindResticBinary also depends on the host environment

The current implementation succeeds if the host has a restic binary somewhere in PATH, but otherwise asserts an error.
This makes the outcome environment-dependent and weakens the value of the test.

Consider switching to an in-memory filesystem and explicitly creating a dummy restic file in one of the expected locations. This makes the expected result unambiguous and removes the fallback branch from the test path.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between e6389f7 and f6571f0.

📒 Files selected for processing (6)
  • commands_display.go (1 hunks)
  • complete.go (1 hunks)
  • config/config.go (1 hunks)
  • filesearch/filesearch.go (11 hunks)
  • filesearch/filesearch_test.go (8 hunks)
  • main.go (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
commands_display.go (1)
filesearch/filesearch.go (1)
  • NewFinder (76-80)
main.go (1)
filesearch/filesearch.go (1)
  • NewFinder (76-80)
complete.go (1)
filesearch/filesearch.go (1)
  • NewFinder (76-80)
config/config.go (1)
filesearch/filesearch.go (1)
  • NewFinder (76-80)
filesearch/filesearch_test.go (1)
filesearch/filesearch.go (2)
  • Finder (72-74)
  • NewFinder (76-80)
filesearch/filesearch.go (1)
constants/app.go (1)
  • ApplicationName (4-4)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and test (1.24, windows-latest)
🔇 Additional comments (6)
commands_display.go (1)

168-168: Implementation successfully refactored to use the Finder struct.

The code now creates a new Finder instance via NewFinder() to call the FindResticBinary method instead of using the package-level function. This change supports the broader refactoring effort and maintains the same functionality.

main.go (2)

278-278: Implementation successfully refactored to use the Finder struct.

The configuration file search logic is now appropriately using the Finder struct instance. This change aligns with the broader refactoring effort while preserving the original functionality.


349-349: Implementation successfully refactored for restic binary location.

The restic binary search logic now properly uses the Finder struct instance. This consistent pattern improves code maintainability.

complete.go (1)

137-137: Implementation successfully refactored for profile name listing.

The configuration file search in the listProfileNames function now correctly uses the Finder struct instance, consistent with the application-wide refactoring approach.

config/config.go (2)

104-104: Implementation successfully refactored for configuration includes.

The code now properly uses the Finder struct to search for configuration includes, maintaining consistency with the refactoring approach across the codebase.


72-73:

Details

✅ Verification successful

Verify implementation of .yml extension support in FindConfigurationFile.

While the refactoring to use Finder is visible in this PR, we should verify that the actual implementation in the filesearch package properly supports .yml extension as stated in the PR objective.


🏁 Script executed:

#!/bin/bash
# Check if the FindConfigurationFile method in the Finder struct supports .yml extension

# Look for .yml extension support in filesearch package
rg -A 5 -B 5 "yml" --glob "filesearch/*.go"

# Check for any test cases that verify .yml extension support
rg -A 5 -B 5 "yml" --glob "filesearch/*_test.go"

Length of output: 3852


.yml extension support verified

  • The filesearch/filesearch.go implementation includes "yml" in its list of recognised extensions.
  • Corresponding test cases in filesearch/filesearch_test.go cover searching for files with the .yml suffix.

All good—no further changes needed.

Comment thread filesearch/filesearch.go Outdated
Copy link
Copy Markdown

@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: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between f6571f0 and 6c0baf8.

📒 Files selected for processing (2)
  • filesearch/filesearch.go (11 hunks)
  • filesearch/filesearch_test.go (8 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
filesearch/filesearch_test.go (1)
filesearch/filesearch.go (2)
  • Finder (70-72)
  • NewFinder (74-78)
filesearch/filesearch.go (1)
constants/app.go (1)
  • ApplicationName (4-4)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build and test (1.24, windows-latest)
  • GitHub Check: Analyze (go)
🔇 Additional comments (13)
filesearch/filesearch_test.go (9)

98-102: Good addition of .yml test case

The addition of the .yml extension test case aligns with the main change in filesearch.go. This ensures proper testing coverage for the newly supported file extension.


140-144: LGTM

Added test case for profiles.yml in the unittest-config directory. This maintains consistency with other extensions test cases.


181-186: LGTM

Appropriately added test case for profiles.yml in the XDG ConfigHome directory, which ensures complete coverage of all configuration extension possibilities.


207-229: Good refactoring to isolated test cases

Excellent refactoring of the test logic to use subtests with parallel execution. The use of in-memory filesystem instances (afero.NewMemMapFs()) for each test provides better isolation and prevents interference between tests. The test now properly exercises the new Finder struct functionality.


235-236: LGTM

Properly updated to use the new Finder struct.


244-261: Good test enhancement

The test has been improved by explicitly creating the test binary in the filesystem. This makes the test more reliable by ensuring the binary exists in a known location rather than depending on actual system paths.


266-269: LGTM

Updated to use the new Finder struct with in-memory filesystem.


281-281: LGTM

Test properly updated to use platform.IsWindows() and the new Finder struct.

Also applies to: 288-290, 296-296


339-375: LGTM

Test properly updated to use the Finder struct with in-memory filesystem. This change maintains consistency with the broader refactoring.

Also applies to: 380-380

filesearch/filesearch.go (4)

26-26: Great! Added .yml extension support

Adding the .yml extension to the list of supported configuration file extensions is a good change that addresses issue #404. This extension is commonly used as an alternative to .yaml.


13-13: Good use of constants

Replacing hardcoded string "resticprofile" with constants.ApplicationName from the constants package improves maintainability. If the application name needs to change in the future, it will only need to be updated in one place.

Also applies to: 42-42, 224-224, 226-226


70-78: Well-designed refactoring to use dependency injection

The introduction of the Finder struct and the NewFinder constructor function is a good design choice. This change enables proper dependency injection of the filesystem interface, making the code more testable and modular.


82-82: LGTM on method conversion

Converting standalone functions to methods on the Finder struct is a logical part of the refactoring. This ensures a consistent approach to dependency injection throughout the package.

Also applies to: 110-110, 130-130, 175-175

Comment thread filesearch/filesearch.go
@sonarqubecloud
Copy link
Copy Markdown

@creativeprojects creativeprojects merged commit 81a6e45 into master May 19, 2025
11 checks passed
@creativeprojects creativeprojects deleted the support-yml-extension branch May 19, 2025 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] profiles.yaml

1 participant