audit, advisories and doctors/setup work
This commit is contained in:
95
src/Cli/StellaOps.Cli/Commands/ImageCommandGroup.cs
Normal file
95
src/Cli/StellaOps.Cli/Commands/ImageCommandGroup.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System.CommandLine;
|
||||
using StellaOps.Cli.Configuration;
|
||||
|
||||
namespace StellaOps.Cli.Commands;
|
||||
|
||||
internal static class ImageCommandGroup
|
||||
{
|
||||
internal static Command BuildImageCommand(
|
||||
IServiceProvider services,
|
||||
StellaOpsCliOptions options,
|
||||
Option<bool> verboseOption,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var image = new Command("image", "OCI image operations");
|
||||
image.Add(BuildInspectCommand(services, options, verboseOption, cancellationToken));
|
||||
return image;
|
||||
}
|
||||
|
||||
private static Command BuildInspectCommand(
|
||||
IServiceProvider services,
|
||||
StellaOpsCliOptions options,
|
||||
Option<bool> verboseOption,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var referenceArg = new Argument<string>("reference")
|
||||
{
|
||||
Description = "Image reference (e.g., nginx:latest, ghcr.io/org/app@sha256:...)"
|
||||
};
|
||||
|
||||
var resolveIndexOption = new Option<bool>("--resolve-index", new[] { "-r" })
|
||||
{
|
||||
Description = "Resolve multi-arch index to platform manifests"
|
||||
};
|
||||
resolveIndexOption.SetDefaultValue(true);
|
||||
|
||||
var printLayersOption = new Option<bool>("--print-layers", new[] { "-l" })
|
||||
{
|
||||
Description = "Include layer details in output"
|
||||
};
|
||||
printLayersOption.SetDefaultValue(true);
|
||||
|
||||
var platformOption = new Option<string?>("--platform", new[] { "-p" })
|
||||
{
|
||||
Description = "Filter to specific platform (e.g., linux/amd64)"
|
||||
};
|
||||
|
||||
var outputOption = new Option<string>("--output", new[] { "-o" })
|
||||
{
|
||||
Description = "Output format: table (default), json"
|
||||
};
|
||||
outputOption.SetDefaultValue("table");
|
||||
outputOption.FromAmong("table", "json");
|
||||
|
||||
var timeoutOption = new Option<int>("--timeout")
|
||||
{
|
||||
Description = "Request timeout in seconds (default: 60)"
|
||||
};
|
||||
timeoutOption.SetDefaultValue(60);
|
||||
|
||||
var inspect = new Command("inspect", "Inspect OCI image manifest and layers")
|
||||
{
|
||||
referenceArg,
|
||||
resolveIndexOption,
|
||||
printLayersOption,
|
||||
platformOption,
|
||||
outputOption,
|
||||
timeoutOption,
|
||||
verboseOption
|
||||
};
|
||||
|
||||
inspect.SetAction(async (parseResult, _) =>
|
||||
{
|
||||
var reference = parseResult.GetValue(referenceArg) ?? string.Empty;
|
||||
var resolveIndex = parseResult.GetValue(resolveIndexOption);
|
||||
var printLayers = parseResult.GetValue(printLayersOption);
|
||||
var platform = parseResult.GetValue(platformOption);
|
||||
var output = parseResult.GetValue(outputOption) ?? "table";
|
||||
var timeoutSeconds = parseResult.GetValue(timeoutOption);
|
||||
var verbose = parseResult.GetValue(verboseOption);
|
||||
|
||||
return await CommandHandlers.HandleInspectImageAsync(
|
||||
services,
|
||||
reference,
|
||||
resolveIndex,
|
||||
printLayers,
|
||||
platform,
|
||||
output,
|
||||
timeoutSeconds,
|
||||
verbose,
|
||||
cancellationToken);
|
||||
});
|
||||
|
||||
return inspect;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user