Skip to content

Commit

Permalink
Update deprecated method in OpenShiftClient
Browse files Browse the repository at this point in the history
  • Loading branch information
jedla97 committed Jul 18, 2024
1 parent b951dda commit cf5775c
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable;
import io.fabric8.kubernetes.client.dsl.NonDeletingOperation;
import io.fabric8.kubernetes.client.dsl.PodResource;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.openshift.api.model.ImageStream;
Expand Down Expand Up @@ -222,7 +223,7 @@ public void applyServicePropertiesToDeployment(Service service) {
deployment.getSpec().getTemplate().getSpec().getContainers().forEach(container -> {
enrichProperties.forEach((key, value) -> container.getEnv().add(new EnvVar(key, value, null)));
});
client.apps().deployments().resource(deployment).createOrReplace();
client.apps().deployments().resource(deployment).unlock().createOr(NonDeletingOperation::update);
}

/**
Expand Down Expand Up @@ -502,8 +503,8 @@ public void installOperator(Service service, String name, String channel, String
groupModel.getMetadata().setName(service.getName());
groupModel.setSpec(new OperatorGroupSpec());
groupModel.getSpec().setTargetNamespaces(Arrays.asList(currentNamespace));
// call createOrReplace
client.resource(groupModel).createOrReplace();
// call createOr and if it exists the update will be done
client.resource(groupModel).unlock().createOr(NonDeletingOperation::update);

// Install the subscription
Subscription subscriptionModel = new Subscription();
Expand Down Expand Up @@ -771,8 +772,8 @@ private String enrichTemplate(Service service, String template, Map<String, Stri
list.setItems(objs);
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
Serialization.yamlMapper().writeValue(os, list);
template = new String(os.toByteArray());
os.write(Serialization.asYaml(list).getBytes());
template = os.toString();
} catch (IOException e) {
fail("Failed adding properties into OpenShift template. Caused by " + e.getMessage());
}
Expand Down Expand Up @@ -963,7 +964,7 @@ private void createOrUpdateConfigMap(String configMapName, String key, String va
} else {
// create new one
configMaps.resource(new ConfigMapBuilder().withNewMetadata().withName(configMapName).endMetadata()
.addToData(key, value).build()).createOrReplace();
.addToData(key, value).build()).unlock().createOr(NonDeletingOperation::update);
}
}

Expand Down

0 comments on commit cf5775c

Please sign in to comment.