Documentation
¶
Overview ¶
Package clusterdir owns the per-cluster config directory convention: <user config dir>/kubeaid-cli/<cluster>/configs, which is ~/.config/kubeaid-cli/<cluster>/configs on Linux.
Deliberately NOT the working-directory-relative "outputs/configs" that --configs-directory defaults to. secrets.yaml holds cloud credentials and an mTLS private key, and an operator running kubeaid-cli inside a checkout — the likely case, since they have a kubeaid-config repo — would leave those one `git add .` away from being committed.
Stdlib-only on purpose: both pkg/obmondo and pkg/config/parser depend on this, and neither should have to pull in the other.
Index ¶
- Constants
- func For(clusterName string) (string, error)
- func Home(clusterName string) (string, error)
- func List() []string
- func LogsDir(clusterName string) (string, error)
- func LogsDirForConfigs(configsDirectory string) string
- func OwnerOfConfigs(path string) string
- func SharedLogsDir() (string, error)
- func ValidateName(clusterName string) error
Constants ¶
const ReservedLogsName = "logs"
ReservedLogsName is the one directory under the per-user root that is not a cluster: the shared logs directory (see SharedLogsDir).
Variables ¶
This section is empty.
Functions ¶
func Home ¶ added in v0.31.8
Home returns clusterName's directory itself. Configs live in a subdirectory of it (see For); a run's outputs — kubeconfigs, logs, the generated k3d config — sit next to them, so everything the CLI knows about a cluster has one home. Kubeconfigs and logs are strictly state, which XDG would put under ~/.local/state — kept here deliberately, so a cluster is one directory rather than two trees to correlate.
func List ¶
func List() []string
List returns the names of every cluster with a config on disk, sorted.
Best-effort: an unreadable or absent root is an empty list, not an error. Callers use this to enrich a message the operator is already reading, so failing to build it must never replace the message it was decorating.
func LogsDir ¶ added in v0.31.8
LogsDir returns clusterName's logs directory — the one definition of that path, so the log-placement call sites cannot drift from each other.
func LogsDirForConfigs ¶ added in v0.31.8
LogsDirForConfigs returns where a run whose configs live in configsDirectory keeps its logs: the owning cluster's logs directory when the path is a cluster's configs directory under the per-user root, and the "logs" subdirectory of configsDirectory itself otherwise — the operator chose that location, so everything the run produces goes there. The one definition of this routing, shared by the pre-parse log placement and config generate's post-write relocation.
func OwnerOfConfigs ¶ added in v0.31.8
OwnerOfConfigs returns the name of the cluster whose configs directory path is, and "" when path is not a per-cluster configs directory (or no per-user root can be located). The pre-parse half of the path rule: it answers from the path alone, so a run can route its log file before general.yaml has been read.
func SharedLogsDir ¶ added in v0.31.8
SharedLogsDir returns the logs directory used before a run has resolved which cluster it concerns — and permanently, for runs that never do (version, an aborted config generate). Once the cluster is known, the run's log file moves into <cluster home>/logs.
"logs" is therefore a reserved name no cluster may take; ValidateName enforces that on every path builder.
func ValidateName ¶ added in v0.31.8
ValidateName reports whether clusterName may own a directory under the per-user root. Every path builder here calls it, so an invalid name is rejected wherever it enters — a flag, a hand-edited general.yaml, or the prompt.
Types ¶
This section is empty.