private bool ConfirmDeployment(Recommendation recommendation)
        {
            var message = recommendation.Recipe.DeploymentConfirmation?.DefaultMessage;

            if (string.IsNullOrEmpty(message))
            {
                return(true);
            }

            var result = _consoleUtilities.AskYesNoQuestion(message);

            return(result == ConsoleUtilities.YesNo.Yes);
        }
        public Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting)
        {
            var answer = _consoleUtilities.AskYesNoQuestion(string.Empty, recommendation.GetOptionSettingValue <string>(optionSetting));

            recommendation.DeploymentBundle.DotnetPublishSelfContainedBuild = answer == ConsoleUtilities.YesNo.Yes;
            var result = answer == ConsoleUtilities.YesNo.Yes ? "true" : "false";

            return(Task.FromResult <object>(result));
        }
Exemplo n.º 3
0
        public async Task <object> Execute(Recommendation recommendation, OptionSettingItem optionSetting)
        {
            var currentValue = recommendation.GetOptionSettingValue(optionSetting);
            var keyPairs     = await _awsResourceQueryer.ListOfEC2KeyPairs(_session);

            var userInputConfiguration = new UserInputConfiguration <KeyPairInfo>
            {
                DisplaySelector = kp => kp.KeyName,
                DefaultSelector = kp => kp.KeyName.Equals(currentValue),
                AskNewName      = true,
                EmptyOption     = true,
                CurrentValue    = currentValue
            };

            var settingValue = "";

            while (true)
            {
                var userResponse = _consoleUtilities.AskUserToChooseOrCreateNew(keyPairs, "Select key pair to use:", userInputConfiguration);

                if (userResponse.IsEmpty)
                {
                    settingValue = "";
                    break;
                }
                else
                {
                    settingValue = userResponse.SelectedOption?.KeyName ?? userResponse.NewName;
                }

                if (userResponse.CreateNew && !string.IsNullOrEmpty(userResponse.NewName))
                {
                    _toolInteractiveService.WriteLine(string.Empty);
                    _toolInteractiveService.WriteLine("You have chosen to create a new key pair.");
                    _toolInteractiveService.WriteLine("You are required to specify a directory to save the key pair private key.");

                    var answer = _consoleUtilities.AskYesNoQuestion("Do you want to continue?", "false");
                    if (answer == ConsoleUtilities.YesNo.No)
                    {
                        continue;
                    }

                    _toolInteractiveService.WriteLine(string.Empty);
                    _toolInteractiveService.WriteLine($"A new key pair will be created with the name {settingValue}.");

                    var keyPairDirectory = _consoleUtilities.AskForEC2KeyPairSaveDirectory(recommendation.ProjectPath);

                    await _awsResourceQueryer.CreateEC2KeyPair(_session, settingValue.ToString(), keyPairDirectory);
                }

                break;
            }

            return(settingValue);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deletes given CloudFormation stack
        /// </summary>
        /// <param name="stackName">The stack name to be deleted</param>
        /// <exception cref="FailedToDeleteException">Thrown when deletion fails</exception>
        public async Task ExecuteAsync(string stackName)
        {
            var canDelete = await CanDeleteAsync(stackName);

            if (!canDelete)
            {
                return;
            }

            var confirmDelete = _consoleUtilities.AskYesNoQuestion($"Are you sure you want to delete {stackName}?", ConsoleUtilities.YesNo.No);

            if (confirmDelete == ConsoleUtilities.YesNo.No)
            {
                return;
            }

            _interactiveService.WriteLine($"{stackName}: deleting...");
            var monitor = new StackEventMonitor(stackName, _awsClientFactory, _interactiveService, _session);

            try
            {
                await _cloudFormationClient.DeleteStackAsync(new DeleteStackRequest
                {
                    StackName = stackName
                });

                // Fire and forget the monitor
                // Monitor updates the stdout with current status of the CloudFormation stack
                var _ = monitor.StartAsync();

                await WaitForStackDelete(stackName);

                _interactiveService.WriteLine($"{stackName}: deleted");
            }
            catch (AmazonCloudFormationException)
            {
                throw new FailedToDeleteException($"Failed to delete {stackName} stack.");
            }
            finally
            {
                // Stop monitoring CloudFormation stack status once the deletion operation finishes
                monitor.Stop();
            }
        }