// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Globalization;
namespace Microsoft.Agents.AI.Tools.Shell;
///
/// UID/GID pair passed to docker run --user.
///
/// User ID (numeric string, e.g. "65534"; "root" or "0" selects the container's root user).
/// Group ID (numeric string).
public sealed record ContainerUser(string Uid, string Gid)
{
///
/// Default unprivileged user (nobody:nogroup on most distros, UID/GID 65534).
///
public static ContainerUser Default { get; } = new("65534", "65534");
///
/// Container root (UID/GID 0). Avoid in production; use only for diagnostics.
///
public static ContainerUser Root { get; } = new("0", "0");
/// Render as the uid:gid string Docker expects.
public override string ToString() => $"{this.Uid}:{this.Gid}";
///
/// Returns when this user maps to UID 0 (root).
///
public bool IsRoot =>
this.Uid.Equals("root", StringComparison.OrdinalIgnoreCase)
|| (int.TryParse(this.Uid, NumberStyles.Integer, CultureInfo.InvariantCulture, out var uid) && uid == 0);
}