Documentation
¶
Index ¶
- 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 ResourceRef
- type Resources
- type Result
- type Results
- type Runner
- type Severity
Constants ¶
This section is empty.
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 ¶ added in v0.0.6
func GVKToString(gvk *schema.GroupVersionKind) string
func GetGVKString ¶ added in v0.0.6
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 ¶ added in v0.0.6
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 ¶ added in v0.0.5
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 *Resources `json:"resources,omitempty" yaml:"resources,omitempty"` // 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 ¶ added in v0.0.5
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 ResourceRef ¶ added in v0.0.5
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 ¶ added in v0.0.5
type Resources struct { // holds the input KRM resources with the key being GVK in string format Input map[string][]runtime.RawExtension `json:"input,omitempty" yaml:"input,omitempty"` // holds the output KRM resources with the key being GVK in string format Output map[string][]runtime.RawExtension `json:"output,omitempty" yaml:"output,omitempty"` // holds the conditional KRM resources with the key being GVK in string format Conditions map[string][]runtime.RawExtension `json:"conditions,omitempty" yaml:"conditions,omitempty"` }
func (*Resources) AddCondition ¶ added in v0.0.6
func (*Resources) AddUniqueCondition ¶ added in v0.0.10
func (*Resources) AddUniqueIntput ¶ added in v0.0.10
func (*Resources) AddUniqueOutput ¶ added in v0.0.10
type Result ¶ added in v0.0.5
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.