Documentation ¶
Overview ¶
Package qaengine contains the types used for the question answering part of the CLI.
Index ¶
- Constants
- func ArrayToInterface(ans []string, problemType SolutionFormType) (ansI interface{}, err error)
- func GenerateYAMLFromExpression(expr string) (string, error)
- func GetProblemCategories(targetProbId string, additionalCategories []string) []string
- func InterfaceToArray(ansI interface{}, problemType SolutionFormType) (ans []string, err error)
- func MergeYAMLDatasIntoMap(yamlDatas []string) (mapT, error)
- type Cache
- type CacheSpec
- type Config
- type Problem
- func Deserialize(p Problem) (Problem, error)
- func NewConfirmProblem(probid, desc string, hints []string, def bool, ...) (Problem, error)
- func NewInputProblem(probid, desc string, hints []string, def string, ...) (Problem, error)
- func NewMultiSelectProblem(probid, desc string, hints []string, def []string, opts []string, ...) (Problem, error)
- func NewMultilineInputProblem(probid, desc string, hints []string, def string, ...) (Problem, error)
- func NewPasswordProblem(probid, desc string, hints []string, validator func(interface{}) error) (p Problem, err error)
- func NewProblem(p *qagrpc.Problem) (prob Problem, err error)
- func NewSelectProblem(probid, desc string, hints []string, def string, opts []string, ...) (Problem, error)
- func Serialize(p Problem) (Problem, error)
- type QACategory
- type QAMappings
- type QAMappingsSpec
- type SolutionFormType
- type Store
- type ValidationError
Constants ¶
const (
// OtherAnswer - Use as one of the answers, when there is a option to enter the answer in Select Question Type
OtherAnswer = "Other (specify custom option)"
)
const QACacheKind types.Kind = "QACache"
QACacheKind defines kind of QA Cache
const QAMappingsKind = "QAMappings"
QAMappingsKind represents the QAMappings kind
Variables ¶
This section is empty.
Functions ¶
func ArrayToInterface ¶ added in v0.3.0
func ArrayToInterface(ans []string, problemType SolutionFormType) (ansI interface{}, err error)
ArrayToInterface converts the answer array to interface
func GenerateYAMLFromExpression ¶ added in v0.2.0
GenerateYAMLFromExpression generates yaml string from yq syntax expression Example: The expression .foo.bar="abc" gives: foo:
bar: abc
func GetProblemCategories ¶ added in v0.3.12
GetProblemCategories returns the list of categories a particular question belongs to
func InterfaceToArray ¶ added in v0.3.0
func InterfaceToArray(ansI interface{}, problemType SolutionFormType) (ans []string, err error)
InterfaceToArray converts the answer interface to array
func MergeYAMLDatasIntoMap ¶ added in v0.2.0
MergeYAMLDatasIntoMap merges multiple yamls together into a map. Later yamls will override earlier yamls.
Types ¶
type Cache ¶
type Cache struct { types.TypeMeta `yaml:",inline"` types.ObjectMeta `yaml:"metadata,omitempty"` Spec CacheSpec `yaml:"spec,omitempty"` }
Cache stores the answers for reuse
func (*Cache) AddSolution ¶ added in v0.2.0
AddSolution adds a problem to solution cache
func (*Cache) GetSolution ¶
GetSolution reads a solution for the problem
type CacheSpec ¶
type CacheSpec struct { // Problems stores the list of problems with resolutions Problems []Problem `yaml:"solutions"` // contains filtered or unexported fields }
CacheSpec stores the cache data
type Config ¶ added in v0.2.0
type Config struct { OutputPath string // contains filtered or unexported fields }
Config stores the answers in a yaml file
func NewConfig ¶ added in v0.2.0
func NewConfig(outputPath string, configStrings, configFiles []string, persistPasswords bool) (config *Config)
NewConfig creates a new config instance given config strings and paths to config files
func (*Config) AddSolution ¶ added in v0.2.0
AddSolution adds a problem to the config
func (*Config) Get ¶ added in v0.2.0
Get returns the value at the position given by the key in the config
func (*Config) GetSolution ¶ added in v0.2.0
GetSolution reads a solution from the config
type Problem ¶
type Problem struct { ID string `yaml:"id" json:"id"` Type SolutionFormType `yaml:"type,omitempty" json:"type,omitempty"` Desc string `yaml:"description,omitempty" json:"description,omitempty"` Hints []string `yaml:"hints,omitempty" json:"hints,omitempty"` Options []string `yaml:"options,omitempty" json:"options,omitempty"` Default interface{} `yaml:"default,omitempty" json:"default,omitempty"` Answer interface{} `yaml:"answer,omitempty" json:"answer,omitempty"` Validator func(interface{}) error `yaml:"-" json:"-"` Categories []string `yaml:"categories,omitempty" json:"categories,omitempty"` }
Problem defines the QA problem
func Deserialize ¶ added in v0.3.6
Deserialize transforms certain fields of the problem after it gets read from the store.
func NewConfirmProblem ¶
func NewConfirmProblem(probid, desc string, hints []string, def bool, validator func(interface{}) error) (Problem, error)
NewConfirmProblem creates a new instance of confirm problem
func NewInputProblem ¶
func NewInputProblem(probid, desc string, hints []string, def string, validator func(interface{}) error) (Problem, error)
NewInputProblem creates a new instance of input problem
func NewMultiSelectProblem ¶
func NewMultiSelectProblem(probid, desc string, hints []string, def []string, opts []string, validator func(interface{}) error) (Problem, error)
NewMultiSelectProblem creates a new instance of multiselect problem
func NewMultilineInputProblem ¶
func NewMultilineInputProblem(probid, desc string, hints []string, def string, validator func(interface{}) error) (Problem, error)
NewMultilineInputProblem creates a new instance of multiline input problem
func NewPasswordProblem ¶
func NewPasswordProblem(probid, desc string, hints []string, validator func(interface{}) error) (p Problem, err error)
NewPasswordProblem creates a new instance of password problem
func NewProblem ¶ added in v0.3.0
NewProblem creates a new problem object from a GRPC problem
func NewSelectProblem ¶
func NewSelectProblem(probid, desc string, hints []string, def string, opts []string, validator func(interface{}) error) (Problem, error)
NewSelectProblem creates a new instance of select problem
type QACategory ¶ added in v0.3.12
type QACategory struct { Name string `yaml:"name" json:"name"` Enabled bool `yaml:"enabled" json:"enabled"` Questions []string `yaml:"questions" json:"questions"` }
QACategory represents a category of QA engine questions
type QAMappings ¶ added in v0.3.13
type QAMappings struct { types.TypeMeta `yaml:",inline" json:",inline"` types.ObjectMeta `yaml:"metadata,omitempty" json:"metadata,omitempty"` Spec QAMappingsSpec `yaml:"spec" json:"spec"` }
QAMappings defines the structure of the QA Category mapping file
type QAMappingsSpec ¶ added in v0.3.13
type QAMappingsSpec struct {
Categories []QACategory `yaml:"categories" json:"categories"`
}
QAMappingsSpec defines the structure of the QA mapping spec file
type SolutionFormType ¶
type SolutionFormType string
SolutionFormType is the type that defines different types of solutions possible
const ( // SelectSolutionFormType defines a single select solution type SelectSolutionFormType SolutionFormType = "Select" // MultiSelectSolutionFormType defines a multi-select solution type MultiSelectSolutionFormType SolutionFormType = "MultiSelect" // InputSolutionFormType allows single line user input InputSolutionFormType SolutionFormType = "Input" // MultilineInputSolutionFormType allows multiple user input MultilineInputSolutionFormType SolutionFormType = "MultiLineInput" // PasswordSolutionFormType allows password entry PasswordSolutionFormType SolutionFormType = "Password" // ConfirmSolutionFormType allows yes/no answers ConfirmSolutionFormType SolutionFormType = "Confirm" )
type Store ¶ added in v0.2.0
type Store interface { Load() error GetSolution(Problem) (Problem, error) Write() error AddSolution(p Problem) error }
Store helps store answers
type ValidationError ¶ added in v0.3.5
type ValidationError struct {
Reason string
}
ValidationError is the error while validating answer in QA Engine
func (*ValidationError) Error ¶ added in v0.3.5
func (v *ValidationError) Error() string
Error returns the error message as a string.