Documentation ¶
Overview ¶
Example (Full) ¶
package main import ( "os" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "knative.dev/eventing/pkg/apis/sources/v1" "knative.dev/eventing/test/rekt/resources/apiserversource" duckv1 "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", } sinkRef := &duckv1.KReference{ Kind: "sinkkind", Namespace: "sinknamespace", Name: "sinkname", APIVersion: "sinkversion", } res1 := v1.APIVersionKindSelector{ APIVersion: "res1apiVersion", Kind: "res1kind", LabelSelector: nil, } res2 := v1.APIVersionKindSelector{ APIVersion: "res2apiVersion", Kind: "res2kind", LabelSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{"foo": "bar"}, MatchExpressions: nil, }, } res3 := v1.APIVersionKindSelector{ APIVersion: "res3apiVersion", Kind: "res3kind", LabelSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{"foo": "bar"}, MatchExpressions: []metav1.LabelSelectorRequirement{{ Key: "daf", Operator: "uk", Values: []string{"a", "b"}, }}, }, } apiserversource.WithServiceAccountName("src-sa")(cfg) apiserversource.WithEventMode(v1.ReferenceMode)(cfg) apiserversource.WithSink(sinkRef, "uri/parts")(cfg) apiserversource.WithResources(res1, res2, res3)(cfg) files, err := manifest.ExecuteLocalYAML(images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: sources.knative.dev/v1 kind: ApiServerSource metadata: name: foo namespace: bar spec: serviceAccountName: src-sa mode: Reference resources: - apiVersion: res1apiVersion kind: res1kind - apiVersion: res2apiVersion kind: res2kind selector: matchLabels: foo: bar - apiVersion: res3apiVersion kind: res3kind selector: matchLabels: foo: bar matchExpressions: - key: daf operator: uk values: - a - b sink: ref: kind: sinkkind namespace: sinknamespace name: sinkname apiVersion: sinkversion uri: uri/parts
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: sources.knative.dev/v1 kind: ApiServerSource metadata: name: foo namespace: bar spec:
Example (WithEventMode) ¶
package main import ( "os" v1 "knative.dev/eventing/pkg/apis/sources/v1" "knative.dev/eventing/test/rekt/resources/apiserversource" "knative.dev/reconciler-test/pkg/manifest" ) func main() { images := map[string]string{} cfg := map[string]interface{}{ "name": "foo", "namespace": "bar", } apiserversource.WithEventMode(v1.ReferenceMode)(cfg) files, err := manifest.ExecuteLocalYAML(images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: sources.knative.dev/v1 kind: ApiServerSource metadata: name: foo namespace: bar spec: mode: Reference
Example (WithResources) ¶
package main import ( "os" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "knative.dev/eventing/pkg/apis/sources/v1" "knative.dev/eventing/test/rekt/resources/apiserversource" "knative.dev/reconciler-test/pkg/manifest" ) func main() { images := map[string]string{} cfg := map[string]interface{}{ "name": "foo", "namespace": "bar", } res1 := v1.APIVersionKindSelector{ APIVersion: "res1apiVersion", Kind: "res1kind", LabelSelector: nil, } res2 := v1.APIVersionKindSelector{ APIVersion: "res2apiVersion", Kind: "res2kind", LabelSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{"foo": "bar"}, MatchExpressions: nil, }, } res3 := v1.APIVersionKindSelector{ APIVersion: "res3apiVersion", Kind: "res3kind", LabelSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{"foo": "bar"}, MatchExpressions: []metav1.LabelSelectorRequirement{{ Key: "daf", Operator: "uk", Values: []string{"a", "b"}, }}, }, } apiserversource.WithResources(res1, res2, res3)(cfg) files, err := manifest.ExecuteLocalYAML(images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: sources.knative.dev/v1 kind: ApiServerSource metadata: name: foo namespace: bar spec: resources: - apiVersion: res1apiVersion kind: res1kind - apiVersion: res2apiVersion kind: res2kind selector: matchLabels: foo: bar - apiVersion: res3apiVersion kind: res3kind selector: matchLabels: foo: bar matchExpressions: - key: daf operator: uk values: - a - b
Example (WithServiceAccountName) ¶
package main import ( "os" "knative.dev/eventing/test/rekt/resources/apiserversource" "knative.dev/reconciler-test/pkg/manifest" ) func main() { images := map[string]string{} cfg := map[string]interface{}{ "name": "foo", "namespace": "bar", } apiserversource.WithServiceAccountName("src-sa")(cfg) files, err := manifest.ExecuteLocalYAML(images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: sources.knative.dev/v1 kind: ApiServerSource metadata: name: foo namespace: bar spec: serviceAccountName: src-sa
Example (WithSink) ¶
package main import ( "os" "knative.dev/eventing/test/rekt/resources/apiserversource" duckv1 "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", } sinkRef := &duckv1.KReference{ Kind: "sinkkind", Namespace: "sinknamespace", Name: "sinkname", APIVersion: "sinkversion", } apiserversource.WithSink(sinkRef, "uri/parts")(cfg) files, err := manifest.ExecuteLocalYAML(images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: sources.knative.dev/v1 kind: ApiServerSource metadata: name: foo namespace: bar spec: sink: ref: kind: sinkkind namespace: sinknamespace name: sinkname apiVersion: sinkversion uri: uri/parts
Index ¶
- func Gvr() schema.GroupVersionResource
- func Install(name string, opts ...manifest.CfgFn) feature.StepFn
- func InstallLocalYaml(ctx context.Context, name string, opts ...manifest.CfgFn) (manifest.Manifest, error)
- func IsReady(name string, timings ...time.Duration) feature.StepFn
- func WithEventMode(eventMode string) manifest.CfgFn
- func WithResources(resources ...v1.APIVersionKindSelector) manifest.CfgFn
- func WithServiceAccountName(serviceAccountName string) manifest.CfgFn
- func WithSink(ref *duckv1.KReference, uri string) manifest.CfgFn
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Gvr ¶
func Gvr() schema.GroupVersionResource
func Install ¶
Install returns a step function which creates an ApiServerSource resource, augmented with the config fn options.
func InstallLocalYaml ¶
func InstallLocalYaml(ctx context.Context, name string, opts ...manifest.CfgFn) (manifest.Manifest, error)
InstallLocalYaml will create a ApiServerSource resource, augmented with the config fn options.
func WithEventMode ¶
WithEventMode sets the event mode on the ApiServerSource spec.
func WithResources ¶
func WithResources(resources ...v1.APIVersionKindSelector) manifest.CfgFn
WithResources adds the resources related config to a ApiServerSource spec.
func WithServiceAccountName ¶
WithServiceAccountName sets the service account name on the ApiServerSource spec.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.