Is your feature request related to a problem? Please describe. I have a bootstrap.properties with native env type enabled

spring.cloud.config.server.composite[0].type=native
spring.cloud.config.server.composite[0].search-locations=test/{application}/{label}

and application.yml with imports of yaml files grouped in directories

spring.config.import:
  - a.yml
  - car/b.yml
  - car/c.yml
  ...
  - airplane/d.yml
  - airplane/e.yml
  ...

car, airplane, and other directories are created in production servers if need. So, application.yml works with app local configs, but does not work then configs are moved to Spring Cloud Server (client app just starts without car/*, airplane/* imports without error also in case of spring.cloud.config.fail-fast=true).

Describe the solution you'd like Spring Cloud Server finds and reads all config files, but filter out files not directly placed in spring.cloud.config.server.composite[0].search-locations by NativeEnvironmentRepository.matchesLocation():323 method

if (normal.startsWith(finalPattern) && !normal.substring(finalPattern.length()).contains("/")) {
    matches = true;
    break;
}
if (locations != null) {
    return !Arrays.stream(locations).map(this::cleanFileLocation)
        .noneMatch(location -> location.startsWith(finalPattern)
            && !location.substring(finalPattern.length()).contains("/"));
}

IMHO, normal.substring(finalPattern.length()).contains("/") check is redundant. Why is it needed? IMHO, check only limits functionality without adding value, limits functionality well working with local FS configs.

Describe alternatives you've considered No alternatives. Feature working with local FS imports doesn't work with cloud config.

Comment From: ryanjbaxter

Can you elaborate why you are using bootstrap.yaml? What if you just put that config in application.yaml?

Comment From: vananiev

We should move configurations of all our apps to spring cloud. Spring Cloud Server used in embedded mode, so this app application.yml was moved to spring config servers's native configs folder.

Comment From: ryanjbaxter

Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.

Comment From: vananiev

Sample project https://github.com/vananiev/spring-cloud-server-demo. Steps to reproduce see in README.md

Comment From: ryanjbaxter

What if you set spring.cloud.config.server.native.searchLocations with a comma separated list of locations?

Comment From: vananiev

I know about this workaround, but

car, airplane, and other directories are created in production servers if need

  1. Subdirectories is created at runtime. Reboot not desirable for embedded app.
  2. There are 2nd, 3d level nesting levels. Too many subdirectories. So it will cause a bug (forgotten directory in config) sooner or later.

Why doesn't PR solve the issue?

Comment From: ryanjbaxter

I'm trying to understand the underlying problem maybe the PR does solve the problem.

Your sample does not start, can you please fix it so it reproduces the problem

Comment From: vananiev

I tried the following steps again, it works: - IntelliJ Idea 2021.2.3 (Ultimate Edition) - File -> New -> Project from Existing Sources -> https://github.com/vananiev/spring-cloud-server-demo.git - Shift + F9

After that I test console output (no dir/file2.yml mention) and GET http://localhost:8080/app/master (no dir/file2.yml content is shown)