helpers

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MPL-2.0 Imports: 28 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 added in v1.0.0

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

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

func AppendErrors added in v1.2.0

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

AppendErrors adds errors to the multierr wrapper.

func CheckErrors added in v1.2.0

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 added in v1.2.0

func ClientVersionCheck(ctx context.Context, c *client.Client) error

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

func ExtractFileFromTarGz added in v0.6.0

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 added in v0.9.0

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 added in v1.2.0

func NonFatalError(err error) error

NonFatalError wraps another error into a ErrNonFatal.

func PrintApplyResults added in v1.0.0

func PrintApplyResults(resp *machine.ApplyConfigurationResponse)

PrintApplyResults prints out all warnings and auto apply results.

func ReadGRPCStream added in v1.2.0

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 added in v1.2.0

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 added in v1.2.0

func (e *ErrNonFatalError) Error() string

Error implements error interface.

type Message added in v1.2.0

type Message interface {
	GetMetadata() *common.Metadata
	proto.Message
}

Message defines the contract for the grpc message.

type Mode added in v1.0.0

type Mode struct {
	Mode        machine.ApplyConfigurationRequest_Mode
	Immediate   bool
	Interactive bool
	OnReboot    bool
	// contains filtered or unexported fields
}

Mode apply, patch, edit config config update mode.

func (*Mode) Set added in v1.0.0

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

Set implements Flag interface.

func (Mode) String added in v1.0.0

func (m Mode) String() string

func (*Mode) Type added in v1.0.0

func (m *Mode) Type() string

Type implements Flag interface.

type Stream added in v1.2.0

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