private void OutputResultData(GkeDeploymentResult result, GkeDeployment.DeploymentOptions options) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentSuccessMessage, _publishDialog.Project.Name)); if (result.DeploymentUpdated) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentUpdatedMessage, options.DeploymentName)); } if (result.DeploymentScaled) { GcpOutputWindow.OutputLine( String.Format(Resources.GkePublishDeploymentScaledMessage, options.DeploymentName, options.Replicas)); } if (result.ServiceUpdated) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishServiceUpdatedMessage, options.DeploymentName)); } if (result.ServiceExposed) { if (result.PublicServiceIpAddress != null) { GcpOutputWindow.OutputLine( String.Format(Resources.GkePublishServiceIpMessage, DeploymentName, result.PublicServiceIpAddress)); } else { if (ExposePublicService) { GcpOutputWindow.OutputLine(Resources.GkePublishServiceIpTimeoutMessage); } else { GcpOutputWindow.OutputLine( String.Format( Resources.GkePublishServiceClusterIpMessage, DeploymentName, result.ClusterServiceIpAddress)); } } } if (result.ServiceDeleted) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishServiceDeletedMessage, DeploymentName)); } }
/// <summary> /// Start the publish operation. /// </summary> public override async void Publish() { if (!ValidateInput()) { Debug.WriteLine("Invalid input cancelled the operation."); return; } var project = _publishDialog.Project; try { var verifyGCloudTask = VerifyGCloudDependencies(); _publishDialog.TrackTask(verifyGCloudTask); if (!await verifyGCloudTask) { Debug.WriteLine("Aborting deployment, no kubectl was found."); return; } var gcloudContext = new GCloudContext { CredentialsPath = CredentialsStore.Default.CurrentAccountPath, ProjectId = CredentialsStore.Default.CurrentProjectId, AppName = GoogleCloudExtensionPackage.ApplicationName, AppVersion = GoogleCloudExtensionPackage.ApplicationVersion, }; var kubectlContextTask = GCloudWrapper.GetKubectlContextForClusterAsync( cluster: SelectedCluster.Name, zone: SelectedCluster.Zone, context: gcloudContext); _publishDialog.TrackTask(kubectlContextTask); using (var kubectlContext = await kubectlContextTask) { var deploymentExistsTask = KubectlWrapper.DeploymentExistsAsync(DeploymentName, kubectlContext); _publishDialog.TrackTask(deploymentExistsTask); if (await deploymentExistsTask) { if (!UserPromptUtils.ActionPrompt( String.Format(Resources.GkePublishDeploymentAlreadyExistsMessage, DeploymentName), Resources.GkePublishDeploymentAlreadyExistsTitle, actionCaption: Resources.UiUpdateButtonCaption)) { return; } } var options = new GkeDeployment.DeploymentOptions { Cluster = SelectedCluster.Name, Zone = SelectedCluster.Zone, DeploymentName = DeploymentName, DeploymentVersion = DeploymentVersion, ExposeService = ExposeService, GCloudContext = gcloudContext, KubectlContext = kubectlContext, Replicas = int.Parse(Replicas), WaitingForServiceIpCallback = () => GcpOutputWindow.OutputLine(Resources.GkePublishWaitingForServiceIpMessage) }; GcpOutputWindow.Activate(); GcpOutputWindow.Clear(); GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeployingToGkeMessage, project.Name)); _publishDialog.FinishFlow(); GkeDeploymentResult result; using (var frozen = StatusbarHelper.Freeze()) using (var animationShown = StatusbarHelper.ShowDeployAnimation()) using (var progress = StatusbarHelper.ShowProgressBar(Resources.GkePublishDeploymentStatusMessage)) using (var deployingOperation = ShellUtils.SetShellUIBusy()) { result = await GkeDeployment.PublishProjectAsync( project.FullPath, options, progress, GcpOutputWindow.OutputLine); } if (result != null) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentSuccessMessage, project.Name)); if (result.DeploymentUpdated) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentUpdatedMessage, options.DeploymentName)); } if (result.DeploymentScaled) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentScaledMessage, options.DeploymentName, options.Replicas)); } if (result.WasExposed) { if (result.ServiceIpAddress != null) { GcpOutputWindow.OutputLine( String.Format(Resources.GkePublishServiceIpMessage, DeploymentName, result.ServiceIpAddress)); } else { GcpOutputWindow.OutputLine(Resources.GkePublishServiceIpTimeoutMessage); } } StatusbarHelper.SetText(Resources.PublishSuccessStatusMessage); if (OpenWebsite && result.WasExposed && result.ServiceIpAddress != null) { Process.Start($"http://{result.ServiceIpAddress}"); } } else { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentFailureMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishFailureStatusMessage); } } } catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex)) { GcpOutputWindow.OutputLine(String.Format(Resources.GkePublishDeploymentFailureMessage, project.Name)); StatusbarHelper.SetText(Resources.PublishFailureStatusMessage); _publishDialog.FinishFlow(); } }