Documentation ¶
Overview ¶
Example (Full) ¶
package main import ( "embed" "os" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/eventing/pkg/apis/eventing/v1alpha1" "knative.dev/eventing/test/rekt/resources/eventpolicy" "knative.dev/pkg/ptr" 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", } cfgFn := []manifest.CfgFn{ eventpolicy.WithTo([]v1alpha1.EventPolicySpecTo{ { Ref: &v1alpha1.EventPolicyToReference{ Name: "my-broker", Kind: "Broker", APIVersion: "eventing.knative.dev/v1", }, }, { Selector: &v1alpha1.EventPolicySelector{ LabelSelector: &metav1.LabelSelector{ MatchLabels: map[string]string{ "matchlabel1": "matchlabelvalue1", "matchlabel2": "matchlabelvalue2", }, MatchExpressions: []metav1.LabelSelectorRequirement{ { Key: "matchlabelselector1", Values: []string{"matchlabelselectorvalue1"}, Operator: metav1.LabelSelectorOpIn, }, }, }, TypeMeta: &metav1.TypeMeta{ APIVersion: "eventing.knative.dev/v1", Kind: "Broker", }, }, }, }...), eventpolicy.WithFrom([]v1alpha1.EventPolicySpecFrom{ { Ref: &v1alpha1.EventPolicyFromReference{ APIVersion: "eventing.knative.dev/v1", Name: "my-broker", Kind: "Broker", Namespace: "my-ns-2", }, }, { Sub: ptr.String("my-sub"), }, }...), } for _, fn := range cfgFn { fn(cfg) } files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: eventing.knative.dev/v1alpha1 kind: EventPolicy metadata: name: foo namespace: bar spec: to: - ref: apiVersion: eventing.knative.dev/v1 kind: Broker name: my-broker - selector: apiVersion: eventing.knative.dev/v1 kind: Broker matchLabels: matchlabel1: matchlabelvalue1 matchlabel2: matchlabelvalue2 matchExpressions: - key: matchlabelselector1 operator: In values: - matchlabelselectorvalue1 from: - ref: apiVersion: eventing.knative.dev/v1 kind: Broker name: my-broker namespace: my-ns-2 - sub: my-sub
Example (Min) ¶
The following examples validate the processing of the With* helper methods applied to config and go template parser.
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", "from": []map[string]interface{}{ { "ref": map[string]string{ "kind": "Broker", "name": "my-broker", "namespace": "my-ns", "apiVersion": "eventing.knative.dev/v1", }, }, }, } files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: eventing.knative.dev/v1alpha1 kind: EventPolicy metadata: name: foo namespace: bar spec: from: - ref: apiVersion: eventing.knative.dev/v1 kind: Broker name: my-broker namespace: my-ns
Index ¶
- func GVR() schema.GroupVersionResource
- func Install(name string, opts ...manifest.CfgFn) feature.StepFn
- func IsReady(name string, timing ...time.Duration) feature.StepFn
- func WithFrom(froms ...eventingv1alpha1.EventPolicySpecFrom) manifest.CfgFn
- func WithTo(tos ...eventingv1alpha1.EventPolicySpecTo) manifest.CfgFn
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GVR ¶
func GVR() schema.GroupVersionResource
func WithFrom ¶
func WithFrom(froms ...eventingv1alpha1.EventPolicySpecFrom) manifest.CfgFn
func WithTo ¶
func WithTo(tos ...eventingv1alpha1.EventPolicySpecTo) manifest.CfgFn
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.