Documentation ¶
Overview ¶
Package pod provides methods for converting between a TaskRun and a Pod.
Index ¶
- Constants
- Variables
- func DidTaskRunFail(pod *corev1.Pod) bool
- func IsContainerStep(name string) bool
- func IsPodExceedingNodeResources(pod *corev1.Pod) bool
- func IsPodHitConfigError(pod *corev1.Pod) bool
- func IsSidecarStatusRunning(tr *v1beta1.TaskRun) bool
- func MakeLabels(s *v1beta1.TaskRun) map[string]string
- func MakeTaskRunStatus(logger *zap.SugaredLogger, tr v1beta1.TaskRun, pod *corev1.Pod) (v1beta1.TaskRunStatus, error)
- func MarkStatusFailure(trs *v1beta1.TaskRunStatus, message string)
- func MarkStatusRunning(trs *v1beta1.TaskRunStatus, reason, message string)
- func MarkStatusSuccess(trs *v1beta1.TaskRunStatus)
- func ShouldOverrideHomeEnv(ctx context.Context) bool
- func SidecarsReady(podStatus corev1.PodStatus) bool
- func StopSidecars(nopImage string, kubeclient kubernetes.Interface, pod corev1.Pod) error
- func TrimSidecarPrefix(name string) string
- func UpdateReady(kubeclient kubernetes.Interface, pod corev1.Pod) error
- type Builder
- type EntrypointCache
Constants ¶
const ( // ReasonCouldntGetTask indicates that the reason for the failure status is that the // Task couldn't be found ReasonCouldntGetTask = "CouldntGetTask" // ReasonFailedResolution indicated that the reason for failure status is // that references within the TaskRun could not be resolved ReasonFailedResolution = "TaskRunResolutionFailed" // ReasonFailedValidation indicated that the reason for failure status is // that taskrun failed runtime validation ReasonFailedValidation = "TaskRunValidationFailed" // ReasonExceededResourceQuota indicates that the TaskRun failed to create a pod due to // a ResourceQuota in the namespace ReasonExceededResourceQuota = "ExceededResourceQuota" // ReasonExceededNodeResources indicates that the TaskRun's pod has failed to start due // to resource constraints on the node ReasonExceededNodeResources = "ExceededNodeResources" // ReasonCreateContainerConfigError indicates that the TaskRun failed to create a pod due to // config error of container ReasonCreateContainerConfigError = "CreateContainerConfigError" // ReasonPodCreationFailed indicates that the reason for the current condition // is that the creation of the pod backing the TaskRun failed ReasonPodCreationFailed = "PodCreationFailed" // ReasonPending indicates that the pod is in corev1.Pending, and the reason is not // ReasonExceededNodeResources or IsPodHitConfigError ReasonPending = "Pending" )
const (
// ResultsDir is the folder used by default to create the results file
ResultsDir = "/tekton/results"
)
Variables ¶
var (
ReleaseAnnotation = "pipeline.tekton.dev/release"
)
These are effectively const, but Go doesn't have such an annotation.
Functions ¶
func DidTaskRunFail ¶ added in v0.11.0
DidTaskRunFail check the status of pod to decide if related taskrun is failed
func IsContainerStep ¶ added in v0.11.0
isContainerStep returns true if the container name indicates that it represents a step.
func IsPodExceedingNodeResources ¶
IsPodExceedingNodeResources returns true if the Pod's status indicates there are insufficient resources to schedule the Pod.
func IsPodHitConfigError ¶ added in v0.10.0
IsPodHitConfigError returns true if the Pod's status undicates there are config error raised
func IsSidecarStatusRunning ¶ added in v0.11.0
IsSidecarStatusRunning determines if any SidecarStatus on a TaskRun is still running.
func MakeLabels ¶ added in v0.11.0
MakeLabels constructs the labels we will propagate from TaskRuns to Pods.
func MakeTaskRunStatus ¶
func MakeTaskRunStatus(logger *zap.SugaredLogger, tr v1beta1.TaskRun, pod *corev1.Pod) (v1beta1.TaskRunStatus, error)
MakeTaskRunStatus returns a TaskRunStatus based on the Pod's status.
func MarkStatusFailure ¶ added in v0.15.0
func MarkStatusFailure(trs *v1beta1.TaskRunStatus, message string)
MarkStatusFailure sets taskrun status to failure
func MarkStatusRunning ¶ added in v0.15.0
func MarkStatusRunning(trs *v1beta1.TaskRunStatus, reason, message string)
MarkStatusRunning sets taskrun status to running
func MarkStatusSuccess ¶ added in v0.15.0
func MarkStatusSuccess(trs *v1beta1.TaskRunStatus)
MarkStatusSuccess sets taskrun status to success
func ShouldOverrideHomeEnv ¶ added in v0.11.0
ShouldOverrideHomeEnv returns a bool indicating whether a Pod should have its $HOME environment variable overwritten with /tekton/home or if it should be left unmodified. The default behaviour is to overwrite the $HOME variable but this is planned to change in an upcoming release.
For further reference see https://github.com/tektoncd/pipeline/issues/2013
func SidecarsReady ¶
SidecarsReady returns true if all of the Pod's sidecars are Ready or Terminated.
func StopSidecars ¶
StopSidecars updates sidecar containers in the Pod to a nop image, which exits successfully immediately.
func TrimSidecarPrefix ¶ added in v0.11.0
trimSidecarPrefix returns the container name, stripped of its sidecar prefix.
func UpdateReady ¶
func UpdateReady(kubeclient kubernetes.Interface, pod corev1.Pod) error
UpdateReady updates the Pod's annotations to signal the first step to start by projecting the ready annotation via the Downward API.
Types ¶
type Builder ¶ added in v0.15.0
type Builder struct { Images pipeline.Images KubeClient kubernetes.Interface EntrypointCache EntrypointCache OverrideHomeEnv bool }
Builder exposes options to configure Pod construction from TaskSpecs/Runs.
func (*Builder) Build ¶ added in v0.15.0
func (b *Builder) Build(ctx context.Context, taskRun *v1beta1.TaskRun, taskSpec v1beta1.TaskSpec) (*corev1.Pod, error)
Build creates a Pod using the configuration options set on b and the TaskRun and TaskSpec provided in its arguments. An error is returned if there are any problems during the conversion.
type EntrypointCache ¶
type EntrypointCache interface { // Get the Image data for the given image reference. If the value is // not found in the cache, it will be fetched from the image registry, // possibly using K8s service account imagePullSecrets. Get(ref name.Reference, namespace, serviceAccountName string) (v1.Image, error) // Update the cache with a new digest->Image mapping. This will avoid a // remote registry lookup next time Get is called. Set(digest name.Digest, img v1.Image) }
EntrypointCache looks up an image's entrypoint (command) in a container image registry, possibly using the given service account's credentials.
func NewEntrypointCache ¶
func NewEntrypointCache(kubeclient kubernetes.Interface) (EntrypointCache, error)
NewEntrypointCache returns a new entrypoint cache implementation that uses K8s credentials to pull image metadata from a container image registry.