qaengine

package
v0.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

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

Index

Constants

View Source
const QACacheKind types.Kind = "QACache"

QACacheKind defines kind of cfcontainerizers

Variables

This section is empty.

Functions

This section is empty.

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

NewCache creates new cache instance

func (*Cache) AddProblemSolutionToCache

func (cache *Cache) AddProblemSolutionToCache(p Problem) bool

AddProblemSolutionToCache adds a problem to solution cache

func (*Cache) GetSolution

func (cache *Cache) GetSolution(p Problem) (ans Problem, err 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 Problem

type Problem struct {
	ID       int          `yaml:"-" json:"id"`
	Desc     string       `yaml:"description" json:"description"`
	Context  []string     `yaml:"context,omitempty" json:"context,omitempty"`
	Solution SolutionForm `yaml:"solution" json:"solution,omitempty"`
	Resolved bool         `yaml:"resolved,omitempty" json:"resolved,omitempty"`
}

Problem defines the QA problem

func NewConfirmProblem

func NewConfirmProblem(desc string, context []string, def bool) (p Problem, err error)

NewConfirmProblem creates a new instance of confirm problem

func NewInputProblem

func NewInputProblem(desc string, context []string, def string) (p Problem, err error)

NewInputProblem creates a new instance of input problem

func NewMultiSelectProblem

func NewMultiSelectProblem(desc string, context []string, def []string, opts []string) (p Problem, err error)

NewMultiSelectProblem creates a new instance of multiselect problem

func NewMultilineInputProblem

func NewMultilineInputProblem(desc string, context []string, def string) (p Problem, err error)

NewMultilineInputProblem creates a new instance of multiline input problem

func NewPasswordProblem

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

NewPasswordProblem creates a new instance of password problem

func NewSelectProblem

func NewSelectProblem(desc string, context []string, def string, opts []string) (p Problem, err error)

NewSelectProblem creates a new instance of select problem

func (*Problem) GetBoolAnswer

func (p *Problem) GetBoolAnswer() (ans bool, err error)

GetBoolAnswer returns a bool as answer if the solution type supports it

func (*Problem) GetSliceAnswer

func (p *Problem) GetSliceAnswer() (ans []string, err error)

GetSliceAnswer returns a slice as answer if the solution type supports it

func (*Problem) GetStringAnswer

func (p *Problem) GetStringAnswer() (ans string, err error)

GetStringAnswer returns a string as answer if the solution type supports it

func (*Problem) SetAnswer

func (p *Problem) SetAnswer(answer []string) error

SetAnswer sets the answer

type SolutionForm

type SolutionForm struct {
	Type    SolutionFormType `yaml:"type" json:"type"`
	Default []string         `yaml:"default,omitempty" json:"default,omitempty"`
	Options []string         `yaml:"options,omitempty" json:"options,omitempty"`
	Answer  []string         `yaml:"answer" json:"answer"`
}

SolutionForm defines the solution

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"
)

Jump to

Keyboard shortcuts

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