Skip to content

Commit

Permalink
Add ability to pass custom env vars to deployments through Session CR
Browse files Browse the repository at this point in the history
(#156)

* Remove monitor port workaround
  • Loading branch information
jfaltermeier committed Apr 24, 2023
1 parent 8c56d05 commit 6d6f339
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.ConfigMapEnvSource;
import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.ContainerPort;
import io.fabric8.kubernetes.api.model.EnvFromSource;
import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.LocalObjectReference;
Expand Down Expand Up @@ -241,23 +240,6 @@ public static void addImagePullSecret(Deployment deployment, String secret) {
imagePullSecrets.add(new LocalObjectReference(secret));
}

public static void removeMonitorPort(Deployment deployment, AppDefinition appDefinition) {
String containerName = appDefinition.getSpec().getName();

Optional<Integer> maybeContainerIdx = findContainerIdxInDeployment(deployment, containerName);
if (maybeContainerIdx.isEmpty()) {
LOGGER.error("Trying to remove monitor port in Deployment." + "Could not find the container "
+ containerName + " in Deployment named" + deployment.getMetadata().getName());
return;
}
int containerIdx = maybeContainerIdx.get();
Container container = deployment.getSpec().getTemplate().getSpec().getContainers().get(containerIdx);
List<ContainerPort> newContainerPorts = container.getPorts().stream()
.filter((p) -> !(p.getName().equals("monitor"))).collect(Collectors.toList());

deployment.getSpec().getTemplate().getSpec().getContainers().get(containerIdx).setPorts(newContainerPorts);
}

/* ------------------- Addition of env vars to Deployments ------------------ */
public static void addCustomEnvVarsToDeploymentFromSession(String correlationId, Deployment deployment,
Session session, AppDefinition appDefinition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,6 @@ protected void createAndApplyDeployment(String correlationId, String sessionReso
appDefinition.getSpec().getUplinkLimit(), correlationId);
AddedHandlerUtil.removeEmptyResources(deployment);

if (!arguments.isEnableMonitor()) {
AddedHandlerUtil.removeMonitorPort(deployment, appDefinition);
}

AddedHandlerUtil.addCustomEnvVarsToDeploymentFromSession(correlationId, deployment, session,
appDefinition);

Expand Down

0 comments on commit 6d6f339

Please sign in to comment.