-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds structs and validation for v1 TaskRun, including params, resultRef and workspaces. This is copied from v1beta1 with the following exceptions: - omitted TaskRunResources - This includes the `TaskRunInputs` and `TaskRunOutputs` and respective test - omitted `CloudEventDeliveryState` - renamed the Go fields of `StepState.ContainerName` to `StepState.Container`and `SidecarState.ContainerName` to `SidecarState.Container` but not the api fields - renamed `taskResults` to `results`
- Loading branch information
Showing
28 changed files
with
5,624 additions
and
17 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
Copyright 2022 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1 | ||
|
||
import "github.com/tektoncd/pipeline/pkg/apis/pipeline/pod" | ||
|
||
// PodTemplate holds pod specific configuration | ||
type PodTemplate = pod.Template | ||
|
||
// MergePodTemplateWithDefault merges 2 PodTemplates together. If the same | ||
// field is set on both templates, the value from tpl will overwrite the value | ||
// from defaultTpl. | ||
func MergePodTemplateWithDefault(tpl, defaultTpl *PodTemplate) *PodTemplate { | ||
switch { | ||
case defaultTpl == nil: | ||
// No configured default, just return the template | ||
return tpl | ||
case tpl == nil: | ||
// No template, just return the default template | ||
return defaultTpl | ||
default: | ||
// Otherwise, merge fields | ||
if tpl.NodeSelector == nil { | ||
tpl.NodeSelector = defaultTpl.NodeSelector | ||
} | ||
if tpl.Tolerations == nil { | ||
tpl.Tolerations = defaultTpl.Tolerations | ||
} | ||
if tpl.Affinity == nil { | ||
tpl.Affinity = defaultTpl.Affinity | ||
} | ||
if tpl.SecurityContext == nil { | ||
tpl.SecurityContext = defaultTpl.SecurityContext | ||
} | ||
if tpl.Volumes == nil { | ||
tpl.Volumes = defaultTpl.Volumes | ||
} | ||
if tpl.RuntimeClassName == nil { | ||
tpl.RuntimeClassName = defaultTpl.RuntimeClassName | ||
} | ||
if tpl.AutomountServiceAccountToken == nil { | ||
tpl.AutomountServiceAccountToken = defaultTpl.AutomountServiceAccountToken | ||
} | ||
if tpl.DNSPolicy == nil { | ||
tpl.DNSPolicy = defaultTpl.DNSPolicy | ||
} | ||
if tpl.DNSConfig == nil { | ||
tpl.DNSConfig = defaultTpl.DNSConfig | ||
} | ||
if tpl.EnableServiceLinks == nil { | ||
tpl.EnableServiceLinks = defaultTpl.EnableServiceLinks | ||
} | ||
if tpl.PriorityClassName == nil { | ||
tpl.PriorityClassName = defaultTpl.PriorityClassName | ||
} | ||
if tpl.SchedulerName == "" { | ||
tpl.SchedulerName = defaultTpl.SchedulerName | ||
} | ||
if tpl.ImagePullSecrets == nil { | ||
tpl.ImagePullSecrets = defaultTpl.ImagePullSecrets | ||
} | ||
if tpl.HostAliases == nil { | ||
tpl.HostAliases = defaultTpl.HostAliases | ||
} | ||
if tpl.HostNetwork == false && defaultTpl.HostNetwork == true { | ||
tpl.HostNetwork = true | ||
} | ||
return tpl | ||
} | ||
} | ||
|
||
// AAPodTemplate holds pod specific configuration for the affinity-assistant | ||
type AAPodTemplate = pod.AffinityAssistantTemplate | ||
|
||
// MergeAAPodTemplateWithDefault is the same as MergePodTemplateWithDefault but | ||
// for AffinityAssistantPodTemplates. | ||
func MergeAAPodTemplateWithDefault(tpl, defaultTpl *AAPodTemplate) *AAPodTemplate { | ||
switch { | ||
case defaultTpl == nil: | ||
// No configured default, just return the template | ||
return tpl | ||
case tpl == nil: | ||
// No template, just return the default template | ||
return defaultTpl | ||
default: | ||
// Otherwise, merge fields | ||
if tpl.NodeSelector == nil { | ||
tpl.NodeSelector = defaultTpl.NodeSelector | ||
} | ||
if tpl.Tolerations == nil { | ||
tpl.Tolerations = defaultTpl.Tolerations | ||
} | ||
if tpl.ImagePullSecrets == nil { | ||
tpl.ImagePullSecrets = defaultTpl.ImagePullSecrets | ||
} | ||
return tpl | ||
} | ||
} |
Oops, something went wrong.