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

Ehance native backend documentation #2647

Open
andersonfaria-hotmart opened this issue Nov 22, 2024 · 12 comments
Open

Ehance native backend documentation #2647

andersonfaria-hotmart opened this issue Nov 22, 2024 · 12 comments

Comments

@andersonfaria-hotmart
Copy link

Documentation says that to use native file backend is necessary to use spring.profiles.active=native.
But if it's necessary to use different profiles (embedded config server with local files for example) it'd be impossible to change behavior for staging or production for example.
In such cases it's possible to use a different profile from native and create a NativeEnvironmentRepository Bean:

@Bean
public NativeEnvironmentRepository environmentRepository(NativeEnvironmentRepositoryFactory factory,
                                       NativeEnvironmentProperties environmentProperties) {
    return factory.build(environmentProperties);
}
@ryanjbaxter
Copy link
Contributor

Can you provide a more complete example of the problem? I am not sure I understand what the issue or suggestion is.

@andersonfaria-hotmart
Copy link
Author

andersonfaria-hotmart commented Nov 22, 2024

Documentation does not say about the possibility to create the NativeEnvironmentRepository, only says about the spring.profiles.active=native.
It could help someone else this information. I spent some time to figure out this.

@ryanjbaxter
Copy link
Contributor

That is true of every bean that is conditionally activated. If the bean is not created for some reason you have the option to create it yourself. We don't typically document those things, we try to document functionality instead.

@andersonfaria-hotmart
Copy link
Author

This documentation could be helpful in cases when someone needs to manage different profiles, as I mentioned. I spent some time figuring it out...

@ryanjbaxter
Copy link
Contributor

So why not activate multiple profiles?

@andersonfaria-hotmart
Copy link
Author

Well, I tried it, but didn't work. I don't know why but the only way for me was creating the NativeEnvironmentRepository

@ryanjbaxter
Copy link
Contributor

It should work. In fact we explicitely call that out in the documentation as a way of supporting multiple EnvironmentRepositorys
https://docs.spring.io/spring-cloud-config/reference/server/environment-repository/composite-repositories.html

@andersonfaria-hotmart
Copy link
Author

But that wasn't the problem. The NativeEnvironmentRepository was needed to use one repository (native) with multiple profiles

@ryanjbaxter
Copy link
Contributor

The additional profiles were unrelated to the config server?

@andersonfaria-hotmart
Copy link
Author

In my specific case I intended to use config server for resource bundles to another apis. But I needed to use it with local files, so I needed to use the profile=native.
I tried to use 2 profiles at the same time (native and production or native and staging) but this didn't work. So I created the NativeEnvironmentRepository and used the desired profile with the respective properties

@ryanjbaxter
Copy link
Contributor

Can you provide a sample that reproduces the problem?

@andersonfaria-hotmart
Copy link
Author

I'll create a sample project and share it here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants