Documentation
¶
Overview ¶
Example (Full) ¶
package main import ( "embed" "os" "knative.dev/eventing/test/rekt/resources/pod" 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", "image": "baz", "port": "8080", "labels": map[string]string{"app": "bla"}, } pod.WithLabels(map[string]string{"overwrite": "yes"})(cfg) pod.WithImage("myimage")(cfg) files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: v1 kind: Pod metadata: name: foo namespace: bar labels: overwrite: yes spec: containers: - name: user-container image: myimage ports: - containerPort: 8080
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", "image": "baz", "port": "8080", "labels": map[string]string{"app": "bla"}, } files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: v1 kind: Pod metadata: name: foo namespace: bar labels: app: bla spec: containers: - name: user-container image: baz ports: - containerPort: 8080
Example (WithImage) ¶
package main import ( "embed" "os" "knative.dev/eventing/test/rekt/resources/pod" 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", "image": "baz", "port": "8080", "labels": map[string]string{"app": "bla"}, } pod.WithImage("myimage")(cfg) files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: v1 kind: Pod metadata: name: foo namespace: bar labels: app: bla spec: containers: - name: user-container image: myimage ports: - containerPort: 8080
Example (WithLabels) ¶
package main import ( "embed" "os" "knative.dev/eventing/test/rekt/resources/pod" 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", "image": "baz", "port": "8080", "labels": map[string]string{"app": "bla"}, } pod.WithLabels(map[string]string{"overwrite": "yes"})(cfg) files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: v1 kind: Pod metadata: name: foo namespace: bar labels: overwrite: yes spec: containers: - name: user-container image: baz ports: - containerPort: 8080
Example (WithNamespace) ¶
package main import ( "embed" "os" "knative.dev/eventing/test/rekt/resources/pod" 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", "image": "baz", "port": "8080", "labels": map[string]string{"app": "bla"}, } pod.WithNamespace("new-namespace")(cfg) files, err := manifest.ExecuteYAML(ctx, yaml, images, cfg) if err != nil { panic(err) } manifest.OutputYAML(os.Stdout, files) }
Output: apiVersion: v1 kind: Pod metadata: name: foo namespace: new-namespace labels: app: bla spec: containers: - name: user-container image: baz ports: - containerPort: 8080
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Install ¶
Install will create a Pod with defaults that can be overwritten by the With* methods.
func WithLabels ¶
WithLabels sets the given labels on the Pod.
func WithNamespace ¶ added in v0.36.0
WithOverriddenNamespace will modify the namespace of the pod from the specs to the provided one
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.