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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.10
2.0.11
48 changes: 21 additions & 27 deletions src/VirtualClient/VirtualClient.Main/BootstrapPackageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ namespace VirtualClient
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using VirtualClient.Contracts;
Expand All @@ -16,15 +14,15 @@ namespace VirtualClient
/// Command executes the operations to bootstrap/install dependencies on the system
/// prior to running a Virtual Client profile.
/// </summary>
public class BootstrapPackageCommand : CommandBase
internal class BootstrapPackageCommand : ExecuteProfileCommand
{
/// <summary>
/// The name of the package to bootstrap/install.
/// The name (logical name) to use when registering the package.
/// </summary>
public string Name { get; set; }

/// <summary>
/// The logical name of the package to bootstrap/install.
/// The name of the package (in storage) to bootstrap/install.
/// </summary>
public string Package { get; set; }

Expand All @@ -36,31 +34,27 @@ public class BootstrapPackageCommand : CommandBase
/// <returns>The exit code for the command operations.</returns>
public override Task<int> ExecuteAsync(string[] args, CancellationTokenSource cancellationTokenSource)
{
ExecuteProfileCommand profileExecutionCommand = new ExecuteProfileCommand
string registerAsName = this.Name;
if (String.IsNullOrWhiteSpace(registerAsName))
{
ClientId = this.ClientId,
ContentStore = this.ContentStore,
Verbose = this.Verbose,
Timeout = ProfileTiming.OneIteration(),
EventHubStore = this.EventHubStore,
ExecutionSystem = this.ExecutionSystem,
ExperimentId = this.ExperimentId,
InstallDependencies = true,
Metadata = this.Metadata,
PackageStore = this.PackageStore,
Parameters = new Dictionary<string, IConvertible>
{
{ "Package", this.Package },
{ "RegisterAsName", this.Name }
},
Profiles = new List<DependencyProfileReference>
{
new DependencyProfileReference("BOOTSTRAP-DEPENDENCIES.json")
},
ProxyApiUri = this.ProxyApiUri
registerAsName = Path.GetFileNameWithoutExtension(this.Package);
}

this.Timeout = ProfileTiming.OneIteration();
this.Profiles = new List<DependencyProfileReference>
{
new DependencyProfileReference("BOOTSTRAP-DEPENDENCIES.json")
};

return profileExecutionCommand.ExecuteAsync(args, cancellationTokenSource);
if (this.Parameters == null)
{
this.Parameters = new Dictionary<string, IConvertible>(StringComparer.OrdinalIgnoreCase);
}

this.Parameters["Package"] = this.Package;
this.Parameters["RegisterAsName"] = registerAsName;

return base.ExecuteAsync(args, cancellationTokenSource);
}
}
}
1 change: 1 addition & 0 deletions src/VirtualClient/VirtualClient.Main/CommandBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public abstract class CommandBase
/// </summary>
protected CommandBase()
{
this.CertificateManager = new CertificateManager();
}

/// <summary>
Expand Down
15 changes: 12 additions & 3 deletions src/VirtualClient/VirtualClient.Main/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,6 @@ internal static CommandLineBuilder SetupCommandLine(string[] args, CancellationT
// --package
OptionFactory.CreatePackageOption(required: true),

// --name
OptionFactory.CreateNameOption(required: true),

// OPTIONAL
// -------------------------------------------------------------------
// --clean
Expand All @@ -342,9 +339,18 @@ internal static CommandLineBuilder SetupCommandLine(string[] args, CancellationT
// --experiment-id
OptionFactory.CreateExperimentIdOption(required: false, Guid.NewGuid().ToString()),

// --iterations (for integration only. not used/always = 1)
OptionFactory.CreateIterationsOption(required: false),

// --layout-path (for integration only. not used.)
OptionFactory.CreateLayoutPathOption(required: false),

// --metadata
OptionFactory.CreateMetadataOption(required: false),

// --name
OptionFactory.CreateNameOption(required: false),

// --log-dir
OptionFactory.CreateLogDirectoryOption(required: false),

Expand All @@ -360,6 +366,9 @@ internal static CommandLineBuilder SetupCommandLine(string[] args, CancellationT
// --package-dir
OptionFactory.CreatePackageDirectoryOption(required: false),

// --parameters
OptionFactory.CreateParametersOption(required: false),

// --package-store
OptionFactory.CreatePackageStoreOption(required: false),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public void VirtualClientDefaultCommandSupportsAllExpectedOptions(string option,
[TestCase("--packagestore", "https://anystorageaccount.blob.core.windows.net/?sv=2020-08-04&ss=b")]
[TestCase("--packages", "https://anystorageaccount.blob.core.windows.net/?sv=2020-08-04&ss=b")]
[TestCase("--ps", "https://anystorageaccount.blob.core.windows.net/?sv=2020-08-04&ss=b")]
[TestCase("--parameters", "Param1=Value1,,,Param2=Value2")]
[TestCase("--state-dir", "C:\\any\\path\\to\\state")]
[TestCase("--sdir", "C:\\any\\path\\to\\state")]
[TestCase("--system", "Azure")]
Expand Down Expand Up @@ -355,6 +356,29 @@ public void VirtualClientBootstrapCommandSupportsAllExpectedOptions(string optio
}
}

[Test]
public void VirtualClientBootstrapCommandHandlesNoOpArguments()
{
using (CancellationTokenSource cancellationSource = new CancellationTokenSource())
{
List<string> arguments = new List<string>()
{
"bootstrap",
"--package", "anypackage.1.0.0.zip",
"--iterations", "1",
"--layoutPath", "/home/user/any/layout.json"
};

Assert.DoesNotThrow(() =>
{
ParseResult result = Program.SetupCommandLine(arguments.ToArray(), cancellationSource).Build().Parse(arguments);
Assert.IsFalse(result.Errors.Any());
result.ThrowOnUsageError();
});
}
}


[Test]
[TestCase("--clean", null)]
[TestCase("--clean", "all")]
Expand Down
Loading