helper

package
v0.0.0-...-908e76c Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListAll

func ListAll[T1 any, T2 any](ctx context.Context, list func(context.Context, *connect.Request[T1]) (*connect.Response[T2], error), f1 func(string) *T1, f2 func(*T2), f3 func(*T2) string) error

ListAll is a helper function to list all items from a paginated API.

list is the function to call to list items. (e.g. kev1alpha.KeService.ListCluster) f1 is the function to create the request object. It takes a page token as input and returns the request message (e.g. func(string) *kev1alpha.ListClusterRequest) f2 is the function to process the response object. It takes the response message as input. (e.g. func(*kev1alpha.ListClusterResponse)) f3 is the function to retrieve the next page token from the response object. It takes the response message as input and returns the next page token. (e.g. func(*kev1alpha.ListClusterResponse) string)

The page token is used to retrieve the next page of results. If it is empty, the first page will be retrieved. The page token is retrieved from the response object using the GetNextPageToken() method. If the token is empty, the last page has been reached and the function will return.

Types

type EnumFlag

type EnumFlag[T ~int32] struct {
	// contains filtered or unexported fields
}

EnumFlag implements pflag.Value for proto enum T.

func NewEnumFlag

func NewEnumFlag[T ~int32](names map[int32]string, values map[string]int32) *EnumFlag[T]

func (*EnumFlag[T]) CompletionFunc

func (e *EnumFlag[T]) CompletionFunc() func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective)

CompletionFunc returns a completion function for the flag. https://github.com/spf13/cobra/blob/main/shell_completions.md#completions-for-flags

func (*EnumFlag[T]) Names

func (e *EnumFlag[T]) Names() []string

Names returns all the names of the enum in order.

func (*EnumFlag[T]) Set

func (e *EnumFlag[T]) Set(s string) error

func (*EnumFlag[T]) String

func (e *EnumFlag[T]) String() string

func (*EnumFlag[T]) Type

func (e *EnumFlag[T]) Type() string

func (*EnumFlag[T]) Value

func (e *EnumFlag[T]) Value() T

Jump to

Keyboard shortcuts

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