Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeHash(obj interface{}) string
- func GetActiveDeadlineSeconds(d time.Duration) *int64
- func GetAuth(opts ...AuthOption) (*rbacv1.ClusterRole, *rbacv1.ClusterRoleBinding, *corev1.ServiceAccount, error)
- func GetJob(opts ...JobOption) (*batchv1.Job, error)
- func GetTerminatedContainersStatusesByPod(pod *corev1.Pod) map[string]*corev1.ContainerStateTerminated
- func IsPodControlledByJobNotFound(err error) bool
- type AuthBuilder
- type AuthOption
- type Collector
- type CollectorOption
- func WithCollectorTimeout(timeout time.Duration) CollectorOption
- func WithContainerResourceRequirements(rr corev1.ResourceRequirements) CollectorOption
- func WithContainerSecurityContext(securityContext *corev1.SecurityContext) CollectorOption
- func WithImageRef(imageRef string) CollectorOption
- func WithJobAffinity(affinity *corev1.Affinity) CollectorOption
- func WithJobAnnotation(annotation map[string]string) CollectorOption
- func WithJobLabels(labels map[string]string) CollectorOption
- func WithJobNamespace(namespace string) CollectorOption
- func WithJobTemplateName(name string) CollectorOption
- func WithJobTolerations(tolerations []corev1.Toleration) CollectorOption
- func WithName(name string) CollectorOption
- func WithNodeConfig(nodeConfig bool) CollectorOption
- func WithPodImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) CollectorOption
- func WithPodPriorityClassName(priorityClassName string) CollectorOption
- func WithPodSpecSecurityContext(podSecurityContext *corev1.PodSecurityContext) CollectorOption
- func WithServiceAccount(sa string) CollectorOption
- func WithTimetout(timeout time.Duration) CollectorOption
- func WithUseNodeSelector(useNodeSelector bool) CollectorOption
- func WithVolumes(volumes []corev1.Volume) CollectorOption
- func WithVolumesMount(volumesMount []corev1.VolumeMount) CollectorOption
- type JobBuilder
- type JobOption
- func WithAffinity(affinity *corev1.Affinity) JobOption
- func WithAnnotation(annotations map[string]string) JobOption
- func WithContainerVolumeMounts(volumeMounts []corev1.VolumeMount) JobOption
- func WithImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) JobOption
- func WithJobName(name string) JobOption
- func WithJobServiceAccount(sa string) JobOption
- func WithJobTimeout(timeout time.Duration) JobOption
- func WithLabels(labels map[string]string) JobOption
- func WithNamespace(namespace string) JobOption
- func WithNodeCollectorImageRef(imageRef string) JobOption
- func WithNodeConfiguration(nodeConfig bool) JobOption
- func WithNodeName(nodeName string) JobOption
- func WithPodVolumes(volumes []corev1.Volume) JobOption
- func WithPriorityClassName(priorityClassName string) JobOption
- func WithReplaceResourceReq(replaceResourceReq bool) JobOption
- func WithResourceRequirements(rr corev1.ResourceRequirements) JobOption
- func WithTemplate(template string) JobOption
- func WithTolerations(tolerations []corev1.Toleration) JobOption
- func WithUseNodeSelectorParam(useNodeSelector bool) JobOption
- type LogsReader
- type ObjectRef
- type Runnable
- type RunnableFunc
- type Runner
- type RunnerOption
Constants ¶
const ( NodeCollectorName = "node-collector" // job headers TrivyCollectorName = "trivy.collector.name" TrivyAutoCreated = "trivy.automatic.created" TrivyResourceName = "trivy.resource.name" TrivyResourceKind = "trivy.resource.kind" )
Variables ¶
var ErrTimeout = errors.New("runner received timeout")
ErrTimeout is returned when Runner's Run method fails due to a timeout event.
Functions ¶
func ComputeHash ¶
func ComputeHash(obj interface{}) string
ComputeHash returns a hash value calculated from a given object. The hash will be safe encoded to avoid bad words.
func GetAuth ¶ added in v0.6.0
func GetAuth(opts ...AuthOption) (*rbacv1.ClusterRole, *rbacv1.ClusterRoleBinding, *corev1.ServiceAccount, error)
func GetTerminatedContainersStatusesByPod ¶
func GetTerminatedContainersStatusesByPod(pod *corev1.Pod) map[string]*corev1.ContainerStateTerminated
GetTerminatedContainersStatusesByPod collect information about contianer status by pod
Types ¶
type AuthBuilder ¶ added in v0.6.0
type AuthBuilder struct {
// contains filtered or unexported fields
}
type AuthOption ¶ added in v0.6.0
type AuthOption func(*AuthBuilder)
func WithServiceAccountNamespace ¶ added in v0.6.0
func WithServiceAccountNamespace(namespace string) AuthOption
type Collector ¶
type Collector interface { ApplyAndCollect(ctx context.Context, nodeName string) (string, error) Apply(ctx context.Context, nodeName string) (*batchv1.Job, error) AppendLabels(opts ...CollectorOption) Cleanup(ctx context.Context) }
func NewCollector ¶
func NewCollector( cluster k8s.Cluster, opts ...CollectorOption, ) Collector
type CollectorOption ¶
type CollectorOption func(*jobCollector)
func WithCollectorTimeout ¶ added in v0.6.0
func WithCollectorTimeout(timeout time.Duration) CollectorOption
func WithContainerResourceRequirements ¶ added in v0.6.0
func WithContainerResourceRequirements(rr corev1.ResourceRequirements) CollectorOption
func WithContainerSecurityContext ¶ added in v0.5.0
func WithContainerSecurityContext(securityContext *corev1.SecurityContext) CollectorOption
func WithImageRef ¶
func WithImageRef(imageRef string) CollectorOption
func WithJobAffinity ¶ added in v0.6.4
func WithJobAffinity(affinity *corev1.Affinity) CollectorOption
func WithJobAnnotation ¶ added in v0.5.5
func WithJobAnnotation(annotation map[string]string) CollectorOption
func WithJobLabels ¶
func WithJobLabels(labels map[string]string) CollectorOption
func WithJobNamespace ¶
func WithJobNamespace(namespace string) CollectorOption
func WithJobTemplateName ¶
func WithJobTemplateName(name string) CollectorOption
func WithJobTolerations ¶
func WithJobTolerations(tolerations []corev1.Toleration) CollectorOption
func WithName ¶
func WithName(name string) CollectorOption
func WithNodeConfig ¶ added in v0.6.1
func WithNodeConfig(nodeConfig bool) CollectorOption
func WithPodImagePullSecrets ¶ added in v0.5.0
func WithPodImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) CollectorOption
func WithPodPriorityClassName ¶ added in v0.5.8
func WithPodPriorityClassName(priorityClassName string) CollectorOption
func WithPodSpecSecurityContext ¶ added in v0.5.0
func WithPodSpecSecurityContext(podSecurityContext *corev1.PodSecurityContext) CollectorOption
func WithServiceAccount ¶
func WithServiceAccount(sa string) CollectorOption
func WithTimetout ¶
func WithTimetout(timeout time.Duration) CollectorOption
func WithUseNodeSelector ¶ added in v0.6.2
func WithUseNodeSelector(useNodeSelector bool) CollectorOption
func WithVolumes ¶ added in v0.5.0
func WithVolumes(volumes []corev1.Volume) CollectorOption
func WithVolumesMount ¶ added in v0.5.0
func WithVolumesMount(volumesMount []corev1.VolumeMount) CollectorOption
type JobBuilder ¶
type JobBuilder struct {
// contains filtered or unexported fields
}
type JobOption ¶
type JobOption func(*JobBuilder)
func WithAffinity ¶ added in v0.6.4
func WithAnnotation ¶
func WithContainerVolumeMounts ¶ added in v0.5.0
func WithContainerVolumeMounts(volumeMounts []corev1.VolumeMount) JobOption
func WithImagePullSecrets ¶ added in v0.5.0
func WithImagePullSecrets(imagePullSecrets []corev1.LocalObjectReference) JobOption
func WithJobName ¶
func WithJobServiceAccount ¶
func WithJobTimeout ¶ added in v0.6.0
func WithLabels ¶
func WithNamespace ¶
func WithNodeConfiguration ¶ added in v0.6.1
func WithNodeName ¶ added in v0.6.4
func WithPodVolumes ¶ added in v0.5.0
func WithPriorityClassName ¶ added in v0.5.8
func WithReplaceResourceReq ¶ added in v0.6.5
func WithResourceRequirements ¶ added in v0.6.0
func WithResourceRequirements(rr corev1.ResourceRequirements) JobOption
func WithTemplate ¶
func WithTolerations ¶
func WithTolerations(tolerations []corev1.Toleration) JobOption
func WithUseNodeSelectorParam ¶ added in v0.6.4
type LogsReader ¶
type LogsReader interface { GetLogsByJobAndContainerName(ctx context.Context, job *batchv1.Job, containerName string) (io.ReadCloser, error) GetTerminatedContainersStatusesByJob(ctx context.Context, job *batchv1.Job) (map[string]*corev1.ContainerStateTerminated, error) }
LogsReader responsible for collecting container status and logs
func NewLogsReader ¶
func NewLogsReader(clientset kubernetes.Interface) LogsReader
NewLogsReader instansiate new log reader
type Runnable ¶
Runnable is the interface that wraps the basic Run method.
Run should be implemented by any task intended to be executed by the Runner.
func NewRunnableJob ¶
func NewRunnableJob( clientset kubernetes.Interface, job *batchv1.Job, ) Runnable
NewRunnableJob constructs a new Runnable task defined as Kubernetes
type RunnableFunc ¶
The RunnableFunc type is an adapter to allow the use of ordinary functions as Runnable tasks. If f is a function with the appropriate signature, RunnableFunc(f) is a Runnable that calls f.
type Runner ¶
Runner is the interface that wraps the basic Run method.
Run executes submitted Runnable tasks.
func New ¶
func New(opts ...RunnerOption) Runner
New constructs a new ready-to-use Runner for running a Runnable task.
type RunnerOption ¶
type RunnerOption func(*runner)
func WithTimeout ¶
func WithTimeout(timeout time.Duration) RunnerOption