builders

package
v1.0.37 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRiskAnalyzerFunc = func(s *RiskAnalyzerBuilder) error {
	for _, q := range s.Questions {
		s.Risks[q.ID] = &Risk{}

		a, ok := s.Answers[q.ID]
		if !ok {
			s.Risks[q.ID].NotAnswered = true
			continue
		}

		env := map[string]bool{
			"default": true,
		}

		for _, c := range q.Choices {
			env[string(c.Ref)] = false
		}

		for _, c := range a.Choices {
			env[cast.String(c.Ref)] = true
		}

		for _, r := range q.Risks {
			rule := r.Condition

			program, err := expr.Compile(rule, expr.Env(env))
			if err != nil {
				return err
			}

			output, err := expr.Run(program, env)
			if err != nil {
				return err
			}

			v, ok := output.(bool)
			if !ok {
				return fmt.Errorf("expected bool, got %T", v)
			}

			switch r.Risk {
			case "HIGH_RISK":
				s.Risks[q.ID].High = v
			case "MEDIUM_RISK":
				s.Risks[q.ID].Medium = v
			case "LOW_RISK":
				s.Risks[q.ID].Low = v
			case "NO_RISK":
				s.Risks[q.ID].NoRisk = v
			}

			if v {
				break
			}
		}
	}

	return nil
}

DefaultRiskAnalyzerFunc ... nolint:gocyclo

View Source
var HeadingClasses = map[int]string{
	0: "text-5xl font-bold py-4",
	1: "text-4xl font-bold py-4",
	2: "text-3xl font-bold py-4",
	3: "text-2xl font-bold py-4",
	4: "text-xl font-bold py-4",
	5: "text-lg font-bold py-4",
	6: "text-base font-bold py-4",
}

HeadingClasses ...

Functions

func NewMarkdownBuilder

func NewMarkdownBuilder(opts ...html.Option) render.NodeRenderer

NewMarkdownBuilder ...

Types

type MarkdownBuilder

type MarkdownBuilder struct {
	html.Config
}

MarkdownBuilder ...

func (*MarkdownBuilder) Heading

func (r *MarkdownBuilder) Heading(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error)

Heading ...

func (r *MarkdownBuilder) Link(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error)

Link ...

func (*MarkdownBuilder) List

func (r *MarkdownBuilder) List(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error)

List ...

func (*MarkdownBuilder) ListItem

func (r *MarkdownBuilder) ListItem(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error)

ListItem ...

func (*MarkdownBuilder) Paragraph

func (r *MarkdownBuilder) Paragraph(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error)

Paragraph ...

func (MarkdownBuilder) RegisterFuncs

func (builder MarkdownBuilder) RegisterFuncs(registerer render.NodeRendererFuncRegisterer)

func (*MarkdownBuilder) Table

func (r *MarkdownBuilder) Table(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error)

Table ...

func (*MarkdownBuilder) TaskCheckBox

func (r *MarkdownBuilder) TaskCheckBox(w util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error)

TaskCheckBox ...

type Risk

type Risk struct {
	// High ...
	High bool
	// Medium ...
	Medium bool
	// Low ...
	Low bool
	// NoRisk ...
	NoRisk bool
	// NotApplicable ...
	NotApplicable bool
	// NotAnswered ...
	NotAnswered bool
}

Risk ...

type RiskAnalyzerBuildFunc

type RiskAnalyzerBuildFunc func(*RiskAnalyzerBuilder) error

RiskAnalyzerBuildFunc ...

type RiskAnalyzerBuilder

type RiskAnalyzerBuilder struct {
	Questions map[int]models.Question
	Answers   map[int]models.WorkloadLensQuestionAnswer
	Risks     map[int]*Risk
	Error     error
	// contains filtered or unexported fields
}

RiskAnalyzerBuilder ...

func NewRiskAnalyzerBuilder

func NewRiskAnalyzerBuilder(opts ...RiskAnalyzerBuilderOpt) *RiskAnalyzerBuilder

NewRiskAnalyzerBuilder ...

func (*RiskAnalyzerBuilder) AddAnswers

AddAnswers ...

func (*RiskAnalyzerBuilder) AddQuestions

func (r *RiskAnalyzerBuilder) AddQuestions(questions ...models.Question) *RiskAnalyzerBuilder

AddQuestions ...

func (*RiskAnalyzerBuilder) Build

Build ...

func (*RiskAnalyzerBuilder) TotalAnswers

func (r *RiskAnalyzerBuilder) TotalAnswers() int

TotalAnswers ...

func (*RiskAnalyzerBuilder) TotalHighRisks

func (r *RiskAnalyzerBuilder) TotalHighRisks() int

TotalHighRisks ...

func (*RiskAnalyzerBuilder) TotalLowRisks

func (r *RiskAnalyzerBuilder) TotalLowRisks() int

TotalLowRisks ...

func (*RiskAnalyzerBuilder) TotalMediumRisks

func (r *RiskAnalyzerBuilder) TotalMediumRisks() int

TotalMediumRisks ...

func (*RiskAnalyzerBuilder) TotalNoRisk

func (r *RiskAnalyzerBuilder) TotalNoRisk() int

TotalNoRisk ...

func (*RiskAnalyzerBuilder) TotalNotAnswered

func (r *RiskAnalyzerBuilder) TotalNotAnswered() int

TotalNotAnswered ...

func (*RiskAnalyzerBuilder) TotalNotApplicable

func (r *RiskAnalyzerBuilder) TotalNotApplicable() int

TotalNotApplicable ...

func (*RiskAnalyzerBuilder) TotalQuestions

func (r *RiskAnalyzerBuilder) TotalQuestions() int

TotalQuestions ...

type RiskAnalyzerBuilderOpt

type RiskAnalyzerBuilderOpt func(*RiskAnalyzerBuilder)

RiskAnalyzerBuilderOpt ...

Jump to

Keyboard shortcuts

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