Documentation ¶
Index ¶
- Constants
- Variables
- func Address(ctx context.Context, gvr schema.GroupVersionResource, name string) (*duckv1.Addressable, error)
- func GetFirstTerminationMessage(pod *corev1.Pod) string
- func GetJobPod(ctx context.Context, kubeClientset kubernetes.Interface, ...) (*corev1.Pod, error)
- func GetJobPodByJobName(ctx context.Context, jobName string) (*corev1.Pod, error)
- func GetOperationsResult(ctx context.Context, pod *corev1.Pod, result interface{}) error
- func IsAddressable(gvr schema.GroupVersionResource, name string, timing ...time.Duration) feature.StepFn
- func IsJobComplete(job *batchv1.Job) bool
- func IsJobFailed(job *batchv1.Job) bool
- func IsJobSucceeded(job *batchv1.Job) bool
- func IsNotReady(gvr schema.GroupVersionResource, name string, timing ...time.Duration) feature.StepFn
- func IsReady(gvr schema.GroupVersionResource, name string, timing ...time.Duration) feature.StepFn
- func JobFailedMessage(job *batchv1.Job) string
- func LogsFor(client kubernetes.Interface, namespace, name string, ...) (string, error)
- func NamespacedAddress(ctx context.Context, gvr schema.GroupVersionResource, name, namespace string) (*duckv1.Addressable, error)
- func PodLogs(ctx context.Context, podName, containerName, namespace string) ([]byte, error)
- func PollTimings(ctx context.Context, timings []time.Duration) (time.Duration, time.Duration)
- func WaitForAddress(ctx context.Context, gvr schema.GroupVersionResource, name string, ...) (*duckv1.Addressable, error)
- func WaitForJobCondition(ctx context.Context, t feature.T, name string, ...) error
- func WaitForJobTerminationMessage(ctx context.Context, t feature.T, name string, timing ...time.Duration) (string, error)
- func WaitForPodReadyOrSucceededOrFail(ctx context.Context, t feature.T, podName string)
- func WaitForReadyOrDone(ctx context.Context, t feature.T, ref corev1.ObjectReference, ...) error
- func WaitForReadyOrDoneOrFail(ctx context.Context, t feature.T, ref corev1.ObjectReference, ...)
- func WaitForResourceCondition(ctx context.Context, t feature.T, namespace, name string, ...) error
- func WaitForResourceNotReady(ctx context.Context, t feature.T, namespace, name string, ...) error
- func WaitForResourceReady(ctx context.Context, t feature.T, namespace, name string, ...) error
- func WaitForServiceEndpoints(ctx context.Context, t feature.T, name string, numberOfExpectedEndpoints int) error
- func WaitForServiceEndpointsOrFail(ctx context.Context, t feature.T, name string, numberOfExpectedEndpoints int)
- func WaitForServiceReady(ctx context.Context, t feature.T, name string, readinessPath string) error
- func WaitForServiceReadyOrFail(ctx context.Context, t feature.T, name string, readinessPath string)
- func WaitUntilJobDone(ctx context.Context, t feature.T, name string, timing ...time.Duration) error
- func WaitUntilJobFailed(ctx context.Context, t feature.T, name string, timing ...time.Duration) error
- func WaitUntilJobSucceeded(ctx context.Context, t feature.T, name string, timing ...time.Duration) error
- func WithDefaultPodSecurityContext(cfg map[string]interface{})
- func WithEventListener(ctx context.Context, env environment.Environment) (context.Context, error)
- type ConditionFunc
- type EventHandler
- type EventListener
Constants ¶
const PodCompletedReason = "PodCompleted"
PodCompletedReason is present in ready condition, when the pod completed successfully.
Variables ¶
var ErrWaitingForServiceEndpoints = errors.New("waiting for service endpoints")
ErrWaitingForServiceEndpoints if waiting for service endpoints failed.
var ErrWaitingForServiceReady = errors.New("waiting for service ready")
ErrWaitingForServiceReady if waiting for service ready failed.
var ( // WaitForPodRunningOrFail waits for pods to be ready. // Deprecated, use WaitForPodReadyOrSucceededOrFail WaitForPodRunningOrFail = WaitForPodReadyOrSucceededOrFail )
Functions ¶
func Address ¶
func Address(ctx context.Context, gvr schema.GroupVersionResource, name string) (*duckv1.Addressable, error)
Address attempts to resolve an Addressable address into a URL. If the resource is found but not Addressable, Address will return (nil, nil).
func GetJobPod ¶
func GetJobPod(ctx context.Context, kubeClientset kubernetes.Interface, namespace, uid, operation string) (*corev1.Pod, error)
GetJobPod will find the Pod that belongs to the resource that created it. Uses label ""controller-uid as the label selector. So, your job should tag the job with that label as the UID of the resource that's needing it. For example, if you create a storage object that requires us to create a notification for it, the controller should set the label on the Job responsible for creating the Notification for it with the label "controller-uid" set to the uid of the storage CR.
func GetJobPodByJobName ¶
GetJobPodByJobName will find the Pods that belong to that job. Each pod for a given job will have label called: "job-name" set to the job that it belongs to, so just filter by that.
func GetOperationsResult ¶
func IsAddressable ¶
func IsAddressable(gvr schema.GroupVersionResource, name string, timing ...time.Duration) feature.StepFn
IsAddressable tests to see if a resource becomes Addressable within the time given. Timing is optional but if provided is [interval, timeout].
func IsJobComplete ¶
func IsJobFailed ¶
func IsJobSucceeded ¶
func IsNotReady ¶
func IsNotReady(gvr schema.GroupVersionResource, name string, timing ...time.Duration) feature.StepFn
IsNotReady returns a reusable feature.StepFn to assert if a resource is not ready within the time given. Timing is optional but if provided is [interval, timeout].
func IsReady ¶
IsReady returns a reusable feature.StepFn to assert if a resource is ready within the time given. Timing is optional but if provided is [interval, timeout].
func JobFailedMessage ¶
func LogsFor ¶
func LogsFor(client kubernetes.Interface, namespace, name string, gvr schema.GroupVersionResource) (string, error)
func NamespacedAddress ¶
func NamespacedAddress(ctx context.Context, gvr schema.GroupVersionResource, name, namespace string) (*duckv1.Addressable, error)
NamespacedAddress attempts to resolve an Addressable address in a specific namespace into a URL. If the resource is found but not Addressable, Address will return (nil, nil).
func PollTimings ¶
PollTimings will find the correct timings based on priority: - passed timing slice [interval, timeout]. - values from from context. - defaults.
func WaitForAddress ¶
func WaitForAddress(ctx context.Context, gvr schema.GroupVersionResource, name string, timing ...time.Duration) (*duckv1.Addressable, error)
WaitForAddress waits until a resource has an address. Timing is optional but if provided is [interval, timeout].
func WaitForJobCondition ¶
func WaitForJobTerminationMessage ¶
func WaitForJobTerminationMessage(ctx context.Context, t feature.T, name string, timing ...time.Duration) (string, error)
WaitForJobTerminationMessage waits for a job to end and then collects the termination message. Timing is optional but if provided is [interval, timeout].
func WaitForPodReadyOrSucceededOrFail ¶
WaitForPodReadyOrSucceededOrFail waits for the given pod to be in running state.
func WaitForReadyOrDone ¶
func WaitForReadyOrDone(ctx context.Context, t feature.T, ref corev1.ObjectReference, timing ...time.Duration) error
WaitForReadyOrDone will wait for a resource to become ready or succeed. Timing is optional but if provided is [interval, timeout].
func WaitForReadyOrDoneOrFail ¶
func WaitForReadyOrDoneOrFail(ctx context.Context, t feature.T, ref corev1.ObjectReference, timing ...time.Duration)
WaitForReadyOrDoneOrFail will call WaitForReadyOrDone and fail if the resource is not ready.
func WaitForResourceCondition ¶
func WaitForResourceCondition(ctx context.Context, t feature.T, namespace, name string, gvr schema.GroupVersionResource, condition ConditionFunc, timing ...time.Duration) error
WaitForResourceCondition waits until the specified resource in the given namespace satisfies a given condition. Timing is optional but if provided is [interval, timeout].
func WaitForResourceNotReady ¶
func WaitForResourceNotReady(ctx context.Context, t feature.T, namespace, name string, gvr schema.GroupVersionResource, timing ...time.Duration) error
WaitForResourceNotReady waits until the specified resource in the given namespace is not ready. Only the top level ready condition is considered (internal `happy` condition of knative.dev/pkg). Timing is optional but if provided is [interval, timeout].
func WaitForResourceReady ¶
func WaitForResourceReady(ctx context.Context, t feature.T, namespace, name string, gvr schema.GroupVersionResource, timing ...time.Duration) error
WaitForResourceReady waits until the specified resource in the given namespace are ready or completed successfully. Timing is optional but if provided is [interval, timeout].
func WaitForServiceEndpoints ¶
func WaitForServiceEndpoints(ctx context.Context, t feature.T, name string, numberOfExpectedEndpoints int) error
WaitForServiceEndpoints polls the status of the specified Service every interval until number of service endpoints >= numOfEndpoints.
func WaitForServiceEndpointsOrFail ¶
func WaitForServiceEndpointsOrFail(ctx context.Context, t feature.T, name string, numberOfExpectedEndpoints int)
WaitForServiceEndpointsOrFail polls the status of the specified Service every interval until number of service endpoints >= numOfEndpoints.
func WaitForServiceReady ¶
WaitForServiceReady will deploy a job that will try to invoke a service using readiness path. This makes sure the service is ready to serve traffic, from other components. See: https://stackoverflow.com/a/59713538/844449
func WaitForServiceReadyOrFail ¶
WaitForServiceReadyOrFail will call WaitForServiceReady and fail if error is returned.
func WaitUntilJobDone ¶
WaitUntilJobDone waits until a job has finished. Timing is optional but if provided is [interval, timeout].
func WaitUntilJobFailed ¶
func WaitUntilJobFailed(ctx context.Context, t feature.T, name string, timing ...time.Duration) error
WaitUntilJobFailed waits until a job has failed. Timing is optional but if provided is [interval, timeout].
func WaitUntilJobSucceeded ¶
func WaitUntilJobSucceeded(ctx context.Context, t feature.T, name string, timing ...time.Duration) error
WaitUntilJobSucceeded waits until a job has succeeded. Timing is optional but if provided is [interval, timeout].
func WithDefaultPodSecurityContext ¶
func WithDefaultPodSecurityContext(cfg map[string]interface{})
func WithEventListener ¶
func WithEventListener(ctx context.Context, env environment.Environment) (context.Context, error)
Types ¶
type ConditionFunc ¶
ConditionFunc is a function that determines whether a condition on a resource is satisfied.
type EventHandler ¶
EventHandler is the callback type for the EventListener
type EventListener ¶
type EventListener struct {
// contains filtered or unexported fields
}
EventListener is a type that broadcasts new k8s events to subscribed EventHandler The scope of EventListener should be global in the Environment lifecycle
func EventListenerFromContext ¶
func EventListenerFromContext(ctx context.Context) *EventListener
func (*EventListener) AddHandler ¶
func (el *EventListener) AddHandler(name string, handler EventHandler) int
func (*EventListener) GetHandler ¶
func (el *EventListener) GetHandler(name string) EventHandler
func (*EventListener) Stop ¶
func (el *EventListener) Stop()