common

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func AddFailIfError added in v0.3.0

func AddFailIfError(cmd *cobra.Command)

func AddFailIfNotFoundFlag

func AddFailIfNotFoundFlag(cmd *cobra.Command)

func Client

func Client() sdkservices.Services

func Config

func Config() *svc.Config

func ConfigYAMLFilePath

func ConfigYAMLFilePath() string

func Consume added in v0.2.0

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

func FailIfError added in v0.3.0

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

func FailIfNotFound

func FailIfNotFound(cmd *cobra.Command, what string, found bool) 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)

func ToExitCodeError added in v0.3.0

func ToExitCodeError(err error, what string) error

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