{"modulePath":"github.com/newstack-cloud/bluelink/libs/plugin-framework","version":"v0.17.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package utils\n\n## Functions\n\n```go\nfunc CreateListener(config *ListenerConfig) (net.Listener, error)\n```\nCreateListener 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.\n\nFor 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.\n\n```go\nfunc DeriveLinkableTypes(resourceType string, allLinkTypes []string) []string\n```\nDeriveLinkableTypes extracts all resource types that the given resource can link to.\n\n```go\nfunc ExtractPluginNamespace(pluginID string) string\n```\nExtractPluginNamespace 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\".\n\n```go\nfunc GetKeys[Item any](m map[string]Item) []string\n```\nGetKeys returns the keys of a map as a slice of strings.\n\n```go\nfunc IsAnyNil(value any) bool\n```\nIsAnyNil checks if the provided value is nil or a nil pointer.\n\n```go\nfunc ProviderContextFromVarMaps(\n\tproviderConfigVars map[string]*core.ScalarValue,\n\tcontextVars map[string]*core.ScalarValue,\n) provider.Context\n```\nProviderContextFromVarMaps 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.\n\n```go\nfunc ProviderContextFromVarMapsWithTagging(\n\tproviderConfigVars map[string]*core.ScalarValue,\n\tcontextVars map[string]*core.ScalarValue,\n\ttaggingConfig *provider.TaggingConfig,\n) provider.Context\n```\nProviderContextFromVarMapsWithTagging creates a provider.Context from the given provider config, context variables, and tagging configuration.\n\n```go\nfunc TransformerContextFromVarMaps(\n\ttransformerConfigVars map[string]*core.ScalarValue,\n\tcontextVars map[string]*core.ScalarValue,\n) transform.Context\n```\nTransformerContextFromVarMaps 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.\n\n## Types\n\n```go\ntype ContextKey string\n```\nContextKey is a type used for keys in context.Context that hold plugin framework specific values.\n\n```go\nconst (\n\t// ContextKeyLinkID is the key used to store the link ID in the context.\n\tContextKeyLinkID ContextKey = \"linkID\"\n)\n```\n\n```go\nfunc (c ContextKey) String() string\n```\n\n```go\ntype ListenerConfig struct {\n\t// A pre-determined listener to use.\n\t// If this is set, TCPPort and UnixSocket will be ignored.\n\tListener net.Listener\n\t// UnixSocket is the path to the Unix socket\n\t// to connect to. If this is set, TCPPort will be ignored.\n\tUnixSocket string\n\t// TCPPort is the port to connect to.\n\t// If this is set and the intention is to use TCP, UnixSocket should be empty\n\t// and Listener should be nil.\n\tTCPPort int\n}\n```\nListenerConfig is a configuration for creating a network listener. This is primarily useful for setting up gRPC servers for the plugin system.\n\n```go\ntype TypeSetCache struct {\n\t// contains filtered or unexported fields\n}\n```\nTypeSetCache holds the set of item types (e.g. resource types) that a plugin supports, loaded from the plugin on first use. Client wrappers use this to determine whether a plugin supports an item type before handing back a client for it, so that unsupported item types are reported as not found rather than failing later on the first call made to the plugin for that item.\n\n```go\nfunc NewTypeSetCache(\n\tloadTypes func(ctx context.Context) ([]string, error),\n) *TypeSetCache\n```\nNewTypeSetCache creates a cache for the set of item types supported by a plugin. The provided function is called at most once to populate the cache.\n\n```go\nfunc (c *TypeSetCache) Has(ctx context.Context, itemType string) (bool, error)\n```\nHas determines whether the given item type is in the set of item types supported by a plugin, loading the set from the plugin the first time it is called.\n\n","path":"github.com/newstack-cloud/bluelink/libs/plugin-framework/utils","name":"utils","synopsis":"","isRedistributable":true}
