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

Extend AddOcelot to EnumerateFiles in subfdirectories #1235

Closed
christoff85 opened this issue May 22, 2020 · 2 comments · Fixed by #1569
Closed

Extend AddOcelot to EnumerateFiles in subfdirectories #1235

christoff85 opened this issue May 22, 2020 · 2 comments · Fixed by #1569
Assignees
Labels
merged Issue has been merged to dev and is waiting for the next release proposal Proposal for a new functionality in Ocelot

Comments

@christoff85
Copy link

Expected Behavior / New Feature

Search ocelot.json files in given directory and all subdirectories.

Actual Behavior / Motivation for New Feature

Currently AddOcelot only enumerates files in top directory only.

I would like to add even more structure to my ocelot files and keep them as small and maintainable as possible.

Steps to Reproduce the Problem

Only one piece of code would need to be changed in:
Ocelot.DependencyInjection.ConfigurationBuilderExtensions.AddOcelot(this IConfigurationBuilder builder, string folder, IWebHostEnvironment env)
starting at line 37:

var files = new DirectoryInfo(folder)
.EnumerateFiles("*", SearchOption.AllDirectories)
.Where(fi => reg.IsMatch(fi.Name) && (fi.Name != excludeConfigName))
.ToList();

Specifications

  • Version: 14.0.9
@raman-m raman-m added the proposal Proposal for a new functionality in Ocelot label Sep 21, 2023
@raman-m
Copy link
Member

raman-m commented Sep 21, 2023

@christoff85 Hi Krzysztof!
Thanks for your interest in Ocelot!

Soon you will be able to do everything in Ocelot core services, add/remove services from DI.
We will have Custom MVC Builder feature soon: #1655
Also we will have Ocelot config file extensions in linked #1569 where you will be able to load Ocelot configuration from memory being constructed it as you wish, read from anywhere, including reading file from everywhere.

Also, you can hack current AddOcelot by specifying string folder param you want during Ocelot startup! So you can traverse the directory tree as you wish.

raman-m added a commit that referenced this issue Sep 23, 2023
…ration construction (#1569)

* Added AddOcelot Configbuilder Overload

Added an AddOcelot overload to load FileConfiguration directly from the application, so that all the routes could be made configurable and could be load from anywhere.

* Code review changes

* Added unit tests for ConfigurationBuilder AddOcelot method overload

* code review

* CA1816 Change ConfigurationReloadTests.Dispose() to call GC.SuppressFinalize(object). This will prevent derived types that introduce a finalizer from needing to re-implement 'IDisposable' to call it.

* SYSLIB1045 Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time.

* SA1601 Partial elements should be documented

* Add developer's XML-docs

---------

Co-authored-by: raman-m <[email protected]>
@raman-m raman-m added the merged Issue has been merged to dev and is waiting for the next release label Sep 23, 2023
@raman-m
Copy link
Member

raman-m commented Sep 23, 2023

@christoff85
The base support of your idea is available now.
If you still need to enumerate subdirectories, please, open PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged Issue has been merged to dev and is waiting for the next release proposal Proposal for a new functionality in Ocelot
Projects
None yet
2 participants