diff --git a/source/Calamari.AzureResourceGroup.Tests/Calamari.AzureResourceGroup.Tests.csproj b/source/Calamari.AzureResourceGroup.Tests/Calamari.AzureResourceGroup.Tests.csproj
index 15226288c6..2fc21b020a 100644
--- a/source/Calamari.AzureResourceGroup.Tests/Calamari.AzureResourceGroup.Tests.csproj
+++ b/source/Calamari.AzureResourceGroup.Tests/Calamari.AzureResourceGroup.Tests.csproj
@@ -11,23 +11,9 @@
-
-
-
-
- false
- Octopus.Dependencies.AzureCLI.nupkg
- true
- true
- true
- contentFiles/any/any/Octopus.Dependencies.AzureCLI.nupkg
- PreserveNewest
-
-
-
diff --git a/source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs b/source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs
index 1bd5c2213f..989bcad678 100644
--- a/source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs
+++ b/source/Calamari.AzureResourceGroup.Tests/DeployAzureBicepTemplateCommandFixture.cs
@@ -11,7 +11,6 @@
using Calamari.Testing;
using Calamari.Testing.Azure;
using Calamari.Testing.Helpers;
-using Calamari.Testing.Tools;
using NUnit.Framework;
namespace Calamari.AzureResourceGroup.Tests
@@ -32,8 +31,6 @@ class DeployAzureBicepTemplateCommandFixture
readonly string packagePath = TestEnvironment.GetTestPath("Packages", "Bicep");
SubscriptionResource subscriptionResource;
- static IDeploymentTool AzureCLI = new InPathDeploymentTool("Octopus.Dependencies.AzureCLI", "AzureCLI\\wbin");
-
[OneTimeSetUp]
public async Task Setup()
{
@@ -142,8 +139,6 @@ await CommandTestBuilder.CreateAsync()
void AddDefaults(CommandTestBuilderContext context)
{
- context.WithTool(AzureCLI);
-
context.Variables.Add(AzureScripting.SpecialVariables.Account.AccountType, "AzureServicePrincipal");
context.Variables.Add(AzureAccountVariables.SubscriptionId, subscriptionId);
context.Variables.Add(AzureAccountVariables.TenantId, tenantId);
diff --git a/source/Calamari.AzureScripting.Tests/AzurePowershellCommandFixture.cs b/source/Calamari.AzureScripting.Tests/AzurePowershellCommandFixture.cs
index d762cf6c21..a38d6d25fc 100644
--- a/source/Calamari.AzureScripting.Tests/AzurePowershellCommandFixture.cs
+++ b/source/Calamari.AzureScripting.Tests/AzurePowershellCommandFixture.cs
@@ -7,7 +7,6 @@
using NUnit.Framework;
using Calamari.Testing;
using Calamari.Testing.Requirements;
-using Calamari.Testing.Tools;
namespace Calamari.AzureScripting.Tests
{
@@ -19,14 +18,6 @@ class AzurePowerShellCommandFixture
string? tenantId;
string? subscriptionId;
- static IDeploymentTool AzureCLI = new InPathDeploymentTool("Octopus.Dependencies.AzureCLI", "AzureCLI\\wbin");
- static IDeploymentTool AzureCmdlets = new BoostrapperModuleDeploymentTool("Octopus.Dependencies.AzureCmdlets",
- new[]
- {
- "Powershell\\Azure.Storage\\4.6.1",
- "Powershell\\Azure\\5.3.0",
- "Powershell",
- });
static readonly CancellationTokenSource CancellationTokenSource = new CancellationTokenSource();
readonly CancellationToken cancellationToken = CancellationTokenSource.Token;
@@ -113,8 +104,6 @@ void AddDefaults(CommandTestBuilderContext context)
context.Variables.Add(SpecialVariables.Action.Azure.TenantId, tenantId);
context.Variables.Add(SpecialVariables.Action.Azure.ClientId, clientId);
context.Variables.Add(SpecialVariables.Action.Azure.Password, clientSecret);
- context.WithTool(AzureCLI);
- context.WithTool(AzureCmdlets);
}
}
}
\ No newline at end of file
diff --git a/source/Calamari.AzureScripting.Tests/Calamari.AzureScripting.Tests.csproj b/source/Calamari.AzureScripting.Tests/Calamari.AzureScripting.Tests.csproj
index cc004f8bfd..4c49804386 100644
--- a/source/Calamari.AzureScripting.Tests/Calamari.AzureScripting.Tests.csproj
+++ b/source/Calamari.AzureScripting.Tests/Calamari.AzureScripting.Tests.csproj
@@ -18,34 +18,7 @@
-
-
-
-
-
-
-
-
- false
- Octopus.Dependencies.AzureCLI.nupkg
- true
- true
- true
- contentFiles/any/any/Octopus.Dependencies.AzureCLI.nupkg
- PreserveNewest
-
-
- false
- Octopus.Dependencies.AzureCmdlets.nupkg
- true
- true
- true
- contentFiles/any/any/Octopus.Dependencies.AzureCmdlets.nupkg
- PreserveNewest
-
-
-
diff --git a/source/Calamari.Terraform.Tests/Calamari.Terraform.Tests.csproj b/source/Calamari.Terraform.Tests/Calamari.Terraform.Tests.csproj
index 033202e388..93c8eacfdb 100644
--- a/source/Calamari.Terraform.Tests/Calamari.Terraform.Tests.csproj
+++ b/source/Calamari.Terraform.Tests/Calamari.Terraform.Tests.csproj
@@ -19,7 +19,6 @@
-
diff --git a/source/Calamari.Testing/CommandTestBuilder.cs b/source/Calamari.Testing/CommandTestBuilder.cs
index 53f2fe2547..ba20280b59 100644
--- a/source/Calamari.Testing/CommandTestBuilder.cs
+++ b/source/Calamari.Testing/CommandTestBuilder.cs
@@ -159,49 +159,6 @@ List GetArgs(string workingPath)
return args;
}
- List InstallTools(string toolsPath)
- {
- var extractor = new NupkgExtractor(new InMemoryLog());
-
- var modulePaths = new List();
- var addToPath = new List();
- var platform = "win-x64";
-
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- platform = "linux-x64";
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
- platform = "osx-x64";
-
- foreach (var tool in context.Tools)
- {
- var toolPath = Path.Combine(toolsPath, tool.Id);
- modulePaths.AddRange(tool.GetCompatiblePackage(platform)
- .SelectValueOr(package => package.BootstrapperModulePaths, Enumerable.Empty())
- .Select(s => Path.Combine(toolPath, s)));
-
- var toolPackagePath = Path.Combine(Path.GetDirectoryName(AssemblyExtensions.FullLocalPath(Assembly.GetExecutingAssembly())) ?? string.Empty, $"{tool.Id}.nupkg");
- if (!File.Exists(toolPackagePath))
- throw new Exception($"{tool.Id}.nupkg missing.");
-
- extractor.Extract(toolPackagePath, toolPath);
- var fullPathToTool = tool.SubFolder.None()
- ? toolPath
- : Path.Combine(toolPath, tool.SubFolder.Value);
- if (tool.ToolPathVariableToSet.Some())
- context.Variables[tool.ToolPathVariableToSet.Value] = fullPathToTool
- .Replace("$HOME", "#{env:HOME}")
- .Replace("$TentacleHome", "#{env:TentacleHome}");
-
- if (tool.AddToPath)
- addToPath.Add(fullPathToTool);
- }
-
- var modules = string.Join(";", modulePaths);
- context.Variables["Octopus.Calamari.Bootstrapper.ModulePaths"] = modules;
-
- return addToPath;
- }
-
void Copy(string sourcePath, string destinationPath)
{
foreach (var dirPath in Directory.EnumerateDirectories(sourcePath, "*", SearchOption.AllDirectories))
@@ -243,7 +200,7 @@ void CopyFilesToWorkingFolder(string workingPath)
}
}
- async Task ExecuteActionHandler(List args, string workingFolder, List paths)
+ async Task ExecuteActionHandler(List args, string workingFolder)
{
var inMemoryLog = new InMemoryLog();
var constructor = typeof(TCalamariProgram).GetConstructor(
@@ -267,8 +224,7 @@ async Task ExecuteActionHandler(List args, st
throw new Exception($"{typeof(TCalamariProgram).Name}.Run method was not found.");
}
- var exitCode = await ExecuteWrapped(paths,
- async () =>
+ var exitCode = await ExecuteWrapped(async () =>
{
if (methodInfo.ReturnType.IsGenericType)
return await (Task)methodInfo.Invoke(instance, new object?[] { args.ToArray() })!;
@@ -312,13 +268,12 @@ async Task ExecuteActionHandler(List args, st
Environment.CurrentDirectory = workingPath;
using var toolsBasePath = TemporaryDirectory.Create();
- var paths = InstallTools(toolsBasePath.DirectoryPath);
var args = GetArgs(workingPath);
CopyFilesToWorkingFolder(workingPath);
- result = await ExecuteActionHandler(args, workingPath, paths);
+ result = await ExecuteActionHandler(args, workingPath);
if (assertWasSuccess)
{
@@ -335,23 +290,8 @@ async Task ExecuteActionHandler(List args, st
return result;
}
- async Task ExecuteWrapped(IReadOnlyCollection paths, Func> func)
+ async Task ExecuteWrapped( Func> func)
{
- if (paths.Count > 0)
- {
- var originalPath = Environment.GetEnvironmentVariable("PATH");
- try
- {
- Environment.SetEnvironmentVariable("PATH", $"{originalPath}{Path.PathSeparator}{string.Join(Path.PathSeparator.ToString(), paths)}", EnvironmentVariableTarget.Process);
-
- return await func();
- }
- finally
- {
- Environment.SetEnvironmentVariable("PATH", originalPath, EnvironmentVariableTarget.Process);
- }
- }
-
return await func();
}
}
diff --git a/source/Calamari.Testing/CommandTestBuilderContext.cs b/source/Calamari.Testing/CommandTestBuilderContext.cs
index 4ce5d742e2..acf6058e1b 100644
--- a/source/Calamari.Testing/CommandTestBuilderContext.cs
+++ b/source/Calamari.Testing/CommandTestBuilderContext.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.IO;
using Calamari.Common.Plumbing.Extensions;
-using Calamari.Testing.Tools;
using Octostache;
namespace Calamari.Testing
@@ -11,7 +10,6 @@ public class CommandTestBuilderContext
{
public List<(string? filename, Stream contents)> Files = new List<(string?, Stream)>();
- public List Tools { get; } = new();
internal bool withStagedPackageArgument;
@@ -52,11 +50,5 @@ public CommandTestBuilderContext WithDataFile(Stream fileContents, string? fileN
Files.Add((fileName, fileContents));
return this;
}
-
- public CommandTestBuilderContext WithTool(IDeploymentTool tool)
- {
- Tools.Add(tool);
- return this;
- }
}
}
\ No newline at end of file
diff --git a/source/Calamari.Testing/Tools/BootstrapperModuleDeploymentTool.cs b/source/Calamari.Testing/Tools/BootstrapperModuleDeploymentTool.cs
deleted file mode 100644
index c12c2f0f61..0000000000
--- a/source/Calamari.Testing/Tools/BootstrapperModuleDeploymentTool.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System.Collections.Generic;
-using Octopus.CoreUtilities;
-
-namespace Calamari.Testing.Tools;
-
-public class BoostrapperModuleDeploymentTool : IDeploymentTool
-{
- private readonly IReadOnlyList modulePaths;
-
- public BoostrapperModuleDeploymentTool(
- string id,
- IReadOnlyList modulePaths,
- params string[] supportedPlatforms)
- {
- this.modulePaths = modulePaths;
- this.Id = id;
- this.SupportedPlatforms = supportedPlatforms ?? new string[0];
- }
-
- public string Id { get; }
-
- public Maybe SubFolder => Maybe.None;
-
- public bool AddToPath => false;
-
- public Maybe ToolPathVariableToSet => Maybe.None;
-
- public string[] SupportedPlatforms { get; }
-
- public Maybe GetCompatiblePackage(
- string platform)
- {
- return platform != "win-x64" && platform != "netfx" ? Maybe.None : new DeploymentToolPackage((IDeploymentTool) this, this.Id, this.modulePaths).AsSome();
- }
-}
\ No newline at end of file
diff --git a/source/Calamari.Testing/Tools/IDeploymentTool.cs b/source/Calamari.Testing/Tools/IDeploymentTool.cs
deleted file mode 100644
index a3cb6cea0a..0000000000
--- a/source/Calamari.Testing/Tools/IDeploymentTool.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Octopus.CoreUtilities;
-
-namespace Calamari.Testing.Tools
-{
- //TODO: This is pulled in from Sashimi.Server.Contracts as an attempt to run Calamari Commands with Tools. Ideally this wouldn't be duplicated.
- public interface IDeploymentTool
- {
- string Id { get; }
- Maybe SubFolder { get; }
- bool AddToPath { get; }
- Maybe ToolPathVariableToSet { get; }
- string[] SupportedPlatforms { get; }
- Maybe GetCompatiblePackage(string platform);
- }
-
- public class DeploymentToolPackage
- {
- public DeploymentToolPackage(IDeploymentTool tool, string id)
- {
- Tool = tool;
- Id = id;
- BootstrapperModulePaths = new string[0];
- }
-
- public DeploymentToolPackage(IDeploymentTool tool, string id, IReadOnlyList modulePaths)
- {
- Tool = tool;
- Id = id;
- BootstrapperModulePaths = modulePaths;
- }
-
- public IDeploymentTool Tool { get; }
- public string Id { get; }
- public IReadOnlyList BootstrapperModulePaths { get; set; }
- }
-}
\ No newline at end of file
diff --git a/source/Calamari.Testing/Tools/InPathDeploymentTool.cs b/source/Calamari.Testing/Tools/InPathDeploymentTool.cs
deleted file mode 100644
index e72d71a2fb..0000000000
--- a/source/Calamari.Testing/Tools/InPathDeploymentTool.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using System;
-using Octopus.CoreUtilities;
-
-namespace Calamari.Testing.Tools;
-
-public class InPathDeploymentTool : IDeploymentTool
-{
- public InPathDeploymentTool(
- string id,
- string? subFolder = null,
- string? toolPathVariableToSet = null,
- string[]? supportedPlatforms = null)
- {
- this.Id = id;
- this.SubFolder = subFolder == null ? Maybe.None : Maybe.Some(subFolder);
- this.ToolPathVariableToSet = toolPathVariableToSet == null ? Maybe.None : Maybe.Some(toolPathVariableToSet);
- this.SupportedPlatforms = supportedPlatforms ?? new string[0];
- }
-
- public string Id { get; }
-
- public Maybe SubFolder { get; }
-
- public bool AddToPath => true;
-
- public Maybe ToolPathVariableToSet { get; }
-
- public string[] SupportedPlatforms { get; }
-
- public virtual Maybe GetCompatiblePackage(
- string platform)
- {
- return new DeploymentToolPackage((IDeploymentTool) this, this.Id).AsSome();
- }
-}
\ No newline at end of file