Search in sources :

Example 1 with UserSpecifiedPathDeploymentSource

use of com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource 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)

Example 2 with UserSpecifiedPathDeploymentSource

use of com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource in project google-cloud-intellij by GoogleCloudPlatform.

the class AppEngineDeploymentConfiguration method checkCommonConfig.

private void checkCommonConfig(AppEngineDeployable deployable) throws RuntimeConfigurationError {
    // do not check SDK if it supports dynamic install - the deployment runner will block itself
    // until installation is done.
    CloudSdkService cloudSdkService = CloudSdkService.getInstance();
    SdkStatus sdkStatus = cloudSdkService.getStatus();
    if (sdkStatus != SdkStatus.READY && !cloudSdkService.isInstallSupported()) {
        Set<CloudSdkValidationResult> sdkValidationResult = CloudSdkValidator.getInstance().validateCloudSdk();
        if (!sdkValidationResult.isEmpty()) {
            CloudSdkValidationResult result = Iterables.getFirst(sdkValidationResult, null);
            throw new RuntimeConfigurationError(GctBundle.message("appengine.flex.config.server.error", result.getMessage()));
        }
    }
    check(deployable instanceof UserSpecifiedPathDeploymentSource || deployable.isValid(), "appengine.config.deployment.source.error");
    check(StringUtils.isNotBlank(cloudProjectName), "appengine.flex.config.project.missing.message");
}
Also used : UserSpecifiedPathDeploymentSource(com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource) CloudSdkService(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService) RuntimeConfigurationError(com.intellij.execution.configurations.RuntimeConfigurationError) SdkStatus(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus) CloudSdkValidationResult(com.google.cloud.tools.intellij.appengine.sdk.CloudSdkValidationResult)

Aggregations

UserSpecifiedPathDeploymentSource (com.google.cloud.tools.intellij.appengine.cloud.flexible.UserSpecifiedPathDeploymentSource)2 RuntimeConfigurationError (com.intellij.execution.configurations.RuntimeConfigurationError)2 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 CloudSdkService (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService)1 SdkStatus (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkService.SdkStatus)1 CloudSdkValidationResult (com.google.cloud.tools.intellij.appengine.sdk.CloudSdkValidationResult)1