Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ public sealed class ContainerFileSystemCallbackAnnotation : IResourceAnnotation
public required string DestinationPath { get; init; }

/// <summary>
/// The UID of the default owner for files/directories to be created or updated in the container. Defaults to 0 for root.
/// The UID of the default owner for files/directories to be created or updated in the container. The UID defaults to 0 for root if null.
/// </summary>
public int DefaultOwner { get; init; }
public int? DefaultOwner { get; init; }

/// <summary>
/// The GID of the default group for files/directories to be created or updated in the container. Defaults to 0 for root.
/// The GID of the default group for files/directories to be created or updated in the container. The GID defaults to 0 for root if null.
/// </summary>
public int DefaultGroup { get; init; }
public int? DefaultGroup { get; init; }

/// <summary>
/// The umask to apply to files or folders without an explicit mode permission. If set to null, a default umask value of 0022 (octal) will be used.
Expand Down
12 changes: 6 additions & 6 deletions src/Aspire.Hosting/ContainerResourceBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ public static IResourceBuilder<T> WithBuildSecret<T>(this IResourceBuilder<T> bu
/// <param name="builder">The resource builder for the container resource.</param>
/// <param name="destinationPath">The destination (absolute) path in the container.</param>
/// <param name="entries">The file system entries to create.</param>
/// <param name="defaultOwner">The default owner UID for the created or updated file system. Defaults to 0 for root.</param>
/// <param name="defaultGroup">The default group ID for the created or updated file system. Defaults to 0 for root.</param>
/// <param name="defaultOwner">The default owner UID for the created or updated file system. Defaults to 0 for root if not set.</param>
/// <param name="defaultGroup">The default group ID for the created or updated file system. Defaults to 0 for root if not set.</param>
/// <param name="umask">The umask <see cref="UnixFileMode"/> permissions to exclude from the default file and folder permissions. This takes away (rather than granting) default permissions to files and folders without an explicit mode permission set.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
/// <remarks>
Expand Down Expand Up @@ -741,7 +741,7 @@ public static IResourceBuilder<T> WithBuildSecret<T>(this IResourceBuilder<T> bu
/// defaultOwner: 1000);
/// </code>
/// </example>
public static IResourceBuilder<T> WithContainerFiles<T>(this IResourceBuilder<T> builder, string destinationPath, IEnumerable<ContainerFileSystemItem> entries, int defaultOwner = 0, int defaultGroup = 0, UnixFileMode? umask = null) where T : ContainerResource
public static IResourceBuilder<T> WithContainerFiles<T>(this IResourceBuilder<T> builder, string destinationPath, IEnumerable<ContainerFileSystemItem> entries, int? defaultOwner = null, int? defaultGroup = null, UnixFileMode? umask = null) where T : ContainerResource
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(destinationPath);
Expand Down Expand Up @@ -769,8 +769,8 @@ public static IResourceBuilder<T> WithContainerFiles<T>(this IResourceBuilder<T>
/// <param name="builder">The resource builder for the container resource.</param>
/// <param name="destinationPath">The destination (absolute) path in the container.</param>
/// <param name="callback">The callback that will be invoked when the resource is being created.</param>
/// <param name="defaultOwner">The default owner UID for the created or updated file system. Defaults to 0 for root.</param>
/// <param name="defaultGroup">The default group ID for the created or updated file system. Defaults to 0 for root.</param>
/// <param name="defaultOwner">The default owner UID for the created or updated file system. Defaults to 0 for root if not set.</param>
/// <param name="defaultGroup">The default group ID for the created or updated file system. Defaults to 0 for root if not set.</param>
/// <param name="umask">The umask <see cref="UnixFileMode"/> permissions to exclude from the default file and folder permissions. This takes away (rather than granting) default permissions to files and folders without an explicit mode permission set.</param>
/// <returns>The <see cref="IResourceBuilder{T}"/>.</returns>
/// <remarks>
Expand Down Expand Up @@ -814,7 +814,7 @@ public static IResourceBuilder<T> WithContainerFiles<T>(this IResourceBuilder<T>
/// });
/// </code>
/// </example>
public static IResourceBuilder<T> WithContainerFiles<T>(this IResourceBuilder<T> builder, string destinationPath, Func<ContainerFileSystemCallbackContext, CancellationToken, Task<IEnumerable<ContainerFileSystemItem>>> callback, int defaultOwner = 0, int defaultGroup = 0, UnixFileMode? umask = null) where T : ContainerResource
public static IResourceBuilder<T> WithContainerFiles<T>(this IResourceBuilder<T> builder, string destinationPath, Func<ContainerFileSystemCallbackContext, CancellationToken, Task<IEnumerable<ContainerFileSystemItem>>> callback, int? defaultOwner = null, int? defaultGroup = null, UnixFileMode? umask = null) where T : ContainerResource
{
ArgumentNullException.ThrowIfNull(builder);
ArgumentNullException.ThrowIfNull(destinationPath);
Expand Down
6 changes: 4 additions & 2 deletions src/Aspire.Hosting/Dcp/Model/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,13 @@ internal sealed class ContainerCreateFileSystem : IEquatable<ContainerCreateFile

// The default owner UID to use for created (or updated) file system entries. Defaults to 0 for root.
[JsonPropertyName("defaultOwner")]
public int DefaultOwner { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? DefaultOwner { get; set; }

// The default group GID to use for created (or updated) file system entries. Defaults to 0 for root.
[JsonPropertyName("defaultGroup")]
public int DefaultGroup { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? DefaultGroup { get; set; }

// The umask for created files and folders without explicit permissions set (defaults to 022 if null)
[JsonPropertyName("umask")]
Expand Down
8 changes: 4 additions & 4 deletions tests/Aspire.Hosting.PostgreSQL.Tests/AddPostgresTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ public async Task WithPostgresProducesValidServersJsonFile()

Assert.Equal("/pgadmin4", createServers.DestinationPath);
Assert.Null(createServers.Umask);
Assert.Equal(0, createServers.DefaultOwner);
Assert.Equal(0, createServers.DefaultGroup);
Assert.Null(createServers.DefaultOwner);
Assert.Null(createServers.DefaultGroup);

var entries = await createServers.Callback(new() { Model = pgadmin, ServiceProvider = app.Services }, CancellationToken.None);

Expand Down Expand Up @@ -547,8 +547,8 @@ public async Task WithPgwebProducesValidBookmarkFiles()

Assert.Equal("/", createBookmarks.DestinationPath);
Assert.Null(createBookmarks.Umask);
Assert.Equal(0, createBookmarks.DefaultOwner);
Assert.Equal(0, createBookmarks.DefaultGroup);
Assert.Null(createBookmarks.DefaultOwner);
Assert.Null(createBookmarks.DefaultGroup);

var entries = await createBookmarks.Callback(new() { Model = pgweb, ServiceProvider = app.Services }, CancellationToken.None);

Expand Down
Loading