You are reading the documentation for an outdated Corteza release. 2023.9 is the latest stable Corteza release.

Server plugins

Deprecation warning: Plugin support has been deprecated in version 2022.9 as the current go plugin support with go >= 1.18 does not suite the architecture of Corteza.

Corteza implements the support for Go plugins which can be used to modify default behaviour of the server and provide new functionalities like workflow functions and types.

Basic plugin structure

package main

type (
	examplePlugin struct {} (1)
)

func CortezaPlugin() interface{} { (2)
	return &examplePlugin{}
}
1 Plugin struct. Beside the functions required by the interface (Setup, Initialize, …​) you are free to add your own fields and functions.
2 Be sure you return an interface{}, otherwise Corteza can not cast it to plugin.

Supported hooks

Setup

In order to hook into the server setup procedure, your plugin should implement the plugin.Setup interface. The Setup() function will be called after internal setup procedure.

package plugin

import (
    "go.uber.org/zap"
)

type (
    Setup interface {
        Setup(log *zap.Logger) error
    }
)

Initialization

In order to hook into the server initialization procedure, your plugin should implement the plugin.Initialize interface. The Initialize() function will be called after initialization procedure with all services are initialized.

package plugin

import (
    "go.uber.org/zap"
)

type (
	Initialize interface {
		Initialize(ctx context.Context, log *zap.Logger) error
	}
)

Automation function provider

In order to register additional automation (workflow) functions, your plugin should implement the plugin.AutomationFunctionsProvider interface. The AutomationFunctions() function is called after initialization and should return slice of automation functions to be registered.

You can override existing functions by using same function reference.

package plugin

import (
	"github.com/cortezaproject/corteza-server/automation/types"
)

type (
	AutomationFunctionsProvider interface {
		AutomationFunctions() []*types.Function
	}
)