broker

package
v0.43.2 Latest Latest
Warning

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

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

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",
		"brokerClass": "a-broker-class",
		"config": map[string]interface{}{
			"kind":       "cfgkind",
			"name":       "cfgname",
			"apiVersion": "cfgapi",
		},
		"delivery": map[string]interface{}{
			"retry":         "42",
			"backoffPolicy": "exponential",
			"backoffDelay":  "2007-03-01T13:00:00Z/P1Y2M10DT2H30M",
			"deadLetterSink": map[string]interface{}{
				"ref": map[string]string{
					"kind":       "deadkind",
					"name":       "deadname",
					"apiVersion": "deadapi",
				},
				"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: Broker
metadata:
  name: foo
  namespace: bar
  annotations:
    eventing.knative.dev/broker.class: a-broker-class
spec:
  config:
    kind: cfgkind
    namespace: bar
    name: cfgname
    apiVersion: cfgapi
  delivery:
    deadLetterSink:
      ref:
        kind: deadkind
        namespace: bar
        name: deadname
        apiVersion: deadapi
      uri: /extra/path
    retry: 42
    backoffPolicy: exponential
    backoffDelay: "2007-03-01T13:00:00Z/P1Y2M10DT2H30M"
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",
	}

	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: Broker
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 Broker spec.

View Source
var WithRetry = delivery.WithRetry

WithRetry adds the retry related config to a Broker spec.

View Source
var WithTimeout = delivery.WithTimeout

WithTimeout adds the timeout related config to the config.

Functions

func Address

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

Address returns a broker's address.

func AsDestinationRef added in v0.39.0

func AsDestinationRef(name string) *duckv1.Destination

func AsKReference added in v0.39.0

func AsKReference(name string) *duckv1.KReference

AsKReference returns a KReference for a Broker without namespace.

func GVR added in v0.22.0

func Install

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

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

func InstallMTBroker added in v0.39.0

func InstallMTBroker(name string) *feature.Feature

func InstallMTBrokerStepFn added in v0.42.0

func InstallMTBrokerStepFn(brokerName string) feature.StepFn

func IsAddressable

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

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

func IsNotReady added in v0.36.5

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

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

func IsReady

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

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

func ValidateAddress added in v0.38.5

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

ValidateAddress validates the address retured by Address

func WaitForCondition added in v0.29.0

func WaitForCondition(name string, condition Condition, timing ...time.Duration) feature.StepFn

func WithAnnotations added in v0.36.0

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

WithAnnotations adds annotations to the broker

Example
package main

import (
	"embed"
	"os"

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

	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",
	}
	broker.WithAnnotations(map[string]interface{}{
		"eventing.knative.dev/foo": "bar",
	})(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: Broker
metadata:
  name: foo
  namespace: bar
  annotations:
    eventing.knative.dev/foo: bar
spec:

func WithBrokerClass

func WithBrokerClass(class string) manifest.CfgFn

WithBrokerClass adds the broker class config to a Broker spec.

Example
package main

import (
	"embed"
	"os"

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

	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",
	}
	broker.WithBrokerClass("a-broker-class")(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: Broker
metadata:
  name: foo
  namespace: bar
  annotations:
    eventing.knative.dev/broker.class: a-broker-class
spec:

func WithBrokerTemplateFiles added in v0.22.0

func WithBrokerTemplateFiles(dir string) manifest.CfgFn

func WithConfig added in v0.24.0

func WithConfig(name string) manifest.CfgFn

WithConfig adds the specified config map to the Broker spec.

Example
package main

import (
	"embed"
	"os"

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

	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",
	}
	broker.WithConfig("my-funky-config")(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: Broker
metadata:
  name: foo
  namespace: bar
spec:
  config:
    kind: ConfigMap
    namespace: bar
    name: my-funky-config
    apiVersion: v1

func WithConfigNamespace added in v0.36.0

func WithConfigNamespace(namespace string) manifest.CfgFn

WithConfigNamespace adds the specified config map namespace to the Broker spec.

Example
package main

import (
	"embed"
	"os"

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

	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",
	}

	broker.WithConfigNamespace("knative-eventing")(cfg)
	broker.WithConfig("my-funky-config")(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: Broker
metadata:
  name: foo
  namespace: bar
spec:
  config:
    kind: ConfigMap
    namespace: knative-eventing
    name: my-funky-config
    apiVersion: v1

func WithEnvConfig added in v0.22.0

func WithEnvConfig() []manifest.CfgFn

func WithNamespace added in v0.42.0

func WithNamespace(namespace string) manifest.CfgFn

Types

type Condition added in v0.29.0

type Condition struct {
	Name      string
	Condition func(br eventingv1.Broker) (bool, error)
}

func HasDelivery added in v0.29.0

func HasDelivery() Condition

func HasDeliveryBackoffDelay added in v0.29.0

func HasDeliveryBackoffDelay() Condition

func HasDeliveryBackoffPolicy added in v0.29.0

func HasDeliveryBackoffPolicy() Condition

func HasDeliveryRetry added in v0.29.0

func HasDeliveryRetry() Condition

func (Condition) And added in v0.29.0

func (c Condition) And(other Condition) Condition

type EnvConfig added in v0.22.0

type EnvConfig struct {
	BrokerClass        string `envconfig:"BROKER_CLASS" default:"MTChannelBasedBroker" required:"true"`
	BrokerTemplatesDir string `envconfig:"BROKER_TEMPLATES"`
}
var EnvCfg EnvConfig

Jump to

Keyboard shortcuts

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