Skip to content

Commit

Permalink
address chris' comments
Browse files Browse the repository at this point in the history
  • Loading branch information
philasmar committed Oct 11, 2024
1 parent 2ea4f02 commit a1e9699
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public Task<TypeHintResourceTable> GetResources(Recommendation recommendation, O
}
};

foreach (var value in recommendation.Recipe.SupportedArchitectures ?? new List<SupportedArchitecture> { SupportedArchitecture.X86_64 })
foreach (var value in recommendation.Recipe.SupportedArchitectures ??
new List<SupportedArchitecture> { Enum.Parse<SupportedArchitecture>(Constants.Recipe.DefaultSupportedArchitecture) })
{
var stringValue = value.ToString();
var row = new TypeHintResource(stringValue, stringValue);
Expand Down
3 changes: 2 additions & 1 deletion src/AWS.Deploy.Common/DeploymentBundles/DeploymentBundle.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -69,6 +70,6 @@ public class DeploymentBundle
/// <summary>
/// The CPU architecture of the environment to create.
/// </summary>
public SupportedArchitecture EnvironmentArchitecture { get; set; } = SupportedArchitecture.X86_64;
public SupportedArchitecture EnvironmentArchitecture { get; set; } = Enum.Parse<SupportedArchitecture>(Constants.Recipe.DefaultSupportedArchitecture);
}
}
1 change: 1 addition & 0 deletions src/AWS.Deploy.Constants/AWS.Deploy.Constants.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Docker.cs" />
<Compile Include="$(MSBuildThisFileDirectory)EC2.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ElasticBeanstalk.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Recipe.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RecipeIdentifier.cs" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions src/AWS.Deploy.Constants/Recipe.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// The default supported architecture
/// </summary>
public const string DefaultSupportedArchitecture = "X86_64";
}
}
2 changes: 1 addition & 1 deletion src/AWS.Deploy.Orchestration/Orchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
4 changes: 3 additions & 1 deletion test/AWS.Deploy.Orchestration.UnitTests/OrchestratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<InvalidOperationException>(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]);
}
}

0 comments on commit a1e9699

Please sign in to comment.