Documentation ¶
Index ¶
- Constants
- Variables
- func WriteResources(data DomainResources, filepath string) error
- type Domain
- type DomainResources
- type LulaValidation
- func (v *LulaValidation) GetDomainResourcesAsJSON() []byte
- func (v *LulaValidation) RequireExecutionConfirmation() (confirm bool)
- func (v *LulaValidation) RunTests(ctx context.Context, saveResources bool) (*LulaValidationTestReport, error)
- func (v *LulaValidation) Validate(ctx context.Context, opts ...LulaValidationOption) error
- type LulaValidationOption
- func ExecutionAllowed(executionAllowed bool) LulaValidationOption
- func GetResourcesOnly(onlyResources bool) LulaValidationOption
- func Interactive(isInteractive bool) LulaValidationOption
- func WithSpinner(spinner *message.Spinner) LulaValidationOption
- func WithStaticResources(resources DomainResources) LulaValidationOption
- type LulaValidationTest
- type LulaValidationTestChange
- type LulaValidationTestData
- type LulaValidationTestReport
- type LulaValidationTestResult
- type LulaValidationType
- type Provider
- type Result
Constants ¶
const (
LulaValidationWorkDir contextKey = iota
)
Variables ¶
var ( ErrExecutionNotAllowed = errors.New("execution not allowed") ErrDomainGetResources = errors.New("domain GetResources error") ErrProviderEvaluate = errors.New("provider Evaluate error") )
Define base errors for validations
Functions ¶
func WriteResources ¶ added in v0.11.0
func WriteResources(data DomainResources, filepath string) error
WriteResources writes the domain resources to a file or stdout
Types ¶
type Domain ¶ added in v0.2.0
type Domain interface { GetResources(context.Context) (DomainResources, error) IsExecutable() bool }
type DomainResources ¶ added in v0.2.0
type DomainResources map[string]interface{}
type LulaValidation ¶ added in v0.2.0
type LulaValidation struct { // Name of the Validation Name string // UUID of the validation - tied to the component-definition.backmatter UUID string // Provider is the provider that is evaluating the validation Provider *Provider // Domain is the domain that provides the evidence for the validation Domain *Domain // DomainResources is the set of resources that the domain is providing DomainResources *DomainResources // LulaValidationType is the type of validation that is being performed LulaValidationType LulaValidationType // Evaluated is a boolean that represents if the validation has been evaluated Evaluated bool // ValidationTestData is a slice of test data corresponding to the lula validation ValidationTestData []*LulaValidationTestData // Result is the result of the validation Result *Result }
func CreateFailingLulaValidation ¶ added in v0.4.0
func CreateFailingLulaValidation(name string) *LulaValidation
CreateFailingLulaValidation creates a placeholder LulaValidation object that is always failing
func CreatePassingLulaValidation ¶ added in v0.4.0
func CreatePassingLulaValidation(name string) *LulaValidation
CreatePassingLulaValidation creates a placeholder LulaValidation object that is always passing
func (*LulaValidation) GetDomainResourcesAsJSON ¶ added in v0.8.0
func (v *LulaValidation) GetDomainResourcesAsJSON() []byte
Return domain resources as a json []byte
func (*LulaValidation) RequireExecutionConfirmation ¶ added in v0.4.0
func (v *LulaValidation) RequireExecutionConfirmation() (confirm bool)
Check if the validation requires confirmation before possible execution code is run
func (*LulaValidation) RunTests ¶ added in v0.12.0
func (v *LulaValidation) RunTests(ctx context.Context, saveResources bool) (*LulaValidationTestReport, error)
RunTests executes any tests defined in the validation and returns a report of the results
func (*LulaValidation) Validate ¶ added in v0.2.0
func (v *LulaValidation) Validate(ctx context.Context, opts ...LulaValidationOption) error
Perform the validation, and store the result in the LulaValidation struct
type LulaValidationOption ¶ added in v0.3.0
type LulaValidationOption func(*lulaValidationOptions)
func ExecutionAllowed ¶ added in v0.4.0
func ExecutionAllowed(executionAllowed bool) LulaValidationOption
ExecutionAllowed sets the value of the executionAllowed field in the LulaValidation object
func GetResourcesOnly ¶ added in v0.4.0
func GetResourcesOnly(onlyResources bool) LulaValidationOption
RequireExecutionConfirmation is a function that returns a boolean indicating if the validation requires confirmation before execution
func Interactive ¶ added in v0.4.0
func Interactive(isInteractive bool) LulaValidationOption
Interactive is a function that returns a boolean indicating if the validation should be interactive
func WithSpinner ¶ added in v0.4.0
func WithSpinner(spinner *message.Spinner) LulaValidationOption
WithSpinner returns a LulaValidationOption that sets the spinner for the LulaValidation object
func WithStaticResources ¶ added in v0.3.0
func WithStaticResources(resources DomainResources) LulaValidationOption
WithStaticResources sets the static resources for the LulaValidation object
type LulaValidationTest ¶ added in v0.12.0
type LulaValidationTest struct { Name string `json:"name" yaml:"name"` Changes []LulaValidationTestChange `json:"changes" yaml:"changes"` ExpectedResult string `json:"expected-result" yaml:"expected-result"` }
LulaValidationTest is a struct that contains the details of the test performed on the LulaValidation The 'test' is an evaluation of the Provider, comparing the actual result against expected, when provided with a changed input of Domain Resources
func (*LulaValidationTest) ValidateData ¶ added in v0.12.0
func (l *LulaValidationTest) ValidateData() error
ValidateData validates the data in the LulaValidationTest struct
type LulaValidationTestChange ¶ added in v0.12.0
type LulaValidationTestChange struct { Path string `json:"path" yaml:"path"` Type transform.ChangeType `json:"type" yaml:"type"` Value string `json:"value" yaml:"value"` ValueMap map[string]interface{} `json:"value-map" yaml:"value-map"` }
LulaValidationTestChange is a struct that contains the details of the changes that are to be made to the resources for a LulaValidationTest
type LulaValidationTestData ¶ added in v0.12.0
type LulaValidationTestData struct { Test *LulaValidationTest Result *LulaValidationTestResult }
LulaValidationTestData is a struct that contains the details of the test performed on the LulaValidation as well as the result of the test
func (*LulaValidationTestData) ExecuteTest ¶ added in v0.12.0
func (d *LulaValidationTestData) ExecuteTest(ctx context.Context, validation *LulaValidation, resources map[string]interface{}, saveResources bool) (*LulaValidationTestResult, error)
ExecuteTest executes a single LulaValidationTest
type LulaValidationTestReport ¶ added in v0.12.0
type LulaValidationTestReport struct { Name string `json:"name"` TestResults []*LulaValidationTestResult `json:"test-results"` }
LulaValidationTestReport contains the report of all the tests performed on a LulaValidation
func NewLulaValidationTestReport ¶ added in v0.12.0
func NewLulaValidationTestReport(name string) *LulaValidationTestReport
NewLulaValidationTestReport creates a new report for a Lula Validation
func (*LulaValidationTestReport) AddTestResult ¶ added in v0.12.0
func (r *LulaValidationTestReport) AddTestResult(result *LulaValidationTestResult)
func (*LulaValidationTestReport) PrintReport ¶ added in v0.12.0
func (r *LulaValidationTestReport) PrintReport()
func (*LulaValidationTestReport) TestFailed ¶ added in v0.12.0
func (r *LulaValidationTestReport) TestFailed() bool
type LulaValidationTestResult ¶ added in v0.12.0
type LulaValidationTestResult struct { TestName string `json:"test-name"` Pass bool `json:"pass"` Result string `json:"result"` Remarks map[string]string `json:"remarks"` TestResourcesPath string `json:"test-resources-path"` }
LulaValidationTestResult is a struct that contains the details of the results of the test performed on the LulaValidation
type LulaValidationType ¶ added in v0.2.0
type LulaValidationType string
const ( LulaValidationTypeNormal LulaValidationType = "Lula Validation" DefaultLulaValidationType LulaValidationType = LulaValidationTypeNormal )
type Provider ¶ added in v0.2.0
type Provider interface {
Evaluate(DomainResources) (Result, error)
}
type Result ¶
type Result struct { UUID string `json:"uuid" yaml:"uuid"` ControlId string `json:"control-id" yaml:"control-id"` Description string `json:"description" yaml:"description"` Passing int `json:"passing" yaml:"passing"` Failing int `json:"failing" yaml:"failing"` State string `json:"state" yaml:"state"` Observations map[string]string `json:"observations" yaml:"observations"` }
native type for conversion to targeted report format