common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvVarPrefix       = "AK_"
	ConfigYAMLFileName = "config.yaml"
)
View Source
const (
	NotFoundExitCode   = 10
	NotAMemberExitCode = NotFoundExitCode
)

Variables

This section is empty.

Functions

func AddFailIfNotFoundFlag

func AddFailIfNotFoundFlag(cmd *cobra.Command)

func Client

func Client() sdkservices.Services

func Config

func Config() *basesvc.Config

func ConfigYAMLFilePath

func ConfigYAMLFilePath() string

func Consume added in v0.2.0

func Consume(args []string) (data []byte, path string, err error)

func FailIfNotFound

func FailIfNotFound[T any](cmd *cobra.Command, what string, v *T) error

func FailNotFound added in v0.2.0

func FailNotFound(cmd *cobra.Command, what string) error

func InitConfig

func InitConfig(confmap map[string]any) (err error)

func InitRPCClient

func InitRPCClient(url string, authToken string)

func JSONRenderer

func JSONRenderer(o any)

func LimitedContext

func LimitedContext() (context.Context, context.CancelFunc)

TODO(ENG-320): Configuration to disable timeout for debugging.

func NiceJSONRenderer

func NiceJSONRenderer(o any)

func Render

func Render(o any)

func RenderKV

func RenderKV(k string, v any)

func RenderKVIfV

func RenderKVIfV[T any](k string, v *T)

func RenderList

func RenderList[T fmt.Stringer](ts []T)

func SetRenderer

func SetRenderer(r Renderer)

func StandardCommand

func StandardCommand(cmd *cobra.Command) *cobra.Command

func TextRenderer

func TextRenderer(o any)

Types

type ExitCodeError

type ExitCodeError struct {
	Err  error
	Code int
}

func NewExitCodeError

func NewExitCodeError(code int, err error) ExitCodeError

func (ExitCodeError) Error

func (e ExitCodeError) Error() string

type KV

type KV struct {
	K string
	V any
}

func (KV) MarshalJSON

func (kv KV) MarshalJSON() ([]byte, error)

func (KV) Text

func (kv KV) Text() string

type KVIfV

type KVIfV[T any] struct {
	K string
	V *T
}

This will not print anything if V is nil for text rendering. Should make output parsing easier for get operations. TODO: should we even care for non-json output parsing?

func (KVIfV[T]) MarshalJSON

func (kv KVIfV[T]) MarshalJSON() ([]byte, error)

func (KVIfV[T]) Text

func (kv KVIfV[T]) Text() string

type Renderer

type Renderer func(any)

type Texter

type Texter interface{ Text() string }

Jump to

Keyboard shortcuts

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