io.pivotal.services.plugin.tasks.helper.CfRenameAppDelegate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ya-cf-app-gradle-plugin Show documentation
Show all versions of ya-cf-app-gradle-plugin Show documentation
Gradle Plugin to push an application to Cloud Foundry
package io.pivotal.services.plugin.tasks.helper;
import io.pivotal.services.plugin.CfProperties;
import org.cloudfoundry.operations.CloudFoundryOperations;
import org.cloudfoundry.operations.applications.RenameApplicationRequest;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import reactor.core.publisher.Mono;
/**
* Responsible for renaming an app. Since this functionality is going to be called from a few places this logic has been
* centralized here.
*
* @author Biju Kunjummen
*/
public class CfRenameAppDelegate {
private static final Logger LOGGER = Logging.getLogger(CfRenameAppDelegate.class);
public Mono renameApp(CloudFoundryOperations cfOperations,
CfProperties cfOldAppProperties, CfProperties cfNewProperties) {
if (cfNewProperties.name() == null) {
throw new RuntimeException("New name not provided");
}
return cfOperations.applications().rename(RenameApplicationRequest
.builder()
.name(cfOldAppProperties.name())
.newName(cfNewProperties.name())
.build()).doOnSubscribe((s) -> {
LOGGER.lifecycle("Renaming app from {} to {}", cfOldAppProperties.name(), cfNewProperties.name());
});
}
}