Skip to content

Commit

Permalink
[QT-708] various fixes for larger repositories (#133)
Browse files Browse the repository at this point in the history
This adds a few small quality of life fixes into the enos cli that
become more apparent when working in larger repositories, longer running
scenarios, or syntax issues in scenarios with many variants.

* `enos scenario list` now returns a stream of scenarios rather than a
  single response. Not only does this make listing directories with
  several hundred thousand scenarios possible without changing the gRPC
  message size limits, it actually improves the speed. Since our client
  and server implementation are bundled together, changing this API is
  fine.
* Allow passing in `-gcflags` when compiling enos with `make`. This makes
  it easier to build binaries without optimizations for debugging.
* Increase our default CLI timeout to 1 hour.
* Short circuit validation when we encounter an error diagnostic. This
  makes it so find issues quickly rather than attempting to validate
  everything.
* Fix a panic in scneario outlines when a scenario has no matrices.
* Update Go modules.
* Bump version

Signed-off-by: Ryan Cragun <[email protected]>
  • Loading branch information
ryancragun authored May 1, 2024
1 parent 98c23bb commit 750db2b
Show file tree
Hide file tree
Showing 20 changed files with 1,423 additions and 1,133 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ BUILD_BINARY_PATH=${CURRENT_DIRECTORY}/dist/${BINARY}
REPO=github.com/hashicorp/enos
GO_BUILD_TAGS=-tags osusergo,netgo
GO_LD_FLAGS=-ldflags="-extldflags=-static -X ${REPO}/internal/version.Version=${VERSION} -X ${REPO}/internal/version.GitSHA=${GIT_SHA}"
GO_GC_FLAGS=
GO_GC_FLAGS?=
LINT_OUT_FORMAT?=colored-line-number
BUF_LINT_OUT_FORMAT?=github-actions
GORACE=GORACE=log_path=/tmp/enos-gorace.log
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ require (
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
github.com/zclconf/go-cty v1.14.4
golang.org/x/net v0.22.0
golang.org/x/term v0.18.0
golang.org/x/net v0.24.0
golang.org/x/term v0.19.0
golang.org/x/text v0.14.0
google.golang.org/grpc v1.62.1
google.golang.org/grpc v1.63.2
google.golang.org/protobuf v1.33.0
)

Expand All @@ -49,7 +49,6 @@ require (
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
Expand All @@ -64,13 +63,14 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/tools v0.20.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
22 changes: 20 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNX
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
github.com/skeema/knownhosts v1.2.1 h1:SHWdIUa82uGZz+F+47k8SY4QhhI291cXCpopT1lK2AQ=
github.com/skeema/knownhosts v1.2.1/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
Expand Down Expand Up @@ -200,20 +202,28 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -230,11 +240,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
Expand All @@ -246,11 +260,15 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY=
golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 h1:DujSIu+2tC9Ht0aPNA7jgj23Iq8Ewi5sgkQ++wdvonE=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
Expand Down
3 changes: 2 additions & 1 deletion internal/command/enos/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"golang.org/x/term"

"github.com/hashicorp/enos/internal/client"
"github.com/hashicorp/enos/internal/diagnostics"
"github.com/hashicorp/enos/internal/server"
uipkg "github.com/hashicorp/enos/internal/ui"
"github.com/hashicorp/enos/internal/ui/status"
Expand Down Expand Up @@ -84,7 +85,7 @@ func Execute() {

if ui != nil {
var err2 error
var diagErr *status.ErrDiagnostic
var diagErr *diagnostics.Error
if errors.As(err, &diagErr) {
err2 = ui.ShowDiagnostics(diagErr.Diags)
} else {
Expand Down
2 changes: 1 addition & 1 deletion internal/command/enos/cmd/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func newScenarioCmd() *cobra.Command {
PersistentPostRun: scenarioCmdPostRun,
}

scenarioCmd.PersistentFlags().DurationVar(&scenarioState.timeout, "timeout", 15*time.Minute, "The command timeout")
scenarioCmd.PersistentFlags().DurationVar(&scenarioState.timeout, "timeout", 1*time.Hour, "The command timeout")
scenarioCmd.PersistentFlags().BoolVar(&scenarioState.tfConfig.FailOnWarnings, "fail-on-warnings", false, "Fail immediately if warning diagnostics are created")
scenarioCmd.PersistentFlags().StringVarP(&scenarioState.baseDir, "chdir", "d", "", "Use the given directory as the working directory")
scenarioCmd.PersistentFlags().StringVarP(&scenarioState.outDir, "out", "o", "", "Configure the base directory where generated modules will be created")
Expand Down
24 changes: 23 additions & 1 deletion internal/command/enos/cmd/scenario_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package cmd

import (
"io"

"github.com/spf13/cobra"

"github.com/hashicorp/enos/internal/diagnostics"
Expand Down Expand Up @@ -34,7 +36,7 @@ func runScenarioListCmd(cmd *cobra.Command, args []string) error {
})
}

res, err := rootState.enosConnection.Client.ListScenarios(
stream, err := rootState.enosConnection.Client.ListScenarios(
ctx, &pb.ListScenariosRequest{
Workspace: &pb.Workspace{
Flightplan: scenarioState.protoFp,
Expand All @@ -46,5 +48,25 @@ func runScenarioListCmd(cmd *cobra.Command, args []string) error {
return err
}

res := &pb.ListScenariosResponse{}
for {
msg, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
return err
}

switch val := msg.GetResponse().(type) {
case *pb.EnosServiceListScenariosResponse_Decode:
res.Decode = val.Decode
res.Diagnostics = val.Decode.GetDiagnostics()
case *pb.EnosServiceListScenariosResponse_Scenario:
res.Scenarios = append(res.Scenarios, val.Scenario)
default:
}
}

return ui.ShowScenarioList(res)
}
12 changes: 12 additions & 0 deletions internal/diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ func FromErr(err error) []*pb.Diagnostic {
}}
}

// ToError takes a slice of diagnostics and returns an wrapper error chain.
func ToError(diags ...*pb.Diagnostic) error {
if len(diags) < 1 {
return nil
}

err := NewError()
err.Diags = diags

return err
}

// FromTFJSON takes terraform-json Diagnostics and returns them as proto diagnostics.
func FromTFJSON(in []tfjson.Diagnostic) []*pb.Diagnostic {
if len(in) < 1 {
Expand Down
54 changes: 54 additions & 0 deletions internal/diagnostics/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package diagnostics

import (
"strings"

"github.com/hashicorp/enos/proto/hashicorp/enos/v1/pb"
)

var _ error = (*Error)(nil)

func NewError() *Error {
return &Error{}
}

// Error is an error that can carry diagnostics information.
type Error struct {
Diags []*pb.Diagnostic
DiagStringOpts []StringOpt
Err error
}

// Error returns a joined message from all diagnostics errors.
func (e *Error) Error() string {
if e.Diags == nil {
if e.Err != nil {
return e.Err.Error()
}

return ""
}

msg := strings.Builder{}

if e.Err != nil {
msg.WriteString(e.Err.Error())
}

for _, diag := range e.Diags {
_, _ = msg.WriteString(String(diag, e.DiagStringOpts...))
}

return msg.String()
}

// Unwrap returns the wrapped error.
func (e *Error) Unwrap() error {
return e.Err
}

// SetStringOpts allows configuring the stringer opts on the error. This allows the caller
// to determine the formatting of the error message if diagnostics are preset.
func (e *Error) SetStringOpts(opts ...StringOpt) {
e.DiagStringOpts = opts
}
29 changes: 29 additions & 0 deletions internal/flightplan/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ func (d *Decoder) baseEvalContext() *hcl.EvalContext {
}

// Decode decodes the HCL into a flight plan.
//
//nolint:gocyclop,cyclop // it's a complex func
func (d *Decoder) Decode(ctx context.Context) (*FlightPlan, hcl.Diagnostics) {
diags := hcl.Diagnostics{}

Expand Down Expand Up @@ -338,21 +340,33 @@ func (d *Decoder) Decode(ctx context.Context) (*FlightPlan, hcl.Diagnostics) {
if d.target >= DecodeTargetVariables {
// Decode and validate our variables and add them to the eval context.
diags = diags.Extend(fp.decodeVariables(evalCtx, varsFiles, d.varEnvVars))
if diags != nil && diags.HasErrors() {
return diags
}
}

if d.target >= DecodeTargetGlobals {
// Decode our globals and add them to the eval context.
diags = diags.Extend(fp.decodeGlobals(evalCtx))
if diags != nil && diags.HasErrors() {
return diags
}
}

if d.target >= DecodeTargetSamples {
// Decode to only our samples but does not verify correctness or an intersection with scenarios.
diags = diags.Extend(fp.decodeSamples(evalCtx))
if diags != nil && diags.HasErrors() {
return diags
}
}

if d.target >= DecodeTargetQualities {
// Decode out qualities and add them to the eval context.
diags = diags.Extend(fp.decodeQualities(evalCtx))
if diags != nil && diags.HasErrors() {
return diags
}
}

switch d.target {
Expand All @@ -372,18 +386,30 @@ func (d *Decoder) Decode(ctx context.Context) (*FlightPlan, hcl.Diagnostics) {

if d.target >= DecodeTargetTerraformSettings {
diags = diags.Extend(fp.decodeTerraformSettings(evalCtx))
if diags != nil && diags.HasErrors() {
return diags
}
}

if d.target >= DecodeTargetTerraformCLIs {
diags = diags.Extend(fp.decodeTerraformCLIs(evalCtx))
if diags != nil && diags.HasErrors() {
return diags
}
}

if d.target >= DecodeTargetProviders {
diags = diags.Extend(fp.decodeProviders(evalCtx))
if diags != nil && diags.HasErrors() {
return diags
}
}

if d.target >= DecodeTargetModules {
diags = diags.Extend(fp.decodeModules(evalCtx))
if diags != nil && diags.HasErrors() {
return diags
}
}

// Decode the fewest scenarios possible to generate an outline and return.
Expand All @@ -394,6 +420,9 @@ func (d *Decoder) Decode(ctx context.Context) (*FlightPlan, hcl.Diagnostics) {
if d.target >= DecodeTargetScenariosComplete {
// Decode scenarios and fully validate them.
diags = diags.Extend(fp.decodeScenarios(ctx, evalCtx, d.target, d.filter))
if diags.HasErrors() {
return diags
}
}

if d.target > DecodeTargetAll {
Expand Down
9 changes: 1 addition & 8 deletions internal/flightplan/eval_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,8 @@ func (e *errNotDefinedInCtx) Unwrap() error {
func findEvalContextVariable(name string, baseCtx *hcl.EvalContext) (cty.Value, error) {
var val cty.Value

// Search through the eval context chain until we find a variable that
// matches our name
// Search through the eval context chain until we find a variable that matches our name
for ctx := baseCtx; ctx != nil; ctx = ctx.Parent() {
if ctx == nil {
// We've run out of eval contexts to search so we'll break out and
// return an error
break
}

var ok bool
val, ok = ctx.Variables[name]
if ok {
Expand Down
24 changes: 24 additions & 0 deletions internal/flightplan/matrix_decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ func (d *DecodedMatrices) Matrix() *Matrix {
return d.FinalProduct
}

func (d *DecodedMatrices) GetOriginal() *Matrix {
if d == nil {
return nil
}

return d.Original
}

func (d *DecodedMatrices) GetIncludeProducts() []*Matrix {
if d == nil {
return nil
}

return d.IncludeProducts
}

func (d *DecodedMatrices) GetExcludes() []*Exclude {
if d == nil {
return nil
}

return d.Excludes
}

func (d *DecodedMatrices) Filter(f *ScenarioFilter) *Matrix {
if d == nil || d.FinalProduct == nil {
return nil
Expand Down
Loading

0 comments on commit 750db2b

Please sign in to comment.