Documentation ¶
Index ¶
- Constants
- type NoPodEventsYetFn
- type OnPodEventFn
- type PodWatcher
- func (p *PodWatcher) Connect(listOpts metav1.ListOptions) error
- func (p *PodWatcher) Start(listOpts metav1.ListOptions) (*corev1.Pod, error)
- func (p *PodWatcher) Stop()
- func (p *PodWatcher) WaitForCompletion() (*corev1.Pod, error)
- func (p *PodWatcher) WithNoPodEventsYetFn(fn NoPodEventsYetFn) *PodWatcher
- func (p *PodWatcher) WithOnPodAddedFn(fn OnPodEventFn) *PodWatcher
- func (p *PodWatcher) WithOnPodDeletedFn(fn OnPodEventFn) *PodWatcher
- func (p *PodWatcher) WithOnPodModifiedFn(fn OnPodEventFn) *PodWatcher
- func (p *PodWatcher) WithSkipPodFn(fn SkipPodFn) *PodWatcher
- func (p *PodWatcher) WithTimeoutPodFn(fn TimeoutPodFn) *PodWatcher
- type SkipPodFn
- type TimeoutPodFn
Constants ¶
const ( // ContextTimeoutMessage is the message for a context timeout ContextTimeoutMessage = "context deadline has been exceeded" // RequestTimeoutMessage is the message for a request timeout RequestTimeoutMessage = "request timeout has expired" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NoPodEventsYetFn ¶ added in v0.6.0
NoPodEventsYetFn when the watch has not received the create event within a reasonable time, where a PodList is also provided in the off chance the Pod completed before the Watch was started.
type OnPodEventFn ¶
OnPodEventFn when a pod is modified this method handles the event.
type PodWatcher ¶
type PodWatcher struct {
// contains filtered or unexported fields
}
PodWatcher a simple function orchestrator based on watching a given pod and reacting upon the state modifications, should work as a helper to build business logic based on the build POD changes.
func NewPodWatcher ¶
func NewPodWatcher( ctx context.Context, timeout time.Duration, clientset kubernetes.Interface, ns string, ) (*PodWatcher, error)
NewPodWatcher instantiate PodWatcher event-loop.
func (*PodWatcher) Connect ¶ added in v0.10.0
func (p *PodWatcher) Connect(listOpts metav1.ListOptions) error
Connect is the first of two methods called by Start, and it handles the creation of the watch based on the list options provided. Separating out Connect from Start helps deal with the fake k8s clients, which are used by the unit tests, and the capabilities of their Watch implementation.
func (*PodWatcher) Start ¶
func (p *PodWatcher) Start(listOpts metav1.ListOptions) (*corev1.Pod, error)
Start is a convenience method for capturing the use of both Connect and WaitForCompletion
func (*PodWatcher) Stop ¶
func (p *PodWatcher) Stop()
Stop closes the stop channel, and stops the execution loop.
func (*PodWatcher) WaitForCompletion ¶ added in v0.10.0
func (p *PodWatcher) WaitForCompletion() (*corev1.Pod, error)
WaitForCompletion is the second of two methods called by Start, and it runs the event loop based on the watch instantiated (by Connect) against informed pod. In case of errors the loop is interrupted. Separating out WaitForCompletion from Start helps deal with the fake k8s clients, which are used by the unit tests, and the capabilities of their Watch implementation.
func (*PodWatcher) WithNoPodEventsYetFn ¶ added in v0.6.0
func (p *PodWatcher) WithNoPodEventsYetFn(fn NoPodEventsYetFn) *PodWatcher
WithNoPodEventsYetFn sets the function executed when the watcher decides it has waited long enough for the first event
func (*PodWatcher) WithOnPodAddedFn ¶
func (p *PodWatcher) WithOnPodAddedFn(fn OnPodEventFn) *PodWatcher
WithOnPodAddedFn sets the function executed when a pod is added.
func (*PodWatcher) WithOnPodDeletedFn ¶
func (p *PodWatcher) WithOnPodDeletedFn(fn OnPodEventFn) *PodWatcher
WithOnPodDeletedFn sets the function executed when a pod is modified.
func (*PodWatcher) WithOnPodModifiedFn ¶
func (p *PodWatcher) WithOnPodModifiedFn(fn OnPodEventFn) *PodWatcher
WithOnPodModifiedFn sets the function executed when a pod is modified.
func (*PodWatcher) WithSkipPodFn ¶
func (p *PodWatcher) WithSkipPodFn(fn SkipPodFn) *PodWatcher
WithSkipPodFn sets the skip function instance.
func (*PodWatcher) WithTimeoutPodFn ¶ added in v0.6.0
func (p *PodWatcher) WithTimeoutPodFn(fn TimeoutPodFn) *PodWatcher
WithTimeoutPodFn sets the function executed when the context or request timeout fires
type SkipPodFn ¶
SkipPodFn a given pod instance is informed and expects a boolean as return. When true is returned this container state processing is skipped completely.
type TimeoutPodFn ¶ added in v0.6.0
type TimeoutPodFn func(msg string)
TimeoutPodFn when either the context or request timeout expires before the Pod finishes