From 6d2cebadf70a410932bcf310c81ef722b049850f Mon Sep 17 00:00:00 2001 From: Lourens de Jager <165963988+lourens-octopus@users.noreply.github.com> Date: Thu, 7 Nov 2024 09:32:26 +1300 Subject: [PATCH] Add Git Repository Trigger --- ...AreaShouldNotRegress..NETCore.approved.txt | 21 ++++++++++++++ ...houldNotRegress..NETFramework.approved.txt | 21 ++++++++++++++ .../Triggers/GitTriggers/GitFilterResource.cs | 29 +++++++++++++++++++ .../Model/Triggers/TriggerFilterResource.cs | 3 +- .../Serialization/TriggerFilterConverter.cs | 4 ++- 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 source/Octopus.Server.Client/Model/Triggers/GitTriggers/GitFilterResource.cs diff --git a/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETCore.approved.txt b/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETCore.approved.txt index 9ddb2b37..63634479 100644 --- a/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETCore.approved.txt +++ b/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETCore.approved.txt @@ -7433,6 +7433,27 @@ Octopus.Client.Model.Triggers DaysPerWeekSchedule = 6 FeedFilter = 7 ArcFeedFilter = 8 + GitFilter = 9 + } +} +Octopus.Client.Model.Triggers.GitTriggers +{ + class GitFilterResource + Octopus.Client.Extensibility.IResource + Octopus.Client.Model.IAuditedResource + Octopus.Client.Model.Triggers.TriggerFilterResource + { + .ctor() + Octopus.Client.Model.Triggers.TriggerFilterType FilterType { get; } + List Sources { get; set; } + } + class GitTriggerSourceResource + { + .ctor(String, String, String[], String[]) + String DeploymentActionSlug { get; set; } + String[] ExcludeFilePaths { get; set; } + String GitDependencyName { get; set; } + String[] IncludeFilePaths { get; set; } } } Octopus.Client.Model.Triggers.ScheduledTriggers diff --git a/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETFramework.approved.txt b/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETFramework.approved.txt index 30415a3d..c40ea9df 100644 --- a/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETFramework.approved.txt +++ b/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETFramework.approved.txt @@ -7457,6 +7457,27 @@ Octopus.Client.Model.Triggers DaysPerWeekSchedule = 6 FeedFilter = 7 ArcFeedFilter = 8 + GitFilter = 9 + } +} +Octopus.Client.Model.Triggers.GitTriggers +{ + class GitFilterResource + Octopus.Client.Extensibility.IResource + Octopus.Client.Model.IAuditedResource + Octopus.Client.Model.Triggers.TriggerFilterResource + { + .ctor() + Octopus.Client.Model.Triggers.TriggerFilterType FilterType { get; } + List Sources { get; set; } + } + class GitTriggerSourceResource + { + .ctor(String, String, String[], String[]) + String DeploymentActionSlug { get; set; } + String[] ExcludeFilePaths { get; set; } + String GitDependencyName { get; set; } + String[] IncludeFilePaths { get; set; } } } Octopus.Client.Model.Triggers.ScheduledTriggers diff --git a/source/Octopus.Server.Client/Model/Triggers/GitTriggers/GitFilterResource.cs b/source/Octopus.Server.Client/Model/Triggers/GitTriggers/GitFilterResource.cs new file mode 100644 index 00000000..f2acdcae --- /dev/null +++ b/source/Octopus.Server.Client/Model/Triggers/GitTriggers/GitFilterResource.cs @@ -0,0 +1,29 @@ +#nullable enable +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Octopus.Client.Model.Triggers.GitTriggers; + +public class GitFilterResource : TriggerFilterResource +{ + public override TriggerFilterType FilterType => TriggerFilterType.GitFilter; + + public List Sources { get; set; } = []; +} + +public class GitTriggerSourceResource +{ + [JsonConstructor] + public GitTriggerSourceResource(string deploymentActionSlug, string gitDependencyName, string[] includeFilePaths, string[] excludeFilePaths) + { + DeploymentActionSlug = deploymentActionSlug; + GitDependencyName = gitDependencyName; + IncludeFilePaths = includeFilePaths; + ExcludeFilePaths = excludeFilePaths; + } + + public string DeploymentActionSlug { get; set; } + public string GitDependencyName { get; set; } + public string[] IncludeFilePaths { get; set; } + public string[] ExcludeFilePaths { get; set; } +} diff --git a/source/Octopus.Server.Client/Model/Triggers/TriggerFilterResource.cs b/source/Octopus.Server.Client/Model/Triggers/TriggerFilterResource.cs index c22c4206..d908066b 100644 --- a/source/Octopus.Server.Client/Model/Triggers/TriggerFilterResource.cs +++ b/source/Octopus.Server.Client/Model/Triggers/TriggerFilterResource.cs @@ -13,7 +13,8 @@ public enum TriggerFilterType DailySchedule, DaysPerWeekSchedule, FeedFilter, - ArcFeedFilter + ArcFeedFilter, + GitFilter } public abstract class TriggerFilterResource : Resource diff --git a/source/Octopus.Server.Client/Serialization/TriggerFilterConverter.cs b/source/Octopus.Server.Client/Serialization/TriggerFilterConverter.cs index c5a6094c..7b420d9b 100644 --- a/source/Octopus.Server.Client/Serialization/TriggerFilterConverter.cs +++ b/source/Octopus.Server.Client/Serialization/TriggerFilterConverter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using Octopus.Client.Model.Triggers; +using Octopus.Client.Model.Triggers.GitTriggers; using Octopus.Client.Model.Triggers.ScheduledTriggers; namespace Octopus.Client.Serialization @@ -18,7 +19,8 @@ public class TriggerFilterConverter : InheritedClassConverter DerivedTypeMappings => FilterTypes;