-
Notifications
You must be signed in to change notification settings - Fork 34
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
Default the ContainerUser to rootless users on .NET 8 and above #393
Conversation
@@ -19,6 +19,8 @@ public class CapturingLogger : ILogger | |||
private List<BuildErrorEventArgs> _errors = new(); | |||
public IReadOnlyList<BuildErrorEventArgs> Errors {get { return _errors; } } | |||
|
|||
public List<string> AllMessages => Errors.Select(e => e.Message!).Concat(Warnings.Select(w => w.Message!)).Concat(Messages.Select(m => m.Message!)).ToList(); |
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.
Added this as a helper while debugging tests.
@@ -16,12 +16,13 @@ public class ParseContainerPropertiesTests | |||
[DockerDaemonAvailableFact] | |||
public void Baseline() | |||
{ | |||
var (project, _) = ProjectInitializer.InitProject(new () { | |||
var (project, _, d) = ProjectInitializer.InitProject(new () { |
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.
We need to dispose the ProjectCollection to ensure that the binlogs get written, again to help with debugging.
{ | ||
["NETCoreSdkVersion"] = sdkVersion, | ||
["_TargetFrameworkVersionWithoutV"] = tfm, | ||
["TargetFrameworkVersion"] = tfm, |
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 changed the ProjectInitializer to use TFM instead of the private property, and 'generate' the private property as part of the method call. This seemed less surprising.
[InlineData("v8.0", "linux-x64", "64198")] | ||
[InlineData("v8.0", "win-x64", "ContainerUser")] | ||
[InlineData("v7.0", "linux-x64", null)] | ||
[InlineData("v7.0", "win-x64", null)] | ||
[InlineData("v9.0", "linux-x64", "64198")] | ||
[InlineData("v9.0", "win-x64", "ContainerUser")] |
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.
Our boundary conditions are:
- 2 OS's
- 3 ranges - less than 8.0, 8.0 exactly, and greater than 8.0
So these 6 tests should cover all permutations.
@@ -11,6 +11,7 @@ | |||
OR $(NETCoreSdkVersion.Contains('-')) == false | |||
) | |||
)">true</_IsSDKContainerAllowedVersion> | |||
<_ContainerIsTargetingNet8TFM>$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '8.0'))</_ContainerIsTargetingNet8TFM> |
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.
Added a few private properties to make conditions read a bit easier.
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.
This looks good to me. Do we have an e2e test to cover this scenario?
@vlada-shubina added one now - but it introduced a bit of noise as I had to make some code changes to make analyzers in .NET 8 happy. |
Correction - I was able to write one locally but it would require us to move to a .NET 8 SDK - I'm not sure that we want to do this. The test build a net8.0 MinimalTestApp, set the user to |
Fix #373
Defaults the ContainerUser to platform-specific non-root users when targeting .NET 8 and above.