Search in sources :

Example 1 with FunctionDeployConfiguration

use of com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeployConfiguration in project azure-tools-for-java by Microsoft.

the class DeployFunctionAppAction method getRunConfigurationSettings.

private RunnerAndConfigurationSettings getRunConfigurationSettings(RunManagerEx manager) {
    final ConfigurationFactory factory = new FunctionDeploymentConfigurationFactory(functionType);
    final String runConfigurationName = String.format("%s: %s:%s", factory.getName(), project.getName(), functionNode.getName());
    RunnerAndConfigurationSettings settings = manager.findConfigurationByName(runConfigurationName);
    if (settings == null) {
        settings = manager.createConfiguration(runConfigurationName, factory);
    }
    final RunConfiguration runConfiguration = settings.getConfiguration();
    if (runConfiguration instanceof FunctionDeployConfiguration) {
        final IFunctionApp functionApp = Azure.az(AzureAppService.class).functionApp(functionNode.getId());
        final FunctionAppConfig config = FunctionAppService.getInstance().getFunctionAppConfigFromExistingFunction(functionApp);
        ((FunctionDeployConfiguration) runConfiguration).saveConfig(config);
    }
    return settings;
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) FunctionAppConfig(com.microsoft.azure.toolkit.lib.function.FunctionAppConfig) AzureAppService(com.microsoft.azure.toolkit.lib.appservice.AzureAppService) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) FunctionDeploymentConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FunctionDeployConfiguration(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeployConfiguration) IFunctionApp(com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp) FunctionDeploymentConfigurationFactory(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory)

Example 2 with FunctionDeployConfiguration

use of com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeployConfiguration in project azure-tools-for-java by Microsoft.

the class FunctionRunConfigurationProducer method setupConfigurationFromContext.

@Override
protected boolean setupConfigurationFromContext(AzureRunConfigurationBase runConfigurationBase, ConfigurationContext context, Ref ref) {
    if (!(runConfigurationBase instanceof FunctionRunConfiguration || runConfigurationBase instanceof FunctionDeployConfiguration)) {
        return false;
    }
    final Location contextLocation = context.getLocation();
    assert contextLocation != null;
    Location<PsiMethod> methodLocation = getAzureFunctionMethods(contextLocation);
    if (methodLocation == null) {
        return false;
    }
    AzureRunConfigurationBase configuration = runConfigurationBase;
    if (configuration instanceof FunctionDeployConfiguration) {
        final RunManagerEx manager = RunManagerEx.getInstanceEx(context.getProject());
        // since deploy configuration doesn't support, we need to create a FunctionRunConfiguration
        final RunnerAndConfigurationSettings settings = RunConfigurationUtils.getOrCreateRunConfigurationSettings(context.getModule(), manager, getConfigurationFactory());
        configuration = (AzureRunConfigurationBase) settings.getConfiguration();
    }
    FunctionRunConfiguration runConfiguration = (FunctionRunConfiguration) configuration;
    final RunnerAndConfigurationSettings template = context.getRunManager().getConfigurationTemplate(getConfigurationFactory());
    final Module contextModule = context.getModule();
    final Module predefinedModule = ((FunctionRunConfiguration) template.getConfiguration()).getModule();
    if (predefinedModule != null) {
        runConfiguration.initializeDefaults(predefinedModule);
    } else {
        final Module module = findModule(runConfiguration, contextModule);
        if (module != null) {
            runConfiguration.initializeDefaults(module);
        } else {
            return false;
        }
    }
    if (StringUtils.isBlank(configuration.getName())) {
        configuration.setName("Run Functions - " + runConfiguration.getModule().getName());
    }
    return true;
}
Also used : RunManagerEx(com.intellij.execution.RunManagerEx) PsiMethod(com.intellij.psi.PsiMethod) AzureRunConfigurationBase(com.microsoft.azure.toolkit.intellij.common.AzureRunConfigurationBase) FunctionRunConfiguration(com.microsoft.azure.toolkit.intellij.function.runner.localrun.FunctionRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) FunctionDeployConfiguration(com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeployConfiguration) Module(com.intellij.openapi.module.Module) Location(com.intellij.execution.Location)

Aggregations

RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 FunctionDeployConfiguration (com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeployConfiguration)2 Location (com.intellij.execution.Location)1 RunManagerEx (com.intellij.execution.RunManagerEx)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 Module (com.intellij.openapi.module.Module)1 PsiMethod (com.intellij.psi.PsiMethod)1 AzureRunConfigurationBase (com.microsoft.azure.toolkit.intellij.common.AzureRunConfigurationBase)1 FunctionDeploymentConfigurationFactory (com.microsoft.azure.toolkit.intellij.function.runner.deploy.FunctionDeploymentConfigurationFactory)1 FunctionRunConfiguration (com.microsoft.azure.toolkit.intellij.function.runner.localrun.FunctionRunConfiguration)1 AzureAppService (com.microsoft.azure.toolkit.lib.appservice.AzureAppService)1 IFunctionApp (com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp)1 FunctionAppConfig (com.microsoft.azure.toolkit.lib.function.FunctionAppConfig)1