sequence

package
v0.42.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0 Imports: 11 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",
			},
		},
		"steps": []map[string]interface{}{{
			"ref": map[string]string{
				"apiVersion": "step0-api",
				"kind":       "step0-kind",
				"name":       "step0",
				"namespace":  "bar",
			},
			"uri": "/extra/path",
		}, {
			"ref": map[string]string{
				"apiVersion": "step1-api",
				"kind":       "step1-kind",
				"name":       "step1",
				"namespace":  "bar",
			},
			"uri": "/extra/path",
		}},
		"reply": map[string]interface{}{
			"ref": map[string]string{
				"apiVersion": "reply-api",
				"kind":       "reply-kind",
				"name":       "reply",
				"namespace":  "bar",
			},
			"uri": "/extra/path",
		},
	}

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

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

apiVersion: flows.knative.dev/v1
kind: Sequence
metadata:
  name: foo
  namespace: bar
spec:
  channelTemplate:
    apiVersion: channelimpl/v1
    kind: mychannel
    spec:
      thing1: value1
      thing2: value2
  steps:
    -
      ref:
        kind: step0-kind
        namespace: bar
        name: step0
        apiVersion: step0-api
      uri: /extra/path
    -
      ref:
        kind: step1-kind
        namespace: bar
        name: step1
        apiVersion: step1-api
      uri: /extra/path
  reply:
    ref:
      kind: reply-kind
      namespace: bar
      name: reply
      apiVersion: reply-api
    uri: /extra/path
Example (FullDelivery)
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]interface{}{
				"delivery": map[string]interface{}{
					"retry": 8,
				},
				"thing2": "value2",
			},
		},
		"steps": []map[string]interface{}{{
			"ref": map[string]string{
				"apiVersion": "step0-api",
				"kind":       "step0-kind",
				"name":       "step0",
				"namespace":  "bar",
			},
			"uri": "/extra/path",
		}, {
			"ref": map[string]string{
				"apiVersion": "step1-api",
				"kind":       "step1-kind",
				"name":       "step1",
				"namespace":  "bar",
			},
			"uri": "/extra/path",
		}},
		"reply": map[string]interface{}{
			"ref": map[string]string{
				"apiVersion": "reply-api",
				"kind":       "reply-kind",
				"name":       "reply",
				"namespace":  "bar",
			},
			"uri": "/extra/path",
		},
	}

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

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

apiVersion: flows.knative.dev/v1
kind: Sequence
metadata:
  name: foo
  namespace: bar
spec:
  channelTemplate:
    apiVersion: channelimpl/v1
    kind: mychannel
    spec:
      delivery:
        retry: 8
      thing2: value2
  steps:
    -
      ref:
        kind: step0-kind
        namespace: bar
        name: step0
        apiVersion: step0-api
      uri: /extra/path
    -
      ref:
        kind: step1-kind
        namespace: bar
        name: step1
        apiVersion: step1-api
      uri: /extra/path
  reply:
    ref:
      kind: reply-kind
      namespace: bar
      name: reply
      apiVersion: reply-api
    uri: /extra/path
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: flows.knative.dev/v1
kind: Sequence
metadata:
  name: foo
  namespace: bar
spec:
  steps:
Example (WithReply)
package main

import (
	"embed"
	"os"

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

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

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

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

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

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

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

apiVersion: flows.knative.dev/v1
kind: Sequence
metadata:
  name: foo
  namespace: bar
spec:
  steps:
  reply:
    ref:
      kind: repkind
      namespace: bar
      name: repname
      apiVersion: repversion
    uri: /extra/path
Example (WithStep)
package main

import (
	"embed"
	"os"

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

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

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

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

	sequence.WithStep(&v1.KReference{
		Kind:       "step0-kind",
		APIVersion: "step0-api",
		Namespace:  "bar",
		Name:       "step0name",
	}, "/extra/path")(cfg)

	sequence.WithStep(&v1.KReference{
		Kind:       "step1-kind",
		APIVersion: "step1-api",
		Namespace:  "bar",
		Name:       "step1name",
	}, "")(cfg)

	sequence.WithStep(nil, "http://full/path")(cfg)

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

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

apiVersion: flows.knative.dev/v1
kind: Sequence
metadata:
  name: foo
  namespace: bar
spec:
  steps:
    -
      ref:
        kind: step0-kind
        namespace: bar
        name: step0name
        apiVersion: step0-api
      uri: /extra/path
    -
      ref:
        kind: step1-kind
        namespace: bar
        name: step1name
        apiVersion: step1-api
    -
      uri: http://full/path

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

func AsRef

func AsRef(name string) *duckv1.KReference

AsRef returns a KRef for a Parallel without namespace.

func GVK

func GVR

func Install

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

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

func IsAddressable

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

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

func IsReady

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

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

func ValidateAddress added in v0.39.4

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

ValidateAddress validates the address retured by Address

func WithChannelTemplate added in v0.25.4

func WithChannelTemplate(template channel_template.ChannelTemplate) manifest.CfgFn

WithChannelTemplate adds the top level channel references.

func WithReply

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

WithReply adds the top level reply config to a Parallel spec.

func WithReplyFromDestination added in v0.39.4

func WithReplyFromDestination(dest *duckv1.Destination) manifest.CfgFn

func WithStep

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

WithStep adds the a step config to a Sequence spec at steps[len].

func WithStepFromDestination added in v0.39.4

func WithStepFromDestination(dest *duckv1.Destination) manifest.CfgFn

Types

This section is empty.

Jump to

Keyboard shortcuts

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