Is your feature request related to a problem? Please describe.
I've a project that has multiple components(nginx, grafana, prometheus, consul, ...) deployed with docker-compose. Security requirement is to accept https only on single a port so the only entrypoint is nginx. Access to consul api is rewritten so opening https://my-host.local/consul/v1/... . The problem is that I can't specify the path for consul discovery.
Describe the solution you'd like
I did a little investigation and found out that ConsulRawClient already supports setting a custom path but the ConsulClient does not. Imo it'd much better to specify custom path in the properties (like host and port) like this:
It only requires modifying ConsulProperties and ConsulAutoConfiguration + docs.
Describe alternatives you've considered
The alternative way is to write my own ConsulClient building it from the raw client like this:
@Bean
public ConsulClient consulClient(ConsulProperties consulProperties) {
final int agentPort = consulProperties.getPort();
final String agentHost = !StringUtils.isEmpty(consulProperties.getScheme())
? consulProperties.getScheme() + "://" + consulProperties.getHost() : consulProperties.getHost();
var consulRawClient = ConsulRawClient.Builder.builder()
.setHost(agentHost)
.setPort(agentPort);
if (consulProperties.getTls() != null) {
ConsulProperties.TLSConfig tls = consulProperties.getTls();
TLSConfig tlsConfig = new TLSConfig(tls.getKeyStoreInstanceType(), tls.getCertificatePath(),
tls.getCertificatePassword(), tls.getKeyStorePath(), tls.getKeyStorePassword());
consulRawClient.setTlsConfig(tlsConfig);
}
consulRawClient.setPath("/consul"); // custom path example
return new ConsulClient(consulRawClient.build());
}
That works fine.
Additional context
As I said, I can reach what I want without any PRs, but the way is kinda ugly. I'd define my own property like spring.cloud.consul.path and inject it manually into the configuration to set the path from it. Imo it'd be much more consistent to allow setting path from properties.
I can make a PR if you're ok with the proposal.
Thanks in advance!
Is your feature request related to a problem? Please describe. I've a project that has multiple components(nginx, grafana, prometheus, consul, ...) deployed with docker-compose. Security requirement is to accept https only on single a port so the only entrypoint is nginx. Access to consul api is rewritten so opening https://my-host.local/consul/v1/... . The problem is that I can't specify the path for consul discovery.
Describe the solution you'd like I did a little investigation and found out that
ConsulRawClient
already supports setting a custom path but theConsulClient
does not. Imo it'd much better to specify custom path in the properties (like host and port) like this:It only requires modifying
ConsulProperties
andConsulAutoConfiguration
+ docs.Describe alternatives you've considered The alternative way is to write my own
ConsulClient
building it from the raw client like this:That works fine.
Additional context As I said, I can reach what I want without any PRs, but the way is kinda ugly. I'd define my own property like
spring.cloud.consul.path
and inject it manually into the configuration to set the path from it. Imo it'd be much more consistent to allow setting path from properties. I can make a PR if you're ok with the proposal. Thanks in advance!