containersource

package
v0.38.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 10 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",
		"args":      "--period=1",
		"ceOverrides": map[string]interface{}{
			"extensions": map[string]string{
				"ext1": "val1",
				"ext2": "val2",
			},
		},
		"sink": map[string]interface{}{
			"ref": map[string]interface{}{
				"kind":       "AKind",
				"namespace":  "ANamespace",
				"apiVersion": "something.valid/v1",
				"name":       "thesink",
			},
			"uri":     "uri/parts",
			"CACerts": "cert",
		},
	}

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

	manifest.OutputYAML(os.Stdout, files)
	// apiVersion: sources.knative.dev/v1
	// kind: ContainerSource
	// metadata:
	//
	//	name: foo
	//	namespace: bar
	//
	// spec:
	//
	//	ceOverrides:
	//	  extensions:
	//	    ext1: val1
	//	    ext2: val2
	//	sink:
	//	  ref:
	//	    kind: AKind
	//	    namespace: ANamespace
	//	    name: thesink
	//	    apiVersion: something.valid/v1
	//	  uri: uri/parts
	//	  CACerts: |-
	//	    cert
	//	template:
	//	  spec:
	//	    containers:
	//	    - name: heartbeats
	//	      image: ko://knative.dev/eventing/cmd/heartbeats
	//	      imagePullPolicy: IfNotPresent
	//	      args:
	//	      - --period=1
	//	      env:
	//	      - name: POD_NAME
	//	        value: heartbeats
	//	      - name: POD_NAMESPACE
	//	        value: bar
}
Output:

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",
		"args":      "--period=1",
	}

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

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

apiVersion: sources.knative.dev/v1
kind: ContainerSource
metadata:
  name: foo
  namespace: bar
spec:
  sink:
  template:
    spec:
      containers:
      - name: heartbeats
        image: ko://knative.dev/eventing/cmd/heartbeats
        imagePullPolicy: IfNotPresent
        args:
        - --period=1
        env:
        - name: POD_NAME
          value: heartbeats
        - name: POD_NAMESPACE
          value: bar
Example (Sink)
package main

import (
	"embed"
	"os"

	"knative.dev/eventing/test/rekt/resources/containersource"
	"knative.dev/pkg/apis"

	duckv1 "knative.dev/pkg/apis/duck/v1"

	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",
		"args":      "--period=1",
		"ceOverrides": map[string]interface{}{
			"extensions": map[string]string{
				"ext1": "val1",
				"ext2": "val2",
			},
		},
	}

	sinkRef := &duckv1.Destination{
		Ref: &duckv1.KReference{
			Kind:       "AKind",
			Namespace:  "sinknamespace",
			Name:       "thesink",
			APIVersion: "something.valid/v1",
		},
		URI: &apis.URL{Path: "uri/parts"},
	}
	containersource.WithSink(sinkRef)(cfg)

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

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

apiVersion: sources.knative.dev/v1
kind: ContainerSource
metadata:
  name: foo
  namespace: bar
spec:
  ceOverrides:
    extensions:
      ext1: val1
      ext2: val2
  sink:
    ref:
      kind: AKind
      namespace: sinknamespace
      name: thesink
      apiVersion: something.valid/v1
    uri: uri/parts
  template:
    spec:
      containers:
      - name: heartbeats
        image: ko://knative.dev/eventing/cmd/heartbeats
        imagePullPolicy: IfNotPresent
        args:
        - --period=1
        env:
        - name: POD_NAME
          value: heartbeats
        - name: POD_NAMESPACE
          value: bar

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gvr

func Install

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

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

func IsReady

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

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

func WithArgs added in v0.35.0

func WithArgs(args string) manifest.CfgFn

WithArgs add template.spec.containers.args to a ContainerSource spec.

func WithExtensions

func WithExtensions(extensions map[string]interface{}) manifest.CfgFn

WithExtensions adds the ceOverrides related config to a ContainerSource spec.

func WithSink added in v0.35.0

func WithSink(d *duckv1.Destination) manifest.CfgFn

WithSink adds the sink related config to a ContainerSource spec.

Types

This section is empty.

Jump to

Keyboard shortcuts

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