Documentation
¶
Index ¶
- Variables
- func DetectAndSetRoot(cmd *cobra.Command, _ []string) error
- func DetectAndSetRootFromFiles(filePaths []string) error
- func DetectProjectRoot(startDir string) (string, error)
- func DetectProjectRootForFile(filePath string) (string, error)
- func DetectRootForTemplate(templatePath string) (string, error)
- func EnsureTalosconfigPath(cmd *cobra.Command)
- func ExpandFilePaths(paths []string) ([]string, error)
- func ResolveSecretsPath(withSecrets string) string
- func ValidateAndDetectRootsForFiles(filePaths []string) (string, error)
- func WithClient(action func(context.Context, *client.Client) error, ...) error
- func WithClientAuto(action func(context.Context, *client.Client) error) error
- func WithClientMaintenance(enforceFingerprints []string, ...) error
- func WithClientNoNodes(action func(context.Context, *client.Client) error, ...) error
- func WithClientSkipVerify(action func(context.Context, *client.Client) error) error
Constants ¶
This section is empty.
Variables ¶
var Commands []*cobra.Command
Commands is a list of commands published by the package.
var CompleteTalosconfigEndpoints = completeTalosconfigField(flagNameEndpoints)
CompleteTalosconfigEndpoints is the exported entry point for completion of the root `--endpoints` persistent flag.
var CompleteTalosconfigNodes = completeTalosconfigField(flagNameNodes)
CompleteTalosconfigNodes is the exported entry point for completion of the root `--nodes` persistent flag. main.go wires it via cobra.RegisterFlagCompletionFunc.
var Config struct { RootDir string RootDirExplicit bool // true if --root was explicitly set GlobalOptions struct { Talosconfig string `yaml:"talosconfig"` Kubeconfig string `yaml:"kubeconfig"` } `yaml:"globalOptions"` TemplateOptions struct { Offline bool `yaml:"offline"` ValueFiles []string `yaml:"valueFiles"` Values []string `yaml:"values"` StringValues []string `yaml:"stringValues"` FileValues []string `yaml:"fileValues"` JsonValues []string `yaml:"jsonValues"` //nolint:revive // public field name kept for backwards compatibility with existing consumers in template.go and pkg/engine LiteralValues []string `yaml:"literalValues"` TalosVersion string `yaml:"talosVersion"` WithSecrets string `yaml:"withSecrets"` KubernetesVersion string `yaml:"kubernetesVersion"` Full bool `yaml:"full"` Debug bool `yaml:"debug"` } `yaml:"templateOptions"` ApplyOptions struct { DryRun bool `yaml:"preserve"` Timeout string `yaml:"timeout"` TimeoutDuration time.Duration CertFingerprints []string `yaml:"certFingerprints"` } `yaml:"applyOptions"` UpgradeOptions struct { Preserve bool `yaml:"preserve"` Stage bool `yaml:"stage"` Force bool `yaml:"force"` } `yaml:"upgradeOptions"` InitOptions struct { Version string } }
Config is the package-level configuration populated from Chart.yaml and CLI persistent flags. Mirrors GlobalArgs for project-root-relative path resolution across every subcommand.
var GlobalArgs global.Args
GlobalArgs is the common arguments for the root command.
Functions ¶
func DetectAndSetRoot ¶ added in v0.18.1
DetectAndSetRoot detects and sets the project root using fallback strategy: 1. From -f/--file flag (if files specified) 2. From -t/--template flag (if templates specified) 3. From current working directory
args is part of the cobra.PositionalArgs / PreRunE signature; the function does not consult positional arguments — root selection is driven entirely by --root, --file, --template, and the CWD walk-up.
func DetectAndSetRootFromFiles ¶ added in v0.18.1
DetectAndSetRootFromFiles detects and sets project root from file paths. This is a common pattern used in commands like apply, upgrade, and talosctl wrapper. It detects root from files if provided, otherwise falls back to current working directory.
func DetectProjectRoot ¶ added in v0.18.1
DetectProjectRoot automatically detects the project root directory by looking for Chart.yaml and secrets.yaml (or secrets.encrypted.yaml) files in the current directory and parent directories. Returns the absolute path to the project root, or empty string if not found.
func DetectProjectRootForFile ¶ added in v0.18.1
DetectProjectRootForFile detects the project root for a given file path. It finds the directory containing the file, then searches up for Chart.yaml and secrets.yaml.
func DetectRootForTemplate ¶ added in v0.18.1
DetectRootForTemplate detects the project root for a template file path. Similar to ValidateAndDetectRootsForFiles but for a single template file.
func EnsureTalosconfigPath ¶ added in v0.18.1
EnsureTalosconfigPath ensures talosconfig path is set to project root if not explicitly set via flag.
func ExpandFilePaths ¶ added in v0.19.0
ExpandFilePaths expands file paths: if a path is a directory, finds all YAML files in it. Returns a list of file paths, with directories expanded to their YAML files.
func ResolveSecretsPath ¶ added in v0.18.1
ResolveSecretsPath resolves secrets.yaml path relative to project root if not absolute.
func ValidateAndDetectRootsForFiles ¶ added in v0.18.1
ValidateAndDetectRootsForFiles resolves the project root for a chain of `-f` files. Only the FIRST file anchors the project root; subsequent files are loaded as patches without re-running detection, so a chain like `talm apply -f nodes/cp01.yaml -f /tmp/side-patch.yaml` is accepted — cp01.yaml carries the root, side-patch.yaml is patched on top without needing its own Chart.yaml ancestor.
The first-file-anchors rule is ordering-dependent by design. Reversing the chain (orphan first, rooted second) is rejected with a hint that names the FIRST file and tells the operator to reorder, not to move the file. Single-file orphans continue to error out exactly as before.
Wrapped talosctl subcommands (`talm dashboard -f …`, `talm reset -f …`, `talm get -f …`) also call this through their PreRunE chain. For them the "chain" notion isn't semantic — each file is its own per-node modeline source — but the relaxed first-file-anchors rule still applies: a cross-project chain that would have errored before now silently pins Config.RootDir to file[0]'s root. In practice operators don't mix files from different projects in a single talosctl invocation; if they do, EnsureTalosconfigPath downstream will use file[0]'s talosconfig.
func WithClient ¶
func WithClient(action func(context.Context, *client.Client) error, dialOptions ...grpc.DialOption) error
WithClient builds upon WithClientNoNodes to provide set of nodes on request context based on config & flags.
func WithClientAuto ¶ added in v0.21.0
WithClientAuto automatically selects the appropriate client wrapper based on GlobalArgs.SkipVerify. If SkipVerify is true, uses WithClientSkipVerify, otherwise uses WithClientNoNodes.
func WithClientMaintenance ¶
func WithClientMaintenance(enforceFingerprints []string, action func(context.Context, *client.Client) error) error
WithClientMaintenance wraps common code to initialize Talos client in maintenance (insecure mode).
func WithClientNoNodes ¶
func WithClientNoNodes(action func(context.Context, *client.Client) error, dialOptions ...grpc.DialOption) error
WithClientNoNodes wraps common code to initialize Talos client and provide cancellable context.
WithClientNoNodes doesn't set any node information on the request context.
func WithClientSkipVerify ¶ added in v0.21.0
WithClientSkipVerify wraps common code to initialize Talos client with TLS verification disabled but with client certificate authentication preserved. This is useful when connecting to nodes via IP addresses not listed in the server certificate's SANs.
Types ¶
This section is empty.
Source Files
¶
- apply.go
- completion.go
- consts.go
- crashdump_handler.go
- dmesg_handler.go
- init.go
- kubeconfig_handler.go
- preflight.go
- preflight_apply_safety.go
- preflight_apply_safety_redact.go
- preflight_upgrade_verify.go
- reset_handler.go
- root.go
- root_detection.go
- rotate_ca_handler.go
- talosconfig.go
- talosctl_wrapper.go
- template.go
- tui_handler.go
- upgrade_handler.go
- upgrade_image_source.go