From 786a7291bf38e8f85c2a75bb23ddb038e83e350a Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 28 Oct 2020 12:26:37 -0400 Subject: [PATCH] remove unused EvalValidateCount --- terraform/eval_validate.go | 48 -------------------------------------- 1 file changed, 48 deletions(-) diff --git a/terraform/eval_validate.go b/terraform/eval_validate.go index c9f47b1b72..c5daf01efb 100644 --- a/terraform/eval_validate.go +++ b/terraform/eval_validate.go @@ -15,54 +15,6 @@ import ( "github.com/zclconf/go-cty/cty/gocty" ) -// EvalValidateCount is an EvalNode implementation that validates -// the count of a resource. -type EvalValidateCount struct { - Resource *configs.Resource -} - -// TODO: test -func (n *EvalValidateCount) Eval(ctx EvalContext) (interface{}, error) { - var diags tfdiags.Diagnostics - var count int - var err error - - val, valDiags := ctx.EvaluateExpr(n.Resource.Count, cty.Number, nil) - diags = diags.Append(valDiags) - if valDiags.HasErrors() { - goto RETURN - } - if val.IsNull() || !val.IsKnown() { - goto RETURN - } - - err = gocty.FromCtyValue(val, &count) - if err != nil { - // The EvaluateExpr call above already guaranteed us a number value, - // so if we end up here then we have something that is out of range - // for an int, and the error message will include a description of - // the valid range. - rawVal := val.AsBigFloat() - diags = diags.Append(&hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: "Invalid count value", - Detail: fmt.Sprintf("The number %s is not a valid count value: %s.", rawVal, err), - Subject: n.Resource.Count.Range().Ptr(), - }) - } else if count < 0 { - rawVal := val.AsBigFloat() - diags = diags.Append(&hcl.Diagnostic{ - Severity: hcl.DiagError, - Summary: "Invalid count value", - Detail: fmt.Sprintf("The number %s is not a valid count value: count must not be negative.", rawVal), - Subject: n.Resource.Count.Range().Ptr(), - }) - } - -RETURN: - return nil, diags.NonFatalErr() -} - // EvalValidateProvisioner validates the configuration of a provisioner // belonging to a resource. The provisioner config is expected to contain the // merged connection configurations.