utils

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateListener

func CreateListener(config *ListenerConfig) (net.Listener, error)

CreateListener creates a network listener based on the configuration provided. This is useful for setting up gRPC servers for the plugin system. The behaviour is as follows (in order of priority): If a listener is provided, it will be used. If a Unix socket is provided, it will be used. If a TCP port is provided, it will be used.

For TCP connections, the listener will be created on the `127.0.0.1` loopback address. This is meant for inter-process communication on the same host, you can opt out by providing a pre-determined listener but do so carefully as the plugin system should only communicate between processes on the same host.

func ExtractPluginNamespace

func ExtractPluginNamespace(pluginID string) string

ExtractPluginNamespace extracts the plugin namespace to be used with the blueprint framework from the given plugin ID. For example, the plugin namespace for the plugin ID "registry.customhost.com/bluelink/azure" would be "azure".

func GetKeys

func GetKeys[Item any](m map[string]Item) []string

GetKeys returns the keys of a map as a slice of strings.

func IsAnyNil

func IsAnyNil(value any) bool

IsAnyNil checks if the provided value is nil or a nil pointer.

func ProviderContextFromVarMaps

func ProviderContextFromVarMaps(
	providerConfigVars map[string]*core.ScalarValue,
	contextVars map[string]*core.ScalarValue,
) provider.Context

ProviderContextFromVarMaps creates a provider.Context from the given provider config and context variables. This is primarily useful for creating a blueprint framework provider.Context from config maps derived from a deserialised protobuf message.

func ProviderContextFromVarMapsWithTagging added in v0.2.0

func ProviderContextFromVarMapsWithTagging(
	providerConfigVars map[string]*core.ScalarValue,
	contextVars map[string]*core.ScalarValue,
	taggingConfig *provider.TaggingConfig,
) provider.Context

ProviderContextFromVarMapsWithTagging creates a provider.Context from the given provider config, context variables, and tagging configuration.

func TransformerContextFromVarMaps

func TransformerContextFromVarMaps(
	transformerConfigVars map[string]*core.ScalarValue,
	contextVars map[string]*core.ScalarValue,
) transform.Context

TransformerContextFromVarMaps creates a transform.Context from the given transformer config and context variables. This is primarily useful for creating a blueprint framework transform.Context from config maps derived from a deserialised protobuf message.

Types

type ContextKey

type ContextKey string

ContextKey is a type used for keys in context.Context that hold plugin framework specific values.

const (
	// ContextKeyLinkID is the key used to store the link ID in the context.
	ContextKeyLinkID ContextKey = "linkID"
)

func (ContextKey) String

func (c ContextKey) String() string

type ListenerConfig

type ListenerConfig struct {
	// A pre-determined listener to use.
	// If this is set, TCPPort and UnixSocket will be ignored.
	Listener net.Listener
	// UnixSocket is the path to the Unix socket
	// to connect to. If this is set, TCPPort will be ignored.
	UnixSocket string
	// TCPPort is the port to connect to.
	// If this is set and the intention is to use TCP, UnixSocket should be empty
	// and Listener should be nil.
	TCPPort int
}

ListenerConfig is a configuration for creating a network listener. This is primarily useful for setting up gRPC servers for the plugin system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL