sequence

package
v0.23.4 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Example (Full)
package main

import (
	"os"

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

func main() {
	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.ExecuteLocalYAML(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 (Min)
package main

import (
	"os"

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

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

	files, err := manifest.ExecuteLocalYAML(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 (
	"os"

	"knative.dev/eventing/test/rekt/resources/sequence"
	v1 "knative.dev/pkg/apis/duck/v1"
	"knative.dev/reconciler-test/pkg/manifest"
)

func main() {
	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.ExecuteLocalYAML(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 (
	"os"

	"knative.dev/eventing/test/rekt/resources/sequence"
	v1 "knative.dev/pkg/apis/duck/v1"
	"knative.dev/reconciler-test/pkg/manifest"
)

func main() {
	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.ExecuteLocalYAML(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) (*apis.URL, 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 WithReply

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

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

func WithStep

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

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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