Search in sources :

Example 1 with FlexibleRuntime

use of com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService.FlexibleRuntime in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfiguration method checkFlexConfig.

/**
 * Checks that this configuration is valid for a flex deployment, otherwise throws a {@link
 * RuntimeConfigurationError}.
 *
 * @param deployable the {@link AppEngineDeployable deployment source} that was selected by the
 *     user to deploy
 * @param project the {@link Project} that this configuration belongs to
 * @throws RuntimeConfigurationError if this configuration is not valid for a flex deployment
 */
private void checkFlexConfig(AppEngineDeployable deployable, Project project) throws RuntimeConfigurationError {
    check(!(deployable instanceof UserSpecifiedPathDeploymentSource) || (!StringUtil.isEmpty(userSpecifiedArtifactPath) && isJarOrWar(userSpecifiedArtifactPath)), "appengine.flex.config.user.specified.artifact.error");
    check(StringUtils.isNotBlank(moduleName), "appengine.flex.config.select.module");
    AppEngineFlexibleFacet facet = AppEngineFlexibleFacet.getFacetByModuleName(moduleName, project);
    check(facet != null, "appengine.flex.config.select.module");
    String appYamlPath = facet.getConfiguration().getAppYamlPath();
    check(StringUtils.isNotBlank(appYamlPath), "appengine.flex.config.browse.app.yaml");
    check(Files.exists(Paths.get(appYamlPath)), "appengine.deployment.config.appyaml.error");
    try {
        Optional<FlexibleRuntime> runtime = AppEngineProjectService.getInstance().getFlexibleRuntimeFromAppYaml(appYamlPath);
        if (runtime.isPresent() && runtime.get().isCustom()) {
            String dockerDirectory = facet.getConfiguration().getDockerDirectory();
            check(StringUtils.isNotBlank(dockerDirectory), "appengine.flex.config.browse.docker.directory");
            check(Files.exists(Paths.get(dockerDirectory, DOCKERFILE_NAME)), "appengine.deployment.config.dockerfile.error");
        }
    } catch (MalformedYamlFileException e) {
        throw new RuntimeConfigurationError(GctBundle.message("appengine.appyaml.malformed"));
    }
}
Also used : UserSpecifiedPathDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource) MalformedYamlFileException(com.google.cloud.tools.intellij.appengine.project.MalformedYamlFileException) AppEngineFlexibleFacet(com.google.cloud.tools.intellij.appengine.facet.flexible.AppEngineFlexibleFacet) FlexibleRuntime(com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService.FlexibleRuntime) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError)

Aggregations

UserSpecifiedPathDeploymentSource (com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource)1 AppEngineFlexibleFacet (com.google.cloud.tools.intellij.appengine.facet.flexible.AppEngineFlexibleFacet)1 FlexibleRuntime (com.google.cloud.tools.intellij.appengine.project.AppEngineProjectService.FlexibleRuntime)1 MalformedYamlFileException (com.google.cloud.tools.intellij.appengine.project.MalformedYamlFileException)1 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)1