use of com.google.cloud.tools.appengine.cloudsdk.process.ProcessStartListener in project google-cloud-intellij by GoogleCloudPlatform.
the class AppEngineDeploy method deploy.
/**
* Given a staging directory, deploy the application to Google App Engine.
*/
// TODO(eshaul) break this down into smaller parts
public void deploy(@NotNull Path stagingDirectory, @NotNull ProcessStartListener deployStartListener) {
final StringBuilder rawDeployOutput = new StringBuilder();
DefaultDeployConfiguration configuration = new DefaultDeployConfiguration();
String appYamlName;
if (environment.isStandard() || environment.isFlexCompat()) {
appYamlName = FlexibleFacetEditor.APP_YAML_FILE_NAME;
} else {
String moduleName = deploymentConfiguration.getModuleName();
if (StringUtils.isEmpty(moduleName)) {
callback.errorOccurred(GctBundle.message("appengine.deployment.error.appyaml.notspecified"));
return;
}
AppEngineFlexibleFacet flexFacet = AppEngineFlexibleFacet.getFacetByModuleName(moduleName, helper.getProject());
if (flexFacet == null) {
// This should not happen since staging already verified the file
callback.errorOccurred(GctBundle.message("appengine.deployment.error.appyaml.notfound"));
return;
} else {
appYamlName = Paths.get(flexFacet.getConfiguration().getAppYamlPath()).getFileName().toString();
}
}
List<File> deployables = APPENGINE_EXTRA_CONFIG_FILE_PATHS.stream().map(configFilePath -> stagingDirectory.resolve(configFilePath).toFile()).filter(configFile -> deploymentConfiguration.isDeployAllConfigs() && configFile.exists()).collect(Collectors.toList());
deployables.add(stagingDirectory.resolve(appYamlName).toFile());
configuration.setDeployables(deployables);
configuration.setProject(deploymentConfiguration.getCloudProjectName());
configuration.setPromote(deploymentConfiguration.isPromote());
// promoting).
if ((environment.isFlexible() || environment.isFlexCompat()) && deploymentConfiguration.isPromote()) {
configuration.setStopPreviousVersion(deploymentConfiguration.isStopPreviousVersion());
}
if (!StringUtil.isEmpty(deploymentConfiguration.getVersion())) {
configuration.setVersion(deploymentConfiguration.getVersion());
}
ProcessExitListener deployExitListener = new DeployExitListener(rawDeployOutput);
CloudSdk sdk = helper.createSdk(loggingHandler, deployStartListener, line -> loggingHandler.print(line + "\n"), rawDeployOutput::append, deployExitListener);
// show a warning notification if the cloud sdk version is not supported
CloudSdkVersionNotifier.getInstance().notifyIfUnsupportedVersion();
CloudSdkAppEngineDeployment deployment = new CloudSdkAppEngineDeployment(sdk);
deployment.deploy(configuration);
}
Aggregations