Documentation
¶
Index ¶
- Variables
- func ConfirmPromptWithTemplate(msg string) func(parameters Parameters, configs Configs) string
- func DefaultConfirmPrompt(parameters Parameters, configs Configs) string
- func ExecutorAs[T Executor](exec Executor) (T, bool)
- func GetMgcTagBool(t reflect.StructTag, name string) bool
- func HMACSHA256(key []byte, data []byte) []byte
- func HMACSHA256String(key []byte, data string) []byte
- func NewGrouperContext(parent context.Context, group func() Grouper) context.Context
- func NewLinkConfirmableExecutor(linkExecutor LinkExecutor) *linkConfirmableExecutor
- func NewLinkExecutor(target Executor, preparedParameters Parameters, preparedConfigs Configs, ...) *linkExecutor
- func NewLinkPromptInputExecutor(linkExecutor LinkExecutor) *linkPromptInputExecutor
- func NewLinkTerminatorExecutor(linkExecutor LinkExecutor) *linkTerminatorExecutor
- func NewRefPathResolverContext(parent context.Context, refResolver RefPathResolver) context.Context
- func NewResultWithOriginalSource(originalSource ResultSource, result Result) *resultWithOriginalSource
- func NewSimpleLink(s SimpleLinkSpec) *simpleLink
- func ResolveSchema(refResolver RefPathResolver, ref string) (result *mgcSchema.Schema, err error)
- func ResolveSchemaChildren(r RefPathResolver, schema *mgcSchema.Schema) (result *mgcSchema.Schema, err error)
- func ResolveSchemaPath(refResolver RefPathResolver, path RefPath) (result *mgcSchema.Schema, err error)
- func ResolveSchemaRef(refResolver RefPathResolver, schemaRef *mgcSchema.SchemaRef) (result *mgcSchema.Schema, err error)
- func ResultAs[T Result](result Result) (T, bool)
- func SHA256Hex(reader io.Reader) (string, error)
- func VisitAllExecutors(child Descriptor, path []string, includeInternal bool, ...) (bool, error)
- type BoundRefPathResolver
- type ChainedError
- type Configs
- type ConfirmableExecutor
- type Descriptor
- type DescriptorSpec
- type DescriptorVisitor
- type DocumentRefPathResolver
- type Example
- type Executor
- func NewExecuteFormat(executor Executor, getFormatter func(exec Executor, result Result) string) Executor
- func NewExecuteResultOutputOptions(executor Executor, getOutputOptions func(exec Executor, result Result) string) Executor
- func NewExecuteResultWrapper(executor Executor, ...) Executor
- func NewHumanIdentifiableFieldsExecutor(exec Executor, humanIdentifierFields []string) Executor
- func NoOpExecutor() Executor
- func ResolveExecutor(refResolver RefPathResolver, ref string) (exec Executor, err error)
- func ResolveExecutorPath(refResolver RefPathResolver, path RefPath) (exec Executor, err error)
- type ExecutorSpec
- type ExecutorSpecFn
- type ExecutorWrapper
- type FailedTerminationError
- type Grouper
- type GrouperLazyChildren
- type HumanIdentifiableFieldsExecutor
- type LinkExecutor
- type Linker
- type Links
- type LinksSpecFn
- type MergeGroup
- type MgcTag
- type MissingFieldError
- type MultiRefPathResolver
- type Parameters
- type PromptInput
- type PromptInputExecutor
- type RefPath
- type RefPathResolveError
- type RefPathResolver
- type RelatedSpecFn
- type Result
- type ResultSource
- type ResultWithDefaultFormatter
- type ResultWithDefaultOutputOptions
- type ResultWithMultipart
- type ResultWithReader
- type ResultWithValue
- type ResultWrapper
- type RetryUntil
- type RetryUntilCb
- type RetryUntilCheck
- type RetryUntilConfig
- type Schema
- type Scope
- type Scopes
- type ScopesString
- type SimpleDescriptor
- func (d *SimpleDescriptor) Description() string
- func (d *SimpleDescriptor) DescriptorSpec() DescriptorSpec
- func (d *SimpleDescriptor) GroupID() string
- func (d *SimpleDescriptor) IsInternal() bool
- func (d *SimpleDescriptor) Name() string
- func (d *SimpleDescriptor) Scopes() Scopes
- func (d *SimpleDescriptor) Summary() string
- func (d *SimpleDescriptor) Version() string
- type SimpleExecutor
- func NewReflectedSimpleExecutor[ParamsT any, ConfigsT any, ResultT any](baseSpec ExecutorSpec, ...) *SimpleExecutor
- func NewReflectedSimpleExecutorSchemas[ParamsT any, ConfigsT any, ResultT any](baseSpec ExecutorSpec) *SimpleExecutor
- func NewSimpleExecutor(spec ExecutorSpec) *SimpleExecutor
- func NewStaticExecute[ParamsT any, ConfigsT any, ResultT any](spec DescriptorSpec, ...) *SimpleExecutor
- func NewStaticExecuteSimple[ResultT any](spec DescriptorSpec, ...) *SimpleExecutor
- func (e *SimpleExecutor) ConfigsSchema() *Schema
- func (*SimpleExecutor) EmptyResult() Result
- func (e *SimpleExecutor) Execute(context context.Context, parameters Parameters, configs Configs) (result Result, err error)
- func (e *SimpleExecutor) HiddenFlags() []string
- func (e *SimpleExecutor) Links() Links
- func (e *SimpleExecutor) ParametersSchema() *Schema
- func (e *SimpleExecutor) PositionalArgs() []string
- func (e *SimpleExecutor) Related() map[string]Executor
- func (e *SimpleExecutor) ResultSchema() *Schema
- type SimpleGrouper
- type SimpleLinkSpec
- type SimpleResult
- type TerminatorExecutor
- type Time
- type UsageError
- type UserDeniedConfirmationError
- type Value
- type VersionChecker
- type WaitTerminationConfig
Constants ¶
This section is empty.
Variables ¶
var ErrorResultHasNoValue = errors.New("result has no value")
Functions ¶
func ConfirmPromptWithTemplate ¶
func ConfirmPromptWithTemplate(msg string) func(parameters Parameters, configs Configs) string
ConfirmPromptWithTemplate parses and executes the template provided in the message. If the template fails to parse or execute, a default generic message is returned
func DefaultConfirmPrompt ¶
func DefaultConfirmPrompt(parameters Parameters, configs Configs) string
func ExecutorAs ¶
func HMACSHA256 ¶
HMACSHA256 computes a HMAC-SHA256 of data given the provided key.
func HMACSHA256String ¶
func NewGrouperContext ¶
func NewLinkConfirmableExecutor ¶
func NewLinkConfirmableExecutor(linkExecutor LinkExecutor) *linkConfirmableExecutor
Wraps a linkExecutor that implements ConfirmableExecutor
linkExecutor.Unwrap() (target) must implement the ConfirmableExecutor interface, otherwise it will panic
func NewLinkExecutor ¶
func NewLinkExecutor( target Executor, preparedParameters Parameters, preparedConfigs Configs, additionalParametersSchema *Schema, additionalConfigsSchema *Schema, ) *linkExecutor
Wraps the target executor, handling prepared values before calling it.
The returned Executor will expose additionalParametersSchema() as ParametersSchema() and additionalConfigsSchema as ConfigsSchema().
Then the Execute() will automatically copy the preparedParameters and preparedConfigs in the given parameters and configs (respectively), before calling target.Execute().
Other Executor methods will be passed thru target without further modifications.
func NewLinkPromptInputExecutor ¶
func NewLinkPromptInputExecutor(linkExecutor LinkExecutor) *linkPromptInputExecutor
func NewLinkTerminatorExecutor ¶
func NewLinkTerminatorExecutor(linkExecutor LinkExecutor) *linkTerminatorExecutor
Wraps a linkExecutor that implements TerminatorExecutor
linkExecutor.Unwrap() (target) must implement the TerminatorExecutor interface, otherwise it will panic
func NewRefPathResolverContext ¶
func NewRefPathResolverContext(parent context.Context, refResolver RefPathResolver) context.Context
func NewResultWithOriginalSource ¶
func NewResultWithOriginalSource(originalSource ResultSource, result Result) *resultWithOriginalSource
Wraps (embeds) a result and overrides the original source.
func NewSimpleLink ¶
func NewSimpleLink(s SimpleLinkSpec) *simpleLink
func ResolveSchema ¶
func ResolveSchema(refResolver RefPathResolver, ref string) (result *mgcSchema.Schema, err error)
func ResolveSchemaChildren ¶
func ResolveSchemaChildren(r RefPathResolver, schema *mgcSchema.Schema) (result *mgcSchema.Schema, err error)
This changes schema *IN PLACE* so future resolutions will use the same pointers
This guarantees the Schema and internal elements are fully resolved.
func ResolveSchemaPath ¶
func ResolveSchemaPath(refResolver RefPathResolver, path RefPath) (result *mgcSchema.Schema, err error)
func ResolveSchemaRef ¶
func ResolveSchemaRef(refResolver RefPathResolver, schemaRef *mgcSchema.SchemaRef) (result *mgcSchema.Schema, err error)
This changes schemaRef *IN PLACE* so future resolutions will use the same pointers
This guarantees the SchemaRef, Schema and internal elements are fully resolved.
Types ¶
type BoundRefPathResolver ¶
type BoundRefPathResolver struct { Resolver *MultiRefPathResolver CurrentUrl string // if RefPath's URL is this placeholder given to MultiRefPathResolver, use this URL instead. }
Wraps MultiRefPathResolver and automatically pass CurrentUrl
func NewBoundRefResolver ¶
func NewBoundRefResolver(currentUrl string, resolver *MultiRefPathResolver) *BoundRefPathResolver
func (*BoundRefPathResolver) Resolve ¶
func (r *BoundRefPathResolver) Resolve(ref string) (result any, err error)
func (*BoundRefPathResolver) ResolvePath ¶
func (r *BoundRefPathResolver) ResolvePath(path RefPath) (result any, err error)
type ChainedError ¶
type ChainedError = utils.ChainedError
type Configs ¶
type Configs = Parameters
type ConfirmableExecutor ¶
type ConfirmableExecutor interface { Executor ConfirmPrompt(parameters Parameters, configs Configs) (message string) }
func NewConfirmableExecutor ¶
func NewConfirmableExecutor( exec Executor, confirmPrompt func(parameters Parameters, configs Configs) (message string), ) ConfirmableExecutor
type Descriptor ¶
type Descriptor interface { Name() string Version() string Description() string Summary() string IsInternal() bool Scopes() Scopes DescriptorSpec() DescriptorSpec GroupID() string }
General interface that describes both Executor and Grouper
type DescriptorSpec ¶
type DescriptorSpec struct { Name string `json:"name"` Version string `json:"version"` Description string `json:"description"` Summary string `json:"summary"` IsInternal *bool `json:"isInternal,omitempty"` Scopes Scopes `json:"scopes"` Observations string `json:"observation,omitempty"` GroupID string `json:"groupId,omitempty"` }
func (*DescriptorSpec) Validate ¶
func (d *DescriptorSpec) Validate() error
type DescriptorVisitor ¶
type DescriptorVisitor func(child Descriptor) (run bool, err error)
type DocumentRefPathResolver ¶
type DocumentRefPathResolver struct {
// contains filtered or unexported fields
}
Resolve within a single document, walks from root group to leaf Executors and their sub-fields
Most users will want BoundRefPathResolver instead.
func NewDocumentRefPathResolver ¶
func NewDocumentRefPathResolver(getRoot utils.LoadWithError[any]) *DocumentRefPathResolver
NOTE: getRoot() will be called multiple times, make sure it caches its own results, ex utils.NewLazyLoaderWithError()
func (*DocumentRefPathResolver) Resolve ¶
func (r *DocumentRefPathResolver) Resolve(ref string) (result any, err error)
func (*DocumentRefPathResolver) ResolvePath ¶
func (r *DocumentRefPathResolver) ResolvePath(path RefPath) (result any, err error)
type Executor ¶
type Executor interface { Descriptor ParametersSchema() *Schema ConfigsSchema() *Schema // The general schema this executor can produce. It may be oneOf/anyOf with multiple schemas. // The Result.Schema() may be a subset of the schema, if multiple were available. ResultSchema() *Schema PositionalArgs() []string HiddenFlags() []string // Linkers wrap executors that can operate on the result of this executor. // // For other executors that may be associated or operate together with this one, see Related(). // // NOTE: it's possible to add new links using Links().AddLink(), but it's not possible to delete // nor override any existing links Links() Links // Executors that may be associated or operate together with this one. // // For executors that can operate on the returned value, see Links(). // // NOTE: This map should not be altered externally. Related() map[string]Executor // The maps for the parameters and configs should NOT be modified inside the implementation of 'Execute' Execute(context context.Context, parameters Parameters, configs Configs) (result Result, err error) // A zero value instantiation of the concrete Result type used by each Executor. Useful for Encoding/Decoding the Result EmptyResult() Result }
func NewExecuteFormat ¶
func NewExecuteFormat( executor Executor, getFormatter func(exec Executor, result Result) string, ) Executor
Wraps (embeds) an executor and add specific result formatting.
func NewExecuteResultOutputOptions ¶
func NewExecuteResultOutputOptions( executor Executor, getOutputOptions func(exec Executor, result Result) string, ) Executor
Wraps (embeds) an executor and add specific result default output options getter.
func NewExecuteResultWrapper ¶
func NewExecuteResultWrapper( executor Executor, wrapResult func(wrapperExecutor ExecutorWrapper, originalResult Result) (wrappedResult Result, err error), ) Executor
Wraps (embeds) an executor and wrap its result. This may be used to add extra interfaces to a result, such as formatting or output options
func NoOpExecutor ¶
func NoOpExecutor() Executor
func ResolveExecutor ¶
func ResolveExecutor(refResolver RefPathResolver, ref string) (exec Executor, err error)
func ResolveExecutorPath ¶
func ResolveExecutorPath(refResolver RefPathResolver, path RefPath) (exec Executor, err error)
type ExecutorSpec ¶
type ExecutorSpec struct { DescriptorSpec ParametersSchema *Schema ConfigsSchema *Schema ResultSchema *Schema Links LinksSpecFn Related RelatedSpecFn PositionalArgs []string HiddenFlags []string Execute ExecutorSpecFn }
func ReflectExecutorSpec ¶
func ReflectExecutorSpec[ParamsT any, ConfigsT any, ResultT any]( baseSpec ExecutorSpec, typedExecute func(context context.Context, params ParamsT, configs ConfigsT) (result ResultT, err error), ) (spec ExecutorSpec, err error)
func ReflectExecutorSpecSchemas ¶
func ReflectExecutorSpecSchemas[ParamsT any, ConfigsT any, ResultT any](baseSpec ExecutorSpec) (spec ExecutorSpec, err error)
Given a base spec and types to be reflected, populate with the schemas
func (*ExecutorSpec) Validate ¶
func (s *ExecutorSpec) Validate() (err error)
type ExecutorSpecFn ¶
type ExecutorSpecFn func(executor Executor, context context.Context, parameters Parameters, configs Configs) (result Result, err error)
func ReflectExecutorSpecFn ¶
type ExecutorWrapper ¶
NOTE: whenever you wrap an executor remember to also wrap the result with ExecutorWrapResult() so the outmost executor is given as source
type FailedTerminationError ¶
func (FailedTerminationError) Error ¶
func (e FailedTerminationError) Error() string
type Grouper ¶
type Grouper interface { Descriptor VisitChildren(visitor DescriptorVisitor) (finished bool, err error) GetChildByName(name string) (child Descriptor, err error) }
func GrouperFromContext ¶
func NewStaticGroup ¶
func NewStaticGroup(spec DescriptorSpec, createChildren func() []Descriptor) Grouper
type GrouperLazyChildren ¶
type GrouperLazyChildren[T Descriptor] struct { // contains filtered or unexported fields }
Implements VisitChildren() and GetChildByName() by calling createChildren() only once, when/if needed, and storing the results.
Children will be automatically sorted by their names, so visitor are always in a predictable and stable order.
func NewGrouperLazyChildren ¶
func NewGrouperLazyChildren[T Descriptor](createChildren func() ([]T, error)) *GrouperLazyChildren[T]
func (*GrouperLazyChildren[T]) GetChildByName ¶
func (g *GrouperLazyChildren[T]) GetChildByName(name string) (child Descriptor, err error)
func (*GrouperLazyChildren[T]) VisitChildren ¶
func (g *GrouperLazyChildren[T]) VisitChildren(visitor DescriptorVisitor) (finished bool, err error)
type LinkExecutor ¶
type LinkExecutor interface { Executor ExecutorWrapper // contains filtered or unexported methods }
type Linker ¶
type Linker interface { Name() string Description() string IsInternal() bool // Describes the additional parameters required by the created executor. // // This will match CreateExecutor().ParametersSchema() AdditionalParametersSchema() *Schema // Describes the additional configuration required by the created executor. // // This will match CreateExecutor().ConfigsSchema() AdditionalConfigsSchema() *Schema ResultSchema() *Schema // Create an executor based on a result. // // The returned executor will have ParametersSchema() matching AdditionalParametersSchema() // and ConfigsSchema() matching AdditionalConfigsSchema() CreateExecutor(originalResult Result) (exec Executor, err error) Links() Links IsTargetTerminatorExecutor() bool }
type LinksSpecFn ¶
type MergeGroup ¶
type MergeGroup struct { SimpleDescriptor *GrouperLazyChildren[Descriptor] // contains filtered or unexported fields }
func NewMergeGroup ¶
func NewMergeGroup(desc DescriptorSpec, createToMerge func() []Grouper) (o *MergeGroup)
type MgcTag ¶
type MgcTag [2]string
func GetMgcTags ¶
Standard way to get the tags, splitting by comma
type MissingFieldError ¶
type MissingFieldError string
func (MissingFieldError) Error ¶
func (e MissingFieldError) Error() string
type MultiRefPathResolver ¶
type MultiRefPathResolver struct { Resolvers map[string]RefPathResolver // maps url => resolver CurrentUrlPlaceholder string // if RefPath's URL is this placeholder, use the given currentUrl EmptyDocumentUrl string // if RefPath's URL is empty, then use this URL. }
Discovers the document from the pointerPath and call the specific document resolver.
if RefPath's URL is CurrentUrlPlaceholder, then use the given currentUrl. If the placeholder if empty, currentUrl is also used.
if CurrentUrlPlaceholder is non-empty and RefPath's URL is empty, then use EmptyDocumentUrl.
func NewMultiRefPathResolver ¶
func NewMultiRefPathResolver() *MultiRefPathResolver
func (*MultiRefPathResolver) Add ¶
func (r *MultiRefPathResolver) Add(url string, docResolver RefPathResolver) error
Associates the given URL to a document resolver
func (*MultiRefPathResolver) Resolve ¶
func (r *MultiRefPathResolver) Resolve(ref string, currentUrl string) (result any, err error)
func (*MultiRefPathResolver) ResolvePath ¶
func (r *MultiRefPathResolver) ResolvePath(path RefPath, currentUrl string) (result any, err error)
type Parameters ¶
TODO: Evaluate if the typealias/type assign is needed at all. If a type assign is needed for some reason, the kin-openapi lib will need to be patched to accept type assigns of the correct structure on VisitJSON (likely through reflection). As it is now, validation fails with type assigns
type PromptInput ¶
type PromptInput func(parameters Parameters, configs Configs) (message string, validate func(input string) error)
func NewPromptInput ¶
func NewPromptInput(msgTemplate string, confirmationTemplate string) PromptInput
The msgTemplate represents a template used to generate the confirmation message for the user The confirmationValueTemplate define what the user need to type in order to confirm the operation
type PromptInputExecutor ¶
type PromptInputExecutor interface { Executor PromptInput(parameters Parameters, configs Configs) (message string, validate func(input string) error) }
func NewPromptInputExecutor ¶
func NewPromptInputExecutor( exec Executor, promptInput PromptInput, ) PromptInputExecutor
type RefPath ¶
type RefPath string
Similar to JSON Pointers - RFC6901
The difference is that it allow an URL to be specified before the JSON Pointer, so both are valid:
- /path/to/element
- http://some.url.com#/path/to/element
func (*RefPath) UnmarshalJSON ¶
type RefPathResolveError ¶
func (*RefPathResolveError) Error ¶
func (e *RefPathResolveError) Error() string
func (*RefPathResolveError) Unwrap ¶
func (e *RefPathResolveError) Unwrap() error
type RefPathResolver ¶
type RefPathResolver interface { // validate the given string, convert it to RefPath and resolve it Resolve(path string) (result any, err error) ResolvePath(path RefPath) (result any, err error) }
func RefPathResolverFromContext ¶
func RefPathResolverFromContext(ctx context.Context) RefPathResolver
type RelatedSpecFn ¶
type Result ¶
type Result interface { // What was used to produce this result Source() ResultSource Encode() ([]byte, error) Decode([]byte) error }
func ExecutorWrapResult ¶
func ExecutorWrapResult(executorWrapper ExecutorWrapper, result Result, err error) (Result, error)
The new Result with have Source().Executor set back to executorWrapper
func ExecutorWrapResultSource ¶
func ExecutorWrapResultSource(source ResultSource, result Result, err error) (Result, error)
The new Result with have Source() set back to source
type ResultSource ¶
type ResultSource struct { // Will be nil if Result was decoded Executor Executor `json:"-"` // Will be nil if Result was decoded Context context.Context `json:"-"` Parameters Parameters Configs Configs }
type ResultWithDefaultFormatter ¶
type ResultWithDefaultFormatter interface { ResultWithValue DefaultFormatter() string }
Implement this interface in Result that want to provide customized formatting of output. It's used by the command line interface (CLI) and possible other tools. This is only called if no other explicit formatting is desired
func NewResultWithDefaultFormatter ¶
func NewResultWithDefaultFormatter( result ResultWithValue, formatter string, ) ResultWithDefaultFormatter
Wraps (embeds) a result and add specific result formatting.
type ResultWithDefaultOutputOptions ¶
type ResultWithDefaultOutputOptions interface { ResultWithValue // The return should be in the same format as CLI -o "VALUE" // example: "yaml" or "table=COL:$.path.to[*].element,OTHERCOL:$.path.to[*].other" DefaultOutputOptions() string }
Implement this interface in Results that want to provide default output options. It's used by the command line interface (CLI) and possible other tools. This is only called if no other explicit options are desired
func NewResultWithDefaultOutputOptions ¶
func NewResultWithDefaultOutputOptions( result ResultWithValue, outputOptions string, ) ResultWithDefaultOutputOptions
Wraps (embeds) a result and add specific result default output options getter.
type ResultWithMultipart ¶
type ResultWithReader ¶
type ResultWithValue ¶
type ResultWrapper ¶
type RetryUntil ¶
type RetryUntil struct { MaxRetries int Interval time.Duration Check RetryUntilCheck }
func (*RetryUntil) Run ¶
func (r *RetryUntil) Run(ctx context.Context, cb RetryUntilCb) (result Result, err error)
type RetryUntilCb ¶
type RetryUntilCheck ¶
func NewRetryUntilCheckFromJsonPath ¶
func NewRetryUntilCheckFromJsonPath(expression string) (check RetryUntilCheck, err error)
func NewRetryUntilCheckFromTemplate ¶
func NewRetryUntilCheckFromTemplate(expression string) (check RetryUntilCheck, err error)
type RetryUntilConfig ¶
type RetryUntilConfig struct { MaxRetries int `json:"maxRetries,omitempty"` Interval time.Duration `json:"interval,omitempty"` JSONPathQuery string `json:"jsonPathQuery,omitempty"` TemplateQuery string `json:"templateQuery,omitempty"` }
func (*RetryUntilConfig) Build ¶
func (c *RetryUntilConfig) Build() (r *RetryUntil, err error)
func (*RetryUntilConfig) UnmarshalJSON ¶
func (c *RetryUntilConfig) UnmarshalJSON(data []byte) (err error)
type Scopes ¶
type Scopes []Scope
func (Scopes) AsScopesString ¶
func (s Scopes) AsScopesString() ScopesString
type ScopesString ¶
type ScopesString string
func (ScopesString) AsScopes ¶
func (s ScopesString) AsScopes() Scopes
type SimpleDescriptor ¶
type SimpleDescriptor struct {
Spec DescriptorSpec
}
func (*SimpleDescriptor) Description ¶
func (d *SimpleDescriptor) Description() string
func (*SimpleDescriptor) DescriptorSpec ¶
func (d *SimpleDescriptor) DescriptorSpec() DescriptorSpec
func (*SimpleDescriptor) GroupID ¶
func (d *SimpleDescriptor) GroupID() string
func (*SimpleDescriptor) IsInternal ¶
func (d *SimpleDescriptor) IsInternal() bool
func (*SimpleDescriptor) Name ¶
func (d *SimpleDescriptor) Name() string
func (*SimpleDescriptor) Scopes ¶
func (d *SimpleDescriptor) Scopes() Scopes
func (*SimpleDescriptor) Summary ¶
func (d *SimpleDescriptor) Summary() string
func (*SimpleDescriptor) Version ¶
func (d *SimpleDescriptor) Version() string
type SimpleExecutor ¶
type SimpleExecutor struct { SimpleDescriptor // contains filtered or unexported fields }
func NewReflectedSimpleExecutor ¶
func NewReflectedSimpleExecutor[ParamsT any, ConfigsT any, ResultT any]( baseSpec ExecutorSpec, execute func(context context.Context, params ParamsT, configs ConfigsT) (result ResultT, err error), ) *SimpleExecutor
Go Parameter and Config structs Note: we use both 'jsonschema' and 'mapstructure' for this helper. Be careful when using struct tags in your Params and Configs structs, as the tags from those libraries can't be out of sync when it comes to field names/json names See: - https://pkg.go.dev/github.com/invopop/jsonschema - https://pkg.go.dev/github.com/mitchellh/mapstructure
func NewReflectedSimpleExecutorSchemas ¶
func NewReflectedSimpleExecutorSchemas[ParamsT any, ConfigsT any, ResultT any]( baseSpec ExecutorSpec, ) *SimpleExecutor
Version that generates the schema, but uses baseSpec.Execute as is
func NewSimpleExecutor ¶
func NewSimpleExecutor(spec ExecutorSpec) *SimpleExecutor
func NewStaticExecute ¶
func NewStaticExecute[ParamsT any, ConfigsT any, ResultT any]( spec DescriptorSpec, execute func(context context.Context, params ParamsT, configs ConfigsT) (result ResultT, err error), ) *SimpleExecutor
Go Parameter and Config structs Note: we use both 'jsonschema' and 'mapstructure' for this helper. Be careful when using struct tags in your Params and Configs structs, as the tags from those libraries can't be out of sync when it comes to field names/json names See: - https://pkg.go.dev/github.com/invopop/jsonschema - https://pkg.go.dev/github.com/mitchellh/mapstructure
func NewStaticExecuteSimple ¶
func NewStaticExecuteSimple[ResultT any]( spec DescriptorSpec, execute func(context context.Context) (result ResultT, err error), ) *SimpleExecutor
No parameters or configs
func (*SimpleExecutor) ConfigsSchema ¶
func (e *SimpleExecutor) ConfigsSchema() *Schema
func (*SimpleExecutor) EmptyResult ¶
func (*SimpleExecutor) EmptyResult() Result
func (*SimpleExecutor) Execute ¶
func (e *SimpleExecutor) Execute(context context.Context, parameters Parameters, configs Configs) (result Result, err error)
func (*SimpleExecutor) HiddenFlags ¶
func (e *SimpleExecutor) HiddenFlags() []string
func (*SimpleExecutor) Links ¶
func (e *SimpleExecutor) Links() Links
func (*SimpleExecutor) ParametersSchema ¶
func (e *SimpleExecutor) ParametersSchema() *Schema
func (*SimpleExecutor) PositionalArgs ¶
func (e *SimpleExecutor) PositionalArgs() []string
func (*SimpleExecutor) Related ¶
func (e *SimpleExecutor) Related() map[string]Executor
func (*SimpleExecutor) ResultSchema ¶
func (e *SimpleExecutor) ResultSchema() *Schema
type SimpleGrouper ¶
type SimpleGrouper[T Descriptor] struct { SimpleDescriptor *GrouperLazyChildren[T] }
func NewSimpleGrouper ¶
func NewSimpleGrouper[T Descriptor](spec DescriptorSpec, createChildren func() ([]T, error)) *SimpleGrouper[T]
type SimpleLinkSpec ¶
type SimpleResult ¶
type SimpleResult struct { SourceData ResultSource ResultSchema *Schema ResultValue Value }
func NewSimpleResult ¶
func NewSimpleResult(source ResultSource, schema *Schema, value Value) *SimpleResult
func (*SimpleResult) Decode ¶
func (s *SimpleResult) Decode(data []byte) error
func (SimpleResult) Encode ¶
func (s SimpleResult) Encode() ([]byte, error)
func (SimpleResult) Schema ¶
func (s SimpleResult) Schema() *Schema
func (SimpleResult) Source ¶
func (s SimpleResult) Source() ResultSource
func (SimpleResult) ValidateSchema ¶
func (s SimpleResult) ValidateSchema() error
func (SimpleResult) Value ¶
func (s SimpleResult) Value() Value
type TerminatorExecutor ¶
type TerminatorExecutor interface { Executor ExecuteUntilTermination(context context.Context, parameters Parameters, configs Configs) (result Result, err error) }
func NewTerminatorExecutorWithCheck ¶
func NewTerminatorExecutorWithCheck( executor Executor, maxRetries int, interval time.Duration, checkTerminate func(ctx context.Context, exec Executor, result ResultWithValue) (terminated bool, err error), ) TerminatorExecutor
Execute the operation and check the results until it's considered terminated. The executor will wait `interval` between retries, executing up to `maxRetries`
type Time ¶
NOTE: This is so 'jsonschema' doesn't generate a schema with type string and format 'date-time'. We want the raw object schema for later validation
type UsageError ¶
type UsageError struct {
Err error
}
func (UsageError) Error ¶
func (e UsageError) Error() string
func (UsageError) Unwrap ¶
func (e UsageError) Unwrap() error
type UserDeniedConfirmationError ¶
type UserDeniedConfirmationError struct {
Prompt string
}
func (UserDeniedConfirmationError) Error ¶
func (e UserDeniedConfirmationError) Error() string
type VersionChecker ¶
type VersionChecker struct {
// contains filtered or unexported fields
}
func NewVersionChecker ¶
func NewVersionChecker( getHttp getCall, getConfig, setConfig configValue, ) *VersionChecker
NewVersionChecker creates a new VersionChecker getHttp - the getCall client to use for requests getConfig - a function to get a config value setConfig - a function to set a config value
func (*VersionChecker) CheckVersion ¶
func (v *VersionChecker) CheckVersion(currentVersion string, args ...string)
CheckVersion checks if the current version is outdated and prints a message if it is. It also sets the last check time to the current time. currentVersion - the current version of the cli args - optional command line arguments
type WaitTerminationConfig ¶
type WaitTerminationConfig struct { MaxRetries int `json:"maxRetries,omitempty"` Interval time.Duration `json:"interval,omitempty"` JSONPathQuery string `json:"jsonPathQuery,omitempty"` TemplateQuery string `json:"templateQuery,omitempty"` ErrorJSONPathQuery string `json:"errorJsonPathQuery,omitempty"` ErrorTemplateQuery string `json:"errorTemplateQuery,omitempty"` }
func (*WaitTerminationConfig) Build ¶
func (c *WaitTerminationConfig) Build(exec Executor, getDocument func(result ResultWithValue) any) (tExec TerminatorExecutor, err error)
func (*WaitTerminationConfig) UnmarshalJSON ¶
func (c *WaitTerminationConfig) UnmarshalJSON(data []byte) (err error)
Source Files
¶
- confirmable_executor.go
- descriptor.go
- grouper_lazy_children.go
- hmac.go
- human_identifiable_fields_executor.go
- link_executor.go
- linker.go
- logger.go
- merge.go
- mgc_tag.go
- noop_executor.go
- prompt_input_executor.go
- ref_resolver.go
- result.go
- retry_until.go
- scopes.go
- simple_executor.go
- simple_grouper.go
- static_execute.go
- static_group.go
- terminator_executor.go
- types.go
- usage_error.go
- version_checker.go
- wait_termination_config.go