-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDefaultDeploymentPolicy.cs
More file actions
55 lines (50 loc) · 2.08 KB
/
Copy pathDefaultDeploymentPolicy.cs
File metadata and controls
55 lines (50 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using ModularityKit.Mutator.Abstractions.Effects;
using ModularityKit.Mutator.Abstractions.Engine;
using ModularityKit.Mutator.Abstractions.Policies;
using PolicyComposition.State;
namespace PolicyComposition.Policies.Deployment;
/// <summary>
/// Supplies the fallback deployment path for non production releases.
/// </summary>
/// <remarks>
/// The policy does not inspect environment-specific risk beyond the fact that it
/// is the default branch in the composed deployment gate. It moves the release to
/// a deploy-ready stage and contributes both a side effect and metadata so the
/// composition result stays auditable.
/// </remarks>
internal sealed class DefaultDeploymentPolicy : IMutationPolicy<ReleaseGateState>
{
/// <summary>
/// Policy identifier used in composition metadata.
/// </summary>
public string Name => "DefaultDeployment";
/// <summary>
/// Lowest priority in the deployment composition, so it acts as the fallback branch.
/// </summary>
public int Priority => 100;
/// <summary>
/// Describes the fallback deployment behavior.
/// </summary>
public string Description => "Default non-production deployment path.";
/// <summary>
/// Moves the release into the ready for deployment stage and emits an audit trace.
/// </summary>
/// <param name="mutation">The mutation being evaluated.</param>
/// <param name="state">The current release state.</param>
/// <returns>An allowed decision that marks the release ready for deployment.</returns>
public PolicyDecision Evaluate(IMutation<ReleaseGateState> mutation, ReleaseGateState state)
=> new()
{
IsAllowed = true,
PolicyName = Name,
Modifications = new Dictionary<string, object>
{
["State"] = state with { Stage = "ReadyForDeploy" },
["SideEffect"] = SideEffect.Create("audit", "Default deployment path selected.")
},
Metadata = new Dictionary<string, object>
{
["deploymentPath"] = "default"
}
};
}