Skip to content

Commit

Permalink
Added patching support for DeploymentConfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvenga committed Jun 2, 2022
1 parent 3d1749c commit ca8004c
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Contrast.K8s.AgentOperator.Core.Events;
using Contrast.K8s.AgentOperator.Core.Kube;
using Contrast.K8s.AgentOperator.Core.OpenShift;
using Contrast.K8s.AgentOperator.Core.State;
using Contrast.K8s.AgentOperator.Core.State.Resources;
using Contrast.K8s.AgentOperator.Core.State.Resources.Interfaces;
Expand Down Expand Up @@ -68,6 +69,7 @@ private ValueTask PatchToDesiredState(DesiredState desiredState, ResourceIdentit
DaemonSetResource => PatchToDesiredStateDaemonSet(desiredState, identity),
StatefulSetResource => PatchToDesiredStateStatefulSet(desiredState, identity),
DeploymentResource => PatchToDesiredStateDeployment(desiredState, identity),
DeploymentConfigResource => PatchToDesiredStateDeploymentConfig(desiredState, identity),
_ => throw new ArgumentOutOfRangeException()
};
}
Expand All @@ -90,6 +92,12 @@ private async ValueTask PatchToDesiredStateDeployment(DesiredState desiredState,
await _patcher.Patch<V1Deployment>(identity.Name, identity.Namespace, o => { PatchAnnotations(desiredState, o.Spec.Template); });
}

private async ValueTask PatchToDesiredStateDeploymentConfig(DesiredState desiredState, NamespacedResourceIdentity identity)
{
await _state.MarkAsDirty(identity);
await _patcher.Patch<V1DeploymentConfig>(identity.Name, identity.Namespace, o => { PatchAnnotations(desiredState, o.Spec.Template!); });
}

private static void PatchAnnotations(DesiredState desiredState, V1PodTemplateSpec spec)
{
// This call creates a new list if annotations is null.
Expand Down

0 comments on commit ca8004c

Please sign in to comment.