Skip to content

Commit 968481e

Browse files
committed
Allow configuration of Spring API client proxies via environment variable
1 parent eeef0b8 commit 968481e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

orkes-spring/src/main/java/io/orkes/conductor/client/spring/OrkesConductorClientAutoConfiguration.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
import io.orkes.conductor.client.http.OrkesWorkflowClient;
3535

3636
import lombok.extern.slf4j.Slf4j;
37+
import org.springframework.core.env.Environment;
38+
39+
import java.net.InetSocketAddress;
40+
import java.net.Proxy;
41+
import java.net.URI;
3742

3843
@AutoConfiguration
3944
@Slf4j
@@ -45,7 +50,7 @@ public class OrkesConductorClientAutoConfiguration {
4550
@Primary
4651
@ConditionalOnMissingBean
4752
public ApiClient orkesConductorClient(ClientProperties clientProperties,
48-
OrkesClientProperties orkesClientProperties) {
53+
OrkesClientProperties orkesClientProperties, Environment environment) {
4954
var basePath = StringUtils.isBlank(clientProperties.getRootUri()) ? clientProperties.getBasePath() : clientProperties.getRootUri();
5055
if (basePath == null) {
5156
basePath = orkesClientProperties.getConductorServerUrl();
@@ -62,6 +67,14 @@ public ApiClient orkesConductorClient(ClientProperties clientProperties,
6267
.writeTimeout(clientProperties.getTimeout().getWrite())
6368
.verifyingSsl(clientProperties.isVerifyingSsl());
6469

70+
var proxy = environment.getProperty("CONDUCTOR_SERVER_PROXY_URL");
71+
72+
if (proxy != null) {
73+
var uri = URI.create(proxy);
74+
var address = new InetSocketAddress(uri.getHost(), uri.getPort() == -1 ? 80 : uri.getPort());
75+
76+
builder.proxy(new Proxy(Proxy.Type.HTTP, address));
77+
}
6578

6679
if (orkesClientProperties.getKeyId() != null) {
6780
builder.credentials(orkesClientProperties.getKeyId(), orkesClientProperties.getSecret());

0 commit comments

Comments
 (0)