Skip to content

Commit

Permalink
feat: Remove disabled fields from showing on redeployment in server mode
Browse files Browse the repository at this point in the history
  • Loading branch information
philasmar committed Jul 2, 2024
1 parent 2c676af commit fdf67d3
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ private List<OptionSettingItemSummary> ListOptionSettingSummary(IOptionSettingHa
Value = optionSettingHandler.GetOptionSettingValue(recommendation, setting),
Advanced = setting.AdvancedSetting,
ReadOnly = recommendation.IsExistingCloudApplication && !setting.Updatable,
Visible = optionSettingHandler.IsOptionSettingDisplayable(recommendation, setting),
Visible =
optionSettingHandler.IsOptionSettingDisplayable(recommendation, setting) &&
!(recommendation.IsExistingCloudApplication && !setting.Updatable && !setting.VisibleOnRedeployment),

Check warning on line 213 in src/AWS.Deploy.CLI/ServerMode/Controllers/DeploymentController.cs

View check run for this annotation

Codecov / codecov/patch

src/AWS.Deploy.CLI/ServerMode/Controllers/DeploymentController.cs#L211-L213

Added lines #L211 - L213 were not covered by tests
SummaryDisplayable = optionSettingHandler.IsSummaryDisplayable(recommendation, setting),
AllowedValues = setting.AllowedValues,
ValueMapping = setting.ValueMapping,
Expand Down
5 changes: 5 additions & 0 deletions src/AWS.Deploy.Common/Recipes/OptionSettingItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ public partial class OptionSettingItem : IOptionSettingItem
/// </summary>
public bool Updatable { get; set; }

/// <summary>
/// If the value is true, the setting will be displayed during a redeployment. This only applies to server-mode clients.
/// </summary>
public bool VisibleOnRedeployment { get; set; }

/// <summary>
/// List of all validators that should be run when configuring this OptionSettingItem.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"TypeHint": "AppRunnerService",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"DefaultValue": "{StackName}-service",
"Validators": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"TypeHint": "ECSCluster",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"ChildOptionSettings": [
{
"Id": "CreateNew",
Expand All @@ -136,6 +137,7 @@
"TypeHint": "ExistingECSCluster",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand All @@ -160,6 +162,7 @@
"DefaultValue": "{StackName}",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand Down Expand Up @@ -195,6 +198,7 @@
"DefaultValue": "{StackName}-service",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand Down Expand Up @@ -738,7 +742,8 @@
"Type": "Bool",
"DefaultValue": true,
"AdvancedSetting": false,
"Updatable": false
"Updatable": false,
"VisibleOnRedeployment": true
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"TypeHint": "BeanstalkApplication",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"ChildOptionSettings": [
{
"Id": "CreateNew",
Expand All @@ -155,6 +156,7 @@
"DefaultValue": "{StackName}",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"DependsOn": [
{
"Id": "BeanstalkApplication.CreateNew",
Expand Down Expand Up @@ -187,6 +189,7 @@
"DefaultValue": "{StackName}",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"DependsOn": [
{
"Id": "BeanstalkApplication.CreateNew",
Expand Down Expand Up @@ -215,6 +218,7 @@
"Type": "Object",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"ChildOptionSettings": [
{
"Id": "EnvironmentName",
Expand All @@ -225,6 +229,7 @@
"DefaultValue": "{StackName}-dev",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"TypeHint": "BeanstalkApplication",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"ChildOptionSettings": [
{
"Id": "CreateNew",
Expand All @@ -155,6 +156,7 @@
"DefaultValue": "{StackName}",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"DependsOn": [
{
"Id": "BeanstalkApplication.CreateNew",
Expand Down Expand Up @@ -187,6 +189,7 @@
"DefaultValue": "{StackName}",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"DependsOn": [
{
"Id": "BeanstalkApplication.CreateNew",
Expand Down Expand Up @@ -216,6 +219,7 @@
"DefaultValue": "{StackName}-dev",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
"TypeHint": "ECSCluster",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"ChildOptionSettings": [
{
"Id": "CreateNew",
Expand All @@ -154,6 +155,7 @@
"TypeHint": "ExistingECSCluster",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand All @@ -178,6 +180,7 @@
"DefaultValue": "{StackName}",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
"TypeHint": "ECSCluster",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"ChildOptionSettings": [
{
"Id": "CreateNew",
Expand All @@ -194,6 +195,7 @@
"TypeHint": "ExistingECSCluster",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand All @@ -218,6 +220,7 @@
"DefaultValue": "{StackName}",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand Down Expand Up @@ -247,6 +250,7 @@
"DefaultValue": "{StackName}-service",
"AdvancedSetting": false,
"Updatable": false,
"VisibleOnRedeployment": true,
"Validators": [
{
"ValidatorType": "Regex",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,12 @@
"description": "If the setting is false the setting can not be changed during redeployment.",
"minLength": 1
},
"VisibleOnRedeployment": {
"type": "boolean",
"title": "VisibleOnRedeployment",
"description": "If the value is true, the setting will be displayed during a redeployment. This only applies to server-mode clients.",
"minLength": 1
},
"DependsOn": {
"type": "array",
"title": "",
Expand Down
82 changes: 82 additions & 0 deletions test/AWS.Deploy.CLI.IntegrationTests/ServerModeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,88 @@ public async Task GetRecommendationsWithEncryptedCredentials()
}
}

[Fact]
public async Task AppRunnerRedeployment_VisibleOnRedeploymentSettings()
{
_stackName = $"ServerModeAppRunner{Guid.NewGuid().ToString().Split('-').Last()}";

var projectPath = _testAppManager.GetProjectPath(Path.Combine("testapps", "WebAppWithDockerFile", "WebAppWithDockerFile.csproj"));
var portNumber = 4950;
using var httpClient = ServerModeHttpClientFactory.ConstructHttpClient(ServerModeUtilities.ResolveDefaultCredentials);

var serverCommand = new ServerModeCommand(_serviceProvider.GetRequiredService<IToolInteractiveService>(), portNumber, null, true);
var cancelSource = new CancellationTokenSource();

var serverTask = serverCommand.ExecuteAsync(cancelSource.Token);
try
{
var baseUrl = $"http://localhost:{portNumber}/";
var restClient = new RestAPIClient(baseUrl, httpClient);

await restClient.WaitUntilServerModeReady();

var startSessionOutput = await restClient.StartDeploymentSessionAsync(new StartDeploymentSessionInput
{
AwsRegion = _awsRegion,
ProjectPath = projectPath
});

var sessionId = startSessionOutput.SessionId;
Assert.NotNull(sessionId);

var signalRClient = new DeploymentCommunicationClient(baseUrl);
await signalRClient.JoinSession(sessionId);

var logOutput = new StringBuilder();
RegisterSignalRMessageCallbacks(signalRClient, logOutput);

var getRecommendationOutput = await restClient.GetRecommendationsAsync(sessionId);
Assert.NotEmpty(getRecommendationOutput.Recommendations);

var appRunnerRecommendation = getRecommendationOutput.Recommendations.FirstOrDefault(x => string.Equals(x.RecipeId, "AspNetAppAppRunner"));
Assert.NotNull(appRunnerRecommendation);

await restClient.SetDeploymentTargetAsync(sessionId, new SetDeploymentTargetInput
{
NewDeploymentName = _stackName,
NewDeploymentRecipeId = appRunnerRecommendation.RecipeId
});

await restClient.StartDeploymentAsync(sessionId);

await restClient.WaitForDeployment(sessionId);

var stackStatus = await _cloudFormationHelper.GetStackStatus(_stackName);
Assert.Equal(StackStatus.CREATE_COMPLETE, stackStatus);

Assert.True(logOutput.Length > 0);

var redeploymentSessionOutput = await restClient.StartDeploymentSessionAsync(new StartDeploymentSessionInput
{
AwsRegion = _awsRegion,
ProjectPath = projectPath
});

var redeploymentSessionId = redeploymentSessionOutput.SessionId;

await restClient.SetDeploymentTargetAsync(redeploymentSessionId, new SetDeploymentTargetInput
{
ExistingDeploymentId = await _cloudFormationHelper.GetStackArn(_stackName)
});

var settings = await restClient.GetConfigSettingsAsync(redeploymentSessionId);

Assert.True(settings.OptionSettings.First(x => x.Id.Equals("ServiceName")).Visible);
Assert.False(settings.OptionSettings.First(x => x.Id.Equals("EncryptionKmsKey")).Visible);
}
finally
{
cancelSource.Cancel();
await _cloudFormationHelper.DeleteStack(_stackName);
_stackName = null;
}
}

[Fact]
public async Task WebFargateDeploymentNoConfigChanges()
{
Expand Down

0 comments on commit fdf67d3

Please sign in to comment.