Documentation ¶
Index ¶
- Constants
- Variables
- func CompareQuality(a, b *Quality) int
- func CompareQualityProto(ap, bp *pb.Quality) int
- func StepVariableVal(stepVar *StepVariable) cty.Value
- func WithScenarioDecoderDecodeTarget(t DecodeTarget) func(*ScenarioDecoder)
- func WithScenarioDecoderEvalContext(evctx *hcl.EvalContext) func(*ScenarioDecoder)
- func WithScenarioDecoderScenarioFilter(f *ScenarioFilter) func(*ScenarioDecoder)
- type DecodeTarget
- type DecodedMatrices
- type DecodedScenarioBlock
- type DecodedScenarioBlocks
- type Decoder
- type DecoderOpt
- func WithDecoderBaseDir(path string) DecoderOpt
- func WithDecoderDecodeTarget(mode DecodeTarget) DecoderOpt
- func WithDecoderEnv(vars []string) DecoderOpt
- func WithDecoderFPFiles(files RawFiles) DecoderOpt
- func WithDecoderScenarioFilter(filter *ScenarioFilter) DecoderOpt
- func WithDecoderVarFiles(files RawFiles) DecoderOpt
- type Element
- type Exclude
- type FlightPlan
- type Matrix
- func (m *Matrix) AddVector(vec *Vector)
- func (m *Matrix) AddVectorSorted(vec *Vector)
- func (m *Matrix) CartesianProduct() *Matrix
- func (m *Matrix) Compact()
- func (m *Matrix) ContainsVectorUnordered(other *Vector) bool
- func (m *Matrix) Copy() *Matrix
- func (m *Matrix) Equal(other *Matrix) bool
- func (m *Matrix) EqualUnordered(other *Matrix) bool
- func (m *Matrix) Exclude(Excludes ...*Exclude) *Matrix
- func (m *Matrix) Filter(filter *ScenarioFilter) *Matrix
- func (m *Matrix) FromProto(in *pb.Matrix)
- func (m *Matrix) GetVectors() []*Vector
- func (m *Matrix) HasVector(other *Vector) bool
- func (m *Matrix) HasVectorSorted(other *Vector) bool
- func (m *Matrix) HasVectorUnordered(other *Vector) bool
- func (m *Matrix) IntersectionContainsUnordered(other *Matrix) *Matrix
- func (m *Matrix) Proto() *pb.Matrix
- func (m *Matrix) Sort()
- func (m *Matrix) SortVectorElements()
- func (m *Matrix) String() string
- func (m *Matrix) SymmetricDifferenceUnordered(other *Matrix) *Matrix
- func (m *Matrix) Unique() *Matrix
- func (m *Matrix) UniqueValues() *Matrix
- type Module
- type Opt
- type Provider
- type Quality
- type RawFiles
- type Sample
- type SampleFrame
- func (s *SampleFrame) Elements(subsetFrameName string, r *rand.Rand, m *Matrix) ([]*pb.Sample_Element, error)
- func (s *SampleFrame) FilterMax() (int32, error)
- func (s *SampleFrame) FilterMin() (int32, error)
- func (s *SampleFrame) FilterMinMax() (int32, int32, error)
- func (s *SampleFrame) FilterPercentage() (float32, error)
- func (s *SampleFrame) FilterValidate() (bool, error)
- func (s *SampleFrame) Keys() []string
- func (s *SampleFrame) Ref() *pb.Ref_Sample
- func (s *SampleFrame) Size() int32
- func (s *SampleFrame) Validate() error
- type SampleObservation
- type SampleObservationFunc
- type SampleObservationOpt
- func WithSampleObservationReqFilter(f *pb.Sample_Filter) SampleObservationOpt
- func WithSampleObservationReqFunc(m SampleObservationFunc) SampleObservationOpt
- func WithSampleObservationReqRandSeed(seed int64) SampleObservationOpt
- func WithSampleObservationReqWorkSpace(ws *pb.Workspace) SampleObservationOpt
- type SampleObservationReq
- type SampleSubset
- type SampleSubsetFrame
- type SampleSubsetFrames
- type SampleSubsetObservation
- type SampleSubsetObservations
- type SampleValidationOpt
- type SampleValidationReq
- type Scenario
- type ScenarioDecoder
- type ScenarioDecoderOpt
- type ScenarioFilter
- type ScenarioFilterOpt
- func WithScenarioFilterDecode(filter *pb.Scenario_Filter) ScenarioFilterOpt
- func WithScenarioFilterFromSampleSubset(subset *SampleSubset) ScenarioFilterOpt
- func WithScenarioFilterFromScenarioRef(ref *pb.Ref_Scenario) ScenarioFilterOpt
- func WithScenarioFilterMatchingVariants(vec *Vector) ScenarioFilterOpt
- func WithScenarioFilterName(name string) ScenarioFilterOpt
- func WithScenarioFilterParse(args []string) ScenarioFilterOpt
- func WithScenarioFilterSelectAll() ScenarioFilterOpt
- type ScenarioOutput
- type ScenarioStep
- type SchemalessBlock
- type StepVariable
- type TerraformCLI
- type TerraformSetting
- type TerraformSettingBackend
- type Variable
- type VariableValue
- type VariableValueSource
- type Vector
- func (v *Vector) Add(e Element)
- func (v *Vector) ContainsUnordered(other *Vector) bool
- func (v *Vector) Copy() *Vector
- func (v *Vector) CtyVal() cty.Value
- func (v *Vector) Elements() []Element
- func (v *Vector) Equal(other *Vector) bool
- func (v *Vector) EqualUnordered(other *Vector) bool
- func (v *Vector) Proto() *pb.Matrix_Vector
- func (v *Vector) Sort()
- func (v *Vector) String() string
Constants ¶
const ( DecodeTargetUnset = iota DecodeTargetVariables DecodeTargetGlobals DecodeTargetSamples DecodeTargetQualities DecodeTargetScenariosNamesNoVariants DecodeTargetScenariosMatrixOnly DecodeTargetScenariosNamesExpandVariants DecodeTargetTerraformSettings DecodeTargetTerraformCLIs DecodeTargetProviders DecodeTargetModules DecodeTargetScenariosOutlines DecodeTargetScenariosComplete DecodeTargetAll // Make sure this is always the latest decoding target )
const EnvVarPrefix = "ENOS_VAR_"
Variables ¶
var ( FlightPlanFileNamePattern = regexp.MustCompile(`^enos[-\w]*?\.hcl$`) VariablesNamePattern = regexp.MustCompile(`^enos[-\w]*?\.vars\.hcl$`) )
FlightPlanFileNamePattern is what file names match valid enos configuration files.
var StepVariableType cty.Type
StepVariableType is a cty capsule type that represents "step" variables. Step variables might be known values or unknown references to module outputs. Due to the complex nature of these values we have our cty Type to carry this information for us.
Functions ¶
func CompareQuality ¶
CompareQuality implements a slices.SortFunc for Quality's.
func CompareQualityProto ¶
CompareQuality implements a slices.SortFunc for pb.Quality's.
func StepVariableVal ¶
func StepVariableVal(stepVar *StepVariable) cty.Value
StepVariableVal returns a new cty.Value of type StepVariableType.
func WithScenarioDecoderDecodeTarget ¶
func WithScenarioDecoderDecodeTarget(t DecodeTarget) func(*ScenarioDecoder)
WithScenarioDecoderDecodeTarget sets the desired target level for the scenario decoder.
func WithScenarioDecoderEvalContext ¶
func WithScenarioDecoderEvalContext(evctx *hcl.EvalContext) func(*ScenarioDecoder)
WithScenarioDecoderEvalContext sets the parent hcl.EvalContext for the decoder.
func WithScenarioDecoderScenarioFilter ¶
func WithScenarioDecoderScenarioFilter(f *ScenarioFilter) func(*ScenarioDecoder)
WithScenarioDecoderScenarioFilter sets the decoders scenario filter.
Types ¶
type DecodeTarget ¶
type DecodeTarget int
DecodeTarget determines the depth of flight plan decoding so we only ever decode, expand and validate information relevant to our operation.
type DecodedMatrices ¶
type DecodedMatrices struct { Original *Matrix IncludeProducts []*Matrix Excludes []*Exclude FinalProduct *Matrix }
func (*DecodedMatrices) Filter ¶
func (d *DecodedMatrices) Filter(f *ScenarioFilter) *Matrix
func (*DecodedMatrices) GetExcludes ¶ added in v0.0.29
func (d *DecodedMatrices) GetExcludes() []*Exclude
func (*DecodedMatrices) GetIncludeProducts ¶ added in v0.0.29
func (d *DecodedMatrices) GetIncludeProducts() []*Matrix
func (*DecodedMatrices) GetOriginal ¶ added in v0.0.29
func (d *DecodedMatrices) GetOriginal() *Matrix
func (*DecodedMatrices) Matrix ¶
func (d *DecodedMatrices) Matrix() *Matrix
func (*DecodedMatrices) Set ¶
func (d *DecodedMatrices) Set(m *Matrix)
type DecodedScenarioBlock ¶
type DecodedScenarioBlock struct { Name string Block *hcl.Block EvalContext *hcl.EvalContext DecodeTarget DecodeTarget Scenarios []*Scenario Diagnostics hcl.Diagnostics DecodedMatrices *DecodedMatrices }
DecodedScenarioBlock is a decoded scenario block.
func (*DecodedScenarioBlock) Matrix ¶
func (d *DecodedScenarioBlock) Matrix() *Matrix
type DecodedScenarioBlocks ¶
type DecodedScenarioBlocks []*DecodedScenarioBlock
DecodedScenarioBlocks are all of the scenario blocks that have been decoded.
func (DecodedScenarioBlocks) CombinedMatrix ¶
func (d DecodedScenarioBlocks) CombinedMatrix() *Matrix
CombinedMatrix returns a combined matrix of all scenario blocks matrices. Uniqueness is by values.
func (DecodedScenarioBlocks) Diagnostics ¶
func (d DecodedScenarioBlocks) Diagnostics() hcl.Diagnostics
func (DecodedScenarioBlocks) Scenarios ¶
func (d DecodedScenarioBlocks) Scenarios() []*Scenario
Scenarios returns all of the scenarios that were decoded.
type Decoder ¶
type Decoder struct { FPParser *hclparse.Parser VarsParser *hclparse.Parser // contains filtered or unexported fields }
Decoder is our Enos flight plan, or, our representation of the HCL file(s) an author has composed.
func NewDecoder ¶
func NewDecoder(opts ...DecoderOpt) (*Decoder, error)
NewDecoder takes functional options and returns a new flight plan.
func (*Decoder) Decode ¶
func (d *Decoder) Decode(ctx context.Context) (*FlightPlan, hcl.Diagnostics)
Decode decodes the HCL into a flight plan.
func (*Decoder) Parse ¶
func (d *Decoder) Parse() hcl.Diagnostics
Parse locates enos configuration files and parses them.
type DecoderOpt ¶
DecoderOpt is a functional option for a new flight plan.
func WithDecoderBaseDir ¶
func WithDecoderBaseDir(path string) DecoderOpt
WithDecoderBaseDir sets the flight plan base directory.
func WithDecoderDecodeTarget ¶
func WithDecoderDecodeTarget(mode DecodeTarget) DecoderOpt
WithDecoderDecodeTarget sets the decoding mode.
func WithDecoderEnv ¶
func WithDecoderEnv(vars []string) DecoderOpt
WithDecoderEnv sets flight plan variables from env vars.
func WithDecoderFPFiles ¶
func WithDecoderFPFiles(files RawFiles) DecoderOpt
WithDecoderFPFiles sets the flight plan contents as raw bytes.
func WithDecoderScenarioFilter ¶
func WithDecoderScenarioFilter(filter *ScenarioFilter) DecoderOpt
WithDecoderScenarioFilter sets the scenario decoding filter.
func WithDecoderVarFiles ¶
func WithDecoderVarFiles(files RawFiles) DecoderOpt
WithDecoderVarFiles sets the flight plan variable contents as raw bytes.
type Element ¶
An Element represents a single element of a matrix vector.
func NewElement ¶
NewElement takes an element key and value and returns a new Element.
func (Element) Proto ¶
func (e Element) Proto() *pb.Matrix_Element
Proto returns the element as a proto message.
type Exclude ¶
type Exclude struct { Mode pb.Matrix_Exclude_Mode Vector *Vector }
Exclude is an exclusion filter that can be passed to the matrix. It includes the exclusion mode to use and a matching vector.
func NewExclude ¶
func NewExclude(mode pb.Matrix_Exclude_Mode, vec *Vector) (*Exclude, error)
NewExclude takes an ExcludeMode and Vector, validates the ExcludeMode and returns a pointer to a new instance of Exclude and any errors encountered.
func (*Exclude) FromProto ¶
func (ex *Exclude) FromProto(pfe *pb.Matrix_Exclude)
FromProto unmarshals a proto Matrix_Exclude into itself.
func (*Exclude) Proto ¶
func (ex *Exclude) Proto() *pb.Matrix_Exclude
Proto returns the exclude as a proto message.
type FlightPlan ¶
type FlightPlan struct { BaseDir string BodyContent *hcl.BodyContent Files map[string]*hcl.File Modules []*Module Providers []*Provider Qualities []*Quality TerraformSettings []*TerraformSetting TerraformCLIs []*TerraformCLI Samples []*Sample ScenarioBlocks DecodedScenarioBlocks }
FlightPlan represents our flight plan, the main configuration of Enos.
func DecodeProto ¶
func DecodeProto( ctx context.Context, pfp *pb.FlightPlan, target DecodeTarget, f *pb.Scenario_Filter, ) (*FlightPlan, *pb.DecodeResponse)
DecodeProto takes a wire request of a FlightPlan and returns a new flight plan and a wire encodable decode response.
func NewFlightPlan ¶
func NewFlightPlan(opts ...Opt) (*FlightPlan, error)
NewFlightPlan returns a new instance of a FlightPlan.
func (*FlightPlan) Scenarios ¶
func (fp *FlightPlan) Scenarios() []*Scenario
func (*FlightPlan) ScenariosSelect ¶
func (fp *FlightPlan) ScenariosSelect(f *ScenarioFilter) []*Scenario
ScenariosSelect takes a scenario filter and returns a slice of matching scenarios.
type Matrix ¶
type Matrix struct {
Vectors []*Vector
}
Matrix is an ordered list of vectors. Vectors can be of any length. A matrix can be irregular if different length vectors are used.
func (*Matrix) AddVectorSorted ¶
AddVectorSorted adds a sorted Vector to a sorted Matrix.
func (*Matrix) CartesianProduct ¶
CartesianProduct returns a pointer to a new Matrix whose Vectors are the Cartesian product of combining all possible Vector Elements from the Matrix.
func (*Matrix) Compact ¶
func (m *Matrix) Compact()
Compact removes duplicate Vectors from a Matrix.
func (*Matrix) ContainsVectorUnordered ¶
ContainsVectorUnordered returns whether or not a matrix has a Vector whose unordered values contain those of the other Vector.
func (*Matrix) EqualUnordered ¶
EqualUnordered returns true if the Matrix and other Matrix have equal but unordered verticies.
func (*Matrix) Exclude ¶
Exclude takes exclude vararg exclude directives as instances of Exclude. It returns a new Matrix with all Exclude directives having been processed on the parent Matrix.
func (*Matrix) Filter ¶
func (m *Matrix) Filter(filter *ScenarioFilter) *Matrix
Filter takes a CcenarioFilter returns a new filtered Matrix.
func (*Matrix) FromProto ¶
FromProto takes a proto representation of a Matrix and unmarshals it into itself.
func (*Matrix) GetVectors ¶
GetVectors is an accessor for the vectors.
func (*Matrix) HasVector ¶
HasVector returns whether or not a Matrix has a Vector that exactly matches the Elements of another that is given.
func (*Matrix) HasVectorSorted ¶
HasVectorSorted returns whether or not a sorted Matrix has a sorted Vector. It assumes the Matrix and Vector have both already been sorted.
func (*Matrix) HasVectorUnordered ¶
HasVectorUnordered returns whether or not a Matrix has a Vector whose unordered values match exactly with another that is given.
func (*Matrix) IntersectionContainsUnordered ¶
IntersectionContainsUnordered takes another Matrix and returns a new Matrix whose Vectors are composed of the result of a intersection of both matrices vector elements that are contained and unordered. It's important to note that contains does not mean equal, so a vector [1,2,3] contains [3,1] but a vector of [3,1] does not contain [1,2,3] because it doesn't have all of the elements.
func (*Matrix) Proto ¶
Proto returns the Matrix as a proto message. If a Matrix is created with a ScenarioFilter that has Includes and Excludes a round trip is lossy and will only retain the Vectors.
func (*Matrix) SortVectorElements ¶
func (m *Matrix) SortVectorElements()
SortVectorElements sorts all the elements of each Vector.
func (*Matrix) SymmetricDifferenceUnordered ¶
SymmetricDifferenceUnordered returns a new Matrix that includes the symmetric difference between two matrices of unordered vertices.
func (*Matrix) UniqueValues ¶
UniqueValues returns a new Matrix with all Vectors that have unique values.
type Module ¶
Module represents an Enos Terraform module block.
func (*Module) FromCtyValue ¶
FromCtyValue takes a cty.Value and unmarshals it onto itself. It expects a valid object created from ToCtyValue().
func (*Module) ToCtyValue ¶
ToCtyValue returns the module contents as an object cty.Value. We can then embed this into the Variables section of the eval context to allowed method style expression references.
type Opt ¶
type Opt func(*FlightPlan) error
Opt is a flight plan option.
func WithFlightPlanBaseDirectory ¶
WithFlightPlanBaseDirectory sets the base directory to the absolute path of the directory given.
type Provider ¶
type Provider struct { Type string `cty:"type"` Alias string `cty:"alias"` Config *SchemalessBlock `cty:"config"` }
Provider is a Enos transport configuration.
func (*Provider) FromCtyValue ¶
FromCtyValue takes a cty.Value and unmarshals it onto itself. It expects a valid object created from ToCtyValue().
func (*Provider) ToCtyValue ¶
ToCtyValue returns the provider contents as an object cty.Value.
type Quality ¶
Quality represents an Enos Terraform quality block.
func (*Quality) FromCtyValue ¶
FromCtyValue takes a cty.Value and unmarshals it onto itself. It expects a valid object created from ToCtyValue().
func (*Quality) ToCtyValue ¶
ToCtyValue returns the quality contents as an object cty.Value. We can then embed this into the quality section of the eval context to allowed method style expression references.
type RawFiles ¶
RawFiles are a map of flightplan configuration files and their contents.
func FindRawFiles ¶
FindRawFiles scans a directory for files matching the given pattern and returns the loaded raw files.
func LoadRawFiles ¶
LoadRawFiles takes a slice of paths and returns the loaded raw files.
type Sample ¶
type Sample struct { Name string Attributes cty.Value Subsets []*SampleSubset }
A sample is named collection of subsets and attributes.
func (*Sample) Decode ¶
func (s *Sample) Decode(block *hcl.Block, ctx *hcl.EvalContext) hcl.Diagnostics
Decode decodes a sample from an HCL block and eval context.
func (*Sample) Frame ¶
func (s *Sample) Frame( ctx context.Context, ws *pb.Workspace, filter *pb.Sample_Filter, ) ( *SampleFrame, *pb.DecodeResponse, )
Frame takes a context, workspace, and sample filter and decodes and filters a matching field.
type SampleFrame ¶
type SampleFrame struct { *Sample Filter *pb.Sample_Filter SubsetFrames SampleSubsetFrames }
A sample field is a collection of subset fields one-or-more subsets.
func (*SampleFrame) Elements ¶
func (s *SampleFrame) Elements(subsetFrameName string, r *rand.Rand, m *Matrix) ([]*pb.Sample_Element, error)
Elements takes a SubsetFrames name, a random number source, and optionally a matrix whose vertices refer elements in the sample subset frame to include. If no matrix is given the entire subset frame will be returned.
func (*SampleFrame) FilterMax ¶
func (s *SampleFrame) FilterMax() (int32, error)
func (*SampleFrame) FilterMin ¶
func (s *SampleFrame) FilterMin() (int32, error)
func (*SampleFrame) FilterMinMax ¶
func (s *SampleFrame) FilterMinMax() (int32, int32, error)
func (*SampleFrame) FilterPercentage ¶
func (s *SampleFrame) FilterPercentage() (float32, error)
func (*SampleFrame) FilterValidate ¶
func (s *SampleFrame) FilterValidate() (bool, error)
FilterValidate compares the sample frame with our filter configuration settings. It returns a boolean if we should return the entire frame. It will raise an error if our frame is unable to meet out filter configuration.
func (*SampleFrame) Keys ¶
func (s *SampleFrame) Keys() []string
func (*SampleFrame) Ref ¶
func (s *SampleFrame) Ref() *pb.Ref_Sample
func (*SampleFrame) Size ¶
func (s *SampleFrame) Size() int32
func (*SampleFrame) Validate ¶ added in v0.0.29
func (s *SampleFrame) Validate() error
Validate validates the sample frame by ensuring that at least one subset frame exists and is valid.
type SampleObservation ¶
type SampleObservation struct { *SampleFrame // The sample frame that was used to create the observation SubsetObservations SampleSubsetObservations }
SampleObservation is a result of taking an algorithmic observation of a sample frame. Each subset is represented by a matrix whose vertices correspond to the sampled elements.
func SampleFuncAll ¶
func SampleFuncAll(ctx context.Context, frame *SampleFrame, r *rand.Rand) (*SampleObservation, error)
SampleFuncAll takes a sample frame and returns all of the subsets elements as the observation. If the frame filter is not compatible with returning all an error will be returned.
func SampleFuncPurposiveStratified ¶
func SampleFuncPurposiveStratified(ctx context.Context, frame *SampleFrame, r *rand.Rand) (*SampleObservation, error)
SampleFuncPurposiveStratified takes a sample frame and random number generator and returns a new sample observation. We're purposive (or judgemental) in that our algorithm will prefer that each subset is represented before doing a stratified distribution by proportion. If there are any remainders after our purposive and stratified distributions then we'll distribute remaining elements across subsets evenly by order of subset remaining capacity.
func (*SampleObservation) Elements ¶
func (s *SampleObservation) Elements(r *rand.Rand) ([]*pb.Sample_Element, error)
Elements takes a random source, expands all of the sample elements in all frames, and returns the elements in the wire format.
func (*SampleObservation) Size ¶
func (s *SampleObservation) Size() int32
Size is the length of the our SubsetObservations.
type SampleObservationFunc ¶
type SampleObservationFunc func(context.Context, *SampleFrame, *rand.Rand) (*SampleObservation, error)
SampleObservationFunc takes a context, a sample frame, and a random number source and returns a SampleObservation.
type SampleObservationOpt ¶
type SampleObservationOpt func(*SampleObservationReq)
SampleObservationOpt is a functional option for a NewSampleObservationReq.
func WithSampleObservationReqFilter ¶
func WithSampleObservationReqFilter(f *pb.Sample_Filter) SampleObservationOpt
func WithSampleObservationReqFunc ¶
func WithSampleObservationReqFunc(m SampleObservationFunc) SampleObservationOpt
func WithSampleObservationReqRandSeed ¶
func WithSampleObservationReqRandSeed(seed int64) SampleObservationOpt
func WithSampleObservationReqWorkSpace ¶
func WithSampleObservationReqWorkSpace(ws *pb.Workspace) SampleObservationOpt
type SampleObservationReq ¶
type SampleObservationReq struct { Ws *pb.Workspace Filter *pb.Sample_Filter Func SampleObservationFunc Rand *rand.Rand }
SampleObservationReq is a request to take an observation of a sample set.
func NewSampleObservationReq ¶
func NewSampleObservationReq(opts ...SampleObservationOpt) (*SampleObservationReq, error)
NewSampleObservationReq takes optional NewSampleObservationOpt's and returns a new SampleObservationReq. Some validation is performed to ensure a valid request but not all validation can happen until the observation request is executed.
func (*SampleObservationReq) Frame ¶
func (s *SampleObservationReq) Frame(ctx context.Context) (*SampleFrame, *pb.DecodeResponse)
Frame returns the valid sample Frame.
func (*SampleObservationReq) Observe ¶
func (s *SampleObservationReq) Observe(ctx context.Context) (*pb.Sample_Observation, *pb.DecodeResponse)
Observe returns a sample observation.
type SampleSubset ¶
type SampleSubset struct { Name string SampleName string ScenarioName string ScenarioFilter string Attributes cty.Value Matrix *Matrix }
SampleSubset is a subset of samples.
func NewSampleSubset ¶
func NewSampleSubset() *SampleSubset
NewSampleSubset returns a new SampleSubset.
func (*SampleSubset) Frame ¶
func (s *SampleSubset) Frame(ctx context.Context, ws *pb.Workspace) (*SampleSubsetFrame, *pb.DecodeResponse)
Frame takes a context and workspace and decodes and filters the samples scenario matrix into a frame.
type SampleSubsetFrame ¶
type SampleSubsetFrame struct { *SampleSubset ScenarioFilter *pb.Scenario_Filter *Matrix }
SampleSubsetFrame is filtered frame of a subset.
func (*SampleSubsetFrame) ObserveSimpleRandom ¶
func (s *SampleSubsetFrame) ObserveSimpleRandom(take int32, r *rand.Rand) (*SampleSubsetObservation, error)
ObserveSimpleRandom takes a sample size and a randomness source and returns a sample subset observation from the sample subset using a simple random sampling strategy.
func (*SampleSubsetFrame) Ref ¶
func (s *SampleSubsetFrame) Ref() *pb.Ref_Sample_Subset
Ref converts our frame to a wire reference. As it only refers to a frame it is lossy.
func (*SampleSubsetFrame) Size ¶
func (s *SampleSubsetFrame) Size() int32
Size returns the total size of elements in the frame.
func (*SampleSubsetFrame) Validate ¶ added in v0.0.29
func (s *SampleSubsetFrame) Validate() error
Validate that a sample frame is capable of being used to sample from.
type SampleSubsetFrames ¶
type SampleSubsetFrames map[string]*SampleSubsetFrame // subset name -> subset frame
SampleSubsetFrames are a collection from one-or-more named subset frames.
func (SampleSubsetFrames) Size ¶
func (s SampleSubsetFrames) Size() int32
Size returns the total size of elements in the frame.
type SampleSubsetObservation ¶
type SampleSubsetObservation struct { *SampleSubsetFrame *Matrix }
SampleSubsetObservation is an obserservation of a sample subset frame.
func (*SampleSubsetObservation) Size ¶
func (s *SampleSubsetObservation) Size() int32
Size is the size of the sample subset observation.
type SampleSubsetObservations ¶
type SampleSubsetObservations map[string]*SampleSubsetObservation
SampleSubsetObservations are a map of subsets to their observations.
func (SampleSubsetObservations) Keys ¶
func (s SampleSubsetObservations) Keys() []string
Keys are sorted keys of the subset obserservation.
func (SampleSubsetObservations) Size ¶
func (s SampleSubsetObservations) Size() int32
Size is the size of all sample subset observations.
type SampleValidationOpt ¶ added in v0.0.29
type SampleValidationOpt func(*SampleValidationReq)
SampleValidationOpt is a functional option for a NewSampleValidationReq.
func WithSampleValidationReqFilter ¶ added in v0.0.29
func WithSampleValidationReqFilter(f *pb.Sample_Filter) SampleValidationOpt
func WithSampleValidationReqWorkSpace ¶ added in v0.0.29
func WithSampleValidationReqWorkSpace(ws *pb.Workspace) SampleValidationOpt
func WithSampleValidationWorkerCount ¶ added in v0.0.29
func WithSampleValidationWorkerCount(c int) SampleValidationOpt
type SampleValidationReq ¶ added in v0.0.29
type SampleValidationReq struct { Ws *pb.Workspace Filter *pb.Sample_Filter WorkerCount int }
SampleValidationReq is a request to validate samples decode and have valid sub-frames.
func NewSampleValidationReq ¶ added in v0.0.29
func NewSampleValidationReq(opts ...SampleValidationOpt) (*SampleValidationReq, error)
NewSampleValidationReq takes optional NewSampleValidationOpt's and returns a new SampleValidationReq. Some validation is performed to ensure a valid request but not all validation can happen until the observation request is executed.
func (*SampleValidationReq) Validate ¶ added in v0.0.29
func (s *SampleValidationReq) Validate(ctx context.Context) *pb.DecodeResponse
Validate takes a sample observation request and validates that the sample can be decoded and that there are no empty sub-frames in the sample frame.
type Scenario ¶
type Scenario struct { Name string Description string Variants *Vector TerraformCLI *TerraformCLI TerraformSetting *TerraformSetting Steps []*ScenarioStep Providers []*Provider Outputs []*ScenarioOutput }
Scenario represents an Enos scenario.
func (*Scenario) FromRef ¶
func (s *Scenario) FromRef(ref *pb.Ref_Scenario)
FromRef takes a unmarshals a scenario reference into itself.
func (*Scenario) Match ¶
func (s *Scenario) Match(filter *ScenarioFilter) bool
Match takes a filter and determines whether or not the scenario matches it.
func (*Scenario) Outline ¶
func (s *Scenario) Outline() *pb.Scenario_Outline
Outline returns the scenario as a scenario outline.
type ScenarioDecoder ¶
type ScenarioDecoder struct { *hcl.EvalContext DecodeTarget *ScenarioFilter }
ScenarioDecoder decodes filters and decodes scenario blocks to a desired target level.
func NewScenarioDecoder ¶
func NewScenarioDecoder(opts ...ScenarioDecoderOpt) (*ScenarioDecoder, error)
NewScenarioDecoder takes any number of scenario decoder opts and returns a new scenario decoder. If the scenario decoder has not been configured in a valid way an error will be returned.
func (*ScenarioDecoder) DecodeScenario ¶
func (d *ScenarioDecoder) DecodeScenario( vec *Vector, block *hcl.Block, ) (bool, *Scenario, hcl.Diagnostics)
DecodeScenario configures a child eval context and decodes the scenario.
func (*ScenarioDecoder) DecodeScenarioBlocks ¶
func (d *ScenarioDecoder) DecodeScenarioBlocks(ctx context.Context, blocks []*hcl.Block) DecodedScenarioBlocks
DecodeScenarioBlcoks decodes the "scenario" blocks that are defined in the top-level schem to the target level configured in the decode spec.
type ScenarioDecoderOpt ¶
type ScenarioDecoderOpt func(*ScenarioDecoder)
ScenarioDecoderOpt is a scenario decoder option.
type ScenarioFilter ¶
type ScenarioFilter struct { Name string // The scenario name Include *Vector // A scenanario filter broken include a matrix vector Exclude []*Exclude // Explicit scenario/variant exclusions SelectAll bool // Get all scenarios and variants IntersectionMatrix *Matrix // Like Include but can contain more than one Vector }
ScenarioFilter is a filter for scenarios.
func NewScenarioFilter ¶
func NewScenarioFilter(opts ...ScenarioFilterOpt) (*ScenarioFilter, error)
NewScenarioFilter takes in options and returns a new filter.
func ParseScenarioFilter ¶
func ParseScenarioFilter(args []string) (*ScenarioFilter, error)
ParseScenarioFilter takes command arguments that have been split by spaces and validates that they are composed of a valid scenario filter.
func (*ScenarioFilter) FromProto ¶
func (sf *ScenarioFilter) FromProto(filter *pb.Scenario_Filter)
FromProto unmarshals a proto filter into itself.
func (*ScenarioFilter) FromSampleSubset ¶
func (sf *ScenarioFilter) FromSampleSubset(subset *SampleSubset) error
FromSampleSubset takes a sample subset and returns a scenario filter for it.
func (*ScenarioFilter) FromScenarioRef ¶
func (sf *ScenarioFilter) FromScenarioRef(ref *pb.Ref_Scenario)
FromScenarioRef takes a reference to a scenario and returns a filter for it.
func (*ScenarioFilter) Proto ¶
func (sf *ScenarioFilter) Proto() *pb.Scenario_Filter
Proto returns the scenario filter as a proto filter.
func (*ScenarioFilter) String ¶
func (sf *ScenarioFilter) String() string
String returns the scenario filter as a string.
type ScenarioFilterOpt ¶
type ScenarioFilterOpt func(*ScenarioFilter) error
ScenarioFilterOpt is a scenario filter constructor functional option.
func WithScenarioFilterDecode ¶
func WithScenarioFilterDecode(filter *pb.Scenario_Filter) ScenarioFilterOpt
WithScenarioFilterDecode decodes a filter from a proto Filter.
func WithScenarioFilterFromSampleSubset ¶
func WithScenarioFilterFromSampleSubset(subset *SampleSubset) ScenarioFilterOpt
WithScenarioFilterFromSampleSubset takes a sample subset and returns a filter for it.
func WithScenarioFilterFromScenarioRef ¶
func WithScenarioFilterFromScenarioRef(ref *pb.Ref_Scenario) ScenarioFilterOpt
WithScenarioFilterFromScenarioRef takes a scenario reference and returns a filter for it.
func WithScenarioFilterMatchingVariants ¶
func WithScenarioFilterMatchingVariants(vec *Vector) ScenarioFilterOpt
WithScenarioFilterMatchingVariants makes the filter select only scenarios with variants that match the given values.
func WithScenarioFilterName ¶
func WithScenarioFilterName(name string) ScenarioFilterOpt
WithScenarioFilterName sets the filter name.
func WithScenarioFilterParse ¶
func WithScenarioFilterParse(args []string) ScenarioFilterOpt
WithScenarioFilterParse parses the given filter.
func WithScenarioFilterSelectAll ¶
func WithScenarioFilterSelectAll() ScenarioFilterOpt
WithScenarioFilterSelectAll makes the filter select all.
type ScenarioOutput ¶
ScenarioOutput represents an "output" block in a scenario.
func NewScenarioOutput ¶
func NewScenarioOutput() *ScenarioOutput
NewScenarioOutput returns a new Output.
type ScenarioStep ¶
type ScenarioStep struct { Name string Description string Module *Module Providers map[string]*Provider DependsOn []string Verifies []*Quality Skip bool }
ScenarioStep is a step in an Enos scenario.
func NewScenarioStep ¶
func NewScenarioStep() *ScenarioStep
NewScenarioStep returns a new Scenario step.
type SchemalessBlock ¶
type SchemalessBlock struct { Type string `cty:"type"` Labels []string `cty:"labels"` Attrs map[string]cty.Value `cty:"attrs"` Children []*SchemalessBlock `cty:"blocks"` }
SchemalessBlock is our value on HCL block that has no known schema.
func NewSchemalessBlock ¶
func NewSchemalessBlock() *SchemalessBlock
NewSchemalessBlock takes a block type and any labels and returns a new schemaless block.
func (*SchemalessBlock) Decode ¶
func (s *SchemalessBlock) Decode(block *hcl.Block, ctx *hcl.EvalContext) hcl.Diagnostics
Decode takes in an HCL block and eval context and attempts to decode and evaluate it.
func (*SchemalessBlock) FromCtyValue ¶
func (s *SchemalessBlock) FromCtyValue(val cty.Value) error
FromCtyValue takes a cty.Value and unmarshals it onto itself. It expects a valid object created from ToCtyValue().
func (*SchemalessBlock) ToCtyValue ¶
func (s *SchemalessBlock) ToCtyValue() cty.Value
ToCtyValue returns the schemaless block contents as an object cty.Value.
type StepVariable ¶
StepVariable is the type encapsulated in StepVariableType.
func StepVariableFromVal ¶
func StepVariableFromVal(v cty.Value) (*StepVariable, hcl.Diagnostics)
StepVariableFromVal returns the *StepVariable from a given value.
type TerraformCLI ¶
type TerraformCLI struct { Name string `cty:"name" hcl:"name"` Path string `cty:"path" hcl:"path,optional"` Env map[string]string `cty:"env" hcl:"env,optional"` ConfigVal cty.Value `cty:"config" hcl:"config,optional"` }
TerraformCLI is a Terraform CLI configuration.
func DefaultTerraformCLI ¶
func DefaultTerraformCLI() *TerraformCLI
DefaultTerraformCLI returns a "default" Terraform CLI that attempts to resolve terraform from the system PATH.
func NewTerraformCLI ¶
func NewTerraformCLI() *TerraformCLI
NewTerraformCLI returns a new TerraformCLI.
type TerraformSetting ¶
type TerraformSetting struct { Name string RequiredVersion cty.Value Experiments cty.Value // name, object with source and version RequiredProviders map[string]cty.Value // name, map of attribute names and values ProviderMetas map[string]map[string]cty.Value Backend *TerraformSettingBackend Cloud cty.Value }
TerraformSetting is a terraform settings configuration.
func NewTerraformSetting ¶
func NewTerraformSetting() *TerraformSetting
NewTerraformSetting returns a new TerraformSetting.
func (*TerraformSetting) FromCtyValue ¶
func (t *TerraformSetting) FromCtyValue(val cty.Value) error
FromCtyValue takes a cty.Value and unmasharls the value onto itself. Any errors that are encountered are returned. It is expected that the cty.Value is the cty.Value in the eval context.
func (*TerraformSetting) ToCtyValue ¶
func (t *TerraformSetting) ToCtyValue() cty.Value
ToCtyValue returns the terraform contents as an object cty.Value. We can then embed this into the Variables section of the eval context to allowed method style expression references.
type TerraformSettingBackend ¶
TerraformSettingBackend is the "backend".
func NewTerraformSettingBackend ¶
func NewTerraformSettingBackend() *TerraformSettingBackend
NewTerraformSettingBackend returns a new TerraformSettingBackend.
type Variable ¶
type Variable struct { Name string Description string Sensitive bool Default cty.Value SetValue cty.Value Type cty.Type ConstraintType cty.Type }
Variable represents a "variable" block in a module or file.
type VariableValue ¶
type VariableValue struct { Expr hcl.Expression Range hcl.Range Source VariableValueSource EnvVarRaw string }
VariableValue is a user supplied variable value.
type VariableValueSource ¶
type VariableValueSource int
const ( VariableValueSourceUnknown VariableValueSource = iota VariableValueSourceVarsFile VariableValueSourceEnvVar )
type Vector ¶
type Vector struct {
// contains filtered or unexported fields
}
Vector is an ordered collection of matrix elements.
func NewVector ¶
NewMatrix takes zero-or-more elements and returns a pointer to a new instance of Vector.
func NewVectorFromProto ¶
func NewVectorFromProto(pbv *pb.Matrix_Vector) *Vector
NewVectorFromProto takes a proto filter vector and returns a new Vector.
func (*Vector) ContainsUnordered ¶
ContainsUnordered takes a Vector and determines whether all Elements in the given Vector are represented in the Vector.
func (*Vector) CtyVal ¶
CtyVal returns the vector as a cty.Value. This is lossy as duplicate keys will be overwritten.
func (*Vector) Equal ¶
Equal returns true if both Vectors have Equal values and Equal value ordering.
func (*Vector) EqualUnordered ¶
EqualUnordered returns true if both Vectors have the same Elements but might not be ordered the same. This is useful for Vectors of pairs that do not enforce ordering.
func (*Vector) Proto ¶
func (v *Vector) Proto() *pb.Matrix_Vector
Proto returns the Vector as a proto message.
Source Files ¶
- decoder.go
- eval_context.go
- file_finder.go
- flightplan.go
- matrix.go
- matrix_decoder.go
- module.go
- provider.go
- quality.go
- sample.go
- sample_frame.go
- sample_funcs.go
- sample_observation.go
- sample_subset.go
- sample_subset_frame.go
- sample_validation.go
- scenario.go
- scenario_decoder.go
- scenario_filter.go
- scenario_output.go
- scenario_step.go
- schemaless_block.go
- step_variable.go
- terraform_cli.go
- terraform_setting.go
- variable.go