common

package
v0.11.8 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 27 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 AddModeFlag added in v0.5.0

func AddModeFlag(cmd *cobra.Command)

AddModeFlag adds the AutoKitteh service mode flag to the given CLI command. See also ParseModeFlag.

func AddNotFoundErrIfCond added in v0.8.4

func AddNotFoundErrIfCond(err error, found bool) error

keep given error, if passed or return notFound if !found condition

func Build added in v0.3.2

func Build(rts sdkservices.Runtimes, srcFS fs.FS, paths []string, syms []sdktypes.Symbol) (*sdkbuildfile.BuildFile, error)

func BuildProject added in v0.4.0

func BuildProject(pid sdktypes.ProjectID, dirPaths, filePaths []string) (sdktypes.BuildID, error)

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

func GetToken() (string, error)

func InitConfig

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

func InitRPCClient

func InitRPCClient(authToken string) (err error)

func JSONRenderer

func JSONRenderer(o any)

func LimitedContext

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

func NewDevSvc added in v0.5.0

func NewDevSvc(silent bool) (svc.Service, error)

NewDevSvc returns a new AutoKitteh service in dev mode.

func NewNonEmptyString added in v0.9.0

func NewNonEmptyString(val string, p *string) *nonEmptyStringValue

func NewSvc added in v0.5.0

func NewSvc(silent bool) (svc.Service, error)

Returns a new AutoKitteh service initialized with the mode defined by AddModeFlag and parsed by ParseModeFlag.

func NiceJSONRenderer

func NiceJSONRenderer(o any)

func OpenURL added in v0.5.13

func OpenURL(cmd *cobra.Command, link string) error

func ParseModeFlag added in v0.9.2

func ParseModeFlag() (m configset.Mode, err error)

ParseModeFlag returns the parsed value of the AutoKitteh service mode CLI flag, initialized with AddModeFlag.

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

func ServerURL() *url.URL

func SetRenderer

func SetRenderer(r Renderer)

func StandardCommand

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

func StoreToken added in v0.5.1

func StoreToken(token string) error

func TextRenderer

func TextRenderer(o any)

func ToExitCodeError added in v0.3.0

func ToExitCodeError(err error, whats ...string) error

ToExitCodeError wraps the given error with an OS exit code. If the error is nil, it also returns nil.

func ToExitCodeWithSkipNotFoundFlag added in v0.8.4

func ToExitCodeWithSkipNotFoundFlag(cmd *cobra.Command, err error, whats ...string) error

ToExitCodeWithSkipNotFoundFlag returns the given command's error (may be nil) with an OS exit code, but considers the "--fail" flag: if set to false, we skip "not found" errors.

func WithLimitedContext added in v0.4.0

func WithLimitedContext(ctx context.Context) (context.Context, context.CancelFunc)

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

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) ToString added in v0.8.5

func (kv KV) ToString() 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]) ToString added in v0.8.5

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

type Renderer

type Renderer func(any)

type ToStringer added in v0.8.5

type ToStringer interface{ ToString() string }

Jump to

Keyboard shortcuts

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