Skip to content

Commit

Permalink
Merge pull request #1617 from opentap/1589-make-tap-image-browsable
Browse files Browse the repository at this point in the history
1589 make tap image browsable
  • Loading branch information
Oeh1995 committed Jun 20, 2024
2 parents 0c96c5e + 670b0d7 commit 6d5eb66
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
3 changes: 1 addition & 2 deletions Engine.UnitTests/TestTestSteps/PipingProcessStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public class RequestObject
[Submit] public string Answer { get; set; }
}

[CommandLineArgument("answers", ShortName = "a",
Description = "The answers that the caller is intending to give.")]
[CommandLineArgument("answers", ShortName = "a", Description = "The answers that the caller is intending to give.")]
public string[] ExpectedAnswers { get; set; }

private static TraceSource log = Log.CreateSource(nameof(UserInputTestAction));
Expand Down
31 changes: 15 additions & 16 deletions Package/PackageActions/ImageInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,34 @@

namespace OpenTap.Package
{
[Browsable(false)]
[Display("install", Group: "image")]
[Display("install", Description: "Install the specified image, overwriting the existing installation.", Group: "image")]
internal class ImageInstallAction : IsolatedPackageAction
{
/// <summary>
/// Path to Image file containing XML or JSON formatted Image specification, or just the string itself, e.g "REST-API,TUI:beta".
/// </summary>
[UnnamedCommandLineArgument("image")]
[UnnamedCommandLineArgument("image", Required = true)]
public string ImagePath { get; set; }

/// <summary>
/// Option to merge with target installation. Default is false, which means overwrite installation
/// </summary>
[CommandLineArgument("merge")]
[CommandLineArgument("merge", Description = "Merge the requested image with the existing installation instead of overwriting it.")]
public bool Merge { get; set; }

/// <summary> Never prompt for user input. </summary>
[CommandLineArgument("non-interactive", Description = "Never prompt for user input.")]
public bool NonInteractive { get; set; } = false;

/// <summary> Which operative system to resolve packages for. </summary>
[CommandLineArgument("os", Description = "Specify which operative system to resolve packages for.")]
[CommandLineArgument("os", Description = "The operating system to resolve packages for.")]
public string Os { get; set; }

/// <summary> Which CPU architecture to resolve packages for. </summary>
[CommandLineArgument("architecture", Description = "Specify which architecture to resolve packages for.")]
[CommandLineArgument("architecture", Description = "The architecture to resolve packages for.")]
public CpuArchitecture Architecture { get; set; } = CpuArchitecture.Unspecified;
/// <summary> dry-run - resolve, but don't install the packages. </summary>

/// <summary> Resolve and print a summary of the changes that would be applied, but don't apply them. </summary>
[CommandLineArgument("dry-run", Description = "Only print the result, don't install the packages.")]
public bool DryRun { get; set; }

Expand All @@ -55,14 +54,14 @@ protected override int LockedExecute(CancellationToken cancellationToken)

if (string.IsNullOrEmpty(ImagePath))
throw new ArgumentException("'image' not specified.", nameof(ImagePath));

var imageString = ImagePath;
if (File.Exists(imageString))
imageString = File.ReadAllText(imageString);
var imageSpecifier = ImageSpecifier.FromString(imageString);

// image specifies any repositories?
if(imageSpecifier.Repositories?.Any() != true)
if (imageSpecifier.Repositories?.Any() != true)
{
if (Repositories?.Any() == true)
imageSpecifier.Repositories = Repositories.ToList();
Expand All @@ -80,7 +79,7 @@ protected override int LockedExecute(CancellationToken cancellationToken)

if (!string.IsNullOrWhiteSpace(Os))
imageSpecifier.OS = Os;
if (Architecture!= CpuArchitecture.Unspecified)
if (Architecture != CpuArchitecture.Unspecified)
imageSpecifier.Architecture = Architecture;


Expand All @@ -105,7 +104,7 @@ protected override int LockedExecute(CancellationToken cancellationToken)
// or if the package cache has been cleared by the user, and an image install is attempted
// without the original source repository of some package.
imageSpecifier.AdditionalPackages.AddRange(new Installation(Target).GetPackages());

image = imageSpecifier.Resolve(TapThread.Current.AbortToken);
}

Expand All @@ -128,7 +127,7 @@ protected override int LockedExecute(CancellationToken cancellationToken)
throw new OperationCanceledException("Image installation was canceled.");
}
}

log.Debug("Image hash: {0}", image.Id);
if (DryRun)
{
Expand All @@ -152,7 +151,7 @@ protected override int LockedExecute(CancellationToken cancellationToken)
}

}

enum WipeInstallationResponse
{
No,
Expand Down

0 comments on commit 6d5eb66

Please sign in to comment.