helpers

package
v1.14.6 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MPL-2.0 Imports: 30 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddModeFlags

func AddModeFlags(mode *Mode, command *cobra.Command)

AddModeFlags adds deprecated flags to the command and registers mode flag with it's parser.

func AppendErrors

func AppendErrors(err error, errs ...error) error

AppendErrors adds errors to the multierr wrapper.

func ClientVersionCheck

func ClientVersionCheck(ctx context.Context, clientFactory ClientFactory) error

ClientVersionCheck verifies that client is not outdated vs. Talos version.

func Confirm added in v1.4.0

func Confirm(prompt string) bool

Confirm asks the user to confirm their action. Anything other than `y` and `yes` returns false.

func DeprecationMessage added in v1.14.0

func DeprecationMessage(flag *pflag.Flag) string

DeprecationMessage returns the message registered for the flag by MarkFlagDeprecated, or an empty string if the flag is not deprecated.

It stands in for pflag's own Flag.Deprecated field, which is left unset so that pflag does not print the warning itself.

func ExtractFileFromTarGz

func ExtractFileFromTarGz(filename string, r io.ReadCloser) ([]byte, error)

ExtractFileFromTarGz reads a single file data from an archive.

func ExtractTarGz

func ExtractTarGz(localPath string, r io.ReadCloser) error

ExtractTarGz extracts .tar.gz archive from r into filesystem under localPath.

The archive is a dump of node's filesystem which might contain symlinks or other special files, handle them in a safe way for the client.

func FormatLabels added in v1.13.0

func FormatLabels(labels map[string]string) string

FormatLabels formats labels as a comma-separated key=value pairs.

func MachineConfigUpdater added in v1.14.0

func MachineConfigUpdater(ctx context.Context,
	clientFactory *global.ClientFactory,
	callback func(ctx context.Context, client *client.Client, node string, mc resource.Resource) error,
	args []string,
) error

MachineConfigUpdater gets resources from the controller runtime and runs a callback for each resource.

func MarkFlagDeprecated added in v1.14.0

func MarkFlagDeprecated(flags *pflag.FlagSet, name, message string) error

MarkFlagDeprecated marks the named flag as deprecated: it is hidden from the help output, and using it prints a warning.

It replaces pflag's own MarkDeprecated, which leaves the warning for cobra to print via cmd.Print, i.e. to the command's output stream. That stream is stdout for talosctl (the help output goes there), so the warning would land in the middle of the command output instead of on stderr.

func NonFatalError

func NonFatalError(err error) error

NonFatalError wraps another error into a ErrNonFatal.

func PrintApplyResults

func PrintApplyResults(resp *machine.ApplyConfigurationResponse)

PrintApplyResults prints out all warnings and auto apply results.

func ReadGRPCStream

func ReadGRPCStream[S Stream[T], T Message](stream S, handler func(T, string, bool) error) error

ReadGRPCStream consumes all messages from the gRPC stream, handles errors, calls the passed handler for each message.

func TalosVersionCheck added in v1.13.0

func TalosVersionCheck(ctx context.Context, clientFactory ClientFactory, desired semver.Range) error

TalosVersionCheck verifies that all nodes are running the desired Talos version.

Types

type ClientFactory added in v1.14.0

type ClientFactory interface {
	BuildClient(ctx context.Context, node string) (context.Context, *client.Client, error)
	Nodes() []string
}

ClientFactory is the interface for the client factory.

type ErrNonFatalError

type ErrNonFatalError struct {
	// contains filtered or unexported fields
}

ErrNonFatalError represents the error that can be returned from the handler in the gRPC stream reader which doesn't mean that we should stop iterating over the messages in the stream, but log this error and continue the process.

func (*ErrNonFatalError) Error

func (e *ErrNonFatalError) Error() string

Error implements error interface.

type Message

type Message interface {
	GetMetadata() *common.Metadata //nolint:staticcheck // to be refactored next
	proto.Message
}

Message defines the contract for the grpc message.

type Mode

type Mode struct {
	Mode machine.ApplyConfigurationRequest_Mode
	// contains filtered or unexported fields
}

Mode apply, patch, edit config update mode.

func (*Mode) Set

func (m *Mode) Set(value string) error

Set implements Flag interface.

func (Mode) String

func (m Mode) String() string

func (*Mode) Type

func (m *Mode) Type() string

Type implements Flag interface.

type Stream

type Stream[T proto.Message] interface {
	Recv() (T, error)
	grpc.ClientStream
}

Stream implements the contract for the grpc stream of a specific type.

type VersionOutsideRangeError added in v1.13.0

type VersionOutsideRangeError struct{}

VersionOutsideRangeError is returned when a node is running a Talos version that is outside the desired range.

Jump to

Keyboard shortcuts

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