trigger

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Overview

Example (Full)
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",
		"brokerName": "baz",
		"filter": map[string]interface{}{
			"attributes": map[string]string{
				"x":    "y",
				"type": "z",
			},
		},
		"subscriber": map[string]interface{}{
			"ref": map[string]string{
				"kind":       "subkind",
				"name":       "subname",
				"apiVersion": "subversion",
			},
			"uri": "/extra/path",
		},
	}

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

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

apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: foo
  namespace: bar
spec:
  broker: baz
  filter:
    attributes:
      type: "z"
      x: "y"
  subscriber:
    ref:
      kind: subkind
      namespace: bar
      name: subname
      apiVersion: subversion
    uri: /extra/path
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",
		"brokerName": "baz",
		"subscriber": map[string]interface{}{
			"ref": map[string]string{
				"kind":       "subkind",
				"name":       "subname",
				"apiVersion": "subversion",
			},
		},
	}

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

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

apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: foo
  namespace: bar
spec:
  broker: baz
  subscriber:
    ref:
      kind: subkind
      namespace: bar
      name: subname
      apiVersion: subversion
Example (Zero)
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: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: foo
  namespace: bar
spec:

Index

Examples

Constants

This section is empty.

Variables

View Source
var WithDeadLetterSink = delivery.WithDeadLetterSink

WithDeadLetterSink adds the dead letter sink related config to a Trigger spec.

View Source
var WithDeadLetterSinkFromDestination = delivery.WithDeadLetterSinkFromDestination

WithDeadLetterSinkFromDestination adds the dead letter sink related config to the config.

View Source
var WithFormat = delivery.WithFormat

WithFormat adds the format related config to a Trigger spec

View Source
var WithRetry = delivery.WithRetry

WithRetry adds the retry related config to a Trigger spec.

View Source
var WithTimeout = delivery.WithTimeout

WithTimeout adds the timeout related config to the config.

Functions

func AsKReference added in v0.41.0

func AsKReference(name string) *duckv1.KReference

func GVR added in v0.31.0

func Install

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

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

func IsReady

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

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

func WithAnnotations added in v0.35.0

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

WithAnnotations adds annotations to the trigger

func WithBrokerName added in v0.42.0

func WithBrokerName(brokerName string) manifest.CfgFn

func WithBrokerRef added in v0.42.0

func WithBrokerRef(ref *duckv1.KReference) manifest.CfgFn

WithBrokerRef adds the brokerRef related config to a Trigger spec.

func WithExtensions added in v0.35.0

func WithExtensions(extensions map[string]interface{}) manifest.CfgFn

WithExtensions adds the ceOverrides related config to a ContainerSource spec.

func WithFilter

func WithFilter(attributes map[string]string) manifest.CfgFn

WithFilter adds the filter related config to a Trigger spec.

Example
package main

import (
	"embed"
	"os"

	"knative.dev/eventing/test/rekt/resources/trigger"

	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",
		"brokerName": "baz",
	}

	trigger.WithFilter(map[string]string{
		"x":    "y",
		"type": "z",
	})(cfg)

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

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

apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: foo
  namespace: bar
spec:
  broker: baz
  filter:
    attributes:
      type: "z"
      x: "y"

func WithNewFilters added in v0.39.0

func WithNewFilters(filters []eventingv1.SubscriptionsAPIFilter) manifest.CfgFn
Example
package main

import (
	"embed"
	"os"

	eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
	"knative.dev/eventing/test/rekt/resources/trigger"

	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",
		"brokerName": "baz",
	}

	trigger.WithNewFilters([]eventingv1.SubscriptionsAPIFilter{
		{
			CESQL: "source IN ('order.created', 'order.updated', 'order.canceled')",
		},
		{
			Not: &eventingv1.SubscriptionsAPIFilter{
				CESQL: "type = 'tp'",
			},
		},
	})(cfg)

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

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

apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: foo
  namespace: bar
spec:
  broker: baz
  filters:
    - cesql: source IN ('order.created', 'order.updated', 'order.canceled')
    - not:
        cesql: type = 'tp'

func WithSubscriber

func WithSubscriber(ref *duckv1.KReference, uri string) manifest.CfgFn

WithSubscriber adds the subscriber related config to a Trigger spec.

Example
package main

import (
	"embed"
	"os"

	"knative.dev/eventing/test/rekt/resources/trigger"

	v1 "knative.dev/pkg/apis/duck/v1"

	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",
		"brokerName": "baz",
	}

	trigger.WithSubscriber(&v1.KReference{
		Kind:       "subkind",
		Name:       "subname",
		APIVersion: "subversion",
	}, "/extra/path")(cfg)

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

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

apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: foo
  namespace: bar
spec:
  broker: baz
  subscriber:
    ref:
      kind: subkind
      namespace: bar
      name: subname
      apiVersion: subversion
    uri: /extra/path

func WithSubscriberFromDestination added in v0.38.0

func WithSubscriberFromDestination(dest *duckv1.Destination) manifest.CfgFn

WithSubscriberFromDestination adds the subscriber related config to a Trigger spec.

Types

This section is empty.

Jump to

Keyboard shortcuts

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