private async Task CreateDeploymentBundle() { if (_selectedRecommendation.Recipe.DeploymentBundle == DeploymentBundleTypes.Container) { await _orchestrator.CreateContainerDeploymentBundle(_cloudApplication, _selectedRecommendation); } else if (_selectedRecommendation.Recipe.DeploymentBundle == DeploymentBundleTypes.DotnetPublishZipFile) { var dotnetPublishDeploymentBundleResult = await _orchestrator.CreateDotnetPublishDeploymentBundle(_selectedRecommendation); if (!dotnetPublishDeploymentBundleResult) { throw new FailedToCreateDeploymentBundleException("Failed to create a deployment bundle"); } } }
private async Task CreateDeploymentBundle(Orchestrator orchestrator, Recommendation selectedRecommendation, CloudApplication cloudApplication) { if (selectedRecommendation.Recipe.DeploymentBundle == DeploymentBundleTypes.Container) { while (!await orchestrator.CreateContainerDeploymentBundle(cloudApplication, selectedRecommendation)) { if (_toolInteractiveService.DisableInteractive) { var errorMessage = "Failed to build Docker Image." + Environment.NewLine; errorMessage += "Docker builds usually fail due to executing them from a working directory that is incompatible with the Dockerfile." + Environment.NewLine; errorMessage += "Specify a valid Docker execution directory as part of the deployment settings file and try again."; throw new DockerBuildFailedException(errorMessage); } _toolInteractiveService.WriteLine(string.Empty); var answer = _consoleUtilities.AskYesNoQuestion("Do you want to go back and modify the current configuration?", "false"); if (answer == YesNo.Yes) { var dockerExecutionDirectory = _consoleUtilities.AskUserForValue( "Enter the docker execution directory where the docker build command will be executed from:", selectedRecommendation.DeploymentBundle.DockerExecutionDirectory, allowEmpty: true); if (!_directoryManager.Exists(dockerExecutionDirectory)) { continue; } selectedRecommendation.DeploymentBundle.DockerExecutionDirectory = dockerExecutionDirectory; } else { throw new FailedToCreateDeploymentBundleException("Failed to create a deployment bundle"); } } } else if (selectedRecommendation.Recipe.DeploymentBundle == DeploymentBundleTypes.DotnetPublishZipFile) { var dotnetPublishDeploymentBundleResult = await orchestrator.CreateDotnetPublishDeploymentBundle(selectedRecommendation); if (!dotnetPublishDeploymentBundleResult) { throw new FailedToCreateDeploymentBundleException("Failed to create a deployment bundle"); } } }