Documentation
¶
Overview ¶
Package plugins discovers frontend plugin bundles (a manifest.json plus a bundle.zip holding the plugin's JS entry file and everything else it references) from two sources - labeled ConfigMaps, and optionally a filesystem directory - and keeps an in-memory index that the backend's /api/v1/plugins routes serve. Either source can change at any time; the registry reflects the change on the next request, with no antrea-ui restart required. See configmaps.go for the ConfigMap source and disk.go for the directory source.
Both sources ship a single bundle.zip rather than one file per key/directory entry: a plugin with subdirectory-nested assets (e.g. Angular's assets/ convention - images, i18n locale files, anything referenced by a relative runtime URL rather than pulled into the JS module graph) can't be represented as flat ConfigMap keys (the apiserver rejects "/" in a key name) or flat directory entries (this package used to skip subdirectories outright, mirroring that same flat-namespace convention) - a zip's own internal paths sidestep both restrictions without this package needing to special-case either "/" character.
Both sources also serve their bundle from local disk rather than memory: a bundle.zip is extracted once, into a per-plugin, per-source subdirectory of a shared scratch cache (see diskCacheDir), and every subsequent file request reads straight from there. This requires a writable scratch directory (a real /tmp, or a mounted emptyDir if the container's root filesystem is read-only) - see docs/plugins.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func (*Registry) Close ¶
func (r *Registry) Close()
Close removes the registry's extracted-plugin scratch directory, if diskCacheDir ever created one. A long-lived server process has no need to call this - the container/OS reclaims the whole writable filesystem on exit - but tests build many short-lived Registrys (newTestRegistry, testServer) that would otherwise each leak a MkdirTemp under the real /tmp.
func (*Registry) File ¶
File returns a reader (and its size in bytes, for Content-Length) for filename belonging to the plugin named pluginName, as currently known to the registry. Callers must Close the returned ReadCloser. When the plugin name is claimed by more than one source, it resolves to the source that claimed the name in Index() - usually the one whose manifest Index() lists, except when every one of that manifest's federation routes collided and Index() dropped it entirely while still leaving it holding the name (see refreshResolvedEntriesLocked).
func (*Registry) Index ¶
func (r *Registry) Index() []apisv1.PluginManifest
Index returns the current set of plugin manifests, deduplicated by manifest name and by federation route path, across both the ConfigMap and directory sources (see refreshResolvedEntriesLocked), sorted by name for a deterministic response.
func (*Registry) RunConfigMapWatch ¶
func (r *Registry) RunConfigMapWatch(stopCh <-chan struct{})
RunConfigMapWatch watches ConfigMaps matching the registry's namespace and label selector until stopCh is closed. It blocks and should be called from a goroutine.
func (*Registry) RunDirectoryWatch ¶
RunDirectoryWatch watches dir for plugin bundle subdirectories - one directory per plugin, each holding a manifest.json plus a bundle.zip with everything else it references, the on-disk mirror of a plugin ConfigMap's Data/BinaryData. Meant for local development (no cluster round-trip to iterate on a plugin), and as a fallback if a deployment's plugins outgrow a ConfigMap's 1MiB cap and it mounts a shared volume here instead. A plugin subdirectory can be created, changed, or removed at any time; the registry reflects the change shortly after (see requeueDelay), with no antrea-ui restart required. Blocks and should be called from a goroutine. A no-op if dir is empty.