Documentation ¶
Index ¶
- type FieldAttributes
- type Input
- type InputCollection
- type InputCursor
- type InputField
- func (f *InputField) AcceptedValues() []string
- func (f *InputField) DefaultValue() *string
- func (f *InputField) Enabled(evaluate bool, tags ...string) bool
- func (f *InputField) EnvVars() []string
- func (f *InputField) HasValue() bool
- func (f *InputField) InputSet() bool
- func (f *InputField) LongDescription() string
- func (f *InputField) Optional() bool
- func (f *InputField) Sensitive() bool
- func (f *InputField) SetAcceptedValues(acceptedValues []string, acceptedValuesErrorMessage string)
- func (f *InputField) SetExclusionFilter(exclusionFilter, exclusionFilterErrorMessage string) error
- func (f *InputField) SetInclusionFilter(inclusionFilter, inclusionFilterErrorMessage string) error
- func (f *InputField) SetInput()
- func (f *InputField) SetValue(value *string) error
- func (f *InputField) SetValueRef(valueRef interface{}) error
- func (f *InputField) Type() InputType
- func (f *InputField) Value() *string
- func (f *InputField) ValueFromFile() (bool, []string)
- type InputForm
- type InputGroup
- func (g *InputGroup) AddFieldValueHint(name, hint string) error
- func (g *InputGroup) BindFields(target interface{}) error
- func (g *InputGroup) Description() string
- func (g *InputGroup) DisplayName() string
- func (g *InputGroup) Enabled(evaluate bool, tags ...string) bool
- func (g *InputGroup) EnabledInputs(evaluate bool, tags ...string) []Input
- func (g *InputGroup) GetFieldValue(name string) (*string, error)
- func (g *InputGroup) GetFieldValueHints(name string) ([]string, error)
- func (g *InputGroup) GetInputField(name string) (*InputField, error)
- func (g *InputGroup) InputFields() []*InputField
- func (g *InputGroup) InputValues() map[string]string
- func (g *InputGroup) Inputs() []Input
- func (g *InputGroup) LongDescription() string
- func (g *InputGroup) Name() string
- func (g *InputGroup) NewInputContainer(name, displayName, description string, groupId int) Input
- func (g *InputGroup) NewInputField(attributes FieldAttributes) (Input, error)
- func (g *InputGroup) SetFieldValue(name string, value string) error
- func (g *InputGroup) String() string
- func (g *InputGroup) Type() InputType
- type InputType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldAttributes ¶
type FieldAttributes struct { // name of the field Name, DisplayName, Description string // defines a group id. all fields having // the same group id will be added to // a "Container" input group where only // one input in the "Container" will // be collected. an id of 0 flags the // field as not belonging to Container // group GroupID int // type of the input used for validation InputType InputType // if true then the input value should be // a file which will be read as the value // of the field ValueFromFile bool // a default value. nil if no default value DefaultValue *string // indicates if the field value should be masked Sensitive bool // any environment variables the value for // this input can be sourced from EnvVars []string // inputs that this input depends. this // helps define the input flow. this can // be of the format: // // - "field_name": // this field will require input only // if the given dependent field is // entered // // - "field_name=value": // this field will be require input // only if the given dependent field has // the given value // DependsOn []string // tags used to create field subsets // for input Tags []string // field value should match this regex InclusionFilter, InclusionFilterErrorMessage string // field value should not match this regex ExclusionFilter, ExclusionFilterErrorMessage string // list of acceptable values for field AcceptedValues []string // error message to return none of the // accepted values match the field value AcceptedValuesErrorMessage string }
InputField initialization attributes
type Input ¶
type Input interface { Name() string DisplayName() string Description() string LongDescription() string Type() InputType Inputs() []Input Enabled(evaluate bool, tags ...string) bool EnabledInputs(evaluate bool, tags ...string) []Input // contains filtered or unexported methods }
Input abstraction
type InputCollection ¶
type InputCollection struct {
// contains filtered or unexported fields
}
func NewInputCollection ¶
func NewInputCollection() *InputCollection
func (*InputCollection) Group ¶
func (ic *InputCollection) Group(name string) *InputGroup
func (*InputCollection) Groups ¶
func (ic *InputCollection) Groups() []*InputGroup
func (*InputCollection) HasGroup ¶
func (ic *InputCollection) HasGroup(name string) bool
func (*InputCollection) NewGroup ¶
func (ic *InputCollection) NewGroup( name string, description string, ) *InputGroup
type InputCursor ¶
type InputCursor struct {
// contains filtered or unexported fields
}
func NewInputCursor ¶
func NewInputCursor( input *InputGroup, tags ...string, ) *InputCursor
func NewInputCursorFromCollection ¶
func NewInputCursorFromCollection( groupName string, collection *InputCollection, tags ...string, ) (*InputCursor, error)
func (*InputCursor) GetCurrentInput ¶
func (c *InputCursor) GetCurrentInput() (Input, error)
out: input at current cursor position
func (*InputCursor) NextInput ¶
func (c *InputCursor) NextInput() *InputCursor
advances the cursor to the next input
func (*InputCursor) SetDefaultInput ¶
func (c *InputCursor) SetDefaultInput(name string) (*InputCursor, error)
sets default value of input at current cursor position and updates state if input has dependent inputs
in: name - of input to set value of out: c
func (*InputCursor) SetInput ¶
func (c *InputCursor) SetInput(name, value string) (*InputCursor, error)
sets value of input at current cursor position and updates state if input has dependent inputs
in: name - of input to set value of in: value - value to set. if nil default value will be used. out: c
type InputField ¶
type InputField struct { InputGroup // contains filtered or unexported fields }
This structure defines metadata for an input field in a data input group. If a field has a required element then input for the required field will be collected first in a wizard like flow. It implements the Input abstraction.
func (*InputField) AcceptedValues ¶
func (f *InputField) AcceptedValues() []string
out: list of acceptable values for field
func (*InputField) DefaultValue ¶
func (f *InputField) DefaultValue() *string
out: the default value of the field
func (*InputField) Enabled ¶
func (f *InputField) Enabled(evaluate bool, tags ...string) bool
out: whether this field is enabled
func (*InputField) EnvVars ¶
func (f *InputField) EnvVars() []string
out: environment variables associated with this field
func (*InputField) HasValue ¶
func (f *InputField) HasValue() bool
out: whether a value can be returned for this input
func (*InputField) LongDescription ¶
func (f *InputField) LongDescription() string
out: the long description of the group
func (*InputField) Optional ¶
func (f *InputField) Optional() bool
out: whether the field is optional as it has a default value
func (*InputField) Sensitive ¶
func (f *InputField) Sensitive() bool
out: whether to mask the field value
func (*InputField) SetAcceptedValues ¶
func (f *InputField) SetAcceptedValues( acceptedValues []string, acceptedValuesErrorMessage string, )
in: acceptedValues - list of acceptable values for field in: acceptedValuesErrorMessage - error message to return none of the accepted values match the field value
func (*InputField) SetExclusionFilter ¶
func (f *InputField) SetExclusionFilter( exclusionFilter, exclusionFilterErrorMessage string, ) error
in: exclusionFilter - field value should not match this regex in: exclusionFilterErrorMessage - error message to return if exclusion filter matches
func (*InputField) SetInclusionFilter ¶
func (f *InputField) SetInclusionFilter( inclusionFilter, inclusionFilterErrorMessage string, ) error
in: inclusionFilter - field value must match this regex in: inclusionFilterErrorMessage - error message to return if inclusion filter does not match
func (*InputField) SetValue ¶
func (f *InputField) SetValue(value *string) error
in: value - input value to set
func (*InputField) SetValueRef ¶
func (f *InputField) SetValueRef(valueRef interface{}) error
in: valueRef - pointer to a value or a pointer to a pointer to
a value. changing the contents of this pointer will modify the value reference and hence the contents of the field.
func (*InputField) Type ¶
func (f *InputField) Type() InputType
out: returns input type of the field
func (*InputField) ValueFromFile ¶
func (f *InputField) ValueFromFile() (bool, []string)
out: whether value is sourced from a file out: list of file paths to source from read from input field's
environment variables. If this field has a value then this list will have an entry named [saved] along with the possible paths to load a new the value from.
type InputForm ¶
type InputForm interface { Input BindFields(target interface{}) error AddFieldValueHint(name, hint string) error GetFieldValueHints(name string) ([]string, error) GetInputField(name string) (*InputField, error) GetFieldValue(name string) (*string, error) SetFieldValue(name string, value string) error InputFields() []*InputField InputValues() map[string]string }
InputForm abstraction
type InputGroup ¶
type InputGroup struct {
// contains filtered or unexported fields
}
This structure is a container for a collection of inputs which implements the InputForm abstraction
func (*InputGroup) AddFieldValueHint ¶
func (g *InputGroup) AddFieldValueHint(name, hint string) error
in: name - name of the field for which a hint should be added in: hint - the hint which is a URL with the following patterns.
- http://<url> - a http url from which source a list values separated by newlines
- file://<path> - a path to a file from which to source a list values separated by newlines
- field://<name>/<path> - a path to a value in a field with json content
func (*InputGroup) BindFields ¶
func (g *InputGroup) BindFields(target interface{}) error
in: binds the given target data structure to this input form's fields
func (*InputGroup) Description ¶
func (g *InputGroup) Description() string
out: the description of the group
func (*InputGroup) DisplayName ¶
func (g *InputGroup) DisplayName() string
out: the display name of the group
func (*InputGroup) Enabled ¶
func (g *InputGroup) Enabled(evaluate bool, tags ...string) bool
in: evaluate - whether field's dependencies should be evaluated in: tags - fields associated with these tags should be enabled out: whether this group is enabled
func (*InputGroup) EnabledInputs ¶
func (g *InputGroup) EnabledInputs(evaluate bool, tags ...string) []Input
in: evaluate - whether field's dependencies should be evaluated in: tags - fields associated with these tags should be enabled out: list of inputs that match any one of the given
tags and satisfies the input's post-condition
func (*InputGroup) GetFieldValue ¶
func (g *InputGroup) GetFieldValue(name string) (*string, error)
in: the name of the input field whose value should be retrieved out: a reference to the value of the input field
func (*InputGroup) GetFieldValueHints ¶
func (g *InputGroup) GetFieldValueHints(name string) ([]string, error)
in: name - name of the field for which a hint should be retrieved out: array of hint values
func (*InputGroup) GetInputField ¶
func (g *InputGroup) GetInputField(name string) (*InputField, error)
in: the name of the input field to retrieve out: the input field with the given name
func (*InputGroup) InputFields ¶
func (g *InputGroup) InputFields() []*InputField
out: a list of all fields for the group
func (*InputGroup) InputValues ¶
func (g *InputGroup) InputValues() map[string]string
out: map of name-values of all inputs entered
func (*InputGroup) Inputs ¶
func (g *InputGroup) Inputs() []Input
out: a list of all inputs for the group
func (*InputGroup) LongDescription ¶
func (g *InputGroup) LongDescription() string
out: the long description of the group
func (*InputGroup) NewInputContainer ¶
func (g *InputGroup) NewInputContainer( name, displayName, description string, groupId int, ) Input
in: name - name of the container in: displayName - the name to display when requesting input in: description - a long description which can also be
the help text for the container
out: An initialized instance of an InputGroup of type "Container" structure
func (*InputGroup) NewInputField ¶
func (g *InputGroup) NewInputField( attributes FieldAttributes, ) (Input, error)
in: attributes - The field attributes
out: An initialized instance of an InputField structure
func (*InputGroup) SetFieldValue ¶
func (g *InputGroup) SetFieldValue(name string, value string) error
in: the name of the input field to set the value of in: a reference to the value to set. if nil the value is cleared
func (*InputGroup) String ¶
func (g *InputGroup) String() string
func (*InputGroup) Type ¶
func (g *InputGroup) Type() InputType
out: returns input type of "Container"