From a1e96999e60ee023e51a9b27c3bb47fbb0b1c8f7 Mon Sep 17 00:00:00 2001 From: Phil Asmar Date: Fri, 11 Oct 2024 14:54:06 -0400 Subject: [PATCH] address chris' comments --- .../TypeHints/EnvironmentArchitectureCommand.cs | 3 ++- .../DeploymentBundles/DeploymentBundle.cs | 3 ++- .../AWS.Deploy.Constants.projitems | 1 + src/AWS.Deploy.Constants/Recipe.cs | 13 +++++++++++++ src/AWS.Deploy.Orchestration/Orchestrator.cs | 2 +- .../OrchestratorTests.cs | 4 +++- 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 src/AWS.Deploy.Constants/Recipe.cs diff --git a/src/AWS.Deploy.CLI/Commands/TypeHints/EnvironmentArchitectureCommand.cs b/src/AWS.Deploy.CLI/Commands/TypeHints/EnvironmentArchitectureCommand.cs index 71f97138a..e55a842e1 100644 --- a/src/AWS.Deploy.CLI/Commands/TypeHints/EnvironmentArchitectureCommand.cs +++ b/src/AWS.Deploy.CLI/Commands/TypeHints/EnvironmentArchitectureCommand.cs @@ -31,7 +31,8 @@ public Task GetResources(Recommendation recommendation, O } }; - foreach (var value in recommendation.Recipe.SupportedArchitectures ?? new List { SupportedArchitecture.X86_64 }) + foreach (var value in recommendation.Recipe.SupportedArchitectures ?? + new List { Enum.Parse(Constants.Recipe.DefaultSupportedArchitecture) }) { var stringValue = value.ToString(); var row = new TypeHintResource(stringValue, stringValue); diff --git a/src/AWS.Deploy.Common/DeploymentBundles/DeploymentBundle.cs b/src/AWS.Deploy.Common/DeploymentBundles/DeploymentBundle.cs index 677fd7b2f..360511167 100644 --- a/src/AWS.Deploy.Common/DeploymentBundles/DeploymentBundle.cs +++ b/src/AWS.Deploy.Common/DeploymentBundles/DeploymentBundle.cs @@ -1,6 +1,7 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 +using System; using AWS.Deploy.Common.Recipes; namespace AWS.Deploy.Common @@ -69,6 +70,6 @@ public class DeploymentBundle /// /// The CPU architecture of the environment to create. /// - public SupportedArchitecture EnvironmentArchitecture { get; set; } = SupportedArchitecture.X86_64; + public SupportedArchitecture EnvironmentArchitecture { get; set; } = Enum.Parse(Constants.Recipe.DefaultSupportedArchitecture); } } diff --git a/src/AWS.Deploy.Constants/AWS.Deploy.Constants.projitems b/src/AWS.Deploy.Constants/AWS.Deploy.Constants.projitems index 7ea42a2bc..1860c5594 100644 --- a/src/AWS.Deploy.Constants/AWS.Deploy.Constants.projitems +++ b/src/AWS.Deploy.Constants/AWS.Deploy.Constants.projitems @@ -15,6 +15,7 @@ + \ No newline at end of file diff --git a/src/AWS.Deploy.Constants/Recipe.cs b/src/AWS.Deploy.Constants/Recipe.cs new file mode 100644 index 000000000..c1da5b7c7 --- /dev/null +++ b/src/AWS.Deploy.Constants/Recipe.cs @@ -0,0 +1,13 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\r +// SPDX-License-Identifier: Apache-2.0 + +namespace AWS.Deploy.Constants +{ + internal class Recipe + { + /// + /// The default supported architecture + /// + public const string DefaultSupportedArchitecture = "X86_64"; + } +} diff --git a/src/AWS.Deploy.Orchestration/Orchestrator.cs b/src/AWS.Deploy.Orchestration/Orchestrator.cs index b20221d06..1c8245b63 100644 --- a/src/AWS.Deploy.Orchestration/Orchestrator.cs +++ b/src/AWS.Deploy.Orchestration/Orchestrator.cs @@ -246,7 +246,7 @@ public async Task ApplyAllReplacementTokens(Recommendation recommendation, strin } if (recommendation.ReplacementTokens.ContainsKey(Constants.RecipeIdentifier.REPLACE_TOKEN_DEFAULT_ENVIRONMENT_ARCHITECTURE)) { - recommendation.AddReplacementToken(Constants.RecipeIdentifier.REPLACE_TOKEN_DEFAULT_ENVIRONMENT_ARCHITECTURE, SupportedArchitecture.X86_64.ToString()); + recommendation.AddReplacementToken(Constants.RecipeIdentifier.REPLACE_TOKEN_DEFAULT_ENVIRONMENT_ARCHITECTURE, Constants.Recipe.DefaultSupportedArchitecture); } } diff --git a/test/AWS.Deploy.Orchestration.UnitTests/OrchestratorTests.cs b/test/AWS.Deploy.Orchestration.UnitTests/OrchestratorTests.cs index b1842ed84..67e5adfe8 100644 --- a/test/AWS.Deploy.Orchestration.UnitTests/OrchestratorTests.cs +++ b/test/AWS.Deploy.Orchestration.UnitTests/OrchestratorTests.cs @@ -66,6 +66,8 @@ public async Task ApplyAllReplacementTokensTest() recommendation.ReplacementTokens.Clear(); recommendation.ReplacementTokens.Add(Constants.RecipeIdentifier.REPLACE_TOKEN_DEFAULT_ENVIRONMENT_ARCHITECTURE, true); - await Assert.ThrowsAsync(async () => await orchestrator.ApplyAllReplacementTokens(recommendation, "WebAppNoDockerFile")); + await orchestrator.ApplyAllReplacementTokens(recommendation, "WebAppNoDockerFile"); + + Assert.Equal(Constants.Recipe.DefaultSupportedArchitecture, recommendation.ReplacementTokens[Constants.RecipeIdentifier.REPLACE_TOKEN_DEFAULT_ENVIRONMENT_ARCHITECTURE]); } }