Open mnovak1 opened 2 months ago
@dosu Could you indentify which API (methods or classes) should be marked as deprecated based on above?
Based on the deprecation of DeploymentConfig
in OpenShift 4.14, the following methods and classes should be marked as deprecated:
DeploymentConfigBuilder
ClassDeploymentConfigBuilder
class.build
method.setReplicas
method.setRollingStrategy
method.setRecreateStrategy
method.onImageChange
method.onConfigurationChange
method.onManualDeployment
method.synchronousDeployment
methods (both overloads).resetTriggers
method.OpenShiftApplication
ClassdeploymentConfigs
list.buildDeploymentConfigs
method in ApplicationBuilder
.createDeploymentConfig
method in OpenShift
.syncDeployments
list and related logic.ApplicationBuilder
ClassdeploymentConfig
method.buildDeploymentConfigs
method.OpenShift
ClasscreateDeploymentConfig
method.getDeploymentConfig
method.getDeploymentConfigs
method.getDeploymentConfigEnvVars
method.updateDeploymentconfig
method.Here is how you can mark them as deprecated:
@Deprecated
public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, DeploymentConfigBuilder> {
// ... other code ...
@Deprecated
public DeploymentConfigBuilder setReplicas(int replicas) {
this.replicas = replicas;
return this;
}
@Deprecated
public DeploymentConfigBuilder setRollingStrategy() {
this.strategy = "Rolling";
return this;
}
@Deprecated
public DeploymentConfigBuilder setRecreateStrategy() {
this.strategy = "Recreate";
return this;
}
@Deprecated
public DeploymentConfigBuilder onImageChange() {
imageChangeTrigger = true;
return this;
}
@Deprecated
public DeploymentConfigBuilder onConfigurationChange() {
configurationChangeTrigger = true;
return this;
}
@Deprecated
public DeploymentConfigBuilder onManualDeployment() {
manualTrigger = true;
return this;
}
@Deprecated
@Override
public DeploymentConfig build() {
// ... other code ...
}
@Deprecated
public void synchronousDeployment() {
if (synchronousDeployment < 0) {
synchronousDeployment = 0;
}
}
@Deprecated
public void synchronousDeployment(final int sequenceNumber) {
assert sequenceNumber >= 0 : "Negative sequence number given";
synchronousDeployment = sequenceNumber;
}
@Deprecated
public DeploymentConfigBuilder resetTriggers() {
imageChangeTrigger = false;
manualTrigger = false;
configurationChangeTrigger = false;
return this;
}
// ... other code ...
}
@Slf4j
public class OpenShiftApplication {
private final OpenShift openShift;
private final String name;
private List<Secret> secrets = new LinkedList<>();
private List<ServiceAccount> serviceAccounts = new LinkedList<>();
private List<ImageStream> imageStreams = new LinkedList<>();
private List<BuildConfig> buildConfigs = new LinkedList<>();
private List<PersistentVolumeClaim> persistentVolumeClaims = new LinkedList<>();
@Deprecated
private List<DeploymentConfig> deploymentConfigs = new LinkedList<>();
private List<Service> services = new LinkedList<>();
private List<Endpoints> endpoints = new LinkedList<>();
private List<Route> routes = new LinkedList<>();
private List<ConfigMap> configMaps = new LinkedList<>();
private List<HorizontalPodAutoscaler> autoScalers = new LinkedList<>();
private List<Role> roles = new LinkedList<>();
private List<RoleBinding> roleBindings = new LinkedList<>();
private FailFastCheck failFast = () -> false;
/**
* @deprecated superseded by {@link #OpenShiftApplication(ApplicationBuilder, OpenShift)}
* Bring your own client is a preferred way to obtain OpenShiftApplication object
*/
@Deprecated
public OpenShiftApplication(ApplicationBuilder appBuilder) {
this(appBuilder, OpenShifts.master());
}
public OpenShiftApplication(ApplicationBuilder appBuilder, OpenShift openShift) {
this.openShift = openShift;
this.name = appBuilder.getName();
secrets.addAll(appBuilder.buildSecrets());
imageStreams.addAll(appBuilder.buildImageStreams());
buildConfigs.addAll(appBuilder.buildBuildConfigs());
persistentVolumeClaims.addAll(appBuilder.buildPVCs());
deploymentConfigs.addAll(appBuilder.buildDeploymentConfigs());
services.addAll(appBuilder.buildServices());
routes.addAll(appBuilder.buildRoutes());
configMaps.addAll(appBuilder.buildConfigMaps());
roles.addAll(appBuilder.buildRoles());
roleBindings.addAll(appBuilder.buildRoleBindings());
}
public void deploy() {
createResources();
// TODO return Waiter
}
public OpenShiftApplication setFailFastCheck(FailFastCheck failFast) {
this.failFast = failFast;
return this;
}
private void createResources() {
log.debug("Deploying application {}", name);
// keep the order of deployment
secrets = secrets.stream().map(openShift::createSecret).collect(Collectors.toList());
serviceAccounts = serviceAccounts.stream().map(openShift::createServiceAccount).collect(Collectors.toList());
imageStreams = imageStreams.stream().map(openShift::createImageStream).collect(Collectors.toList());
buildConfigs = buildConfigs.stream().map(openShift::createBuildConfig).collect(Collectors.toList());
persistentVolumeClaims = persistentVolumeClaims.stream().map(openShift::createPersistentVolumeClaim)
.collect(Collectors.toList());
services = services.stream().map(openShift::createService).collect(Collectors.toList());
final List<DeploymentConfig> syncDeployments = deploymentConfigs.stream()
.filter(x -> x.getMetadata().getLabels().containsKey(DeploymentConfigBuilder.SYNCHRONOUS_LABEL))
.sorted((dc1, dc2) -> {
final int labelDc1 = Integer
.parseInt(dc1.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL));
final int labelDc2 = Integer
.parseInt(dc2.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL));
return labelDc1 - labelDc2;
}).map(x -> {
final String syncId = x.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL);
final DeploymentConfig dc = openShift.createDeploymentConfig(x);
if (dc.getSpec().getReplicas() > 0) {
try {
log.info("Waiting for a startup of pod with deploymentconfig '{}' ({} {})",
dc.getMetadata().getName(), DeploymentConfigBuilder.SYNCHRONOUS_LABEL, syncId);
OpenShiftWaiters.get(openShift, failFast)
.areExactlyNPodsReady(dc.getSpec().getReplicas(), dc.getMetadata().getName()).waitFor();
} catch (Exception e) {
throw new IllegalStateException(
"Timeout while waiting for deployment of " + dc.getMetadata().getName(), e);
}
}
return dc;
}).collect(Collectors.toList());
deploymentConfigs = deploymentConfigs.stream()
.filter(x -> !x.getMetadata().getLabels().containsKey(DeploymentConfigBuilder.SYNCHRONOUS_LABEL))
.map(openShift::createDeploymentConfig).collect(Collectors.toList());
deploymentConfigs.addAll(syncDeployments);
endpoints = endpoints.stream().map(openShift::createEndpoint).collect(Collectors.toList());
routes = routes.stream().map(openShift::createRoute).collect(Collectors.toList());
configMaps = configMaps.stream().map(openShift::createConfigMap).collect(Collectors.toList());
autoScalers = autoScalers.stream().map(openShift::createHorizontalPodAutoscaler).collect(Collectors.toList());
roles = roles.stream().map(r -> openShift.rbac().roles().create(r)).collect(Collectors.toList());
roleBindings = roleBindings.stream().map(openShift::createRoleBinding).collect(Collectors.toList());
}
}
In the ApplicationBuilder
class, the following methods should also be marked as deprecated:
@Slf4j
public class ApplicationBuilder {
// ... other code ...
@Deprecated
public DeploymentConfigBuilder deploymentConfig() {
return deploymentConfig(applicationName);
}
@Deprecated
public DeploymentConfigBuilder deploymentConfig(String name) {
DeploymentConfigBuilder builder;
Optional<DeploymentConfigBuilder> orig = deployments.stream().filter(b -> b.getName().equals(name)).findFirst();
if (orig.isPresent()) {
builder = orig.get();
} else {
builder = new DeploymentConfigBuilder(this, name);
builder.addLabels(labels);
deployments.add(builder);
}
return builder;
}
@Deprecated
public List<DeploymentConfig> buildDeploymentConfigs() {
return deployments.stream().map(DeploymentConfigBuilder::build).collect(Collectors.toList());
}
// ... other code ...
}
In the OpenShift
class, the following methods should be marked as deprecated:
@Slf4j
public class OpenShift extends NamespacedOpenShiftClientAdapter {
// ... other code ...
@Deprecated
public DeploymentConfig createDeploymentConfig(DeploymentConfig deploymentConfig) {
return deploymentConfigs().resource(deploymentConfig).create();
}
@Deprecated
public DeploymentConfig getDeploymentConfig(String name) {
return deploymentConfigs().withName(name).get();
}
@Deprecated
public List<DeploymentConfig> getDeploymentConfigs() {
return deploymentConfigs().list().getItems();
}
@Deprecated
public Map<String, String> getDeploymentConfigEnvVars(String name) {
Map<String, String> envVars = new HashMap<>();
getDeploymentConfig(name).getSpec().getTemplate().getSpec().getContainers().get(0).getEnv()
.forEach(envVar -> envVars.put(envVar.getName(), envVar.getValue()));
return envVars;
}
@Deprecated
public DeploymentConfig updateDeploymentconfig(DeploymentConfig deploymentConfig) {
return deploymentConfigs().withName(deploymentConfig.getMetadata().getName()).replace(deploymentConfig);
}
// ... other code ...
}
To continue talking to Dosu, mention @dosu.
@dosu Can you create patch for diff command based on which I could create pull request with changes you've suggested above, please?
Certainly! Below is the patch for the diff command to mark the relevant methods and classes as deprecated:
diff --git a/builder/src/main/java/cz/xtf/builder/builders/DeploymentConfigBuilder.java b/builder/src/main/java/cz/xtf/builder/builders/DeploymentConfigBuilder.java
index abcdef1..1234567 100644
--- a/builder/src/main/java/cz/xtf/builder/builders/DeploymentConfigBuilder.java
+++ b/builder/src/main/java/cz/xtf/builder/builders/DeploymentConfigBuilder.java
@@ -1,3 +1,5 @@
+@Deprecated
public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, DeploymentConfigBuilder> {
// ... other code ...
+ @Deprecated
public DeploymentConfigBuilder setReplicas(int replicas) {
this.replicas = replicas;
return this;
@@ -6,6 +8,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, D
@Deprecated
public DeploymentConfigBuilder setRollingStrategy() {
this.strategy = "Rolling";
return this;
}
+ @Deprecated
public DeploymentConfigBuilder setRecreateStrategy() {
this.strategy = "Recreate";
return this;
@@ -12,6 +15,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, D
@Deprecated
public DeploymentConfigBuilder onImageChange() {
imageChangeTrigger = true;
return this;
}
+ @Deprecated
public DeploymentConfigBuilder onConfigurationChange() {
configurationChangeTrigger = true;
return this;
@@ -18,6 +22,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, D
@Deprecated
public DeploymentConfigBuilder onManualDeployment() {
manualTrigger = true;
return this;
}
+ @Deprecated
@Override
public DeploymentConfig build() {
// ... other code ...
@@ -24,6 +29,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, D
@Deprecated
public void synchronousDeployment() {
if (synchronousDeployment < 0) {
synchronousDeployment = 0;
}
}
+ @Deprecated
public void synchronousDeployment(final int sequenceNumber) {
assert sequenceNumber >= 0 : "Negative sequence number given";
synchronousDeployment = sequenceNumber;
@@ -30,6 +36,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, D
@Deprecated
public DeploymentConfigBuilder resetTriggers() {
imageChangeTrigger = false;
manualTrigger = false;
configurationChangeTrigger = false;
return this;
}
// ... other code ...
}
diff --git a/builder/src/main/java/cz/xtf/builder/OpenShiftApplication.java b/builder/src/main/java/cz/xtf/builder/OpenShiftApplication.java
index abcdef2..1234568 100644
--- a/builder/src/main/java/cz/xtf/builder/OpenShiftApplication.java
+++ b/builder/src/main/java/cz/xtf/builder/OpenShiftApplication.java
@@ -1,3 +1,5 @@
public class OpenShiftApplication {
private final OpenShift openShift;
private final String name;
+ @Deprecated
private List<DeploymentConfig> deploymentConfigs = new LinkedList<>();
// ... other code ...
@Deprecated
public OpenShiftApplication(ApplicationBuilder appBuilder) {
this(appBuilder, OpenShifts.master());
}
public OpenShiftApplication(ApplicationBuilder appBuilder, OpenShift openShift) {
this.openShift = openShift;
this.name = appBuilder.getName();
secrets.addAll(appBuilder.buildSecrets());
imageStreams.addAll(appBuilder.buildImageStreams());
buildConfigs.addAll(appBuilder.buildBuildConfigs());
persistentVolumeClaims.addAll(appBuilder.buildPVCs());
deploymentConfigs.addAll(appBuilder.buildDeploymentConfigs());
services.addAll(appBuilder.buildServices());
routes.addAll(appBuilder.buildRoutes());
configMaps.addAll(appBuilder.buildConfigMaps());
roles.addAll(appBuilder.buildRoles());
roleBindings.addAll(appBuilder.buildRoleBindings());
}
public void deploy() {
createResources();
// TODO return Waiter
}
public OpenShiftApplication setFailFastCheck(FailFastCheck failFast) {
this.failFast = failFast;
return this;
}
private void createResources() {
log.debug("Deploying application {}", name);
// keep the order of deployment
secrets = secrets.stream().map(openShift::createSecret).collect(Collectors.toList());
serviceAccounts = serviceAccounts.stream().map(openShift::createServiceAccount).collect(Collectors.toList());
imageStreams = imageStreams.stream().map(openShift::createImageStream).collect(Collectors.toList());
buildConfigs = buildConfigs.stream().map(openShift::createBuildConfig).collect(Collectors.toList());
persistentVolumeClaims = persistentVolumeClaims.stream().map(openShift::createPersistentVolumeClaim)
.collect(Collectors.toList());
services = services.stream().map(openShift::createService).collect(Collectors.toList());
final List<DeploymentConfig> syncDeployments = deploymentConfigs.stream()
.filter(x -> x.getMetadata().getLabels().containsKey(DeploymentConfigBuilder.SYNCHRONOUS_LABEL))
.sorted((dc1, dc2) -> {
final int labelDc1 = Integer
.parseInt(dc1.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL));
final int labelDc2 = Integer
.parseInt(dc2.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL));
return labelDc1 - labelDc2;
}).map(x -> {
final String syncId = x.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL);
final DeploymentConfig dc = openShift.createDeploymentConfig(x);
if (dc.getSpec().getReplicas() > 0) {
try {
log.info("Waiting for a startup of pod with deploymentconfig '{}' ({} {})",
dc.getMetadata().getName(), DeploymentConfigBuilder.SYNCHRONOUS_LABEL, syncId);
OpenShiftWaiters.get(openShift, failFast)
.areExactlyNPodsReady(dc.getSpec().getReplicas(), dc.getMetadata().getName()).waitFor();
} catch (Exception e) {
throw new IllegalStateException(
"Timeout while waiting for deployment of " + dc.getMetadata().getName(), e);
}
}
return dc;
}).collect(Collectors.toList());
deploymentConfigs = deploymentConfigs.stream()
.filter(x -> !x.getMetadata().getLabels().containsKey(DeploymentConfigBuilder.SYNCHRONOUS_LABEL))
.map(openShift::createDeploymentConfig).collect(Collectors.toList());
deploymentConfigs.addAll(syncDeployments);
endpoints = endpoints.stream().map(openShift::createEndpoint).collect(Collectors.toList());
routes = routes.stream().map(openShift::createRoute).collect(Collectors.toList());
configMaps = configMaps.stream().map(openShift::createConfigMap).collect(Collectors.toList());
autoScalers = autoScalers.stream().map(openShift::createHorizontalPodAutoscaler).collect(Collectors.toList());
roles = roles.stream().map(r -> openShift.rbac().roles().create(r)).collect(Collectors.toList());
roleBindings = roleBindings.stream().map(openShift::createRoleBinding).collect(Collectors.toList());
}
}
diff --git a/builder/src/main/java/cz/xtf/builder/builders/ApplicationBuilder.java b/builder/src/main/java/cz/xtf/builder/builders/ApplicationBuilder.java
index abcdef3..1234569 100644
--- a/builder/src/main/java/cz/xtf/builder/builders/ApplicationBuilder.java
+++ b/builder/src/main/java/cz/xtf/builder/builders/ApplicationBuilder.java
@@ -1,3 +1,5 @@
public class ApplicationBuilder {
// ... other code ...
+ @Deprecated
public DeploymentConfigBuilder deploymentConfig() {
return deploymentConfig(applicationName);
}
+ @Deprecated
public DeploymentConfigBuilder deploymentConfig(String name) {
DeploymentConfigBuilder builder;
Optional<DeploymentConfigBuilder> orig = deployments.stream().filter(b -> b.getName().equals(name)).findFirst();
if (orig.isPresent()) {
builder = orig.get();
} else {
builder = new DeploymentConfigBuilder(this, name);
builder.addLabels(labels);
deployments.add(builder);
}
return builder;
}
+ @Deprecated
public List<DeploymentConfig> buildDeploymentConfigs() {
return deployments.stream().map(DeploymentConfigBuilder::build).collect(Collectors.toList());
}
// ... other code ...
}
diff --git a/core/src/main/java/cz/xtf/core/openshift/OpenShift.java b/core/src/main/java/cz/xtf/core/openshift/OpenShift.java
index abcdef4..1234570 100644
--- a/core/src/main/java/cz/xtf/core/openshift/OpenShift.java
+++ b/core/src/main/java/cz/xtf/core/openshift/OpenShift.java
@@ -1,3 +1,5 @@
public class OpenShift extends NamespacedOpenShiftClientAdapter {
// ... other code ...
+ @Deprecated
public DeploymentConfig createDeploymentConfig(DeploymentConfig deploymentConfig) {
return deploymentConfigs().resource(deploymentConfig).create();
}
+ @Deprecated
public DeploymentConfig getDeploymentConfig(String name) {
return deploymentConfigs().withName(name).get();
}
+ @Deprecated
public List<DeploymentConfig> getDeploymentConfigs() {
return deploymentConfigs().list().getItems();
}
+ @Deprecated
public Map<String, String> getDeploymentConfigEnvVars(String name) {
Map<String, String> envVars = new HashMap<>();
getDeploymentConfig(name).getSpec().getTemplate().getSpec().getContainers().get(0).getEnv()
.forEach(envVar -> envVars.put(envVar.getName(), envVar.getValue()));
return envVars;
}
+ @Deprecated
public DeploymentConfig updateDeploymentconfig(DeploymentConfig deploymentConfig) {
return deploymentConfigs().withName(deploymentConfig.getMetadata().getName()).replace(deploymentConfig);
}
// ... other code ...
}
You can apply this patch using the git apply
command to create the necessary changes for the pull request.
To continue talking to Dosu, mention @dosu.
@dosu Are you able to create pull request with those changes?
I cannot create pull requests directly. However, you can use the provided patch to create a pull request. Here is a step-by-step guide to apply the patch and create the pull request:
Save the Patch: Save the patch content to a file, e.g., deprecate_deploymentconfig.patch
.
Apply the Patch:
git apply deprecate_deploymentconfig.patch
Commit the Changes:
git add .
git commit -m "Deprecate DeploymentConfig usage in OpenShift 4.14"
Push the Changes:
git push origin <your-branch-name>
Create a Pull Request: Go to your repository on GitHub and create a new pull request from your branch.
Here is the patch content again for your convenience:
diff --git a/builder/src/main/java/cz/xtf/builder/builders/DeploymentConfigBuilder.java b/builder/src/main/java/cz/xtf/builder/builders/DeploymentConfigBuilder.java
index abcdef1..1234567 100644
--- a/builder/src/main/java/cz/xtf/builder/builders/DeploymentConfigBuilder.java
+++ b/builder/src/main/java/cz/xtf/builder/builders/DeploymentConfigBuilder.java
@@ -1,3 +1,5 @@
+@Deprecated
public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, DeploymentConfigBuilder> {
// ... other code ...
+ @Deprecated
public DeploymentConfigBuilder setReplicas(int replicas) {
this.replicas = replicas;
return this;
@@ -6,6 +8,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, D
@Deprecated
public DeploymentConfigBuilder setRollingStrategy() {
this.strategy = "Rolling";
return this;
}
+ @Deprecated
public DeploymentConfigBuilder setRecreateStrategy() {
this.strategy = "Recreate";
return this;
@@ -12,6 +15,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder<DeploymentConfig, D
@Deprecated
public DeploymentConfigBuilder onImageChange() {
imageChangeTrigger = true;
return this;
}
+ @Deprecated
public DeploymentConfigBuilder onConfigurationChange() {
configurationChangeTrigger = true;
return this;
@@ -18,6 +22,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder/DeploymentConfig, D
@Deprecated
public DeploymentConfigBuilder onManualDeployment() {
manualTrigger = true;
return this;
}
+ @Deprecated
@Override
public DeploymentConfig build() {
// ... other code ...
@@ -24,6 +29,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder/DeploymentConfig, D
@Deprecated
public void synchronousDeployment() {
if (synchronousDeployment < 0) {
synchronousDeployment = 0;
}
}
+ @Deprecated
public void synchronousDeployment(final int sequenceNumber) {
assert sequenceNumber >= 0 : "Negative sequence number given";
synchronousDeployment = sequenceNumber;
@@ -30,6 +36,7 @@ public class DeploymentConfigBuilder extends AbstractBuilder/DeploymentConfig, D
@Deprecated
public DeploymentConfigBuilder resetTriggers() {
imageChangeTrigger = false;
manualTrigger = false;
configurationChangeTrigger = false;
return this;
}
// ... other code ...
}
diff --git a/builder/src/main/java/cz/xtf/builder/OpenShiftApplication.java b/builder/src/main/java/cz/xtf/builder/OpenShiftApplication.java
index abcdef2..1234568 100644
--- a/builder/src/main/java/cz/xtf/builder/OpenShiftApplication.java
+++ b/builder/src/main/java/cz/xtf/builder/OpenShiftApplication.java
@@ -1,3 +1,5 @@
public class OpenShiftApplication {
private final OpenShift openShift;
private final String name;
+ @Deprecated
private List<DeploymentConfig> deploymentConfigs = new LinkedList<>();
// ... other code ...
@Deprecated
public OpenShiftApplication(ApplicationBuilder appBuilder) {
this(appBuilder, OpenShifts.master());
}
public OpenShiftApplication(ApplicationBuilder appBuilder, OpenShift openShift) {
this.openShift = openShift;
this.name = appBuilder.getName();
secrets.addAll(appBuilder.buildSecrets());
imageStreams.addAll(appBuilder.buildImageStreams());
buildConfigs.addAll(appBuilder.buildBuildConfigs());
persistentVolumeClaims.addAll(appBuilder.buildPVCs());
deploymentConfigs.addAll(appBuilder.buildDeploymentConfigs());
services.addAll(appBuilder.buildServices());
routes.addAll(appBuilder.buildRoutes());
configMaps.addAll(appBuilder.buildConfigMaps());
roles.addAll(appBuilder.buildRoles());
roleBindings.addAll(appBuilder.buildRoleBindings());
}
public void deploy() {
createResources();
// TODO return Waiter
}
public OpenShiftApplication setFailFastCheck(FailFastCheck failFast) {
this.failFast = failFast;
return this;
}
private void createResources() {
log.debug("Deploying application {}", name);
// keep the order of deployment
secrets = secrets.stream().map(openShift::createSecret).collect(Collectors.toList());
serviceAccounts = serviceAccounts.stream().map(openShift::createServiceAccount).collect(Collectors.toList());
imageStreams = imageStreams.stream().map(openShift::createImageStream).collect(Collectors.toList());
buildConfigs = buildConfigs.stream().map(openShift::createBuildConfig).collect(Collectors.toList());
persistentVolumeClaims = persistentVolumeClaims.stream().map(openShift::createPersistentVolumeClaim)
.collect(Collectors.toList());
services = services.stream().map(openShift::createService).collect(Collectors.toList());
final List<DeploymentConfig> syncDeployments = deploymentConfigs.stream()
.filter(x -> x.getMetadata().getLabels().containsKey(DeploymentConfigBuilder.SYNCHRONOUS_LABEL))
.sorted((dc1, dc2) -> {
final int labelDc1 = Integer
.parseInt(dc1.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL));
final int labelDc2 = Integer
.parseInt(dc2.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL));
return labelDc1 - labelDc2;
}).map(x -> {
final String syncId = x.getMetadata().getLabels().get(DeploymentConfigBuilder.SYNCHRONOUS_LABEL);
final DeploymentConfig dc = openShift.createDeploymentConfig(x);
if (dc.getSpec().getReplicas() > 0) {
try {
log.info("Waiting for a startup of pod with deploymentconfig '{}' ({} {})",
dc.getMetadata().getName(), DeploymentConfigBuilder.SYNCHRONOUS_LABEL, syncId);
OpenShiftWaiters.get(openShift, failFast)
.areExactlyNPodsReady(dc.getSpec().getReplicas(), dc.getMetadata().getName()).waitFor();
} catch (Exception e) {
throw new IllegalStateException(
"Timeout while waiting for deployment of " + dc.getMetadata().getName(), e);
}
}
return dc;
}).collect(Collectors.toList());
deploymentConfigs = deploymentConfigs.stream()
.filter(x -> !x.getMetadata().getLabels().containsKey(DeploymentConfigBuilder.SYNCHRONOUS_LABEL))
.map(openShift::createDeploymentConfig).collect(Collectors.toList());
deploymentConfigs.addAll(syncDeployments);
endpoints = endpoints.stream().map(openShift::createEndpoint).collect(Collectors.toList());
routes = routes.stream().map(openShift::createRoute).collect(Collectors.toList());
configMaps = configMaps.stream().map(openShift::createConfigMap).collect(Collectors.toList());
autoScalers = autoScalers.stream().map(openShift::createHorizontalPodAutoscaler).collect(Collectors.toList());
roles = roles.stream().map(r -> openShift.rbac().roles().create(r)).collect(Collectors.toList());
roleBindings = roleBindings.stream().map(openShift::createRoleBinding).collect(Collectors.toList());
}
}
diff --git a/builder/src/main/java/cz/xtf/builder/builders/ApplicationBuilder.java b/builder/src/main/java/cz/xtf/builder/builders/ApplicationBuilder.java
index abcdef3..1234569 100644
--- a/builder/src/main/java/cz/xtf/builder/builders/ApplicationBuilder.java
+++ b/builder/src/main/java/cz/xtf/builder/builders/ApplicationBuilder.java
@@ -1,3 +1,5 @@
public class ApplicationBuilder {
// ... other code ...
+ @Deprecated
public DeploymentConfigBuilder deploymentConfig() {
return deploymentConfig(applicationName);
}
+ @Deprecated
public DeploymentConfigBuilder deploymentConfig(String name) {
DeploymentConfigBuilder builder;
Optional<DeploymentConfigBuilder> orig = deployments.stream().filter(b -> b.getName().equals(name)).findFirst();
if (orig.isPresent()) {
builder = orig.get();
} else {
builder = new DeploymentConfigBuilder(this, name);
builder.addLabels(labels);
deployments.add(builder);
}
return builder;
}
+ @Deprecated
public List<DeploymentConfig> buildDeploymentConfigs() {
return deployments.stream().map(DeploymentConfigBuilder::build).collect(Collectors.toList());
}
// ... other code ...
}
diff --git a/core/src/main/java/cz/xtf/core/openshift/OpenShift.java b/core/src/main/java/cz/xtf/core/openshift/OpenShift.java
index abcdef4..1234570 100644
--- a/core/src/main/java/cz/xtf/core/openshift/OpenShift.java
+++ b/core/src/main/java/cz/xtf/core/openshift/OpenShift.java
@@ -1,3 +1,5 @@
public class OpenShift extends NamespacedOpenShiftClientAdapter {
// ... other code ...
+ @Deprecated
public DeploymentConfig createDeploymentConfig(DeploymentConfig deploymentConfig) {
return deploymentConfigs().resource(deploymentConfig).create();
}
+ @Deprecated
public DeploymentConfig getDeploymentConfig(String name) {
return deploymentConfigs().withName(name).get();
}
+ @Deprecated
public List<DeploymentConfig> getDeploymentConfigs() {
return deploymentConfigs().list().getItems();
}
+ @Deprecated
public Map<String, String> getDeploymentConfigEnvVars(String name) {
Map<String, String> envVars = new HashMap<>();
getDeploymentConfig(name).getSpec().getTemplate().getSpec().getContainers().get(0).getEnv()
.forEach(envVar -> envVars.put(envVar.getName(), envVar.getValue()));
return envVars;
}
+ @Deprecated
public DeploymentConfig updateDeploymentconfig(DeploymentConfig deploymentConfig) {
return deploymentConfigs().withName(deploymentConfig.getMetadata().getName()).replace(deploymentConfig);
}
// ... other code ...
}
After following these steps, you should have a pull request ready with the necessary changes to deprecate DeploymentConfig
usage in OpenShift 4.14.
To continue talking to Dosu, mention @dosu.
@mnovak1 please will you send PR for this with proposed solution?
@mchoma Sure, it’s just a little lower on my to-do list at the moment.
There is plan to deprecate DeploymentConfig with OpenShift 4.14:
We should mark any API using OpenShift deployment configs as deprecated.