common

package
v0.6.10 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 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)

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(project string, 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 FailIfError added in v0.3.0

func FailIfError(cmd *cobra.Command, err error, whats ...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 GetMode added in v0.5.0

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

Get the mode initialized using AddModeFlag.

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)

Returns a new service initialized with dev mode.

func NewSvc added in v0.5.0

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

Returns a new service initialized with the mode set by AddModeFlag.

func NiceJSONRenderer

func NiceJSONRenderer(o any)

func OpenURL added in v0.5.13

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

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

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) 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