Documentation ¶
Index ¶
- Constants
- func AsMain(input interface{}) error
- func GVKToString(gvk *schema.GroupVersionKind) string
- func GetGVKString(o Object) string
- func Log(in ...interface{})
- func Logf(format string, in ...interface{})
- func Run(p ResourceContextProcessor, in []byte) ([]byte, error)
- func StringToGVK(s string) *schema.GroupVersionKind
- type ByteReadWriter
- type Context
- type Object
- type ResourceContext
- type ResourceContextProcessor
- type ResourceContextProcessorFunc
- type ResourceParameters
- type ResourceRef
- type Resources
- type Result
- type Results
- type Runner
- type Severity
Constants ¶
View Source
const ( Group = "fnctrlr.lcnc.io" ConditionedResourceKey = Group + "/" + "conditioned" InternalResourceKey = Group + "/" + "internal" )
Variables ¶
This section is empty.
Functions ¶
func AsMain ¶
func AsMain(input interface{}) error
AsMain evaluates the ResourceContext from STDIN to STDOUT. `input` can be - a `ResourceContextProcessor` which implements `Process` method - a function `Runner` which implements `Run` method
func GVKToString ¶
func GVKToString(gvk *schema.GroupVersionKind) string
func GetGVKString ¶
func Run ¶
func Run(p ResourceContextProcessor, in []byte) ([]byte, error)
Run evaluates the function. input must be a resourceContext in json format. An updated resourceContext will be returned.
func StringToGVK ¶
func StringToGVK(s string) *schema.GroupVersionKind
Types ¶
type ByteReadWriter ¶
type ByteReadWriter struct { // Reader is where ResourceContext are decoded from. Reader io.Reader // Writer is where ResourceContext are encoded. Writer io.Writer }
func (*ByteReadWriter) Read ¶
func (rw *ByteReadWriter) Read() (*ResourceContext, error)
type ResourceContext ¶
type ResourceContext struct { // fnconfig provides additional configuration for the function FunctionConfig map[string]runtime.RawExtension `json:"functionConfig,omitempty" yaml:"functionConfig,omitempty"` // Resources contain the resource on which this function operates Resources map[string][]runtime.RawExtension `json:"resources" yaml:"resources"` // results provide a structured Results *Results `json:"results,omitempty" yaml:"results,omitempty"` }
func ParseResourceContext ¶
func ParseResourceContext(input []byte) (*ResourceContext, error)
type ResourceContextProcessor ¶
type ResourceContextProcessor interface {
Process(fnCtx *ResourceContext) (bool, error)
}
ResourceContextProcessor is implemented by configuration functions built with this framework
func WithContext ¶
func WithContext(ctx context.Context, runner Runner) ResourceContextProcessor
type ResourceContextProcessorFunc ¶
type ResourceContextProcessorFunc func(fnCtx *ResourceContext) (bool, error)
ResourceContextProcessorFunc converts a compatible function to a ResourceContextProcessor.
func (ResourceContextProcessorFunc) Process ¶
func (p ResourceContextProcessorFunc) Process(fnCtx *ResourceContext) (bool, error)
type ResourceParameters ¶
type ResourceRef ¶
type ResourceRef struct { APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` Kind string `json:"kind,omitempty" yaml:"kind,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` }
ResourceRef fills the ResourceRef field in Results
type Resources ¶
type Resources struct {
Resources map[string][]runtime.RawExtension `json:"resources" yaml:"resources"`
}
func (*Resources) AddResource ¶
func (r *Resources) AddResource(o Object, p *ResourceParameters) error
type Result ¶
type Result struct { // Message is a human readable message. This field is required. Message string `json:"message,omitempty" yaml:"message,omitempty"` // Severity is the severity of this result Severity Severity `yaml:"severity,omitempty" json:"severity,omitempty"` // ResourceRef is a reference to a resource. // Required fields: apiVersion, kind, name. ResourceRef *ResourceRef `json:"resourceRef,omitempty" yaml:"resourceRef,omitempty"` }
Result defines a result for the fucntion execution
type Runner ¶
type Runner interface { // Run provides the entrypoint to allow you to process the resources. any crud operation // Args: // fnConfig: the configuration parameters of the function // resources: The KRM resources. // results: You can use `ErrorE` `Errorf` `Infof` to add user message to `Results`. // Returns: // return a boolean to tell whether the execution should be considered as PASS or FAIL. Run(context *Context, fnConfig map[string]runtime.RawExtension, resources *Resources, results *Results) bool }
Click to show internal directories.
Click to hide internal directories.