Skip to content
This repository was archived by the owner on May 2, 2023. It is now read-only.
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
4 changes: 2 additions & 2 deletions source/Calamari/Calamari.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Calamari.Common" Version="18.1.0" />
<PackageReference Include="Calamari.Scripting" Version="9.0.0" />
<PackageReference Include="Calamari.Common" Version="19.1.0" />
<PackageReference Include="Calamari.Scripting" Version="11.0.0" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Scripts\*" />
Expand Down
15 changes: 8 additions & 7 deletions source/Sashimi.Tests/AzureActionHandlerExtensionsFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using NSubstitute;
using NUnit.Framework;
using Octopus.Server.Extensibility.HostServices.Diagnostics;
using Sashimi.Server.Contracts.ActionHandlers;
using Sashimi.Server.Contracts.CommandBuilders;
using Sashimi.Tests.Shared.Server;
Expand All @@ -20,7 +21,7 @@ public void AzureCmdletsToolAddedWhenBundledModulesTrue()
variables.Set(SpecialVariables.Action.Azure.UseBundledAzureModules, Boolean.TrueString);
context.Variables.Returns(variables);

builder.WithAzureTools(context);
builder.WithAzureTools(context, Substitute.For<ITaskLog>());
builder.Received().WithTool(AzureTools.AzureCmdlets);
}

Expand All @@ -34,7 +35,7 @@ public void AzureCmdletsToolExcludedWhenBundledModulesFalse()
variables.Set(SpecialVariables.Action.Azure.UseBundledAzureModules, Boolean.FalseString);
context.Variables.Returns(variables);

builder.WithAzureTools(context);
builder.WithAzureTools(context, Substitute.For<ITaskLog>());
builder.DidNotReceive().WithTool(AzureTools.AzureCmdlets);
}

Expand All @@ -48,7 +49,7 @@ public void AzureCmdletsToolAddedWhenLegacyVariableIsTrue()
variables.Set(SpecialVariables.Action.Azure.UseBundledAzureModulesLegacy, Boolean.TrueString);
context.Variables.Returns(variables);

builder.WithAzureTools(context);
builder.WithAzureTools(context, Substitute.For<ITaskLog>());
builder.Received().WithTool(AzureTools.AzureCmdlets);
}

Expand All @@ -62,7 +63,7 @@ public void AzureCmdletsToolExcludedWhenLegacyVariableIsFalse()
variables.Set(SpecialVariables.Action.Azure.UseBundledAzureModulesLegacy, Boolean.FalseString);
context.Variables.Returns(variables);

builder.WithAzureTools(context);
builder.WithAzureTools(context, Substitute.For<ITaskLog>());
builder.DidNotReceive().WithTool(AzureTools.AzureCmdlets);
}

Expand All @@ -77,7 +78,7 @@ public void AzureCmdletsWillIgnoreLegacyVariableWhenBundledModulesFalse()
variables.Set(SpecialVariables.Action.Azure.UseBundledAzureModules, Boolean.FalseString);
context.Variables.Returns(variables);

builder.WithAzureTools(context);
builder.WithAzureTools(context, Substitute.For<ITaskLog>());
builder.DidNotReceive().WithTool(AzureTools.AzureCmdlets);
}

Expand All @@ -92,7 +93,7 @@ public void AzureCmdletsWillIgnoreLegacyVariableWhenBundledModulesTrueAndLegacyI
variables.Set(SpecialVariables.Action.Azure.UseBundledAzureModules, Boolean.TrueString);
context.Variables.Returns(variables);

builder.WithAzureTools(context);
builder.WithAzureTools(context, Substitute.For<ITaskLog>());
builder.Received().WithTool(AzureTools.AzureCmdlets);
}

Expand All @@ -107,7 +108,7 @@ public void AzureCmdletsWillNotBeAddedWhenLegacyAndBundledModulesSetToFalse()
variables.Set(SpecialVariables.Action.Azure.UseBundledAzureModules, Boolean.FalseString);
context.Variables.Returns(variables);

builder.WithAzureTools(context);
builder.WithAzureTools(context, Substitute.For<ITaskLog>());
builder.DidNotReceive().WithTool(AzureTools.AzureCmdlets);
}
}
Expand Down
4 changes: 2 additions & 2 deletions source/Sashimi.Tests/Sashimi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.25" />
<PackageReference Include="Octopus.Server.Tests.Extensibility" Version="12.1.1" />
<PackageReference Include="Sashimi.Tests.Shared" Version="9.0.0" />
<PackageReference Include="Octopus.Server.Tests.Extensibility" Version="13.0.0" />
<PackageReference Include="Sashimi.Tests.Shared" Version="11.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 12 additions & 9 deletions source/Sashimi/AzureActionHandlerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Octopus.Server.Extensibility.HostServices.Diagnostics;
using Sashimi.Azure.Accounts;
using Sashimi.Server.Contracts;
using Sashimi.Server.Contracts.ActionHandlers;
using Sashimi.Server.Contracts.Calamari;
using Sashimi.Server.Contracts.CommandBuilders;

namespace Sashimi.AzureScripting
Expand All @@ -11,24 +11,26 @@ public static class AzureActionHandlerExtensions
{
public static ICalamariCommandBuilder WithAzureTools(
this ICalamariCommandBuilder builder,
IActionHandlerContext context)
IActionHandlerContext context,
ITaskLog taskLog)
{
return builder.WithAzureCmdlets(context).WithAzureCLI(context);
return builder.WithAzureCmdlets(context, taskLog).WithAzureCLI(context, taskLog);
}

public static ICalamariCommandBuilder WithCheckAccountIsNotManagementCertificate(this ICalamariCommandBuilder builder, IActionHandlerContext context)
public static ICalamariCommandBuilder WithCheckAccountIsNotManagementCertificate(this ICalamariCommandBuilder builder, IActionHandlerContext context, ITaskLog taskLog)
{
if (context.Variables.Get(SpecialVariables.AccountType) != AccountTypes.AzureServicePrincipalAccountType.ToString())
{
context.Log.Warn("Azure have announced they will be retiring Service Management API support on June 30th 2018. Please switch to using Service Principals for your Octopus Azure accounts https://g.octopushq.com/AzureServicePrincipalAccount");
taskLog.Warn("Azure have announced they will be retiring Service Management API support on June 30th 2018. Please switch to using Service Principals for your Octopus Azure accounts https://g.octopushq.com/AzureServicePrincipalAccount");
}

return builder;
}

public static ICalamariCommandBuilder WithAzureCmdlets(
this ICalamariCommandBuilder builder,
IActionHandlerContext context)
IActionHandlerContext context,
ITaskLog taskLog)
{
// This is the new value that the user can set on the step. It and the legacy variable both default to true, if either are false then
// we don't include the tooling.
Expand All @@ -39,7 +41,7 @@ public static ICalamariCommandBuilder WithAzureCmdlets(
if (legacyModuleBundling == false)
{
// user has explicitly used the legacy flag to switch off bundling, tell them it's available on the step now
context.Log.Warn($"The {SpecialVariables.Action.Azure.UseBundledAzureModules} variable has been used to disable using the bundled Azure PowerShell modules. Note that this variable is deprecated and will be removed in a future version, please use the bundling options on the step to control this behavior now.");
taskLog.Warn($"The {SpecialVariables.Action.Azure.UseBundledAzureModules} variable has been used to disable using the bundled Azure PowerShell modules. Note that this variable is deprecated and will be removed in a future version, please use the bundling options on the step to control this behavior now.");
}

if (useBundledTooling && legacyModuleBundling)
Expand All @@ -50,7 +52,8 @@ public static ICalamariCommandBuilder WithAzureCmdlets(

public static ICalamariCommandBuilder WithAzureCLI(
this ICalamariCommandBuilder builder,
IActionHandlerContext context)
IActionHandlerContext context,
ITaskLog taskLog)
{
// This is the new value that the user can set on the step. It and the legacy variable both default to true, if either are false then
// we don't include the tooling.
Expand All @@ -61,7 +64,7 @@ public static ICalamariCommandBuilder WithAzureCLI(
if (legacyCliBundling == false)
{
// user has explicitly used the legacy flag to switch off bundling, tell them it's available on the step now
context.Log.Warn($"The {SpecialVariables.Action.Azure.UseBundledAzureCLI} variable has been used to disable using the bundled Azure CLI. Note that this variable is deprecated and will be removed in a future version, please use the bundling options on the step to control this behavior now.");
taskLog.Warn($"The {SpecialVariables.Action.Azure.UseBundledAzureCLI} variable has been used to disable using the bundled Azure CLI. Note that this variable is deprecated and will be removed in a future version, please use the bundling options on the step to control this behavior now.");
}

if (useBundledTooling && legacyCliBundling)
Expand Down
9 changes: 5 additions & 4 deletions source/Sashimi/AzurePowerShellActionHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Octopus.Server.Extensibility.HostServices.Diagnostics;
using Sashimi.Server.Contracts;
using Sashimi.Server.Contracts.ActionHandlers;

Expand All @@ -16,23 +17,23 @@ public class AzurePowerShellActionHandler : IActionHandlerWithAccount
public ActionHandlerCategory[] Categories => new[] { ActionHandlerCategory.BuiltInStep, AzureConstants.AzureActionHandlerCategory, ActionHandlerCategory.Script };
public string[] StepBasedVariableNameForAccountIds { get; } = {SpecialVariables.Action.Azure.AccountId};

public IActionHandlerResult Execute(IActionHandlerContext context)
public IActionHandlerResult Execute(IActionHandlerContext context, ITaskLog taskLog)
{
var syntax = context.Variables.GetEnum(KnownVariables.Action.Script.Syntax, ScriptSyntax.PowerShell);

var builder = context.CalamariCommand(AzureConstants.CalamariAzure, "run-script")
.WithAzureCLI(context);
.WithAzureCLI(context, taskLog);

if (syntax == ScriptSyntax.PowerShell)
builder = builder.WithAzureCmdlets(context);
builder = builder.WithAzureCmdlets(context, taskLog);

var isInPackage = KnownVariableValues.Action.Script.ScriptSource.Package.Equals(context.Variables.Get(KnownVariables.Action.Script.ScriptSource), StringComparison.OrdinalIgnoreCase);
if (isInPackage)
{
builder.WithStagedPackageArgument();
}

return builder.Execute();
return builder.Execute(taskLog);
}
}
}
6 changes: 3 additions & 3 deletions source/Sashimi/Sashimi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<ItemGroup>
<PackageReference Include="Octopus.Dependencies.AzureCLI" Version="2.0.50" />
<PackageReference Include="Octopus.Dependencies.AzureCmdlets" Version="6.13.1" />
<PackageReference Include="Sashimi.Azure.Common" Version="9.0.0" />
<PackageReference Include="Sashimi.Azure.Accounts" Version="9.0.0" />
<PackageReference Include="Sashimi.Server.Contracts" Version="9.0.0" />
<PackageReference Include="Sashimi.Azure.Common" Version="11.0.0" />
<PackageReference Include="Sashimi.Azure.Accounts" Version="11.0.0" />
<PackageReference Include="Sashimi.Server.Contracts" Version="11.0.0" />
</ItemGroup>
<Target Name="GetPackageFiles" AfterTargets="ResolveReferences" DependsOnTargets="RunResolvePackageDependencies">
<Message Text="Collecting nupkg packages to bundle with Sashimi module binaries" Importance="high" />
Expand Down