subscription

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Overview

Example (Full)
package main

import (
	"embed"
	"os"

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

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

func main() {
	images := map[string]string{}
	cfg := map[string]interface{}{
		"name":      "foo",
		"namespace": "bar",
		"subscriber": map[string]interface{}{
			"ref": map[string]string{
				"kind":       "subkind",
				"name":       "subname",
				"apiVersion": "subversion",
			},
			"uri": "/extra/path",
		},
		"reply": map[string]interface{}{
			"ref": map[string]string{
				"kind":       "repkind",
				"name":       "repname",
				"apiVersion": "repversion",
			},
			"uri": "/extra/path",
		},
		"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(yaml, images, cfg)
	if err != nil {
		panic(err)
	}

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

apiVersion: messaging.knative.dev/v1
kind: Subscription
metadata:
  name: foo
  namespace: bar
spec:
  subscriber:
    ref:
      kind: subkind
      namespace: bar
      name: subname
      apiVersion: subversion
    uri: /extra/path
  reply:
    ref:
      kind: repkind
      namespace: bar
      name: repname
      apiVersion: repversion
    uri: /extra/path
  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"

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

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

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.ExecuteYAML(yaml, images, cfg)
	if err != nil {
		panic(err)
	}

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

apiVersion: messaging.knative.dev/v1
kind: Subscription
metadata:
  name: foo
  namespace: bar
spec:
  subscriber:
    ref:
      kind: subkind
      namespace: bar
      name: subname
      apiVersion: subversion
Example (Zero)
package main

import (
	"embed"
	"os"

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

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

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

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

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

apiVersion: messaging.knative.dev/v1
kind: Subscription
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 Subscription spec.

View Source
var WithRetry = delivery.WithRetry

WithRetry adds the retry related config to a Subscription spec.

Functions

func Install

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

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

func IsReady

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

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

func WithChannel

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

WithChannel adds the channel related config to a Subscription spec.

Example
package main

import (
	"embed"
	"os"

	v1 "knative.dev/pkg/apis/duck/v1"
	"knative.dev/reconciler-test/pkg/manifest"

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

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

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

	subscription.WithChannel(&v1.KReference{
		Kind:       "chkind",
		Name:       "chname",
		APIVersion: "chversion",
	})(cfg)
	files, err := manifest.ExecuteYAML(yaml, images, cfg)
	if err != nil {
		panic(err)
	}

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

apiVersion: messaging.knative.dev/v1
kind: Subscription
metadata:
  name: foo
  namespace: bar
spec:
  channel:
    kind: chkind
    name: chname
    apiVersion: chversion

func WithReply

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

WithSubscriber adds the subscriber related config to a Subscription spec.

Example
package main

import (
	"embed"
	"os"

	v1 "knative.dev/pkg/apis/duck/v1"
	"knative.dev/reconciler-test/pkg/manifest"

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

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

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

	subscription.WithReply(&v1.KReference{
		Kind:       "repkind",
		Name:       "repname",
		APIVersion: "repversion",
	}, "/extra/path")(cfg)

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

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

apiVersion: messaging.knative.dev/v1
kind: Subscription
metadata:
  name: foo
  namespace: bar
spec:
  reply:
    ref:
      kind: repkind
      namespace: bar
      name: repname
      apiVersion: repversion
    uri: /extra/path

func WithSubscriber

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

WithSubscriber adds the subscriber related config to a Subscription spec.

Example
package main

import (
	"embed"
	"os"

	v1 "knative.dev/pkg/apis/duck/v1"
	"knative.dev/reconciler-test/pkg/manifest"

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

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

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

	subscription.WithSubscriber(&v1.KReference{
		Kind:       "subkind",
		Name:       "subname",
		APIVersion: "subversion",
	}, "/extra/path")(cfg)
	files, err := manifest.ExecuteYAML(yaml, images, cfg)
	if err != nil {
		panic(err)
	}

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

apiVersion: messaging.knative.dev/v1
kind: Subscription
metadata:
  name: foo
  namespace: bar
spec:
  subscriber:
    ref:
      kind: subkind
      namespace: bar
      name: subname
      apiVersion: subversion
    uri: /extra/path

Types

This section is empty.

Jump to

Keyboard shortcuts

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