Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ public enum BandwidthLimiter {
"--sessionsPerUser" }, description = "Number of active sessions a single user is allowed to start.", required = false)
private Integer sessionsPerUser;

@Option(names = { "--serviceAuthToken" }, description = "Service authentication token necessary for service calls", required = false)
@Option(names = {
"--serviceAuthToken" }, description = "Service authentication token necessary for service calls", required = false)
private String serviceAuthToken;

@Option(names = { "--appId" }, description = "(Deprecated) Use --serviceAuthToken instead. Application ID necessary for service calls", required = false, hidden = true)

@Option(names = {
"--appId" }, description = "(Deprecated) Use --serviceAuthToken instead. Application ID necessary for service calls", required = false, hidden = true)
private String appId;

@Option(names = {
Expand Down Expand Up @@ -141,11 +143,16 @@ public enum BandwidthLimiter {
"--enableBuildCachePush" }, description = "Whether sessions are allowed to push to the build cache.", required = false)
private boolean enableBuildCachePush = false;

@Option(names = {
"--buildCacheSecretName" }, description = "Name of the Kubernetes Secret containing build cache username and password.", required = false)
private String buildCacheSecretName;

@Option(names = {
"--enableDependencyCaching" }, description = "Whether to enable the dependency cache (Reposilite).", required = false)
private boolean enableDependencyCaching = false;

@Option(names = { "--dependencyCacheUrl" }, description = "The URL of the dependency cache server (Reposilite).", required = false)
@Option(names = {
"--dependencyCacheUrl" }, description = "The URL of the dependency cache server (Reposilite).", required = false)
private String dependencyCacheUrl;

public boolean isUseKeycloak() {
Expand Down Expand Up @@ -194,7 +201,7 @@ public Integer getMonitorInterval() {
public String getServiceAuthToken() {
return getServiceAuthTokenWithFallback();
}

/**
* @deprecated Use {@link #getServiceAuthToken()} instead. This method is maintained for backwards compatibility.
* @return the configured service auth token
Expand Down Expand Up @@ -251,12 +258,11 @@ public int getLeaderRetryPeriod() {
public long getMaxWatchIdleTime() {
return maxWatchIdleTime;
}

/**
* Gets the number of threads to use for session event handling.
*
* If a specific thread count is configured and greater than zero, returns that value.
* Otherwise, calculates a default based on the number of available CPU cores,
* with a formula of (cores * 2) bounded within the range [4, 32].
* Gets the number of threads to use for session event handling. If a specific thread count is configured and
* greater than zero, returns that value. Otherwise, calculates a default based on the number of available CPU
* cores, with a formula of (cores * 2) bounded within the range [4, 32].
*
* @return the number of session handler threads
*/
Expand All @@ -277,36 +283,34 @@ public boolean isContinueOnException() {
public String getOAuth2ProxyVersion() {
return oAuth2ProxyVersion;
}

/**
* Get the service auth token with fallback to deprecated app id argument.
* Logs a deprecation warning if the old argument is used.
* Get the service auth token with fallback to deprecated app id argument. Logs a deprecation warning if the old
* argument is used.
*/
private String getServiceAuthTokenWithFallback() {
if (serviceAuthToken != null) {
return serviceAuthToken;
}

if (appId != null) {
Logger logger = Logger.getLogger(TheiaCloudOperatorArguments.class.getName());
logger.warning("Using deprecated command line argument '--appId'. " +
"Please migrate to '--serviceAuthToken' in your configuration.");
logger.warning("Using deprecated command line argument '--appId'. "
+ "Please migrate to '--serviceAuthToken' in your configuration.");
return appId;
}

return null;
}

/**
* Validates that required argument combinations are satisfied.
* Must be called after argument parsing.
* Validates that required argument combinations are satisfied. Must be called after argument parsing.
*
* @throws IllegalArgumentException if a caching flag is enabled but its URL is missing
*/
public void validate() {
if (enableBuildCaching && (buildCacheUrl == null || buildCacheUrl.trim().isEmpty())) {
throw new IllegalArgumentException(
"--buildCacheUrl is required when --enableBuildCaching is set");
throw new IllegalArgumentException("--buildCacheUrl is required when --enableBuildCaching is set");
}
if (enableDependencyCaching && (dependencyCacheUrl == null || dependencyCacheUrl.trim().isEmpty())) {
throw new IllegalArgumentException(
Expand All @@ -326,6 +330,10 @@ public boolean isEnableBuildCachePush() {
return enableBuildCachePush;
}

public String getBuildCacheSecretName() {
return buildCacheSecretName;
}

public boolean isEnableDependencyCaching() {
return enableDependencyCaching;
}
Expand Down Expand Up @@ -368,6 +376,7 @@ public int hashCode() {
result = prime * result + (enableBuildCaching ? 1231 : 1237);
result = prime * result + ((buildCacheUrl == null) ? 0 : buildCacheUrl.hashCode());
result = prime * result + (enableBuildCachePush ? 1231 : 1237);
result = prime * result + ((buildCacheSecretName == null) ? 0 : buildCacheSecretName.hashCode());
result = prime * result + (enableDependencyCaching ? 1231 : 1237);
result = prime * result + ((dependencyCacheUrl == null) ? 0 : dependencyCacheUrl.hashCode());
return result;
Expand Down Expand Up @@ -490,6 +499,11 @@ public boolean equals(Object obj) {
return false;
if (enableBuildCachePush != other.enableBuildCachePush)
return false;
if (buildCacheSecretName == null) {
if (other.buildCacheSecretName != null)
return false;
} else if (!buildCacheSecretName.equals(other.buildCacheSecretName))
return false;
if (enableDependencyCaching != other.enableDependencyCaching)
return false;
if (dependencyCacheUrl == null) {
Expand All @@ -513,10 +527,10 @@ public String toString() {
+ ", keycloakClientId=" + keycloakClientId + ", leaderLeaseDuration=" + leaderLeaseDuration
+ ", leaderRenewDeadline=" + leaderRenewDeadline + ", leaderRetryPeriod=" + leaderRetryPeriod
+ ", maxWatchIdleTime=" + maxWatchIdleTime + ", continueOnException=" + continueOnException
+ ", oAuth2ProxyVersion=" + oAuth2ProxyVersion + ", enableBuildCaching=" + enableBuildCaching + ", buildCacheUrl="
+ buildCacheUrl + ", enableBuildCachePush=" + enableBuildCachePush
+ ", enableDependencyCaching=" + enableDependencyCaching + ", dependencyCacheUrl="
+ dependencyCacheUrl + "]";
+ ", oAuth2ProxyVersion=" + oAuth2ProxyVersion + ", enableBuildCaching=" + enableBuildCaching
+ ", buildCacheUrl=" + buildCacheUrl + ", enableBuildCachePush=" + enableBuildCachePush
+ ", buildCacheSecretName=" + buildCacheSecretName + ", enableDependencyCaching="
+ enableDependencyCaching + ", dependencyCacheUrl=" + dependencyCacheUrl + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class DefaultDeploymentTemplateReplacements implements DeploymentTemplate
public static final String PLACEHOLDER_ENV_BUILD_CACHE_ENABLED = "placeholder-build-cache-enabled";
public static final String PLACEHOLDER_ENV_BUILD_CACHE_URL = "placeholder-build-cache-url";
public static final String PLACEHOLDER_ENV_BUILD_CACHE_PUSH = "placeholder-build-cache-push";
public static final String PLACEHOLDER_BUILD_CACHE_SECRET_NAME = "placeholder-build-cache-secret-name";

public static final String PLACEHOLDER_ENV_DEPENDENCY_CACHE_ENABLED = "placeholder-dependency-cache-enabled";
public static final String PLACEHOLDER_ENV_DEPENDENCY_CACHE_URL = "placeholder-dependency-cache-url";
Expand Down Expand Up @@ -168,17 +169,23 @@ protected Map<String, String> getEnvironmentVariables(AppDefinition appDefinitio
environmentVariables.put(PLACEHOLDER_ENV_BUILD_CACHE_URL, arguments.getBuildCacheUrl().trim());
environmentVariables.put(PLACEHOLDER_ENV_BUILD_CACHE_PUSH,
arguments.isEnableBuildCachePush() ? "true" : "false");

String secretName = (arguments.getBuildCacheSecretName() != null
&& !arguments.getBuildCacheSecretName().trim().isEmpty())
? arguments.getBuildCacheSecretName().trim()
: "theia-cloud-no-cache-secret";
environmentVariables.put(PLACEHOLDER_BUILD_CACHE_SECRET_NAME, secretName);
} else {
environmentVariables.put(PLACEHOLDER_ENV_BUILD_CACHE_ENABLED, "false");
environmentVariables.put(PLACEHOLDER_ENV_BUILD_CACHE_URL, "");
environmentVariables.put(PLACEHOLDER_ENV_BUILD_CACHE_PUSH, "false");
environmentVariables.put(PLACEHOLDER_BUILD_CACHE_SECRET_NAME, "theia-cloud-no-cache-secret");
}

if (arguments.isEnableDependencyCaching() && arguments.getDependencyCacheUrl() != null
&& !arguments.getDependencyCacheUrl().trim().isEmpty()) {
environmentVariables.put(PLACEHOLDER_ENV_DEPENDENCY_CACHE_ENABLED, "true");
environmentVariables.put(PLACEHOLDER_ENV_DEPENDENCY_CACHE_URL,
arguments.getDependencyCacheUrl().trim());
environmentVariables.put(PLACEHOLDER_ENV_DEPENDENCY_CACHE_URL, arguments.getDependencyCacheUrl().trim());
} else {
environmentVariables.put(PLACEHOLDER_ENV_DEPENDENCY_CACHE_ENABLED, "false");
environmentVariables.put(PLACEHOLDER_ENV_DEPENDENCY_CACHE_URL, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ spec:
value: placeholder-build-cache-url
- name: BUILD_CACHE_PUSH
value: placeholder-build-cache-push
- name: BUILD_CACHE_USERNAME
valueFrom:
secretKeyRef:
name: placeholder-build-cache-secret-name
key: username
optional: true
- name: BUILD_CACHE_PASSWORD
valueFrom:
secretKeyRef:
name: placeholder-build-cache-secret-name
key: password
optional: true
- name: DEPENDENCY_CACHE_ENABLED
value: placeholder-dependency-cache-enabled
- name: DEPENDENCY_CACHE_URL
Expand Down
Loading