Skip to content

Commit 4f9d1d6

Browse files
authored
Update Argo CD Dto's (#1767)
* Update argo CD dto's * Fix compile
1 parent 5539d2d commit 4f9d1d6

File tree

4 files changed

+35
-65
lines changed

4 files changed

+35
-65
lines changed

source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,21 @@ public void Init()
6363
nonSensitiveCalamariVariables.Add(SpecialVariables.Git.CommitMessageSummary, "Commit Summary");
6464
nonSensitiveCalamariVariables.Add(SpecialVariables.Git.CommitMessageDescription, "Commit Description");
6565

66-
var argoCdCustomPropertiesDto = new ArgoCDCustomPropertiesDto(new[]
67-
{
66+
var argoCdCustomPropertiesDto = new ArgoCDCustomPropertiesDto(
67+
[
68+
new ArgoCDGatewayDto(GatewayId, "Gateway1")
69+
],
70+
[
6871
new ArgoCDApplicationDto(GatewayId,
6972
"App1",
7073
"argocd",
7174
"yaml",
7275
"docker.io",
7376
null)
74-
},
75-
new GitCredentialDto[]
76-
{
77+
],
78+
[
7779
new GitCredentialDto(new Uri(OriginPath).AbsoluteUri, "", "")
78-
});
80+
]);
7981
customPropertiesLoader.Load<ArgoCDCustomPropertiesDto>().Returns(argoCdCustomPropertiesDto);
8082

8183
argoCdApplicationFromYaml = new Application()

source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,21 @@ public void Init()
5959
nonSensitiveCalamariVariables.Add(SpecialVariables.Git.CommitMessageSummary, "Commit Summary");
6060
nonSensitiveCalamariVariables.Add(SpecialVariables.Git.CommitMessageDescription, "Commit Description");
6161

62-
var argoCdCustomPropertiesDto = new ArgoCDCustomPropertiesDto(new[]
63-
{
62+
var argoCdCustomPropertiesDto = new ArgoCDCustomPropertiesDto(
63+
[
64+
new ArgoCDGatewayDto(GatewayId, "Gateway1")
65+
],
66+
[
6467
new ArgoCDApplicationDto(GatewayId,
6568
"App1",
6669
"argocd",
6770
"yaml",
6871
"docker.io",
6972
"http://my-argo.com")
70-
},
71-
new GitCredentialDto[]
72-
{
73+
],
74+
[
7375
new GitCredentialDto(new Uri(OriginPath).AbsoluteUri, "", "")
74-
});
76+
]);
7577
customPropertiesLoader.Load<ArgoCDCustomPropertiesDto>().Returns(argoCdCustomPropertiesDto);
7678

7779
var argoCdApplicationFromYaml = new ArgoCDApplicationBuilder()

source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,21 @@ public void Init()
5757
originRepo = RepositoryHelpers.CreateBareRepository(OriginPath);
5858
RepositoryHelpers.CreateBranchIn(argoCDBranchName, OriginPath);
5959

60-
var argoCdCustomPropertiesDto = new ArgoCDCustomPropertiesDto(new[]
61-
{
60+
var argoCdCustomPropertiesDto = new ArgoCDCustomPropertiesDto(
61+
[
62+
new ArgoCDGatewayDto(GatewayId, "Gateway1")
63+
],
64+
[
6265
new ArgoCDApplicationDto(GatewayId,
6366
"App1",
6467
"argocd",
6568
"yaml",
6669
"docker.io",
6770
"http://my-argo.com")
68-
},
69-
new GitCredentialDto[]
70-
{
71+
],
72+
[
7173
new GitCredentialDto(new Uri(RepoUrl).AbsoluteUri, "", "")
72-
});
74+
]);
7375
customPropertiesLoader.Load<ArgoCDCustomPropertiesDto>().Returns(argoCdCustomPropertiesDto);
7476

7577
var argoCdApplicationFromYaml = new ArgoCDApplicationBuilder()
Lines changed: 11 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,17 @@
11
#nullable enable
2-
using System.Collections.Generic;
32

3+
namespace Calamari.ArgoCD.Dtos;
44

5-
namespace Calamari.ArgoCD.Dtos
6-
{
7-
public class ArgoCDCustomPropertiesDto
8-
{
9-
public ArgoCDCustomPropertiesDto(ArgoCDApplicationDto[] applications, GitCredentialDto[] credentials)
10-
{
11-
Applications = applications;
12-
Credentials = credentials;
13-
}
5+
public record ArgoCDCustomPropertiesDto(ArgoCDGatewayDto[] Gateways, ArgoCDApplicationDto[] Applications, GitCredentialDto[] Credentials);
146

15-
public ArgoCDApplicationDto[] Applications { get; }
16-
public GitCredentialDto[] Credentials { get; }
17-
}
7+
public record ArgoCDGatewayDto(string Id, string Name);
188

19-
public class ArgoCDApplicationDto
20-
{
21-
public ArgoCDApplicationDto(string gatewayId, string name, string kubernetesNamespace, string manifest, string defaultRegistry, string? instanceWebUIUrl)
22-
{
23-
GatewayId = gatewayId;
24-
Name = name;
25-
KubernetesNamespace = kubernetesNamespace;
26-
DefaultRegistry = defaultRegistry;
27-
InstanceWebUiUrl = instanceWebUIUrl;
28-
Manifest = manifest;
29-
}
9+
public record ArgoCDApplicationDto(
10+
string GatewayId,
11+
string Name,
12+
string KubernetesNamespace,
13+
string Manifest,
14+
string DefaultRegistry,
15+
string? InstanceWebUiUrl);
3016

31-
public string GatewayId { get; }
32-
public string Name { get; }
33-
34-
public string KubernetesNamespace { get; }
35-
public string DefaultRegistry { get; set; }
36-
public string? InstanceWebUiUrl { get; }
37-
public string Manifest { get; }
38-
}
39-
40-
public class GitCredentialDto
41-
{
42-
public GitCredentialDto(string url, string username, string password)
43-
{
44-
Url = url;
45-
Username = username;
46-
Password = password;
47-
}
48-
49-
public string Url { get; }
50-
public string Username { get; }
51-
public string Password { get; }
52-
}
53-
}
17+
public record GitCredentialDto(string Url, string Username, string Password);

0 commit comments

Comments
 (0)