cmd

package
v0.0.12 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TryConvertErrorToAttrs

func TryConvertErrorToAttrs(err error) []interface{}

Will try and json unmarshal an error string into a slice of interfaces that match the slog algorithm for varadic parameters (alternating key value pairs)

Types

type CommandHelper

type CommandHelper struct {
	// Cmd is a pointer to the command that is being executed
	Cmd *cobra.Command
	// Args are the arguments (not flags) passed to the command
	Args []string
}

func (*CommandHelper) GetArgs

func (r *CommandHelper) GetArgs() []string

func (*CommandHelper) GetBuildInfo

func (r *CommandHelper) GetBuildInfo() (*build.Info, error)

func (*CommandHelper) GetCmd

func (r *CommandHelper) GetCmd() *cobra.Command

func (*CommandHelper) GetConfig

func (r *CommandHelper) GetConfig() (config.Hook, error)

func (*CommandHelper) GetContext

func (r *CommandHelper) GetContext() context.Context

func (*CommandHelper) GetKonnectSDKFactory

func (r *CommandHelper) GetKonnectSDKFactory() helpers.SDKFactory

func (*CommandHelper) GetLogger

func (r *CommandHelper) GetLogger() (*slog.Logger, error)

func (*CommandHelper) GetOutputFormat

func (r *CommandHelper) GetOutputFormat() (common.OutputFormat, error)

func (*CommandHelper) GetProduct

func (r *CommandHelper) GetProduct() (products.ProductValue, error)

func (*CommandHelper) GetStreams

func (r *CommandHelper) GetStreams() *iostreams.IOStreams

func (*CommandHelper) GetVerb

func (r *CommandHelper) GetVerb() (verbs.VerbValue, error)

type Common

type Common interface {
	// contains filtered or unexported methods
}

type ConfigurationError

type ConfigurationError struct {
	Err error
}

ConfigurationError represents errors that are a result of bad flags, combinations of flags, configuration settings, environment values, or other command usage issues.

func (*ConfigurationError) Error

func (e *ConfigurationError) Error() string

type ExecutionError

type ExecutionError struct {
	// friendly error message to display to the user
	Msg string
	// Err is the error that occurred during execution
	Err error
	// Optional attributes that can be used to provide additional context to the error
	Attrs []interface{}
}

ExecutionError represents errors that occur after a command has been validated and an unsuccessful result occurs. Network errors, server side errors, invalid credentials or responses are examples of RunttimeError types.

func PrepareExecutionError

func PrepareExecutionError(msg string, err error, cmd *cobra.Command, attrs ...any) *ExecutionError

This will construct an execution error AND turn off error and usage output for the command

func (*ExecutionError) Error

func (e *ExecutionError) Error() string

type FlagEnum

type FlagEnum struct {
	Allowed []string
	Value   string
}

func NewEnum

func NewEnum(allowed []string, d string) *FlagEnum

func (*FlagEnum) Set

func (a *FlagEnum) Set(p string) error

func (FlagEnum) String

func (a FlagEnum) String() string

func (*FlagEnum) Type

func (a *FlagEnum) Type() string

type Helper

type Helper interface {
	GetCmd() *cobra.Command
	GetArgs() []string
	GetVerb() (verbs.VerbValue, error)
	GetProduct() (products.ProductValue, error)
	GetStreams() *iostreams.IOStreams
	GetConfig() (config.Hook, error)
	GetOutputFormat() (common.OutputFormat, error)
	GetLogger() (*slog.Logger, error)
	GetBuildInfo() (*build.Info, error)
	GetContext() context.Context
	GetKonnectSDKFactory() helpers.SDKFactory
}

func BuildHelper

func BuildHelper(cmd *cobra.Command, args []string) Helper

type MockHelper

type MockHelper struct {
	mock.Mock
}

MockHelper is an autogenerated mock type for the Helper type

func NewMockHelper

func NewMockHelper(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockHelper

NewMockHelper creates a new instance of MockHelper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockHelper) EXPECT

func (_m *MockHelper) EXPECT() *MockHelper_Expecter

func (*MockHelper) GetArgs

func (_m *MockHelper) GetArgs() []string

GetArgs provides a mock function with given fields:

func (*MockHelper) GetBuildInfo

func (_m *MockHelper) GetBuildInfo() (*build.Info, error)

GetBuildInfo provides a mock function with given fields:

func (*MockHelper) GetCmd

func (_m *MockHelper) GetCmd() *cobra.Command

GetCmd provides a mock function with given fields:

func (*MockHelper) GetConfig

func (_m *MockHelper) GetConfig() (config.Hook, error)

GetConfig provides a mock function with given fields:

func (*MockHelper) GetContext

func (_m *MockHelper) GetContext() context.Context

GetContext provides a mock function with given fields:

func (*MockHelper) GetKonnectSDKFactory

func (_m *MockHelper) GetKonnectSDKFactory() helpers.SDKFactory

GetKonnectSDKFactory provides a mock function with given fields:

func (*MockHelper) GetLogger

func (_m *MockHelper) GetLogger() (*slog.Logger, error)

GetLogger provides a mock function with given fields:

func (*MockHelper) GetOutputFormat

func (_m *MockHelper) GetOutputFormat() (common.OutputFormat, error)

GetOutputFormat provides a mock function with given fields:

func (*MockHelper) GetProduct

func (_m *MockHelper) GetProduct() (products.ProductValue, error)

GetProduct provides a mock function with given fields:

func (*MockHelper) GetStreams

func (_m *MockHelper) GetStreams() *iostreams.IOStreams

GetStreams provides a mock function with given fields:

func (*MockHelper) GetVerb

func (_m *MockHelper) GetVerb() (verbs.VerbValue, error)

GetVerb provides a mock function with given fields:

type MockHelper_Expecter

type MockHelper_Expecter struct {
	// contains filtered or unexported fields
}

func (*MockHelper_Expecter) GetArgs

GetArgs is a helper method to define mock.On call

func (*MockHelper_Expecter) GetBuildInfo

GetBuildInfo is a helper method to define mock.On call

func (*MockHelper_Expecter) GetCmd

GetCmd is a helper method to define mock.On call

func (*MockHelper_Expecter) GetConfig

GetConfig is a helper method to define mock.On call

func (*MockHelper_Expecter) GetContext

GetContext is a helper method to define mock.On call

func (*MockHelper_Expecter) GetKonnectSDKFactory

func (_e *MockHelper_Expecter) GetKonnectSDKFactory() *MockHelper_GetKonnectSDKFactory_Call

GetKonnectSDKFactory is a helper method to define mock.On call

func (*MockHelper_Expecter) GetLogger

GetLogger is a helper method to define mock.On call

func (*MockHelper_Expecter) GetOutputFormat

GetOutputFormat is a helper method to define mock.On call

func (*MockHelper_Expecter) GetProduct

GetProduct is a helper method to define mock.On call

func (*MockHelper_Expecter) GetStreams

GetStreams is a helper method to define mock.On call

func (*MockHelper_Expecter) GetVerb

GetVerb is a helper method to define mock.On call

type MockHelper_GetArgs_Call

type MockHelper_GetArgs_Call struct {
	*mock.Call
}

MockHelper_GetArgs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetArgs'

func (*MockHelper_GetArgs_Call) Return

func (*MockHelper_GetArgs_Call) Run

func (_c *MockHelper_GetArgs_Call) Run(run func()) *MockHelper_GetArgs_Call

func (*MockHelper_GetArgs_Call) RunAndReturn

func (_c *MockHelper_GetArgs_Call) RunAndReturn(run func() []string) *MockHelper_GetArgs_Call

type MockHelper_GetBuildInfo_Call

type MockHelper_GetBuildInfo_Call struct {
	*mock.Call
}

MockHelper_GetBuildInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBuildInfo'

func (*MockHelper_GetBuildInfo_Call) Return

func (*MockHelper_GetBuildInfo_Call) Run

func (*MockHelper_GetBuildInfo_Call) RunAndReturn

func (_c *MockHelper_GetBuildInfo_Call) RunAndReturn(run func() (*build.Info, error)) *MockHelper_GetBuildInfo_Call

type MockHelper_GetCmd_Call

type MockHelper_GetCmd_Call struct {
	*mock.Call
}

MockHelper_GetCmd_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCmd'

func (*MockHelper_GetCmd_Call) Return

func (*MockHelper_GetCmd_Call) Run

func (_c *MockHelper_GetCmd_Call) Run(run func()) *MockHelper_GetCmd_Call

func (*MockHelper_GetCmd_Call) RunAndReturn

func (_c *MockHelper_GetCmd_Call) RunAndReturn(run func() *cobra.Command) *MockHelper_GetCmd_Call

type MockHelper_GetConfig_Call

type MockHelper_GetConfig_Call struct {
	*mock.Call
}

MockHelper_GetConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetConfig'

func (*MockHelper_GetConfig_Call) Return

func (*MockHelper_GetConfig_Call) Run

func (*MockHelper_GetConfig_Call) RunAndReturn

func (_c *MockHelper_GetConfig_Call) RunAndReturn(run func() (config.Hook, error)) *MockHelper_GetConfig_Call

type MockHelper_GetContext_Call

type MockHelper_GetContext_Call struct {
	*mock.Call
}

MockHelper_GetContext_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetContext'

func (*MockHelper_GetContext_Call) Return

func (*MockHelper_GetContext_Call) Run

func (*MockHelper_GetContext_Call) RunAndReturn

type MockHelper_GetKonnectSDKFactory_Call

type MockHelper_GetKonnectSDKFactory_Call struct {
	*mock.Call
}

MockHelper_GetKonnectSDKFactory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKonnectSDKFactory'

func (*MockHelper_GetKonnectSDKFactory_Call) Return

func (*MockHelper_GetKonnectSDKFactory_Call) Run

func (*MockHelper_GetKonnectSDKFactory_Call) RunAndReturn

type MockHelper_GetLogger_Call

type MockHelper_GetLogger_Call struct {
	*mock.Call
}

MockHelper_GetLogger_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLogger'

func (*MockHelper_GetLogger_Call) Return

func (*MockHelper_GetLogger_Call) Run

func (*MockHelper_GetLogger_Call) RunAndReturn

func (_c *MockHelper_GetLogger_Call) RunAndReturn(run func() (*slog.Logger, error)) *MockHelper_GetLogger_Call

type MockHelper_GetOutputFormat_Call

type MockHelper_GetOutputFormat_Call struct {
	*mock.Call
}

MockHelper_GetOutputFormat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetOutputFormat'

func (*MockHelper_GetOutputFormat_Call) Return

func (*MockHelper_GetOutputFormat_Call) Run

func (*MockHelper_GetOutputFormat_Call) RunAndReturn

type MockHelper_GetProduct_Call

type MockHelper_GetProduct_Call struct {
	*mock.Call
}

MockHelper_GetProduct_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProduct'

func (*MockHelper_GetProduct_Call) Return

func (*MockHelper_GetProduct_Call) Run

func (*MockHelper_GetProduct_Call) RunAndReturn

type MockHelper_GetStreams_Call

type MockHelper_GetStreams_Call struct {
	*mock.Call
}

MockHelper_GetStreams_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetStreams'

func (*MockHelper_GetStreams_Call) Return

func (*MockHelper_GetStreams_Call) Run

func (*MockHelper_GetStreams_Call) RunAndReturn

type MockHelper_GetVerb_Call

type MockHelper_GetVerb_Call struct {
	*mock.Call
}

MockHelper_GetVerb_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetVerb'

func (*MockHelper_GetVerb_Call) Return

func (*MockHelper_GetVerb_Call) Run

func (_c *MockHelper_GetVerb_Call) Run(run func()) *MockHelper_GetVerb_Call

func (*MockHelper_GetVerb_Call) RunAndReturn

func (_c *MockHelper_GetVerb_Call) RunAndReturn(run func() (verbs.VerbValue, error)) *MockHelper_GetVerb_Call

Jump to

Keyboard shortcuts

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