From c7d448ca49ed2b788eb79b6b244742ac74e8e592 Mon Sep 17 00:00:00 2001 From: Harsh Thakur Date: Tue, 23 Feb 2021 15:16:45 +0530 Subject: [PATCH] Add fields to pod spec (#1932) Co-authored-by: Vishal --- pkg/executor/util/merge.go | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/pkg/executor/util/merge.go b/pkg/executor/util/merge.go index f529ed12..e8c7355f 100644 --- a/pkg/executor/util/merge.go +++ b/pkg/executor/util/merge.go @@ -126,6 +126,66 @@ func MergePodSpec(srcPodSpec *apiv1.PodSpec, targetPodSpec *apiv1.PodSpec) (*api srcPodSpec.Hostname = targetPodSpec.Hostname } + if targetPodSpec.RuntimeClassName != nil { + srcPodSpec.RuntimeClassName = targetPodSpec.RuntimeClassName + } + + if targetPodSpec.RestartPolicy != "" { + srcPodSpec.RestartPolicy = targetPodSpec.RestartPolicy + } + + if targetPodSpec.ActiveDeadlineSeconds != nil { + srcPodSpec.ActiveDeadlineSeconds = targetPodSpec.ActiveDeadlineSeconds + } + + if targetPodSpec.DNSPolicy != "" { + srcPodSpec.DNSPolicy = targetPodSpec.DNSPolicy + } + + if targetPodSpec.ServiceAccountName != "" { + srcPodSpec.ServiceAccountName = targetPodSpec.ServiceAccountName + } + + if targetPodSpec.DeprecatedServiceAccount != "" { + srcPodSpec.DeprecatedServiceAccount = targetPodSpec.DeprecatedServiceAccount + } + + if targetPodSpec.AutomountServiceAccountToken != nil { + srcPodSpec.AutomountServiceAccountToken = targetPodSpec.AutomountServiceAccountToken + } + + if targetPodSpec.HostNetwork != false { + srcPodSpec.HostNetwork = targetPodSpec.HostNetwork + } + + if targetPodSpec.HostPID != false { + srcPodSpec.HostPID = targetPodSpec.HostPID + } + + if targetPodSpec.HostIPC != false { + srcPodSpec.HostIPC = targetPodSpec.HostIPC + } + + if targetPodSpec.ShareProcessNamespace != nil { + srcPodSpec.ShareProcessNamespace = targetPodSpec.ShareProcessNamespace + } + + if targetPodSpec.PriorityClassName != "" { + srcPodSpec.PriorityClassName = targetPodSpec.PriorityClassName + } + + if targetPodSpec.Priority != nil { + srcPodSpec.Priority = targetPodSpec.Priority + } + + if targetPodSpec.PreemptionPolicy != nil { + srcPodSpec.PreemptionPolicy = targetPodSpec.PreemptionPolicy + } + + if targetPodSpec.EnableServiceLinks != nil { + srcPodSpec.EnableServiceLinks = targetPodSpec.EnableServiceLinks + } + srcPodSpec.ImagePullSecrets = append(srcPodSpec.ImagePullSecrets, targetPodSpec.ImagePullSecrets...) srcPodSpec.Tolerations = append(srcPodSpec.Tolerations, targetPodSpec.Tolerations...) srcPodSpec.HostAliases = append(srcPodSpec.HostAliases, targetPodSpec.HostAliases...)