Skip to content

Commit

Permalink
feat: get correct base url
Browse files Browse the repository at this point in the history
(cherry picked from commit 6812c53)
  • Loading branch information
1nb0und committed Dec 18, 2023
1 parent 3f830e4 commit 8a82427
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.lang.invoke.MethodHandles;
import java.util.Objects;

/**
* This will be deprecated once we move to the new schema (i.e. not prefixing with camunda.*)
Expand Down Expand Up @@ -117,22 +118,23 @@ public void setAuthUrl(String authUrl) {
this.authUrl = authUrl;
}

private String operateCloudBaseUrl = "operate.camunda.io";


public String getOperateUrl() {
if (url != null) {
LOG.debug("Connecting to Camunda Operate on URL: " +url);
return url;
} else if (clusterId != null) {
String url = "https://" + region + "." + operateCloudBaseUrl + "/" + clusterId + "/";
String url = "https://" + region + "." + getFinalBaseUrl() + "/" + clusterId + "/";
LOG.debug("Connecting to Camunda Operate SaaS via URL: " + url);
return url;
}
throw new IllegalArgumentException(
"In order to connect to Camunda Operate you need to specify either a SaaS clusterId or an Operate URL.");
}

private String getFinalBaseUrl() {
return Objects.requireNonNullElse(baseUrl, "operate.camunda.io");
}

@PostConstruct
private void applyFinalValues() {
if (this.getClientId() != null && this.getClientSecret() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.lang.invoke.MethodHandles;
import java.util.Objects;

@ConfigurationProperties(prefix = "operate.client")
public class OperateClientConfigurationProperties extends Client {
Expand All @@ -30,14 +31,18 @@ public String getOperateUrl() {
LOG.debug("Connecting to Camunda Operate on URL: " + getUrl());
return getUrl();
} else if (clusterId != null) {
String url = "https://" + region + "." + operateCloudBaseUrl + "/" + clusterId + "/";
String url = "https://" + region + "." + getFinalBaseUrl() + "/" + clusterId + "/";
LOG.debug("Connecting to Camunda Operate SaaS via URL: " + url);
return url;
}
throw new IllegalArgumentException(
"In order to connect to Camunda Operate you need to specify either a SaaS clusterId or an Operate URL.");
}

private String getFinalBaseUrl() {
return Objects.requireNonNullElse(getBaseUrl(), "operate.camunda.io");
}

@PostConstruct
private void applyFinalValues() {
if (this.getClientId() != null && this.getClientSecret() != null) {
Expand Down

0 comments on commit 8a82427

Please sign in to comment.