channel_impl

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Overview

Example (Env)
package main

import (
	"embed"
	"os"

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

	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{}
	apiVersion, kind := channel_impl.GVK().ToAPIVersionAndKind()
	cfg := map[string]interface{}{
		"name":       "foo",
		"namespace":  "bar",
		"kind":       kind,
		"apiVersion": apiVersion,
	}

	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: InMemoryChannel
metadata:
  name: foo
  namespace: bar
spec:
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",
		"apiVersion": "example.com/v1",
		"kind":       "Sample",
		"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: example.com/v1
kind: Sample
metadata:
  name: foo
  namespace: bar
spec:
  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",
		"apiVersion": "example.com/v1",
		"kind":       "Sample",
	}

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

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

apiVersion: example.com/v1
kind: Sample
metadata:
  name: foo
  namespace: bar
spec:
Example (Setenv)
package main

import (
	"embed"
	"log"
	"os"

	"github.com/kelseyhightower/envconfig"
	"knative.dev/eventing/test/rekt/resources/channel_impl"

	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{}

	_ = os.Setenv("CHANNEL_GROUP_KIND", "Sample.example.com")
	_ = os.Setenv("CHANNEL_VERSION", "v2")

	if err := envconfig.Process("", &channel_impl.EnvCfg); err != nil {
		log.Fatal("Failed to process env var", err)
	}

	apiVersion, kind := channel_impl.GVK().ToAPIVersionAndKind()
	cfg := map[string]interface{}{
		"name":       "foo",
		"namespace":  "bar",
		"kind":       kind,
		"apiVersion": apiVersion,
	}

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

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

apiVersion: example.com/v2
kind: Sample
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.

Functions

func Address

func Address(ctx context.Context, name string, timings ...time.Duration) (*apis.URL, 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 HasDeadLetterSinkURI added in v0.27.4

func HasDeadLetterSinkURI(name string, gvr schema.GroupVersionResource) feature.StepFn

HasDeadLetterSinkURI asserts that the Channel has the resolved dead letter sink URI in the status.

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 TypeMeta added in v0.31.0

func TypeMeta() metav1.TypeMeta

Types

type EnvConfig

type EnvConfig struct {
	ChannelGK string `envconfig:"CHANNEL_GROUP_KIND" default:"InMemoryChannel.messaging.knative.dev" required:"true"`
	ChannelV  string `envconfig:"CHANNEL_VERSION" default:"v1" required:"true"`
}
var EnvCfg EnvConfig

Jump to

Keyboard shortcuts

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