Documentation
¶
Index ¶
- func ConfirmDelete(helper Helper, description string, warnings ...string) error
- func DeleteAutoApproveEnabled(helper Helper) bool
- func DeleteForceEnabled(helper Helper) bool
- func SetDeleteAutoApprove(cmd *cobra.Command, approved bool)
- func SetDeleteForce(cmd *cobra.Command, force bool)
- func TryConvertErrorToAttrs(err error) []any
- type CommandHelper
- func (r *CommandHelper) GetArgs() []string
- func (r *CommandHelper) GetBuildInfo() (*build.Info, error)
- func (r *CommandHelper) GetCmd() *cobra.Command
- func (r *CommandHelper) GetConfig() (config.Hook, error)
- func (r *CommandHelper) GetContext() context.Context
- func (r *CommandHelper) GetKonnectSDK(cfg config.Hook, logger *slog.Logger) (helpers.SDKAPI, error)
- func (r *CommandHelper) GetLogger() (*slog.Logger, error)
- func (r *CommandHelper) GetOutputFormat() (common.OutputFormat, error)
- func (r *CommandHelper) GetProduct() (products.ProductValue, error)
- func (r *CommandHelper) GetStreams() *iostreams.IOStreams
- func (r *CommandHelper) GetVerb() (verbs.VerbValue, error)
- type Common
- type ConfigurationError
- type ExecutionError
- func PrepareExecutionError(msg string, err error, cmd *cobra.Command, attrs ...any) *ExecutionError
- func PrepareExecutionErrorFromErr(helper Helper, err error, attrs ...any) *ExecutionError
- func PrepareExecutionErrorMsg(helper Helper, msg string, attrs ...any) *ExecutionError
- func PrepareExecutionErrorWithHelper(helper Helper, msg string, err error, attrs ...any) *ExecutionError
- type FlagEnum
- type Helper
- type MockHelper
- func (_m *MockHelper) EXPECT() *MockHelper_Expecter
- func (_m *MockHelper) GetArgs() []string
- func (_m *MockHelper) GetBuildInfo() (*build.Info, error)
- func (_m *MockHelper) GetCmd() *cobra.Command
- func (_m *MockHelper) GetConfig() (config.Hook, error)
- func (_m *MockHelper) GetContext() context.Context
- func (_m *MockHelper) GetKonnectSDK(cfg config.Hook, logger *slog.Logger) (helpers.SDKAPI, error)
- func (_m *MockHelper) GetLogger() (*slog.Logger, error)
- func (_m *MockHelper) GetOutputFormat() (common.OutputFormat, error)
- func (_m *MockHelper) GetProduct() (products.ProductValue, error)
- func (_m *MockHelper) GetStreams() *iostreams.IOStreams
- func (_m *MockHelper) GetVerb() (verbs.VerbValue, error)
- type MockHelper_Expecter
- func (_e *MockHelper_Expecter) GetArgs() *MockHelper_GetArgs_Call
- func (_e *MockHelper_Expecter) GetBuildInfo() *MockHelper_GetBuildInfo_Call
- func (_e *MockHelper_Expecter) GetCmd() *MockHelper_GetCmd_Call
- func (_e *MockHelper_Expecter) GetConfig() *MockHelper_GetConfig_Call
- func (_e *MockHelper_Expecter) GetContext() *MockHelper_GetContext_Call
- func (_e *MockHelper_Expecter) GetKonnectSDK(cfg interface{}, logger interface{}) *MockHelper_GetKonnectSDK_Call
- func (_e *MockHelper_Expecter) GetLogger() *MockHelper_GetLogger_Call
- func (_e *MockHelper_Expecter) GetOutputFormat() *MockHelper_GetOutputFormat_Call
- func (_e *MockHelper_Expecter) GetProduct() *MockHelper_GetProduct_Call
- func (_e *MockHelper_Expecter) GetStreams() *MockHelper_GetStreams_Call
- func (_e *MockHelper_Expecter) GetVerb() *MockHelper_GetVerb_Call
- type MockHelper_GetArgs_Call
- type MockHelper_GetBuildInfo_Call
- func (_c *MockHelper_GetBuildInfo_Call) Return(_a0 *build.Info, _a1 error) *MockHelper_GetBuildInfo_Call
- func (_c *MockHelper_GetBuildInfo_Call) Run(run func()) *MockHelper_GetBuildInfo_Call
- func (_c *MockHelper_GetBuildInfo_Call) RunAndReturn(run func() (*build.Info, error)) *MockHelper_GetBuildInfo_Call
- type MockHelper_GetCmd_Call
- type MockHelper_GetConfig_Call
- type MockHelper_GetContext_Call
- type MockHelper_GetKonnectSDK_Call
- func (_c *MockHelper_GetKonnectSDK_Call) Return(_a0 helpers.SDKAPI, _a1 error) *MockHelper_GetKonnectSDK_Call
- func (_c *MockHelper_GetKonnectSDK_Call) Run(run func(cfg config.Hook, logger *slog.Logger)) *MockHelper_GetKonnectSDK_Call
- func (_c *MockHelper_GetKonnectSDK_Call) RunAndReturn(run func(config.Hook, *slog.Logger) (helpers.SDKAPI, error)) *MockHelper_GetKonnectSDK_Call
- type MockHelper_GetLogger_Call
- type MockHelper_GetOutputFormat_Call
- func (_c *MockHelper_GetOutputFormat_Call) Return(_a0 common.OutputFormat, _a1 error) *MockHelper_GetOutputFormat_Call
- func (_c *MockHelper_GetOutputFormat_Call) Run(run func()) *MockHelper_GetOutputFormat_Call
- func (_c *MockHelper_GetOutputFormat_Call) RunAndReturn(run func() (common.OutputFormat, error)) *MockHelper_GetOutputFormat_Call
- type MockHelper_GetProduct_Call
- func (_c *MockHelper_GetProduct_Call) Return(_a0 products.ProductValue, _a1 error) *MockHelper_GetProduct_Call
- func (_c *MockHelper_GetProduct_Call) Run(run func()) *MockHelper_GetProduct_Call
- func (_c *MockHelper_GetProduct_Call) RunAndReturn(run func() (products.ProductValue, error)) *MockHelper_GetProduct_Call
- type MockHelper_GetStreams_Call
- type MockHelper_GetVerb_Call
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfirmDelete ¶ added in v0.3.4
ConfirmDelete prompts the user to confirm destructive delete operations unless the --force flag was provided.
func DeleteAutoApproveEnabled ¶ added in v0.3.4
DeleteAutoApproveEnabled reports whether the user opted to skip confirmation prompts.
func DeleteForceEnabled ¶ added in v0.3.4
DeleteForceEnabled reports whether the current helper is operating in force mode (confirmation prompts should be skipped).
func SetDeleteAutoApprove ¶ added in v0.3.4
SetDeleteAutoApprove stores the --auto-approve flag state.
func SetDeleteForce ¶ added in v0.3.4
SetDeleteForce stores the --force flag value on the command context so that nested delete handlers can read it without rebinding flags or configs.
func TryConvertErrorToAttrs ¶
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) GetContext ¶
func (r *CommandHelper) GetContext() context.Context
func (*CommandHelper) GetKonnectSDK ¶ added in v0.0.13
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
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 []any
}
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 ¶
This will construct an execution error AND turn off error and usage output for the command
func PrepareExecutionErrorFromErr ¶ added in v0.3.2
func PrepareExecutionErrorFromErr(helper Helper, err error, attrs ...any) *ExecutionError
PrepareExecutionErrorFromErr converts an arbitrary error into an ExecutionError while silencing usage/error output on the associated command. The friendly message defaults to the underlying error string when msg is empty.
func PrepareExecutionErrorMsg ¶ added in v0.3.2
func PrepareExecutionErrorMsg(helper Helper, msg string, attrs ...any) *ExecutionError
PrepareExecutionErrorMsg builds an ExecutionError from a message when a backing error is not already available.
func PrepareExecutionErrorWithHelper ¶ added in v0.3.2
func PrepareExecutionErrorWithHelper(helper Helper, msg string, err error, attrs ...any) *ExecutionError
PrepareExecutionErrorWithHelper mirrors PrepareExecutionError but accepts a Helper. It ensures command usage/error output is silenced for runtime failures.
func (*ExecutionError) Error ¶
func (e *ExecutionError) Error() 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
GetKonnectSDK(cfg config.Hook, logger *slog.Logger) (helpers.SDKAPI, error)
}
type MockHelper ¶
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 no fields
func (*MockHelper) GetBuildInfo ¶
func (_m *MockHelper) GetBuildInfo() (*build.Info, error)
GetBuildInfo provides a mock function with no fields
func (*MockHelper) GetCmd ¶
func (_m *MockHelper) GetCmd() *cobra.Command
GetCmd provides a mock function with no fields
func (*MockHelper) GetConfig ¶
func (_m *MockHelper) GetConfig() (config.Hook, error)
GetConfig provides a mock function with no fields
func (*MockHelper) GetContext ¶
func (_m *MockHelper) GetContext() context.Context
GetContext provides a mock function with no fields
func (*MockHelper) GetKonnectSDK ¶ added in v0.0.13
GetKonnectSDK provides a mock function with given fields: cfg, logger
func (*MockHelper) GetLogger ¶
func (_m *MockHelper) GetLogger() (*slog.Logger, error)
GetLogger provides a mock function with no fields
func (*MockHelper) GetOutputFormat ¶
func (_m *MockHelper) GetOutputFormat() (common.OutputFormat, error)
GetOutputFormat provides a mock function with no fields
func (*MockHelper) GetProduct ¶
func (_m *MockHelper) GetProduct() (products.ProductValue, error)
GetProduct provides a mock function with no fields
func (*MockHelper) GetStreams ¶
func (_m *MockHelper) GetStreams() *iostreams.IOStreams
GetStreams provides a mock function with no fields
type MockHelper_Expecter ¶
type MockHelper_Expecter struct {
// contains filtered or unexported fields
}
func (*MockHelper_Expecter) GetArgs ¶
func (_e *MockHelper_Expecter) GetArgs() *MockHelper_GetArgs_Call
GetArgs is a helper method to define mock.On call
func (*MockHelper_Expecter) GetBuildInfo ¶
func (_e *MockHelper_Expecter) GetBuildInfo() *MockHelper_GetBuildInfo_Call
GetBuildInfo is a helper method to define mock.On call
func (*MockHelper_Expecter) GetCmd ¶
func (_e *MockHelper_Expecter) GetCmd() *MockHelper_GetCmd_Call
GetCmd is a helper method to define mock.On call
func (*MockHelper_Expecter) GetConfig ¶
func (_e *MockHelper_Expecter) GetConfig() *MockHelper_GetConfig_Call
GetConfig is a helper method to define mock.On call
func (*MockHelper_Expecter) GetContext ¶
func (_e *MockHelper_Expecter) GetContext() *MockHelper_GetContext_Call
GetContext is a helper method to define mock.On call
func (*MockHelper_Expecter) GetKonnectSDK ¶ added in v0.0.13
func (_e *MockHelper_Expecter) GetKonnectSDK(cfg interface{}, logger interface{}) *MockHelper_GetKonnectSDK_Call
GetKonnectSDK is a helper method to define mock.On call
- cfg config.Hook
- logger *slog.Logger
func (*MockHelper_Expecter) GetLogger ¶
func (_e *MockHelper_Expecter) GetLogger() *MockHelper_GetLogger_Call
GetLogger is a helper method to define mock.On call
func (*MockHelper_Expecter) GetOutputFormat ¶
func (_e *MockHelper_Expecter) GetOutputFormat() *MockHelper_GetOutputFormat_Call
GetOutputFormat is a helper method to define mock.On call
func (*MockHelper_Expecter) GetProduct ¶
func (_e *MockHelper_Expecter) GetProduct() *MockHelper_GetProduct_Call
GetProduct is a helper method to define mock.On call
func (*MockHelper_Expecter) GetStreams ¶
func (_e *MockHelper_Expecter) GetStreams() *MockHelper_GetStreams_Call
GetStreams is a helper method to define mock.On call
func (*MockHelper_Expecter) GetVerb ¶
func (_e *MockHelper_Expecter) GetVerb() *MockHelper_GetVerb_Call
GetVerb is a helper method to define mock.On call
type MockHelper_GetArgs_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 (_c *MockHelper_GetArgs_Call) Return(_a0 []string) *MockHelper_GetArgs_Call
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 ¶
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 (_c *MockHelper_GetBuildInfo_Call) Return(_a0 *build.Info, _a1 error) *MockHelper_GetBuildInfo_Call
func (*MockHelper_GetBuildInfo_Call) Run ¶
func (_c *MockHelper_GetBuildInfo_Call) Run(run func()) *MockHelper_GetBuildInfo_Call
func (*MockHelper_GetBuildInfo_Call) RunAndReturn ¶
func (_c *MockHelper_GetBuildInfo_Call) RunAndReturn(run func() (*build.Info, error)) *MockHelper_GetBuildInfo_Call
type MockHelper_GetCmd_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 (_c *MockHelper_GetCmd_Call) Return(_a0 *cobra.Command) *MockHelper_GetCmd_Call
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 ¶
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 (_c *MockHelper_GetConfig_Call) Return(_a0 config.Hook, _a1 error) *MockHelper_GetConfig_Call
func (*MockHelper_GetConfig_Call) Run ¶
func (_c *MockHelper_GetConfig_Call) Run(run func()) *MockHelper_GetConfig_Call
func (*MockHelper_GetConfig_Call) RunAndReturn ¶
func (_c *MockHelper_GetConfig_Call) RunAndReturn(run func() (config.Hook, error)) *MockHelper_GetConfig_Call
type MockHelper_GetContext_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 (_c *MockHelper_GetContext_Call) Return(_a0 context.Context) *MockHelper_GetContext_Call
func (*MockHelper_GetContext_Call) Run ¶
func (_c *MockHelper_GetContext_Call) Run(run func()) *MockHelper_GetContext_Call
func (*MockHelper_GetContext_Call) RunAndReturn ¶
func (_c *MockHelper_GetContext_Call) RunAndReturn(run func() context.Context) *MockHelper_GetContext_Call
type MockHelper_GetKonnectSDK_Call ¶ added in v0.0.13
MockHelper_GetKonnectSDK_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKonnectSDK'
func (*MockHelper_GetKonnectSDK_Call) Return ¶ added in v0.0.13
func (_c *MockHelper_GetKonnectSDK_Call) Return(_a0 helpers.SDKAPI, _a1 error) *MockHelper_GetKonnectSDK_Call
func (*MockHelper_GetKonnectSDK_Call) Run ¶ added in v0.0.13
func (_c *MockHelper_GetKonnectSDK_Call) Run(run func(cfg config.Hook, logger *slog.Logger)) *MockHelper_GetKonnectSDK_Call
func (*MockHelper_GetKonnectSDK_Call) RunAndReturn ¶ added in v0.0.13
func (_c *MockHelper_GetKonnectSDK_Call) RunAndReturn(run func(config.Hook, *slog.Logger) (helpers.SDKAPI, error)) *MockHelper_GetKonnectSDK_Call
type MockHelper_GetLogger_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 (_c *MockHelper_GetLogger_Call) Return(_a0 *slog.Logger, _a1 error) *MockHelper_GetLogger_Call
func (*MockHelper_GetLogger_Call) Run ¶
func (_c *MockHelper_GetLogger_Call) Run(run func()) *MockHelper_GetLogger_Call
func (*MockHelper_GetLogger_Call) RunAndReturn ¶
func (_c *MockHelper_GetLogger_Call) RunAndReturn(run func() (*slog.Logger, error)) *MockHelper_GetLogger_Call
type MockHelper_GetOutputFormat_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 (_c *MockHelper_GetOutputFormat_Call) Return(_a0 common.OutputFormat, _a1 error) *MockHelper_GetOutputFormat_Call
func (*MockHelper_GetOutputFormat_Call) Run ¶
func (_c *MockHelper_GetOutputFormat_Call) Run(run func()) *MockHelper_GetOutputFormat_Call
func (*MockHelper_GetOutputFormat_Call) RunAndReturn ¶
func (_c *MockHelper_GetOutputFormat_Call) RunAndReturn(run func() (common.OutputFormat, error)) *MockHelper_GetOutputFormat_Call
type MockHelper_GetProduct_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 (_c *MockHelper_GetProduct_Call) Return(_a0 products.ProductValue, _a1 error) *MockHelper_GetProduct_Call
func (*MockHelper_GetProduct_Call) Run ¶
func (_c *MockHelper_GetProduct_Call) Run(run func()) *MockHelper_GetProduct_Call
func (*MockHelper_GetProduct_Call) RunAndReturn ¶
func (_c *MockHelper_GetProduct_Call) RunAndReturn(run func() (products.ProductValue, error)) *MockHelper_GetProduct_Call
type MockHelper_GetStreams_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 (_c *MockHelper_GetStreams_Call) Return(_a0 *iostreams.IOStreams) *MockHelper_GetStreams_Call
func (*MockHelper_GetStreams_Call) Run ¶
func (_c *MockHelper_GetStreams_Call) Run(run func()) *MockHelper_GetStreams_Call
func (*MockHelper_GetStreams_Call) RunAndReturn ¶
func (_c *MockHelper_GetStreams_Call) RunAndReturn(run func() *iostreams.IOStreams) *MockHelper_GetStreams_Call
type MockHelper_GetVerb_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 (_c *MockHelper_GetVerb_Call) Return(_a0 verbs.VerbValue, _a1 error) *MockHelper_GetVerb_Call
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