{"modulePath":"github.com/Azure/eno","version":"v0.2.28","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package function\n\n## Variables\n\n```go\nvar ErrInputNotFound = errors.New(\"input not found\")\n```\n\n```go\nvar ErrInputReadingFailed = errors.New(\"input reading failed\")\n```\n\n```go\nvar Scheme = scheme.Scheme\n```\n\n## Functions\n\n```go\nfunc AddCustomInputType[Resource client.Object, Custom any](bind func(Resource) (Custom, error))\n```\nAddCustomInputType allows types that do not implement client.Object to be used as fields of Inputs structs.\n\n```go\nfunc Main[T Inputs](fn SynthFunc[T], opts ...Option)\n```\nMain is the entrypoint for Eno synthesizer processes written using the framework defined by this package.\n\n```go\nfunc ReadInput[T client.Object](ir *InputReader, key string, out T) error\n```\n\n```go\nfunc ReadManifest(path string) ([]client.Object, error)\n```\nReadManifest reads a YAML file from disk and parses each document into an unstructured object.\n\n## Types\n\n```go\ntype InputReader struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewDefaultInputReader() (*InputReader, error)\n```\n\n```go\nfunc NewInputReader(r io.Reader) (*InputReader, error)\n```\n\n```go\nfunc (i *InputReader) All() map[string]*unstructured.Unstructured\n```\n\n```go\nfunc (ir *InputReader) IsOptional(key string) bool\n```\nIsOptional returns true if the input with the given key is marked as optional. This is determined by checking the FunctionConfig.optionalRefs list which contains all optional ref keys from the synthesizer spec.\n\n```go\ntype Inputs interface{}\n```\nInputs is satisfied by any struct that defines the inputs required by a SynthFunc. Use the \\`eno\\_key\\` struct tag to specify the corresponding ref key for each input. Each field must either be a client.Object or a custom type registered with AddCustomInputType.\n\n```go\ntype MungableInputs interface {\n\tMunge() error\n}\n```\nMungableInputs is an optional interface that can be implemented by Inputs structs if it is, it gets called after inputs are read. It can fail the whole Synthesis.\n\n```go\ntype MungeFunc func(*unstructured.Unstructured)\n```\n\n```go\ntype Option func(*mainConfig)\n```\noption defines an option for configuring/augmenting the Main function.\n\n```go\nfunc WithManagedByEno() Option\n```\nWithManagedByEno returns an iption that annotates the given Kubernetes object to indicate that it is managed by Eno. It sets the \"eno.azure.io/managed-by\" annotation to the Eno controller identifier.\n\n```go\nfunc WithMunger(m MungeFunc) Option\n```\nWithMunger adds a munge function that will be applied to each output object. Multiple munge functions can be provided and they will be applied in order.\n\nExample usage:\n\n\tMain(synthesizer,\n\t\tWithMunger(func(obj *unstructured.Unstructured) {\n\t\t\t// Add common labels\n\t\t\tlabels := obj.GetLabels()\n\t\t\tif labels == nil {\n\t\t\t\tlabels = make(map[string]string)\n\t\t\t}\n\t\t\tlabels[\"app.kubernetes.io/managed-by\"] = \"eno\"\n\t\t\tobj.SetLabels(labels)\n\t\t}),\n\t\tWithMunger(func(obj *unstructured.Unstructured) {\n\t\t\t// Add environment-specific annotations\n\t\t\tannotations := obj.GetAnnotations()\n\t\t\tif annotations == nil {\n\t\t\t\tannotations = make(map[string]string)\n\t\t\t}\n\t\t\tannotations[\"eno.azure.io/reconcile-interval\"] = \"1m\"\n\t\t\tobj.SetAnnotations(annotations)\n\t\t}),\n\t)\n\n```go\nfunc WithReconcilationInterval(interval time.Duration) Option\n```\nWithReconcilationInterval returns an option that annotates the given Kubernetes object to configure its reconciliation interval. It sets the \"eno.azure.io/reconcile-interval\" annotation to the provided duration string, which controls how frequently Eno will reconcile the resource.\n\n```go\nfunc WithScheme(scheme *runtime.Scheme) Option\n```\nWithScheme configures the runtime.Scheme used for automatic type metadata inference.\n\nThe scheme enables automatic population of TypeMeta (apiVersion and kind) fields for Kubernetes objects based on their Go types. When an object is processed and its GroupVersionKind is empty, the scheme will be consulted to determine the appropriate apiVersion and kind values.\n\nIf no scheme is provided, or if an object's type is not registered in the scheme, the object will be processed without modification.\n\nExample usage:\n\n\tscheme := runtime.NewScheme()\n\tcorev1.AddToScheme(scheme)\n\tappsv1.AddToScheme(scheme)\n\tMain(synthesizer, WithScheme(scheme))\n\n```go\ntype OutputWriter struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewDefaultOutputWriter() *OutputWriter\n```\n\n```go\nfunc NewOutputWriter(w io.Writer, munge MungeFunc) *OutputWriter\n```\n\n```go\nfunc (w *OutputWriter) Add(outs ...client.Object) error\n```\n\n```go\nfunc (w *OutputWriter) AddResult(result *krmv1.Result)\n```\n\n```go\nfunc (w *OutputWriter) Write() error\n```\n\n```go\ntype SynthFunc[T Inputs] func(inputs T) ([]client.Object, error)\n```\nSynthFunc defines a synthesizer function that takes a set of inputs and returns a list of objects.\n\n","path":"github.com/Azure/eno/pkg/function","name":"function","synopsis":"","isRedistributable":true}
