Documentation ¶
Overview ¶
Example (Full) ¶
package main import ( "embed" "os" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/apis" testlog "knative.dev/reconciler-test/pkg/logging" 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" ) //go:embed *.yaml var yaml embed.FS func main() { ctx := testlog.NewContext() images := map[string]string{} cfg := map[string]interface{}{ "name": "foo", "namespace": "bar", } sinkRef := &duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "sinkkind", Namespace: "sinknamespace", Name: "sinkname", APIVersion: "sinkversion", }, URI: &apis.URL{Path: "uri/parts"}, } 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)(cfg) apiserversource.WithResources(res1, res2, res3)(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: 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 ( "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: sources.knative.dev/v1 kind: ApiServerSource metadata: name: foo namespace: bar spec:
Example (WithEmptyNamespaceSelector) ¶
package main import ( "embed" "os" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" testlog "knative.dev/reconciler-test/pkg/logging" "knative.dev/eventing/test/rekt/resources/apiserversource" "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", } apiserversource.WithNamespaceSelector(&metav1.LabelSelector{ MatchLabels: map[string]string{}, MatchExpressions: []metav1.LabelSelectorRequirement{}, })(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: ApiServerSource metadata: name: foo namespace: bar spec: namespaceSelector: matchLabels: matchExpressions:
Example (WithEventMode) ¶
package main import ( "embed" "os" testlog "knative.dev/reconciler-test/pkg/logging" v1 "knative.dev/eventing/pkg/apis/sources/v1" "knative.dev/eventing/test/rekt/resources/apiserversource" "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", } apiserversource.WithEventMode(v1.ReferenceMode)(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: ApiServerSource metadata: name: foo namespace: bar spec: mode: Reference
Example (WithNamespaceSelector) ¶
package main import ( "embed" "os" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" testlog "knative.dev/reconciler-test/pkg/logging" "knative.dev/eventing/test/rekt/resources/apiserversource" "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", } apiserversource.WithNamespaceSelector(&metav1.LabelSelector{ MatchLabels: map[string]string{"env": "development"}, MatchExpressions: []metav1.LabelSelectorRequirement{{ Key: "daf", Operator: "uk", Values: []string{"a", "b"}, }}, })(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: ApiServerSource metadata: name: foo namespace: bar spec: namespaceSelector: matchLabels: env: development matchExpressions: - key: daf operator: uk values: - a - b
Example (WithResources) ¶
package main import ( "embed" "os" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" testlog "knative.dev/reconciler-test/pkg/logging" v1 "knative.dev/eventing/pkg/apis/sources/v1" "knative.dev/eventing/test/rekt/resources/apiserversource" "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", } 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.ExecuteYAML(ctx, yaml, 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 ( "embed" "os" testlog "knative.dev/reconciler-test/pkg/logging" "knative.dev/eventing/test/rekt/resources/apiserversource" "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", } apiserversource.WithServiceAccountName("src-sa")(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: ApiServerSource metadata: name: foo namespace: bar spec: serviceAccountName: src-sa
Example (WithSink) ¶
package main import ( "embed" "os" "knative.dev/pkg/apis" testlog "knative.dev/reconciler-test/pkg/logging" "knative.dev/eventing/test/rekt/resources/apiserversource" duckv1 "knative.dev/pkg/apis/duck/v1" "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", } sinkRef := &duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "sinkkind", Namespace: "sinknamespace", Name: "sinkname", APIVersion: "sinkversion", }, URI: &apis.URL{Path: "uri/parts"}, } apiserversource.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: 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 MatchLabels(labels1 map[string]string, labels2 map[string]string) bool
- func ResetNodeLabels(ctx context.Context, t feature.T)
- func SetupNodeLabels() feature.StepFn
- func TestLabels() map[string]string
- func VerifyNodeSelectorDeployment(source string) feature.StepFn
- func WithEventMode(eventMode string) manifest.CfgFn
- func WithFilters(filters []eventingv1.SubscriptionsAPIFilter) manifest.CfgFn
- func WithNamespaceSelector(selector *metav1.LabelSelector) manifest.CfgFn
- func WithResources(resources ...v1.APIVersionKindSelector) manifest.CfgFn
- func WithServiceAccountName(serviceAccountName string) manifest.CfgFn
- func WithSink(d *duckv1.Destination) 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 MatchLabels ¶ added in v0.41.0
func SetupNodeLabels ¶ added in v0.41.0
func TestLabels ¶ added in v0.41.0
func VerifyNodeSelectorDeployment ¶ added in v0.41.0
func WithEventMode ¶
WithEventMode sets the event mode on the ApiServerSource spec.
func WithFilters ¶ added in v0.42.0
func WithFilters(filters []eventingv1.SubscriptionsAPIFilter) manifest.CfgFn
func WithNamespaceSelector ¶ added in v0.36.0
func WithNamespaceSelector(selector *metav1.LabelSelector) manifest.CfgFn
WithNamespaceSelector adds a namespace selector to an 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.