pingsource

package
v0.43.3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 9 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",
		"schedule":    "*/1 * * * *",
		"contentType": "application/json",
		"data":        `{"message": "Hello world!"}`,
		"sink": map[string]interface{}{
			"ref": map[string]string{
				"kind":       "sinkkind",
				"namespace":  "sinknamespace",
				"name":       "sinkname",
				"apiVersion": "sinkversion",
			},
			"uri": "uri/parts",
		},
	}

	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: PingSource
metadata:
  name: foo
  namespace: bar
spec:
  schedule: '*/1 * * * *'
  contentType: 'application/json'
  data: '{"message": "Hello world!"}'
  sink:
    ref:
      kind: sinkkind
      namespace: sinknamespace
      name: sinkname
      apiVersion: sinkversion
    uri: uri/parts
Example (Fullbase64)
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",
		"schedule":    "*/1 * * * *",
		"contentType": "application/json",
		"dataBase64":  "aabbccddeeff",
		"sink": map[string]interface{}{
			"ref": map[string]string{
				"kind":       "sinkkind",
				"namespace":  "sinknamespace",
				"name":       "sinkname",
				"apiVersion": "sinkversion",
			},
			"uri":     "uri/parts",
			"CACerts": "xyz",
		},
	}

	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: PingSource
metadata:
  name: foo
  namespace: bar
spec:
  schedule: '*/1 * * * *'
  contentType: 'application/json'
  dataBase64: 'aabbccddeeff'
  sink:
    ref:
      kind: sinkkind
      namespace: sinknamespace
      name: sinkname
      apiVersion: sinkversion
    uri: uri/parts
    CACerts: |-
      xyz
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",
		"brokerName": "baz",
	}

	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: PingSource
metadata:
  name: foo
  namespace: bar
spec:
Example (Schedule_with_secs)
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",
		"schedule":    "10 0/5 * * * ?",
		"contentType": "application/json",
		"data":        `{"message": "Hello world!"}`,
		"sink": map[string]interface{}{
			"ref": map[string]string{
				"kind":       "sinkkind",
				"namespace":  "sinknamespace",
				"name":       "sinkname",
				"apiVersion": "sinkversion",
			},
			"uri": "uri/parts",
		},
	}

	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: PingSource
metadata:
  name: foo
  namespace: bar
spec:
  schedule: '10 0/5 * * * ?'
  contentType: 'application/json'
  data: '{"message": "Hello world!"}'
  sink:
    ref:
      kind: sinkkind
      namespace: sinknamespace
      name: sinkname
      apiVersion: sinkversion
    uri: uri/parts

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 Broker resource, augmented with the config fn options.

func IsReady

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

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

func WithData

func WithData(contentType, data string) manifest.CfgFn

WithData adds the contentType and data config to a PingSource spec.

func WithDataBase64

func WithDataBase64(contentType, dataBase64 string) manifest.CfgFn

WithDataBase64 adds the contentType and dataBase64 config to a PingSource spec.

func WithSchedule added in v0.34.5

func WithSchedule(schedule string) manifest.CfgFn

WithSchedule add the schedule config to a Pingsource spec.

func WithSink

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

WithSink adds the sink related config to a PingSource spec.

Types

This section is empty.

Jump to

Keyboard shortcuts

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