channel

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

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",
		"channelTemplate": map[string]interface{}{
			"apiVersion": "channelimpl/v1",
			"kind":       "mychannel",
			"spec": map[string]string{
				"thing1": "value1",
				"thing2": "value2",
			},
		},
		"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: messaging.knative.dev/v1
kind: Channel
metadata:
  name: foo
  namespace: bar
spec:
  channelTemplate:
    apiVersion: channelimpl/v1
    kind: mychannel
    spec:
      thing1: value1
      thing2: value2
  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",
	}

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

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

apiVersion: messaging.knative.dev/v1
kind: Channel
metadata:
  name: foo
  namespace: bar
spec:
Example (WithTemplate)
package main

import (
	"embed"
	"encoding/json"
	"os"

	"k8s.io/apimachinery/pkg/runtime"
	testlog "knative.dev/reconciler-test/pkg/logging"
	"knative.dev/reconciler-test/pkg/manifest"

	messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1"
	"knative.dev/eventing/test/rekt/resources/channel"
)

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

func main() {
	ctx := testlog.NewContext()
	spec := map[string]string{
		"thing1": "value1",
		"thing2": "value2",
	}
	bytesSpec, err := json.Marshal(spec)
	if err != nil {
		panic(err)
	}

	re := &runtime.RawExtension{
		Raw: bytesSpec,
	}

	images := map[string]string{}
	cfg := map[string]interface{}{
		"name":      "foo",
		"namespace": "bar",
	}
	withTemplate := channel.WithTemplate(func(spec *messagingv1.ChannelTemplateSpec) error {
		spec.Spec = re
		return nil
	})
	withTemplate(cfg)

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

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

apiVersion: messaging.knative.dev/v1
kind: Channel
metadata:
  name: foo
  namespace: bar
spec:
  channelTemplate:
    apiVersion: messaging.knative.dev/v1
    kind: InMemoryChannel
    spec:
      thing1: value1
      thing2: value2

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 Channel's address.

func AsRef

func AsRef(name string) *duckv1.KReference

AsRef returns a KRef for a Channel without namespace.

func GVK

func GVR

func Install

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

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

func IsAddressable

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

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

func IsReady

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

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

func WithTemplate added in v0.27.4

func WithTemplate(options ...messagingv1.ChannelTemplateSpecOption) manifest.CfgFn

WithTemplate adds channelTemplate to the Channel's config after apply the provided options.

Types

This section is empty.

Jump to

Keyboard shortcuts

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