layout

package
v0.33.16 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package layout centralizes the on-disk filesystem layout used by the d8 plugins subsystem: directory names, suffixes, and helpers that build concrete paths from the install root.

The install root is the on-disk directory under which the subsystem keeps everything it owns - installed plugin binaries (<root>/plugins/...) and cached contracts (<root>/cache/contracts/...). It is supplied by the caller (typically the plugins.Manager directory, sourced from --plugins-dir, with default /opt/deckhouse/lib/deckhouse-cli, or ~/.deckhouse-cli as fallback).

Callers should use the builder functions (PluginDir, BinaryPath, ...) for full paths; the directory-name segments are package-private.

Index

Constants

View Source
const (
	ContractFileExt = ".json"

	VersionDirPrefix = "v"
)

Variables

This section is empty.

Functions

func BinaryPath

func BinaryPath(installRoot, pluginName string, majorVersion int) string

BinaryPath returns <installRoot>/plugins/<pluginName>/v<majorVersion>/<pluginName>.

func ContractFile

func ContractFile(installRoot, pluginName string) string

ContractFile returns <installRoot>/cache/contracts/<pluginName>.json.

func ContractsDir

func ContractsDir(installRoot string) string

ContractsDir returns <installRoot>/cache/contracts.

func CurrentLinkPath

func CurrentLinkPath(installRoot, pluginName string) string

CurrentLinkPath returns <installRoot>/plugins/<pluginName>/current - the symlink to the currently active binary version.

func HomeFallbackPath

func HomeFallbackPath() (string, error)

HomeFallbackPath returns ~/.deckhouse-cli - the fallback install root used when the default /opt path is not writable.

func InstallLockPath

func InstallLockPath(installRoot, pluginName string) string

InstallLockPath returns <installRoot>/plugins/<pluginName>/install.lock - one lock per plugin (not per major): installs of different majors still contend on the shared `current` symlink and contract cache, so they must serialize.

func InstalledNames added in v0.33.15

func InstalledNames(root string) ([]string, error)

InstalledNames returns the names of the plugins installed under <root>/plugins - the directories carrying a `current` symlink. Requiring the symlink (not just any subdir) means a leftover empty v<major> dir from a failed install does not count as an install. The cache dir is a sibling, never miscounted.

func PluginDir

func PluginDir(installRoot, pluginName string) string

PluginDir returns <installRoot>/plugins/<pluginName>.

func PluginsRoot

func PluginsRoot(installRoot string) string

PluginsRoot returns <installRoot>/plugins.

func ResolveInstallRoot added in v0.33.15

func ResolveInstallRoot(configured string) (string, bool)

ResolveInstallRoot reports just the root resolved by ResolveInstalled.

func ResolveInstalled added in v0.33.15

func ResolveInstalled(configured string) (string, []string, bool)

ResolveInstalled reports the plugins root that actually holds an install, the plugin names in it, and whether one was found: the configured root, or the home fallback (~/.deckhouse-cli) that EnsureInstallRoot switches to when the configured one is not writable. The final result is false when no plugins are installed anywhere, and the root is then empty and the names nil.

Callers resolving a plugin by name must use this rather than the configured root alone: with an unwritable default root the installs live in the fallback, and looking only at the configured root would miss every one of them.

func RootHasInstall

func RootHasInstall(root string) bool

RootHasInstall reports whether <root>/plugins holds at least one installed plugin.

func ValidatePluginName added in v0.33.8

func ValidatePluginName(name string) error

ValidatePluginName guards a plugin name from any external source (user input, registry catalog, plugin contract) before it becomes a filesystem path or a registry route.

func VersionDir

func VersionDir(installRoot, pluginName string, majorVersion int) string

VersionDir returns <installRoot>/plugins/<pluginName>/v<majorVersion>.

Types

This section is empty.

Jump to

Keyboard shortcuts

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