Add validation for runtime parse

This commit is contained in:
Flanker-MSFT 2023-12-22 15:00:14 +08:00
Родитель 8f57138e9f
Коммит ea82bae12c
2 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -135,6 +135,9 @@ public class DeployHandler {
final String javaVersion = getJavaVersion();
final Runtime runtime = os == OperatingSystem.DOCKER ? FunctionAppRuntime.DOCKER : os == OperatingSystem.WINDOWS ?
FunctionAppWindowsRuntime.fromJavaVersionUserText(javaVersion) : FunctionAppLinuxRuntime.fromJavaVersionUserText(javaVersion);
if (Objects.isNull(runtime) && StringUtils.isNotBlank(config.javaVersion())) {
throw new AzureToolkitRuntimeException("invalid runtime configuration, please refer to https://aka.ms/maven_function_configuration#supported-runtime for valid values");
}
return new RuntimeConfig().runtime(runtime)
.image(config.image()).registryUrl(config.registryUrl())
.username(config.username()).password(config.password());

Просмотреть файл

@ -175,6 +175,9 @@ public class DeployTask extends DefaultTask {
final Runtime runtime = os == OperatingSystem.DOCKER ? FunctionAppRuntime.DOCKER : os == OperatingSystem.WINDOWS ?
WebAppWindowsRuntime.fromContainerAndJavaVersionUserText(webContainer, javaVersion) :
WebAppLinuxRuntime.fromContainerAndJavaVersionUserText(webContainer, javaVersion);
if (Objects.isNull(runtime) && (StringUtils.isNotBlank(config.webContainer()) || StringUtils.isNotBlank(config.javaVersion()))) {
throw new AzureToolkitRuntimeException("invalid runtime configuration, please refer to https://aka.ms/maven_webapp_runtime for valid values");
}
return new RuntimeConfig()
.runtime(runtime)
.registryUrl(config.registryUrl())