helpers

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

InteractiveMode fake mode value for the interactive config mode. Should be never passed to the API.

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 CheckErrors

func CheckErrors[T interface{ GetMetadata() *common.Metadata }](messages ...T) error

CheckErrors goes through the returned message list and checks if any messages have errors set.

func ClientVersionCheck

func ClientVersionCheck(ctx context.Context, c *client.Client) 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 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.

func FailIfMultiNodes

func FailIfMultiNodes(ctx context.Context, command string) error

FailIfMultiNodes checks if ctx contains multi-node request metadata.

func ForEachResource

func ForEachResource(ctx context.Context,
	c *client.Client,
	callbackRD func(rd *meta.ResourceDefinition) error,
	callback func(ctx context.Context, hostname string, r resource.Resource, callError error) error,
	namespace string,
	args ...string,
) error

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

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.

Types

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
	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.

Jump to

Keyboard shortcuts

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