jobsink

package
v0.43.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Example (Full)
package main

import (
	"embed"
	"os"

	batchv1 "k8s.io/api/batch/v1"
	corev1 "k8s.io/api/core/v1"

	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"knative.dev/pkg/ptr"

	testlog "knative.dev/reconciler-test/pkg/logging"
	"knative.dev/reconciler-test/pkg/manifest"

	"knative.dev/eventing/test/rekt/resources/jobsink"
)

//go:embed *.yaml
var yaml embed.FS

func main() {
	ctx := testlog.NewContext()
	images := map[string]string{}
	cfg := map[string]interface{}{
		"name":      "foo",
		"namespace": "bar",
	}

	jobsink.WithJob(batchv1.Job{
		TypeMeta:   metav1.TypeMeta{},
		ObjectMeta: metav1.ObjectMeta{},
		Spec: batchv1.JobSpec{
			Parallelism: ptr.Int32(1),
			Template: corev1.PodTemplateSpec{
				Spec: corev1.PodSpec{
					Containers: []corev1.Container{
						{Name: "job-c"},
					},
				},
			},
		},
	})(cfg)

	files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg)
	if err != nil {
		panic(err)
	}

	manifest.OutputYAML(os.Stdout, files)
}
Output:

apiVersion: sinks.knative.dev/v1alpha1
kind: JobSink
metadata:
  name: foo
  namespace: bar
spec:
  job:
    metadata:
      creationTimestamp: null
    spec:
      parallelism: 1
      template:
        metadata:
          creationTimestamp: null
        spec:
          containers:
          - name: job-c
            resources: {}
    status: {}
Example (Min)
package main

import (
	"embed"
	"os"

	testlog "knative.dev/reconciler-test/pkg/logging"
	"knative.dev/reconciler-test/pkg/manifest"
)

//go:embed *.yaml
var yaml embed.FS

func main() {
	ctx := testlog.NewContext()
	images := map[string]string{}
	cfg := map[string]interface{}{
		"name":      "foo",
		"namespace": "bar",
	}

	files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg)
	if err != nil {
		panic(err)
	}

	manifest.OutputYAML(os.Stdout, files)
}
Output:

apiVersion: sinks.knative.dev/v1alpha1
kind: JobSink
metadata:
  name: foo
  namespace: bar
spec:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(ctx context.Context, name string, timings ...time.Duration) (*duckv1.Addressable, error)

Address returns a JobSink's address.

func AsDestinationRef

func AsDestinationRef(name string) *duckv1.Destination

func AsKReference

func AsKReference(name string) *duckv1.KReference

AsKReference returns a KReference for a JobSink without namespace.

func GVR

func GoesReadySimple added in v0.43.0

func GoesReadySimple(name string) *feature.Feature

GoesReadySimple returns a feature that will create a JobSink with a simple sink and confirm it becomes ready with an address.

func Install

func Install(name string, opts ...manifest.CfgFn) feature.StepFn

Install will create a resource, augmented with the config fn options.

func IsAddressable

func IsAddressable(name string, timings ...time.Duration) feature.StepFn

IsAddressable tests to see if a JobSink becomes addressable within the time given.

func IsNotReady

func IsNotReady(name string, timing ...time.Duration) feature.StepFn

IsNotReady tests to see if a JobSink becomes NotReady within the time given.

func IsReady

func IsReady(name string, timing ...time.Duration) feature.StepFn

IsReady tests to see if a JobSink becomes ready within the time given.

func ValidateAddress

func ValidateAddress(name string, validate addressable.ValidateAddressFn, timings ...time.Duration) feature.StepFn

ValidateAddress validates the address retured by Address

func WithAnnotations

func WithAnnotations(annotations map[string]interface{}) manifest.CfgFn

WithAnnotations adds annotations to the JobSink.

func WithForwarderJob

func WithForwarderJob(sink string, options ...func(*batchv1.Job)) manifest.CfgFn

func WithJob

func WithJob(job batchv1.Job) manifest.CfgFn

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL