Documentation
¶
Index ¶
- Constants
- func InvokeActionEvaluation(action Action, p Provider, name string, config []byte, input []byte) ([]byte, error)
- func MarshalVal(schema Schema, val cty.Value) ([]byte, error)
- func UnmarshalVal(schema Schema, data []byte) (cty.Value, error)
- type Action
- type AttrSchema
- type BlockSchema
- type EvaluateServerPayload
- type Function
- type ObjectSchema
- type Provider
- type ProviderPlugin
- type ProviderRPCClient
- func (p *ProviderRPCClient) ActionConfigurationSchema(name string) (ObjectSchema, error)
- func (p *ProviderRPCClient) ActionEvaluate(name string, config []byte, input []byte) ([]byte, error)
- func (p *ProviderRPCClient) ActionNames() ([]string, error)
- func (p *ProviderRPCClient) ActionOutputType(name string) (Type, error)
- func (p *ProviderRPCClient) Init(val []byte) error
- func (p *ProviderRPCClient) InitSchema() (ObjectSchema, error)
- type ProviderRPCServer
- func (p *ProviderRPCServer) ActionConfigurationSchema(name string, reply *ObjectSchema) error
- func (p *ProviderRPCServer) ActionEvaluate(payload EvaluateServerPayload, reply *[]byte) error
- func (p *ProviderRPCServer) ActionNames(_ any, reply *[]string) error
- func (p *ProviderRPCServer) ActionOutputType(name string, reply *Type) error
- func (p *ProviderRPCServer) Init(val []byte, _ *any) error
- func (p *ProviderRPCServer) InitSchema(_ any, reply *ObjectSchema) error
- type Schema
- type Trigger
- type Type
Constants ¶
const ( NUMBER_TYPE = "number" BOOLEAN_TYPE = "bool" STRING_TYPE = "string" OBJECT_TYPE = "object" MAP_TYPE = "map" LIST_TYPE = "list" INVALID_TYPE = "invalid" )
Variables ¶
This section is empty.
Functions ¶
func InvokeActionEvaluation ¶
Types ¶
type Action ¶
type Action interface { Function // Evaluate accepts two value parameters. The first contains provider Config details. The second //is a value that should map to the Function.ConfigurationSchema output. This // is the main function called by the runner service when a particular action is being processed. In // a standard integration provider, this is where the guts of integration code will be. Evaluate(config cty.Value, input cty.Value) (cty.Value, error) }
type AttrSchema ¶
AttrSchema represents a key/val coming from the provided data structure
func OptionalAttrSchema ¶
func OptionalAttrSchema(name string, valType Type) *AttrSchema
func RequiredAttrSchema ¶
func RequiredAttrSchema(name string, valType Type) *AttrSchema
func (*AttrSchema) Decode ¶
func (b *AttrSchema) Decode() hcldec.Spec
type BlockSchema ¶
BlockSchema maps to block types from the Config. Blocks with labels are not supported, meaning only one block type per provided Config is permitted
func OptionalBlockSchema ¶
func OptionalBlockSchema(name string, nested Schema) *BlockSchema
func (*BlockSchema) Decode ¶
func (b *BlockSchema) Decode() hcldec.Spec
type EvaluateServerPayload ¶
type Function ¶
type Function interface { // ConfigurationSchema returns an ObjectSpec that returns all required/optional blocks and attributes // in an Action or Trigger. This should include all general configuration settings, as well as all details // pertinent to an individual interaction (api call, event publish, etc.) with the integration ConfigurationSchema() (ObjectSchema, error) // OutputType provides a schema structure for the result of an Action or Trigger. This is an essential component // of using output from one action in a workflow as the Input of another, as well as pre-deployment // configuration validation. Note, this does not return an ObjectSchema because that type is primarily // used for helping the calling application know how the hcl Config data should look. OutputType() (Type, error) }
type ObjectSchema ¶
ObjectSchema is primarily used as root of all schemas in switchboard. This enforces a key/value style of Config for anything using this. Many Provider interface methods will return this to enforce a certain style of how providers expect user Config data to look.
func (*ObjectSchema) Decode ¶
func (s *ObjectSchema) Decode() hcldec.Spec
type Provider ¶
type Provider interface { //Init is called shortly after loading a plugin, and provides some stateful values //to the provider, such as auth keys. // //The byte array param must be the result of json.Marshal //from the github.com/zclconf/go-cty/cty/json package and should immediately be //unmarshalled into a cty.Value based on the type as inferred from the hcldec.ObjectSpec from InitSchema Init([]byte) error //InitSchema is used by the CLI to validate user provided Config, and is also used in Init //to unmarshal the string into a cty.Value InitSchema() (ObjectSchema, error) ActionNames() ([]string, error) ActionEvaluate(name string, config []byte, input []byte) ([]byte, error) ActionConfigurationSchema(name string) (ObjectSchema, error) ActionOutputType(name string) (Type, error) }
Provider is the main interface that must be implemented by every integration provider in order to work with the Switchboard runner service. In addition to provider specific methods, the provider also includes proxy methods to call on specific Action or Trigger implementations (this way, we don't have to register every Action and Trigger as a plugin)
Every method returns an error as the last return type so that we can gracefully deal with any RPC related errors in the go-plugin client implementation of this interface.
func NewProviderRPCClient ¶
func NewProviderRPCClient() Provider
type ProviderPlugin ¶
type ProviderPlugin struct {
Impl Provider
}
func (*ProviderPlugin) Client ¶
func (p *ProviderPlugin) Client(_ *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
func (*ProviderPlugin) Server ¶
func (p *ProviderPlugin) Server(*plugin.MuxBroker) (interface{}, error)
type ProviderRPCClient ¶
type ProviderRPCClient struct {
// contains filtered or unexported fields
}
func (*ProviderRPCClient) ActionConfigurationSchema ¶
func (p *ProviderRPCClient) ActionConfigurationSchema(name string) (ObjectSchema, error)
func (*ProviderRPCClient) ActionEvaluate ¶
func (*ProviderRPCClient) ActionNames ¶
func (p *ProviderRPCClient) ActionNames() ([]string, error)
func (*ProviderRPCClient) ActionOutputType ¶
func (p *ProviderRPCClient) ActionOutputType(name string) (Type, error)
func (*ProviderRPCClient) Init ¶
func (p *ProviderRPCClient) Init(val []byte) error
func (*ProviderRPCClient) InitSchema ¶
func (p *ProviderRPCClient) InitSchema() (ObjectSchema, error)
type ProviderRPCServer ¶
type ProviderRPCServer struct {
Impl Provider
}
func (*ProviderRPCServer) ActionConfigurationSchema ¶
func (p *ProviderRPCServer) ActionConfigurationSchema(name string, reply *ObjectSchema) error
func (*ProviderRPCServer) ActionEvaluate ¶
func (p *ProviderRPCServer) ActionEvaluate(payload EvaluateServerPayload, reply *[]byte) error
func (*ProviderRPCServer) ActionNames ¶
func (p *ProviderRPCServer) ActionNames(_ any, reply *[]string) error
func (*ProviderRPCServer) ActionOutputType ¶
func (p *ProviderRPCServer) ActionOutputType(name string, reply *Type) error
func (*ProviderRPCServer) InitSchema ¶
func (p *ProviderRPCServer) InitSchema(_ any, reply *ObjectSchema) error
type Schema ¶
type Schema interface { //Decode transforms a Schema struct into a hcldec.Spec so that hcl Config data can be serialized //into a usable value and passed to the provider. This is primarily used in the runner application //where hcl is being parsed. Decode() hcldec.Spec }
Schema is an interface implemented by various serializable structs that are used by provider implementations to define the structure of hcl Config data as it is passed by the user. Schemas are pulled from the runner of CLI to tell the hcl decoder what the user Config should look like. All structs that implement this interface MUST use exportable/public properties. non-exportable/private properties will not work when sending data over the wire.
type Trigger ¶
type Trigger interface { Function IsRegistered(config cty.Value, input cty.Value) (bool, error) // Register accepts two value parameters. The first contains provider Config details. The second is the // Input data for the integration. Register is responsible for working with the respective integration to //register the trigger with switchboard. This may be an event-subscription, polling api, or webhook registration. Register(config cty.Value, input cty.Value) (string, error) Unregister(config cty.Value, input cty.Value) (string, error) // ShouldListen tells the caller if it should listen for messages directly from the plugin. // Only applicable for unique cases like event queues where messages are received at the subscription point ShouldListen() (bool, error) // Listen is passed a callback that will be fired any time a trigger where ShouldListen() = true receives // an event from the subscription point Listen(cb func(output cty.Value)) error }
type Type ¶
type Type struct { //Name is a string representation of the underlying type Name string `json:"Name"` //NestedValues is used exclusively for an "object" type NestedValues *map[string]Type `json:"nestedValues,omitempty"` //InternalType is used to represent what type the value of a list or map value is. InternalType *Type `json:"internalType,omitempty"` }
Type is a serializable data structure that helps the CLI and runner understand what data structures in configuration should look like.
var Bool Type
Bool represents a primitive boolean type
var Invalid Type
Invalid is used as an error value for types
var Number Type
Number represents a primitive numeric type
var String Type
String represents a primitive string type
func Map ¶
Map creates an unstructured map of passed key/values as a Type object. Use this when the map keys are unknown or variable