Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public void AnonymousCloneWhenNoCredentialsMatch()
public class SshUrlTests : AuthenticatingRepositoryFactoryTestBase
{
[Test]
// SSH not currently functional on Windows
[Category(TestCategory.CompatibleOS.OnlyNixOrMac)]
public void SshCredentialBranch_IsSelectedAndDispatchesSshKeyGitConnection()
{
// Use an ssh:// URL so the new strict validation allows it, and mock the factory
Expand Down Expand Up @@ -108,6 +110,8 @@ public void HttpsCredentialTakesPriorityOverSshWhenBothMatchAnSshUrl()
}

[Test]
// SSH not currently functional on Windows
[Category(TestCategory.CompatibleOS.OnlyNixOrMac)]
public void KnownHostsFromDtoAreCarriedOntoSshKeyGitConnection()
{
const string sshUrl = "ssh://git@github.com/org/repo.git";
Expand Down
2 changes: 2 additions & 0 deletions source/Calamari.Tests/ArgoCD/Git/RepositoryFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public void CanCloneAnExistingRepositoryAtHEADAndAssociatedFiles()
}

[Test]
// SSH not currently functional on Windows
[Category(TestCategory.CompatibleOS.OnlyNixOrMac)]
public void CloningSshKeyGitConnectionDoesNotResolveAPullRequestClientAndLogsVerboseMessage()
{
var filename = "sshTest.txt";
Expand Down
4 changes: 3 additions & 1 deletion source/Calamari/ArgoCD/Git/RepositoryFactory.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using Calamari.ArgoCD.Git.PullRequests;
using Calamari.Common.Commands;
using Calamari.Common.Plumbing;
using Calamari.Common.Plumbing.Extensions;
using Calamari.Common.Plumbing.FileSystem;
using Calamari.Common.Plumbing.Logging;
Expand Down Expand Up @@ -48,6 +48,8 @@ public RepositoryFactory(ILog log, ICalamariFileSystem fileSystem, string reposi

public RepositoryWrapper CloneRepository(string repositoryName, IGitConnection gitConnection)
{
WindowsSshKeys.AssertSupported(gitConnection);

var repositoryPath = Path.Combine(repositoryParentDirectory, repositoryName);
fileSystem.CreateDirectory(repositoryPath);

Expand Down
20 changes: 20 additions & 0 deletions source/Calamari/ArgoCD/Git/WindowsSshKeys.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using Calamari.Common.Plumbing;
using NuGet.Commands;

namespace Calamari.ArgoCD.Git;

// Our fork LibGit2Sharp uses WinCNG for it's SSH support, and WinCNG does not support some keys.
// This first implementation blocks on all as we want to get the feature out for Linux first and
// we'll come back to attempt to handle it more gracefully at a later date.
public class WindowsSshKeys
{
public static void AssertSupported(IGitConnection? connection)
{
if (!CalamariEnvironment.IsRunningOnWindows) return;
if (connection is not SshKeyGitConnection) return;

throw new CommandException(
"SSH credentials are not currently supported for Git operations running on Windows. Use HTTPS credentials (username + password or PAT) instead or run the deployment on a Linux worker.");
}
}