Skip to content
Draft
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
13 changes: 12 additions & 1 deletion source/Calamari/ArgoCD/Git/AuthenticatingRepositoryFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Calamari.Common.Commands;
using Calamari.Common.Plumbing;
using Calamari.Common.Plumbing.Logging;
using Octopus.Calamari.Contracts.ArgoCD;

Expand Down Expand Up @@ -29,6 +31,15 @@ public AuthenticatingRepositoryFactory(
public RepositoryWrapper CloneRepository(string requestedUrl, string targetRevision)
{
var gitCredential = gitCredentials.GetValueOrDefault(requestedUrl);

if (gitCredential is SshKeyGitCredentialDto && CalamariEnvironment.IsRunningOnWindows)
{
throw new CommandException(
$"Cannot clone '{requestedUrl}' using an SSH key credential: "
+ "SSH git credentials are not supported when Calamari is running on Windows. "
+ "Supply a username/password credential for this repository, or run the deployment on a Linux worker.");
}

switch (gitCredential)
{
case GitCredentialDto passwordCredential:
Expand Down Expand Up @@ -61,4 +72,4 @@ public RepositoryWrapper CloneRepository(string requestedUrl, string targetRevis
var anonGitConnection = new HttpsGitConnection(null, null, GitCloneSafeUrl.ConvertToUriString(requestedUrl), GitReference.CreateFromString(targetRevision));
return repositoryFactory.CloneRepository(UniqueRepoNameGenerator.Generate(), anonGitConnection);
}
}
}