trigger

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2021 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Overview

Example (Full)
package main

import (
	"os"

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

func main() {
	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.ExecuteLocalYAML(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 (
	"os"

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

func main() {
	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.ExecuteLocalYAML(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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

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

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

func IsReady

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

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

Types

type CfgFn

type CfgFn func(map[string]interface{})

func WithFilter

func WithFilter(attributes map[string]string) CfgFn

WithFilter adds the filter related config to a Trigger spec.

Example
package main

import (
	"os"

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

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

func main() {
	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.ExecuteLocalYAML(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 WithSubscriber

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

WithSubscriber adds the subscriber related config to a Trigger spec.

Example
package main

import (
	"os"

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

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

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

func main() {
	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.ExecuteLocalYAML(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

Jump to

Keyboard shortcuts

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