qaengine

package
v0.2.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package qaengine contains the types used for the question answering part of the CLI.

Index

Constants

View Source
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)"
)
View Source
const QACacheKind types.Kind = "QACache"

QACacheKind defines kind of QA Cache

Variables

This section is empty.

Functions

func GenerateYAMLFromExpression added in v0.2.0

func GenerateYAMLFromExpression(expr string) (string, error)

GenerateYAMLFromExpression generates yaml string from yq syntax expression Example: The expression .foo.bar="abc" gives: foo:

bar: abc

func MergeYAMLDatasIntoMap added in v0.2.0

func MergeYAMLDatasIntoMap(yamlDatas []string) (mapT, error)

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 NewCache

func NewCache(file string) (cache *Cache)

NewCache creates new cache instance

func (*Cache) AddSolution added in v0.2.0

func (cache *Cache) AddSolution(p Problem) error

AddSolution adds a problem to solution cache

func (*Cache) GetSolution

func (cache *Cache) GetSolution(p Problem) (Problem, error)

GetSolution reads a solution for the problem

func (*Cache) Load

func (cache *Cache) Load() error

Load loads and merges cache

func (*Cache) Write

func (cache *Cache) Write() error

Write writes cache to disk

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) (config *Config)

NewConfig creates a new config instance given config strings and paths to config files

func (*Config) AddSolution added in v0.2.0

func (c *Config) AddSolution(p Problem) error

AddSolution adds a problem to the config

func (*Config) Get added in v0.2.0

func (c *Config) Get(key string) (value interface{}, ok bool)

Get returns the value at the position given by the key in the config

func (*Config) GetSolution added in v0.2.0

func (c *Config) GetSolution(p Problem) (Problem, error)

GetSolution reads a solution from the config

func (*Config) Load added in v0.2.0

func (c *Config) Load() (err error)

Load loads and merges config files and strings

func (*Config) Write added in v0.2.0

func (c *Config) Write() error

Write writes the config to disk

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"`
}

Problem defines the QA problem

func NewConfirmProblem

func NewConfirmProblem(probid, desc string, hints []string, def bool) (Problem, error)

NewConfirmProblem creates a new instance of confirm problem

func NewInputProblem

func NewInputProblem(probid, desc string, hints []string, def string) (Problem, error)

NewInputProblem creates a new instance of input problem

func NewMultiSelectProblem

func NewMultiSelectProblem(probid, desc string, hints []string, def []string, opts []string) (Problem, error)

NewMultiSelectProblem creates a new instance of multiselect problem

func NewMultilineInputProblem

func NewMultilineInputProblem(probid, desc string, hints []string, def string) (Problem, error)

NewMultilineInputProblem creates a new instance of multiline input problem

func NewPasswordProblem

func NewPasswordProblem(probid, desc string, hints []string) (p Problem, err error)

NewPasswordProblem creates a new instance of password problem

func NewSelectProblem

func NewSelectProblem(probid, desc string, hints []string, def string, opts []string) (Problem, error)

NewSelectProblem creates a new instance of select problem

func (*Problem) SetAnswer

func (p *Problem) SetAnswer(ansI interface{}) error

SetAnswer sets the answer

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"
	// MultilineSolutionFormType allows multiple user input
	MultilineSolutionFormType SolutionFormType = "MultiLine"
	// 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

Jump to

Keyboard shortcuts

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