Skip to content
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

Include Executable WithArgs in manifest #1366

Merged
merged 4 commits into from
Dec 13, 2023

Conversation

Kahbazi
Copy link
Member

@Kahbazi Kahbazi commented Dec 12, 2023

Fixes #1362

Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-codeflow for labeling automated codeflow. intentionally a different color! label Dec 12, 2023
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Dec 12, 2023
}
}

if (args.Count > 0)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously if ExecutableResource.Args was empty the "args" would be in the manifest with an empty array. I changed this to not include the args to be consistence with Container manifest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test to verify this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/// <param name="builder">The resource builder.</param>
/// <param name="args">The arguments to be passed to the executable when it is started.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
public static IResourceBuilder<T> WithArgs<T>(this IResourceBuilder<T> builder, params string[] args) where T : ExecutableResource
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this from #1363 to be able to produce the bug and write test for it.

{
context.Writer.WriteStartArray("args");

foreach (var arg in args ?? [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

args will never be null here now right, so you can avoid the ??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -103,6 +103,32 @@ public void EnsureContainerWithArgsEmitsContainerArgs()
arg => Assert.Equal("more", arg.GetString()));
}

[Fact]
public void EnsureExecutableWithArgsEmitsExecutableArgs()
Copy link
Member

@DamianEdwards DamianEdwards Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a variant that ensures args are added via the extension method even if the resource itself had no args when defined.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good.

@mitchdenny
Copy link
Member

Thanks for the contribution @Kahbazi!

Kahbazi pushed a commit to Kahbazi/aspire that referenced this pull request Dec 13, 2023
@Kahbazi Kahbazi deleted the kahbazi/WithArgsInManifest branch December 13, 2023 09:13
@github-actions github-actions bot locked and limited conversation to collaborators Apr 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-codeflow for labeling automated codeflow. intentionally a different color! community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Args added to executable resources via the WithArgs() extension method are not written to the manifest
3 participants