-
Notifications
You must be signed in to change notification settings - Fork 9
Automatically install Amazon.Lambda.TestTool #28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c0ad606
to
fee0285
Compare
using System.Diagnostics; | ||
using System.Text; | ||
|
||
namespace Aspire.Hosting.AWS.Utils.Internal; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to expose this interface as part of our public API but for unit testing purposes I need to implement the interface and making the interface internal doesn't work for that even marking the assembly internal visible to. So I went with the compromise of putting this in an "Internal" namespace.
…ol which is the Lambda service emulator
fee0285
to
ffbb42b
Compare
namespace Aspire.Hosting.AWS.Lambda; | ||
|
||
/// <summary> | ||
/// Lambda lifecycle hook takes care of getting Amazon.Lambda.TestTool is installed if there was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is installed
-> installed
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Directory.Packages.props
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this change, but why does the entire solution has 1 Directory.Packages.props? So anytime we add a new package, we are adding it for the entire solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repo was setup so that it had centralized package versioning. But in the individual project files you still specify the package you want to use. But in the project you don't set a version. For example in the project file of Aspire.Hosting.AWS we add the packages but don't set the version.
<ItemGroup>
<PackageReference Include="Aspire.Hosting" />
<PackageReference Include="Amazon.CDK.Lib" />
<PackageReference Include="AWSSDK.Core" />
<PackageReference Include="AWSSDK.CloudFormation" />
</ItemGroup>
This way you only have to update the version of a package in one place for all projects in a repository.
{ | ||
internal void AddCommandLineArguments(IList<object> arguments) | ||
{ | ||
arguments.Add("lambda-test-tool"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't the name of our tool dotnet-lambda-test-tool
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apparently dotnet lambda-test-tool
works and so does dotnet-lambda-test-tool
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in sync meeting and we are on the same page now.
@@ -14,4 +14,22 @@ internal class LambdaEmulatorAnnotation(EndpointReference endpoint) : IResourceA | |||
/// The HTTP endpoint for the Lambda runtime emulator. | |||
/// </summary> | |||
public EndpointReference Endpoint { get; init; } = endpoint; | |||
|
|||
/// <summary> | |||
/// If set to true Amazon.Lambda.TestTool will updated/installed during AppHost startup. Amazon.Lambda.TestTool is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name and the description are saying 2 different things. The name suggests that we won't auto install, but the description is saying that we will?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
namespace Aspire.Hosting.AWS.Lambda; | ||
|
||
/// <summary> | ||
/// Options that can be added the Lambda emulator resource. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add "to" between "added" and "the"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
public class LambdaEmulatorOptions | ||
{ | ||
/// <summary> | ||
/// If set to true, Amazon.Lambda.TestTool will updated/installed during AppHost startup. Amazon.Lambda.TestTool is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
{ | ||
internal void AddCommandLineArguments(IList<object> arguments) | ||
{ | ||
arguments.Add("lambda-test-tool"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question on tool name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also didn't we change the behavior so that you need to specify the port for the emulator to run? won't this error out as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed in sync meeting.
{ | ||
if (builder.Resources.FirstOrDefault(x => x.TryGetAnnotationsOfType<LambdaEmulatorAnnotation>(out _)) is not ExecutableResource serviceEmulator) | ||
/// <summary> | ||
/// Add the Lambda service emulator resource. The AddAWSLambdaFunction method will automatically add the Lambda service emulator if it hasn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add doc references to "AddAWSLambdaFunction" and "LambdaEmulatorOptions"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
private async Task<string> GetCurrentInstalledVersionAsync(CancellationToken cancellationToken) | ||
{ | ||
var results = await processCommandService.RunProcessAndCaptureOuputAsync(logger, "dotnet", "lambda-test-tool --tool-info", cancellationToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need to update based on other PR changes aws/aws-lambda-dotnet#1969
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
dbba606
to
0de32d3
Compare
Description of changes:
If the Lambda service emulator is added there will be a check made to see if Amazon.Lambda.TestTool is installed and up to date. If not then it will be installed via the
dotnet tool install
command.The Lambda service emulator is added to the collection resources as part of the first invoke of
AddAWSLambdaFunction
. If the user wants to customize the installation or disable it they can call the newAddAWSLambdaServiceEmulator
method before callingAddAWSLambdaFunction
. TheAddAWSLambdaServiceEmulator
takes in anLambdaEmulatorOptions
that allows disabling the auto install, overriding the version to install or allowing downgrading the version. By default if a newer version of the tooling is already installed then what the Aspire.Hosting.AWS is looking for we will allow assuming the user knows what they are doing.While going through the area I did some minor clean work.
This PR is depending on the Amazon.Lambda.TestTool [PR#](aws/aws-lambda-dotnet#1969) that adds a new
--tool-info
switch that Aspire can used to get metadata about the currently installed version.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.