Documentation ¶
Index ¶
- Constants
- Variables
- func CompileInstillAcceptFormats(sch *structpb.Struct) error
- func CompileInstillFormat(sch *structpb.Struct) error
- func ConvertFromStructpb(from *structpb.Struct, to interface{}) error
- func ConvertToStructpb(from interface{}) (*structpb.Struct, error)
- func FormatErrors(inputPath string, e jsonschema.Detailed, errors *[]string)
- func NewUnresolvedSecret(key string) error
- func ReadFromSecrets(key string, secrets map[string]any) string
- func RenderJSON(tasksJSONBytes []byte, additionalJSONBytes map[string][]byte) ([]byte, error)
- func TaskIDToTitle(id string) string
- func TrimBase64Mime(b64 string) string
- func Validate(data []*structpb.Struct, jsonSchema string, target string) error
- type Component
- func (c *Component) GetDefinition(sysVars map[string]any, compConfig *ComponentConfig) (*pb.ComponentDefinition, error)
- func (c *Component) GetID() string
- func (c *Component) GetLogger() *zap.Logger
- func (c *Component) GetTaskInputSchemas() map[string]string
- func (c *Component) GetTaskOutputSchemas() map[string]string
- func (c *Component) GetUID() uuid.UUID
- func (c *Component) IsSecretField(target string) bool
- func (c *Component) ListSecretFields() ([]string, error)
- func (c *Component) LoadDefinition(definitionJSONBytes, setupJSONBytes, tasksJSONBytes []byte, ...) error
- func (c *Component) Test(sysVars map[string]any, setup *structpb.Struct) error
- func (c *Component) UsageHandlerCreator() UsageHandlerCreator
- type ComponentConfig
- type ComponentExecution
- func (e *ComponentExecution) GetLogger() *zap.Logger
- func (e *ComponentExecution) GetSetup() *structpb.Struct
- func (e *ComponentExecution) GetSystemVariables() map[string]any
- func (e *ComponentExecution) GetTask() string
- func (e *ComponentExecution) GetTaskInputSchema() string
- func (e *ComponentExecution) GetTaskOutputSchema() string
- func (e *ComponentExecution) UsageHandlerCreator() UsageHandlerCreator
- func (e *ComponentExecution) UsesSecret() bool
- type ExecutionWrapper
- type IComponent
- type IExecution
- type InstillAcceptFormatsCompiler
- type InstillAcceptFormatsSchema
- type InstillFormatCompiler
- type InstillFormatSchema
- type UsageHandler
- type UsageHandlerCreator
Constants ¶
const OpenAPITemplate = `` /* 1538-byte string literal not displayed */
const SecretKeyword = "__INSTILL_SECRET"
SecretKeyword is a keyword to reference a secret in a component configuration. When a component detects this value in a configuration parameter, it will used the pre-configured value, injected at initialization.
Variables ¶
var InstillAcceptFormatsMeta = jsonschema.MustCompileString("instillAcceptFormats.json", `{
"properties" : {
"instillAcceptFormats": {
"type": "array",
"items": {
"type": "string"
}
}
}
}`)
var InstillFormatMeta = jsonschema.MustCompileString("instillFormat.json", `{
"properties" : {
"instillFormat": {
"type": "string"
}
}
}`)
Functions ¶
func CompileInstillFormat ¶
func ConvertFromStructpb ¶
ConvertFromStructpb converts from structpb.Struct to a struct
func ConvertToStructpb ¶
ConvertToStructpb converts from a struct to structpb.Struct
func FormatErrors ¶
func NewUnresolvedSecret ¶
NewUnresolvedSecret returns an end-user error signaling that the component configuration references a global secret that wasn't injected into the component.
func ReadFromSecrets ¶
ReadFromSecrets reads a component secret from a secret map that comes from environment variable configuration.
Config parameters are defined with snake_case, but the environment variable configuration loader replaces underscores by dots, so we can't use the parameter key directly. TODO using camelCase in configuration fields would fix this issue.
func RenderJSON ¶
func TaskIDToTitle ¶
TaskIDToTitle builds a Task title from its ID. This is used when the `title` key in the task definition isn't present.
func TrimBase64Mime ¶
Types ¶
type Component ¶
Component implements the common component methods.
func (*Component) GetDefinition ¶
func (c *Component) GetDefinition(sysVars map[string]any, compConfig *ComponentConfig) (*pb.ComponentDefinition, error)
func (*Component) GetTaskInputSchemas ¶
func (*Component) GetTaskOutputSchemas ¶
func (*Component) IsSecretField ¶
IsSecretField checks if the target field is secret field
func (*Component) ListSecretFields ¶
ListSecretFields lists the secret fields by definition id
func (*Component) LoadDefinition ¶
func (c *Component) LoadDefinition(definitionJSONBytes, setupJSONBytes, tasksJSONBytes []byte, additionalJSONBytes map[string][]byte) error
LoadDefinition loads the component definitions from json files
func (*Component) UsageHandlerCreator ¶
func (c *Component) UsageHandlerCreator() UsageHandlerCreator
UsageHandlerCreator returns a function to initialize a UsageHandler.
type ComponentConfig ¶
type ComponentConfig struct { Type string `json:"type,omitempty"` Task string `json:"task,omitempty"` Input map[string]any `json:"input,omitempty"` Condition *string `json:"condition,omitempty"` Setup map[string]any `json:"setup,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` Definition *pb.ComponentDefinition `json:"definition,omitempty"` }
func (*ComponentConfig) GetCondition ¶
func (c *ComponentConfig) GetCondition() *string
func (*ComponentConfig) IsComponent ¶
func (c *ComponentConfig) IsComponent()
type ComponentExecution ¶
type ComponentExecution struct { Component IComponent SystemVariables map[string]any Setup *structpb.Struct Task string }
ComponentExecution implements the common methods for component execution.
func (*ComponentExecution) GetLogger ¶
func (e *ComponentExecution) GetLogger() *zap.Logger
func (*ComponentExecution) GetSetup ¶
func (e *ComponentExecution) GetSetup() *structpb.Struct
func (*ComponentExecution) GetSystemVariables ¶
func (e *ComponentExecution) GetSystemVariables() map[string]any
func (*ComponentExecution) GetTask ¶
func (e *ComponentExecution) GetTask() string
func (*ComponentExecution) GetTaskInputSchema ¶
func (e *ComponentExecution) GetTaskInputSchema() string
func (*ComponentExecution) GetTaskOutputSchema ¶
func (e *ComponentExecution) GetTaskOutputSchema() string
func (*ComponentExecution) UsageHandlerCreator ¶
func (e *ComponentExecution) UsageHandlerCreator() UsageHandlerCreator
UsageHandlerCreator returns a function to initialize a UsageHandler.
func (*ComponentExecution) UsesSecret ¶
func (e *ComponentExecution) UsesSecret() bool
UsesSecret indicates wether the connector execution is configured with global secrets. Components should override this method when they have the ability to be executed with global secrets.
type ExecutionWrapper ¶
type ExecutionWrapper struct {
Execution IExecution
}
ExecutionWrapper performs validation and usage collection around the execution of a component.
type IComponent ¶
type IComponent interface { GetID() string GetUID() uuid.UUID GetLogger() *zap.Logger GetTaskInputSchemas() map[string]string GetTaskOutputSchemas() map[string]string LoadDefinition(definitionJSON, setupJSON, tasksJSON []byte, additionalJSONBytes map[string][]byte) error // Note: Some content in the definition JSON schema needs to be generated // by sysVars or component setting. GetDefinition(sysVars map[string]any, compConfig *ComponentConfig) (*pb.ComponentDefinition, error) CreateExecution(sysVars map[string]any, setup *structpb.Struct, task string) (*ExecutionWrapper, error) Test(sysVars map[string]any, config *structpb.Struct) error IsSecretField(target string) bool UsageHandlerCreator() UsageHandlerCreator }
IComponent is the interface that wraps the basic component methods. All component need to implement this interface.
type IExecution ¶
type IExecution interface { GetTask() string GetLogger() *zap.Logger GetTaskInputSchema() string GetTaskOutputSchema() string GetSystemVariables() map[string]any UsesSecret() bool UsageHandlerCreator() UsageHandlerCreator Execute(context.Context, []*structpb.Struct) ([]*structpb.Struct, error) }
IExecution allows components to be executed.
type InstillAcceptFormatsCompiler ¶
type InstillAcceptFormatsCompiler struct{}
func (InstillAcceptFormatsCompiler) Compile ¶
func (InstillAcceptFormatsCompiler) Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error)
type InstillAcceptFormatsSchema ¶
type InstillAcceptFormatsSchema []string
func (InstillAcceptFormatsSchema) Validate ¶
func (s InstillAcceptFormatsSchema) Validate(ctx jsonschema.ValidationContext, v interface{}) error
type InstillFormatCompiler ¶
type InstillFormatCompiler struct{}
func (InstillFormatCompiler) Compile ¶
func (InstillFormatCompiler) Compile(ctx jsonschema.CompilerContext, m map[string]interface{}) (jsonschema.ExtSchema, error)
type InstillFormatSchema ¶
type InstillFormatSchema string
func (InstillFormatSchema) Validate ¶
func (s InstillFormatSchema) Validate(ctx jsonschema.ValidationContext, v interface{}) error
type UsageHandler ¶
type UsageHandler interface { Check(ctx context.Context, inputs []*structpb.Struct) error Collect(ctx context.Context, inputs, outputs []*structpb.Struct) error }
UsageHandler allows the component execution wrapper to add checks and collect usage metrics around a component execution.
func NewNoopUsageHandler ¶
func NewNoopUsageHandler(IExecution) (UsageHandler, error)
NewNoopUsageHandler is a no-op usage handler initializer.
type UsageHandlerCreator ¶
type UsageHandlerCreator func(IExecution) (UsageHandler, error)
UsageHandlerCreator returns a function to initialize a UsageHandler.