use of com.microsoft.azure.toolkit.lib.legacy.function.bindings.BindingEnum in project azure-tools-for-java by Microsoft.
the class FunctionRunState method prepareStagingFolder.
@AzureOperation(name = "function.prepare_staging_folder_detail", params = { "stagingFolder.getName()", "this.functionRunConfiguration.getFuncPath()" }, type = AzureOperation.Type.SERVICE)
private void prepareStagingFolder(File stagingFolder, RunProcessHandler processHandler, @NotNull final Operation operation) throws Exception {
AzureTaskManager.getInstance().read(() -> {
final Path hostJsonPath = FunctionUtils.getDefaultHostJson(project);
final Path localSettingsJson = Paths.get(functionRunConfiguration.getLocalSettingsJsonPath());
final PsiMethod[] methods = FunctionUtils.findFunctionsByAnnotation(functionRunConfiguration.getModule());
final Path folder = stagingFolder.toPath();
try {
Map<String, FunctionConfiguration> configMap = FunctionUtils.prepareStagingFolder(folder, hostJsonPath, functionRunConfiguration.getModule(), methods);
operation.trackProperty(TelemetryConstants.TRIGGER_TYPE, StringUtils.join(FunctionUtils.getFunctionBindingList(configMap), ","));
final Map<String, String> appSettings = FunctionUtils.loadAppSettingsFromSecurityStorage(functionRunConfiguration.getAppSettingsKey());
FunctionUtils.copyLocalSettingsToStagingFolder(folder, localSettingsJson, appSettings);
final Set<BindingEnum> bindingClasses = getFunctionBindingEnums(configMap);
if (isInstallingExtensionNeeded(bindingClasses, processHandler)) {
installProcess = getRunFunctionCliExtensionInstallProcessBuilder(stagingFolder).start();
}
} catch (AzureExecutionException | IOException e) {
final String error = String.format("failed prepare staging folder[%s]", folder);
throw new AzureToolkitRuntimeException(error, e);
}
});
if (installProcess != null) {
readInputStreamByLines(installProcess.getErrorStream(), inputLine -> {
if (processHandler.isProcessRunning()) {
processHandler.println(inputLine, ProcessOutputTypes.STDERR);
}
});
readInputStreamByLines(installProcess.getInputStream(), inputLine -> {
if (processHandler.isProcessRunning()) {
processHandler.setText(inputLine);
}
});
int exitCode = installProcess.waitFor();
if (exitCode != 0) {
throw new AzureExecutionException(message("function.run.error.installFuncFailed"));
}
}
}
Aggregations