Search in sources :

Example 1 with PushImageRunConfiguration

use of com.microsoft.azure.toolkit.intellij.webapp.docker.pushimage.PushImageRunConfiguration in project azure-tools-for-java by Microsoft.

the class PushToContainerRegistryAction method openRunDialog.

private void openRunDialog(Project project, PrivateRegistryImageSetting imageSetting) {
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final ConfigurationFactory factory = configType.getPushImageRunConfigurationFactory();
    RunnerAndConfigurationSettings settings = manager.createConfiguration(String.format("%s: %s", factory.getName(), project.getName()), factory);
    PushImageRunConfiguration conf = (PushImageRunConfiguration) settings.getConfiguration();
    conf.setPrivateRegistryImageSetting(imageSetting);
    openRunDialog(project, settings);
}
Also used : RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PushImageRunConfiguration(com.microsoft.azure.toolkit.intellij.webapp.docker.pushimage.PushImageRunConfiguration)

Example 2 with PushImageRunConfiguration

use of com.microsoft.azure.toolkit.intellij.webapp.docker.pushimage.PushImageRunConfiguration in project azure-tools-for-java by Microsoft.

the class PushToContainerRegistryAction method runConfiguration.

@SuppressWarnings({ "deprecation", "Duplicates" })
private void runConfiguration(@NotNull Project project) {
    final RunManagerEx manager = RunManagerEx.getInstanceEx(project);
    final ConfigurationFactory factory = configType.getPushImageRunConfigurationFactory();
    RunnerAndConfigurationSettings settings = manager.findConfigurationByName(String.format("%s: %s", factory.getName(), project.getName()));
    Observable.fromCallable(() -> {
        Registry registry = ContainerRegistryMvpModel.getInstance().getContainerRegistry(currentNode.getSubscriptionId(), currentNode.getResourceId());
        return ContainerRegistryMvpModel.getInstance().createImageSettingWithRegistry(registry);
    }).subscribeOn(SchedulerProviderFactory.getInstance().getSchedulerProvider().io()).subscribe(ret -> {
        if (settings != null) {
            PushImageRunConfiguration conf = (PushImageRunConfiguration) settings.getConfiguration();
            PrivateRegistryImageSetting imageSetting = conf.getPrivateRegistryImageSetting();
            imageSetting.setServerUrl(ret.getServerUrl());
            imageSetting.setUsername(ret.getUsername());
            imageSetting.setPassword(ret.getPassword());
            AzureTaskManager.getInstance().runLater(() -> openRunDialog(project, settings));
            return;
        }
        AzureTaskManager.getInstance().runLater(() -> openRunDialog(project, ret));
    }, err -> {
        err.printStackTrace();
        Notification notification = new Notification(NOTIFICATION_GROUP_ID, DIALOG_TITLE, err.getMessage(), NotificationType.ERROR);
        Notifications.Bus.notify(notification);
    });
}
Also used : PrivateRegistryImageSetting(com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting) RunManagerEx(com.intellij.execution.RunManagerEx) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PushImageRunConfiguration(com.microsoft.azure.toolkit.intellij.webapp.docker.pushimage.PushImageRunConfiguration) Registry(com.microsoft.azure.management.containerregistry.Registry) Notification(com.intellij.notification.Notification)

Aggregations

RunManagerEx (com.intellij.execution.RunManagerEx)2 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)2 PushImageRunConfiguration (com.microsoft.azure.toolkit.intellij.webapp.docker.pushimage.PushImageRunConfiguration)2 Notification (com.intellij.notification.Notification)1 Registry (com.microsoft.azure.management.containerregistry.Registry)1 PrivateRegistryImageSetting (com.microsoft.azuretools.core.mvp.model.webapp.PrivateRegistryImageSetting)1