From 5978de197bcb82d3079a142bcccd741918b81f01 Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Wed, 6 May 2026 17:44:50 +1000 Subject: [PATCH 1/9] Move service messages to contracts --- .../ArgoCD/ArgoCDCustomPropertiesDto.cs | 2 +- .../ArgoCD/ServiceMessages.cs | 18 +++++++ .../Kubernetes/ServiceMessages.cs | 39 +++++++++++++++ .../KubernetesFixtures/Helm3UpgradeFixture.cs | 15 +++--- .../ManifestReporterTests.cs | 5 +- .../ResourceUpdateReporterTests.cs | 9 ++-- .../ArgoCD/ArgoCDFilesUpdatedReporter.cs | 5 +- .../Calamari/Kubernetes/ManifestReporter.cs | 7 +-- .../ResourceStatus/ResourceUpdateReporter.cs | 5 +- .../Calamari/Kubernetes/SpecialVariables.cs | 48 +------------------ 10 files changed, 85 insertions(+), 68 deletions(-) create mode 100644 source/Calamari.Contracts/ArgoCD/ServiceMessages.cs create mode 100644 source/Calamari.Contracts/Kubernetes/ServiceMessages.cs diff --git a/source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs b/source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs index c05d1c106f..b4a5ebc806 100644 --- a/source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs +++ b/source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs @@ -14,4 +14,4 @@ public record ArgoCDApplicationDto( string DefaultRegistry, string? InstanceWebUiUrl); -public record GitCredentialDto(string Url, string Username, string Password); +public record GitCredentialDto(string Url, string Username, string Password); \ No newline at end of file diff --git a/source/Calamari.Contracts/ArgoCD/ServiceMessages.cs b/source/Calamari.Contracts/ArgoCD/ServiceMessages.cs new file mode 100644 index 0000000000..794a4f2d4b --- /dev/null +++ b/source/Calamari.Contracts/ArgoCD/ServiceMessages.cs @@ -0,0 +1,18 @@ +using System; + +namespace Octopus.Calamari.Contracts.ArgoCD; + +public static class ServiceMessages +{ + public static class ArgoCDFilesUpdated + { + public const string Name = "argocd-files-updated"; + + public static class Attributes + { + public const string GatewayId = "gatewayId"; + public const string ApplicationName = "applicationName"; + public const string Sources = "sources"; + } + } +} \ No newline at end of file diff --git a/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs b/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs new file mode 100644 index 0000000000..ab92e0e4bc --- /dev/null +++ b/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs @@ -0,0 +1,39 @@ +using System; + +namespace Octopus.Calamari.Contracts.Kubernetes; + +public static class ServiceMessages +{ + public static class ResourceStatus + { + public const string Name = "k8s-status"; + + public static class Attributes + { + public const string Type = "type"; + public const string ActionId = "actionId"; + public const string StepName = "stepName"; + public const string TaskId = "taskId"; + public const string TargetId = "targetId"; + public const string TargetName = "targetName"; + public const string SpaceId = "spaceId"; + public const string Uuid = "uuid"; + public const string Group = "group"; + public const string Version = "version"; + public const string Kind = "kind"; + public const string Name = "name"; + public const string Namespace = "namespace"; + public const string Status = "status"; + public const string Data = "data"; + public const string Removed = "removed"; + public const string CheckCount = "checkCount"; + } + } + + public static class ManifestApplied + { + public const string Name = "k8s-manifest-applied"; + public const string ManifestAttribute = "manifest"; + public const string NamespaceAttribute = "ns"; + } +} \ No newline at end of file diff --git a/source/Calamari.Tests/KubernetesFixtures/Helm3UpgradeFixture.cs b/source/Calamari.Tests/KubernetesFixtures/Helm3UpgradeFixture.cs index a6e2130ab5..a322c90a67 100644 --- a/source/Calamari.Tests/KubernetesFixtures/Helm3UpgradeFixture.cs +++ b/source/Calamari.Tests/KubernetesFixtures/Helm3UpgradeFixture.cs @@ -7,6 +7,7 @@ using Calamari.Testing.Requirements; using FluentAssertions; using NUnit.Framework; +using Octopus.Calamari.Contracts.Kubernetes; namespace Calamari.Tests.KubernetesFixtures { @@ -65,14 +66,14 @@ public void HelmVersionNewerThanMinimumVersion_ReportsObjectStatus() result.AssertOutputMatches("Resource Status Check: Stopped."); result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) .Should() .HaveCountGreaterOrEqualTo(1); result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) .Should() - .Contain(sm => sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Name] == $"mychart-configmap-{ReleaseName}" && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Namespace] == Namespace && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Group] == "" && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Version] == "v1" && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Kind] == "ConfigMap" && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Status] == Kubernetes.ResourceStatus.Resources.ResourceStatus.Successful.ToString()); + .Contain(sm => sm.Properties[ServiceMessages.ResourceStatus.Attributes.Name] == $"mychart-configmap-{ReleaseName}" && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Namespace] == Namespace && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Group] == "" && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Version] == "v1" && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Kind] == "ConfigMap" && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Status] == Kubernetes.ResourceStatus.Resources.ResourceStatus.Successful.ToString()); } [Test] @@ -99,7 +100,7 @@ public async Task HelmVersionOlderThanMinimumVersion_DoesNotRunObjectStatus() result.AssertOutputMatches("Octopus needs Helm v3.13 or later to display object status and manifests."); result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) .Should() .BeEmpty(); } @@ -128,7 +129,7 @@ public void HooksOnlyPackage_RetrievesEmptyManifestButDoesNotReportObjectStatus( //we should not have received any KOS service messages result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) .Should() .BeEmpty(); } @@ -156,7 +157,7 @@ public void EmptyChart_RetrievesEmptyManifestButDoesNotReportObjectStatus() //we should not have received any KOS service messages result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) .Should() .BeEmpty(); } @@ -183,7 +184,7 @@ public void TargetingANamespaceThatDoesNotExistAbortsTheManifestSearchingLoop() //we should not have received any KOS service messages result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) .Should() .BeEmpty(); } diff --git a/source/Calamari.Tests/KubernetesFixtures/ManifestReporterTests.cs b/source/Calamari.Tests/KubernetesFixtures/ManifestReporterTests.cs index 3c4bd6646d..11c6f3a911 100644 --- a/source/Calamari.Tests/KubernetesFixtures/ManifestReporterTests.cs +++ b/source/Calamari.Tests/KubernetesFixtures/ManifestReporterTests.cs @@ -12,6 +12,7 @@ using FluentAssertions; using NSubstitute; using NUnit.Framework; +using Octopus.Calamari.Contracts.Kubernetes; using YamlDotNet.RepresentationModel; namespace Calamari.Tests.KubernetesFixtures @@ -44,7 +45,7 @@ public void GivenValidYaml_ShouldPostSingleServiceMessage() mr.ReportManifestFileApplied(filePath); - var expected = ServiceMessage.Create(SpecialVariables.ServiceMessages.ManifestApplied.Name, ("ns", "default"), ("manifest", yaml)); + var expected = ServiceMessage.Create(ServiceMessages.ManifestApplied.Name, ("ns", "default"), ("manifest", yaml)); memoryLog.ServiceMessages.Should().BeEquivalentTo(new List { expected }); } } @@ -109,7 +110,7 @@ public void GivenValidYamlString_ShouldPostSingleServiceMessage() mr.ReportManifestApplied(yaml); - var expected = ServiceMessage.Create(SpecialVariables.ServiceMessages.ManifestApplied.Name, ("ns", "default"), ("manifest", expectedYaml)); + var expected = ServiceMessage.Create(ServiceMessages.ManifestApplied.Name, ("ns", "default"), ("manifest", expectedYaml)); memoryLog.ServiceMessages.Should().BeEquivalentTo(new List { expected }); } diff --git a/source/Calamari.Tests/KubernetesFixtures/ResourceStatus/ResourceUpdateReporterTests.cs b/source/Calamari.Tests/KubernetesFixtures/ResourceStatus/ResourceUpdateReporterTests.cs index bf106c3b56..351bd3ad2d 100644 --- a/source/Calamari.Tests/KubernetesFixtures/ResourceStatus/ResourceUpdateReporterTests.cs +++ b/source/Calamari.Tests/KubernetesFixtures/ResourceStatus/ResourceUpdateReporterTests.cs @@ -7,6 +7,7 @@ using Calamari.Testing.Helpers; using FluentAssertions; using NUnit.Framework; +using Octopus.Calamari.Contracts.Kubernetes; namespace Calamari.Tests.KubernetesFixtures.ResourceStatus { @@ -29,7 +30,7 @@ public void ReportsCreatedResourcesCorrectly() reporter.ReportUpdatedResources(originalStatuses, newStatuses, 1); var serviceMessages = log.ServiceMessages - .Where(message => message.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(message => message.Name == ServiceMessages.ResourceStatus.Name) .ToList(); serviceMessages.Select(message => message.Properties["name"]) @@ -72,7 +73,7 @@ public void ReportsUpdatedResourcesCorrectly() reporter.ReportUpdatedResources(originalStatuses, newStatuses, 1); var serviceMessages = log.ServiceMessages - .Where(message => message.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(message => message.Name == ServiceMessages.ResourceStatus.Name) .ToList(); serviceMessages.Should().ContainSingle().Which.Properties @@ -102,7 +103,7 @@ public void ReportsRemovedResourcesCorrectly() reporter.ReportUpdatedResources(originalStatuses, newStatuses, 1); var serviceMessages = log.ServiceMessages - .Where(message => message.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(message => message.Name == ServiceMessages.ResourceStatus.Name) .ToList(); serviceMessages.Should().ContainSingle().Which.Properties @@ -132,7 +133,7 @@ public void ClusterScopedResourcesAreIncluded() reporter.ReportUpdatedResources(new Dictionary(), newStatuses, 1); var serviceMessages = log.ServiceMessages - .Where(message => message.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) + .Where(message => message.Name == ServiceMessages.ResourceStatus.Name) .ToList(); serviceMessages.Should().Contain(sm => sm.Properties.Intersect(new[] diff --git a/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs b/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs index ebf06cdc9c..ded28b7427 100644 --- a/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs +++ b/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs @@ -7,7 +7,8 @@ using Calamari.Common.Plumbing.Logging; using Calamari.Common.Plumbing.ServiceMessages; using Calamari.Kubernetes; -using ArgoCDFilesUpdatedAttributes = Calamari.Kubernetes.SpecialVariables.ServiceMessages.ArgoCDFilesUpdated.Attributes; +using Octopus.Calamari.Contracts.ArgoCD; +using ArgoCDFilesUpdatedAttributes = Octopus.Calamari.Contracts.ArgoCD.ServiceMessages.ArgoCDFilesUpdated.Attributes; namespace Calamari.ArgoCD { @@ -38,7 +39,7 @@ public void ReportFilesUpdated(GitCommitParameters gitCommitParameters, IReadOnl }; var message = new ServiceMessage( - SpecialVariables.ServiceMessages.ArgoCDFilesUpdated.Name, + ServiceMessages.ArgoCDFilesUpdated.Name, parameters); log.WriteServiceMessage(message); diff --git a/source/Calamari/Kubernetes/ManifestReporter.cs b/source/Calamari/Kubernetes/ManifestReporter.cs index 69cc5ba21e..6e16be563b 100644 --- a/source/Calamari/Kubernetes/ManifestReporter.cs +++ b/source/Calamari/Kubernetes/ManifestReporter.cs @@ -6,6 +6,7 @@ using Calamari.Common.Plumbing.Logging; using Calamari.Common.Plumbing.ServiceMessages; using Calamari.Common.Plumbing.Variables; +using Octopus.Calamari.Contracts.Kubernetes; using YamlDotNet.Core; using YamlDotNet.RepresentationModel; using YamlDotNet.Serialization; @@ -94,11 +95,11 @@ void ReportManifestStreamApplied(YamlStream yamlStream) var ns = namespaceResolver.ResolveNamespace(rootNode, variables); var message = new ServiceMessage( - SpecialVariables.ServiceMessages.ManifestApplied.Name, + ServiceMessages.ManifestApplied.Name, new Dictionary { - { SpecialVariables.ServiceMessages.ManifestApplied.ManifestAttribute, updatedDocument }, - { SpecialVariables.ServiceMessages.ManifestApplied.NamespaceAttribute, ns } + { ServiceMessages.ManifestApplied.ManifestAttribute, updatedDocument }, + { ServiceMessages.ManifestApplied.NamespaceAttribute, ns } }); log.WriteServiceMessage(message); diff --git a/source/Calamari/Kubernetes/ResourceStatus/ResourceUpdateReporter.cs b/source/Calamari/Kubernetes/ResourceStatus/ResourceUpdateReporter.cs index 4f51147fda..f6a8c62910 100644 --- a/source/Calamari/Kubernetes/ResourceStatus/ResourceUpdateReporter.cs +++ b/source/Calamari/Kubernetes/ResourceStatus/ResourceUpdateReporter.cs @@ -6,7 +6,8 @@ using Calamari.Common.Plumbing.Variables; using Calamari.Kubernetes.ResourceStatus.Resources; using Newtonsoft.Json; -using ResourceStatusAttributes = Calamari.Kubernetes.SpecialVariables.ServiceMessages.ResourceStatus.Attributes; +using Octopus.Calamari.Contracts.Kubernetes; +using ResourceStatusAttributes = Octopus.Calamari.Contracts.Kubernetes.ServiceMessages.ResourceStatus.Attributes; namespace Calamari.Kubernetes.ResourceStatus { @@ -97,7 +98,7 @@ private void SendServiceMessage(Resource resource, bool removed, int checkCount) {ResourceStatusAttributes.CheckCount, checkCount.ToString()} }; - var message = new ServiceMessage(SpecialVariables.ServiceMessages.ResourceStatus.Name, parameters); + var message = new ServiceMessage(ServiceMessages.ResourceStatus.Name, parameters); log.WriteServiceMessage(message); } } diff --git a/source/Calamari/Kubernetes/SpecialVariables.cs b/source/Calamari/Kubernetes/SpecialVariables.cs index 05b3d10586..3dfe759307 100644 --- a/source/Calamari/Kubernetes/SpecialVariables.cs +++ b/source/Calamari/Kubernetes/SpecialVariables.cs @@ -137,52 +137,6 @@ public record ApplicationSourceOutputVariables(int Index, ApplicationOutputVaria } } - public static class ServiceMessages - { - public static class ResourceStatus - { - public const string Name = "k8s-status"; - - public static class Attributes - { - public const string Type = "type"; - public const string ActionId = "actionId"; - public const string StepName = "stepName"; - public const string TaskId = "taskId"; - public const string TargetId = "targetId"; - public const string TargetName = "targetName"; - public const string SpaceId = "spaceId"; - public const string Uuid = "uuid"; - public const string Group = "group"; - public const string Version = "version"; - public const string Kind = "kind"; - public const string Name = "name"; - public const string Namespace = "namespace"; - public const string Status = "status"; - public const string Data = "data"; - public const string Removed = "removed"; - public const string CheckCount = "checkCount"; - } - } - - public static class ManifestApplied - { - public const string Name = "k8s-manifest-applied"; - public const string ManifestAttribute = "manifest"; - public const string NamespaceAttribute = "ns"; - } - - public static class ArgoCDFilesUpdated - { - public const string Name = "argocd-files-updated"; - - public static class Attributes - { - public const string GatewayId = "gatewayId"; - public const string ApplicationName = "applicationName"; - public const string Sources = "sources"; - } - } - } + } } \ No newline at end of file From f6232ab939cdb93a2c7d939d949dce9aa4bd407b Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Wed, 6 May 2026 17:47:35 +1000 Subject: [PATCH 2/9] Move file hashes to contracts --- source/Calamari.Contracts/ArgoCD/FileHash.cs | 5 +++++ source/Calamari.Contracts/ArgoCD/FileJsonPatch.cs | 5 +++++ .../Calamari.Contracts/ArgoCD/TrackedSourceDetail.cs | 10 ++++++++++ .../ArgoCD/ArgoCDFilesUpdatedReporterTests.cs | 1 + .../ManifestTemplating/CopyTemplatesSourceUpdater.cs | 1 + .../ManifestTemplating/ManifestUpdateResult.cs | 1 + .../ArgoCD/Conventions/SourceUpdateResult.cs | 1 + .../UpdateImageTag/AbstractHelmUpdater.cs | 1 + .../ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs | 1 + .../Conventions/UpdateImageTag/FileUpdateResult.cs | 1 + source/Calamari/ArgoCD/ProcessApplicationResult.cs | 12 +----------- 11 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 source/Calamari.Contracts/ArgoCD/FileHash.cs create mode 100644 source/Calamari.Contracts/ArgoCD/FileJsonPatch.cs create mode 100644 source/Calamari.Contracts/ArgoCD/TrackedSourceDetail.cs diff --git a/source/Calamari.Contracts/ArgoCD/FileHash.cs b/source/Calamari.Contracts/ArgoCD/FileHash.cs new file mode 100644 index 0000000000..3d37e4f5ec --- /dev/null +++ b/source/Calamari.Contracts/ArgoCD/FileHash.cs @@ -0,0 +1,5 @@ +using System; + +namespace Octopus.Calamari.Contracts.ArgoCD; + +public record FileHash(string FilePath, string Hash); \ No newline at end of file diff --git a/source/Calamari.Contracts/ArgoCD/FileJsonPatch.cs b/source/Calamari.Contracts/ArgoCD/FileJsonPatch.cs new file mode 100644 index 0000000000..1b5e418483 --- /dev/null +++ b/source/Calamari.Contracts/ArgoCD/FileJsonPatch.cs @@ -0,0 +1,5 @@ +using System; + +namespace Octopus.Calamari.Contracts.ArgoCD; + +public record FileJsonPatch(string FilePath, string JsonPatch); \ No newline at end of file diff --git a/source/Calamari.Contracts/ArgoCD/TrackedSourceDetail.cs b/source/Calamari.Contracts/ArgoCD/TrackedSourceDetail.cs new file mode 100644 index 0000000000..23a4fd81d8 --- /dev/null +++ b/source/Calamari.Contracts/ArgoCD/TrackedSourceDetail.cs @@ -0,0 +1,10 @@ +using System; + +namespace Octopus.Calamari.Contracts.ArgoCD; + +public record TrackedSourceDetail( + string? CommitSha, + DateTimeOffset? CommitTimestamp, + int SourceIndex, + List ReplacedFiles, + List PatchedFiles); \ No newline at end of file diff --git a/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs b/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs index 5805e1bab3..4cc5d0ba37 100644 --- a/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs +++ b/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs @@ -8,6 +8,7 @@ using Calamari.Testing.Helpers; using FluentAssertions; using NUnit.Framework; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.Tests.ArgoCD { diff --git a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs index f061a422f5..42c876a2a1 100644 --- a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs @@ -6,6 +6,7 @@ using Calamari.Common.Plumbing.Extensions; using Calamari.Common.Plumbing.FileSystem; using Calamari.Common.Plumbing.Logging; +using Octopus.Calamari.Contracts.ArgoCD; using Octopus.CoreUtilities.Extensions; namespace Calamari.ArgoCD.Conventions.ManifestTemplating; diff --git a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs index e9c05e5887..508436fd5e 100644 --- a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Collections.Generic; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.ManifestTemplating; diff --git a/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs index 89667949a2..06b38eff9e 100644 --- a/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Calamari.ArgoCD.Git; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs index c19af78bee..dfca12fec3 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs @@ -9,6 +9,7 @@ using Calamari.Common.Plumbing.FileSystem; using Calamari.Common.Plumbing.Logging; using Calamari.Kubernetes.Patching.JsonPatch; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.UpdateImageTag; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs index 0ccdb023fd..d621437803 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs @@ -11,6 +11,7 @@ using Calamari.Common.Plumbing.Logging; using Calamari.Kubernetes.Patching; using Calamari.Kubernetes.Patching.JsonPatch; +using Octopus.Calamari.Contracts.ArgoCD; using YamlDotNet.RepresentationModel; namespace Calamari.ArgoCD.Conventions.UpdateImageTag; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs index ebe71467c3..76a3eb6b47 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.UpdateImageTag; diff --git a/source/Calamari/ArgoCD/ProcessApplicationResult.cs b/source/Calamari/ArgoCD/ProcessApplicationResult.cs index abad5c14ed..dbc9dc71f0 100644 --- a/source/Calamari/ArgoCD/ProcessApplicationResult.cs +++ b/source/Calamari/ArgoCD/ProcessApplicationResult.cs @@ -3,20 +3,10 @@ using System.Collections.Generic; using System.Linq; using Calamari.ArgoCD.Models; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD { - public record FileHash(string FilePath, string Hash); - - public record FileJsonPatch(string FilePath, string JsonPatch); - - public record TrackedSourceDetail( - string? CommitSha, - DateTimeOffset? CommitTimestamp, - int SourceIndex, - List ReplacedFiles, - List PatchedFiles); - public class ProcessApplicationResult( string gatewayId, ApplicationName applicationName, From 2684e378312b2843f167e7c90ce630851bcb9d42 Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Thu, 7 May 2026 21:42:57 +1000 Subject: [PATCH 3/9] tweak --- source/Calamari.Contracts/Kubernetes/ServiceMessages.cs | 8 ++++++-- source/Calamari/Kubernetes/ManifestReporter.cs | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs b/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs index ab92e0e4bc..97aa2bd6d9 100644 --- a/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs +++ b/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs @@ -33,7 +33,11 @@ public static class Attributes public static class ManifestApplied { public const string Name = "k8s-manifest-applied"; - public const string ManifestAttribute = "manifest"; - public const string NamespaceAttribute = "ns"; + + public static class Attributes + { + public const string Manifest = "manifest"; + public const string Namespace = "ns"; + } } } \ No newline at end of file diff --git a/source/Calamari/Kubernetes/ManifestReporter.cs b/source/Calamari/Kubernetes/ManifestReporter.cs index 6e16be563b..2759949896 100644 --- a/source/Calamari/Kubernetes/ManifestReporter.cs +++ b/source/Calamari/Kubernetes/ManifestReporter.cs @@ -98,8 +98,8 @@ void ReportManifestStreamApplied(YamlStream yamlStream) ServiceMessages.ManifestApplied.Name, new Dictionary { - { ServiceMessages.ManifestApplied.ManifestAttribute, updatedDocument }, - { ServiceMessages.ManifestApplied.NamespaceAttribute, ns } + { ServiceMessages.ManifestApplied.Attributes.Manifest, updatedDocument }, + { ServiceMessages.ManifestApplied.Attributes.Namespace, ns } }); log.WriteServiceMessage(message); From 7f05e940568ca49c06b2604d31cc890532ea785a Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Tue, 2 Jun 2026 22:10:27 +1000 Subject: [PATCH 4/9] undo --- ...edSourceDetail.cs => SourceFileChanges.cs} | 2 +- .../Kubernetes/ServiceMessages.cs | 43 ------------------- .../KubernetesFixtures/Helm3UpgradeFixture.cs | 15 +++---- .../ManifestReporterTests.cs | 5 +-- .../ResourceUpdateReporterTests.cs | 9 ++-- .../CopyTemplatesSourceUpdater.cs | 1 - .../ManifestUpdateResult.cs | 1 - .../ArgoCD/Conventions/SourceUpdateResult.cs | 1 - .../UpdateImageTag/AbstractHelmUpdater.cs | 1 - .../Conventions/UpdateImageTag/BaseUpdater.cs | 1 - .../UpdateImageTag/FileUpdateResult.cs | 1 - .../ArgoCD/ProcessApplicationResult.cs | 12 +++++- .../Calamari/Kubernetes/ManifestReporter.cs | 7 ++- .../ResourceStatus/ResourceUpdateReporter.cs | 5 +-- .../Calamari/Kubernetes/SpecialVariables.cs | 36 +++++++++++++++- 15 files changed, 65 insertions(+), 75 deletions(-) rename source/Calamari.Contracts/ArgoCD/{TrackedSourceDetail.cs => SourceFileChanges.cs} (85%) delete mode 100644 source/Calamari.Contracts/Kubernetes/ServiceMessages.cs diff --git a/source/Calamari.Contracts/ArgoCD/TrackedSourceDetail.cs b/source/Calamari.Contracts/ArgoCD/SourceFileChanges.cs similarity index 85% rename from source/Calamari.Contracts/ArgoCD/TrackedSourceDetail.cs rename to source/Calamari.Contracts/ArgoCD/SourceFileChanges.cs index 23a4fd81d8..21adb0062d 100644 --- a/source/Calamari.Contracts/ArgoCD/TrackedSourceDetail.cs +++ b/source/Calamari.Contracts/ArgoCD/SourceFileChanges.cs @@ -2,7 +2,7 @@ namespace Octopus.Calamari.Contracts.ArgoCD; -public record TrackedSourceDetail( +public record SourceFileChanges( string? CommitSha, DateTimeOffset? CommitTimestamp, int SourceIndex, diff --git a/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs b/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs deleted file mode 100644 index 97aa2bd6d9..0000000000 --- a/source/Calamari.Contracts/Kubernetes/ServiceMessages.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; - -namespace Octopus.Calamari.Contracts.Kubernetes; - -public static class ServiceMessages -{ - public static class ResourceStatus - { - public const string Name = "k8s-status"; - - public static class Attributes - { - public const string Type = "type"; - public const string ActionId = "actionId"; - public const string StepName = "stepName"; - public const string TaskId = "taskId"; - public const string TargetId = "targetId"; - public const string TargetName = "targetName"; - public const string SpaceId = "spaceId"; - public const string Uuid = "uuid"; - public const string Group = "group"; - public const string Version = "version"; - public const string Kind = "kind"; - public const string Name = "name"; - public const string Namespace = "namespace"; - public const string Status = "status"; - public const string Data = "data"; - public const string Removed = "removed"; - public const string CheckCount = "checkCount"; - } - } - - public static class ManifestApplied - { - public const string Name = "k8s-manifest-applied"; - - public static class Attributes - { - public const string Manifest = "manifest"; - public const string Namespace = "ns"; - } - } -} \ No newline at end of file diff --git a/source/Calamari.Tests/KubernetesFixtures/Helm3UpgradeFixture.cs b/source/Calamari.Tests/KubernetesFixtures/Helm3UpgradeFixture.cs index a322c90a67..a6e2130ab5 100644 --- a/source/Calamari.Tests/KubernetesFixtures/Helm3UpgradeFixture.cs +++ b/source/Calamari.Tests/KubernetesFixtures/Helm3UpgradeFixture.cs @@ -7,7 +7,6 @@ using Calamari.Testing.Requirements; using FluentAssertions; using NUnit.Framework; -using Octopus.Calamari.Contracts.Kubernetes; namespace Calamari.Tests.KubernetesFixtures { @@ -66,14 +65,14 @@ public void HelmVersionNewerThanMinimumVersion_ReportsObjectStatus() result.AssertOutputMatches("Resource Status Check: Stopped."); result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .Should() .HaveCountGreaterOrEqualTo(1); result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .Should() - .Contain(sm => sm.Properties[ServiceMessages.ResourceStatus.Attributes.Name] == $"mychart-configmap-{ReleaseName}" && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Namespace] == Namespace && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Group] == "" && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Version] == "v1" && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Kind] == "ConfigMap" && sm.Properties[ServiceMessages.ResourceStatus.Attributes.Status] == Kubernetes.ResourceStatus.Resources.ResourceStatus.Successful.ToString()); + .Contain(sm => sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Name] == $"mychart-configmap-{ReleaseName}" && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Namespace] == Namespace && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Group] == "" && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Version] == "v1" && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Kind] == "ConfigMap" && sm.Properties[SpecialVariables.ServiceMessages.ResourceStatus.Attributes.Status] == Kubernetes.ResourceStatus.Resources.ResourceStatus.Successful.ToString()); } [Test] @@ -100,7 +99,7 @@ public async Task HelmVersionOlderThanMinimumVersion_DoesNotRunObjectStatus() result.AssertOutputMatches("Octopus needs Helm v3.13 or later to display object status and manifests."); result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .Should() .BeEmpty(); } @@ -129,7 +128,7 @@ public void HooksOnlyPackage_RetrievesEmptyManifestButDoesNotReportObjectStatus( //we should not have received any KOS service messages result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .Should() .BeEmpty(); } @@ -157,7 +156,7 @@ public void EmptyChart_RetrievesEmptyManifestButDoesNotReportObjectStatus() //we should not have received any KOS service messages result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .Should() .BeEmpty(); } @@ -184,7 +183,7 @@ public void TargetingANamespaceThatDoesNotExistAbortsTheManifestSearchingLoop() //we should not have received any KOS service messages result.CapturedOutput.ServiceMessages - .Where(sm => sm.Name == ServiceMessages.ResourceStatus.Name) + .Where(sm => sm.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .Should() .BeEmpty(); } diff --git a/source/Calamari.Tests/KubernetesFixtures/ManifestReporterTests.cs b/source/Calamari.Tests/KubernetesFixtures/ManifestReporterTests.cs index 11c6f3a911..3c4bd6646d 100644 --- a/source/Calamari.Tests/KubernetesFixtures/ManifestReporterTests.cs +++ b/source/Calamari.Tests/KubernetesFixtures/ManifestReporterTests.cs @@ -12,7 +12,6 @@ using FluentAssertions; using NSubstitute; using NUnit.Framework; -using Octopus.Calamari.Contracts.Kubernetes; using YamlDotNet.RepresentationModel; namespace Calamari.Tests.KubernetesFixtures @@ -45,7 +44,7 @@ public void GivenValidYaml_ShouldPostSingleServiceMessage() mr.ReportManifestFileApplied(filePath); - var expected = ServiceMessage.Create(ServiceMessages.ManifestApplied.Name, ("ns", "default"), ("manifest", yaml)); + var expected = ServiceMessage.Create(SpecialVariables.ServiceMessages.ManifestApplied.Name, ("ns", "default"), ("manifest", yaml)); memoryLog.ServiceMessages.Should().BeEquivalentTo(new List { expected }); } } @@ -110,7 +109,7 @@ public void GivenValidYamlString_ShouldPostSingleServiceMessage() mr.ReportManifestApplied(yaml); - var expected = ServiceMessage.Create(ServiceMessages.ManifestApplied.Name, ("ns", "default"), ("manifest", expectedYaml)); + var expected = ServiceMessage.Create(SpecialVariables.ServiceMessages.ManifestApplied.Name, ("ns", "default"), ("manifest", expectedYaml)); memoryLog.ServiceMessages.Should().BeEquivalentTo(new List { expected }); } diff --git a/source/Calamari.Tests/KubernetesFixtures/ResourceStatus/ResourceUpdateReporterTests.cs b/source/Calamari.Tests/KubernetesFixtures/ResourceStatus/ResourceUpdateReporterTests.cs index 351bd3ad2d..bf106c3b56 100644 --- a/source/Calamari.Tests/KubernetesFixtures/ResourceStatus/ResourceUpdateReporterTests.cs +++ b/source/Calamari.Tests/KubernetesFixtures/ResourceStatus/ResourceUpdateReporterTests.cs @@ -7,7 +7,6 @@ using Calamari.Testing.Helpers; using FluentAssertions; using NUnit.Framework; -using Octopus.Calamari.Contracts.Kubernetes; namespace Calamari.Tests.KubernetesFixtures.ResourceStatus { @@ -30,7 +29,7 @@ public void ReportsCreatedResourcesCorrectly() reporter.ReportUpdatedResources(originalStatuses, newStatuses, 1); var serviceMessages = log.ServiceMessages - .Where(message => message.Name == ServiceMessages.ResourceStatus.Name) + .Where(message => message.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .ToList(); serviceMessages.Select(message => message.Properties["name"]) @@ -73,7 +72,7 @@ public void ReportsUpdatedResourcesCorrectly() reporter.ReportUpdatedResources(originalStatuses, newStatuses, 1); var serviceMessages = log.ServiceMessages - .Where(message => message.Name == ServiceMessages.ResourceStatus.Name) + .Where(message => message.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .ToList(); serviceMessages.Should().ContainSingle().Which.Properties @@ -103,7 +102,7 @@ public void ReportsRemovedResourcesCorrectly() reporter.ReportUpdatedResources(originalStatuses, newStatuses, 1); var serviceMessages = log.ServiceMessages - .Where(message => message.Name == ServiceMessages.ResourceStatus.Name) + .Where(message => message.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .ToList(); serviceMessages.Should().ContainSingle().Which.Properties @@ -133,7 +132,7 @@ public void ClusterScopedResourcesAreIncluded() reporter.ReportUpdatedResources(new Dictionary(), newStatuses, 1); var serviceMessages = log.ServiceMessages - .Where(message => message.Name == ServiceMessages.ResourceStatus.Name) + .Where(message => message.Name == SpecialVariables.ServiceMessages.ResourceStatus.Name) .ToList(); serviceMessages.Should().Contain(sm => sm.Properties.Intersect(new[] diff --git a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs index 42c876a2a1..f061a422f5 100644 --- a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs @@ -6,7 +6,6 @@ using Calamari.Common.Plumbing.Extensions; using Calamari.Common.Plumbing.FileSystem; using Calamari.Common.Plumbing.Logging; -using Octopus.Calamari.Contracts.ArgoCD; using Octopus.CoreUtilities.Extensions; namespace Calamari.ArgoCD.Conventions.ManifestTemplating; diff --git a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs index 508436fd5e..e9c05e5887 100644 --- a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs @@ -1,7 +1,6 @@ #nullable enable using System; using System.Collections.Generic; -using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.ManifestTemplating; diff --git a/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs index 06b38eff9e..89667949a2 100644 --- a/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using Calamari.ArgoCD.Git; -using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs index dfca12fec3..c19af78bee 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs @@ -9,7 +9,6 @@ using Calamari.Common.Plumbing.FileSystem; using Calamari.Common.Plumbing.Logging; using Calamari.Kubernetes.Patching.JsonPatch; -using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.UpdateImageTag; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs index d621437803..0ccdb023fd 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs @@ -11,7 +11,6 @@ using Calamari.Common.Plumbing.Logging; using Calamari.Kubernetes.Patching; using Calamari.Kubernetes.Patching.JsonPatch; -using Octopus.Calamari.Contracts.ArgoCD; using YamlDotNet.RepresentationModel; namespace Calamari.ArgoCD.Conventions.UpdateImageTag; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs index 76a3eb6b47..ebe71467c3 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.UpdateImageTag; diff --git a/source/Calamari/ArgoCD/ProcessApplicationResult.cs b/source/Calamari/ArgoCD/ProcessApplicationResult.cs index dbc9dc71f0..abad5c14ed 100644 --- a/source/Calamari/ArgoCD/ProcessApplicationResult.cs +++ b/source/Calamari/ArgoCD/ProcessApplicationResult.cs @@ -3,10 +3,20 @@ using System.Collections.Generic; using System.Linq; using Calamari.ArgoCD.Models; -using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD { + public record FileHash(string FilePath, string Hash); + + public record FileJsonPatch(string FilePath, string JsonPatch); + + public record TrackedSourceDetail( + string? CommitSha, + DateTimeOffset? CommitTimestamp, + int SourceIndex, + List ReplacedFiles, + List PatchedFiles); + public class ProcessApplicationResult( string gatewayId, ApplicationName applicationName, diff --git a/source/Calamari/Kubernetes/ManifestReporter.cs b/source/Calamari/Kubernetes/ManifestReporter.cs index 2759949896..69cc5ba21e 100644 --- a/source/Calamari/Kubernetes/ManifestReporter.cs +++ b/source/Calamari/Kubernetes/ManifestReporter.cs @@ -6,7 +6,6 @@ using Calamari.Common.Plumbing.Logging; using Calamari.Common.Plumbing.ServiceMessages; using Calamari.Common.Plumbing.Variables; -using Octopus.Calamari.Contracts.Kubernetes; using YamlDotNet.Core; using YamlDotNet.RepresentationModel; using YamlDotNet.Serialization; @@ -95,11 +94,11 @@ void ReportManifestStreamApplied(YamlStream yamlStream) var ns = namespaceResolver.ResolveNamespace(rootNode, variables); var message = new ServiceMessage( - ServiceMessages.ManifestApplied.Name, + SpecialVariables.ServiceMessages.ManifestApplied.Name, new Dictionary { - { ServiceMessages.ManifestApplied.Attributes.Manifest, updatedDocument }, - { ServiceMessages.ManifestApplied.Attributes.Namespace, ns } + { SpecialVariables.ServiceMessages.ManifestApplied.ManifestAttribute, updatedDocument }, + { SpecialVariables.ServiceMessages.ManifestApplied.NamespaceAttribute, ns } }); log.WriteServiceMessage(message); diff --git a/source/Calamari/Kubernetes/ResourceStatus/ResourceUpdateReporter.cs b/source/Calamari/Kubernetes/ResourceStatus/ResourceUpdateReporter.cs index f6a8c62910..4f51147fda 100644 --- a/source/Calamari/Kubernetes/ResourceStatus/ResourceUpdateReporter.cs +++ b/source/Calamari/Kubernetes/ResourceStatus/ResourceUpdateReporter.cs @@ -6,8 +6,7 @@ using Calamari.Common.Plumbing.Variables; using Calamari.Kubernetes.ResourceStatus.Resources; using Newtonsoft.Json; -using Octopus.Calamari.Contracts.Kubernetes; -using ResourceStatusAttributes = Octopus.Calamari.Contracts.Kubernetes.ServiceMessages.ResourceStatus.Attributes; +using ResourceStatusAttributes = Calamari.Kubernetes.SpecialVariables.ServiceMessages.ResourceStatus.Attributes; namespace Calamari.Kubernetes.ResourceStatus { @@ -98,7 +97,7 @@ private void SendServiceMessage(Resource resource, bool removed, int checkCount) {ResourceStatusAttributes.CheckCount, checkCount.ToString()} }; - var message = new ServiceMessage(ServiceMessages.ResourceStatus.Name, parameters); + var message = new ServiceMessage(SpecialVariables.ServiceMessages.ResourceStatus.Name, parameters); log.WriteServiceMessage(message); } } diff --git a/source/Calamari/Kubernetes/SpecialVariables.cs b/source/Calamari/Kubernetes/SpecialVariables.cs index 3dfe759307..62bc769e4b 100644 --- a/source/Calamari/Kubernetes/SpecialVariables.cs +++ b/source/Calamari/Kubernetes/SpecialVariables.cs @@ -137,6 +137,40 @@ public record ApplicationSourceOutputVariables(int Index, ApplicationOutputVaria } } - + public static class ServiceMessages + { + public static class ResourceStatus + { + public const string Name = "k8s-status"; + + public static class Attributes + { + public const string Type = "type"; + public const string ActionId = "actionId"; + public const string StepName = "stepName"; + public const string TaskId = "taskId"; + public const string TargetId = "targetId"; + public const string TargetName = "targetName"; + public const string SpaceId = "spaceId"; + public const string Uuid = "uuid"; + public const string Group = "group"; + public const string Version = "version"; + public const string Kind = "kind"; + public const string Name = "name"; + public const string Namespace = "namespace"; + public const string Status = "status"; + public const string Data = "data"; + public const string Removed = "removed"; + public const string CheckCount = "checkCount"; + } + } + + public static class ManifestApplied + { + public const string Name = "k8s-manifest-applied"; + public const string ManifestAttribute = "manifest"; + public const string NamespaceAttribute = "ns"; + } + } } } \ No newline at end of file From ae32bdd46a290e6ce626c88d33a19c4e862dfa1e Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Tue, 2 Jun 2026 22:24:01 +1000 Subject: [PATCH 5/9] Add new type for contracts --- .../ArgoCD/ArgoCDFilesUpdatedReporterTests.cs | 2 ++ ...goCDAppImagesInstallConventionHelmTests.cs | 1 + ...ateArgoCDAppImagesInstallConventionTest.cs | 1 + ...licationManifestsInstallConventionTests.cs | 1 + .../ArgoCD/ArgoCDFilesUpdatedReporter.cs | 25 +++++++------------ 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs b/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs index 4cc5d0ba37..b5b125dbf2 100644 --- a/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs +++ b/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs @@ -9,6 +9,8 @@ using FluentAssertions; using NUnit.Framework; using Octopus.Calamari.Contracts.ArgoCD; +using FileHash = Calamari.ArgoCD.FileHash; +using FileJsonPatch = Calamari.ArgoCD.FileJsonPatch; namespace Calamari.Tests.ArgoCD { diff --git a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs index 615cdc2245..2c56b24102 100644 --- a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs +++ b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs @@ -26,6 +26,7 @@ using NSubstitute; using NUnit.Framework; using Octopus.Calamari.Contracts.ArgoCD; +using FileJsonPatch = Calamari.ArgoCD.FileJsonPatch; namespace Calamari.Tests.ArgoCD.Commands.Conventions { diff --git a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs index 40bcc3480e..1757b637c0 100644 --- a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs +++ b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs @@ -25,6 +25,7 @@ using NSubstitute; using NUnit.Framework; using Octopus.Calamari.Contracts.ArgoCD; +using FileJsonPatch = Calamari.ArgoCD.FileJsonPatch; namespace Calamari.Tests.ArgoCD.Commands.Conventions { diff --git a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs index 702956e6ee..9819cd1b09 100644 --- a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs +++ b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs @@ -24,6 +24,7 @@ using NSubstitute; using NUnit.Framework; using Octopus.Calamari.Contracts.ArgoCD; +using FileHash = Calamari.ArgoCD.FileHash; namespace Calamari.Tests.ArgoCD.Commands.Conventions { diff --git a/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs b/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs index ded28b7427..dccf1c227f 100644 --- a/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs +++ b/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs @@ -35,7 +35,7 @@ public void ReportFilesUpdated(GitCommitParameters gitCommitParameters, IReadOnl { { ArgoCDFilesUpdatedAttributes.GatewayId, appResult.GatewayId }, { ArgoCDFilesUpdatedAttributes.ApplicationName, appResult.ApplicationName.Value }, - { ArgoCDFilesUpdatedAttributes.Sources, JsonSerializer.Serialize(ConvertPathsToPosix(appResult.TrackedSourceDetails)) } + { ArgoCDFilesUpdatedAttributes.Sources, JsonSerializer.Serialize(appResult.TrackedSourceDetails.Select(MapSource).ToList()) } }; var message = new ServiceMessage( @@ -46,22 +46,15 @@ public void ReportFilesUpdated(GitCommitParameters gitCommitParameters, IReadOnl } } - List ConvertPathsToPosix(List inputs) + static SourceFileChanges MapSource(TrackedSourceDetail trackedSourceDetail) { - return inputs.Select(usd => usd with - { - ReplacedFiles = usd.ReplacedFiles.Select(rf => rf with - { - FilePath = rf.FilePath.EnsurePosixDirectorySeparator() - }) - .ToList(), - PatchedFiles = usd.PatchedFiles.Select(pf => pf with - { - FilePath = pf.FilePath.EnsurePosixDirectorySeparator() - }) - .ToList() - }) - .ToList(); + return new SourceFileChanges( + trackedSourceDetail.CommitSha, + trackedSourceDetail.CommitTimestamp, + trackedSourceDetail.SourceIndex, + trackedSourceDetail.ReplacedFiles.Select(f => new Octopus.Calamari.Contracts.ArgoCD.FileHash(f.FilePath.EnsurePosixDirectorySeparator(), f.Hash)).ToList(), + trackedSourceDetail.PatchedFiles.Select(f => new Octopus.Calamari.Contracts.ArgoCD.FileJsonPatch(f.FilePath.EnsurePosixDirectorySeparator(), f.JsonPatch)).ToList() + ); } } } \ No newline at end of file From b0c6bb1d3b323d50f6ed77d4488e93186044ffa1 Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Tue, 2 Jun 2026 22:27:22 +1000 Subject: [PATCH 6/9] undo more --- source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs b/source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs index 100d05f712..9b2c65f341 100644 --- a/source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs +++ b/source/Calamari.Contracts/ArgoCD/ArgoCDCustomPropertiesDto.cs @@ -37,4 +37,4 @@ public record SshKeyGitCredentialDto(string Url, string Username, string Private public string Type => DiscriminatorValue; } -public record SshKnownHostDto(string Host, string PublicKey); +public record SshKnownHostDto(string Host, string PublicKey); \ No newline at end of file From 75b763aa489270acf3a29bfd77ab0ce117935f57 Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Wed, 3 Jun 2026 10:07:46 +1000 Subject: [PATCH 7/9] Dedup FileHash etc. --- .../Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs | 2 -- .../UpdateArgoCDAppImagesInstallConventionHelmTests.cs | 1 - .../UpdateArgoCDAppImagesInstallConventionTest.cs | 1 - ...UpdateArgoCDApplicationManifestsInstallConventionTests.cs | 1 - .../Conventions/ManifestTemplating/ManifestUpdateResult.cs | 1 + source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs | 1 + .../ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs | 1 + source/Calamari/ArgoCD/ProcessApplicationResult.cs | 5 +---- 8 files changed, 4 insertions(+), 9 deletions(-) diff --git a/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs b/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs index b5b125dbf2..4cc5d0ba37 100644 --- a/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs +++ b/source/Calamari.Tests/ArgoCD/ArgoCDFilesUpdatedReporterTests.cs @@ -9,8 +9,6 @@ using FluentAssertions; using NUnit.Framework; using Octopus.Calamari.Contracts.ArgoCD; -using FileHash = Calamari.ArgoCD.FileHash; -using FileJsonPatch = Calamari.ArgoCD.FileJsonPatch; namespace Calamari.Tests.ArgoCD { diff --git a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs index 2c56b24102..615cdc2245 100644 --- a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs +++ b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionHelmTests.cs @@ -26,7 +26,6 @@ using NSubstitute; using NUnit.Framework; using Octopus.Calamari.Contracts.ArgoCD; -using FileJsonPatch = Calamari.ArgoCD.FileJsonPatch; namespace Calamari.Tests.ArgoCD.Commands.Conventions { diff --git a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs index 1757b637c0..40bcc3480e 100644 --- a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs +++ b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDAppImagesInstallConventionTest.cs @@ -25,7 +25,6 @@ using NSubstitute; using NUnit.Framework; using Octopus.Calamari.Contracts.ArgoCD; -using FileJsonPatch = Calamari.ArgoCD.FileJsonPatch; namespace Calamari.Tests.ArgoCD.Commands.Conventions { diff --git a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs index 9819cd1b09..702956e6ee 100644 --- a/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs +++ b/source/Calamari.Tests/ArgoCD/Commands/Conventions/UpdateArgoCDApplicationManifestsInstallConventionTests.cs @@ -24,7 +24,6 @@ using NSubstitute; using NUnit.Framework; using Octopus.Calamari.Contracts.ArgoCD; -using FileHash = Calamari.ArgoCD.FileHash; namespace Calamari.Tests.ArgoCD.Commands.Conventions { diff --git a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs index e9c05e5887..508436fd5e 100644 --- a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/ManifestUpdateResult.cs @@ -1,6 +1,7 @@ #nullable enable using System; using System.Collections.Generic; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.ManifestTemplating; diff --git a/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs index 89667949a2..06b38eff9e 100644 --- a/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/SourceUpdateResult.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using Calamari.ArgoCD.Git; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs index 400265eff1..80a49f09f6 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/FileUpdateResult.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.UpdateImageTag; diff --git a/source/Calamari/ArgoCD/ProcessApplicationResult.cs b/source/Calamari/ArgoCD/ProcessApplicationResult.cs index abad5c14ed..f185e88f51 100644 --- a/source/Calamari/ArgoCD/ProcessApplicationResult.cs +++ b/source/Calamari/ArgoCD/ProcessApplicationResult.cs @@ -3,13 +3,10 @@ using System.Collections.Generic; using System.Linq; using Calamari.ArgoCD.Models; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD { - public record FileHash(string FilePath, string Hash); - - public record FileJsonPatch(string FilePath, string JsonPatch); - public record TrackedSourceDetail( string? CommitSha, DateTimeOffset? CommitTimestamp, From 20f6fe88a2b4c77ef40e8c8e7e9bf53b4216a085 Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Wed, 3 Jun 2026 10:08:54 +1000 Subject: [PATCH 8/9] With --- source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs b/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs index dccf1c227f..bf9a513b45 100644 --- a/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs +++ b/source/Calamari/ArgoCD/ArgoCDFilesUpdatedReporter.cs @@ -52,8 +52,14 @@ static SourceFileChanges MapSource(TrackedSourceDetail trackedSourceDetail) trackedSourceDetail.CommitSha, trackedSourceDetail.CommitTimestamp, trackedSourceDetail.SourceIndex, - trackedSourceDetail.ReplacedFiles.Select(f => new Octopus.Calamari.Contracts.ArgoCD.FileHash(f.FilePath.EnsurePosixDirectorySeparator(), f.Hash)).ToList(), - trackedSourceDetail.PatchedFiles.Select(f => new Octopus.Calamari.Contracts.ArgoCD.FileJsonPatch(f.FilePath.EnsurePosixDirectorySeparator(), f.JsonPatch)).ToList() + trackedSourceDetail.ReplacedFiles.Select(f => f with + { + FilePath = f.FilePath.EnsurePosixDirectorySeparator() + }).ToList(), + trackedSourceDetail.PatchedFiles.Select(f => f with + { + FilePath = f.FilePath.EnsurePosixDirectorySeparator() + }).ToList() ); } } From 3442e7e97792ed69e994f9b07cb95c8930769f94 Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Wed, 3 Jun 2026 10:19:36 +1000 Subject: [PATCH 9/9] c --- .../Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs | 1 + .../ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs | 1 + source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs | 1 + 3 files changed, 3 insertions(+) diff --git a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs index f061a422f5..42c876a2a1 100644 --- a/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/ManifestTemplating/CopyTemplatesSourceUpdater.cs @@ -6,6 +6,7 @@ using Calamari.Common.Plumbing.Extensions; using Calamari.Common.Plumbing.FileSystem; using Calamari.Common.Plumbing.Logging; +using Octopus.Calamari.Contracts.ArgoCD; using Octopus.CoreUtilities.Extensions; namespace Calamari.ArgoCD.Conventions.ManifestTemplating; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs index c19af78bee..dfca12fec3 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/AbstractHelmUpdater.cs @@ -9,6 +9,7 @@ using Calamari.Common.Plumbing.FileSystem; using Calamari.Common.Plumbing.Logging; using Calamari.Kubernetes.Patching.JsonPatch; +using Octopus.Calamari.Contracts.ArgoCD; namespace Calamari.ArgoCD.Conventions.UpdateImageTag; diff --git a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs index 0ccdb023fd..d621437803 100644 --- a/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs +++ b/source/Calamari/ArgoCD/Conventions/UpdateImageTag/BaseUpdater.cs @@ -11,6 +11,7 @@ using Calamari.Common.Plumbing.Logging; using Calamari.Kubernetes.Patching; using Calamari.Kubernetes.Patching.JsonPatch; +using Octopus.Calamari.Contracts.ArgoCD; using YamlDotNet.RepresentationModel; namespace Calamari.ArgoCD.Conventions.UpdateImageTag;